viper.descriptors
Class Descriptor

java.lang.Object
  extended byviper.descriptors.Descriptor
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
DescAggregate, DescPrototype, DescSingle

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

This class represents a Descriptor of a given visual element in a video file. There are three types: FILE, CONTENT, and OBJECT.


Field Summary
protected  Attribute[] attributes
          The attributes.
protected  boolean composable
           
protected  java.lang.String croppingType
           
protected  FrameSpan span
           
 
Constructor Summary
protected Descriptor()
          Constructs a new, empty descriptor.
  Descriptor(java.lang.String designation)
          This constructor takes in the type of Descriptor to create.
 
Method Summary
abstract  java.lang.Object clone()
          Generates a new Descriptor Object sharing none of the references of the original but containing identical data.
 int compareTo(java.lang.Object o)
          This compares the Category and Name fields.
abstract  Descriptor compose(Descriptor D, EvaluationParameters.ScopeRules scope)
          Composes this descriptor with the given descriptor under the given set of scope and composition rules.
static Descriptor composeThese(java.util.Iterator L, EvaluationParameters.ScopeRules scope)
          Turns a list of Descriptors into a single Descriptor in order.
abstract  Descriptor crop(FrameSpan span)
          Like clone, but only clones a subset of this descriptor.
 int endFrame()
          Gets the last valid frame.
 boolean equals(java.lang.Object o)
           
 Attribute getAttribute(java.lang.String attribName)
          Returns the specified Attribute.
 Attribute getAttribute(java.lang.String attribName, Equivalencies map)
          Gets the attribute with the given name.
 int getAttributeIndex(java.lang.String name)
          Function returns the index of the named attribute or -1 if not found.
 int getAttributeIndex(java.lang.String name, Equivalencies map)
          Gets the index of the attribute with the given name, under the given ontology mapping.
 java.lang.String[] getAttributeNames()
          Get all attribute names.
 Attribute[] getAttributesOfType(java.lang.String type, boolean getDerived)
          Returns the specified Attribute.
 java.lang.String getCategory()
          Returns the category of this Descriptor.
 Filterable getFilterable(java.lang.String attribName)
          Returns the specified Attribute or FrameSpan.
abstract  FrameSpan getFrameSpan()
          Gets the frames where the descriptor exists.
 java.lang.String getFullName()
          Gets the full name of the descriptor, including category, e.g.
 int getHighestFrame()
          Returns the number of the highest frame among this Descriptor
abstract  java.lang.Object getID()
           
 java.lang.String getName()
          Gets the name of the Descriptor.
 java.lang.String getType()
          Gets the type of the descriptor, ie OBJECT or CONTENT.
abstract  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.
 boolean hasAttribute(java.lang.String S)
          Checks to see if this String could be a value for any of the Attributes.
 int hashCode()
           
static boolean isCategory(java.lang.String test)
          Tests to see if the String is a Descriptor category.
 boolean isComposable()
          Tests to see if it is possible to aggregate this descriptor with others of the same type.
 boolean isRoc()
          Function resturns true if one of the attributes was ROC.
abstract  void moveFrame(int offset)
          Shifts the descriptor by the given offset.
 boolean named(java.lang.String S)
          Tests to see if the Descriptor is named S
abstract  int numIDs()
          Returns the number of Identification numbers in this descriptor.
static DescPrototype parseDescriptorConfig(org.w3c.dom.Element desc)
          parses the given descriptor config
static DescPrototype parseDescriptorConfig(VReader reader)
          Reads in a piece of Descriptor configuration data from a VReader.
 void printSelf(java.io.PrintWriter output)
          Prints this descriptor in .gtf format to the given output writer.
 void printSelf(java.io.PrintWriter output, java.lang.String padding)
          Prints this descriptor in .gtf format to the given output writer.
 java.lang.String rawFormat()
          Function returns the raw string representation of this object.
 java.lang.String rocAttributeName()
          Function returns the name of the roc attribute or "" if not found
 boolean sameCategoryAs(Descriptor other, Equivalencies map)
          Tests to see if the descriptors refer to the same type under the given ontology mapping.
 void setCategory(java.lang.String s)
          Sets the descriptor type, e.g.
abstract  void setFrameSpan(FrameSpan span)
          Replaces the frame span.
 void setName(java.lang.String n)
          Sets the Descriptor's name.
 int startFrame()
          Gets the first frame of the frame span
static boolean startsWithCategory(java.lang.String test)
          Tests to see if a String starts with a proper Descriptor category
 java.lang.String toString()
          Returns a String representation of the Descriptor.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

attributes

