|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.languagecomputer.api.text.DocumentXML
public class DocumentXML
Handles XML conversion for Document
s. Designed to be capable of
handling different Document
versions. The XML version number
does not depend on the API version number.
Field Summary | |
---|---|
static String |
CURRENT_VERSION
|
Constructor Summary | |
---|---|
DocumentXML()
Creates a new DocumentXML that writes using the current
Document XML version. |
|
DocumentXML(String version)
Creates a new DocumentXML that writes using the given
version. |
Method Summary | |
---|---|
void |
marshal(Object toMarshal,
Writer writer)
Marshalls the Object using a JAXB Marshaller . |
Collection<Text> |
readAnnotations(Reader reader,
Document document)
Reads the XML into a new Collection of Text s and adds
any services to the Document 's service list. |
Document |
readDocument(Reader reader)
Reads the XML into a new Document . |
List<Document> |
readDocuments(Reader reader)
Reads the XML into a new List of Document . |
Object |
unmarshal(Reader reader)
Unmarshalls the Object using a JAXB Unmarshaller . |
void |
writeAnnotations(Collection<? extends Text> annotations,
Collection<String> services,
Writer writer)
Writes the given Text objects (just annotations, cannot contain any
Document s) to the given Writer . |
void |
writeDocument(Document document,
Writer writer)
Writes the given Document to XML in the given Writer . |
void |
writeDocuments(List<Document> documents,
Writer writer)
Writes the given Document s to XML in the given Writer . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CURRENT_VERSION
Constructor Detail |
---|
public DocumentXML()
DocumentXML
that writes using the current
Document XML version. Is capable of reading all known versions.
CURRENT_VERSION
public DocumentXML(String version)
DocumentXML
that writes using the given
version. Is capable of reading all known versions.
version
- The version number to use for writing/reading. Using old
versions for writing is not guaranteed.Method Detail |
---|
public void writeDocuments(List<Document> documents, Writer writer) throws IOException
Document
s to XML in the given Writer
.
Does not close the Writer
.
documents
- Document
s to serialize to XML.writer
- Writer
to write the XML to.
IllegalStateException
- If the version number is unknown.
IOException
- If there is a problem writing to XML.public void writeDocument(Document document, Writer writer) throws IOException
Document
to XML in the given Writer
.
Does not close the Writer
.
document
- Document
to serialize to XML.writer
- Writer
to write the XML to.
IllegalStateException
- If the version number is unknown.
IOException
- If there is a problem writing to XML.public void writeAnnotations(Collection<? extends Text> annotations, Collection<String> services, Writer writer) throws IOException
Text
objects (just annotations, cannot contain any
Document
s) to the given Writer
. Does not close the
Writer
.
annotations
- Collection
of Text
annotations to
serialize to XML.services
- The services that the annotations come from.writer
- Writer
to write the XML to.
IllegalArgumentException
- If any of the annotations is a
Document
.
IOException
- If there is a problem writing to XML.public List<Document> readDocuments(Reader reader) throws IOException
List
of Document
.
reader
- Reader
to read the XML from.
Document
s from the XML.
IllegalArgumentException
- If the Document
s are an unknown
version or are un-readable.
IOException
- If there is a problem reading the XML.public Document readDocument(Reader reader) throws IOException
Document
.
reader
- Reader
to read the XML from.
Document
from the XML.
IllegalArgumentException
- If the Document
is an unknown
version or is un-readable.
IOException
- If there is a problem reading the XML.public Collection<Text> readAnnotations(Reader reader, Document document) throws IOException
Collection
of Text
s and adds
any services to the Document
's service list. The returned
Text
s have no Document
, so it is highly recommended
that the caller sets the Document
upon reading.
Note: If the document is a DefaultDocument
, then
the annotations will be added to it, otherwise they must be added
explicitly.
reader
- Reader
to read the XML from.
Collection
of Text
s from the XML.
IllegalArgumentException
- If the Document
is an unknown
version or is un-readable.
IOException
- If there is a problem reading the XML.public void marshal(Object toMarshal, Writer writer) throws IOException
Object
using a JAXB Marshaller
.
toMarshal
- The Object
to serialize to XML.writer
- The Writer
to write the XML to.
IOException
- Wrapper for an JAXBException that occurs during the
serialization.public Object unmarshal(Reader reader) throws IOException
Object
using a JAXB Unmarshaller
.
reader
- The Reader
to read the XML from.
IOException
- Wrapper for an JAXBException that occurs during the
serialization.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |