org.tm4j.topicmap.utils .TopicMapSerializer

Description

A subclass of HelperBase capable of serializing a TopicMap to an OutputStream. A typical usage pattern for instances of this class is this:

  • Construct an instance of TopicMapSerializer.
  • (optional) Register event listeners so you can deal with property changes. See below for a list of bound properties supported by this class. Changes to most of the properties supported by this class are vetoable, so you are able to register a VetoableChangeListener and provide for consistency or sanity checks.
  • (optional) Register a jakarta-commons Log to receive log messages.
  • (optional) Set properties using their setter methods. You can skip this step if you prefer to use the default property values.
  • Set the output stream using #setOutputStream(OutputStream). Alternatively, you may also use #setOutputFile(File) or #setOutputFile(String) to write directly to a file.
  • Set the topic map to be serialized using #setTopicMap(TopicMap).
  • Invoke #serialize() to perform the actual serialization. When serialization is complete, the output stream is flushed, but not closed.
  • (optional) Close the output stream using #closeOutputStream().
This class supports the following "bound" properties, changes to which are vetoable by registered java.beans.VetoableChangeListeners:
  • "topicMap" (TopicMap, read/write). The topic map to be serialized.
  • "outputStream" (OutputStream, read/write). The output stream to which the topic map is serialized.
  • "includeDoctype" (boolean, read/write). If true, the result document will contain a <!DOCTYPE> declaration, if false, that declaration is omitted. If false, no indentation is used. The default is true.
  • "systemId" (String, read/write). The System identifier to be used in the document type declaration of the output document. The default is the System ID for XTM 1.0. This property is ignored if "includeDoctype" is false.
  • "publicId" (String, read/write). The Public identifier to be used in the document type declaration of the output document. The default is the Public ID for XTM 1.0. This property is ignored if "includeDoctype" is false.
  • "encoding" (String, read/write). The output encoding to be used during serialization. The default is UTF-8.
  • "indentation" (int, read/write). The number of space characters used to indent the serialized output. The default is 2.
  • "logger" (org.apache.commons.logging.Log, read/write). The jakarta-commons log to receive logging messages. The default is null, which will cause any debugging output, except "fatal" messages, to be suppressed. This property is inherited from the superclass.
In addition to the above, the following non-vetoable property is defined for this class:
  • "serialized" (boolean, read-only). true if the result has been properly serialized, false otherwise. The default (prior to serialization) is false.

Inheritance Hierarchy

Field Summary
DEFAULT_ENCODING The default output encoding.
DEFAULT_INCLUDE_DOCTYPE The default setting for including a document type declaration in the output.
DEFAULT_INDENT The default setting for indenting the output.
DEFAULT_OUTPUT_STREAM The default serialization output stream.
XTM_PUBLIC_ID The XTM 1.0 system ID.
XTM_SYSTEM_ID The XTM 1.0 system ID.
Method Summary
void closeOutputStream()
A convenience method that closes the output stream.
java.lang.String getEncoding()
Retrieves the character encoding to be used when serializing.
void getIndentation()
Returns the indentation level of the serialized output.
java.io.OutputStream getOutputStream()
Retrieves the output stream to be used for serialization.
java.lang.String getPublicId()
Retrieves the PUBLIC identifier to be included in the serialized document's <!DOCTYPE> declaration.
java.lang.String getSystemId()
Retrieves the SYSTEM identifier to be included in the serialized document's <!DOCTYPE> declaration.
org.tm4j.topicmap.TopicMap getTopicMap()
Retrieves the TopicMap to be serialized.
void getWriteStubs()
void init()
Initializes the instance and sets appropriate default values for properties.
void isIncludingDoctype()
Determines whether the serialized output will contain a <!DOCTYPE> declaration.
void isSerialized()
Returns whether the instance has successfully completed the serialization process.
void serialize()
Performs the serialization of the merged topic map.
void setEncoding(java.lang.String newVal)
Sets the character encoding to be used when serializing.
void setIncludeDoctype(boolean newVal)
Configures the instance to include a <!DOCTYPE> declaration in the serialized output.
void setIndentation(int newVal)
Configures the instance to indent (pretty-print) the serialized output.
void setOutputFile(java.io.File file)
Configures the instance to use the specified output file for serialization.
void setOutputFile(java.lang.String path)
Configures the instance to use the file denoted by the specified path for serialization.
void setOutputStream(java.io.OutputStream newStream)
Sets the output stream to which the merged result is serialized.
void setPublicId(java.lang.String newVal)
Sets the PUBLIC identifier to be included in the serialized document's <!DOCTYPE> declaration.
void setSerialized(boolean newVal)
Sets the state of serialization.
void setSystemId(java.lang.String newVal)
Sets the SYSTEM identifier to be included in the serialized document's <!DOCTYPE> declaration.
void setTopicMap(org.tm4j.topicmap.TopicMap newTopicMap)
Sets the TopicMap to be serialized.
void setWriteStubs(boolean b)
Sets whether or not the serialization will include topics that have only a single subject indicator or only a subject address and no other properties.