org.w3c.www.http
Class HttpBag

java.lang.Object
  extended by org.w3c.www.http.BasicValue
      extended by org.w3c.www.http.HttpBag
All Implemented Interfaces:
java.lang.Cloneable, HeaderValue

public class HttpBag
extends BasicValue

Internal representation of protocol headers conforming to the bag spec. The bag specification is part of the Protocol Extension Protocol defined by w3c, it can be found

Field Summary
 
Fields inherited from class org.w3c.www.http.BasicValue
isValid, raw, rlen, roff
 
Method Summary
 void addBag(HttpBag subbag)
          Add a named bag into this bag.
 void addItem(HttpBag subbag)
          Add a sub-bag to this bag.
 void addItem(java.lang.String name)
          Add an item into this bag.
 HttpBag getBag(java.lang.String name)
          Get a named sub-bag from this bag.
 java.lang.String getName()
          Get this bag names
 java.lang.Object getValue()
          HeaderValue implemenntation - Get this header value.
 boolean hasBag(java.lang.String name)
          Does this bag have a named sub-bag of the given name ?
 boolean hasItem(java.lang.String name)
          Does this bag contains the given item, being a bag or a simple word.
 boolean isToplevelBag()
          Is that a top level bag or not ?
 java.util.Enumeration keys()
          Get all named items from this bag.
protected  void parse()
          parse.
protected  HttpBag parseBag(org.w3c.www.http.ParseState ps)
          parse bag.
 void removeItem(java.lang.String name)
          Remove an item from that bag.
protected  void updateByteValue()
          Update the RFC822 compatible header value for this object.
 
Methods inherited from class org.w3c.www.http.BasicValue
addBytes, appendValue, checkByteValue, clone, emit, error, invalidateByteValue, setBytes, setString, toExternalForm, toString, validate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

updateByteValue

protected final void updateByteValue()
Description copied from class: BasicValue
Update the RFC822 compatible header value for this object.

Specified by:
updateByteValue in class BasicValue

parseBag

protected HttpBag parseBag(org.w3c.www.http.ParseState ps)
                    throws HttpParserException
parse bag.

Throws:
HttpParserException - if parsing failed.

parse

protected final void parse()
                    throws HttpParserException
parse.

Specified by:
parse in class BasicValue
Throws:
HttpParserException - if parsing failed.

getValue

public java.lang.Object getValue()
Description copied from class: BasicValue
HeaderValue implemenntation - Get this header value.

Specified by:
getValue in interface HeaderValue
Specified by:
getValue in class BasicValue
Returns:
An object representing the parsed value for this header.

getName

public java.lang.String getName()
Get this bag names

Returns:
The name of this bag.

addBag

public void addBag(HttpBag subbag)
Add a named bag into this bag.

Parameters:
bag - The bag to add (in case item is a bag).

hasBag

public boolean hasBag(java.lang.String name)
Does this bag have a named sub-bag of the given name ?

Parameters:
name - The name of the sub-bag to be tested for.
Returns:
true if this sub-bag exists.

getBag

public HttpBag getBag(java.lang.String name)
Get a named sub-bag from this bag.

Parameters:
name - The name of the sub-bag to get.
Returns:
A bag instance, or null if none was found.

addItem

public void addItem(java.lang.String name)
Add an item into this bag.

Parameters:
name - The new item name.

addItem

public void addItem(HttpBag subbag)
Add a sub-bag to this bag.

Parameters:
subbag - The sub-bag to add.

hasItem

public boolean hasItem(java.lang.String name)
Does this bag contains the given item, being a bag or a simple word.

Parameters:
name - The name of the item to test.
Returns:
true if the bag contains the given item, false otherwise.

removeItem

public void removeItem(java.lang.String name)
Remove an item from that bag.

Parameters:
name - The name of the item to remove.

keys

public java.util.Enumeration keys()
Get all named items from this bag. This include both named sub-bags and items by their own.


isToplevelBag

public boolean isToplevelBag()
Is that a top level bag or not ?

Returns:
A boolean, true if the bag was a toplevel bag.