protected Attribute[] attributes
The attributes. Remember -- for all attributes of the same type, they must remain sorted in the same order as the original Config.


croppingType

protected java.lang.String croppingType

span

protected FrameSpan span

composable

protected boolean composable
Constructor Detail

Descriptor

public Descriptor(java.lang.String designation)
           throws BadDataException
This constructor takes in the type of Descriptor to create.

Parameters:
designation - the type of Descriptor. Either FILE, CONTENT, or OBJECT
Throws:
BadDataException - - if the specified category is not one of the three allowable

Descriptor

protected Descriptor()
Constructs a new, empty descriptor.

Method Detail

setCategory

public void setCategory(java.lang.String s)
                 throws java.lang.IllegalArgumentException
Sets the descriptor type, e.g. "CONTENT" or "FILE".

Parameters:
s - the new category
Throws:
java.lang.IllegalArgumentException - if the category isn't valid

isRoc

public boolean isRoc()
Function resturns true if one of the attributes was ROC.

Returns:
if one of the attributes was ROC

rocAttributeName

public java.lang.String rocAttributeName()
Function returns the name of the roc attribute or "" if not found

Returns:
the name of the roc attribute or "" if not found

getAttributeIndex

public int getAttributeIndex(java.lang.String name)
Function returns the index of the named attribute or -1 if not found.

Parameters:
name - the name to look for
Returns:
the index of the attribute

getAttributeIndex

public int getAttributeIndex(java.lang.String name,
                             Equivalencies map)
Gets the index of the attribute with the given name, under the given ontology mapping.

Parameters:
name - the attribute to look for
map - the mapping to use. It will also check the original name.
Returns:
the index, or -1 if not found

isCategory

public static boolean isCategory(java.lang.String test)
Tests to see if the String is a Descriptor category.

Parameters:
test - - the string to be tested
Returns:
true iff the string is either FILE, CONTENT, or OBJECT

startsWithCategory

public static boolean startsWithCategory(java.lang.String test)
Tests to see if a String starts with a proper Descriptor category

Parameters:
test - String to be tested; usually a line of text
Returns:
true iff the string starts with "FILE ", "CONTENT ", or "OBJECT "

clone

public abstract java.lang.Object clone()
Generates a new Descriptor Object sharing none of the references of the original but containing identical data.

Returns:
A new Descriptor initialized with this Descriptor's data

compareTo

public int compareTo(java.lang.Object o)
This compares the Category and Name fields. Useful for sorting.

Parameters:
o - the Descriptor to compare this with
Returns:
0 if the names are equal, and less than or greater lexicographically
Throws:
java.lang.ClassCastException

sameCategoryAs

public boolean sameCategoryAs(Descriptor other,
                              Equivalencies map)
Tests to see if the descriptors refer to the same type under the given ontology mapping.

Parameters:
other - the descriptor to compare with
map - the type map
Returns:
if the two are the same type

hasAttrib

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

Parameters:
attribName - the attribute to check for
Returns:
true iff the attribute is found.

getID

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

numIDs

public abstract int numIDs()
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.

Returns:
the number of Identification numbers in this descriptor

getFrameSpan

public abstract FrameSpan getFrameSpan()
Gets the frames where the descriptor exists.

Returns:
the valid frames of the descriptor

moveFrame

public abstract void moveFrame(int offset)
Shifts the descriptor by the given offset.

Parameters:
offset - the number of frames to shift the descriptor.

setFrameSpan

public abstract void setFrameSpan(FrameSpan span)
Replaces the frame span. Probably doesn't modify any of the attributes.

Parameters:
span - the new span

crop

public abstract Descriptor crop(FrameSpan span)
Like clone, but only clones a subset of this descriptor.

Parameters:
span - the new span
Returns:
the cropped descriptor

getAttribute

public Attribute getAttribute(java.lang.String attribName)
Returns the specified Attribute.

Parameters:
attribName - - the name of the Attribute to get
Returns:
the Attribute; null if not found

getAttribute

public Attribute getAttribute(java.lang.String attribName,
                              Equivalencies map)
Gets the attribute with the given name.

Parameters:
attribName - the attribute name
map - the ontology map
Returns:
the attribute, or null if not found

getAttributesOfType

public Attribute[] getAttributesOfType(java.lang.String type,
                                       boolean getDerived)
                                throws java.lang.ClassNotFoundException
Returns the specified Attribute.

Parameters:
type - the type of Attribute to get
getDerived - true indicates all types derived from the base type
Returns:
the Attribute; null if not found
Throws:
java.lang.ClassNotFoundException - if type is invalid

