Package com.volantis.synergetics

Examples of com.volantis.synergetics.NameValuePair


        String result = name;
        // Try the static cache first.
        int index = Arrays.binarySearch(cacheArray, name, comparator);
        if (index >= 0) {
            NameValuePair pair = (NameValuePair)cacheArray[index];

            // If we are converting to lower case use the value, otherwise
            // use the name (which is uppercase).
            result = convertToLowerCase ? pair.getValue() : pair.getName();
            if (logger.isDebugEnabled()) {
                logger.debug("Found local name in static cache: " + name);
            }
        } else {
            NameValuePair pair = findCachedNameValuePair(
                    new CaseInsensitiveName(name));

            if (pair == null) {
                pair = new NameValuePair(name, convertLocalName(name));

                if (logger.isDebugEnabled()) {
                    logger.debug("Adding localName object to dynamic cache: " +
                                 pair);
                }
                dynamicCache.add(pair);
            }
            result = pair.getValue();
        }
        return result;
    }
View Full Code Here


        String result = convertedLocalName;
        if (qName.length() == 0) {
            result = qName;
        } else if (!qName.equalsIgnoreCase(convertedLocalName)) {

            NameValuePair pair = findCachedNameValuePair(qName);

            if (pair == null) {
                pair = new NameValuePair(
                        qName, convertQName(qName, convertedLocalName));

                if (logger.isDebugEnabled()) {
                    logger.debug("Adding qName object to dynamic cache: " +
                                 pair);
                }
                dynamicCache.add(pair);
            }
            result = pair.getValue();
        }
        return result;
    }
View Full Code Here

     *                    name value pair object.
     * @return            the name value pair object, or null if it cannot be
     *                    found in the cache.
     */
    private NameValuePair findCachedNameValuePair(Comparable comparable) {
        NameValuePair result = null;

        int size = dynamicCache.size();
        for (int i = 0; (i < size) && (result == null); i++) {

            NameValuePair nameValuePair = (NameValuePair)dynamicCache.get(i);
            if (comparable.compareTo(nameValuePair.getName()) == 0) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Found object in dynamic cache: " +
                                 nameValuePair);
                }
                result = nameValuePair;
View Full Code Here

     * @param headerName the name of the header to get the value for
     * @return the header value as a String or null if the header doesnt exist
     */
    public String getHeader( String headerName )
    {
        NameValuePair pair = (NameValuePair)headers.get( headerName );
        if( pair == null )
        {
            return null;
        }
        return pair.getValue();
    }
View Full Code Here

            if( first )
            {
                first = !first;
                parseFirstLine( line );
            } else {
                NameValuePair pair = parseHeaderLine( line );
                if( pair != null )
                {
                    headers.put( pair.getName(), pair );
                }  
            }
            line = readNextLine( reader );
            if(logger.isDebugEnabled()){
                logger.debug( "Received header line " + line );
View Full Code Here

        }
       
        int colon = trimmed.indexOf( ':' );
        if( colon > -1 )
        {
            return new NameValuePair( trimmed.substring( 0, colon ),
                                      trimmed.substring( colon + 1 ).trim() );
        } else {
            return new NameValuePair( trimmed, null );
        }
    }
View Full Code Here

        Set keys = headers.keySet();
        Iterator iter = keys.iterator();
        while( iter.hasNext() )
        {
            String key = (String)iter.next();
            NameValuePair pair = (NameValuePair)headers.get(key);
            s = s + "\n" + pair.toString();
        }
        return s;
    }   
View Full Code Here

            operationProcess, "cacheArray");
        assertNotNull(array);

        TreeSet set = new TreeSet(new Comparator() {
            public int compare(Object o1, Object o2) {
                NameValuePair value1 =
                    (NameValuePair) o1;
                NameValuePair value2 =
                    (NameValuePair) o2;

                return value1.getName().compareTo(value2.getName());
            }
        });

        for (int i = 0; i < array.length; i++) {
            set.add(array[i]);
        }
        assertEquals("Set size matches", array.length, set.size());

        int index = 0;
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            NameValuePair o =
                (NameValuePair) iterator.next();

            assertTrue("Static cache is not sorted by name: " + o.getName(),
                       o == array[index]);

            assertEquals("Static cache name is not uppercase: " + o.getName(),
                         o.getName().toUpperCase(),
                         o.getName());

            assertEquals("Static cache value is not lowercase: " + o.getValue(),
                         o.getValue().toLowerCase(),
                         o.getValue());
            ++index;
        }
    }
View Full Code Here

        Set keys = headers.keySet();
        Iterator iter = keys.iterator();
        while( iter.hasNext() )
        {
            String key = (String)iter.next();
            NameValuePair pair = (NameValuePair)headers.get(key);
            String header = pair.getValue();
       
            if ("Location".equalsIgnoreCase(key))
            {
                header = getAbsoluteLocation(header, request);
            }
View Full Code Here

TOP

Related Classes of com.volantis.synergetics.NameValuePair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.