org.xlightweb
Interface IHeader

Package class diagram package IHeader
All Known Subinterfaces:
IHttpMessage, IHttpMessageHeader, IHttpRequest, IHttpRequestHeader, IHttpResponse, IHttpResponseHeader, IPart
All Known Implementing Classes:
DeleteRequest, FormURLEncodedRequest, GetRequest, Header, HeadRequest, HttpRequest, HttpRequestHeader, HttpRequestHeaderWrapper, HttpRequestWrapper, HttpResponse, HttpResponseHeader, MultipartFormDataRequest, MultipartRequest, OptionsRequest, Part, PostRequest, PutRequest

public interface IHeader

Header definition


Method Summary
 void addHeader(String headername, String headervalue)
          Adds a header with the given name and value.
 void addHeaderLine(String line)
          adds a raw header line
 void addHeaderlines(String... lines)
          adds raw header lines
 boolean containsHeader(String headername)
          Returns a boolean indicating whether the named header has already been set.
 String getCharacterEncoding()
          Returns the name of the character encoding used in the body of this message.
 String getContentType()
          Returns the MIME type of the body of the messag, or null if the type is not known.
 String getDisposition()
          returns the content disposition header of the part, or null if the type is not known.
 String getDispositionParam(String name)
          returns the content disposition param value or null if not set

see also rfc2183
 String getDispositionType()
          returns the content disposition type or null if not set

see also rfc2183
 String getHeader(String headername)
          Returns the value of the specified header as a String.
 String getHeader(String headername, String dfltValue)
          Returns the value of the specified header as a String.
 List<String> getHeaderList(String headername)
          Returns all the values of the specified header as an List of String objects.
 Enumeration getHeaderNames()
          Returns an enumeration of all the header names.
 Set<String> getHeaderNameSet()
          Returns an set of all the header names.
 Enumeration getHeaders(String headername)
          Returns all the values of the specified header as an Enumeration of String objects.
 String getTransferEncoding()
          returns the Transfer-Encoding header parameter or null if the header is not set
 void removeHeader(String headername)
          removes a header with the given name
 void setContentType(String type)
          sets the MIME type of the body of the part
 void setHeader(String headername, String headervalue)
          Sets a header with the given name and value.
 void setTransferEncoding(String transferEncoding)
          sets the Transfer-Encoding parameter
 

Method Detail

addHeader

void addHeader(String headername,
               String headervalue)
Adds a header with the given name and value. This method allows headers to have multiple values.

Parameters:
headername - the name of the header
headervalue - the additional header value. If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)

setHeader

void setHeader(String headername,
               String headervalue)
Sets a header with the given name and value. If the header had already been set, the new value overwrites the previous one.

Parameters:
headername - the name of the header
headervalue - the header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)

removeHeader

void removeHeader(String headername)
removes a header with the given name

Parameters:
headername - the name of the header

containsHeader

boolean containsHeader(String headername)
Returns a boolean indicating whether the named header has already been set.

Parameters:
name - the header name
Returns:
true if the named header has already been set; false otherwise

getHeaderNameSet

Set<String> getHeaderNameSet()
Returns an set of all the header names. If the part has no headers, this method returns an empty Set.

Returns:
an Set of all the header names

getHeaderNames

Enumeration getHeaderNames()
Returns an enumeration of all the header names. If the part has no headers, this method returns an empty enumeration.

Returns:
an enumeration of all the header names

getHeaderList

List<String> getHeaderList(String headername)
Returns all the values of the specified header as an List of String objects.

Some headers, such as Accept-Language can be set by part producer as several headers each with a different value rather than sending the header as a comma separated list.

Parameters:
headername - a String specifying the header name
Returns:
an List containing the values of the requested header. If the part does not have any headers of that name return an empty enumeration.

getHeaders

Enumeration getHeaders(String headername)
Returns all the values of the specified header as an Enumeration of String objects.

Some headers, such as Accept-Language can be set by part producer as several headers each with a different value rather than sending the header as a comma separated list.

Parameters:
headername - a String specifying the header name
Returns:
an Enumeration containing the values of the requested header. If the part does not have any headers of that name return an empty enumeration.

addHeaderlines

void addHeaderlines(String... lines)
adds raw header lines

Parameters:
lines - the headerlines

addHeaderLine

void addHeaderLine(String line)
adds a raw header line

Parameters:
line - the headerline

getHeader

String getHeader(String headername)
Returns the value of the specified header as a String. If the part did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first head in the part.

Parameters:
headername - a String specifying the header name
Returns:
a String containing the value of the requested header, or null if the part does not have a header of that name

getHeader

String getHeader(String headername,
                 String dfltValue)
Returns the value of the specified header as a String. If the part did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first head in the part.

Parameters:
headername - a String specifying the header name
dfltValue - the default value if the header is not set
Returns:
a String containing the value of the requested header, or null if the part does not have a header of that name

setContentType

void setContentType(String type)
sets the MIME type of the body of the part

Parameters:
type - the MIME type of the body of the part

getContentType

String getContentType()
Returns the MIME type of the body of the messag, or null if the type is not known.

Returns:
a String containing the name of the MIME type of the message, or null if the type is not known

getCharacterEncoding

String getCharacterEncoding()
Returns the name of the character encoding used in the body of this message. If the header defines no encoding, the default encoding will be returned

Returns:
a String containing the name of the character encoding

getDisposition

String getDisposition()
returns the content disposition header of the part, or null if the type is not known.

see also rfc2183

Returns:
a String containing the name of the content disposition of the part, or null if the type is not known

getDispositionType

String getDispositionType()
returns the content disposition type or null if not set

see also rfc2183

Returns:
the content disposition type or null if not set

getDispositionParam

String getDispositionParam(String name)
returns the content disposition param value or null if not set

see also rfc2183

Parameters:
name - the parameter name
Returns:
the content disposition param value or null if not set

getTransferEncoding

String getTransferEncoding()
returns the Transfer-Encoding header parameter or null if the header is not set

Returns:
the Transfer-Encoding header parameter or null if the header is not set

setTransferEncoding

void setTransferEncoding(String transferEncoding)
sets the Transfer-Encoding parameter

Parameters:
transferEncoding - the Transfer-Encoding parameter