amwebarsentitlementservice.protocol
Class ProtocolTable

java.lang.Object
  |
  +--amwebarsentitlementservice.protocol.ProtocolTable

public class ProtocolTable
extends java.lang.Object


Field Summary
static java.lang.String PROTOCOL_TABLE_XML_NAME
           
 
Constructor Summary
protected ProtocolTable()
           
 
Method Summary
 void clear()
          Removes all elements of the ProtocolTable.
protected  java.lang.Object clone()
          It isn't permited to clone the object: The clone method throws the CloneNotSupportedException.
 boolean containsProtocolID(java.lang.String protocol_id)
          Tests whether a Protocol prototype with given protocol_id is contained in the ProtocolTable.
 boolean containsProtocolPrototype(AMWebARSProtocol protocol_prototype)
          Tests whether a protocol prototype is contained in the ProtocolTable.
 boolean equals(java.lang.Object other_object)
          Tests whether this ProtocolTable is equal to another.
 void fromXML(org.jdom.Document xml_protocol_table)
          Updates the ProtocolTable from an XML datastructure.
 AMWebARSProtocol generateProtocol(java.lang.String protocol_id)
          Returns an instance of the Protocol with a given protocol_id.
static ProtocolTable getInstance()
          Returns the only instance of the ProtocolTable.
 AMWebARSProtocol getProtocolPrototype(java.lang.String protocol_id)
          Returns the prototype of the Protocol with a given protocol_id.
 void initProtocols()
          Initializes the AMWebARSProtocols of the Protocoltable.
 boolean isEmpty()
          Tests whether this Table contains no Protocols.
 java.util.Enumeration keys()
          Returns the Enumeration of all protocol_ids of the table.
 void load(java.io.InputStream in)
          Loads the ProviderTable from an input stream.
 AMWebARSProtocol registerProtocolPrototype(AMWebARSProtocol protocol_prototype)
          Registers a new prototype of Protocol in the ProtocolTable.
 AMWebARSProtocol removeProtocolPrototype(AMWebARSProtocol protocol_protoype)
          Removes a Protocol prototype from the ProtocolTable.
 AMWebARSProtocol removeProtocolPrototype(java.lang.String protocol_id)
          Removes a Protocol prototype with given protocol_id from the ProtocolTable.
 int size()
          Returns the size of the table that means the number of protocol stored in it.
 void store(java.io.OutputStream out)
          Stores the ProviderTable into an output stream.
 java.lang.String toString()
           
 org.jdom.Document toXML()
          Translates the ProtocolTable to XML.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROTOCOL_TABLE_XML_NAME

public static final java.lang.String PROTOCOL_TABLE_XML_NAME
Constructor Detail

ProtocolTable

protected ProtocolTable()
Method Detail

getInstance

public static ProtocolTable getInstance()
Returns the only instance of the ProtocolTable.
Returns:
only instance of ProtocolTable

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
It isn't permited to clone the object: The clone method throws the CloneNotSupportedException.
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException -  

getProtocolPrototype

public AMWebARSProtocol getProtocolPrototype(java.lang.String protocol_id)
                                      throws java.util.NoSuchElementException
Returns the prototype of the Protocol with a given protocol_id. If the protocol isn't found an exception is thrown.
Parameters:
protocol_id - String ID of the protocol
Returns:
prototype of Protocol with given id.
Throws:
java.util.NoSuchElementException - If the protocol isn't found.

generateProtocol

public AMWebARSProtocol generateProtocol(java.lang.String protocol_id)
                                  throws java.util.NoSuchElementException,
                                         java.lang.CloneNotSupportedException
Returns an instance of the Protocol with a given protocol_id. If the protocol isn't found an exception is thrown. The protocol returned is a clone of the prototype stored in the table. Its state is independent of the prototype.
Parameters:
protocol_id - String ID of the protocol
Returns:
prototype of Protocol with given id.
Throws:
java.util.NoSuchElementException - If the protocol isn't found.
java.lang.CloneNotSupportedException - If the Protocol doesn't support cloning

registerProtocolPrototype

