com.pushtotest.tool.protocolhandler
Class HeaderWrapper

java.lang.Object
  extended by com.pushtotest.tool.protocolhandler.HeaderWrapper
All Implemented Interfaces:
Header
Direct Known Subclasses:
HTTPHeader, SOAPHeader, XMLRPCHeader

public abstract class HeaderWrapper
extends java.lang.Object
implements Header

This is an abstract class that implements the non-type specific parts of the header interface. This will make it easy to implement new wrappers by inheriting from this rather than having to just reimplment the interface over and over.


Field Summary
protected  java.util.Map headers
           
 
Constructor Summary
HeaderWrapper()
           
 
Method Summary
 java.lang.String get(java.lang.String name)
          Returns the value of a single header variable as a String.
 java.util.Iterator getHeaders()
          Returns an Itterator of all of the header values so that they user can get the list and then get the values.
abstract  java.lang.String id()
          Returns an id for this protocol.
 void set(java.lang.String name, java.lang.String value)
          Sets a parameter value pair as something that should be set in the header of this protocol.
 void set(java.lang.String name, java.lang.String value, boolean encode)
          Sets a parameter value pair as something that should be set in the header of this protocol.
abstract  java.lang.String toString()
          Returns the content of the header to be used by the Protocol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

headers

protected java.util.Map headers
Constructor Detail

HeaderWrapper

public HeaderWrapper()
Method Detail

id

public abstract java.lang.String id()
Returns an id for this protocol. The id is a string that will be used to uniquily identify the protocol. For example :// would be appropriate (without the "://").

Specified by:
id in interface Header
Returns:
The id for this Protocol.

set

public void set(java.lang.String name,
                java.lang.String value)
Sets a parameter value pair as something that should be set in the header of this protocol. This delegates to the set(name,value,encode) method passing through the values and setting encode to 'false'.

Specified by:
set in interface Header
Parameters:
name - The name of the header variable.
value - The value to set for this header variable.

set

public void set(java.lang.String name,
                java.lang.String value,
                boolean encode)
Sets a parameter value pair as something that should be set in the header of this protocol. Optionally will encode the value with a protocol specific encoding. E.g. HTTP headers need to have some values Base64 encoded. This implementation does not do any encoding because the encoding type would be indeterminate.

Specified by:
set in interface Header
Parameters:
name - The name of the header variable.
value - The value to set for this header variable.
encode - Whether or not to encode the value with the right encoder for this type.

get

public java.lang.String get(java.lang.String name)
Returns the value of a single header variable as a String.

Specified by:
get in interface Header
Parameters:
name - The name of the header variable to look for.

getHeaders

public java.util.Iterator getHeaders()
Returns an Itterator of all of the header values so that they user can get the list and then get the values.

Specified by:
getHeaders in interface Header
Returns:
An Iterator to iterate over to get all of the values.

toString

public abstract java.lang.String toString()
Returns the content of the header to be used by the Protocol.

Specified by:
toString in interface Header
Overrides:
toString in class java.lang.Object
Returns:
All of the content that should be sent as the Protocol header.