public final class ProcessingResult extends Object
getDocuments()
)) and the created clusters (getClusters()
).Modifier and Type | Method and Description |
---|---|
static ProcessingResult |
deserialize(CharSequence input)
Deserialize from an input stream of characters.
|
static ProcessingResult |
deserialize(InputStream input)
Deserializes a
ProcessingResult from an XML stream. |
<T> T |
getAttribute(String key)
Returns a specific attribute of this result set.
|
Map<String,Object> |
getAttributes()
Returns attributes fed-in and collected during processing.
|
List<Cluster> |
getClusters()
Returns the clusters that have been created during processing.
|
List<Document> |
getDocuments()
Returns the documents that have been processed.
|
String |
serialize()
Serializes this
ProcessingResult to an XML string. |
void |
serialize(OutputStream stream)
Serializes this
ProcessingResult to an XML stream. |
void |
serialize(OutputStream stream,
boolean saveDocuments,
boolean saveClusters)
Serializes this
ProcessingResult to a byte stream. |
void |
serialize(OutputStream stream,
boolean saveDocuments,
boolean saveClusters,
boolean saveOtherAttributes)
Serializes this
ProcessingResult to a byte stream. |
void |
serializeJson(Writer writer)
Serializes this processing result as JSON to the provided
writer . |
void |
serializeJson(Writer writer,
String callback)
Serializes this processing result as JSON to the provided
writer . |
void |
serializeJson(Writer writer,
String callback,
boolean saveDocuments,
boolean saveClusters)
Serializes this processing result as JSON to the provided
writer . |
void |
serializeJson(Writer writer,
String callback,
boolean indent,
boolean saveDocuments,
boolean saveClusters)
Serializes this processing result as JSON to the provided
writer . |
void |
serializeJson(Writer writer,
String callback,
boolean indent,
boolean saveDocuments,
boolean saveClusters,
boolean saveOtherAttributes)
Serializes this processing result as JSON to the provided
writer . |
public Map<String,Object> getAttributes()
public <T> T getAttribute(String key)
getAttributes()
and then getting the required attribute from the
map.key
- key of the attribute to returnpublic List<Document> getDocuments()
null
if no documents are
present in the result.public List<Cluster> getClusters()
null
if no clusters were
present in the result.public String serialize()
ProcessingResult
to an XML string.public void serialize(OutputStream stream) throws Exception
ProcessingResult
to an XML stream. The output includes all
documents, clusters and other attributes.
This method is not thread-safe, external synchronization must be applied if needed.
stream
- the stream to serialize this ProcessingResult
to. The stream
will not be closed.Exception
- in case of any problems with serializationpublic void serialize(OutputStream stream, boolean saveDocuments, boolean saveClusters) throws Exception
ProcessingResult
to a byte stream. Documents and clusters
can be included or skipped in the output as requested. Other attributes are always
included.
This method is not thread-safe, external synchronization must be applied if needed.
stream
- the stream to serialize this ProcessingResult
to. The stream
will not be closed.saveDocuments
- if false
, documents will not be serialized.
Notice that when deserializing XML containing clusters but not
documents, document references in Cluster.getDocuments()
will
not be restored.saveClusters
- if false
, clusters will not be serializedException
- in case of any problems with serializationpublic void serialize(OutputStream stream, boolean saveDocuments, boolean saveClusters, boolean saveOtherAttributes) throws Exception
ProcessingResult
to a byte stream. Documents, clusters and
other attributes can be included or skipped in the output as requested.
This method is not thread-safe, external synchronization must be applied if needed.
stream
- the stream to serialize this ProcessingResult
to. The stream
will not be closed.saveDocuments
- if false
, documents will not be serialized.
Notice that when deserializing XML containing clusters but not
documents, document references in Cluster.getDocuments()
will
not be restored.saveClusters
- if false
, clusters will not be serializedsaveOtherAttributes
- if false
, other attributes will not be
serializedException
- in case of any problems with serializationpublic static ProcessingResult deserialize(CharSequence input) throws Exception
Exception
public static ProcessingResult deserialize(InputStream input) throws Exception
ProcessingResult
from an XML stream.input
- the input XML stream to deserialize a ProcessingResult
from.
The stream will not be closed.ProcessingResult
Exception
- is case of any problems with deserializationpublic void serializeJson(Writer writer) throws IOException
writer
. The
output includes all documents, clusters and other attributes.
This method is not thread-safe, external synchronization must be applied if needed.
writer
- the writer to serialize this processing result to. The writer will
not be closed.IOException
- in case of any problems with serializationpublic void serializeJson(Writer writer, String callback) throws IOException
writer
. The
output includes all documents, clusters and other attributes.
This method is not thread-safe, external synchronization must be applied if needed.
writer
- the writer to serialize this processing result to. The writer will
not be closed.callback
- JavaScript function name in which to wrap the JSON response or
null
.IOException
- in case of any problems with serializationpublic void serializeJson(Writer writer, String callback, boolean saveDocuments, boolean saveClusters) throws IOException
writer
.
Documents and clusters can be included or skipped in the output as requested. Other
attributes are always included.
This method is not thread-safe, external synchronization must be applied if needed.
writer
- the writer to serialize this processing result to. The writer will
not be closed.callback
- JavaScript function name in which to wrap the JSON response or
null
.saveDocuments
- if false
, documents will not be serialized.saveClusters
- if false
, clusters will not be serializedIOException
- in case of any problems with serializationpublic void serializeJson(Writer writer, String callback, boolean indent, boolean saveDocuments, boolean saveClusters) throws IOException
writer
.
This method is not thread-safe, external synchronization must be applied if needed.
writer
- the writer to serialize this processing result to. The writer will
not be closed.callback
- JavaScript function name in which to wrap the JSON response or
null
.indent
- if true
, the output JSON will be pretty-printedsaveDocuments
- if false
, documents will not be serialized.saveClusters
- if false
, clusters will not be serializedIOException
- in case of any problems with serializationpublic void serializeJson(Writer writer, String callback, boolean indent, boolean saveDocuments, boolean saveClusters, boolean saveOtherAttributes) throws IOException
writer
.
Documents, clusters and other attributes can be included or skipped in the output
as requested.writer
- the writer to serialize this processing result to. The writer will
not be closed.callback
- JavaScript function name in which to wrap the JSON response or
null
.indent
- if true
, the output JSON will be pretty-printedsaveDocuments
- if false
, documents will not be serialized.saveClusters
- if false
, clusters will not be serializedsaveOtherAttributes
- if false
, other attributes will not be
serializedIOException
- in case of any problems with serialization