viper.descriptors.attributes
Class AbstractAttribute

java.lang.Object
  extended byviper.descriptors.attributes.AbstractAttribute
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Attribute, AttributePrototype

public abstract class AbstractAttribute
extends java.lang.Object
implements java.lang.Cloneable

This class exists to give a shared base class to Attribute and AttributePrototype.


Constructor Summary
AbstractAttribute()
           
 
Method Summary
abstract  java.lang.Object clone()
          Copies the attribute.
 AttributeValue getArchetype()
          Gets the config value.
 AttributeValue getDefault()
          A default value is what an attribute is set to when created.
 org.w3c.dom.Element getExtraConfigInXML(org.w3c.dom.Document root)
          Gets the attribute-type-specific extended information, if it exists.
 java.lang.String getExtraConfigString()
          Determines how to print it out to the old gtf format
 java.lang.String getName()
          Returns the Attribute name. eg position, size, readability, etc.
abstract  java.lang.String getType()
          Returns the Attribute type, eg lvalue or bbox.
abstract  org.w3c.dom.Element getXMLFormat(org.w3c.dom.Document root)
          Returns an XML formatted version of this data.
 boolean isDynamic()
          A dynamic attribute can change from frame to frame.
static Measurable loadAttributeType(java.lang.String type)
          Makes sure the java class for an attribute is loaded.
 boolean named(java.lang.String S)
          Returns true if the Attribute is named S.
 boolean named(java.lang.String S, Equivalencies map)
          Returns true if the Attribute is named S or mapped to S under map.
protected static int parseAnInt(org.w3c.dom.Element domEl, java.lang.String name)
          Gets the int value of an XML attribute of the given XML element.
 void resetDefault(AttributeValue o)
          Modifies the attribute's default value.
 void setArchetype(AttributeValue archetype)
          ExtraConfig information is information concerning the data that is not expressed in the type itself.
 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 abstract  void setDefaultValue(org.w3c.dom.Element defaultValue)
           
protected abstract  void setDefaultValue(java.lang.String defaultValue)
          Some attributes may have a default value.
protected  void setDynamic(boolean dynamic)
          Set this to allow the attribute to vary from frame to frame.
protected  void setName(java.lang.String name)
          Sets the Attribute name.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAttribute

public AbstractAttribute()
Method Detail

getName

public final java.lang.String getName()
Returns the Attribute name. eg position, size, readability, etc.

Returns:
A String representing the Attribute name.

setName

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

Parameters:
name - The new name.

named

public final boolean named(java.lang.String S)
Returns true if the Attribute is named S. It is case sensitive.

Parameters:
S - The name to test against.
Returns:
true if the Attribute is named S.

named

public final boolean named(java.lang.String S,
                           Equivalencies map)
Returns true if the Attribute is named S or mapped to S under map. It is case sensitive.

Parameters:
S - The name to test against.
map - The list of equivalcencies.
Returns:
true if the Attribute is named S or in the same equivalency set.

getType

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

Returns:
The type.

setDefaultValue

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

Parameters:
defaultValue - What to set as the default.
Throws:
BadDataException - if Attributes.isGoodValue returns false.
MethodNotSupportedException

setDefaultValue

protected abstract void setDefaultValue(org.w3c.dom.Element defaultValue)
                                 throws BadDataException,
                                        MethodNotSupportedException
Throws:
BadDataException
MethodNotSupportedException

resetDefault

public final void resetDefault(AttributeValue o)
Modifies the attribute's default value.

Parameters:
o - the new default value

getDefault

public final AttributeValue getDefault()
A default value is what an attribute is set to when created.

Returns:
A String representing the default.

isDynamic

public final boolean isDynamic()
A dynamic attribute can change from frame to frame.

Returns:
if this can vary from frame to frame. It is meaningless for content or file Descriptors.

setDynamic

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

Parameters:
dynamic - The value.

getXMLFormat

public abstract org.w3c.dom.Element getXMLFormat(org.w3c.dom.Document root)
Returns an XML formatted version of this data.

Parameters:
root - where to print the data.
Returns:
an xml element representing the attribute or attribute schema

setArchetype

public void setArchetype(AttributeValue archetype)
ExtraConfig information is information concerning the data that is not expressed in the type itself. For example, an lvaluetype has a list of possible values in its extra config info. It is maintained as a Map. It is up to the implementation to decide what to do with the Map; it is mostly used as a map for legacy reasons, and I will probably change it to an Object soon enough.

Parameters:
archetype - an example of the data type

getArchetype

public AttributeValue getArchetype()
Gets the config value.

Returns:
the value archetype - the schema value

setArchetype

public void setArchetype(org.w3c.dom.Element E)
                  throws BadDataException
Sets the archetype associated with this descriptor.

Parameters:
E - the description
Throws:
BadDataException

setArchetype

public void setArchetype(java.lang.String S)
                  throws BadDataException
Sets the archetype associated with this descriptor.

Parameters:
S - the description
Throws:
BadDataException

getExtraConfigString

public final java.lang.String getExtraConfigString()
Determines how to print it out to the old gtf format

Returns:
the extra config string, to go in brackets in the GTF CONFIG section

getExtraConfigInXML

public final org.w3c.dom.Element getExtraConfigInXML(org.w3c.dom.Document root)
Gets the attribute-type-specific extended information, if it exists. It returns null, otherwise.

Parameters:
root - the DOM root
Returns:
the extended element, or null

clone

public abstract java.lang.Object clone()
Copies the attribute.

Returns:

parseAnInt

protected static int parseAnInt(org.w3c.dom.Element domEl,
                                java.lang.String name)
                         throws BadDataException
Gets the int value of an XML attribute of the given XML element.

Parameters:
domEl - the element to parse the attribute of
name - the name of the attribute
Returns:
the value of the attribute
Throws:
BadDataException

loadAttributeType

public static Measurable loadAttributeType(java.lang.String type)
                                    throws java.lang.ClassCastException
Makes sure the java class for an attribute is loaded. Various static initializers must run for an attribute in order for them to be usable.

Parameters:
type - the type to load
Returns:
an instance of the type
Throws:
java.lang.ClassCastException - if the type is not found