viper.descriptors
Class DescPrototype

java.lang.Object
  extended byviper.descriptors.Descriptor
      extended byviper.descriptors.DescPrototype
All Implemented Interfaces:
java.lang.Cloneable

public class DescPrototype
extends Descriptor

The DescPrototype is a descriptor object that does not contain data and supports


Field Summary
 
Fields inherited from class viper.descriptors.Descriptor
attributes, composable, croppingType, span
 
Constructor Summary
DescPrototype(java.lang.String category, java.lang.String name)
          Constructs a new descriptor definition.
 
Method Summary
 void addAttribute(AttributePrototype ap)
          Adds the given attribute type.
 void addAttribute(java.lang.String name, java.lang.String type)
          Adds a new attribute with the given type information.
 void addAttribute(java.lang.String name, java.lang.String type, java.lang.String extra)
          Adds the given attribute with the specified parameters.
 java.lang.Object clone()
          Generates a new Descriptor Object sharing none of the references of the original but containing identical data.
 Descriptor compose(Descriptor D, EvaluationParameters.ScopeRules scope)
          Cannot compose prototypes
 Descriptor create()
          Creates a new, empty descriptor from this type information.
 Descriptor crop(FrameSpan span)
          Does nothing.
 java.util.Set getAttribNames()
          Gets the names of all attributes instances of this descriptor type may have.
 AttributePrototype getAttributePrototype(java.lang.String name)
          Gets that specification for the attribute with the given name.
 Filterable getFilterable(java.lang.String attribName)
          Returns the specified Attribute or FrameSpan.
 FrameSpan getFrameSpan()
          Gets the frames where the descriptor exists.
 java.lang.Object getID()
          Returns the ID number of the descriptor.
 org.w3c.dom.Element getXMLFormat(org.w3c.dom.Document root)
          Gets an XML representation of the descriptor.
 boolean hasAttrib(java.lang.String attribName)
          Checks to see if this Descriptor has an attribute with the specifified name.
 void moveFrame(int offset)
          Shifts the descriptor by the given offset.
 int numIDs()
          Returns the number of Identification numbers in this descriptor.
 Descriptor parseDescriptorData(org.w3c.dom.Element myElement, DescVector relativeVector)
          Reads in the data in xml format.
 Descriptor parseDescriptorData(VReader reader, DescVector relativeVector)
          Reads in Descriptor data filtered through this Descriptor's config information.
 void setFrameSpan(FrameSpan span)
          Prototypes are not instantiated, so do not have frame spans; this method throws an exception.
 void setID(int id)
           
 java.lang.String toString()
          Gives the prototype in gtf format.
 
Methods inherited from class viper.descriptors.Descriptor
compareTo, composeThese, endFrame, equals, getAttribute, getAttribute, getAttributeIndex, getAttributeIndex, getAttributeNames, getAttributesOfType, getCategory, getFullName, getHighestFrame, getName, getType, hasAttribute, hashCode, isCategory, isComposable, isRoc, named, parseDescriptorConfig, parseDescriptorConfig, printSelf, printSelf, rawFormat, rocAttributeName, sameCategoryAs, setCategory, setName, startFrame, startsWithCategory
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DescPrototype

public DescPrototype(java.lang.String category,
                     java.lang.String name)
              throws BadDataException
Constructs a new descriptor definition.

Parameters:
category - the category, e.g. "CONTENT" or "OBJECT"
name - the name of the descriptor, e.g. "Person"
Throws:
BadDataException - if the content is unknown or if the name is bad
Method Detail

getAttribNames

public java.util.Set getAttribNames()
Gets the names of all attributes instances of this descriptor type may have.

Returns:
the attribute names, as Strings.

getAttributePrototype

public AttributePrototype getAttributePrototype(java.lang.String name)
Gets that specification for the attribute with the given name.

Parameters:
name - the name of that attribute to look up
Returns:
type information of the named attributed

hasAttrib

public boolean hasAttrib(java.lang.String attribName)
Description copied from class: Descriptor
Checks to see if this Descriptor has an attribute with the specifified name.

Overrides:
hasAttrib in class Descriptor
Parameters:
attribName - the attribute to check for
Returns:
true iff the attribute is found.

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String type)
                  throws BadDataException
Adds a new attribute with the given type information.

Parameters:
name - the name of the new attribute
type - the data type of the new attribute, e.g. viper:bbox.
Throws:
BadDataException

getFilterable

