org.regenstrief.xhl7
Class HL7XMLWriter

java.lang.Object
  extended byorg.regenstrief.xhl7.HL7XMLWriter
All Implemented Interfaces:
org.xml.sax.ContentHandler, HL7XMLLiterate, XMLWriter

public class HL7XMLWriter
extends java.lang.Object
implements org.xml.sax.ContentHandler, HL7XMLLiterate, XMLWriter

A SAX ContentHandler that produces traditionally encoded HL7 messages from XML/SAX events. Message is sent to the OutputStream set for the Writer.

This ContentHandler is also its own facotry.


Field Summary
 
Fields inherited from interface org.regenstrief.xhl7.HL7XMLLiterate
ATT_DEL_COMPONENT, ATT_DEL_ESCAPE, ATT_DEL_FIELD, ATT_DEL_REPEAT, ATT_DEL_SUBCOMPONENT, CDATA, DEFAULT_DELIMITERS, DELIMITER_ESCAPES, N_DEL_COMPONENT, N_DEL_ESCAPE, N_DEL_FIELD, N_DEL_REPEAT, N_DEL_SUBCOMPONENT, NAMESPACE_URI, NUMBER_OF_DELIMITERS, TAG_COMPONENT, TAG_ESCAPE, TAG_FIELD, TAG_REPEAT, TAG_ROOT, TAG_SUBCOMPONENT
 
Constructor Summary
HL7XMLWriter()
          Default constructor used when instantiated by reflection.
HL7XMLWriter(java.io.OutputStream outputStream)
          Convenient constructor that calls setOutputStream.
 
Method Summary
 void characters(char[] ch, int start, int length)
          For the ContentHandler interface.
 void endDocument()
          For the ContentHandler interface - a no-op.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          For the ContentHandler interface.
 void endPrefixMapping(java.lang.String prefix)
          For the ContentHandler interface - a no-op.
 org.xml.sax.ContentHandler getContentHandler()
          Get the content handler.
 void ignorableWhitespace(char[] ch, int start, int length)
          For the ContentHandler interface - a no-op.
 void processingInstruction(java.lang.String target, java.lang.String data)
          For the ContentHandler interface - a no-op.
 void setDocumentLocator(org.xml.sax.Locator locator)
          For the ContentHandler interface - a no-op.
 void setOutputStream(java.io.OutputStream outputStream)
          Set the output stream destination.
 void skippedEntity(java.lang.String name)
          For the ContentHandler interface - a no-op.
 void startDocument()
          For the ContentHandler interface - a no-op.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          For the ContentHandler interface.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          For the ContentHandler interface - a no-op.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HL7XMLWriter

public HL7XMLWriter()
Default constructor used when instantiated by reflection.


HL7XMLWriter

public HL7XMLWriter(java.io.OutputStream outputStream)
Convenient constructor that calls setOutputStream.

Parameters:
outputStream - where the serialized HL7 goes.
Method Detail

setOutputStream

public void setOutputStream(java.io.OutputStream outputStream)
Set the output stream destination.

Specified by:
setOutputStream in interface XMLWriter
Parameters:
outputStream - where the serialized HL7 goes.

getContentHandler

public org.xml.sax.ContentHandler getContentHandler()
Get the content handler. This HL7XMLWriter is itself a content handler, so it returns itself. But the XMLWriter interface is written such that the content handler could be a helper object.

If no outputStream was set previously, an output stream to standard out is used instead.

Specified by:
getContentHandler in interface XMLWriter
Returns:
itself as a content handler.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
For the ContentHandler interface.

Specified by:
characters in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
For the ContentHandler interface.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
For the ContentHandler interface.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startDocument

public void startDocument()
For the ContentHandler interface - a no-op.

Specified by:
startDocument in interface org.xml.sax.ContentHandler

endDocument

public void endDocument()
For the ContentHandler interface - a no-op.

Specified by:
endDocument in interface org.xml.sax.ContentHandler

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
For the ContentHandler interface - a no-op.

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
For the ContentHandler interface - a no-op.

Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
For the ContentHandler interface - a no-op.

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
For the ContentHandler interface - a no-op.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
For the ContentHandler interface - a no-op.

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler

skippedEntity

public void skippedEntity(java.lang.String name)
For the ContentHandler interface - a no-op.

Specified by:
skippedEntity in interface org.xml.sax.ContentHandler