ag
Class AGSet

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

public class AGSet
extends java.util.TreeSet

AGSet is a set of AG objets. It provides an interface to the developer for managing AGs and their associated annotations, timelines, signals and anchors. The developer accesses all AG elements from within AGSet by calling the relevant methods with an Id argument of type String. Consequently, the developer has no direct access to the objects themselves. The AGSet contains a HashMap, timelines, indexed by timelineId, containing Timelines. This allows for a Timeline to be available to multiple AGs. AGSet also contains two Identifiers objects, timelineIds and agIds which are used for indexing AGs and Ids. The Identifiers class is a central storage space containing HashMaps which are class variables.

Author:
Jonathan Dick., Xiaoyi Ma.
See Also:
Serialized Form

Constructor Summary
AGSet(org.w3c.dom.Element element)
           
AGSet(java.lang.String id)
          Class constructor, initializing all timelines, timelineIds, and agIds;
 
Method Summary
 java.lang.String copyAnnotation(java.lang.String annotationId)
          Creates a copy of a specified annotation but assigns it a new id.
 java.lang.String createAG(java.lang.String id, java.lang.String timelineId, java.lang.String type)
          Creates a new AG.
 java.lang.String createAnchor(java.lang.String id, float offset, java.lang.String unit, java.lang.String signalIds)
          Creates an anchor with specified offset, unit and signals.
 java.lang.String createAnchor(java.lang.String id, java.lang.String unit, java.lang.String signalIds)
          Creates an anchor with specified unit and signals.
 java.lang.String createAnnotation(java.lang.String id, java.lang.String anchorId1, java.lang.String anchorId2, java.lang.String annotationType)
          Creates a new annotation and adds it to specified AG.
 java.lang.String createSignal(java.lang.String id, java.lang.String uri, java.lang.String mimeClass, java.lang.String mimeType, java.lang.String encoding, java.lang.String unit, java.lang.String track)
          Creates a new Signal and add it to Timeline specified by the id.
 java.lang.String createTimeline(java.lang.String id)
          Creates a new Timeline and add it to this AGSet.
 void deleteAG(java.lang.String agId)
          Removes an AG from this AGSet.
 void deleteAnchor(java.lang.String anchorId)
          Deletes an anchor from the AG in the namespace of its id.
 void deleteAnnotation(java.lang.String annotationId)
          Deletes an annotation from its corresponding AG.
 void deleteFeature(java.lang.String id, java.lang.String featureName)
          Deletes the specified feature from the metadata or annotation.
 void deleteSignal(java.lang.String signalId)
          Deletes a signal from its Timeline.
 void deleteTimeline(java.lang.String timelineId)
          Removes a Timeline from this AGSet.
 boolean existsAG(java.lang.String agId)
          Check if an AG exists in this AGSet.
 boolean existsAnchor(java.lang.String anchorId)
          Checks if an anchor exists in this AGSet.
 boolean existsAnnotation(java.lang.String annotationId)
          Checks if an Annotation exists in this AGSet.
 boolean existsFeature(java.lang.String id, java.lang.String featureName)
          Checks if a Feature exists in the AG or Annotation specified by id.
 boolean existsSignal(java.lang.String signalId)
          Checks if a Signal exists in this AGSet.
 boolean existsTimeline(java.lang.String timelineId)
          Checks if a Timeline exists in this AGSet.
 java.lang.String getAGId(java.lang.String id)
          Gets the AGId given an annotationId or anchorId.
 java.util.Set getAGIds()
          Gets a Set of Strings containg the ids all AGs in this AGSet.
 float getAnchorOffset(java.lang.String anchorId)
          Gets the offset of the specified anchor.
 java.util.Set getAnchorSet(java.lang.String agId)
          Get the Set of anchors for the specified AG.
 java.util.Set getAnchorSetByOffset(java.lang.String agId, float offset, float epsilon)
          Gets a set containing those anchors with offset between offset +/- epsilon.
 java.util.Set getAnchorSetNearestOffset(java.lang.String agId, float offset)
          Gets a set containing those anchors with offset nearest to a specified offset in the specified AG.
 java.lang.String getAnchorSignalIds(java.lang.String anchorId)
          Gets the signals of the specified anchor.
 java.lang.String getAnnotationByOffset(java.lang.String agId, float offset)
          Gets the first annotation which spans over a specified offset in the specified AG.
 java.util.Set getAnnotationSeqByOffset(java.lang.String agId, float begin, float end)
          Gets all annotations with its start anchor offset in between the specified values from the specified AG.
 java.util.Set getAnnotationSetByFeature(java.lang.String agId, java.lang.String featureName)
          Gets the set of annotations with a specified feature from the specified AG.
 java.util.Set getAnnotationSetByOffset(java.lang.String agId, float offset)
          Gets the annotations that span across the specified time offset from the specified AG.
 java.util.Set getAnnotationSetByType(java.lang.String agId, java.lang.String annotationType)
          Gets the set of annotations with a specified type from the specified AG.
 java.lang.String getAnnotationType(java.lang.String annotationId)
          Gets the type of the specified annotation.
 java.lang.String getEndAnchor(java.lang.String annotationId)
          Gets the id of the end anchor of the specified annotation.
 float getEndOffset(java.lang.String annotationId)
          Gets the id of the end anchor of the specified annotation.
 java.lang.String getFeature(java.lang.String id, java.lang.String featureName)
          Gets 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.
 java.lang.String getID()
           
 java.util.Set getIncomingAnnotationSet(java.lang.String anchorId)
          Gets the set of annotations which have the specified anchor as an end anchor.
 java.lang.String getOffsetUnit(java.lang.String anchorId)
          Gets the unit of the specified anchor.
 java.util.Set getOutgoingAnnotationSet(java.lang.String anchorId)
          Gets the set of annotations which have the specified anchor as a start anchor.
 java.lang.String getSignalEncoding(java.lang.String signalId)
          Gets the type of encoding of the specified signal.
 java.lang.String getSignalMimeClass(java.lang.String signalId)
          Gets the mimeclass of the specified signal.
 java.lang.String getSignalMimeType(java.lang.String signalId)
          Gets the mimetype of the specified signal.
 java.util.HashSet getSignals(java.lang.String timelineId)
          Gets all the signalIds for the signals contained in a Timeline.
 java.lang.String getSignalTrack(java.lang.String signalId)
          Gets the track of the specified signal.
 java.lang.String getSignalUnit(java.lang.String signalId)
          Gets the time unit of the specified signal.
 java.lang.String getSignalXlinkHref(java.lang.String signalId)
          Gets the Xlinkref of the specified signal.
 java.lang.String getSignalXlinkType(java.lang.String signalId)
          Gets the Xlinktype of the specified signal.
 java.lang.String getStartAnchor(java.lang.String annotationId)
          Gets the id of the start anchor of the specified annotation.
 float getStartOffset(java.lang.String annotationId)
          Gets the offset of the start anchor of the specified annotation.
 java.lang.String getTimelineId(java.lang.String id)
          Gets the timelineId give an AgId or SignalId.
 java.util.Set getTimelineIds()
          Returns a set including all the timelineIds in this AGSet.
 java.util.Set nSplitAnnotation(java.lang.String annotationId, int n)
          Split an annotation n times.
 void printAGSetInfo()
           
 void printAnchorSetInfo(java.lang.String agId)
           
 void printAnnotationSetInfo(java.lang.String agId)
           
 void printSignalSetInfo(java.lang.String timelineId)
           
 void setAnchorOffset(java.lang.String anchorId, float offset)
          Sets the specified anchor's offset to the specified offset.
 void setAnchorSignalIds(java.lang.String anchorId, java.lang.String signalIds)
          Sets the signals of the specified anchor.
 void setEndAnchor(java.lang.String annotationId, java.lang.String anchorId)
          Sets the end anchor of the specified annotation to the specified anchor.
 void setEndOffset(java.lang.String annotationId, float offset)
          Sets the specified annotation's end anchor's offset to the specified offset.
 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 setOffsetUnit(java.lang.String anchorId, java.lang.String unit)
          Sets the unit of the specified anchor.
 void setStartAnchor(java.lang.String annotationId, java.lang.String anchorId)
          Sets the start anchor of the specified annotation to the specified anchor.
 void setStartOffset(java.lang.String annotationId, float offset)
          Sets the start offset of an annotation to the specified offset.
 java.lang.String splitAnchor(java.lang.String anchorId)
          Split an anchor in two.
 java.lang.String splitAnnotation(java.lang.String annotationId)
          Split an annotation a in two.
 java.lang.String toString()
          Creates a string representation of this AGSet.
 void unsetAnchorOffset(java.lang.String anchorId)
          Sets the specified anchor's offset to -1.
 void unsetFeature(java.lang.String id, java.lang.String featureName)
          Sets a feature's value to "", an empty String.
 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
 

Constructor Detail

AGSet

public AGSet(java.lang.String id)
Class constructor, initializing all timelines, timelineIds, and agIds;


AGSet

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

getID

public java.lang.String getID()

createAG

public java.lang.String createAG(java.lang.String id,
                                 java.lang.String timelineId,
                                 java.lang.String type)
                          throws AGException
Creates a new AG. Creates a new AG.

Parameters:
id, - the id of the new AG. If the id has already been assigned, the ag gets a new id. The id can be either an AG id or AGSet id.
timelineId, - the id of the timeline to be assigned to the new AG.
type, - the type of the new AG.
Returns:
the String id of the new AG.
Throws:
AGException, - if the id is invalid.
AGException

existsAG

public boolean existsAG(java.lang.String agId)
                 throws AGException
Check if an AG exists in this AGSet. existsAG searches this AGSet for an AG with the specified id.

Parameters:
agId, - the id of the AG.
Returns:
true if the AG exists in AGSet, false otherwise.
Throws:
AGException

deleteAG

public void deleteAG(java.lang.String agId)
              throws AGException
Removes an AG from this AGSet. Removes an AG from this AGSet (AGSet is a TreeSet) as well as from Identifiers. The id is then reclaimed by agIds and available for reuse.

Parameters:
timelineId, - the id of the timeline to be deleted.
Throws:
AGException, - if the AG does not exist in this AGSet.
AGException
See Also:
Identifiers.getTimeline.

getAGIds

public java.util.Set getAGIds()
                       throws AGException
Gets a Set of Strings containg the ids all AGs in this AGSet. getAGIds() returns a sorted set, ordered by a lexical comparison of AGIds, of the AGIds in this AGSet.

Returns:
a Set of Strings of the AGIds.
Throws:
AGException

printAGSetInfo

public void printAGSetInfo()
                    throws AGException
Throws:
AGException

createTimeline

public java.lang.String createTimeline(java.lang.String id)
                                throws AGException
Creates a new Timeline and add it to this AGSet. Creates a new Timeline and add it to this AGSet. Ifthe specified id is a TimelineId, the issuer will try the given id first, if it's taken, it will generate a new TimelineId. The issuer generates a new TimelineId, if the id parameter is an AGSetId.

Parameters:
id - might be AGSetId or TimelineId.
Returns:
the id of the new Timeline.
Throws:
AGException - IF (the id given is invalid)

existsTimeline

public boolean existsTimeline(java.lang.String timelineId)
Checks if a Timeline exists in this AGSet. Queries the Identifiers object to determine if a reference to the specified id exists.

Parameters:
timelineId, - the id of the Timeline.
Returns:
true if the Timeline exists in AGSet, false otherwise.

deleteTimeline

public void deleteTimeline(java.lang.String timelineId)
                    throws AGException
Removes a Timeline from this AGSet. Removes a Timeline from the timelines HashMap as well as from Identifiers. The id is then reclaimed by timelineIds and available for reuse.

Parameters:
timelineId, - the id of the timeline to be deleted.
Throws:
AGException, - if the AG does not exist in this AGSet.
AGException
See Also:
Identifiers

getTimelineIds

public java.util.Set getTimelineIds()
Returns a set including all the timelineIds in this AGSet. Returns a set including all the timelineIds in this AGSet.

Returns:
a Set containing all the timelineIds in this AGSet.

createSignal

public java.lang.String createSignal(java.lang.String id,
                                     java.lang.String uri,
                                     java.lang.String mimeClass,
                                     java.lang.String mimeType,
                                     java.lang.String encoding,
                                     java.lang.String unit,
                                     java.lang.String track)
                              throws AGException
Creates a new Signal and add it to Timeline specified by the id. Creates a new Signal and add it to this AGSet. If the specified id is a TimelineId, the issuer will try the given id first, if it's taken, it will generate a new TimelineId. The issuer generates a new TimelineId, if the id parameter is an AGSetId.

Parameters:
id, - might be AGSetId or TimelineId.
uri, - the "physical" location of the signal.
mimeClass, - the mimeclass of the signal.
mimeType, - the mimeType of the signal.
encoding, - the encoding of the signal.
unit, - the time unit of the signal.
track, - the track of the signal.
Returns:
the id of the new Timeline.
Throws:
AGException - IF (the id given is invalid)

existsSignal

public boolean existsSignal(java.lang.String signalId)
                     throws AGException
Checks if a Signal exists in this AGSet. Queries the Identifiers object to determine if a reference to the specified id exists.

Parameters:
signalId, - the id of the Signal.
Returns:
true if the Signal exists in AGSet, false otherwise.
Throws:
AGException

deleteSignal

public void deleteSignal(java.lang.String signalId)
                  throws AGException
Deletes a signal from its Timeline. Gets the Timeline reference from Identifiers and then invokes that Timeline's deleteSignal method on the reference of the signalId.

Parameters:
signalId, - the id of the signal to be deleted.
Throws:
AGException, - if the signalId is invalid.
AGException
See Also:
Timeline.deleteSignal().

getSignals

public java.util.HashSet getSignals(java.lang.String timelineId)
                             throws AGException
Gets all the signalIds for the signals contained in a Timeline. Gets the Timeline reference from Identifiers and then invokes that Timeline's getSignals() method.

Parameters:
timelineId, - the id of the timeline.
Returns:
a HashSet containing the ids of the Signals belonging to the specified timeline.
Throws:
AGException

getSignalMimeClass

public java.lang.String getSignalMimeClass(java.lang.String signalId)
                                    throws AGException
Gets the mimeclass of the specified signal. Gets the mimeclass of the specified signal.

Parameters:
signalId, - the id of the signal.
Returns:
the name of the mimeclass.
Throws:
AGException

getSignalMimeType

public java.lang.String getSignalMimeType(java.lang.String signalId)
                                   throws AGException
Gets the mimetype of the specified signal. Gets the mimetype of the specified signal.

Parameters:
signalId, - the id of the signal.
Returns:
the name of the mimetype.
Throws:
AGException

getSignalEncoding

public java.lang.String getSignalEncoding(java.lang.String signalId)
                                   throws AGException
Gets the type of encoding of the specified signal. Gets the type of encoding of the specified signal.

Parameters:
signalId, - the id of the signal.
Returns:
the name of the type of encoding.
Throws:
AGException

getSignalXlinkType

public java.lang.String getSignalXlinkType(java.lang.String signalId)
                                    throws AGException
Gets the Xlinktype of the specified signal. Gets the Xlinktype of the specified signal.

Parameters:
signalId, - the id of the signal.
Returns:
the name of the Xlinktype.
Throws:
AGException

getSignalXlinkHref

public java.lang.String getSignalXlinkHref(java.lang.String signalId)
                                    throws AGException
Gets the Xlinkref of the specified signal. Gets the Xlinkref of the specified signal.

Parameters:
signalId, - the id of the signal.
Returns:
the name of the Xlinkref.
Throws:
AGException

getSignalUnit

public java.lang.String getSignalUnit(java.lang.String signalId)
                               throws AGException
Gets the time unit of the specified signal. Gets the time unit of the specified signal.

Parameters:
signalId, - the id of the signal.
Returns:
the name of the time unit.
Throws:
AGException

getSignalTrack

public java.lang.String getSignalTrack(java.lang.String signalId)
                                throws AGException
Gets the track of the specified signal. Gets the track of the specified signal.

Parameters:
signalId, - the id of the signal.
Returns:
the name of the track.
Throws:
AGException

printSignalSetInfo

public void printSignalSetInfo(java.lang.String timelineId)
                        throws AGException
Throws:
AGException

createAnnotation

public java.lang.String createAnnotation(java.lang.String id,
                                         java.lang.String anchorId1,
                                         java.lang.String anchorId2,
                                         java.lang.String annotationType)
                                  throws AGException
Creates a new annotation and adds it to specified AG. Creates a new annotation and adds it to the specified AG. If the specified id is an AnnotationId, the issuer will try the given id first, if it's taken, it will generate a new annotationId. The issuer generates a new annotationId, if the id parameter is an agId.

Parameters:
id - might be agId or annotationId.
Returns:
the id of the new annotation.
Throws:
AGException - IF (the id given is invalid)

copyAnnotation

public java.lang.String copyAnnotation(java.lang.String annotationId)
                                throws AGException
Creates a copy of a specified annotation but assigns it a new id. Creates a new annotation with the same field values as the specified annotation and assigns the annotation a new id.

Parameters:
id, - an the id of the annotation to be copied.
Returns:
the id of the new annotation.
Throws:
AGException - IF (the id given is invalid)

deleteAnnotation

public void deleteAnnotation(java.lang.String annotationId)
                      throws AGException
Deletes an annotation from its corresponding AG. Deletes an annotation from its corresponding AG.

Parameters:
annotationId, - the id of the annotation to be deleted.
Throws:
AGException, - if the id is invalid.
AGException

setStartAnchor

public void setStartAnchor(java.lang.String annotationId,
                           java.lang.String anchorId)
                    throws AGException
Sets the start anchor of the specified annotation to the specified anchor. Sets the start anchor of the specified annotation to the specified anchor.

Parameters:
annotationId, - the annotation being assigned a new start anchor.
anchorId, - the new start anchor.
Throws:
AGException, - if either id is invalid.
AGException

setEndAnchor

public void setEndAnchor(java.lang.String annotationId,
                         java.lang.String anchorId)
                  throws AGException
Sets the end anchor of the specified annotation to the specified anchor. Sets the end anchor of the specified annotation to the specified anchor.

Parameters:
annotationId, - the annotation being assigned a new end anchor.
anchorId, - the new start anchor.
Throws:
AGException, - if either id is invalid.
AGException

setStartOffset

public void setStartOffset(java.lang.String annotationId,
                           float offset)
                    throws AGException
Sets the start offset of an annotation to the specified offset. Sets the start offset of an annotation to the specified offset. A new start anchor is created with the specified offset and anchored to the annotation. The id of the new anchor is returned.

Parameters:
annotationId, - the annotation getting a new offset.
offset, - the new offset value.
Throws:
AGException

setEndOffset

