public class XcasFile
extends java.lang.Object
implements java.lang.Cloneable
XcasFile
wraps all XcasAnnotations
s
in it and also contains their position information in terms of
line and column numbers.Modifier and Type | Field and Description |
---|---|
protected java.util.Hashtable<java.lang.Integer,XcasAnnotation> |
annotations |
protected java.io.File |
f |
protected java.util.Hashtable<XcasAnnotation,java.lang.String> |
positions |
Constructor and Description |
---|
XcasFile()
Default constructor.
|
XcasFile(java.io.File f)
Constructs an
XcasFile with the specified name. |
XcasFile(java.lang.String f)
Constructs an
XcasFile with the specified name. |
Modifier and Type | Method and Description |
---|---|
void |
addAnnotation(int id,
XcasAnnotation a)
Inserts a new annotation with the specified internal
id
to this XcasFile . |
void |
addAnnotation(int id,
XcasAnnotation a,
int lineNum,
int colNum)
Inserts a new annotation, along with its position in the file,
to this
XcasFile object. |
void |
addAnnotation(int id,
XcasAnnotation a,
java.lang.String pos)
Inserts a new annotation, along with its position in the file,
to this
XcasFile object. |
java.util.LinkedList<XcasAnnotation> |
annotationsClone() |
java.lang.Object |
clone() |
boolean |
equals(java.lang.Object obj)
Checks whether the specified object has the same set of annotations.
|
java.util.Collection<XcasAnnotation> |
getAllAnnotations() |
XcasAnnotation |
getAnnotation(int id)
Returns the
XcasAnnotation object associated with
the specified internal id. |
java.lang.String |
getFileName() |
java.lang.String |
getPosition(XcasAnnotation a)
Returns the line and column numbers of the specified
XcasAnnotation . |
java.lang.String |
getPositionOther(XcasAnnotation a)
Finds an
XcasAnnotation with the same attributes as specified,
and returns its line and column numbers. |
java.lang.String |
getPositionOwn(int id)
Returns the line and column numbers of the
XcasAnnotation ,
specified by the original XCAS internal _id field. |
java.lang.String |
getPositionOwn(XcasAnnotation a)
Returns the line and column numbers of the specified
XcasAnnotation ,
which is included in this XcasFile object. |
java.lang.String |
getPositionSimilar(XcasAnnotation a)
Finds an
XcasAnnotation of the same type as specified, and
a same text span, then returns its line and column number. |
boolean |
hasAnnotation(int id)
Checks whether this XCAS file has an annotation with the specified id.
|
boolean |
hasAnnotation(XcasAnnotation a)
Checks whether this XCAS file has the specified
XcasAnnotation . |
static XcasFile |
process(java.lang.String f)
Creates a new
XcasFile object from the specified file. |
protected java.io.File f
protected java.util.Hashtable<java.lang.Integer,XcasAnnotation> annotations
protected java.util.Hashtable<XcasAnnotation,java.lang.String> positions
public XcasFile()
public XcasFile(java.lang.String f)
XcasFile
with the specified name.f
- File name.public XcasFile(java.io.File f)
XcasFile
with the specified name.f
- A File object.public static XcasFile process(java.lang.String f)
XcasFile
object from the specified file.
Avoid using this method if you plan to parse multiple files,
as this method creates an anonymous XcasProcessor
instance
each time called, which could be used to parse multiple files.f
- A string containing the XCAS file name.XcasFile
object.public void addAnnotation(int id, XcasAnnotation a)
id
to this XcasFile
.id
- UIMA CAS internal _id
.a
- An XcasAnnotation
object to add.addAnnotation(int, XcasAnnotation, String)
,
addAnnotation(int, XcasAnnotation, int, int)
public void addAnnotation(int id, XcasAnnotation a, java.lang.String pos)
XcasFile
object.id
- UIMA CAS internal _id
.a
- An XcasAnnotation
object to add.pos
- Line and column number of the specified annotation,
in the form of line_number:column_number
.public void addAnnotation(int id, XcasAnnotation a, int lineNum, int colNum)
XcasFile
object.id
- UIMA CAS internal _id
.a
- An XcasAnnotation
object to add.lineNum
- Line number of the specified annotation.colNum
- Column number of the specified annotation.public XcasAnnotation getAnnotation(int id)
XcasAnnotation
object associated with
the specified internal id.id
- UIMA CAS internal _id
.XcasAnnotation
with the specified id.public java.util.Collection<XcasAnnotation> getAllAnnotations()
public java.lang.String getFileName()
public java.lang.String getPositionOwn(XcasAnnotation a)
XcasAnnotation
,
which is included in this XcasFile
object.line_number:column_number
.getPositionOwn(int)
,
getPositionOther(XcasAnnotation)
public java.lang.String getPositionOwn(int id)
XcasAnnotation
,
specified by the original XCAS internal _id
field.id
- UIMA CAS internal _id
.line_number:column_number
.getPositionOwn(XcasAnnotation)
,
getPositionOther(XcasAnnotation)
public java.lang.String getPositionOther(XcasAnnotation a)
XcasAnnotation
with the same attributes as specified,
and returns its line and column numbers.line_number:column_number
.getPositionOwn(int)
,
getPositionOwn(XcasAnnotation)
public java.lang.String getPosition(XcasAnnotation a)
XcasAnnotation
.
Do not use this method if you know the specified XcasAnnotation
object is in this XcasFile
. Instead, use
getPositionOwn(XcasAnnotation)
, which is faster.
a
- Anline_number:column_number
.getPositionOwn(XcasAnnotation)
,
getPositionOther(XcasAnnotation)
public java.lang.String getPositionSimilar(XcasAnnotation a)
XcasAnnotation
of the same type as specified, and
a same text span, then returns its line and column number.a
- An XcasAnnotation
against which a similar
XcasAnnotation
in this XcasFile
is to be matched.line_number:column_number
.getPositionOther(XcasAnnotation)
public boolean hasAnnotation(int id)
id
- UIMA CAS internal _id
.true
if file has an annotation with the specified id,
false
otherwise.public boolean hasAnnotation(XcasAnnotation a)
XcasAnnotation
.
If there is an XcasAnnotation
object that has exactly the same
type, attributes, and references, return true
.a
- An XcasAnnotation
to check.true
if there is one XcasAnnotation
equals
the specified one, false
otherwise.XcasAnnotation.equals(Object)
public boolean equals(java.lang.Object obj)
XcasFile
object. If so, check whether
its annotation set is of the same size as in this XcasFile
, then check
whether these two sets are equal.equals
in class java.lang.Object
obj
- An object to compare to.true if the specified object is an XcasFile
object and
has a same set of XcasAnnotations
, false
otherwise.
public java.util.LinkedList<XcasAnnotation> annotationsClone()
public java.lang.Object clone()
clone
in class java.lang.Object