GATE
Version 3.1-2270

gate.annotation
Class AnnotationImpl

java.lang.Object
  extended by gate.util.AbstractFeatureBearer
      extended by gate.annotation.AnnotationImpl
All Implemented Interfaces:
Annotation, SimpleAnnotation, FeatureBearer, IdBearer, Serializable, Comparable

public class AnnotationImpl
extends AbstractFeatureBearer
implements Annotation, FeatureBearer, Comparable

Provides an implementation for the interface gate.Annotation

See Also:
Serialized Form

Field Summary
protected  Node end
          The end node
protected  gate.annotation.AnnotationImpl.EventsHandler eventHandler
          The listener for the events coming from the features.
protected  Node start
          The start node
 
Fields inherited from class gate.util.AbstractFeatureBearer
features
 
Constructor Summary
protected AnnotationImpl(Integer id, Node start, Node end, String type, FeatureMap features)
          Constructor.
 
Method Summary
 void addAnnotationListener(AnnotationListener l)
          Adds an annotation listener
 boolean coextensive(Annotation anAnnot)
          Two Annotation are coextensive if their offsets are the same.
 int compareTo(Object o)
          Ordering
 boolean equals(Object obj)
          Returns true if two annotation are Equals.
protected  void fireAnnotationUpdated(AnnotationEvent e)
           
 Node getEndNode()
          The end node.
 Integer getId()
          The ID of the annotation.
 Node getStartNode()
          The start node.
 String getType()
          The type of the annotation (corresponds to TIPSTER "name").
 int hashCode()
          When equals called on two annotations returns true, is REQUIRED that the value hashCode for each annotation to be the same.
 boolean isCompatible(Annotation anAnnot)
          This verifies if this annotation is compatible with another one.
 boolean isCompatible(Annotation anAnnot, Set aFeatureNamesSet)
          This verifies if this annotation is compatible with another one, given a set with certain keys.
 boolean isPartiallyCompatible(Annotation anAnnot)
          This method verifies if two annotation and are partially compatible.
 boolean isPartiallyCompatible(Annotation anAnnot, Set aFeatureNamesSet)
          This method verifies if two annotation and are partially compatible, given a set with certain keys.
 boolean overlaps(Annotation aAnnot)
          This method tells if this overlaps aAnnot.
 void removeAnnotationListener(AnnotationListener l)
          Removes an annotation listener
 void setFeatures(FeatureMap features)
          Set the feature set.
 String toString()
          String representation of hte annotation
 
Methods inherited from class gate.util.AbstractFeatureBearer
getFeatures
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures
 

Field Detail

eventHandler

protected gate.annotation.AnnotationImpl.EventsHandler eventHandler
The listener for the events coming from the features.


start

protected Node start
The start node


end

protected Node end
The end node

Constructor Detail

AnnotationImpl

protected AnnotationImpl(Integer id,
                         Node start,
                         Node end,
                         String type,
                         FeatureMap features)
Constructor. Package access - annotations have to be constructed via AnnotationSets.

Parameters:
id - The id of the new annotation;
start - The node from where the annotation will depart;
end - The node where trhe annotation ends;
type - The type of the new annotation;
features - The features of the annotation.
Method Detail

getId

public Integer getId()
The ID of the annotation.

Specified by:
getId in interface IdBearer

getType

public String getType()
The type of the annotation (corresponds to TIPSTER "name").

Specified by:
getType in interface SimpleAnnotation

getStartNode

public Node getStartNode()
The start node.

Specified by:
getStartNode in interface SimpleAnnotation

getEndNode

public Node getEndNode()
The end node.

Specified by:
getEndNode in interface SimpleAnnotation

toString

public String toString()
String representation of hte annotation

Overrides:
toString in class Object

compareTo

public int compareTo(Object o)
              throws ClassCastException
Ordering

Specified by:
compareTo in interface SimpleAnnotation
Specified by:
compareTo in interface Comparable
Throws:
ClassCastException

