hmi.environment.avatars
Class VirtualHumanSpec

java.lang.Object
  extended by hmi.xml.XMLStructureAdapter
      extended by hmi.environment.avatars.VirtualHumanSpec
All Implemented Interfaces:
XMLStructure
Direct Known Subclasses:
VirtualHumanSpecHmi

public class VirtualHumanSpec
extends XMLStructureAdapter

This is like the 'personnel card' of a virtual human that you want to be created by the VIrtualHumanLoader for putting it in Elckerlyc. A spec consists of a number of named sections (Face, Voice, Body, ...). Each segment has a number of named parameters. A parameter can in principle be any kind of object; e.g., the "gesturebinding" section has a parameter names "gesturebinding" that is, actually, a Gesturebindingh Specs are stored in XML. The order in which things occur in the XML matters: later values for the same section / parameter overwrite values specified earlier in the file. There are two ways to load an XML file with a VirtualHumanSpec. 1) create a new spec of the right type; load the XML into it 2) you already have a spec of the right type; take the STag, then load the content into the already existing spec; then take the STag This class uses SpecLoaders to load parts of the content; a SpecLoader uses the addParameter callback to add data to this spec. Note that for some of the parameters, if they are null, some hard coded default may be used, while in other cases the system may simply omit that aspect from the avatar. E.g., when you do not specify a VoiceSpec, the virtual human will be loaded with no voice planner; but if you omit the BodySpec, you will get a default body :)

Author:
Dennis Reidsma

Field Summary
static String IMPL_VERSION
           
private  HashMap<String,HashMap<String,Object>> sections
           
private  Resources specRes
           
private static String XMLTAG
           
 
Fields inherited from class hmi.xml.XMLStructureAdapter
ATTRIBUTE_TOKEN_DELIMITERS, COMMA_SEPARATOR, DECODEDARRAYSIZE, DEFAULT_RECOVER_MODE, NEWLINE, SYSTEMNEWLINE, TAB, TAB_STRING
 
Constructor Summary
VirtualHumanSpec(Resources newRes)
           
 
Method Summary
 void addSpecParameter(String sectionName, String parameterName, Object parameterValue)
          Add a parameter to the given section.
 boolean canReadSpecType(String tag)
          return true iff the given XMLtag is of a type that this VirtualHumanSPec can read.
 void decodeAttributes(HashMap<String,String> attrMap, XMLTokenizer tokenizer)
          decodes all attributes.
 void decodeContent(XMLTokenizer tokenizer)
          read the content in order; for each encountered element, get a loader that will interpret its content and load it into this spec.
(package private)  SpecLoader getLoader(String type)
          Get a Specloader, for the given element type, attached to this spec Extend this method for subclasses to add extra element types...
 Object getSpecParameter(String sectionName, String parameterName)
           
 Object getSpecParameter(String sectionName, String parameterName, Object defaultValue)
           
 Resources getSpecResources()
           
 String getXMLTag()
          The XML Stag for XML encoding -- use this method to find out the run-time xml tag of an object
static String xmlTag()
          The XML Stag for XML encoding -- use this static method when you want to see if a given String equals the xml tag for this class
 
