org.apache.ctakes.utils.xcas_comparison
Class XcasAnnotation

java.lang.Object
  extended by org.apache.ctakes.utils.xcas_comparison.XcasAnnotation
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<XcasAnnotation>

public class XcasAnnotation
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable<XcasAnnotation>

An XcasAnnotation object represents an element under the CAS tag in an XCAS file. It provides members and methods to store and access its type, attributes,and references.

Note: this class has a natural ordering that is inconsistent with equals. It is strongly recommended that the use of compareTo(XcasAnnotation) be strictly limited to the purpose of an orderly display of multiple objects.

Author:
Mayo Clinic

Field Summary
protected  java.util.Hashtable<java.lang.String,java.lang.String> attributes
           
protected  java.util.Hashtable<java.lang.String,org.apache.ctakes.utils.xcas_comparison.XcasAnnotation.MyVector> references
           
protected  java.util.Hashtable<java.lang.String,java.util.Vector<java.lang.Integer>> refIntArrays
           
protected  java.lang.String type
           
 
Constructor Summary
XcasAnnotation()
          Default constructor.
XcasAnnotation(java.lang.String t)
          Constructs an object with the specified type.
 
Method Summary
 java.lang.String allFieldsValues()
          Returns a string representation of all the attributes and references.
 java.lang.Object clone()
          Recursive, deep copy of this object, including attributes and references.
 int compareTo(XcasAnnotation o)
          Determines the order of this and the specified XcasAnnotation.
 java.lang.String description()
          Returns a String representation of this object, including its type, and all attributes and references.
 boolean equals(java.lang.Object obj)
          Determines whether the specified object equals to this one.
 java.lang.String getAttribute(java.lang.String name)
          Returns the value of the specified attribute.
 java.util.Vector<XcasAnnotation> getReference(java.lang.String name)
          Returns the referenced XcasAnnotations of the specified attribute.
 java.lang.String getType()
           
 void insertAttribute(java.lang.String k, java.lang.String v)
          Inserts an (attribute, value) pair to this XcasAnnotation.
 void insertIntReference(java.lang.String k, int[] a)
           
 void insertReference(java.lang.String k, XcasAnnotation a)
           
 void setType(java.lang.String t)
          Sets the type name of this annotation.
 XcasAnnotation shallowCopy()
          Clones this object, its attributes, and reference keys.
 java.lang.String shortType()
          Returns a short description of this XcasAnnotation's type, specifically, the last segment as separated by dots.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected java.lang.String type

attributes

protected java.util.Hashtable<java.lang.String,java.lang.String> attributes

references

protected java.util.Hashtable<java.lang.String,org.apache.ctakes.utils.xcas_comparison.XcasAnnotation.MyVector> references

refIntArrays

protected java.util.Hashtable<java.lang.String,java.util.Vector<java.lang.Integer>> refIntArrays
Constructor Detail

XcasAnnotation

public XcasAnnotation()
Default constructor. Its type is initialized to empty.


XcasAnnotation

public XcasAnnotation(java.lang.String t)
Constructs an object with the specified type.

Parameters:
t - Type of the XcasAnnotation object to be created.
Method Detail

setType

public void setType(java.lang.String t)
Sets the type name of this annotation.

Parameters:
t - Type to be set.

insertAttribute

public void insertAttribute(java.lang.String k,
                            java.lang.String v)
Inserts an (attribute, value) pair to this XcasAnnotation.

Parameters:
k - Name of the attribute.
v - Value of the attribute.

insertReference

public void insertReference(java.lang.String k,
                            XcasAnnotation a)

insertIntReference

public void insertIntReference(java.lang.String k,
                               int[] a)

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Returns the value of the specified attribute.

Parameters:
name - Name of the attribute.
Returns:
Value of the specified attribute.

getReference

public java.util.Vector<XcasAnnotation> getReference(java.lang.String name)
Returns the referenced XcasAnnotations of the specified attribute.

Parameters:
name - Name of an attribute that references to other XcasAnnotation.
Returns:
A HashSet of referenced objects.

equals

public boolean equals(java.lang.Object obj)
Determines whether the specified object equals to this one. Specifically, an XcasAnnotation a equals to another one o if and only if o is also an XcasAnnotation object and a.type.equals(o.type) && a.attributes.equals(o.attributes) && a.references.equals(o.references).

Overrides:
equals in class java.lang.Object
Parameters:
obj - An object to compare with this one.
Returns:
true if the specified object equals this one, false otherwise.

getType

public java.lang.String getType()

shortType

public java.lang.String shortType()
Returns a short description of this XcasAnnotation's type, specifically, the last segment as separated by dots.

Returns:
A short type name.

allFieldsValues

public java.lang.String allFieldsValues()
Returns a string representation of all the attributes and references. Some long values are shortened to ellipses.

Returns:
A string containing all attributes, references and their values.

description

public java.lang.String description()
Returns a String representation of this object, including its type, and all attributes and references. Named such so as not to override the default much shorter String representation

Returns:
A string containing the type and all attributes, references information.

clone

public java.lang.Object clone()
Recursive, deep copy of this object, including attributes and references.

Overrides:
clone in class java.lang.Object

shallowCopy

public final XcasAnnotation shallowCopy()
Clones this object, its attributes, and reference keys.

Returns:
A shallow copy of this object.

compareTo

public int compareTo(XcasAnnotation o)
Determines the order of this and the specified XcasAnnotation. Note: It is strongly recommended that the use of this method be strictly limited to the purpose of an orderly display of multiple objects. To determine the equality of two objects, use equals(Object).

Specified by:
compareTo in interface java.lang.Comparable<XcasAnnotation>
See Also:
equals(Object)