org.xlightweb
Class HttpRequestHeaderWrapper

Package class diagram package HttpRequestHeaderWrapper
java.lang.Object
  extended by org.xlightweb.HttpRequestHeaderWrapper
All Implemented Interfaces:
IHeader, IHttpMessageHeader, IHttpRequestHeader
Direct Known Subclasses:
HttpRequestWrapper

public class HttpRequestHeaderWrapper
extends Object
implements IHttpRequestHeader

Provides a convenient implementation of the HttpRequestHeader interface that can be subclassed by developers wishing to adapt the request header. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped request header object.


Field Summary
 
Fields inherited from interface org.xlightweb.IHttpMessageHeader
DEFAULT_ENCODING
 
Constructor Summary
HttpRequestHeaderWrapper(IHttpRequestHeader requestHeader)
          constructor
 
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
 void addMatrixParameter(String parameterName, String parameterValue)
          adds a matrix parameter
 void addParameter(String parameterName, String parameterValue)
          adds a parameter
 boolean containsHeader(String headername)
          Returns a boolean indicating whether the named header has already been set.
 IHttpRequestHeader copy()
          creates a copy of this header
 void copyHeaderFrom(IHttpMessageHeader otherHeader, String... upperExcludenames)
          copy the headers
 List<ContentType> getAccept()
          returns the list of the accepted content types, ordered by the quality factory
 Object getAttribute(String name)
          Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
 Enumeration getAttributeNames()
          Returns an Enumeration containing the names of the attributes available to this message.
 Set<String> getAttributeNameSet()
          Returns an Set containing the names of the attributes available to this messaget.
 Boolean getBooleanParameter(String name)
          Get an Boolean parameter, or null if not present.
 boolean getBooleanParameter(String name, boolean defaultVal)
          Get an boolean parameter, with a fallback value.
 String getCharacterEncoding()
          Returns the name of the character encoding used in the body of this message.
 int getContentLength()
          Returns the length, in bytes, of the message body and made available by the input stream, or -1 if the length is not known.
 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
 Double getDoubleParameter(String name)
          Get an Double parameter, or null if not present.
 double getDoubleParameter(String name, double defaultVal)
          Get an double parameter, with a fallback value.
 Float getFloatParameter(String name)
          Get an Float parameter, or null if not present.
 float getFloatParameter(String name, float defaultVal)
          Get an float parameter, with a fallback value.
 String getHeader(String headername)
          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 getHost()
          returns the Host header parameter or null if the header is not set
 Integer getIntParameter(String name)
          Get an Integer parameter, or null if not present.
 int getIntParameter(String name, int defaultVal)
          Get an int parameter, with a fallback value.
 Long getLongParameter(String name)
          Get an Long parameter, or null if not present.
 long getLongParameter(String name, long defaultVal)
          Get an long parameter, with a fallback value.
 String getMatrixParameter(String name)
          Returns the value of a request matrix parameter as a String, or null if the parameter does not exist.
 Set<String> getMatrixParameterNameSet()
          returns the matrix parameter name set
 String[] getMatrixParameterValues(String name)
          Returns an array of String objects containing all of the values the given request matrix parameter has, or null if the parameter does not exist.
 String getMethod()
          Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
 String getParameter(String name)
          Returns the value of a request parameter as a String, or null if the parameter does not exist.
 String getParameter(String name, String defaultVal)
          Get an String parameter, with a fallback value.
 Enumeration getParameterNames()
          Returns an Enumeration of String objects containing the names of the parameters contained in this request.
 Set<String> getParameterNameSet()
          returns the parameter name set
 String[] getParameterValues(String name)
          Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
 String getProtocol()
          Returns the name and version of the protocol the message uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
 String getProtocolVersion()
          Returns the version of the protocol the message uses in the form majorVersion.minorVersion, for example, 1.1.
 String getQueryString()
          Returns the query string that is contained in the request URL after the path.
 String getRemoteAddr()
          Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
 String getRemoteHost()
          Returns the fully qualified name of the client or the last proxy that sent the request.
 int getRemotePort()
          Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
 String getRequestURI()
          Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
 URL getRequestUrl()
          Reconstructs the URL the client used to make the request.
 boolean getRequiredBooleanParameter(String name)
          Get an boolean parameter or throws an exception if parameter is not present
 double getRequiredDoubleParameter(String name)
          Get an double parameter or throws an exception if parameter is not present
 float getRequiredFloatParameter(String name)
          Get an float parameter or throws an exception if parameter is not present
 int getRequiredIntParameter(String name)
          Get an int parameter or throws an exception if parameter is not present
 long getRequiredLongParameter(String name)
          Get an long parameter or throws an exception if parameter is not present
 String getRequiredStringParameter(String name)
          Get an string parameter or throws an exception if parameter is not present
 String getScheme()
          Returns the name of the scheme used to make this request, for example, http or https.
 String getServerName()
          Returns the host name of the server to which the request was sent.
 int getServerPort()
          Returns the port number to which the request was sent.
 String getTransferEncoding()
          returns the Transfer-Encoding header parameter or null if the header is not set
 String getUserAgent()
          returns the User-Agent header parameter or null if the header is not set
