anvil.annot
Class AnnotationContainer

java.lang.Object
  |
  +--java.util.Observable
        |
        +--anvil.annot.AnvilAnnotationNode
              |
              +--anvil.annot.AnnotationContainer
All Implemented Interfaces:
AnnotationNode
Direct Known Subclasses:
AnnotationSet, AnvilTrack

public abstract class AnnotationContainer
extends AnvilAnnotationNode

Abstract class for annotation containers (e.g. tracks or sets), i.e. parts of an annotation that contain elements.


Field Summary
protected  java.util.AbstractCollection elements
          track elements sorted in some total order
protected  java.util.List index2el
          this is for loading (AnvilReader)
 
Fields inherited from class anvil.annot.AnvilAnnotationNode
annotation, name, open, parent, spec, visible
 
Constructor Summary
AnnotationContainer(Annotation annot, GroupNode parent, NodeSpec spec)
           
 
Method Summary
 boolean addElement(AnnotationElement el)
          Add new element to this track.
 void elementChanged()
          Called by annotation elements when they change.
 Annotation getAnnotation()
           
 java.util.List getAttributeNames()
           
 ValueType getAttributeType(java.lang.String attrName)
          Returns the value type of an attribute or null.
 java.util.AbstractCollection getElementCollection()
           
 int getNumOfElements()
           
 java.util.List getReciprocalLinkAttributes()
          Returns names of all reciprocal attributes.
 ContainerSpec getSpec()
           
protected  void indexElements()
          Sets the index slots in all elements to position in the set.
 boolean isEmpty()
           
abstract  void print()
           
 int query(java.util.List positives, java.util.List negatives, java.util.AbstractCollection result)
          Queries container for elements that match AV pairs in positives and do not have AV pairs that occur in negatives.
abstract  boolean removeElement(AnnotationElement el)
          Removes element from this container, including all links pointing from other elements to this one, also removing all dependent elements.
 int replaceAttributeValue(java.lang.String attr, java.lang.String oldValue, java.lang.String newValue)
           
 void setName(java.lang.String n)
          Sets name of container.
 void unlinkElement(AnnotationElement el)
          This method is called before an element is removed.
protected  void writeAnvilFile(kipp.io.MyBufferedWriter f)
          Writes contents of chunk in Anvil format.
 
Methods inherited from class anvil.annot.AnvilAnnotationNode
getFirstHidden, getName, getParent, getShortName, isOpen, isVisible, setOpen, setVisible
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

index2el

protected java.util.List index2el
this is for loading (AnvilReader)


elements

protected java.util.AbstractCollection elements
track elements sorted in some total order

Constructor Detail

AnnotationContainer

public AnnotationContainer(Annotation annot,
                           GroupNode parent,
                           NodeSpec spec)
Method Detail

getReciprocalLinkAttributes

public java.util.List getReciprocalLinkAttributes()
Returns names of all reciprocal attributes.


addElement

public boolean addElement(AnnotationElement el)
Add new element to this track.

Returns:
true if element existed already (should not happen).

elementChanged

public void elementChanged()
Called by annotation elements when they change.


getAnnotation

public Annotation getAnnotation()

getAttributeType

public ValueType getAttributeType(java.lang.String attrName)
                           throws NoSuchAttributeException
Returns the value type of an attribute or null.

NoSuchAttributeException

getAttributeNames

public java.util.List getAttributeNames()

getElementCollection

public java.util.AbstractCollection getElementCollection()

getNumOfElements

public int getNumOfElements()

getSpec

public ContainerSpec getSpec()

indexElements

protected void indexElements()
Sets the index slots in all elements to position in the set.


isEmpty

public boolean isEmpty()

print

public abstract void print()

query

public int query(java.util.List positives,
                 java.util.List negatives,
                 java.util.AbstractCollection result)
Queries container for elements that match AV pairs in positives and do not have AV pairs that occur in negatives. Found elements are appended to the result list. Since the good/nogood lists are CONSTRAINTS, empty lists mean that all elements are valid.

Parameters:
positives - List of QueryProposition elements. List may be empty (acts like "*"). If one AV matches element is OK.
negatives - same as above. If one AV matches element is out.
result - list with container elements; NEW HITS ARE ADDED HERE!
Returns:
number of matched elements

replaceAttributeValue

public int replaceAttributeValue(java.lang.String attr,
                                 java.lang.String oldValue,
                                 java.lang.String newValue)
                          throws NoSuchAttributeException,
                                 WrongValueTypeException
NoSuchAttributeException
WrongValueTypeException

removeElement

public abstract boolean removeElement(AnnotationElement el)
Removes element from this container, including all links pointing from other elements to this one, also removing all dependent elements.


unlinkElement

public void unlinkElement(AnnotationElement el)
This method is called before an element is removed. It cleans all linkage.


setName

public void setName(java.lang.String n)
Sets name of container.


writeAnvilFile

protected void writeAnvilFile(kipp.io.MyBufferedWriter f)
                       throws java.io.IOException
Writes contents of chunk in Anvil format.

java.io.IOException