FileDocCategorySizeDatePackage
BufferedHeader.javaAPI DocAndroid 1.5 API4213Wed May 06 22:41:10 BST 2009org.apache.http.message

BufferedHeader

public class BufferedHeader extends Object implements Cloneable, FormattedHeader
This class represents a raw HTTP header whose content is parsed 'on demand' only when the header value needs to be consumed.
author
Oleg Kalnichevski
version
$Revision: 604625 $ $Date: 2007-12-16 06:11:11 -0800 (Sun, 16 Dec 2007) $

Fields Summary
private final String
name
Header name.
private final CharArrayBuffer
buffer
The buffer containing the entire header line.
private final int
valuePos
The beginning of the header value in the buffer
Constructors Summary
public BufferedHeader(CharArrayBuffer buffer)
Creates a new header from a buffer. The name of the header will be parsed immediately, the value only if it is accessed.

param
buffer the buffer containing the header to represent
throws
ParseException in case of a parse error


        super();
        if (buffer == null) {
            throw new IllegalArgumentException
                ("Char array buffer may not be null");
        }
        int colon = buffer.indexOf(':");
        if (colon == -1) {
            throw new ParseException
                ("Invalid header: " + buffer.toString());
        }
        String s = buffer.substringTrimmed(0, colon);
        if (s.length() == 0) {
            throw new ParseException
                ("Invalid header: " + buffer.toString());
        }
        this.buffer = buffer;
        this.name = s;
        this.valuePos = colon + 1;
    
Methods Summary
public java.lang.Objectclone()

        // buffer is considered immutable
        // no need to make a copy of it
        return super.clone();
    
public org.apache.http.util.CharArrayBuffergetBuffer()

        return this.buffer;
    
public org.apache.http.HeaderElement[]getElements()

        ParserCursor cursor = new ParserCursor(0, this.buffer.length());
        cursor.updatePos(this.valuePos);
        return BasicHeaderValueParser.DEFAULT
            .parseElements(this.buffer, cursor);
    
public java.lang.StringgetName()

        return this.name;
    
public java.lang.StringgetValue()

        return this.buffer.substringTrimmed(this.valuePos, this.buffer.length());
    
public intgetValuePos()

        return this.valuePos;
    
public java.lang.StringtoString()

        return this.buffer.toString();