ag
Class AG

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.TreeSet
              extended by ag.AG
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, java.lang.Iterable, java.util.Collection, java.util.Set, java.util.SortedSet

public class AG
extends java.util.TreeSet
implements java.lang.Comparable

See Also:
Serialized Form

Field Summary
static java.lang.String ANCHOR_ID_NAME
           
static java.lang.String ANNOTATION_ID_NAME
           
 
Constructor Summary
AG(org.w3c.dom.Element element)
           
 
Method Summary
 void addAnchor(Anchor a)
          Adds an anchor to this AG.
 void addAnnotation(Annotation a)
          Adds a new annotation to this AG.
 int compareTo(java.lang.Object that)
           
 java.lang.String copyAnchor(Anchor anchor)
          Creates a new anchor with new id but same values as specified argument, anchor.
 java.lang.String createAnchor(java.lang.String id, float offset, java.lang.String unit, java.lang.String signals)
          Creates an anchor with specified offset, unit and signals.
 java.lang.String createAnchor(java.lang.String id, java.lang.String unit, java.lang.String signals)
          Creates an anchor with specified unit and signals.
 java.lang.String createAnnotation(java.lang.String id, Anchor anchor1, Anchor anchor2, java.lang.String annotationType)
          Creates a new annotation and adds it to the AG.
 void deleteAnchor(Anchor a)
          Deletes an anchor from this AG.
 void deleteAnnotation(Annotation a)
          Delete the annotation from the AG.
 void deleteFeature(java.lang.String id, java.lang.String featureName)
          Delete the specified feature from the metadata or annotation.
 boolean existsFeature(java.lang.String id, java.lang.String featureName)
          Test if a feature exists in the metadata or annotation.
 Anchor getAnchorById(java.lang.String id)
          Gets an anchor by its id.
 java.util.HashSet getAnchorSetByOffset(float offset, float epsilon)
          Gets a set containing those anchors with offset between offset +/- epsilon.
 java.util.Set getAnchorSetNearestOffset(float offset)
          Gets a set containing those anchors with offset nearest to a specified offset.
 java.util.Set getAnnotationSeqByOffset(float begin, float end)
          Gets all annotations with its start anchor offset in between the specified values.
 java.lang.String getFeature(java.lang.String id, java.lang.String featureName)
          Get the value of the specified feature in the metadata or annotation.
 java.util.Set getFeatureNames(java.lang.String id)
          Gets all feature names from the metadata or annotation.
 java.util.Set getFeatures(java.lang.String id)
          Gets all the feature values in the specified metadata or annotation.
 Timeline getTimeline()
          Gets the Timeline of the AG.
 java.lang.String getType()
          Gets the type of this AG.
 java.util.HashSet nSplitAnnotation(Annotation a, int n)
          Split an annotation n times.
 void printAnnotationSetInfo()
           
 void setAnchorOffset(Anchor a, float o)
          Sets the specified anchor's offset to the specified offset.
 void setEndAnchor(Annotation annotation, Anchor anchor)
          Assigns the annotation a new end anchor.
 void setEndOffset(Annotation ann, float offset)
          Sets the specified annotation's end anchor's offset to the specified offset.
 void setFeature(Annotation a, java.lang.String featureName, java.lang.String featureValue)
          Set a feature of an annotation to the specified value, updating the index.
 void setFeature(java.lang.String id, java.lang.String featureName, java.lang.String featureValue)
          Set feature value of the metadata or annotation.
 void setFeatures(java.lang.String id, java.lang.String features)
          Set multiple features in a single string.
 void setStartAnchor(Annotation annotation, Anchor anchor)
          Assigns the annotation a new start anchor.
 void setStartOffset(Annotation ann, float offset)
          Sets the specified annotation's start anchor's offset to the specified offset.
 void setType(java.lang.String type)
          Sets the type of the AG.
 Annotation splitAnnotation(Annotation a1)
          Split an annotation a in two.
 java.util.Vector storeSQLs(java.lang.String agSetId, java.util.Set featureNames)
           
 java.lang.String toString()
          Creates a string representation of this AG.
 void unsetFeatures(java.lang.String id)
          Unsets all features in the metadata or annotation.
 
Methods inherited from class java.util.TreeSet
add, addAll, clear, clone, comparator, contains, first, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Field Detail

ANCHOR_ID_NAME

public static final java.lang.String ANCHOR_ID_NAME
See Also:
Constant Field Values

ANNOTATION_ID_NAME

public static final java.lang.String ANNOTATION_ID_NAME
See Also:
Constant Field Values
Constructor Detail

AG

public AG(org.w3c.dom.Element element)
   throws AGException
Throws:
AGException
Method Detail

setType

public void setType(java.lang.String type)
Sets the type of the AG. Sets the type of the AG.

Parameters:
type, - the new type for this AG.

getType

