com.openharbor.beck.write
Class FastXMLWriter

java.lang.Object
  extended byjava.io.Writer
      extended bycom.openharbor.beck.write.XMLWriter
          extended bycom.openharbor.beck.write.FastXMLWriter
Direct Known Subclasses:
DefaultXMLWriter

public class FastXMLWriter
extends XMLWriter

Output XML without line breaks or indentation (making it compact and fast to parse).


Nested Class Summary
 
Nested classes inherited from class com.openharbor.beck.write.XMLWriter
XMLWriter.MapKey
 
Field Summary
protected static int ATTRIBUTE
          writing attributes
protected  java.io.Writer attributeWriter
          writes PCDATA, replacing XML reserved characters with entity references.
protected static int CONTENT
          writing content
protected  java.io.Writer contentWriter
           
protected static int END
          wrote closing tag
protected  java.io.Writer out
          XML output stream
protected static int START
          wrote start of opening tag
protected  int state
          current state
 
Fields inherited from class com.openharbor.beck.write.XMLWriter
CYCLES, DECLARED_NAMESPACES, ELEMENT_NAME, prefixer, SOURCE, TEXT_IS_SIGNIFICANT, XSI, XSI_TYPE
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
FastXMLWriter(java.io.Writer out)
          Note that the XML is written to a character (not byte) stream.
 
Method Summary
 void attribute(XMLName name, java.lang.String value)
          Add an attribute to the current element.
protected  void beginContent()
           
protected  java.lang.String choosePrefix(java.lang.String namespace, java.util.Map declared)
           
 void close()
           
protected  void declareNamespace(java.lang.String prefix, java.lang.String namespaceURI)
           
 void documentType(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Write <!DOCTYPE sax...
 void endElement()
           
 void flush()
           
protected  void startElement(XMLName name)
           
 void write(char[] content, int off, int len)
          Add text content to the current element.
 void write(int content)
           
 void write(java.lang.String content)
           
 void write(java.lang.String content, int off, int len)
           
 void xmlHeader(java.lang.String encoding)
          Write <?xml version="1.0" sax...
 
Methods inherited from class com.openharbor.beck.write.XMLWriter
attributes, getDocumentState, getElementStack, getElementStackTop, namespace, namespace, newMapKey, prefixToNamespace, resolveNamespace, setDocumentState, startElement
 
Methods inherited from class java.io.Writer
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START

protected static final int START
wrote start of opening tag

See Also:
Constant Field Values

ATTRIBUTE

protected static final int ATTRIBUTE
writing attributes

See Also:
Constant Field Values

CONTENT

protected static final int CONTENT
writing content

See Also:
Constant Field Values

END

protected static final int END
wrote closing tag

See Also:
Constant Field Values

state

protected int state
current state


out

protected java.io.Writer out
XML output stream


attributeWriter

protected java.io.Writer attributeWriter
writes PCDATA, replacing XML reserved characters with entity references.


contentWriter

protected java.io.Writer contentWriter
Constructor Detail

FastXMLWriter

public FastXMLWriter(java.io.Writer out)
Note that the XML is written to a character (not byte) stream. If you encode the XML to a byte stream, take care to write an XML header that declares your chosen character encoding.

Parameters:
out - whither XML will be written
Method Detail

xmlHeader

public void xmlHeader(java.lang.String encoding)
               throws java.io.IOException
Write <?xml version="1.0" sax...

Throws:
java.io.IOException

documentType

public void documentType(java.lang.String name,
                         java.lang.String publicId,
                         java.lang.String systemId)
                  throws java.io.IOException
Write <!DOCTYPE sax...

Parameters:
name - document type name
publicId - public ID, or null to omit the public ID declaration.
Throws:
java.io.IOException

startElement

protected void startElement(XMLName name)
                     throws java.io.IOException
Overrides:
startElement in class XMLWriter
Throws:
java.io.IOException

declareNamespace

protected void declareNamespace(java.lang.String prefix,
                                java.lang.String namespaceURI)
                         throws java.io.IOException
Specified by:
declareNamespace in class XMLWriter
Throws:
java.io.IOException

choosePrefix

protected java.lang.String choosePrefix(java.lang.String namespace,
                                        java.util.Map declared)
                                 throws java.io.IOException
Overrides:
choosePrefix in class XMLWriter
Throws:
java.io.IOException

attribute

public void attribute(XMLName name,
                      java.lang.String value)
               throws java.io.IOException
Description copied from class: XMLWriter
Add an attribute to the current element. If it's an xsi:type attribute, set the Type of the current element accordingly.

Overrides:
attribute in class XMLWriter
Throws:
java.io.IOException - if text or sub-elements have already been written in this element.

endElement

public void endElement()
                throws java.io.IOException
Overrides:
endElement in class XMLWriter
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(java.lang.String content)
           throws java.io.IOException
Overrides:
write in class XMLWriter
Throws:
java.io.IOException

write

public void write(java.lang.String content,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class XMLWriter
Throws:
java.io.IOException

write

public void write(char[] content,
                  int off,
                  int len)
           throws java.io.IOException
Description copied from class: XMLWriter
Add text content to the current element. Do nothing if len <= 0.

Specified by:
write in class XMLWriter
Throws:
java.io.IOException

write

public void write(int content)
           throws java.io.IOException
Throws:
java.io.IOException

beginContent

protected void beginContent()
                     throws java.io.IOException
Throws:
java.io.IOException