hashCode

public int hashCode()
When equals called on two annotations returns true, is REQUIRED that the value hashCode for each annotation to be the same. It is not required that when equals return false, the values to be different. For speed, it would be beneficial to happen that way.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Returns true if two annotation are Equals. Two Annotation are equals if their offsets, types, id and features are the same.

Overrides:
equals in class Object

setFeatures

public void setFeatures(FeatureMap features)
Set the feature set. Overriden from the implementation in AbstractFeatureBearer because it needs to fire events

Specified by:
setFeatures in interface FeatureBearer
Overrides:
setFeatures in class AbstractFeatureBearer

isCompatible

public boolean isCompatible(Annotation anAnnot)
This verifies if this annotation is compatible with another one. Compatible means that they hit the same possition and the FeatureMap of this is incuded into aAnnot FeatureMap.

Specified by:
isCompatible in interface Annotation
Parameters:
anAnnot - a gate Annotation. If anAnnotation is null then false is returned.
Returns:
true if aAnnot is compatible with this and false otherwise.

isCompatible

public boolean isCompatible(Annotation anAnnot,
                            Set aFeatureNamesSet)
This verifies if this annotation is compatible with another one, given a set with certain keys. In this case, compatible means that they hit the same possition and those keys from this's FeatureMap intersected with aFeatureNamesSet are incuded together with their values into the aAnnot's FeatureMap.

Specified by:
isCompatible in interface Annotation
Parameters:
anAnnot - a gate Annotation. If param is null, it will return false.
aFeatureNamesSet - is a set containing certian key that will be intersected with this's FeatureMap's keys.If param is null then isCompatible(Annotation) will be called.
Returns:
true if aAnnot is compatible with this and false otherwise.

isPartiallyCompatible

public boolean isPartiallyCompatible(Annotation anAnnot)
This method verifies if two annotation and are partially compatible. Partially compatible means that they overlap and the FeatureMap of this is incuded into FeatureMap of aAnnot.

Specified by:
isPartiallyCompatible in interface Annotation
Parameters:
anAnnot - a gate Annotation.
Returns:
true if this is partially compatible with anAnnot and false otherwise.

isPartiallyCompatible

public boolean isPartiallyCompatible(Annotation anAnnot,
                                     Set aFeatureNamesSet)
This method verifies if two annotation and are partially compatible, given a set with certain keys. In this case, partially compatible means that they overlap and those keys from this's FeatureMap intersected with aFeatureNamesSet are incuded together with their values into the aAnnot's FeatureMap.

Specified by:
isPartiallyCompatible in interface Annotation
Parameters:
anAnnot - a gate Annotation. If param is null, the method will return false.
aFeatureNamesSet - is a set containing certian key that will be intersected with this's FeatureMap's keys.If param is null then isPartiallyCompatible(Annotation) will be called.
Returns:
true if this is partially compatible with aAnnot and false otherwise.

coextensive

public boolean coextensive(Annotation anAnnot)
Two Annotation are coextensive if their offsets are the same.

Specified by:
coextensive in interface Annotation
Parameters:
anAnnot - A Gate annotation.
Returns:
true if two annotation hit the same possition and false otherwise

overlaps

public boolean overlaps(Annotation aAnnot)
This method tells if this overlaps aAnnot.

Specified by:
overlaps in interface Annotation
Parameters:
aAnnot - a gate Annotation.
Returns:
true if they overlap and false false if they don't.

removeAnnotationListener

public void removeAnnotationListener(AnnotationListener l)
Removes an annotation listener

Specified by:
removeAnnotationListener in interface Annotation

addAnnotationListener

public void addAnnotationListener(AnnotationListener l)
Adds an annotation listener

Specified by:
addAnnotationListener in interface Annotation

fireAnnotationUpdated

protected void fireAnnotationUpdated(AnnotationEvent e)
Parameters:
e -

GATE
Version 3.1-2270