anvil.annot
Class AnnotationElement

java.lang.Object
  |
  +--anvil.annot.AnnotationElement
Direct Known Subclasses:
TrackElement

public class AnnotationElement
extends java.lang.Object

The smallest annotation unit, containing a number of attribute-value pairs.


Field Summary
protected  java.util.Hashtable avField
           
protected  java.lang.String comment
          Contains arbitrary comment
protected  AnnotationContainer container
          Container where this element is contained in.
protected  int index
          index only used for saving (Anvil format)
 
Constructor Summary
AnnotationElement(AnnotationContainer c)
           
 
Method Summary
 void addAttributeLinkValue(java.lang.String attribute, java.lang.Object val)
          Adds value to attribute value list.
 boolean addAttributeLinkValueOnce(java.lang.String attribute, java.lang.Object val)
          Adds value to attribute value list.
protected  void addDependent(AnnotationElement el)
           
protected  java.lang.String ascii2xml(java.lang.String s)
           
 void clearAttribute(java.lang.String attribute)
          Clears value of the attribute.
 void clearExtraObjects()
           
 void clearInlinks()
           
 java.util.List findAllDependents()
          Recursively finds all elements that point to this one (dependents) and all dependents' dependents etc.
protected  int findElementInLinks(AnnotationElement el)
          Returns the number of pointers in attributes of this element.
 java.lang.String getAttribute(java.lang.String attName)
          Returns a String representation of the attribute's value.
 boolean getBoolValue(java.lang.String attrName)
          Returns the attribute's value interpreted as a boolean, i.e. returns true iff value is "true", false otherwise.
 java.util.List getClonedDependents()
          Returns clone of the list.
 java.lang.String getComment()
          Returns the free-form research note/comment to this element.
 AnnotationContainer getContainer()
          Returns the container that contains this element.
 java.util.List getDependents()
          Returns list of all elements in the dependent track (secondary track) that point to this one (by anchor).
 AnvilExtraObject getExtraObject(java.lang.String key)
           
 java.util.List getInlinks()
          Returns list of track elements that point to this one (by attribute).
 java.util.Set getInlinkTracks()
          Returns set of tracks that contain elements pointing to this one.
 java.util.List getLinkedElements()
           
 java.util.List getLinkNames()
          Returns sorted order of attributes of link type.
 java.util.List getListValue(java.lang.String attrName)
          If the attribute is a link, a list is returned (possibly empty).
 java.lang.Integer getNumberValue(java.lang.String attrName)
          Returns the attribute's value interpreted as an integer
 java.util.List getOutlinks()
          Returns all track elements that this element is pointing to (by attribute).
 java.lang.String getShowLabel()
          Returns what should be displayed on the annotation board.
 boolean hasComment()
          Returns true if this element contains a comment, false otherwise.
 boolean isAttribute(java.lang.String att)
          Checks whether att is a valid attribute.
 boolean meetsConstraints(java.util.List goods, java.util.List nogoods)
          Returns true if this element has all the AV-pairs specified in goods and has none of the AV-pairs specified in nogoods (empty goods/nogoods list means "no constraint").
 boolean putAttribute(java.lang.String attName, java.lang.Object attValue)
          Inserts AV pair into attribute field.
 void putExtraObject(java.lang.String key, AnvilExtraObject obj)
           
protected  boolean removeDependent(AnnotationElement el)
           
protected  int removeElementFromLinks(AnnotationElement el)
          Removes track element el from all link attributes containing it.
 int removeMeFromInlinks()
          Removes this element from the inlink lists of all outlinked elements.
 void setComment(java.lang.String comment)
          Sets the free-form research note/comment to this element.
protected  void setDependents(java.util.List deps)
           
 void setInlinks(java.util.List links)
           
 java.lang.String toString()
           
protected  void writeAnvilFile(kipp.io.MyBufferedWriter f)
          Writes the chunk to the Anvil file (including outer tags).
protected  void writeContents(kipp.io.MyBufferedWriter f)
          Called by specialized writeAnvilFile methods to write attributes and comment in XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

avField

protected java.util.Hashtable avField

comment

protected java.lang.String comment
Contains arbitrary comment


container

protected AnnotationContainer container
Container where this element is contained in.


index

protected int index
index only used for saving (Anvil format)

Constructor Detail

AnnotationElement

public AnnotationElement(AnnotationContainer c)
Method Detail

putExtraObject

public void putExtraObject(java.lang.String key,
                           AnvilExtraObject obj)

getExtraObject

public AnvilExtraObject getExtraObject(java.lang.String key)

clearExtraObjects

public void clearExtraObjects()

isAttribute

public boolean isAttribute(java.lang.String att)
Checks whether att is a valid attribute.

