anon.terms
Class TermsAndConditions

java.lang.Object
  extended by anon.terms.TermsAndConditions
All Implemented Interfaces:
IXMLEncodable

public class TermsAndConditions
extends java.lang.Object
implements IXMLEncodable

This is the container for the operator specific sections of Terms and Conditions with all its translations. Any translation refers to a Terms and Conditions template which serves as a 'frame' in which the operator specific sections are displayed. This enables reusability of very common terms which are needed by all operators. operator. A terms and conditions container is referenced by the subject key identifier of its operator. The translations are stored in the context of this object and are referenced by the two letter country code. A Terms and conditions container is either empty or must at least provide the default translation. An empty container cannot be transferred into an XML-DOM-structure.


Nested Class Summary
private  class TermsAndConditions.Translation
          Class that represents a translation of the enclosing terms and conditions.
 
Field Summary
private  boolean accepted
           
static java.lang.String DATE_FORMAT
           
private  TermsAndConditions.Translation defaultTl
           
private  java.util.Date m_date
           
private static java.lang.String MSG_DISPLAY_ERROR
           
private  ServiceOperator operator
           
private static java.util.Hashtable tcHashtable
           
private  java.util.Hashtable translations
           
static java.lang.String XML_ATTR_ACCEPTED
           
static java.lang.String XML_ATTR_DATE
           
static java.lang.String XML_ELEMENT_CONTAINER_NAME
           
static java.lang.String XML_ELEMENT_NAME
           
static java.lang.String XML_ELEMENT_TRANSLATION_NAME
           
 
Fields inherited from interface anon.util.IXMLEncodable
FIELD_XML_ELEMENT_CONTAINER_NAME, FIELD_XML_ELEMENT_NAME, XML_ATTR_ID, XML_ATTR_LANGUAGE, XML_ATTR_VERSION
 
Constructor Summary
TermsAndConditions(org.w3c.dom.Element termsAndConditionRoot)
          Creates a TermsAndConditions container from the given XML DOM element with all translation that are stored within this element.
TermsAndConditions(org.w3c.dom.Element termsAndConditionRoot, ServiceOperator operator, boolean withSignatureCheck)
          Creates a TermsAndConditions container from the given XML DOM element with all translation that are stored within this element.
TermsAndConditions(ServiceOperator operator, java.util.Date date)
          Creates an empty Terms And Condition object for the specified id and validation date which serves as a container for the different translations.
TermsAndConditions(ServiceOperator operator, java.lang.String date)
           
 
Method Summary
 void addTranslation(org.w3c.dom.Element translationRoot)
          adds a T&C translation which specified by the DOMElement translationRoot
private  void addTranslation(TermsAndConditions.Translation t, boolean withSignatureCheck)
           
 int compareTo(java.lang.Object o)
           
 org.w3c.dom.Element createTCRoot(org.w3c.dom.Document doc)
           
 org.w3c.dom.Element createXMLOutput(org.w3c.dom.Document doc)
           
 boolean equals(java.lang.Object anotherTC)
           
static org.w3c.dom.Element getAllTermsAndConditionsAsXMLElement(org.w3c.dom.Document ownerDoc)
           
 java.util.Enumeration getAllTranslations()
          returns all translations of this T&C container
 java.util.Date getDate()
          return a date object which holds the date from when these T&Cs became valid
 java.lang.String getDateString()
          returns the date as String in the format 'yyyyMMdd' from when these T&Cs became valid
 TermsAndConditionsTranslation getDefaultTranslation()
          returns the default translation of the T&C which is displayed if there is no translation available for current display language
 java.lang.String getHTMLText(java.util.Locale locale)
           
 java.lang.String getHTMLText(java.lang.String language)
           
static java.lang.String getHTMLText(TermsAndConditionsTranslation translation)
           
 ServiceOperator getOperator()
          returns the ServiceOperator-DBEntry referring to the operator to whom these T&C belong.
 java.lang.String getTemplateReferenceId(java.lang.String locale)
          return the id of the template which is needed to render the translation specified by the two-letter language code
static TermsAndConditions getTermsAndConditions(ServiceOperator operator)
           
 TermsAndConditionsTranslation getTranslation(java.util.Locale locale)
          returns the translation of the T&C specified by the corresponding locale object
 TermsAndConditionsTranslation getTranslation(java.lang.String locale)
          returns the translation of the T&C specified by the two letter language code
 boolean hasDefaultTranslation()
          for checking if a default translation is specified which must be true if this T&C container is not empty.
 boolean hasTranslation(java.util.Locale locale)
          for checking if this T&C container provides a translation specified by the given locale object
 boolean hasTranslation(java.lang.String locale)
          returns if this T&C container provides a translation specified by the two-letter language code
 boolean hasTranslations()
          for checking whether this T&C container has stored translations at all
 TermsAndConditionsTranslation initializeEmptyTranslation(java.util.Locale locale)
           
 TermsAndConditionsTranslation initializeEmptyTranslation(java.lang.String locale)
           
 boolean isAccepted()
          returns whether these T&C are accepted by the user this is true if and only if they were read and accepted.
 boolean isMostRecent(java.util.Date toWhichDate)
          true if the date of the T&Cs are equal or more recent than 'toWhichDate'
 boolean isMostRecent(java.lang.String toWhichDate)
           
 boolean isSignatureObsolete()
           