public java.lang.String getType()
Gets the type of this AG. Gets the type of this AG.

Returns:
type, this AG's type.

getTimeline

public Timeline getTimeline()
Gets the Timeline of the AG. Gets the Timeline of the AG.

Returns:
Timeline, this AG's Timeline.

createAnchor

public java.lang.String createAnchor(java.lang.String id,
                                     float offset,
                                     java.lang.String unit,
                                     java.lang.String signals)
                              throws AGException
Creates an anchor with specified offset, unit and signals. Creates an anchor with specified offset, unit and signals. If id is a AGId, the id issuer will generate a new AnchorId. If id is a AnchorId, it will try the given id first, if it's taken, generates a new AnchorId. The anchor is added to index upon its creation.

Parameters:
id, - might be AGId or AnchorId.
Returns:
AnchorId of the new anchor.
Throws:
AGException - IF (the id given is invalid)

createAnchor

public java.lang.String createAnchor(java.lang.String id,
                                     java.lang.String unit,
                                     java.lang.String signals)
                              throws AGException
Creates an anchor with specified unit and signals. Creates an anchor with specified unit and signals. If id is a AGId, the id issuer will generate a new AnchorId. If id is a AnchorId, it will try the given id first, if it's taken, generates a new anchorId. The anchor is added to index upon its creation.

Parameters:
id - might be AGId or AnchorId.
Returns:
AnchorId of the new anchor.
Throws:
AGException - IF (the id given is invalid)

copyAnchor

public java.lang.String copyAnchor(Anchor anchor)
                            throws AGException
Creates a new anchor with new id but same values as specified argument, anchor. Creates a new anchor with new id but same values as specified argument, anchor.

Parameters:
anchor, - the anchor to be copied.
Returns:
the id of the newly created anchor.
Throws:
AGException, - if the anchor does not exist in this AG.
AGException

addAnchor

public void addAnchor(Anchor a)
Adds an anchor to this AG. AG uses the index to manage its anchors and calls the index's add function to process the addition of an anchor.

Parameters:
a, - the anchor to be added.
See Also:
AnnotationIndex.addAnchor.

deleteAnchor

public void deleteAnchor(Anchor a)
                  throws AGException
Deletes an anchor from this AG. Deletes an anchor fromt this AG. The anchor is removed from the Identifiers index and deleted from the index. An anchor can only be deleted if it is not anchored to any annotations.

Parameters:
a, - the anchor to be deleted.
Throws:
AGException - if the anchor does not exist in this AG.
See Also:
AnnotationIndex.deleteAnchor.

setAnchorOffset

public void setAnchorOffset(Anchor a,
                            float o)
                     throws AGException
Sets the specified anchor's offset to the specified offset. Sets the specified anchor's offset to the specified offset. The index moves the set of annotations anchored to the specified anchor from the old offset to the new offset in the relevant HashMaps. Note that the indexical operations must take place prior to changing the offset of the anchor.

Parameters:
a, - the specified anchor.
o, - the new offset for the specified anchor.
Throws:
AGException, - if the anchor does not exist in the AG.
AGException
See Also:
AnnotationIndex.changeOffsetMaps.

createAnnotation

public java.lang.String createAnnotation(java.lang.String id,
                                         Anchor anchor1,
                                         Anchor anchor2,
                                         java.lang.String annotationType)
                                  throws AGException
Creates a new annotation and adds it to the AG. Creates a new annotation and adds it to the AG. If id is a AGId, the id issuer will generate a new AnnotationId. If id is an AnnotationId, it will try the given id first, if it's taken, it will generate a new AnnotationId.

Parameters:
id, - might be AGId or AnnotationId.
anchor1, - the start anchor of this annotation.
anchor2, - the end anchor of this annotation.
annotationType, - the type of this annotation.
Returns:
SignalId of the new signal.
Throws:
AGException - IF (the id given is invalid)

addAnnotation

public void addAnnotation(Annotation a)
Adds a new annotation to this AG. Adds a new annotation to this AG.

Parameters:
a, - the annotation to be added.

splitAnnotation

public Annotation splitAnnotation(Annotation a1)
                           throws AGException
Split an annotation a in two. Split an annotation a in two, creating a new annotation a' having the same label data as the original one. The two annotations a, a' connect head-to-tail at a new anchor. The new annotation and anchor have identifiers taken from the specified identifier spaces. The new anchor is has no offset.

Parameters:
a1, - the annotation to be split.
Returns:
a pointer to the new annotation a'.
Throws:
AGException

nSplitAnnotation

public java.util.HashSet nSplitAnnotation(Annotation a,
                                          int n)
                                   throws AGException
Split an annotation n times. A version of split which does the split operation n times over.

Parameters:
annotationId, - the annotation to be split n times.
n, - the number of times original annotation will be split.
Returns:
the set of new annotations.
Throws:
AGException
See Also:
splitAnnotation

