eu.semaine.datatypes.stateinfo
Class StateInfo

java.lang.Object
  extended by eu.semaine.datatypes.stateinfo.StateInfo
Direct Known Subclasses:
AgentStateInfo, DialogStateInfo, UserStateInfo

public abstract class StateInfo
extends java.lang.Object

A class representing one of the information states. It can be created either from an XML document or from a Map of information items, and can be read either as an XML document or as a Map of information items.

Author:
marc

Field Summary
protected  java.lang.String apiVersion
           
protected  org.w3c.dom.Document doc
           
protected  java.util.Map<java.lang.String,java.lang.String> info
           
protected  JMSLogger log
           
protected  java.lang.String stateName
           
 
Constructor Summary
protected StateInfo(org.w3c.dom.Document doc, java.lang.String whatState, java.lang.String apiVersion, java.lang.String rootName, java.lang.String rootNamespace)
           
  StateInfo(java.util.Map<java.lang.String,java.lang.String> infoItems, java.lang.String whatState, java.lang.String apiVersion)
           
 
Method Summary
protected  void analyseDocument(java.lang.String rootName, java.lang.String rootNamespace)
          Read information from the message document and fill our info as much as possible.
protected  boolean analyseElement(org.w3c.dom.Element el)
          Make sense of elements in the markup that come directly below the document element.
protected abstract  void createDocumentFromInfo()
           
 java.lang.String getAPIVersion()
           
 org.w3c.dom.Document getDocument()
           
 java.util.Map<java.lang.String,java.lang.String> getInfo()
          Provide a read-only access to the information in this message.
protected abstract  void setupInfoKeys()
          Set up the possible values that we can know about.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

info

protected java.util.Map<java.lang.String,java.lang.String> info

doc

protected org.w3c.dom.Document doc

log

protected JMSLogger log

stateName

protected java.lang.String stateName

apiVersion

protected java.lang.String apiVersion
Constructor Detail

StateInfo

protected StateInfo(org.w3c.dom.Document doc,
                    java.lang.String whatState,
                    java.lang.String apiVersion,
                    java.lang.String rootName,
                    java.lang.String rootNamespace)
             throws MessageFormatException
Throws:
MessageFormatException

StateInfo

public StateInfo(java.util.Map<java.lang.String,java.lang.String> infoItems,
                 java.lang.String whatState,
                 java.lang.String apiVersion)
Method Detail

setupInfoKeys

protected abstract void setupInfoKeys()
Set up the possible values that we can know about. Things that are not previewed here will not be read from the document. When this changes, the APIVersion must change with it.


createDocumentFromInfo

protected abstract void createDocumentFromInfo()

analyseElement

protected boolean analyseElement(org.w3c.dom.Element el)
                          throws MessageFormatException
Make sense of elements in the markup that come directly below the document element. This base version can interpret markup for which the 'set' attribute is a key in the info map. Subclasses will need to override this method to get additional analysis functionality. They can call super.analyseElement(el) to access this implementation.

Parameters:
el - an element whose parent is the document element.
Returns:
true if the element could be analysed, false otherwise.
Throws:
MessageFormatException

analyseDocument

protected void analyseDocument(java.lang.String rootName,
                               java.lang.String rootNamespace)
                        throws MessageFormatException
Read information from the message document and fill our info as much as possible. If information is found that cannot be interpreted, the code will emit a warning but continue to work.

Throws:
MessageFormatException - if the structure of the document is inconsistent, i.e. structure expectations are violated.

getInfo

public java.util.Map<java.lang.String,java.lang.String> getInfo()
Provide a read-only access to the information in this message. The map contains as keys all information that can be known according to the API version, and as non-null values the values taken from the message. Values for information items not contained in the message will be null.

Returns:
a map with string keys and string values.

getDocument

public org.w3c.dom.Document getDocument()

toString

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

getAPIVersion

public java.lang.String getAPIVersion()