Parameters:
att - attribute's name

getContainer

public AnnotationContainer getContainer()
Returns the container that contains this element.


getComment

public java.lang.String getComment()
Returns the free-form research note/comment to this element.


setComment

public void setComment(java.lang.String comment)
Sets the free-form research note/comment to this element.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getOutlinks

public java.util.List getOutlinks()
Returns all track elements that this element is pointing to (by attribute).

Returns:
list of track elements

getInlinks

public java.util.List getInlinks()
Returns list of track elements that point to this one (by attribute).

Returns:
list of track elements

getInlinkTracks

public java.util.Set getInlinkTracks()
Returns set of tracks that contain elements pointing to this one.

Returns:
set of tracks

clearInlinks

public void clearInlinks()

setInlinks

public void setInlinks(java.util.List links)

addDependent

protected void addDependent(AnnotationElement el)

setDependents

protected void setDependents(java.util.List deps)

removeDependent

protected boolean removeDependent(AnnotationElement el)

getDependents

public java.util.List getDependents()
Returns list of all elements in the dependent track (secondary track) that point to this one (by anchor).

Returns:
list of track elements

findAllDependents

public java.util.List findAllDependents()
Recursively finds all elements that point to this one (dependents) and all dependents' dependents etc.

Returns:
list of track elements

getClonedDependents

public java.util.List getClonedDependents()
Returns clone of the list. That way you can run through the list and dismember the original in one go.


addAttributeLinkValue

public void addAttributeLinkValue(java.lang.String attribute,
                                  java.lang.Object val)
Adds value to attribute value list. Creates new list if attribute has not been set yet.


addAttributeLinkValueOnce

public boolean addAttributeLinkValueOnce(java.lang.String attribute,
                                         java.lang.Object val)
Adds value to attribute value list. Creates new list if attribute has not been set yet. Adds only if not in list yet.

Returns:
true if has been added

removeMeFromInlinks

public int removeMeFromInlinks()
Removes this element from the inlink lists of all outlinked elements.


removeElementFromLinks

protected int removeElementFromLinks(AnnotationElement el)
Removes track element el from all link attributes containing it.

Returns:
number of occurrences found

findElementInLinks

protected int findElementInLinks(AnnotationElement el)
Returns the number of pointers in attributes of this element.


clearAttribute

public void clearAttribute(java.lang.String attribute)
Clears value of the attribute.


putAttribute

public boolean putAttribute(java.lang.String attName,
                            java.lang.Object attValue)
Inserts AV pair into attribute field. Returns true if attribute had existed and become superseded by new value


getAttribute

public java.lang.String getAttribute(java.lang.String attName)
Returns a String representation of the attribute's value. If it's a string, that is returned. If it's a list (links) the string rep. is computed.

Parameters:
attName - Name of desired attribute.
Returns:
always returns at least empty string.

getBoolValue

public boolean getBoolValue(java.lang.String attrName)
Returns the attribute's value interpreted as a boolean, i.e. returns true iff value is "true", false otherwise.

Parameters:
attrName - Name of desired attribute.

getNumberValue

public java.lang.Integer getNumberValue(java.lang.String attrName)
Returns the attribute's value interpreted as an integer

Parameters:
attrName - Name of desired attribute.

getListValue

public java.util.List getListValue(java.lang.String attrName)
If the attribute is a link, a list is returned (possibly empty). Currently, this should be a list of AnnotationElement objects (links).

Returns:
value of list attribute or null

meetsConstraints

public boolean meetsConstraints(java.util.List goods,
                                java.util.List nogoods)
Returns true if this element has all the AV-pairs specified in goods and has none of the AV-pairs specified in nogoods (empty goods/nogoods list means "no constraint").


getLinkNames

public java.util.List getLinkNames()
Returns sorted order of attributes of link type.


getLinkedElements

public java.util.List getLinkedElements()

getShowLabel

public java.lang.String getShowLabel()
Returns what should be displayed on the annotation board. It is usually the values of one or more attributes. If an attribute is of boolean type, the name of the attribute is type in case of 'true' and nothing otherwise. If no attributes are specified, the first attribute is taken as a default!


hasComment

public boolean hasComment()
Returns true if this element contains a comment, false otherwise.


ascii2xml

protected java.lang.String ascii2xml(java.lang.String s)

writeAnvilFile

protected void writeAnvilFile(kipp.io.MyBufferedWriter f)
                       throws java.io.IOException
Writes the chunk to the Anvil file (including outer tags).

java.io.IOException

writeContents

protected void writeContents(kipp.io.MyBufferedWriter f)
                      throws java.io.IOException
Called by specialized writeAnvilFile methods to write attributes and comment in XML file.

java.io.IOException