deleteAnnotation

public void deleteAnnotation(Annotation a)
                      throws AGException
Delete the annotation from the AG. Delete the annotation from the AG. This removes the annotation from this TreeSet, Identifiers, and the index. Note that this method will set the anchored field of the specified annotation's start and end anchors to false if this deletion causes the anchors to be unanchored.

Parameters:
a, - the annotation to be deleted.
Throws:
AGException - if the annotation does not exist in this AG.

setStartAnchor

public void setStartAnchor(Annotation annotation,
                           Anchor anchor)
                    throws AGException
Assigns the annotation a new start anchor. Assigns the annotation a new start anchor. This method will delete the annotation from the index, reassign its start anchor to the specified anchor and then add the annotation back to the index. Note that this method does not ensure that the new start offset will be less than the annotation's end offset.

Parameters:
annotation, - the annotation being assigned a new start anchor.
anchor, - the new start anchor for the specified annotation.
Throws:
AGException, - if the annotation or anchor does not exist in this AG.
AGException

setEndAnchor

public void setEndAnchor(Annotation annotation,
                         Anchor anchor)
                  throws AGException
Assigns the annotation a new end anchor. Assigns the annotation a new end anchor. This method will delete the annotation from the index, reassign its end anchor to the specified anchor and then add the annotation back to the index. Note that this method does not ensure that the new end offset will be greater than the annotation's end offset.

Parameters:
annotation, - the annotation being assigned a new end anchor.
anchor, - the new end anchor for the specified annotation.
Throws:
AGException, - if the annotation or anchor does not exist in this AG.
AGException

setStartOffset

public void setStartOffset(Annotation ann,
                           float offset)
                    throws AGException
Sets the specified annotation's start anchor's offset to the specified offset. Sets the specified annotation's start anchor's offset to the specified offset. Note that all annotations which use the specified annotation's start anchor, either as a start or end anchor, will now start or end at the specified offset. To set only an individual annotation's offset, create a new anchor with the desired offset and use either setStartAnchor or setEndAnchor to attach the anchor.

Parameters:
ann, - the specified annotation.
offset, - the new offset for the start anchor of ann.
Throws:
AGException - if the annotation doesn't exist in the AG.

setEndOffset

public void setEndOffset(Annotation ann,
                         float offset)
                  throws AGException
Sets the specified annotation's end anchor's offset to the specified offset. Sets the specified annotation's end anchor's offset to the specified offset. Note that all annotations which use the specified annotation's end anchor, either has a start or end anchor, will now start or end at the specified offset. To set only an individual annotation's offset, create a new anchor with the desired offset and use either setStartAnchor or setEndAnchor to attach the anchor.

Parameters:
ann, - the specified annotation.
offset, - the new offset for the end anchor of ann.
Throws:
AGException - if the annotation doesn't exist in the AG.
See Also:
setAnchorOffset.

printAnnotationSetInfo

public void printAnnotationSetInfo()

setFeature

public void setFeature(java.lang.String id,
                       java.lang.String featureName,
                       java.lang.String featureValue)
                throws AGException
Set feature value of the metadata or annotation. Set feature value of the metadata or annotation. If it is AGId, then set the feature value of the metadata of the AG. Or, if it is AnnotationId, set the feature value of the annotation. If the id is an AnnotationId, the annotation will also be added to the corresponding set in the byFeature map of the index. Note that if the feature does not already exist in the annotation or metadata, it will be added. If it does exist, the value will be reset to the specified featureValue. This means that no addFeature method exists in AG.

Parameters:
id - could be AGId or AnnotationId.
featureName, - the name of the feature.
featureValue, - the value of the feature.
Throws:
AGException - if the id does not refer to an object in this AG.

existsFeature

public boolean existsFeature(java.lang.String id,
                             java.lang.String featureName)
                      throws AGException
Test if a feature exists in the metadata or annotation. Test if a feature exists in the metadata or annotation. If it is AGId, then test the existence of the feature of the metadata of the AG. Or, if it is AnnotationId, test the existence of the feature of the annotation.

Parameters:
id, - could be AGId or AnnotationId.
featureName, - the name of the feature.
Throws:
AGException

deleteFeature

public void deleteFeature(java.lang.String id,
                          java.lang.String featureName)
                   throws AGException
Delete the specified feature from the metadata or annotation. Delete the specified feature from the metadata or annotation. If it is AGId, then delete the feature from the metadata of the AG. Or, if it is AnnotationId, delete the feature from the annotation. If the id is an AnnotationId, the annotation will also be removed from the corresponding set in the byFeature map of the index.

Parameters:
id - could be AGId or AnnotationId.
featureName, - the name of the feature.
Throws:
AGException
See Also:
AnnotationIndex.deleteFeauture.

getFeature

public java.lang.String getFeature(java.lang.String id,
                                   java.lang.String featureName)
                            throws AGException
Get the value of the specified feature in the metadata or annotation. Get the value of the specified feature in the metadata or annotation. If it is AGId, then get the value of specified feature from the metadata of the AG. Or, if it is AnnotationId, get the value of specified feature from the annotation.

Parameters:
id - could be AGId or AnnotationId.
Returns:
the value of the specified feature.
Throws:
AGException - if either the id is invalid or the object does not contain the feature.

getFeatureNames

public java.util.Set getFeatureNames(java.lang.String id)
                              throws AGException
Gets all feature names from the metadata or annotation. Gets all feature names from the metadata or annotation. If it is AGId, then get all feature names from the metadata of the AG. Or, if it is AnnotationId, get all feature names from the annotation.

Parameters:
id - could be AGId or AnnotationId.
Returns:
a Set of Strings containing all the feature names.
Throws:
AGException, - if the id does not refer to an object in this AG.
AGException

setFeatures

public void setFeatures(java.lang.String id,
                        java.lang.String features)
                 throws AGException
Set multiple features in a single string. Set multiple features in a single string in Dublin Core Structured Values DCSV (Cox & Iannella) format. For example, "name=Stone Philips;phone=(215)555-8888;age=40". id could be AGId or AnnotationId. If it is AGId, then set features of the metadata of the AG. Or, if it is AnnotationId, set features of the annotation.

Parameters:
id, - either an annotationid or agid.
features, - the features to be added.
Throws:
AGException

getFeatures

public java.util.Set getFeatures(java.lang.String id)
                          throws AGException
Gets all the feature values in the specified metadata or annotation. Gets all the feature values in the specified metadata or annotation.

Parameters:
id, - could be the id of an annotation or metadata.
Throws:
AGException - if the id does not refer to an object in this AGSet.

unsetFeatures

public void unsetFeatures(java.lang.String id)
                   throws AGException
Unsets all features in the metadata or annotation. Sets all the features to empty string. If it is AGId, then unset features of the metadata of the AG. Or, if it is AnnotationId unset features of the annotation.Note, that the annotation remains in the byFeature map for each feature.

Parameters:
id - could be AGId or AnnotationId.
Throws:
AGException
See Also:
Metadata.unsetFeatures., Annotation.unsetFeatures.

setFeature

public void setFeature(Annotation a,
                       java.lang.String featureName,
                       java.lang.String featureValue)
                throws AGException
Set a feature of an annotation to the specified value, updating the index. Set a feature of an annotation to the specified value, updating the index.

Parameters:
a, - the annotation being assigned a new feature.
featureName, - the name of the new feature.
featureValue, - the value of the new feature.
Throws:
AGException - if the annotation does not exist in this AG.

getAnchorSetByOffset

public java.util.HashSet getAnchorSetByOffset(float offset,
                                              float epsilon)
                                       throws AGException
Gets a set containing those anchors with offset between offset +/- epsilon. Gets a set containing those anchors with offset between offset +/- epsilon. This function is inclusive.

Parameters:
offset, - the center offset.
epsilon, - the range.
Returns:
HashSet, the Set of anchors in between offset +/- epsilon
Throws:
AGException

getAnchorById

public Anchor getAnchorById(java.lang.String id)
                     throws AGException
Gets an anchor by its id. Gets an anchor by accessing the byAnchorId HashMap.

Parameters:
id, - the id of the anchor to be accessed.
Returns:
the Anchor with corresponding id.
Throws:
AGException, - if no anchor exists in anchor set with the id.
AGException

getAnchorSetNearestOffset

public java.util.Set getAnchorSetNearestOffset(float offset)
                                        throws AGException
Gets a set containing those anchors with offset nearest to a specified offset. Gets a set containing those anchors with offset nearest to a specified offset.

Parameters:
offset, - the center offset.
Returns:
Set, the Set of anchors nearest to specified offset.
Throws:
AGException

getAnnotationSeqByOffset

public java.util.Set getAnnotationSeqByOffset(float begin,
                                              float end)
Gets all annotations with its start anchor offset in between the specified values. Gets all annotations with its start anchor offset in between the specified values. If both values are 0, return all annotations in the AG.

Parameters:
begin, - the lower bound.
end, - the upper bound.
Returns:
all qualified annotations, sorted by start anchor offset.

storeSQLs

public java.util.Vector storeSQLs(java.lang.String agSetId,
                                  java.util.Set featureNames)
                           throws AGException
Throws:
AGException

toString

public java.lang.String toString()
Creates a string representation of this AG. Creates a string representation of this AG. The string is an XML string.

Overrides:
toString in class java.util.AbstractCollection
Returns:
a String representation of this object.

compareTo

public int compareTo(java.lang.Object that)
Specified by:
compareTo in interface java.lang.Comparable