com.ibm.wbi.protocol.http
Class HttpHeaderAscii

java.lang.Object
  |
  +--com.ibm.wbi.protocol.http.HttpHeaderAscii
Direct Known Subclasses:
HttpRequestHeader, HttpResponseHeader

public abstract class HttpHeaderAscii
extends java.lang.Object

HttpHeaderAscii is an abstract class representing a complete HTTP header. Use HttpRequestHeader or HttpResponseHeader to instantiante a header.

See Also:
HttpRequestHeader, HttpResponseHeader

Field Summary
protected  java.lang.String httpVersion
           
protected  MimeHeaderAscii mime
           
protected  boolean stamp
           
 
Constructor Summary
HttpHeaderAscii()
          Construct a new, empty HttpHeaderAscii.
HttpHeaderAscii(byte[] h)
          Construct a new HttpHeaderAscii from the specified bytes representing ASCII characters.
HttpHeaderAscii(byte[] h, int offset, int length)
          Construct a new HttpHeaderAscii from the specified bytes representing ASCII characters.
HttpHeaderAscii(HttpHeaderAscii old)
          Construct a new HttpHeaderAscii that is a copy of an old one.
HttpHeaderAscii(MimeHeaderAscii m)
          Construct a new HttpHeaderAscii with the specified MIME headers.
HttpHeaderAscii(java.lang.String s)
          Construct a new HttpHeaderAscii from the specified String.
 
Method Summary
 void add(java.lang.String key, HeaderField value)
          Set the value for a header field, adding to any previous values.
 void add(java.lang.String key, java.lang.String value)
          Set the value for a header field, adding to any previous values.
 MimeHeaderAscii copyMimeHeader()
          Return a clone of the MIME header fields in this header.
 java.lang.String get(java.lang.String key)
          Get the value of the specified MIME header field.
 java.util.Vector getAll(java.lang.String key)
          Get all values for a header field.
 java.lang.String getMimeHeaderString()
          Get the MIME headers only (not the first HTTP line of the header) as a String.
 java.lang.Object getRaw(java.lang.String key)
          Get the value for a header field.
 java.lang.String getVersion()
          Get the HTTP protocol version string, e.g., "HTTP/1.0".
 java.util.Enumeration keys()
          Return a list of all the header keys in this header.
 java.util.Vector parseAllHeaderFields(java.lang.String key)
          Like parseHeader(String), but returns a Vector of HeaderFields, one per instance of the named header field, even if the header field occurs zero or one times.
 java.util.Vector parseAllSplitHeaderFields(java.lang.String key)
          Calls parseAllSplitHeaderFields(String key, char delim) using the delimiter ",".
 java.util.Vector parseAllSplitHeaderFields(java.lang.String key, char delim)
          Like parseAllHeaderFields(String key)
protected abstract  void parseFirstLine(java.lang.String line)
           
protected  void parseHeader(java.lang.String h)
           
 HeaderField parseHeaderField(java.lang.String key)
          Return the first value of the header field named by key as a parsed HeaderField object.
 boolean remove(java.lang.String key)
          Remove all value(s) for a header field.
 void set(java.lang.String key, HeaderField value)
          Set the value for a header field, replacing any previous value(s).
 void set(java.lang.String key, java.lang.String value)
          Set the value for a header field, replacing any previous value(s).
 void setVersion(java.lang.String v)
          Set the HTTP protocol version string.
 void stamp()
           
 boolean stamped()
           
abstract  java.lang.String toString()
          Returns a String representation of the header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

httpVersion

protected java.lang.String httpVersion

mime

protected MimeHeaderAscii mime

stamp

protected boolean stamp
Constructor Detail

HttpHeaderAscii

public HttpHeaderAscii()
Construct a new, empty HttpHeaderAscii.

HttpHeaderAscii

public HttpHeaderAscii(MimeHeaderAscii m)
Construct a new HttpHeaderAscii with the specified MIME headers.
Parameters:
m - The MIME headers.

HttpHeaderAscii

public HttpHeaderAscii(byte[] h)
                throws MalformedHeaderException
Construct a new HttpHeaderAscii from the specified bytes representing ASCII characters.
Parameters:
h - The header bytes.

HttpHeaderAscii

public HttpHeaderAscii(byte[] h,
                       int offset,
                       int length)
                throws MalformedHeaderException
Construct a new HttpHeaderAscii from the specified bytes representing ASCII characters.
Parameters:
h - The array containing the header bytes.
offset - The offset within the array where the header starts.
length - The number of bytes within the array comprising the header.

HttpHeaderAscii

public HttpHeaderAscii(java.lang.String s)
                throws MalformedHeaderException