public void setEndOffset(java.lang.String annotationId,
                         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 id of 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:
AG.setEndOffset.

splitAnnotation

public java.lang.String splitAnnotation(java.lang.String annotationId)
                                 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 has no offset.

Parameters:
annotationId, - the annotation to be split.
Returns:
the Id of the new annotation a'.
Throws:
AGException
See Also:
AG.splitAnnotation.

nSplitAnnotation

public java.util.Set nSplitAnnotation(java.lang.String annotationId,
                                      int n)
                               throws AGException
Split an annotation n times. A version of split which does the split operation n times over.

Parameters:
annotationId, - the id of 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

existsAnnotation

public boolean existsAnnotation(java.lang.String annotationId)
Checks if an Annotation exists in this AGSet. Queries the Identifiers object to determine if a reference to the specified id exists.

Parameters:
annotationId, - the id of the Annotation.
Returns:
true if the Annotation exists in AGSet, false otherwise.

getAnnotationType

public java.lang.String getAnnotationType(java.lang.String annotationId)
                                   throws AGException
Gets the type of the specified annotation. Gets the type of the specified annotation.

Returns:
the type of the specified annotation.
Throws:
AGException

getStartAnchor

public java.lang.String getStartAnchor(java.lang.String annotationId)
                                throws AGException
Gets the id of the start anchor of the specified annotation. Gets the id of the start anchor of the specified annotation.

Parameters:
annotationId, - the specified annotation.
Returns:
the id of the start anchor of the specified annotation.
Throws:
AGException - if the annotationId does not exist in this AGSet.

getEndAnchor

public java.lang.String getEndAnchor(java.lang.String annotationId)
                              throws AGException
Gets the id of the end anchor of the specified annotation. Gets the id of the end anchor of the specified annotation.

Parameters:
annotationId, - the specified annotation.
Returns:
the id of the end anchor of the specified annotation.
Throws:
AGException - if the annotationId does not exist in this AGSet.

getStartOffset

public float getStartOffset(java.lang.String annotationId)
                     throws AGException
Gets the offset of the start anchor of the specified annotation. Gets the offset of the start anchor of the specified annotation.

Parameters:
annotationId, - the specified annotation.
Returns:
the start offset of the specified annotation. -1 is returned if the offset is not assigned.
Throws:
AGException - if the annotationId does not exist in this AGSet.

getEndOffset

public float getEndOffset(java.lang.String annotationId)
                   throws AGException
Gets the id of the end anchor of the specified annotation. Gets the id of the end anchor of the specified annotation.

Parameters:
annotationId, - the specified annotation.
Returns:
the end offset of the specified annotation. -1 is returned if the offset is not assigned.
Throws:
AGException - if the annotationId does not exist in this AGSet.

printAnnotationSetInfo

public void printAnnotationSetInfo(java.lang.String agId)
                            throws AGException
Throws:
AGException

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 AGSet.

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 - if the id does not refer to an object in this AGSet.

unsetFeature

public void unsetFeature(java.lang.String id,
                         java.lang.String featureName)
                  throws AGException
Sets a feature's value to "", an empty String. Sets a feature's value to "", an empty String. If it is AGId, then unset the feature of the metadata of the AG. Or, if it is AnnotationId unset the featuret 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:
AG.setFeature.

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.

deleteFeature

public void deleteFeature(java.lang.String id,
                          java.lang.String featureName)
                   throws AGException
Deletes the specified feature from the metadata or annotation. Deletes 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. This method removes the feature element from the corresponding featureMap. To keep the feature but set it to "", use unsetFeature.

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

existsFeature

public boolean existsFeature(java.lang.String id,
                             java.lang.String featureName)
                      throws AGException
Checks if a Feature exists in the AG or Annotation specified by id. After determining the type of id, a query is made to the Identifiers object to determine if a reference exists for the specified id.

Parameters:
timelineId, - the id of the Timeline.
Returns:
true if the Timeline exists in AGSet, false otherwise.
Throws:
AGException

getFeature

public java.lang.String getFeature(java.lang.String id,
                                   java.lang.String featureName)
                            throws AGException
Gets the value of the specified feature in the metadata or annotation. Gets 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.

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.

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

createAnchor

public java.lang.String createAnchor(java.lang.String id,
                                     float offset,
                                     java.lang.String unit,
                                     java.lang.String signalIds)
                              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 signalIds)
                              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)

existsAnchor

public boolean existsAnchor(java.lang.String anchorId)
Checks if an anchor exists in this AGSet. Queries the Identifiers object to determine if a reference to the specified id exists.

Parameters:
anchorId, - the id of the anchor.
Returns:
true if the anchor exists in AGSet, false otherwise.

deleteAnchor

public void deleteAnchor(java.lang.String anchorId)
                  throws AGException
Deletes an anchor from the AG in the namespace of its id. Deletes an anchor from the AG in the namespace of its id. 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 the AG.
See Also:
AnnotationIndex.deleteAnchor.

setAnchorOffset

public void setAnchorOffset(java.lang.String anchorId,
                            float offset)
                     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 id of 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.

getAnchorOffset

public float getAnchorOffset(java.lang.String anchorId)
                      throws AGException
Gets the offset of the specified anchor. Gets the offset of the specified anchor.

Parameters:
anchorId, - the id of the specified anchor.
Returns:
the offset of the specified anchor.
Throws:
AGException - if the anchor does not exist in namespace of its id.

setOffsetUnit

public void setOffsetUnit(java.lang.String anchorId,
                          java.lang.String unit)
                   throws AGException
Sets the unit of the specified anchor. Sets the unit of the specified anchor.

Parameters:
anchorId, - the id of the specified anchor.
unit, - the new unit.
Throws:
AGException - if the anchor does not exist in namespace of its id.

getOffsetUnit

public java.lang.String getOffsetUnit(java.lang.String anchorId)
                               throws AGException
Gets the unit of the specified anchor. Gets the unit of the specified anchor.

Parameters:
anchorId, - the id of the specified anchor.
Returns:
the unit of the specified anchor.
Throws:
AGException - if the anchor does not exist in namespace of its id.

setAnchorSignalIds

public void setAnchorSignalIds(java.lang.String anchorId,
                               java.lang.String signalIds)
                        throws AGException
Sets the signals of the specified anchor. Sets the signals of the specified anchor.

Parameters:
anchorId, - the id of the specified anchor.
signalIds, - the new signalIds for the specified anchor.
Throws:
AGException - if the anchor does not exist in namespace of its id.

getAnchorSignalIds

public java.lang.String getAnchorSignalIds(java.lang.String anchorId)
                                    throws AGException
Gets the signals of the specified anchor. Gets the signals of the specified anchor.

Parameters:
anchorId, - the id of the specified anchor.
Returns:
the signalIds for the specified anchor.
Throws:
AGException - if the anchor does not exist in namespace of its id.

unsetAnchorOffset

public void unsetAnchorOffset(java.lang.String anchorId)
                       throws AGException
Sets the specified anchor's offset to -1. Sets the specified anchor's offset to -1. The index removes the set of annotations anchored to the specified anchor from the relevant HashMaps.

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

splitAnchor

public java.lang.String splitAnchor(java.lang.String anchorId)
                             throws AGException
Split an anchor in two. Split an anchor a in two, creating a new anchor a' having the same offset as the original one. Anchor a has all the incoming annotations, while anchor a' has all the outgoing annotations. The new anchor a' is returned.

Parameters:
a1, - the id of the anchor to be split.
Returns:
the id of the new anchor now anchored to the outgoing annotations of a1.
Throws:
AGException, - if the anchor does not exist in this AG.
AGException

getIncomingAnnotationSet

public java.util.Set getIncomingAnnotationSet(java.lang.String anchorId)
                                       throws AGException
Gets the set of annotations which have the specified anchor as an end anchor. Gets the set of annotations from incoming indexed by the anchor.

Parameters:
a, - the id of the specified anchor.
Returns:
a Set containing the ids of the incoming annotations.
Throws:
AGException
See Also:
AnnotationIndex.getIncomingAnnotations.

getOutgoingAnnotationSet

public java.util.Set getOutgoingAnnotationSet(java.lang.String anchorId)
                                       throws AGException
Gets the set of annotations which have the specified anchor as a start anchor. Gets the set of annotations from outgoing indexed by the anchor.