getFilterable

public Filterable getFilterable(java.lang.String attribName)
Returns the specified Attribute or FrameSpan. Framespan is specified by the String " framespan".

Parameters:
attribName - - the name of the Attribute to get
Returns:
the Attribute; null if not found

toString

public java.lang.String toString()
Returns a String representation of the Descriptor. Contains EOL characters.

Returns:
a String containing the category, name, ID number, span, and all scoped Attributes

getFullName

public java.lang.String getFullName()
Gets the full name of the descriptor, including category, e.g. OBJECT Person.

Returns:
the full, .gtf style name

parseDescriptorConfig

public static DescPrototype parseDescriptorConfig(org.w3c.dom.Element desc)
                                           throws BadDataException
parses the given descriptor config

Parameters:
desc - the config element to parse
Returns:
the parsed value
Throws:
BadDataException - if there is an error in the xml

parseDescriptorConfig

public static DescPrototype parseDescriptorConfig(VReader reader)
Reads in a piece of Descriptor configuration data from a VReader.

Parameters:
reader - - the reader to get information from
Returns:
the Descriptor config found next in the reader

setName

public void setName(java.lang.String n)
Sets the Descriptor's name.

Parameters:
n - - the new name of this Descriptor

named

public boolean named(java.lang.String S)
Tests to see if the Descriptor is named S

Parameters:
S - - the name to test
Returns:
true if S equals the name

getName

public java.lang.String getName()
Gets the name of the Descriptor.

Returns:
the name

getType

public java.lang.String getType()
Gets the type of the descriptor, ie OBJECT or CONTENT.

Returns:
the String that represents the type.

getCategory

public java.lang.String getCategory()
Returns the category of this Descriptor.

Returns:
either "FILE", "CONTENT", or "OBJECT"

printSelf

public void printSelf(java.io.PrintWriter output,
                      java.lang.String padding)
Prints this descriptor in .gtf format to the given output writer.

Parameters:
output - the stream to use
padding - the amount of padding to put to the left. Useful for indenting descriptors.

printSelf

public void printSelf(java.io.PrintWriter output)
Prints this descriptor in .gtf format to the given output writer.

Parameters:
output - the stream to use

getHighestFrame

public int getHighestFrame()
Returns the number of the highest frame among this Descriptor

Returns:
the highest frame among this Descriptor and all of its partial and correct matches

hasAttribute

public boolean hasAttribute(java.lang.String S)
Checks to see if this String could be a value for any of the Attributes.

Parameters:
S - the String to check
Returns:
true if some Attribute will accept it

startFrame

public int startFrame()
Gets the first frame of the frame span

Returns:
the first valid frame

endFrame

public int endFrame()
Gets the last valid frame.

Returns:
the last valid frame

rawFormat

public java.lang.String rawFormat()
Function returns the raw string representation of this object.

Returns:
name and ID

composeThese

public static Descriptor composeThese(java.util.Iterator L,
                                      EvaluationParameters.ScopeRules scope)
                               throws BadDataException,
                                      UncomposableException
Turns a list of Descriptors into a single Descriptor in order.

Parameters:
L - the descriptors to compose
scope - the scoping rules to use
Returns:
the aggregate of the descriptors in L
Throws:
BadDataException
UncomposableException

isComposable

public boolean isComposable()
Tests to see if it is possible to aggregate this descriptor with others of the same type.

Returns:
true if the descriptor is amenable to aggregation
See Also:
compose(Descriptor, EvaluationParameters.ScopeRules), DescAggregate

compose

public abstract Descriptor compose(Descriptor D,
                                   EvaluationParameters.ScopeRules scope)
                            throws java.lang.UnsupportedOperationException,
                                   BadDataException,
                                   UncomposableException
Composes this descriptor with the given descriptor under the given set of scope and composition rules. It returns a new copy of this descriptor, leaving it unmodified.

Parameters:
D - the descriptor to compose with
scope - rules for the composition
Returns:
a new descriptor representing both this descriptor and the other one
Throws:
java.lang.UnsupportedOperationException
BadDataException
UncomposableException
See Also:
DescAggregate

getAttributeNames

public java.lang.String[] getAttributeNames()
Get all attribute names.

Returns:
all attribute names

getXMLFormat

public abstract org.w3c.dom.Element getXMLFormat(org.w3c.dom.Document root)
Gets an XML representation of the descriptor.

Parameters:
root - The DOM Document to attach the element to.
Returns:
A DOM Element node representing the descriptor.

equals

public boolean equals(java.lang.Object o)

hashCode

public int hashCode()