Construct a new HttpHeaderAscii from the specified String.
Parameters:
s - The String containing the header text.

HttpHeaderAscii

public HttpHeaderAscii(HttpHeaderAscii old)
Construct a new HttpHeaderAscii that is a copy of an old one.
Parameters:
old - The header to copy.
Method Detail

getVersion

public java.lang.String getVersion()
Get the HTTP protocol version string, e.g., "HTTP/1.0".
Returns:
The protocol version.

setVersion

public void setVersion(java.lang.String v)
Set the HTTP protocol version string.
Parameters:
v - The version string.

getMimeHeaderString

public java.lang.String getMimeHeaderString()
Get the MIME headers only (not the first HTTP line of the header) as a String.
Returns:
The MIME headers as a string.

toString

public abstract java.lang.String toString()
Returns a String representation of the header.
Overrides:
toString in class java.lang.Object
Returns:
The header as a String.

get

public java.lang.String get(java.lang.String key)
Get the value of the specified MIME header field. If the field has more than one value, the first is returned.
Parameters:
key - The name of the header field.
Returns:
A String value for the header field, or null if not set.

getAll

public java.util.Vector getAll(java.lang.String key)
Get all values for a header field.
Parameters:
key - The case-insensitive name of the header field
Returns:
A Vector containing all String values to which the key is mapped, even if zero or one.

getRaw

public java.lang.Object getRaw(java.lang.String key)
Get the value for a header field.
Parameters:
key - The case-insensitive name of the header field
Returns:
null if key is unmapped, or a HeaderField representing the single value to which key is mapped, or the Vector containing the one or more values to which key is mapped.

parseHeaderField

public HeaderField parseHeaderField(java.lang.String key)
Return the first value of the header field named by key as a parsed HeaderField object. If that HeaderField object is modified, then set() must be used to update the header itself: the HeaderField object is a copy, not a reference.
Parameters:
key - The name of the header field.
Returns:
The parsed HeaderField.
See Also:
set(String, HeaderField), HeaderField

parseAllHeaderFields

public java.util.Vector parseAllHeaderFields(java.lang.String key)
Like parseHeader(String), but returns a Vector of HeaderFields, one per instance of the named header field, even if the header field occurs zero or one times.
Parameters:
key - The name of the header field.
Returns:
The Vector of parsed HeaderFields
See Also:
parseHeaderField(String)

parseAllSplitHeaderFields

public java.util.Vector parseAllSplitHeaderFields(java.lang.String key)
Calls parseAllSplitHeaderFields(String key, char delim) using the delimiter ",".
Parameters:
key - the name of the header field.
Returns:
A Vector of HeaderField objects.
See Also:
parseHeaderField(String), parseAllSplitHeaderFields(String, char)

parseAllSplitHeaderFields

public java.util.Vector parseAllSplitHeaderFields(java.lang.String key,
                                                  char delim)
Like parseAllHeaderFields(String key)Accept: a/b, c/d would produce a vector of two HeaderField objects, one representing a/b, the other representing c/d.
Parameters:
key - The name of the header field.
Returns:
A Vector of HeaderField objects.
See Also:
parseHeaderField(String), parseAllHeaderFields(String key)

set

public void set(java.lang.String key,
                java.lang.String value)
Set the value for a header field, replacing any previous value(s).
Parameters:
key - The case-insensitive name of the header field.
value - The new value for the field.

set

public void set(java.lang.String key,
                HeaderField value)
Set the value for a header field, replacing any previous value(s).
Parameters:
key - The case-insensitive name of the header field.
value - The new value for the field.

add

public void add(java.lang.String key,
                java.lang.String value)
Set the value for a header field, adding to any previous values.
Parameters:
key - The case-insensitive name of the header field.
value - The new value to add.

add

public void add(java.lang.String key,
                HeaderField value)
Set the value for a header field, adding to any previous values.
Parameters:
key - The case-insensitive name of the header field.
value - The new value to add.

remove

public boolean remove(java.lang.String key)
Remove all value(s) for a header field.
Parameters:
key - The case-insensitive name of the header field
Returns:
true if all values were removed, false if key already had no value.

keys

public java.util.Enumeration keys()
Return a list of all the header keys in this header.
Returns:
The Enumeration

stamp

public void stamp()

stamped

public boolean stamped()

copyMimeHeader

public MimeHeaderAscii copyMimeHeader()
Return a clone of the MIME header fields in this header.
Returns:
The MIME header fields.

parseHeader

protected void parseHeader(java.lang.String h)
                    throws MalformedHeaderException

parseFirstLine

protected abstract void parseFirstLine(java.lang.String line)
                                throws MalformedHeaderException