public Filterable getFilterable(java.lang.String attribName)
Description copied from class: Descriptor
Returns the specified Attribute or FrameSpan. Framespan is specified by the String " framespan".

Overrides:
getFilterable in class Descriptor
Parameters:
attribName - - the name of the Attribute to get
Returns:
the Attribute; null if not found

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String type,
                         java.lang.String extra)
                  throws BadDataException
Adds the given attribute with the specified parameters.

Parameters:
name - the name of the new attribute
type - the type information for the attribute
extra - extra information, such as the elements of an lvalue list
Throws:
BadDataException - if there is an error in the type or the extras config information

addAttribute

public void addAttribute(AttributePrototype ap)
Adds the given attribute type.

Parameters:
ap - the attribute type and name information

toString

public java.lang.String toString()
Gives the prototype in gtf format.

Overrides:
toString in class Descriptor
Returns:
a String containing the category, name, ID number, span, and all scoped Attributes

getXMLFormat

public org.w3c.dom.Element getXMLFormat(org.w3c.dom.Document root)
Description copied from class: Descriptor
Gets an XML representation of the descriptor.

Specified by:
getXMLFormat in class Descriptor
Parameters:
root - The DOM Document to attach the element to.
Returns:
A DOM Element node representing the descriptor.

create

public Descriptor create()
Creates a new, empty descriptor from this type information.

Returns:
a new instance of this type of descriptor

getID

public java.lang.Object getID()
Returns the ID number of the descriptor.

Specified by:
getID in class Descriptor
Returns:
the ID number of the descriptor

setID

public void setID(int id)

numIDs

public int numIDs()
Description copied from class: Descriptor
Returns the number of Identification numbers in this descriptor. Prototypes or empty descriptors have none, while aggregate descriptors have as many as there are descriptors inside.

Specified by:
numIDs in class Descriptor
Returns:
zero

getFrameSpan

public FrameSpan getFrameSpan()
Description copied from class: Descriptor
Gets the frames where the descriptor exists.

Specified by:
getFrameSpan in class Descriptor
Returns:
null

setFrameSpan

public void setFrameSpan(FrameSpan span)
Prototypes are not instantiated, so do not have frame spans; this method throws an exception.

Specified by:
setFrameSpan in class Descriptor
Parameters:
span - the new span
Throws:
java.lang.UnsupportedOperationException - This method isn't implemented, as it doesn't really apply to prototypes.

compose

public Descriptor compose(Descriptor D,
                          EvaluationParameters.ScopeRules scope)
                   throws java.lang.UnsupportedOperationException
Cannot compose prototypes

Specified by:
compose in class Descriptor
Parameters:
D - the descriptor to compose with
scope - the scoping rules
Returns:
nothing; is an error
Throws:
java.lang.UnsupportedOperationException - This method isn't implemented, as it doesn't really apply to prototypes.
See Also:
DescAggregate

clone

public java.lang.Object clone()
Description copied from class: Descriptor
Generates a new Descriptor Object sharing none of the references of the original but containing identical data.

Specified by:
clone in class Descriptor
Returns:
A new Descriptor initialized with this Descriptor's data

parseDescriptorData

public Descriptor parseDescriptorData(VReader reader,
                                      DescVector relativeVector)
                               throws java.lang.CloneNotSupportedException,
                                      BadDataException
Reads in Descriptor data filtered through this Descriptor's config information.

Parameters:
reader - the reader from which to retrieve the next Descriptor data
relativeVector - the configuration/rules to use are here
Returns:
a new Descriptor with data from the VReader
Throws:
java.lang.CloneNotSupportedException
BadDataException

parseDescriptorData

public Descriptor parseDescriptorData(org.w3c.dom.Element myElement,
                                      DescVector relativeVector)
                               throws BadDataException
Reads in the data in xml format.

Parameters:
myElement - the xml element to parse
relativeVector - the parsed data, so far
Returns:
the new descriptor
Throws:
BadDataException - if there is an error in the file

crop

public Descriptor crop(FrameSpan span)
Does nothing.

Specified by:
crop in class Descriptor
Parameters:
span - the new span
Returns:
the cropped descriptor

moveFrame

public void moveFrame(int offset)
Description copied from class: Descriptor
Shifts the descriptor by the given offset.

Specified by:
moveFrame in class Descriptor
Parameters:
offset - the number of frames to shift the descriptor.
Throws:
java.lang.UnsupportedOperationException