ch.mimo.netty.handler.codec.icap
Class AbstractIcapMessage

java.lang.Object
  extended by ch.mimo.netty.handler.codec.icap.AbstractIcapMessage
All Implemented Interfaces:
IcapMessage
Direct Known Subclasses:
DefaultIcapRequest, DefaultIcapResponse

public abstract class AbstractIcapMessage
extends Object
implements IcapMessage

This is the main Icap message implementation where all common @see DefaultIcapRequest and @see DefaultIcapResponse member are present.

Author:
Michael Mimo Moratti (mimo@mimo.ch)

Constructor Summary
AbstractIcapMessage(IcapVersion version)
           
 
Method Summary
 IcapMessage addHeader(String name, Object value)
          Adds a new header with the specified name and value.
 IcapMessage clearHeaders()
          Removes all headers from this message.
 boolean containsHeader(String name)
           
 boolean containsHttpRequest()
           
 boolean containsHttpResponse()
           
 IcapMessageElementEnum getBodyType()
           
 Encapsulated getEncapsulatedHeader()
           
 String getHeader(String name)
          Returns the header value with the specified header name.
 Set<String> getHeaderNames()
           
 Set<Map.Entry<String,String>> getHeaders()
          Returns the all header names and values that this message contains.
 Set<String> getHeaders(String name)
          Returns the header values with the specified header name.
 org.jboss.netty.handler.codec.http.HttpRequest getHttpRequest()
           
 org.jboss.netty.handler.codec.http.HttpResponse getHttpResponse()
           
 int getPreviewAmount()
           
 IcapVersion getProtocolVersion()
           
 boolean isPreviewMessage()
           
 IcapMessage removeHeader(String name)
          Removes the header with the specified name.
 IcapMessage setBody(IcapMessageElementEnum body)
          Sets the indication that this icap message contains a body of some kind.
 IcapMessage setEncapsulatedHeader(Encapsulated encapsulated)
          Sets the @see Encapsulated Encapsulation header for this message
 IcapMessage setHeader(String name, Iterable<?> values)
          Sets a new header with the specified name and values.
 IcapMessage setHeader(String name, Object value)
          Sets a new header with the specified name and value.
 IcapMessage setHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest httpRequest)
           
 IcapMessage setHttpResponse(org.jboss.netty.handler.codec.http.HttpResponse response)
          Adds a @see HttpResponse to the Icap message.
 IcapMessage setProtocolVersion(IcapVersion version)
          Sets the protocol version of this message.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractIcapMessage

public AbstractIcapMessage(IcapVersion version)
Method Detail

getHeader

public String getHeader(String name)
Description copied from interface: IcapMessage
Returns the header value with the specified header name. If there are more than one header value for the specified header name, the first value is returned.

Specified by:
getHeader in interface IcapMessage
Returns:
the header value or null if there is no such header

getHeaders

public Set<String> getHeaders(String name)
Description copied from interface: IcapMessage
Returns the header values with the specified header name.

Specified by:
getHeaders in interface IcapMessage
Returns:
the List of header values. An empty list if there is no such header.

getHeaders

public Set<Map.Entry<String,String>> getHeaders()
Description copied from interface: IcapMessage
Returns the all header names and values that this message contains.

Specified by:
getHeaders in interface IcapMessage
Returns:
the List of the header name-value pairs. An empty list if there is no header in this message.

containsHeader

public boolean containsHeader(String name)
Specified by:
containsHeader in interface IcapMessage
Parameters:
name - header name
Returns:
true if and only if there is a header with the specified header name.

getHeaderNames

public Set<String> getHeaderNames()
Specified by:
getHeaderNames in interface IcapMessage
Returns:
Set of all header names that this message contains.

addHeader

public IcapMessage addHeader(String name,
                             Object value)
Description copied from interface: IcapMessage
Adds a new header with the specified name and value.

Specified by:
addHeader in interface IcapMessage
Parameters:
name - header name
value - for the given name
Returns:
self in order to chain the method calls

setHeader

public IcapMessage setHeader(String name,
                             Object value)
