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

java.lang.Object
  extended by ch.mimo.netty.handler.codec.icap.Encapsulated

public final class Encapsulated
extends Object

This class parses, creates and provides the very important Encapsulated header to the Decoder and encapsulates the complexity of that header.

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

Constructor Summary
Encapsulated()
           
Encapsulated(String headerValue)
          Creates an instance based on the value given.
 
Method Summary
 void addEntry(IcapMessageElementEnum name, int position)
          Sets an entry with it's corresponding position.
 IcapMessageElementEnum containsBodyEntry()
          Gets whether the message contains a body entity.
 boolean containsEntry(IcapMessageElementEnum entity)
          Gets whether a given entry exists in the header value.
 int encode(org.jboss.netty.buffer.ChannelBuffer buffer)
          This method encodes an Encapsulated instance into an Icap Message.
 IcapMessageElementEnum getNextEntry()
          Iterator method.
 void setEntryAsProcessed(IcapMessageElementEnum entryName)
          reports that a given entry was processed and that the @see Encapsulated#getNextEntry() can now return the next entry in line or null if no more are present.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Encapsulated

public Encapsulated()

Encapsulated

public Encapsulated(String headerValue)
Creates an instance based on the value given.

Parameters:
headerValue - valid Encapsulated value.
Method Detail

containsEntry

public boolean containsEntry(IcapMessageElementEnum entity)
Gets whether a given entry exists in the header value.

Parameters:
entity - the entity such as REQHDR, RESHDR and so on.
Returns:
boolean true if the entity in question is present.

containsBodyEntry

public IcapMessageElementEnum containsBodyEntry()
Gets whether the message contains a body entity. This can be any valid body entry including the null-body entity which indicates that the message does not contain. a body.

Returns:
the correct @see IcapMessageElementEnum value.

getNextEntry

public IcapMessageElementEnum getNextEntry()
Iterator method. This method will provide the next available Entry. Eventually it will return null. Whether to return the next valid entry in the list dependens on the

Returns:
@see IcapMessageElementEnum or null if no more entries are available.
See Also:
method.

setEntryAsProcessed

public void setEntryAsProcessed(IcapMessageElementEnum entryName)
reports that a given entry was processed and that the @see Encapsulated#getNextEntry() can now return the next entry in line or null if no more are present.

Parameters:
entryName - the entry that was procesed.

addEntry

public void addEntry(IcapMessageElementEnum name,
                     int position)
Sets an entry with it's corresponding position.

Parameters:
name - the name of the Entry.
position - the position of the entry within the icap message.

encode

public int encode(org.jboss.netty.buffer.ChannelBuffer buffer)
           throws UnsupportedEncodingException
This method encodes an Encapsulated instance into an Icap Message.

Parameters:
buffer - the Channelbuffer to encode into.
Returns:
the amount of bytes that where written to the buffer while encoding.
Throws:
UnsupportedEncodingException - If a character cannot be encoded in ASCII.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.