biz.c24.io.api.presentation
Class SAXSink

java.lang.Object
  extended by biz.c24.io.api.presentation.Sink
      extended by biz.c24.io.api.presentation.SAXSink
All Implemented Interfaces:
Serializable, Cloneable

public class SAXSink
extends Sink

A sink for generating XML from data objects.

A common usage of this class would be:

 SAXSink snk = new SAXSink();

 // The following is dependent on the actual SAX event source in use
 src.setContentHandler(saxEventSink.asContentHandler());

 src.writeObject(myObj);
 

Please note this class does not use the inherited Sink.getOutputStream() or Sink.getWriter() methods.

Note that this implementation is not synchronized. If multiple threads use an instance concurrently, it must be synchronized externally.

See Also:
Sink, Serialized Form

Constructor Summary
SAXSink()
          Constructs a new instance.
SAXSink(SAXSink clone)
          Constructs a new instance cloned from clone.
 
Method Summary
 Object clone()
           
 DecimalFormat getNumberFormat()
          Returns the decimal format object used to format numbers into Strings.
 boolean isWriteOptionalDefaultValues()
          Returns whether optional default element and attribute values will be produced.
 boolean isWriteOptionalFixedValues()
          Returns whether optional fixed element and attribute values will be produced.
 void setContentHandler(ContentHandler contentHandler)
          Sets the content handler to which SAX events with be sent.
 void setLexicalHandler(LexicalHandler lexicalHandler)
          Sets the lexical handler to which SAX events with be sent.
 void setNumberFormat(DecimalFormat numberFormat)
          Sets the decimal format object used to format numbers into Strings.
 void setWriteOptionalDefaultValues(boolean writeOptionalDefaultValues)
          Sets whether optional default element and attribute values will be produced.
 void setWriteOptionalFixedValues(boolean writeOptionalFixedValues)
          Sets whether optional fixed element and attribute values will be produced.
 void writeObject(ComplexDataObject obj)
          Writes an object to the writer or output stream that has been set.
 
Methods inherited from class biz.c24.io.api.presentation.Sink
checkInit, clearBatchIterators, getEncoding, getOutputStream, getWriter, registerBatchIterator, setEncoding, setOutputStream, setWriter, stream, unregisterBatchIterator, writer
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXSink

public SAXSink()
Constructs a new instance.


SAXSink

public SAXSink(SAXSink clone)
Constructs a new instance cloned from clone.

Parameters:
clone - The instance to clone.
Method Detail

setContentHandler

public void setContentHandler(ContentHandler contentHandler)
Sets the content handler to which SAX events with be sent.

The handler should be used with a SAX event sink - a consumer of SAX events (or possibly a SAXSource).

Parameters:
contentHandler - The content handler.

setLexicalHandler

public void setLexicalHandler(LexicalHandler lexicalHandler)
Sets the lexical handler to which SAX events with be sent.

The handler should be used with a SAX event sink - a consumer of SAX events (or possibly a SAXSource).

Parameters:
lexicalHandler - The lexical handler.

isWriteOptionalDefaultValues

public boolean isWriteOptionalDefaultValues()
Returns whether optional default element and attribute values will be produced. The default value is false.

Returns:
Whether optional default values be produced.

setWriteOptionalDefaultValues

public void setWriteOptionalDefaultValues(boolean writeOptionalDefaultValues)
Sets whether optional default element and attribute values will be produced.

Parameters:
writeOptionalDefaultValues - The new value.

isWriteOptionalFixedValues

public boolean isWriteOptionalFixedValues()
Returns whether optional fixed element and attribute values will be produced. The default value is false.

Returns:
Whether optional default values be produced.

setWriteOptionalFixedValues

public void setWriteOptionalFixedValues(boolean writeOptionalFixedValues)
Sets whether optional fixed element and attribute values will be produced.

Parameters:
writeOptionalFixedValues - The new value.

getNumberFormat

public DecimalFormat getNumberFormat()
Returns the decimal format object used to format numbers into Strings.

Returns:
The number format, or null if the format has not been set up explicitly.

setNumberFormat

public void setNumberFormat(DecimalFormat numberFormat)
Sets the decimal format object used to format numbers into Strings.
It is the users responsibility when settings this format to ensure it represents valid XML. Using a comma as a decimal separator will, for example, break this contract and cause invalid XML to be created.

Parameters:
numberFormat - The new format to use, or null to use the default.

writeObject

public void writeObject(ComplexDataObject obj)
                 throws IOException
Description copied from class: Sink
Writes an object to the writer or output stream that has been set.

Specified by:
writeObject in class Sink
Parameters:
obj - The object to be written.
Throws:
IOException - If the complete object could not be written for any reason.

clone

public Object clone()
Specified by:
clone in class Sink


C24 Technologies © 2002-2012: All Rights Reserved.