Parameters:
a, - the id of the specified anchor.
Returns:
a set containing the outgoing annotations.
Throws:
AGException
See Also:
AnnotationIndex.getOutgoingAnnotations.

printAnchorSetInfo

public void printAnchorSetInfo(java.lang.String agId)
                        throws AGException
Throws:
AGException

getAnchorSet

public java.util.Set getAnchorSet(java.lang.String agId)
                           throws AGException
Get the Set of anchors for the specified AG. Get the Set of anchors for the specified AG.

Parameters:
agId, - the id of the specified AG.
Returns:
the Set of anchors for the specified AG.
Throws:
AGException

getAnchorSetByOffset

public java.util.Set getAnchorSetByOffset(java.lang.String agId,
                                          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

getAnchorSetNearestOffset

public java.util.Set getAnchorSetNearestOffset(java.lang.String agId,
                                               float offset)
                                        throws AGException
Gets a set containing those anchors with offset nearest to a specified offset in the specified AG. Gets a set containing those anchors with offset nearest to a specified offset in the specified AG..

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

getAnnotationSetByFeature

public java.util.Set getAnnotationSetByFeature(java.lang.String agId,
                                               java.lang.String featureName)
                                        throws AGException
Gets the set of annotations with a specified feature from the specified AG. Gets the set of annotations with a specified feature from byFeature from the specified AG.

Parameters:
agId, - the id of the specified AG.
feature, - the specified feature name.
Returns:
a Set containing all annotations with specified feature.
Throws:
AGException

getAnnotationSetByOffset

public java.util.Set getAnnotationSetByOffset(java.lang.String agId,
                                              float offset)
                                       throws AGException
Gets the annotations that span across the specified time offset from the specified AG. Gets the annotations that span across the specified time offset from the specified AG. This function is inclusive.

Parameters:
agId, - the id of the specified AG.
o, - the specified offset.
Returns:
a Set containing the annotations spanning over the specified offset.
Throws:
AGException
See Also:
AnnotationIndex.getAnnotationSetByOffset.

getAnnotationSetByType

public java.util.Set getAnnotationSetByType(java.lang.String agId,
                                            java.lang.String annotationType)
                                     throws AGException
Gets the set of annotations with a specified type from the specified AG. Gets the set of annotations with a specified type from the specified AG.

Parameters:
agId, - the specified AG.
type, - the specified type.
Returns:
a Set containing all annotations of specified type.
Throws:
AGException

getAnnotationSeqByOffset

public java.util.Set getAnnotationSeqByOffset(java.lang.String agId,
                                              float begin,
                                              float end)
                                       throws AGException
Gets all annotations with its start anchor offset in between the specified values from the specified AG. Gets all annotations with its start anchor offset in between the specified values from the specified AG. 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.
Throws:
AGException

getAnnotationByOffset

public java.lang.String getAnnotationByOffset(java.lang.String agId,
                                              float offset)
                                       throws AGException
Gets the first annotation which spans over a specified offset in the specified AG. Gets the first annotation which spans over a specified offset. in the specified AG. This function is inclusive.

Parameters:
agId, - the specified AG.
offset, - the specified offset.
Returns:
the first annotation found spanning over the specified offset.
Throws:
AGException
See Also:
AnnotationIndex.getAnnotationByOffset.

getAGId

public java.lang.String getAGId(java.lang.String id)
                         throws AGException
Gets the AGId given an annotationId or anchorId. Gets the AGId given an annotationId or anchorId.

Parameters:
id, - may be AnnotationId or AnchorId.
Returns:
the id of the AG containing the specified annotationId or anchorId.
Throws:
AGException

getTimelineId

public java.lang.String getTimelineId(java.lang.String id)
                               throws AGException
Gets the timelineId give an AgId or SignalId. Gets the timelineId give an AgId or SignalId.

Parameters:
id, - may be AGId or SignalId.
Returns:
the id of the timelineId.
Throws:
AGException

toString

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

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