protected  IHeader getWrappedHeader()
           
protected  IHttpRequestHeader getWrappedRequestHeader()
           
 boolean isSecure()
          Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
 void removeHeader(String headername)
          removes a header with the given name
 void removeHopByHopHeaders()
          removes all hop-by-hop headers without Transfer-Encoding if set to chunked
 void removeMatrixParameter(String parameterName)
          removes a matrix parameter
 void removeParameter(String parameterName)
          remove a parameter
 void setAttribute(String name, Object o)
          Stores an attribute in this header.
 void setContentLength(int length)
          sets the content length in bytes
 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 setHost(String host)
          sets the Host header (e.g. www.gmx.com or www.gmx.com:9900).
 void setMatrixParameter(String parameterName, String parameterValue)
          sets a matrix parameter
 void setMethod(String method)
          Sets the name of the HTTP method
 void setParameter(String parameterName, String parameterValue)
          sets a parameter
 void setRequestURI(String requestUri)
          set the request uri part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
 void setRequestUrl(URL url)
          set the request url
 void setTransferEncoding(String transferEncoding)
          sets the Transfer-Encoding parameter
 void setUserAgent(String userAgent)
          sets the User-Agent header
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xlightweb.IHeader
addHeader, addHeaderLine, addHeaderlines, containsHeader, getCharacterEncoding, getContentType, getDisposition, getDispositionParam, getDispositionType, getHeader, getHeaderList, getHeaderNames, getHeaderNameSet, getHeaders, removeHeader, setHeader
 

Constructor Detail

HttpRequestHeaderWrapper

public HttpRequestHeaderWrapper(IHttpRequestHeader requestHeader)
constructor

Parameters:
request - the request header to wrap
Method Detail

getWrappedRequestHeader

protected IHttpRequestHeader getWrappedRequestHeader()

getBooleanParameter

public Boolean getBooleanParameter(String name)
Get an Boolean parameter, or null if not present.

Specified by:
getBooleanParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
Returns:
the value, or null

getBooleanParameter

public boolean getBooleanParameter(String name,
                                   boolean defaultVal)
Get an boolean parameter, with a fallback value.

Specified by:
getBooleanParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

getDoubleParameter

public Double getDoubleParameter(String name)
                          throws BadMessageException
Get an Double parameter, or null if not present.

Specified by:
getDoubleParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
Returns:
the value, or null
Throws:
BadMessageException - if the parameter is not a number

getDoubleParameter

public double getDoubleParameter(String name,
                                 double defaultVal)
Get an double parameter, with a fallback value.

Specified by:
getDoubleParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

getFloatParameter

public Float getFloatParameter(String name)
                        throws BadMessageException
Get an Float parameter, or null if not present.

Specified by:
getFloatParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
Returns:
the value, or null
Throws:
BadMessageException - if the parameter value is not a number

getFloatParameter

public float getFloatParameter(String name,
                               float defaultVal)
Get an float parameter, with a fallback value.

Specified by:
getFloatParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

getIntParameter

public Integer getIntParameter(String name)
                        throws BadMessageException
Get an Integer parameter, or null if not present.

Specified by:
getIntParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
Returns:
the value, or null
Throws:
BadMessageException - if the parameter value is not a number

getIntParameter

public int getIntParameter(String name,
                           int defaultVal)
Get an int parameter, with a fallback value.

Specified by:
getIntParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

getLongParameter

public Long getLongParameter(String name)
                      throws BadMessageException
Get an Long parameter, or null if not present.

Specified by:
getLongParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
Returns:
the value, or null
Throws:
BadMessageException - if the parameter value is not a number

getLongParameter

public long getLongParameter(String name,
                             long defaultVal)
Get an long parameter, with a fallback value.

Specified by:
getLongParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

getMethod

public String getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

Specified by:
getMethod in interface IHttpRequestHeader
Returns:
a String specifying the name of the method

getMatrixParameter

