org.annotation.wordfreak
Class Relation

java.lang.Object
  extended byorg.annotation.util.FeatureMap
      extended byorg.annotation.wordfreak.Relation

public class Relation
extends FeatureMap

Class for storing a relation between annotations. The relation is represented as a frame consisting a series of frame elements, a type, and an anchor annotation. Each element is named with its role, and multiple elements can share the same role name. Elements can be uniquely identified via their index in the frame.


Field Summary
static int ARGUMENT_SPAN
           
static int NONE
           
static int ROLE_NAME
           
static java.lang.String TYPE
           
 
Fields inherited from class org.annotation.util.FeatureMap
DEFAULT_SET_DELIMITER, properties
 
Constructor Summary
Relation(java.lang.String t, java.lang.String[] roles, Annotation[] annotations)
          Creates a new relation witht the specified type and populates the frame with the specified role names mapping them to their coresponding specified annotations.
 
Method Summary
 java.util.Iterator annotationsIterator()
           
 void clear()
           
 boolean contains(Annotation a)
           
 boolean contains(java.lang.String r)
           
 Annotation[] get(java.lang.String role)
          Returns each annotation in this relation whose role name matches the specified role name.
 Annotation getAnchor()
           
 Annotation getAnnotation(int position)
           
 Argument getArgument(Annotation a)
           
 Argument getArgument(int position)
           
 java.lang.String getRole(Annotation argument)
          Returns the role name for the specified position in the relation's frame.
 java.lang.String getRole(int position)
          Returns the role name for the specified position in the relation's frame.
 java.lang.String getType()
           
 int indexOf(Annotation ann)
          Returns the index of the first occurance of the specified annotation
 int indexOf(java.lang.String role)
          Returns the index of the first occurance of the specified role name.
 Annotation put(int position, Annotation a)
          Puts the specified annotation at the specified position in the frame and returns the annotation which previously held that position.
 void put(java.lang.String role, Annotation a)
          Adds the specified role to the relation frame and associates it with the specified annotation.
 Annotation remove(Annotation annotation)
          Removes the specified annotation from this relation.
 Annotation removeRole(java.lang.String role)
          Removes each instance of the specified role name.
 void renameRole(java.lang.String oldr, java.lang.String newr)
          Renames the each instance of the specified old role name to the new role name.
 java.util.Iterator rolesIterator()
           
 void setAnchor(Annotation a)
           
 void setAnchor(java.lang.String r)
           
 void setFeature(java.lang.String k, java.lang.String v)
           
 void setType(java.lang.String t)
           
 int size()
          Returns the number of frame elements in this relation.
 void sortBy(int s)
           
 java.lang.String toString()
           
 
Methods inherited from class org.annotation.util.FeatureMap
addFeatureValue, addFeatureValue, existsFeature, getFeature, getFeatureAsSet, getFeatureAsSet, getFeatureSet, removeFeature, removeFeatureValue, removeFeatureValue, setFeatures, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static int NONE

ROLE_NAME

public static int ROLE_NAME

ARGUMENT_SPAN

public static int ARGUMENT_SPAN

TYPE

public static java.lang.String TYPE
Constructor Detail

Relation

public Relation(java.lang.String t,
                java.lang.String[] roles,
                Annotation[] annotations)
Creates a new relation witht the specified type and populates the frame with the specified role names mapping them to their coresponding specified annotations.

Parameters:
t - The type of the relation.
roles - The role names for each of the frame elements.
annotations - The annotations associated with the specified role names.
Method Detail

sortBy

public void sortBy(int s)

setType

public void setType(java.lang.String t)

getType

public java.lang.String getType()

size

public int size()
Returns the number of frame elements in this relation. This can be used in conjunction with getAnnotation to iterate through the frames of a relation.

Returns:
the number of frame elements in this relation.

indexOf

public int indexOf(java.lang.String role)
Returns the index of the first occurance of the specified role name.

Parameters:
role - The role name being searched for.
Returns:
The index of the first occurance of the specified role name.

indexOf

public int indexOf(Annotation ann)
Returns the index of the first occurance of the specified annotation

Parameters:
ann - The annotation being searched for.
Returns:
The index of the first occurance of the specified role name.

put

public void put(java.lang.String role,
                Annotation a)
Adds the specified role to the relation frame and associates it with the specified annotation. If the role alread exists a new role with the same name is created. This may modify the order of the elements in the frame.

Parameters:
role - The role name for the new frame element.
a - The annotation associated with the new frame element.

put

public Annotation put(int position,
                      Annotation a)
Puts the specified annotation at the specified position in the frame and returns the annotation which previously held that position.

Parameters:
position - The position in the frame where the annotation will be placed.
a - The annotation to be placed at the specified position.
Returns:
the annotation which previously held specified position.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range.

getRole

public java.lang.String getRole(int position)
Returns the role name for the specified position in the relation's frame.

Parameters:
position - The position in the frame.
Returns:
The annotation at the specified position in the frame.

getRole

public java.lang.String getRole(Annotation argument)
Returns the role name for the specified position in the relation's frame.

Parameters:
argument - The argument in the frame.
Returns:
The name of the role of the argument

getAnnotation

public Annotation getAnnotation(int position)

getArgument

public Argument getArgument(int position)

getArgument

public Argument getArgument(Annotation a)

get

public Annotation[] get(java.lang.String role)
Returns each annotation in this relation whose role name matches the specified role name.

Parameters:
role - The role name to be search for.
Returns:
An array of each of the annotations associated with the specified role name or a 0-sized array if no frame element's role name matches the specified role name.

contains

public boolean contains(Annotation a)

contains

public boolean contains(java.lang.String r)

renameRole

public void renameRole(java.lang.String oldr,
                       java.lang.String newr)
Renames the each instance of the specified old role name to the new role name.

Parameters:
oldr - The old role name.
newr - The new role name.

removeRole

public Annotation removeRole(java.lang.String role)
Removes each instance of the specified role name.

Parameters:
role - The role name to remove.
Returns:
The annotation associated with the role that was just removed or null if an element with a the specified role name was not in the frame.

remove

public Annotation remove(Annotation annotation)
Removes the specified annotation from this relation.

Parameters:
annotation - The annotation to be removed.
Returns:
The annotation that has been remove or null if the annotation could not be removed.

setAnchor

public void setAnchor(java.lang.String r)

setAnchor

public void setAnchor(Annotation a)

getAnchor

public Annotation getAnchor()

setFeature

public void setFeature(java.lang.String k,
                       java.lang.String v)
Overrides:
setFeature in class FeatureMap

clear

public void clear()

rolesIterator

public java.util.Iterator rolesIterator()

annotationsIterator

public java.util.Iterator annotationsIterator()

toString

public java.lang.String toString()


Copyright © 2004 Thomas Morton and Jeremy LaCivita. All Rights Reserved.