viper.descriptors.attributes
Class AttributePrototype

java.lang.Object
  extended byviper.descriptors.attributes.AbstractAttribute
      extended byviper.descriptors.attributes.AttributePrototype
All Implemented Interfaces:
java.lang.Cloneable

public class AttributePrototype
extends AbstractAttribute

This class is used as a factory for Attribute data.


Constructor Summary
AttributePrototype(AbstractAttribute old)
          Default copy constructor.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this Attribute.
 Attribute create()
          Create a new attribute using this Prototype as a template.
 Attribute create(Attribute old)
          Create a new attribute of the specified type using its constructor that takes an Attribute value (copy-constructor?).
static AttributePrototype createAttributePrototype(java.lang.String type, java.lang.String name, boolean dynamic)
          Creates a new attribute configuration.
 java.lang.String getLocalType()
          Gets the local part of the type name.
 java.lang.String getType()
          Returns the Attribute type, eg lvalue or bbox.
 org.w3c.dom.Element getXMLFormat(org.w3c.dom.Document root)
          Returns the format properly for config information.
static AttributePrototype parseAttributeConfig(org.w3c.dom.Element reader, boolean dynamic)
          Reads in the attribute prototype from the XML DOM node.
static AttributePrototype parseAttributeConfig(VReader reader, boolean mobile)
          Parses an Attribute configuration line.
 void setArchetype(org.w3c.dom.Element E)
          Sets the archetype associated with this descriptor.
 void setArchetype(java.lang.String S)
          Sets the archetype associated with this descriptor.
protected  void setDefaultValue(org.w3c.dom.Element defaultValue)
           
protected  void setDefaultValue(java.lang.String defaultValue)
          Some attributes may have a default value.
 void setDynamic(boolean dynamic)
          Set this to allow the attribute to vary from frame to frame.
 void setName(java.lang.String name)
          Sets the Attribute name.
 void setType(java.lang.String type)
          Sets the attribute type.
 java.lang.String toString()
          Gets the string representation of static Attribute data or an individual frame of static data.
 java.lang.String toString(boolean verbose, boolean endln)
          Gets the string representation of static Attribute data or an individual frame of static data.
 
Methods inherited from class viper.descriptors.attributes.AbstractAttribute
getArchetype, getDefault, getExtraConfigInXML, getExtraConfigString, getName, isDynamic, loadAttributeType, named, named, parseAnInt, resetDefault, setArchetype
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AttributePrototype

public AttributePrototype(AbstractAttribute old)
Default copy constructor.

Parameters:
old - the value to copy
Method Detail

getType

public java.lang.String getType()
Returns the Attribute type, eg lvalue or bbox.

Specified by:
getType in class AbstractAttribute
Returns:
The type.

getLocalType

public java.lang.String getLocalType()
Gets the local part of the type name.

Returns:
the local part of the type name. Might not be unique to a type, but it has been so far.

setType

public void setType(java.lang.String type)
             throws BadDataException
Sets the attribute type.

Parameters:
type - The new type.
Throws:
BadDataException - if Attributes.isType returns false.

setName

public void setName(java.lang.String name)
Sets the Attribute name.

Overrides:
setName in class AbstractAttribute
Parameters:
name - The new name.

setDynamic

public void setDynamic(boolean dynamic)
Set this to allow the attribute to vary from frame to frame.

Overrides:
setDynamic in class AbstractAttribute
Parameters:
dynamic - The value.

clone

public java.lang.Object clone()
Returns a clone of this Attribute.

Specified by:
clone in class AbstractAttribute
Returns:
a reference to a new Attribute with all the values of the original

getXMLFormat

public org.w3c.dom.Element getXMLFormat(org.w3c.dom.Document root)
Returns the format properly for config information.

Specified by:
getXMLFormat in class AbstractAttribute
Parameters:
root - the document to use when creating the element
Returns:
a dom element describing this attribute configuration

toString

public java.lang.String toString()
Gets the string representation of static Attribute data or an individual frame of static data. Use this for the classic GtfConfig format. Equivalent to toString( true, true ).

Returns:
String in gtf format for parsing

toString

public java.lang.String toString(boolean verbose,
                                 boolean endln)
Gets the string representation of static Attribute data or an individual frame of static data. Use this for the classic GtfConfig format. It isn't as useful as the newer format, although it is far more human-readable.

Parameters:
verbose - set to include ending [static] for static attributes
endln - set to include an endln
Returns:
a string in proper format of the data value

createAttributePrototype

public static AttributePrototype createAttributePrototype(java.lang.String type,
                                                          java.lang.String name,
                                                          boolean dynamic)
                                                   throws BadDataException
Creates a new attribute configuration.

Parameters:
type - the data type of the attribute
name - the name to give the attribute
dynamic - if the attribute may vary with the frame number
Returns:
the new attribute class definition
Throws:
BadDataException

parseAttributeConfig

public static AttributePrototype parseAttributeConfig(org.w3c.dom.Element reader,
                                                      boolean dynamic)
                                               throws BadDataException
Reads in the attribute prototype from the XML DOM node.

Parameters:
reader - the element to read in
dynamic - if the attribute may be dynamic
Returns:
the new descrition
Throws:
BadDataException

parseAttributeConfig

public static AttributePrototype parseAttributeConfig(VReader reader,
                                                      boolean mobile)
                                               throws BadDataException
Parses an Attribute configuration line.

Parameters:
reader - the VReader pointing at the line to be parsed
mobile - set true if this is an OBJECT Descriptor
Returns:
an AttributePrototype representing the line in the gtfcfg
Throws:
BadDataException

create

public Attribute create()
Create a new attribute using this Prototype as a template.

Returns:
A new Attribute with the specwith no data.
Throws:
java.lang.IllegalArgumentException - if the attribute is not valid

create

public Attribute create(Attribute old)
                 throws BadDataException
Create a new attribute of the specified type using its constructor that takes an Attribute value (copy-constructor?).

Parameters:
old - the attribute prototype or another copy of the same attribute type
Returns:
a new attribute that conforms to the old attribute type
Throws:
BadDataException

setDefaultValue

protected void setDefaultValue(java.lang.String defaultValue)
                        throws BadDataException
Some attributes may have a default value. If the type is set, this will check the string using Attributes.isGoodValue(Attribute,String).

Specified by:
setDefaultValue in class AbstractAttribute
Parameters:
defaultValue - What to set as the default.
Throws:
BadDataException - if Attributes.isGoodValue returns false.

setDefaultValue

protected void setDefaultValue(org.w3c.dom.Element defaultValue)
                        throws BadDataException
Specified by:
setDefaultValue in class AbstractAttribute
Throws:
BadDataException

setArchetype

public void setArchetype(org.w3c.dom.Element E)
                  throws BadDataException
Description copied from class: AbstractAttribute
Sets the archetype associated with this descriptor.

Overrides:
setArchetype in class AbstractAttribute
Parameters:
E - the description
Throws:
BadDataException

setArchetype

public void setArchetype(java.lang.String S)
                  throws BadDataException
Description copied from class: AbstractAttribute
Sets the archetype associated with this descriptor.

Overrides:
setArchetype in class AbstractAttribute
Parameters:
S - the description
Throws:
BadDataException