public String getMatrixParameter(String name)
Returns the value of a request matrix parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request.

Specified by:
getMatrixParameter in interface IHttpRequestHeader
Parameters:
name - a String specifying the name of the matrix parameter
Returns:
a String representing the single value of the matrix parameter

getMatrixParameterNameSet

public Set<String> getMatrixParameterNameSet()
returns the matrix parameter name set

Specified by:
getMatrixParameterNameSet in interface IHttpRequestHeader
Returns:
the matrix parameter name set

getMatrixParameterValues

public String[] getMatrixParameterValues(String name)
Returns an array of String objects containing all of the values the given request matrix parameter has, or null if the parameter does not exist. If the natrix parameter has a single value, the array has a length of 1.

Specified by:
getMatrixParameterValues in interface IHttpRequestHeader
Parameters:
name - a String specifying the name of the matrix parameter
Returns:
an array of String objects containing the matrix parameter's values

setMatrixParameter

public void setMatrixParameter(String parameterName,
                               String parameterValue)
sets a matrix parameter

Specified by:
setMatrixParameter in interface IHttpRequestHeader
Parameters:
parameterName - the parameter name
parameterValue - the parameter value

addMatrixParameter

public void addMatrixParameter(String parameterName,
                               String parameterValue)
adds a matrix parameter

Specified by:
addMatrixParameter in interface IHttpRequestHeader
Parameters:
parameterName - the parameter name
parameterValue - the parameter value

removeMatrixParameter

public void removeMatrixParameter(String parameterName)
removes a matrix parameter

Specified by:
removeMatrixParameter in interface IHttpRequestHeader
Parameters:
parameterName - the parameter name

removeParameter

public void removeParameter(String parameterName)
remove a parameter

Specified by:
removeParameter in interface IHttpRequestHeader
Parameters:
parameterName - the parameter name

getParameter

