|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.languagecomputer.api.text.DefaultText com.languagecomputer.api.text.DefaultDocument
public class DefaultDocument
Default implementation of a Document
.
DefaultText
Field Summary |
---|
Fields inherited from interface com.languagecomputer.api.text.Document |
---|
TYPE |
Constructor Summary | |
---|---|
DefaultDocument()
Creates a new DefaultDocument . |
Method Summary | ||
---|---|---|
void |
addAnnotation(Text annotation)
Adds a Text to the Document . |
|
void |
addMetaData(String key,
String value)
Adds meta information about the Document using a key-value
pair. |
|
void |
addService(String serviceName)
Adds the serviceName to the list of Service s that have
been processed this Document . |
|
Collection<Text> |
getAllAnnotations()
Returns all the annotations on this Document . |
|
Map<String,Collection<String>> |
getAllMetaData()
Returns all the meta-data values attached to this Document . |
|
|
getAnnotations(AnnotationType<T> annType)
Returns all the annotations on this Document that correspond
to the given AnnotationType . |
|
Document |
getDocument()
Returns this DefaultDocument . |
|
String |
getDocumentID()
Returns the Document ID that identifies this Text . |
|
int |
getEndCharOffset()
Returns the (exclusive) end character offset for this Text
object within the (processed) Document . This offset does not
necessarily line up with the start character offset from the unprocessed
document/file. |
|
Collection<String> |
getMetaData(String key)
Returns the meta-data values for the given meta-data key. |
|
List<String> |
getServices()
Returns the names of the Service s that have processed this
Document . |
|
int |
getStartCharOffset()
Returns the start character offset for this Text object within
the (processed) Document . This offset does not necessarily line up
with the start character offset from the unprocessed document/file. |
|
void |
setAnnotationType(AnnotationType annType)
Not necessary: defaults to Document.TYPE . |
|
void |
setDocument(Document document)
Not allowed: getDocument() can only return this
DefaultDocument . |
|
void |
setDocumentID(String docID)
Sets the Document ID. |
|
void |
setEndCharOffset(int endCharOffset)
Not allowed: computed from DefaultText.getRawString() . |
|
void |
setStartCharOffset(int startCharOffset)
Not allowed: must be 0 (hard-coded). |
|
String |
toString()
Returns a String representation of a
DefaultDocument . |
Methods inherited from class com.languagecomputer.api.text.DefaultText |
---|
getAnnotationType, getCongruentAnnotations, getIntersectingAnnotations, getRawString, getSubAnnotations, getSuperAnnotations, setRawString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.languagecomputer.api.text.Text |
---|
getAnnotationType, getCongruentAnnotations, getIntersectingAnnotations, getRawString, getSubAnnotations, getSuperAnnotations |
Constructor Detail |
---|
public DefaultDocument()
DefaultDocument
.
Method Detail |
---|
public void setDocumentID(String docID)
Document
ID.
docID
- The document ID to use, cannot be null
.
IllegalArgumentException
- If docID is null
.Document.getDocumentID()
public String getDocumentID()
Document
ID that identifies this Text
.
getDocumentID
in interface Document
getDocumentID
in interface Text
getDocumentID
in class DefaultText
Document
that contains this
Text
.public void setDocument(Document document)
getDocument()
can only return this
DefaultDocument
.
setDocument
in class DefaultText
document
- (ignored)
UnsupportedOperationException
- Cannot be called.Text.getDocument()
public Document getDocument()
DefaultDocument
. Required for
Document
to extend Text
.
getDocument
in interface Text
getDocument
in class DefaultText
DefaultDocument
.public void addAnnotation(Text annotation)
Text
to the Document
. If the annotation
is a DefaultText
, then DefaultText.setDocument(com.languagecomputer.api.text.Document)
is
called with this DefaultDocument
.
addAnnotation
in interface Document
annotation
- The Text
annotation to add.Document.getAllAnnotations()
public Collection<Text> getAllAnnotations()
Document
.
getAllAnnotations
in interface Document
Collection
of all Text
objects that are
attached to this Document
. The annotations will be in a
semi-sorted order. This means that non-intersecting objects will be
sorted by their order in the document. No guarantee will be placed on
the order of intersecting objects.public <T extends Text> Collection<T> getAnnotations(AnnotationType<T> annType)
Document
that correspond
to the given AnnotationType
.
getAnnotations
in interface Document
T
- The Text
sub-class corresponding to the given
AnnotationType
.annType
- The AnnotationType
that all returned items will match.
Collection
of objects matching the given
AnnotationType
. The annotations will be in a semi-sorted
order. This means that non-intersecting objects will be sorted
by their order in the document. No guarantee will be placed on the
order of intersecting objects.public void addService(String serviceName)
Service
s that have
been processed this Document
. Services should not need to be
run more than once, so this allows the Document
to know which
services it has been processed by. See Service#getName
for the
convention on naming services.
addService
in interface Document
serviceName
- String
name for a Service
.Service#getName
,
Document.getServices()
public List<String> getServices()
Service
s that have processed this
Document
. Services should not need to be run more than once,
so they can check this list to prevent redundant work. See
Service#getName
for the convention on naming services.
getServices
in interface Document
List
of Service
names that have processed this
Document
.Service#getName
,
Document.addService(String)
public void addMetaData(String key, String value)
Document
using a key-value
pair. A Document
may have multiple values for the same key.
addMetaData
in interface Document
key
- The identifier for the meta-data.value
- The value for the corresponding meta-data key.Document.getMetaData(String)
,
Document.getAllMetaData()
public Collection<String> getMetaData(String key)
getMetaData
in interface Document
key
- The identifier for the meta-data.
Collection
of meta-data values that correspond to
the given key. Returns null
if the given
key has no values.Document.addMetaData(String,String)
,
Document.getAllMetaData()
public Map<String,Collection<String>> getAllMetaData()
Document
.
Note that meta-data may be used to provide information to the end user or
to share information about the document between Service
s.
Consumers of meta-data should therefore be mindful of how meta-data is used
in a particular use case.
getAllMetaData
in interface Document
Map
of every meta-data key to its corresponding
Collection
of meta-data values.Document.addMetaData(String,String)
,
Document.getMetaData(String)
public void setAnnotationType(AnnotationType annType)
Document.TYPE
.
setAnnotationType
in class DefaultText
annType
- AnnotationType
to use for this
DefaultDocument
.Text.getAnnotationType()
,
AnnotationType
public final void setStartCharOffset(int startCharOffset)
0
(hard-coded).
setStartCharOffset
in class DefaultText
startCharOffset
- (ignored)
UnsupportedOperationException
- Handled automatically.Text.getStartCharOffset()
public int getStartCharOffset()
Text
object within
the (processed) Document
. This offset does not necessarily line up
with the start character offset from the unprocessed document/file.
getStartCharOffset
in interface Text
getStartCharOffset
in class DefaultText
public final void setEndCharOffset(int endCharOffset)
DefaultText.getRawString()
.
setEndCharOffset
in class DefaultText
endCharOffset
- (ignored)
UnsupportedOperationException
- Handled automatically.Text.getEndCharOffset()
public int getEndCharOffset()
Text
object within the (processed) Document
. This offset does not
necessarily line up with the start character offset from the unprocessed
document/file.
getEndCharOffset
in interface Text
getEndCharOffset
in class DefaultText
public String toString()
String
representation of a
DefaultDocument
.
toString
in class DefaultText
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |