FileDocCategorySizeDatePackage
CharArrayBuffers.javaAPI DocAndroid 1.5 API2637Wed May 06 22:41:56 BST 2009android.net.http

CharArrayBuffers

public class CharArrayBuffers extends Object
Utility methods for working on CharArrayBuffers. {@hide}

Fields Summary
static final char
uppercaseAddon
Constructors Summary
Methods Summary
static booleancontainsIgnoreCaseTrimmed(org.apache.http.util.CharArrayBuffer buffer, int beginIndex, java.lang.String str)
Returns true if the buffer contains the given string. Ignores leading whitespace and case.

param
buffer to search
param
beginIndex index at which we should start
param
str to search for


                                        
       
                 
        int len = buffer.length();
        char[] chars = buffer.buffer();
        while (beginIndex < len && HTTP.isWhitespace(chars[beginIndex])) {
            beginIndex++;
        }
        int size = str.length();
        boolean ok = len >= beginIndex + size;
        for (int j=0; ok && (j<size); j++) {
            char a = chars[beginIndex+j];
            char b = str.charAt(j);
            if (a != b) {
                a = toLower(a);
                b = toLower(b);
                ok = a == b;
            }
        }
        return ok;
    
static intsetLowercaseIndexOf(org.apache.http.util.CharArrayBuffer buffer, int ch)
Returns index of first occurence ch. Lower cases characters leading up to first occurrence of ch.


        int beginIndex = 0;
        int endIndex = buffer.length();
        char[] chars = buffer.buffer();

        for (int i = beginIndex; i < endIndex; i++) {
            char current = chars[i];
            if (current == ch) {
                return i;
            } else if (current >= 'A" && current <= 'Z"){
                // make lower case
                current += uppercaseAddon;
                chars[i] = current;
            }
        }
        return -1;
    
private static chartoLower(char c)

        if (c >= 'A" && c <= 'Z"){
            c += uppercaseAddon;
        }
        return c;