static void loadTermsAndConditionsFromXMLElement(org.w3c.dom.Element listRoot)
           
static void removeTermsAndConditions(ServiceOperator operator)
           
static void removeTermsAndConditions(TermsAndConditions tc)
           
 TermsAndConditionsTranslation removeTranslation(java.util.Locale locale)
           
 TermsAndConditionsTranslation removeTranslation(java.lang.String locale)
           
 void setAccepted(boolean accepted)
          marks the T&Cs as accepted if 'accepted' is true or rejected otherwise
 void setDate(java.util.Date date)
           
static void storeTermsAndConditions(TermsAndConditions tc)
           
 org.w3c.dom.Element toXmlElement(org.w3c.dom.Document doc)
          Return an element that can be appended to the document.
private  org.w3c.dom.Element xmlOut(org.w3c.dom.Document doc, boolean signedTranslations)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_ATTR_ACCEPTED

public static final java.lang.String XML_ATTR_ACCEPTED
See Also:
Constant Field Values

XML_ATTR_DATE

public static final java.lang.String XML_ATTR_DATE
See Also:
Constant Field Values

MSG_DISPLAY_ERROR

private static final java.lang.String MSG_DISPLAY_ERROR

XML_ELEMENT_CONTAINER_NAME

public static final java.lang.String XML_ELEMENT_CONTAINER_NAME
See Also:
Constant Field Values

XML_ELEMENT_NAME

public static final java.lang.String XML_ELEMENT_NAME
See Also:
Constant Field Values

XML_ELEMENT_TRANSLATION_NAME

public static final java.lang.String XML_ELEMENT_TRANSLATION_NAME
See Also:
Constant Field Values

DATE_FORMAT

public static final java.lang.String DATE_FORMAT
See Also:
Constant Field Values

operator

private ServiceOperator operator

m_date

private java.util.Date m_date

translations

private java.util.Hashtable translations

defaultTl

private TermsAndConditions.Translation defaultTl

accepted

private boolean accepted

tcHashtable

private static final java.util.Hashtable tcHashtable
Constructor Detail

TermsAndConditions

public TermsAndConditions(ServiceOperator operator,
                          java.lang.String date)
                   throws java.text.ParseException
Throws:
java.text.ParseException

TermsAndConditions

public TermsAndConditions(ServiceOperator operator,
                          java.util.Date date)
                   throws java.text.ParseException
Creates an empty Terms And Condition object for the specified id and validation date which serves as a container for the different translations.

Throws:
java.text.ParseException

TermsAndConditions

public TermsAndConditions(org.w3c.dom.Element termsAndConditionRoot)
                   throws XMLParseException,
                          java.text.ParseException,
                          java.security.SignatureException
Creates a TermsAndConditions container from the given XML DOM element with all translation that are stored within this element. The ServiceOperator ID will be extracted from termsAndConditionsRoot

