amwebarsentitlementservice.provider
Class ProviderTable

java.lang.Object
  |
  +--amwebarsentitlementservice.provider.ProviderTable
All Implemented Interfaces:
java.io.Serializable

public class ProviderTable
extends java.lang.Object
implements java.io.Serializable

This class stores all AMWebARSProviders of the AMWebARSEntitlementService. The class is a Singleton. There is only one instance of it. This class and the AMWebARSProvider fullfil the Single Instance by ID pattern.

See Also:
AMWebARSProvider, Serialized Form

Field Summary
static java.lang.String PROVIDER_TABLE_XML_NAME
           
 
Constructor Summary
protected ProviderTable()
           
 
Method Summary
 void clear()
          Removes all elements of the ProviderTable.
protected  java.lang.Object clone()
          It isn't permited to clone the object: The clone method throws the CloneNotSupportedException.
 boolean containsProvider(AMWebARSProvider provider)
          Tests whether a provider is contained in the ProviderTable.
 boolean containsProviderID(java.lang.String provider_id)
          Tests whether a Provider with given provider_id is contained in the ProviderTable.
 boolean equals(java.lang.Object other_object)
          Tests whether this ProviderTable is equal to another.
 void fromXML(org.jdom.Document xml_provider_table)
          Updates the ProviderTable from an XML datastructure.
static ProviderTable getInstance()
          Returns the only instance of the ProviderTable.
 AMWebARSProvider getProvider(java.lang.String provider_id)
          Returns a provider of a given provider_id.
 boolean isEmpty()
          Tests whether this Table contains no Providers.
 void load(java.io.InputStream in)
          Loads the ProviderTable from an input stream.
 AMWebARSProvider registerProvider(java.lang.String provider_id)
          Registers a new Provider in the ProviderTable.
 AMWebARSProvider removeProvider(AMWebARSProvider provider)
          Removes a Provider from the ProviderTable.
 AMWebARSProvider removeProvider(java.lang.String provider_id)
          Removes a Provider with given provider_id from the ProviderTable.
 int size()
          Returns the size of the table that means the number of provider 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 ProviderTable to XML.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROVIDER_TABLE_XML_NAME

public static final java.lang.String PROVIDER_TABLE_XML_NAME
Constructor Detail

ProviderTable

protected ProviderTable()
Method Detail

getInstance

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

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 -  

getProvider

public AMWebARSProvider getProvider(java.lang.String provider_id)
                             throws java.util.NoSuchElementException
Returns a provider of a given provider_id. If the provider isn't found an exception is thrown.
Parameters:
provider_id - String ID of the provider
Returns:
provider of given id.
Throws:
java.util.NoSuchElementException - If the provider isn't found.

registerProvider

public AMWebARSProvider registerProvider(java.lang.String provider_id)
Registers a new Provider in the ProviderTable. The instance is generated by the ProviderTable.
Parameters:
provider_id - String ID of the Provider that is registered.
Returns:
generated Provider
Throws:
NullPointerException - if parameter is null

removeProvider

public AMWebARSProvider removeProvider(java.lang.String provider_id)
                                throws java.util.NoSuchElementException
Removes a Provider with given provider_id from the ProviderTable. The removed Provider is returned.
Parameters:
String - provider_id of the Provider to be removed
Returns:
removed Provider
Throws:
java.util.NoSuchElementException - if the Provider isn't found
NullPointerException - if parameter is null

removeProvider

public AMWebARSProvider removeProvider(AMWebARSProvider provider)
                                throws java.util.NoSuchElementException
Removes a Provider from the ProviderTable. The removed Provider is returned.
Parameters:
provider - Provider to be removed
Returns:
removed Provider
Throws:
java.util.NoSuchElementException - if the Provider isn't found
NullPointerException - if parameter is null

containsProvider

public boolean containsProvider(AMWebARSProvider provider)
Tests whether a provider is contained in the ProviderTable.
Parameters:
provider - Provider to be looked for.
Returns:
boolean true, if the ProviderTable contains the Provider
Throws:
NullPointerException - if parameter is null

containsProviderID

public boolean containsProviderID(java.lang.String provider_id)
Tests whether a Provider with given provider_id is contained in the ProviderTable.
Parameters:
provider_id - String ID of the Provider to be looked for.
Returns:
boolean true, if the ProviderTable contains the Provider
Throws:
NullPointerException - if parameter is null

size

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

isEmpty

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

clear

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

equals

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

toString

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

toXML

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

fromXML

public void fromXML(org.jdom.Document xml_provider_table)
             throws sun.io.MalformedInputException
Updates the ProviderTable from an XML datastructure. The content of the table is overwritten.
Parameters:
xml_provider_table - Document that describes the table.

load

public void load(java.io.InputStream in)
          throws java.io.IOException,
                 org.jdom.JDOMException
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