public AMWebARSProtocol registerProtocolPrototype(AMWebARSProtocol protocol_prototype)
Registers a new prototype of Protocol in the ProtocolTable. It's registered under it's own protocol_id.
Parameters:
protocol_prototype - Protocol that is registered.
Returns:
registered Protocol

removeProtocolPrototype

public AMWebARSProtocol removeProtocolPrototype(java.lang.String protocol_id)
                                         throws java.util.NoSuchElementException
Removes a Protocol prototype with given protocol_id from the ProtocolTable. The removed Protocol prototype is returned.
Parameters:
String - protocol_id of the Protocol to be removed
Returns:
removed Protocol
Throws:
java.util.NoSuchElementException - if the Protocol isn't found

removeProtocolPrototype

public AMWebARSProtocol removeProtocolPrototype(AMWebARSProtocol protocol_protoype)
                                         throws java.util.NoSuchElementException
Removes a Protocol prototype from the ProtocolTable. The removed Protocol prototype is returned.
Parameters:
protocol - Protocol prototype to be removed
Returns:
removed Protocol prototype
Throws:
java.util.NoSuchElementException - if the Protocol isn't found

containsProtocolPrototype

public boolean containsProtocolPrototype(AMWebARSProtocol protocol_prototype)
Tests whether a protocol prototype is contained in the ProtocolTable.
Parameters:
protocol_prototype - Protocol to be looked for.
Returns:
boolean true, if the ProtocolTable contains the Protocol prototype
Throws:
NullPointerException - if the parameter is null

containsProtocolID

public boolean containsProtocolID(java.lang.String protocol_id)
Tests whether a Protocol prototype with given protocol_id is contained in the ProtocolTable.
Parameters:
protocol_id - String ID of the Protocol prototype to be looked for.
Returns:
boolean true, if the ProtocolTable contains the Protocol prototype
Throws:
NullPointerException - if the parameter is null

keys

public java.util.Enumeration keys()
Returns the Enumeration of all protocol_ids of the table.
Returns:
Eumeration of all keys

size

public int size()
Returns the size of the table that means the number of protocol stored in it.
Returns:
int number of protocols

isEmpty

public boolean isEmpty()
Tests whether this Table contains no Protocols.
Returns:
boolean true if the table is empty

clear

public void clear()
Removes all elements of the ProtocolTable.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other_object)
Tests whether this ProtocolTable is equal to another.
Overrides:
equals in class java.lang.Object
Returns:
boolean true if both obj are the same.

initProtocols

public void initProtocols()
                   throws ProtocolLoadException
Initializes the AMWebARSProtocols of the Protocoltable. Dependent on the config key ConfigKeys.PROTOCOL_MODULE_LOAD_FROM_CONFIG_KEY the method looks for the list of protocols to be loaded in the general configuration or in another ProtocolTable XML config file.
Throws:
ProtocolLoadException - if the XML file couldn't be accessed or an error in the instantiation of the protocols occured.

toXML

public org.jdom.Document toXML()
Translates the ProtocolTable to XML.
Returns:
XML Document of the ProtocolTable

fromXML

public void fromXML(org.jdom.Document xml_protocol_table)
             throws sun.io.MalformedInputException,
                    java.lang.ClassNotFoundException,
                    java.lang.NoSuchMethodException,
                    java.lang.InstantiationException,
                    java.lang.IllegalAccessException,
                    java.lang.reflect.InvocationTargetException
Updates the ProtocolTable from an XML datastructure. The content of the table is overwritten.
Parameters:
xml_protocol_table - Document that describes the table.

load

public void load(java.io.InputStream in)
          throws java.io.IOException,
                 org.jdom.JDOMException,
                 java.lang.ClassNotFoundException,
                 java.lang.NoSuchMethodException,
                 java.lang.InstantiationException,
                 java.lang.IllegalAccessException,
                 java.lang.reflect.InvocationTargetException
Loads the ProviderTable from an input stream. The input stream has to point to a source in XML format.
Parameters:
in - InputStream

store

public void store(java.io.OutputStream out)
           throws java.io.IOException
Stores the ProviderTable into an output stream.
Parameters:
out - OutputStream