public String getParameter(String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request.

Specified by:
getParameter in interface IHttpRequestHeader
Parameters:
name - a String specifying the name of the parameter
Returns:
a String representing the single value of the parameter

getParameter

public String getParameter(String name,
                           String defaultVal)
Get an String parameter, with a fallback value.

Specified by:
getParameter in interface IHttpRequestHeader
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

getParameterNameSet

public Set<String> getParameterNameSet()
returns the parameter name set

Specified by:
getParameterNameSet in interface IHttpRequestHeader
Returns:
the parameter name set

getParameterNames

public Enumeration getParameterNames()
Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Enumeration.

Specified by:
getParameterNames in interface IHttpRequestHeader
Returns:
an Enumeration of String objects, each String containing the name of a request parameter; or an empty Enumeration if the request has no parameters

getParameterValues

public String[] getParameterValues(String name)
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist. If the parameter has a single value, the array has a length of 1.

Specified by:
getParameterValues in interface IHttpRequestHeader
Parameters:
name - a String specifying the name of the parameter
Returns:
an array of String objects containing the parameter's values

getQueryString

public String getQueryString()
Returns the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string.

Specified by:
getQueryString in interface IHttpRequestHeader
Returns:
a String containing the query string or null if the URL contains no query string.

getRemoteAddr

public String getRemoteAddr()
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.

Specified by:
getRemoteAddr in interface IHttpRequestHeader
Returns:
a String containing the IP address of the client that sent the request

getRemoteHost

public String getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address.

Specified by:
getRemoteHost in interface IHttpRequestHeader
Returns:
a String containing the fully qualified name of the client

getRemotePort

public int getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.

Specified by:
getRemotePort in interface IHttpRequestHeader
Returns:
an integer specifying the port number

getRequestURI

public String getRequestURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.

Specified by:
getRequestURI in interface IHttpRequestHeader
Returns:
a String containing the part of the URL from the protocol name up to the query string

setRequestURI

public void setRequestURI(String requestUri)
set the request uri part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.

Specified by:
setRequestURI in interface IHttpRequestHeader
Parameters:
requestUri - the request uri

getRequestUrl

public URL getRequestUrl()
Reconstructs the URL the client used to make the request.

Specified by:
getRequestUrl in interface IHttpRequestHeader
Returns:
the URL

getRequiredBooleanParameter

public boolean getRequiredBooleanParameter(String name)
                                    throws BadMessageException
Get an boolean parameter or throws an exception if parameter is not present

Specified by:
getRequiredBooleanParameter in interface IHttpRequestHeader
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present

getRequiredDoubleParameter

public double getRequiredDoubleParameter(String name)
                                  throws BadMessageException
Get an double parameter or throws an exception if parameter is not present

Specified by:
getRequiredDoubleParameter in interface IHttpRequestHeader
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present or the parameter value is not a number

getRequiredFloatParameter

public float getRequiredFloatParameter(String name)
                                throws BadMessageException
Get an float parameter or throws an exception if parameter is not present

Specified by:
getRequiredFloatParameter in interface IHttpRequestHeader
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present or the parameter value is not a number

getRequiredIntParameter

public int getRequiredIntParameter(String name)
                            throws BadMessageException
Get an int parameter or throws an exception if parameter is not present

Specified by:
getRequiredIntParameter in interface IHttpRequestHeader
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present or the parameter is not a number

getRequiredLongParameter

public long getRequiredLongParameter(String name)
                              throws BadMessageException
Get an long parameter or throws an exception if parameter is not present

Specified by:
getRequiredLongParameter in interface IHttpRequestHeader
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present or the parameter is not a number

getRequiredStringParameter

public String getRequiredStringParameter(String name)
                                  throws BadMessageException
Get an string parameter or throws an exception if parameter is not present

Specified by:
getRequiredStringParameter in interface IHttpRequestHeader
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present

getServerName

public String getServerName()
Returns the host name of the server to which the request was sent. It is the value of the part before ":" in the Host header value, if any, or the resolved server name, or the server IP address.

Specified by:
getServerName in interface IHttpRequestHeader
Returns:
the server name

getServerPort

public int getServerPort()
Returns the port number to which the request was sent. It is the value of the part after ":" in the Host header value, if any, or the server port where the client connection was accepted on.

Specified by:
getServerPort in interface IHttpRequestHeader
Returns:
the server port

getContentLength

public int getContentLength()
Returns the length, in bytes, of the message body and made available by the input stream, or -1 if the length is not known.

Specified by:
getContentLength in interface IHttpMessageHeader
Returns:
an integer containing the length of the message body or -1 if the length is not known

isSecure

public boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.

Specified by:
isSecure in interface IHttpRequestHeader
Returns:
a boolean indicating if the request was made using a secure channel

setMethod

public void setMethod(String method)
Sets the name of the HTTP method

Specified by:
setMethod in interface IHttpRequestHeader
Parameters:
method - a String specifying the name of the method

setParameter

public void setParameter(String parameterName,
                         String parameterValue)
sets a parameter

Specified by:
setParameter in interface IHttpRequestHeader
Parameters:
parameterName - the parameter name
parameterValue - the parameter value

addParameter

public void addParameter(String parameterName,
                         String parameterValue)
adds a parameter

Specified by:
addParameter in interface IHttpRequestHeader
Parameters:
parameterName - the parameter name
parameterValue - the parameter value

setRequestUrl

public void setRequestUrl(URL url)
set the request url

Specified by:
setRequestUrl in interface IHttpRequestHeader
Parameters:
url - the request url

getAttribute

public Object getAttribute(String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Attribute names should follow the same conventions as package names.

Specified by:
getAttribute in interface IHttpMessageHeader
Parameters:
name - a String specifying the name of the attribute
Returns:
an Object containing the value of the attribute, or null if the attribute does not exist

getAttributeNameSet

public Set<String> getAttributeNameSet()
Returns an Set containing the names of the attributes available to this messaget. This method returns an empty Set if the request has no attributes available to it.

Specified by:
getAttributeNameSet in interface IHttpMessageHeader
Returns:
an Set of strings containing the names of the message's attributes

getAttributeNames

public Enumeration getAttributeNames()
Returns an Enumeration containing the names of the attributes available to this message. This method returns an empty Enumeration if the message has no attributes available to it.

Specified by:
getAttributeNames in interface IHttpMessageHeader
Returns:
an Enumeration of strings containing the names of the message's attributes

getAccept

public List<ContentType> getAccept()
returns the list of the accepted content types, ordered by the quality factory

Specified by:
getAccept in interface IHttpRequestHeader
Returns:
the accepted content types

getScheme

public String getScheme()
Returns the name of the scheme used to make this request, for example, http or https.

Specified by:
getScheme in interface IHttpRequestHeader
Returns:
a String containing the name of the scheme

getHost

public String getHost()
returns the Host header parameter or null if the header is not set

Specified by:
getHost in interface IHttpRequestHeader
Returns:
the Host header parameter or null if the header is not set

getUserAgent

public String getUserAgent()
returns the User-Agent header parameter or null if the header is not set

Specified by:
getUserAgent in interface IHttpRequestHeader
Returns:
the User-Agent header parameter or null if the header is not set

setHost

public void setHost(String host)
sets the Host header (e.g. www.gmx.com or www.gmx.com:9900). If the port value is -1, it will be removed, automatically

Specified by:
setHost in interface IHttpRequestHeader
Parameters:
host - the Host header

setUserAgent

public void setUserAgent(String userAgent)
sets the User-Agent header

Specified by:
setUserAgent in interface IHttpRequestHeader
Parameters:
userAgent - the User-Agent header

copy

public IHttpRequestHeader copy()
creates a copy of this header

Specified by:
copy in interface IHttpMessageHeader
Specified by:
copy in interface IHttpRequestHeader
Returns:
return the copy

copyHeaderFrom

public void copyHeaderFrom(IHttpMessageHeader otherHeader,
                           String... upperExcludenames)
copy the headers

Specified by:
copyHeaderFrom in interface IHttpMessageHeader
Parameters:
otherHeader - the other header
upperExcludenames - the header names to exclude

getProtocol

public String getProtocol()
Returns the name and version of the protocol the message uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.

Specified by:
getProtocol in interface IHttpMessageHeader
Returns:
a String containing the protocol name and version number

getProtocolVersion

public String getProtocolVersion()
Returns the version of the protocol the message uses in the form majorVersion.minorVersion, for example, 1.1.

Specified by:
getProtocolVersion in interface IHttpMessageHeader
Returns:
a String containing the protocol version number

getTransferEncoding

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

Specified by:
getTransferEncoding in interface IHeader
Returns:
the Transfer-Encoding header parameter or null if the header is not set

removeHopByHopHeaders

public void removeHopByHopHeaders()
removes all hop-by-hop headers without Transfer-Encoding if set to chunked

Specified by:
removeHopByHopHeaders in interface IHttpMessageHeader

setAttribute

public void setAttribute(String name,
                         Object o)
Stores an attribute in this header. Attributes are reset between messages.

Attribute names should follow the same conventions as package names.

Specified by:
setAttribute in interface IHttpMessageHeader
Parameters:
name - a String specifying the name of the attribute
o - the Object to be stored

setContentLength

public void setContentLength(int length)
sets the content length in bytes

Specified by:
setContentLength in interface IHttpMessageHeader
Parameters:
length - the content length in bytes

setContentType

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

Specified by:
setContentType in interface IHeader
Parameters:
type - the MIME type of the body of the part

setTransferEncoding

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

Specified by:
setTransferEncoding in interface IHeader
Parameters:
transferEncoding - the Transfer-Encoding parameter

toString

public String toString()

getWrappedHeader

protected IHeader getWrappedHeader()

addHeader

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

Specified by:
addHeader in interface IHeader
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)

addHeaderLine

public void addHeaderLine(String line)
adds a raw header line

Specified by:
addHeaderLine in interface IHeader
Parameters:
line - the headerline

addHeaderlines

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

Specified by:
addHeaderlines in interface IHeader
Parameters:
lines - the headerlines

containsHeader

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

Specified by:
containsHeader in interface IHeader
Returns:
true if the named header has already been set; false otherwise

getCharacterEncoding

public 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

Specified by:
getCharacterEncoding in interface IHeader
Returns:
a String containing the name of the character encoding

getContentType

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

Specified by:
getContentType in interface IHeader
Returns:
a String containing the name of the MIME type of the message, or null if the type is not known

getDisposition

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

see also rfc2183

Specified by:
getDisposition in interface IHeader
Returns:
a String containing the name of the content disposition of the part, or null if the type is not known

getDispositionType

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

see also rfc2183

Specified by:
getDispositionType in interface IHeader
Returns:
the content disposition type or null if not set

getDispositionParam

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

see also rfc2183

Specified by:
getDispositionParam in interface IHeader
Parameters:
name - the parameter name
Returns:
the content disposition param value or null if not set

getHeader

public 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.

Specified by:
getHeader in interface IHeader
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

getHeaderList

public 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.

Specified by:
getHeaderList in interface IHeader
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.

getHeaderNameSet

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

Specified by:
getHeaderNameSet in interface IHeader
Returns:
an Set of all the header names

getHeaderNames

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

Specified by:
getHeaderNames in interface IHeader
Returns:
an enumeration of all the header names

getHeaders

public 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.

Specified by:
getHeaders in interface IHeader
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.

removeHeader

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

Specified by:
removeHeader in interface IHeader
Parameters:
headername - the name of the header

setHeader

public 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.

Specified by:
setHeader in interface IHeader
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)