Parameters:
termsAndConditionRoot - the DOM Element from which the Container will be created
Throws:
XMLParseException - if termsAndConditionsRoot does not provide a valid operator SKI or the date attribute is missing
java.text.ParseException - if the date is in a wrong format (must be .
java.security.SignatureException - if the signature of a Terms and Conditions translation has no valid signature.

TermsAndConditions

public TermsAndConditions(org.w3c.dom.Element termsAndConditionRoot,
                          ServiceOperator operator,
                          boolean withSignatureCheck)
                   throws XMLParseException,
                          java.text.ParseException,
                          java.security.SignatureException
Creates a TermsAndConditions container from the given XML DOM element with all translation that are stored within this element. The ServiceOperator ID from op is used if it is not null. Otherwise the ID will be extracted from termsAndConditionsRoot

Parameters:
termsAndConditionRoot - the DOM Element from which the Container will be created
op - the Operator to whom these Terms And Conditions belong
Throws:
XMLParseException - if op is null and termsAndConditionsRoot does not provide a valid operator SKI or the date attribute is missing
java.text.ParseException - if the date is in a wrong format.
java.security.SignatureException - if the signature of a Terms and Conditions translation has no valid signature.
Method Detail

getDateString

public java.lang.String getDateString()
returns the date as String in the format 'yyyyMMdd' from when these T&Cs became valid

Returns:
the date in the format 'yyyyMMdd' from when these T&Cs became valid

addTranslation

public void addTranslation(org.w3c.dom.Element translationRoot)
                    throws XMLParseException,
                           java.security.SignatureException
adds a T&C translation which specified by the DOMElement translationRoot

Parameters:
translationRoot - the DOMELement form which the translation should be appended to the T&Cs container
Throws:
XMLParseException - if the translation does not refer to a valid T&C template or the 'locale' attribute which specifies the language is not set.
java.security.SignatureException - if translationRoot does not contain a valid signature

removeTranslation

public TermsAndConditionsTranslation removeTranslation(java.lang.String locale)

removeTranslation

public TermsAndConditionsTranslation removeTranslation(java.util.Locale locale)

initializeEmptyTranslation

public TermsAndConditionsTranslation initializeEmptyTranslation(java.lang.String locale)

initializeEmptyTranslation

public TermsAndConditionsTranslation initializeEmptyTranslation(java.util.Locale locale)

addTranslation

private void addTranslation(TermsAndConditions.Translation t,
                            boolean withSignatureCheck)
                     throws java.security.SignatureException
Throws:
java.security.SignatureException

getDefaultTranslation

public TermsAndConditionsTranslation getDefaultTranslation()
returns the default translation of the T&C which is displayed if there is no translation available for current display language

Returns:
the default T&C translation

getTranslation

public TermsAndConditionsTranslation getTranslation(java.util.Locale locale)
returns the translation of the T&C specified by the corresponding locale object

Parameters:
locale - the locale refering to the desired translation language
Returns:
the desired T&C translation or null if the translation does not exist.

getTranslation

public TermsAndConditionsTranslation getTranslation(java.lang.String locale)
returns the translation of the T&C specified by the two letter language code

Parameters:
the - two letter code specifying the desired translation langugae
Returns:
the desired T&C translation or null if the translation does not exist.

getAllTranslations

public java.util.Enumeration getAllTranslations()
returns all translations of this T&C container

Returns:
all translations as (implementing interface TermsAndConditionsTranslation) of this T&C container as an enumeration.

getTemplateReferenceId

public java.lang.String getTemplateReferenceId(java.lang.String locale)
return the id of the template which is needed to render the translation specified by the two-letter language code

Parameters:
locale -
Returns:

hasTranslation

public boolean hasTranslation(java.lang.String locale)
returns if this T&C container provides a translation specified by the two-letter language code

Parameters:
locale - the two letter-code of the language
Returns:
true if the specified translation exists, false otherwise

hasTranslation

public boolean hasTranslation(java.util.Locale locale)
for checking if this T&C container provides a translation specified by the given locale object

Parameters:
locale - locale object referring to the corresponding language
Returns:
true if the specified translation exists, false otherwise

hasTranslations

public boolean hasTranslations()
for checking whether this T&C container has stored translations at all

Returns:
true if this T&C container provides at least one translation, false otherwise.

hasDefaultTranslation

public boolean hasDefaultTranslation()
for checking if a default translation is specified which must be true if this T&C container is not empty.

Returns:
true if this T&C container has a default translation false otherwise

getOperator

public ServiceOperator getOperator()
returns the ServiceOperator-DBEntry referring to the operator to whom these T&C belong.

Returns:

setDate

public void setDate(java.util.Date date)

getDate

public java.util.Date getDate()
return a date object which holds the date from when these T&Cs became valid

Returns:
a date object which holds the date from when these T&Cs became valid.

setAccepted

public void setAccepted(boolean accepted)
marks the T&Cs as accepted if 'accepted' is true or rejected otherwise

Parameters:
accepted - true stands for accept, false for reject

isAccepted

public boolean isAccepted()
returns whether these T&C are accepted by the user this is true if and only if they were read and accepted.

Returns:
true if and only if the T&Cs were read and accepted, false otherwise

storeTermsAndConditions

public static void storeTermsAndConditions(TermsAndConditions tc)

getTermsAndConditions

public static TermsAndConditions getTermsAndConditions(ServiceOperator operator)

removeTermsAndConditions

public static void removeTermsAndConditions(TermsAndConditions tc)

removeTermsAndConditions

public static void removeTermsAndConditions(ServiceOperator operator)

getAllTermsAndConditionsAsXMLElement

public static org.w3c.dom.Element getAllTermsAndConditionsAsXMLElement(org.w3c.dom.Document ownerDoc)

loadTermsAndConditionsFromXMLElement

public static void loadTermsAndConditionsFromXMLElement(org.w3c.dom.Element listRoot)

getHTMLText

public java.lang.String getHTMLText(java.util.Locale locale)

getHTMLText

public java.lang.String getHTMLText(java.lang.String language)

getHTMLText

public static java.lang.String getHTMLText(TermsAndConditionsTranslation translation)

isSignatureObsolete

public boolean isSignatureObsolete()

equals

public boolean equals(java.lang.Object anotherTC)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)

isMostRecent

public boolean isMostRecent(java.lang.String toWhichDate)
                     throws java.text.ParseException
Throws:
java.text.ParseException

isMostRecent

public boolean isMostRecent(java.util.Date toWhichDate)
true if the date of the T&Cs are equal or more recent than 'toWhichDate'


xmlOut

private org.w3c.dom.Element xmlOut(org.w3c.dom.Document doc,
                                   boolean signedTranslations)

createTCRoot

public org.w3c.dom.Element createTCRoot(org.w3c.dom.Document doc)

toXmlElement

public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document doc)
Description copied from interface: IXMLEncodable
Return an element that can be appended to the document. This Method must not change the document in any way!

Specified by:
toXmlElement in interface IXMLEncodable
Parameters:
doc - a document
Returns:
the interface as xml element

createXMLOutput

public org.w3c.dom.Element createXMLOutput(org.w3c.dom.Document doc)