|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objectorg.xlightweb.HttpRequestHeaderWrapper
public class HttpRequestHeaderWrapper
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 |
getContextPath()
Returns the portion of the request URI that indicates the context of the request. |
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 setsee also rfc2183 |
String |
getDispositionType()
returns the content disposition type or null if not setsee 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. |
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 |
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 |
getPathInfo()
Returns any extra path information associated with the URL. |
String |
getPathInfo(boolean removeSurroundingSlashs)
Returns any extra path information associated with the URL. |
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 |
getRequestHandlerPath()
returns the request handler path. |
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 |
setContextPath(String contextPath)
sets the context path. |
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 |
setRequestHandlerPath(String requestHandlerPath)
sets the request handler path |
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, getHeader, getHeaderList, getHeaderNames, getHeaderNameSet, getHeaders, removeHeader, setHeader |
| Constructor Detail |
|---|
public HttpRequestHeaderWrapper(IHttpRequestHeader requestHeader)
request - the request header to wrap| Method Detail |
|---|
protected IHttpRequestHeader getWrappedRequestHeader()
public Boolean getBooleanParameter(String name)
getBooleanParameter in interface IHttpRequestHeadername - the name of the parameter
null
public boolean getBooleanParameter(String name,
boolean defaultVal)
getBooleanParameter in interface IHttpRequestHeadername - the name of the parameterdefaultVal - the default value to use as fallback
public Double getDoubleParameter(String name)
throws BadMessageException
getDoubleParameter in interface IHttpRequestHeadername - the name of the parameter
null
BadMessageException - if the parameter is not a number
public double getDoubleParameter(String name,
double defaultVal)
getDoubleParameter in interface IHttpRequestHeadername - the name of the parameterdefaultVal - the default value to use as fallback
public Float getFloatParameter(String name)
throws BadMessageException
getFloatParameter in interface IHttpRequestHeadername - the name of the parameter
null
BadMessageException - if the parameter value is not a number
public float getFloatParameter(String name,
float defaultVal)
getFloatParameter in interface IHttpRequestHeadername - the name of the parameterdefaultVal - the default value to use as fallback
public Integer getIntParameter(String name)
throws BadMessageException
getIntParameter in interface IHttpRequestHeadername - the name of the parameter
null
BadMessageException - if the parameter value is not a number
public int getIntParameter(String name,
int defaultVal)
getIntParameter in interface IHttpRequestHeadername - the name of the parameterdefaultVal - the default value to use as fallback
public Long getLongParameter(String name)
throws BadMessageException
getLongParameter in interface IHttpRequestHeadername - the name of the parameter
null
BadMessageException - if the parameter value is not a number
public long getLongParameter(String name,
long defaultVal)
getLongParameter in interface IHttpRequestHeadername - the name of the parameterdefaultVal - the default value to use as fallback
public String getMethod()
getMethod in interface IHttpRequestHeaderpublic String getMatrixParameter(String name)
getMatrixParameter in interface IHttpRequestHeadername - a String specifying the name of the matrix parameter
public Set<String> getMatrixParameterNameSet()
getMatrixParameterNameSet in interface IHttpRequestHeaderpublic String[] getMatrixParameterValues(String name)
getMatrixParameterValues in interface IHttpRequestHeadername - a String specifying the name of the matrix parameter
public void setMatrixParameter(String parameterName,
String parameterValue)
setMatrixParameter in interface IHttpRequestHeaderparameterName - the parameter nameparameterValue - the parameter value
public void addMatrixParameter(String parameterName,
String parameterValue)
addMatrixParameter in interface IHttpRequestHeaderparameterName - the parameter nameparameterValue - the parameter valuepublic void removeMatrixParameter(String parameterName)
removeMatrixParameter in interface IHttpRequestHeaderparameterName - the parameter namepublic void removeParameter(String parameterName)
removeParameter in interface IHttpRequestHeaderparameterName - the parameter namepublic String getParameter(String name)
getParameter in interface IHttpRequestHeadername - a String specifying the name of the parameter
public String getParameter(String name,
String defaultVal)
getParameter in interface IHttpRequestHeadername - the name of the parameterdefaultVal - the default value to use as fallback
public Set<String> getParameterNameSet()
getParameterNameSet in interface IHttpRequestHeaderpublic Enumeration getParameterNames()
getParameterNames in interface IHttpRequestHeaderpublic String[] getParameterValues(String name)
getParameterValues in interface IHttpRequestHeadername - a String specifying the name of the parameter
public String getQueryString()
null
if the URL does not have a query string.
getQueryString in interface IHttpRequestHeaderpublic String getRemoteAddr()
getRemoteAddr in interface IHttpRequestHeaderpublic String getRemoteHost()
getRemoteHost in interface IHttpRequestHeaderpublic int getRemotePort()
getRemotePort in interface IHttpRequestHeaderpublic String getRequestURI()
getRequestURI in interface IHttpRequestHeaderpublic void setRequestURI(String requestUri)
setRequestURI in interface IHttpRequestHeaderrequestUri - the request uripublic URL getRequestUrl()
getRequestUrl in interface IHttpRequestHeaderpublic String getPathInfo()
getPathInfo in interface IHttpRequestHeadernull if the URL does not have any extra path informationpublic String getPathInfo(boolean removeSurroundingSlashs)
getPathInfo in interface IHttpRequestHeaderremoveSurroundingSlashs - true, if surrounding slashs wil lbe removed
null if the URL does not have any extra path informationpublic String getRequestHandlerPath()
getRequestHandlerPath in interface IHttpRequestHeaderpublic void setRequestHandlerPath(String requestHandlerPath)
setRequestHandlerPath in interface IHttpRequestHeaderrequestHandlerPath - the request handler pathpublic String getContextPath()
getContextPath in interface IHttpRequestHeaderIHttpRequest.getRequestHandlerPath()public void setContextPath(String contextPath)
setContextPath in interface IHttpRequestHeadercontextPath - the context path
public boolean getRequiredBooleanParameter(String name)
throws BadMessageException
getRequiredBooleanParameter in interface IHttpRequestHeadername - the parameter name
BadMessageException - if the parameter is not present
public double getRequiredDoubleParameter(String name)
throws BadMessageException
getRequiredDoubleParameter in interface IHttpRequestHeadername - the parameter name
BadMessageException - if the parameter is not present or the parameter value is not a number
public float getRequiredFloatParameter(String name)
throws BadMessageException
getRequiredFloatParameter in interface IHttpRequestHeadername - the parameter name
BadMessageException - if the parameter is not present or the parameter value is not a number
public int getRequiredIntParameter(String name)
throws BadMessageException
getRequiredIntParameter in interface IHttpRequestHeadername - the parameter name
BadMessageException - if the parameter is not present or the parameter is not a number
public long getRequiredLongParameter(String name)
throws BadMessageException
getRequiredLongParameter in interface IHttpRequestHeadername - the parameter name
BadMessageException - if the parameter is not present or the parameter is not a number
public String getRequiredStringParameter(String name)
throws BadMessageException
getRequiredStringParameter in interface IHttpRequestHeadername - the parameter name
BadMessageException - if the parameter is not presentpublic String getServerName()
getServerName in interface IHttpRequestHeaderpublic int getServerPort()
getServerPort in interface IHttpRequestHeaderpublic int getContentLength()
getContentLength in interface IHttpMessageHeaderpublic boolean isSecure()
isSecure in interface IHttpRequestHeaderpublic void setMethod(String method)
setMethod in interface IHttpRequestHeadermethod - a String specifying the name of the method
public void setParameter(String parameterName,
String parameterValue)
setParameter in interface IHttpRequestHeaderparameterName - the parameter nameparameterValue - the parameter value
public void addParameter(String parameterName,
String parameterValue)
addParameter in interface IHttpRequestHeaderparameterName - the parameter nameparameterValue - the parameter valuepublic void setRequestUrl(URL url)
setRequestUrl in interface IHttpRequestHeaderurl - the request urlpublic Object getAttribute(String name)
Object,
or null if no attribute of the given name exists.
getAttribute in interface IHttpMessageHeadername - a String specifying the name of the attribute
Object containing the value of the attribute,
or null if the attribute does not existpublic Set<String> getAttributeNameSet()
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.
getAttributeNameSet in interface IHttpMessageHeaderSet of strings
containing the names of the message's attributespublic Enumeration getAttributeNames()
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.
getAttributeNames in interface IHttpMessageHeaderEnumeration of strings containing the names
of the message's attributespublic List<ContentType> getAccept()
getAccept in interface IHttpRequestHeaderpublic String getScheme()
getScheme in interface IHttpRequestHeaderpublic String getHost()
null if the header is not set
getHost in interface IHttpRequestHeadernull if the header is not setpublic String getUserAgent()
null if the header is not set
getUserAgent in interface IHttpRequestHeadernull if the header is not setpublic void setHost(String host)
setHost in interface IHttpRequestHeaderhost - the Host headerpublic void setUserAgent(String userAgent)
setUserAgent in interface IHttpRequestHeaderuserAgent - the User-Agent headerpublic IHttpRequestHeader copy()
copy in interface IHttpMessageHeadercopy in interface IHttpRequestHeader
public void copyHeaderFrom(IHttpMessageHeader otherHeader,
String... upperExcludenames)
copyHeaderFrom in interface IHttpMessageHeaderotherHeader - the other headerupperExcludenames - the header names to excludepublic String getProtocol()
getProtocol in interface IHttpMessageHeaderpublic String getProtocolVersion()
getProtocolVersion in interface IHttpMessageHeaderpublic String getTransferEncoding()
null if the header is not set
getTransferEncoding in interface IHeadernull if the header is not setpublic void removeHopByHopHeaders()
removeHopByHopHeaders in interface IHttpMessageHeader
public void setAttribute(String name,
Object o)
setAttribute in interface IHttpMessageHeadername - a String specifying
the name of the attributeo - the Object to be storedpublic void setContentLength(int length)
setContentLength in interface IHttpMessageHeaderlength - the content length in bytespublic void setContentType(String type)
setContentType in interface IHeadertype - the MIME type of the body of the partpublic void setTransferEncoding(String transferEncoding)
setTransferEncoding in interface IHeadertransferEncoding - the Transfer-Encoding parameterpublic String toString()
protected IHeader getWrappedHeader()
public void addHeader(String headername,
String headervalue)
addHeader in interface IHeaderheadername - the name of the headerheadervalue - the additional header value. If it contains octet string, it should be encoded
according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)public void addHeaderLine(String line)
addHeaderLine in interface IHeaderline - the headerlinepublic void addHeaderlines(String... lines)
addHeaderlines in interface IHeaderlines - the headerlinespublic boolean containsHeader(String headername)
containsHeader in interface IHeadertrue if the named header has already been set; false otherwisepublic String getCharacterEncoding()
getCharacterEncoding in interface IHeaderString containing the name of the character encodingpublic String getContentType()
null if the type is not known.
getContentType in interface IHeaderString containing the name of the MIME type of
the message, or null if the type is not knownpublic String getDisposition()
null if the type is not known.
getDisposition in interface IHeaderString containing the name of the content disposition of
the part, or null if the type is not knownpublic String getDispositionType()
null if not set
getDispositionType in interface IHeadernull if not setpublic String getDispositionParam(String name)
null if not set
getDispositionParam in interface IHeadername - the parameter name
null if not setpublic String getHeader(String headername)
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.
getHeader in interface IHeaderheadername - a String specifying the header name
String containing the value of the
requested header, or null if the part
does not have a header of that name
public String getHeader(String headername,
String dfltValue)
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.
getHeader in interface IHeaderheadername - a String specifying the header namedfltValue - the default value if the header is not set
String containing the value of the
requested header, or null if the part
does not have a header of that namepublic List<String> getHeaderList(String headername)
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.
getHeaderList in interface IHeaderheadername - a String specifying the header name
List containing the values of the requested header.
If the part does not have any headers of that name return an empty enumeration.public Set<String> getHeaderNameSet()
getHeaderNameSet in interface IHeaderpublic Enumeration getHeaderNames()
getHeaderNames in interface IHeaderpublic Enumeration getHeaders(String headername)
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.
getHeaders in interface IHeaderheadername - a String specifying the header name
Enumeration containing the values of the requested header.
If the part does not have any headers of that name return an empty enumeration.public void removeHeader(String headername)
removeHeader in interface IHeaderheadername - the name of the header
public void setHeader(String headername,
String headervalue)
setHeader in interface IHeaderheadername - the name of the headerheadervalue - the header value If it contains octet string,
it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||