Description copied from interface: IcapMessage
Sets a new header with the specified name and value. If there is an existing header with the same name, the existing header is removed.

Specified by:
setHeader in interface IcapMessage
Parameters:
name - header name
value - for the given name
Returns:
self in order to chain the method calls

setHeader

public IcapMessage setHeader(String name,
                             Iterable<?> values)
Description copied from interface: IcapMessage
Sets a new header with the specified name and values. If there is an existing header with the same name, the existing header is removed.

Specified by:
setHeader in interface IcapMessage
Parameters:
name - header name
values - for the given name
Returns:
self in order to chain the method calls

removeHeader

public IcapMessage removeHeader(String name)
Description copied from interface: IcapMessage
Removes the header with the specified name.

Specified by:
removeHeader in interface IcapMessage
Returns:
self in order to chain the method calls

getPreviewAmount

public int getPreviewAmount()
Specified by:
getPreviewAmount in interface IcapMessage
Returns:
the @see Integer preview header value.

clearHeaders

public IcapMessage clearHeaders()
Description copied from interface: IcapMessage
Removes all headers from this message.

Specified by:
clearHeaders in interface IcapMessage
Returns:
self in order to chain the method calls

getProtocolVersion

public IcapVersion getProtocolVersion()
Specified by:
getProtocolVersion in interface IcapMessage
Returns:
the protocol version of this message.

setProtocolVersion

public IcapMessage setProtocolVersion(IcapVersion version)
Description copied from interface: IcapMessage
Sets the protocol version of this message.

Specified by:
setProtocolVersion in interface IcapMessage
Parameters:
version - @see IcapVersion
Returns:
self in order to chain the method calls

containsHttpRequest

public boolean containsHttpRequest()
Specified by:
containsHttpRequest in interface IcapMessage
Returns:
true if a http request was delivered.

getHttpRequest

public org.jboss.netty.handler.codec.http.HttpRequest getHttpRequest()
Specified by:
getHttpRequest in interface IcapMessage
Returns:
the actual http request instance @see HttpRequest

setHttpRequest

public IcapMessage setHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest httpRequest)
Specified by:
setHttpRequest in interface IcapMessage
Returns:
self in order to chain the method calls

containsHttpResponse

public boolean containsHttpResponse()
Specified by:
containsHttpResponse in interface IcapMessage
Returns:
true if a http response was delivered.

getHttpResponse

public org.jboss.netty.handler.codec.http.HttpResponse getHttpResponse()
Specified by:
getHttpResponse in interface IcapMessage
Returns:
the actual http response instance @see HttpResponse

setHttpResponse

public IcapMessage setHttpResponse(org.jboss.netty.handler.codec.http.HttpResponse response)
Description copied from interface: IcapMessage
Adds a @see HttpResponse to the Icap message.

Specified by:
setHttpResponse in interface IcapMessage
Parameters:
response - the @see HttpResponse
Returns:
self in order to chain the method calls

setEncapsulatedHeader

public IcapMessage setEncapsulatedHeader(Encapsulated encapsulated)
Description copied from interface: IcapMessage
Sets the @see Encapsulated Encapsulation header for this message

Specified by:
setEncapsulatedHeader in interface IcapMessage
Parameters:
encapsulated - @see Encapsulated instance
Returns:
self in order to chain the method calls

getEncapsulatedHeader

public Encapsulated getEncapsulatedHeader()
Specified by:
getEncapsulatedHeader in interface IcapMessage
Returns:
@see Encapsulated Encapsulated header value

isPreviewMessage

public boolean isPreviewMessage()
Specified by:
isPreviewMessage in interface IcapMessage
Returns:
whether this message is a preview of the actual message.

setBody

public IcapMessage setBody(IcapMessageElementEnum body)
Description copied from interface: IcapMessage
Sets the indication that this icap message contains a body of some kind.

Specified by:
setBody in interface IcapMessage
Parameters:
body - @see IcapMessageElementEnum
Returns:
self in order to chain the method calls

getBodyType

public IcapMessageElementEnum getBodyType()
Specified by:
getBodyType in interface IcapMessage
Returns:
@see IcapMessageElementEnum message body indicator.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.