|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.annotation.wordfreak.AnnotationTree
A data structure for storing extent-based annotations in a sorted tree structure and meta-information relating them. The sorting is based on the annoation's span. In cases where this does not indicate a unique location within the tree methods are available to specify which parent or sibling should be used or to prefer placing the annotation deeper or shallower in the tree.
Field Summary | |
static java.lang.String |
ANNOTATION_SOURCE
|
static java.lang.String |
DEFAULT
|
static java.lang.String |
DEFAULT_VIEW
|
protected AnnotationFile |
file
The i/o file for this Tree. |
protected java.util.List |
heads
List of chain head annotations. |
static java.lang.String |
ID
|
protected int |
maxId
Largest id being used in this tree. |
protected boolean |
messaging
Specifies whether views should be notified of changes to this tree. |
protected java.util.Map |
nextMap
Mapping between a head annotation and it's chained annotation. |
protected java.util.Map |
prevMap
Mapping between a chained annotation and it's head annotation. |
protected java.util.HashMap |
relations_per_anchor
Mapping between anchor annotation and their relation. |
protected HashList |
relations_per_annotation
Mapping between annotation and every relation which references that annotation. |
protected HashList |
relations_per_type
Mapping between a relation type and all the realtions of that type. |
protected Annotation |
root
The root of this Tree. |
protected AnnotationSource |
source
The data source that this Tree annotates. |
protected java.util.Set |
usedIds
Set of id keys currently being used in this tree. |
protected java.util.Map |
views
A list of various masked views of this Tree. |
static java.lang.String |
XML_TYPE
|
Constructor Summary | |
AnnotationTree(AnnotationFile f,
AnnotationSource s)
|
Method Summary | |
boolean |
add(Annotation annotation)
|
boolean |
add(Annotation root,
Annotation annotation)
Adds a new annotation to root and updates dependent annotations adjusting it if necessary to maintain tree integrity. |
boolean |
add(Annotation root,
Annotation annotation,
Annotation above)
|
boolean |
add(Annotation root,
Annotation annotation,
Annotation above,
boolean strictContains)
|
boolean |
add(Annotation root,
Annotation annotation,
Annotation above,
boolean preferShallow,
int start,
int end)
Adds the specified annotation below the specified root and above the specified above annotation prefering shallow insertion when the specified boolean is true. |
boolean |
addAbove(Annotation annotation,
Annotation above)
|
AnnotationView |
addAnnotationView(java.lang.Object key)
|
AnnotationView |
addAnnotationView(java.lang.Object key,
AnnotationFilter filter)
|
AnnotationView |
addAnnotationView(java.lang.Object key,
AnnotationFilter aFilter,
AnnotationFilter bFilter)
|
AnnotationView |
addAnnotationView(java.lang.Object key,
AnnotationFilter aFilter,
AnnotationFilter bFilter,
SortedAnnotations s)
|
void |
addAnnotationView(java.lang.Object key,
AnnotationView view)
|
void |
addAnnotator(java.lang.String annotator)
|
void |
addFeature(java.lang.String feature)
|
int |
adjacent(Annotation a,
Annotation b)
|
void |
chainAnnotations(Annotation a,
Annotation b)
Creates a chain between the two specified annotations. |
void |
clear()
|
boolean |
contains(Annotation a)
|
Relation |
createRelation(java.lang.String type,
java.lang.Object key,
java.lang.String[] frame,
Annotation[] annotations)
Returns a new releation with the specified type, anchor key, frame, and annotations. |
boolean |
deepAdd(Annotation annotation)
|
boolean |
deepAdd(Annotation root,
Annotation annotation)
|
void |
deepInsert(Annotation a)
|
Annotation |
deepInsert(java.lang.String type,
int s,
int e)
|
void |
fireTreeNodesChanged(Annotation node,
Annotation[] children)
|
void |
fireTreeNodesInserted(Annotation node,
Annotation[] children)
|
void |
fireTreeNodesMoved(Annotation[] children,
Annotation oldParent,
Annotation newParent)
|
void |
fireTreeNodesRemoved(Annotation node,
Annotation[] children)
|
void |
fireTreeStructureChanged(Annotation node)
|
AnnotationFile |
getAnnotationFile()
|
AnnotationSource |
getAnnotationSource()
|
AnnotationView |
getAnnotationView(java.lang.Object key)
|
Annotation[] |
getChain(Annotation a)
Returns the chains associated with the specified annotation. |
Annotation[] |
getChains()
Returns the head annotations associated with all chains in this tree. |
java.lang.Object |
getChild(Annotation a,
int i)
Returns the child at the specified index of the specified annotation. |
java.lang.Object |
getChild(java.lang.Object node,
int i)
|
int |
getChildCount(Annotation a)
Returns the number of children that the specified annotation has. |
int |
getChildCount(java.lang.Object node)
|
Annotation |
getContainingLeaf(int offset)
Returns the leaf which contains the offset. |
Annotation |
getContainingNode(Span span)
Returns the deepest annotation which contains the specified span. |
byte[] |
getData(int offset,
int length)
|
int |
getIndexOfChild(java.lang.Object node,
java.lang.Object child)
|
java.util.List |
getLeavesInRange(int s,
int e)
|
java.lang.Object |
getParent(Annotation a)
|
Relation |
getRelation(Annotation a)
|
Relation |
getRelation(java.lang.String type,
Annotation a)
Returns a relation which is of the specified type and has as its anchor the specified annotation. |
Relation[] |
getRelations()
Returns all the relations in this tree. |
Relation[] |
getRelations(Annotation a)
Returns all the relations which relate the specified annotation. |
Relation[] |
getRelations(java.lang.String type)
Returns all the relations of a given type in this tree. |
Relation[] |
getRelations(java.lang.String type,
Annotation a)
Returns all relation which are of the specified type and which contain the specified annotation. |
Annotation |
getRoot()
|
AnnotationSource |
getSource()
|
void |
insert(Annotation a)
|
void |
insert(Annotation parent,
Annotation annotation)
Inserts the specified annotation below the specified parent. |
void |
insert(Annotation root,
Annotation annotation,
Annotation above)
|
Annotation |
insert(int s,
int e)
|
Annotation |
insert(int s,
int e,
Annotation parent)
|
Annotation |
insert(java.lang.String type,
Annotation s,
Annotation e)
Inserts and annotation which has s as its first child and e as its last child. |
Annotation |
insert(java.lang.String type,
int s,
int e)
Inserts an annotation with specified type and span and returns that new annotation. |
Annotation |
insert(java.lang.String type,
int s,
int e,
Annotation parent)
|
Annotation |
insertParent(Annotation child)
Creates a parent above an Annotation. |
Annotation |
insertParent(java.lang.String type,
Annotation child)
Creates a parent above an Annotation. |
void |
insertSubTree(Annotation a,
Annotation p)
|
Annotation |
insertZeroLengthAnnotationAfter(Annotation after)
|
Annotation |
insertZeroLengthAnnotationAfter(java.lang.String type,
Annotation after)
|
Annotation |
insertZeroLengthAnnotationBefore(Annotation before)
|
Annotation |
insertZeroLengthAnnotationBefore(java.lang.String type,
Annotation before)
|
boolean |
isAnchor(Annotation chainedAnnotation)
Returns true of the specified annotation is the head of a chain. |
boolean |
isLeaf(java.lang.Object node)
|
boolean |
isTerminalSpan(int start,
int end)
Returns true if the span given by the specified start and end values can be inserted into this tree as a leaf. |
boolean |
isTerminalSpan(Span span)
Returns true if the specified span can be inserted into this tree as a leaf. |
boolean |
isValidSpan(int start,
int end)
Returns true if the span given by the specified start and end values can be inserted into this tree without crossing another annotation. |
boolean |
isValidSpan(Span span)
Returns true if the specified span can be inserted into this tree without crossing another annotation. |
java.util.Iterator |
iterator()
|
void |
move(Annotation node,
Annotation dest)
moves an Annotation from one place to another. |
void |
put(int roleIndex,
Annotation ann,
Relation relation)
Puts the specified annotation at the specified role index in the specified relation. |
void |
put(java.lang.String role,
Annotation ann,
Relation relation)
Puts the specified annotation the specified relation with the specified role name. |
void |
remove(Annotation annotation)
|
void |
remove(Annotation annotation,
boolean shrink)
|
void |
remove(Annotation annotation,
Relation relation)
Removes the specified annotation from the specified relation or if the specified annotation is the anchor of the relation, removes the relation from this tree. |
void |
remove(Relation relation)
Removes the specified relation from this tree. |
void |
remove(java.lang.String type,
Annotation a,
Relation relation)
|
void |
removeAnnotationView(java.lang.Object key)
|
Annotation |
removeFromChain(Annotation a)
Removes the specified annotation from a chain and returns another annotation from the modified chain if such an annotation exists. |
javax.swing.tree.TreeNode |
removeSubTree(Annotation annotation)
|
void |
setAnnotationSource(AnnotationSource s)
|
void |
setRoot(Annotation r)
|
protected void |
setSourceFileName(java.lang.String sfn)
|
boolean |
shallowAdd(Annotation annotation)
|
boolean |
shallowAdd(Annotation root,
Annotation annotation)
|
Annotation |
terminalInsert(java.lang.String type,
int start,
int end)
Inserts a newly created annotation with the specified type and span in this tree and returns the newly created annotation. |
void |
update(Annotation a)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String ID
public static final java.lang.String ANNOTATION_SOURCE
public static final java.lang.String DEFAULT_VIEW
public static final java.lang.String XML_TYPE
public static final java.lang.String DEFAULT
protected AnnotationFile file
protected AnnotationSource source
protected Annotation root
protected java.util.Map views
protected java.util.Set usedIds
protected int maxId
protected java.util.List heads
protected java.util.Map nextMap
protected java.util.Map prevMap
protected java.util.HashMap relations_per_anchor
protected HashList relations_per_annotation
protected HashList relations_per_type
protected boolean messaging
Constructor Detail |
public AnnotationTree(AnnotationFile f, AnnotationSource s)
Method Detail |
protected void setSourceFileName(java.lang.String sfn)
public void setAnnotationSource(AnnotationSource s)
public AnnotationSource getAnnotationSource()
public AnnotationView getAnnotationView(java.lang.Object key)
public AnnotationView addAnnotationView(java.lang.Object key)
public AnnotationView addAnnotationView(java.lang.Object key, AnnotationFilter filter)
public AnnotationView addAnnotationView(java.lang.Object key, AnnotationFilter aFilter, AnnotationFilter bFilter)
public AnnotationView addAnnotationView(java.lang.Object key, AnnotationFilter aFilter, AnnotationFilter bFilter, SortedAnnotations s)
public void addAnnotationView(java.lang.Object key, AnnotationView view)
public void removeAnnotationView(java.lang.Object key)
public Annotation getContainingLeaf(int offset)
offset
- The offset.
public Annotation getContainingNode(Span span)
span
- The span which the returned node must contain.
public boolean add(Annotation annotation)
public boolean add(Annotation root, Annotation annotation)
root
- parent annotation into which new annotaiton will be inserted.annotation
- new annotation to be added.
public boolean addAbove(Annotation annotation, Annotation above)
public boolean deepAdd(Annotation annotation)
public boolean deepAdd(Annotation root, Annotation annotation)
public boolean shallowAdd(Annotation annotation)
public boolean shallowAdd(Annotation root, Annotation annotation)
public boolean add(Annotation root, Annotation annotation, Annotation above)
public boolean add(Annotation root, Annotation annotation, Annotation above, boolean strictContains)
public boolean add(Annotation root, Annotation annotation, Annotation above, boolean preferShallow, int start, int end)
root
- the annotation below which the annotation is added.annotation
- The annotation to be added.above
- An annotation above which the specified annotation should be inserted.preferShallow
- specifies whether the addition should prefer shallower placement in the tree.start
- end
-
public void insert(Annotation parent, Annotation annotation)
parent
- The parent annotation of the annotation to be inserted.annotation
- The annotation to insert into this tree.public void insert(Annotation root, Annotation annotation, Annotation above)
public void insert(Annotation a)
public void deepInsert(Annotation a)
public Annotation insert(int s, int e)
public Annotation insert(int s, int e, Annotation parent)
public Annotation deepInsert(java.lang.String type, int s, int e)
public Annotation terminalInsert(java.lang.String type, int start, int end)
type
- The type of annotation to create.start
- The start of the span of the new annotation.end
- The end of the span of the new annotation.
public boolean isValidSpan(int start, int end)
start
- The start value of the span.end
- The end value of the span.
public boolean isValidSpan(Span span)
span
- The span to be tested.
public boolean isTerminalSpan(int start, int end)
start
- The start value of the span.end
- The end value of the span.
public boolean isTerminalSpan(Span span)
span
- The span to be tested.
public Annotation insert(java.lang.String type, int s, int e, Annotation parent)
public Annotation insert(java.lang.String type, int s, int e)
type
- the type.s
- the start of the span.e
- then end of the span.
public Annotation insert(java.lang.String type, Annotation s, Annotation e)
s
as its first child and e
as its last child.
public void insertSubTree(Annotation a, Annotation p)
public Annotation insertZeroLengthAnnotationBefore(Annotation before)
public Annotation insertZeroLengthAnnotationBefore(java.lang.String type, Annotation before)
public Annotation insertZeroLengthAnnotationAfter(Annotation after)
public Annotation insertZeroLengthAnnotationAfter(java.lang.String type, Annotation after)
public Annotation insertParent(Annotation child)
child
- the annotation to create a parent above.
public Annotation insertParent(java.lang.String type, Annotation child)
child
- the annotation to create a parent above.type
- the type of annotation to create.
public void move(Annotation node, Annotation dest)
node
- the annotation to move.dest
- the annotation to move it into.public void remove(Annotation annotation)
public void remove(Annotation annotation, boolean shrink)
public javax.swing.tree.TreeNode removeSubTree(Annotation annotation)
public void update(Annotation a)
public void clear()
public boolean contains(Annotation a)
public java.util.Iterator iterator()
public void setRoot(Annotation r)
public Annotation getRoot()
public AnnotationFile getAnnotationFile()
public java.util.List getLeavesInRange(int s, int e)
public byte[] getData(int offset, int length)
public AnnotationSource getSource()
public void addAnnotator(java.lang.String annotator)
public void addFeature(java.lang.String feature)
public void fireTreeNodesInserted(Annotation node, Annotation[] children)
public void fireTreeNodesMoved(Annotation[] children, Annotation oldParent, Annotation newParent)
public void fireTreeNodesRemoved(Annotation node, Annotation[] children)
public void fireTreeNodesChanged(Annotation node, Annotation[] children)
public void fireTreeStructureChanged(Annotation node)
public void chainAnnotations(Annotation a, Annotation b)
a
- The first annotation in the chain.b
- The second annotation in the chain.public Annotation[] getChains()
public Annotation[] getChain(Annotation a)
a
- An annotation in a chain.
public Annotation removeFromChain(Annotation a)
a
- The annotation to be removed.
public boolean isAnchor(Annotation chainedAnnotation)
chainedAnnotation
- Tha annotation to check.
public Relation createRelation(java.lang.String type, java.lang.Object key, java.lang.String[] frame, Annotation[] annotations)
type
- The type of the relations.key
- The anchor annotation of this relation.frame
- The names of the frame elements of the relation.annotations
- The annotation which occupy the frame elements.
public void put(int roleIndex, Annotation ann, Relation relation)
roleIndex
- The position in the frame of the specified relation when the specified annotaiton will be placed.ann
- The annotation to be placed at the specified role Index in the specified relation.relation
- The annotation to be modified.public void put(java.lang.String role, Annotation ann, Relation relation)
role
- The name of the role slot in the relation when the annotation will be placed.ann
- The annotation to put in the relation.relation
- The relation to be modified.public void remove(Relation relation)
relation
- The relation to be removed.public void remove(Annotation annotation, Relation relation)
annotation
- The annotaiton to remove.relation
- The relation from which the spevified annotation is removed.public void remove(java.lang.String type, Annotation a, Relation relation)
public Relation[] getRelations()
public Relation[] getRelations(java.lang.String type)
type
- the type of Relation to return
type
in this tree.public Relation[] getRelations(Annotation a)
a
- the Annotation to find Relations forpublic Relation[] getRelations(java.lang.String type, Annotation a)
type
- The type of relations to be returned.a
- The annotation which the returned relations contain.
public Relation getRelation(Annotation a)
public Relation getRelation(java.lang.String type, Annotation a)
type
- The type of relation to be returned.a
- The anchor of the relations to be returned.
public int adjacent(Annotation a, Annotation b)
public java.lang.Object getChild(java.lang.Object node, int i)
public int getChildCount(java.lang.Object node)
public int getIndexOfChild(java.lang.Object node, java.lang.Object child)
public boolean isLeaf(java.lang.Object node)
public java.lang.Object getParent(Annotation a)
public java.lang.Object getChild(Annotation a, int i)
a
- The annotation whose child is to be returned.i
- The index of the child to be returned.
public int getChildCount(Annotation a)
a
- The annotation whose children count is being requested.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |