Save This Page
Home » commons-httpclient-3.1-src » org.apache.commons » httpclient » [javadoc | source]
org.apache.commons.httpclient
public class: HeaderElement [javadoc | source]
java.lang.Object
   org.apache.commons.httpclient.NameValuePair
      org.apache.commons.httpclient.HeaderElement

All Implemented Interfaces:
    Serializable

One element of an HTTP header's value.

Some HTTP headers (such as the set-cookie header) have values that can be decomposed into multiple elements. Such headers must be in the following form:

header = [ element ] *( "," [ element ] )
element = name [ "=" [ value ] ] *( ";" [ param ] )
param = name [ "=" [ value ] ]

name = token
value = ( token | quoted-string )

token = 1*<any char except "=", ",", ";", <"> and
white space>
quoted-string = <"> *( text | quoted-char ) <">
text = any char except <">
quoted-char = "\" char

Any amount of white space is allowed between any part of the header, element or param and is ignored. A missing value in any element or param will be stored as the empty String ; if the "=" is also missing null will be stored instead.

This class represents an individual header element, containing both a name/value pair (value may be null) and optionally a set of additional parameters.

This class also exposes a #parse method for parsing a Header value into an array of elements.

Constructor:
 public HeaderElement() 
 public HeaderElement(char[] chars) 
 public HeaderElement(String name,
    String value) 
    Constructor.
    Parameters:
    name - my name
    value - my (possibly null) value
 public HeaderElement(String name,
    String value,
    NameValuePair[] parameters) 
    Constructor with name, value and parameters.
    Parameters:
    name - my name
    value - my (possibly null) value
    parameters - my (possibly null) parameters
 public HeaderElement(char[] chars,
    int offset,
    int length) 
Method from org.apache.commons.httpclient.HeaderElement Summary:
getParameterByName,   getParameters,   parse,   parseElements,   parseElements
Methods from org.apache.commons.httpclient.NameValuePair:
equals,   getName,   getValue,   hashCode,   setName,   setValue,   toString
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.httpclient.HeaderElement Detail:
 public NameValuePair getParameterByName(String name) 
    Returns parameter with the given name, if found. Otherwise null is returned
 public NameValuePair[] getParameters() 
    Get parameters, if any.
 public static final HeaderElement[] parse(String headerValue) throws HttpException 
Deprecated! Use - #parseElements(String).

    This parses the value part of a header. The result is an array of HeaderElement objects.
 public static final HeaderElement[] parseElements(char[] headerValue) 
    This parses the value part of a header. The result is an array of HeaderElement objects.
 public static final HeaderElement[] parseElements(String headerValue) 
    This parses the value part of a header. The result is an array of HeaderElement objects.