Methods inherited from class hmi.xml.XMLStructureAdapter
appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttributes, appendAttributes, appendAttributeString, appendAttributeString, appendBooleans, appendCloseEmptyTag, appendCloseSTag, appendComment, appendContent, appendContent, appendDoubleElement, appendEmptyTag, appendEmptyTag, appendEmptyTag, appendEmptyTag, appendEmptyTag, appendEmptyTag, appendETag, appendETag, appendFloatArrayElement, appendFloatElement, appendFloats, appendIntArrayElement, appendIntElement, appendInts, appendLongElement, appendNewLine, appendNewLine, appendNewLine, appendOpenSTag, appendOptionalDoubleElement, appendOptionalFloatElement, appendOptionalIntElement, appendOptionalLongElement, appendSpaces, appendSpaces, appendSTag, appendSTag, appendSTag, appendStringArrayElement, appendStrings, appendSystemNewLine, appendTab, appendTextElement, appendXML, appendXML, appendXML, appendXML, appendXML, appendXMLStructure, appendXMLStructureList, appendXMLTextElementList, countTokens, countTokens, decodeAttribute, decodeAttribute, decodeBoolean, decodeBooleanArray, decodeBooleanArray, decodeBooleanArray, decodeBooleanArray, decodeDouble, decodeDoubleArray, decodeDoubleArray, decodeDoubleArray, decodeDoubleArray, decodeFloat, decodeFloatArray, decodeFloatArray, decodeFloatArray, decodeFloatArray, decodeInt, decodeIntArray, decodeIntArray, decodeIntArray, decodeIntArray, decodeLong, decodeStringArray, decodeStringArray, decodeStringArray, decodeStringArray, decodeXMLStructureList, decodeXMLValueElement, getNamespace, getOptionalAttribute, getOptionalAttribute, getOptionalBooleanAttribute, getOptionalDoubleAttribute, getOptionalFloatAttribute, getOptionalIntAttribute, getOptionalLongAttribute, getRequiredAttribute, getRequiredBooleanAttribute, getRequiredDoubleAttribute, getRequiredFloatAttribute, getRequiredIntAttribute, getRequiredLongAttribute, getTagLine, hasContent, parseXMLElement, postProcess, preProcess, readXML, readXML, readXML, setConsoleAttributeEnabled, setDefaultRecoverMode, setRecoverMode, spaces, toString, toXMLString, toXMLString, toXMLString, toXMLString, toXMLString, toXMLString, writeXML, writeXML, writeXML, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IMPL_VERSION

public static final String IMPL_VERSION
See Also:
Constant Field Values

specRes

private Resources specRes

sections

private HashMap<String,HashMap<String,Object>> sections

XMLTAG

private static final String XMLTAG
See Also:
Constant Field Values
Constructor Detail

VirtualHumanSpec

public VirtualHumanSpec(Resources newRes)
Method Detail

getSpecResources

public Resources getSpecResources()

decodeAttributes

public void decodeAttributes(HashMap<String,String> attrMap,
                             XMLTokenizer tokenizer)
Description copied from class: XMLStructureAdapter
decodes all attributes. The default implementation calls decodeAttribute for every attribute in turn. The decodeAttributes method can be reimplemented when attributes must be processed in some particular order.

Overrides:
decodeAttributes in class XMLStructureAdapter

decodeContent

public void decodeContent(XMLTokenizer tokenizer)
                   throws IOException
read the content in order; for each encountered element, get a loader that will interpret its content and load it into this spec.

Overrides:
decodeContent in class XMLStructureAdapter
Throws:
IOException

getLoader

SpecLoader getLoader(String type)
Get a Specloader, for the given element type, attached to this spec Extend this method for subclasses to add extra element types... also, if you want, for a specialized type of spec, to have other loaders interpret a certain section, you can also override this method...


addSpecParameter

public void addSpecParameter(String sectionName,
                             String parameterName,
                             Object parameterValue)
Add a parameter to the given section. Overwrite value possibly stored earlier.


getSpecParameter

public Object getSpecParameter(String sectionName,
                               String parameterName,
                               Object defaultValue)
Returns:
the value of the given parameter in the give section, or default if it doesn't exist

getSpecParameter

public Object getSpecParameter(String sectionName,
                               String parameterName)
Returns:
the value of the given parameter in the give section, or null if it doesn't exist

canReadSpecType

public boolean canReadSpecType(String tag)
return true iff the given XMLtag is of a type that this VirtualHumanSPec can read.


xmlTag

public static String xmlTag()
The XML Stag for XML encoding -- use this static method when you want to see if a given String equals the xml tag for this class


getXMLTag

public String getXMLTag()
The XML Stag for XML encoding -- use this method to find out the run-time xml tag of an object

Specified by:
getXMLTag in interface XMLStructure
Overrides:
getXMLTag in class XMLStructureAdapter