org.extex.util.xml
Class XMLStreamWriter

java.lang.Object
  extended by org.extex.util.xml.XMLStreamWriter

public class XMLStreamWriter
extends java.lang.Object

A writer, which write xml-elements, attributes and so on to an output stream.

only xml version 1.0

Version:
$Revision: 6388 $
Author:
Michael Niedermair

Constructor Summary
XMLStreamWriter(java.io.OutputStream sout, java.lang.String enc)
          Create a new object.
 
Method Summary
 void close()
          Close the output.
 void flush()
          Flush the buffer to the output.
 java.lang.String getDefaultNamespace()
          Returns the default namespace.
 boolean isRemoveWhiteSpace()
          Getter for removeWhiteSpace.
 void newLine()
          Write a newline to the output.
 void setBeauty(boolean b)
          Set the beauty.
 void setDefaultNamespace(java.lang.String ns)
          Set the default name space for elements.
 void setDocType(java.lang.String rootn, java.lang.String publicId, java.lang.String systemId)
          Set the doctpye definition.
 void setIndent(java.lang.String i)
          Set the indent.
 void setNumberformat(java.text.NumberFormat nformat)
          Setter for number format.
 void setRemoveWhiteSpace(boolean removeWhiteSpace)
          Setter for removeWhiteSpace.
 void writeAttribute(java.lang.String name, boolean value)
          Write a attribute to the element.
 void writeAttribute(java.lang.String name, double value)
          Write a attribute to the element.
 void writeAttribute(java.lang.String name, long value)
          Write a attribute to the element.
 void writeAttribute(java.lang.String name, long value, int length)
          Write a attribute to the element.
 void writeAttribute(java.lang.String name, java.lang.Object value)
          Write a attribute to the element.
 void writeAttribute(java.lang.String name, java.lang.String value)
          Write a attribute to the element.
 void writeAttribute(java.lang.String ns, java.lang.String name, java.lang.String value)
          Write a attribute (with name space) to the element.
 void writeByteArray(byte[] bytes)
          Write a byte array with hex values to the output.
 void writeByteArrayAsEntries(byte[] bytes)
          Write a byte array as entries (hex).
 void writeCDATA(byte[] array)
          Write a CDATA string.
 void writeCDATA(java.lang.String text)
          Write a cdata string.
 void writeCharacters(char[] ch, int start, int length)
          Write characters to the output.
 void writeCharacters(java.lang.String text)
          Write characters to the output.
 void writeComment(java.lang.String text)
          Write a comment.
 void writeEndDocument()
          Write the end of the document.
 void writeEndElement()
          Write the end element to the output.
 void writeFormatAttribute(java.lang.String name, double value)
          Write a attribute to the element and use the formatter.
 void writeIntArrayAsEntries(int[] array)
          Write a int array as entries (hex).
 void writeShortArray(short[] shorts)
          Write a short array with hex values to the output.
 void writeStartDocument()
          Write the start of the document.
 void writeStartElement(java.lang.String element)
          Write the start element to the output.
 void writeStartElement(java.lang.String ns, java.lang.String element)
          Write the start element to the output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLStreamWriter

public XMLStreamWriter(java.io.OutputStream sout,
                       java.lang.String enc)
                throws java.io.IOException
Create a new object.

Parameters:
sout - The output.
enc - The encoding
Throws:
java.io.IOException - if an error occurs.
Method Detail

close

public void close()
           throws java.io.IOException
Close the output.

Throws:
java.io.IOException - if an error occurs.

flush

public void flush()
           throws java.io.IOException
Flush the buffer to the output.

Throws:
java.io.IOException - if an error occurs.

getDefaultNamespace

public java.lang.String getDefaultNamespace()
Returns the default namespace.

Returns:
Returns the defaultns.

isRemoveWhiteSpace

public boolean isRemoveWhiteSpace()
Getter for removeWhiteSpace.

Returns:
the removeWhiteSpace

newLine

public void newLine()
             throws java.io.IOException
Write a newline to the output.

Throws:
java.io.IOException - if an error occurs.

setBeauty

public void setBeauty(boolean b)
               throws java.io.IOException
Set the beauty.

Parameters:
b - The beauty to set.
Throws:
java.io.IOException - if an error occurs.

setDefaultNamespace

public void setDefaultNamespace(java.lang.String ns)
                         throws java.io.IOException
Set the default name space for elements.

Parameters:
ns - The default name space to set.
Throws:
java.io.IOException - if an error occurs.

setDocType

public void setDocType(java.lang.String rootn,
                       java.lang.String publicId,
                       java.lang.String systemId)
                throws java.io.IOException
Set the doctpye definition.

Parameters:
rootn - The root element.
publicId - The public id.
systemId - The system id.
Throws:
java.io.IOException - if an IO-error occurred.

setIndent

public void setIndent(java.lang.String i)
               throws java.io.IOException
Set the indent.

Parameters:
i - The indent to set.
Throws:
java.io.IOException - if an error occurs.

setNumberformat

public void setNumberformat(java.text.NumberFormat nformat)
Setter for number format.

Parameters:
nformat - The number format to set.

setRemoveWhiteSpace

public void setRemoveWhiteSpace(boolean removeWhiteSpace)
Setter for removeWhiteSpace.

Parameters:
removeWhiteSpace - the removeWhiteSpace to set

writeAttribute

public void writeAttribute(java.lang.String name,
                           boolean value)
                    throws java.io.IOException
Write a attribute to the element.

Parameters:
name - The name of the attribute.
value - The value of the attribute.
Throws:
java.io.IOException - if an error occurs.

writeAttribute

public void writeAttribute(java.lang.String name,
                           double value)
                    throws java.io.IOException
Write a attribute to the element.

Parameters:
name - The name of the attribute.
value - The value of the attribute.
Throws:
java.io.IOException - if an error occurs.

writeAttribute

public void writeAttribute(java.lang.String name,
                           long value)
                    throws java.io.IOException
Write a attribute to the element.

Parameters:
name - The name of the attribute.
value - The value of the attribute.
Throws:
java.io.IOException - if an error occurs.

writeAttribute

public void writeAttribute(java.lang.String name,
                           long value,
                           int length)
                    throws java.io.IOException
Write a attribute to the element. The long-value is print a a hex string.

Parameters:
name - The name of the attribute.
value - The value of the attribute.
length - The length of the hex string.
Throws:
java.io.IOException - if an error occurs.

writeAttribute

public void writeAttribute(java.lang.String name,
                           java.lang.Object value)
                    throws java.io.IOException
Write a attribute to the element.

Parameters:
name - The name of the attribute.
value - The value of the attribute.
Throws:
java.io.IOException - if an error occurs.

writeAttribute

public void writeAttribute(java.lang.String name,
                           java.lang.String value)
                    throws java.io.IOException
Write a attribute to the element.

Parameters:
name - The name of the attribute.
value - The value of the attribute.
Throws:
java.io.IOException - if an error occurs.

writeAttribute

public void writeAttribute(java.lang.String ns,
                           java.lang.String name,
                           java.lang.String value)
                    throws java.io.IOException
Write a attribute (with name space) to the element.

Parameters:
ns - The name space.
name - The name of the attribute.
value - The value of the attribute.
Throws:
java.io.IOException - if an error occurs.

writeByteArray

public void writeByteArray(byte[] bytes)
                    throws java.io.IOException
Write a byte array with hex values to the output.

Parameters:
bytes - The byte array.
Throws:
java.io.IOException - if an error occurs.

writeByteArrayAsEntries

public void writeByteArrayAsEntries(byte[] bytes)
                             throws java.io.IOException
Write a byte array as entries (hex).

Parameters:
bytes - The byte array.
Throws:
java.io.IOException - if an error occurs.

writeCDATA

public void writeCDATA(byte[] array)
                throws java.io.IOException
Write a CDATA string.

Parameters:
array - The CDATA as array.
Throws:
java.io.IOException - if an error occurs.

writeCDATA

public void writeCDATA(java.lang.String text)
                throws java.io.IOException
Write a cdata string.

Parameters:
text - The cdata string.
Throws:
java.io.IOException - if an error occurs.

writeCharacters

public void writeCharacters(char[] ch,
                            int start,
                            int length)
                     throws java.io.IOException
Write characters to the output.

Parameters:
ch - The char array.
start - The start position.
length - The length.
Throws:
java.io.IOException - if an error occurs.

writeCharacters

public void writeCharacters(java.lang.String text)
                     throws java.io.IOException
Write characters to the output.

Parameters:
text - The text
Throws:
java.io.IOException - if an error occurs.

writeComment

public void writeComment(java.lang.String text)
                  throws java.io.IOException
Write a comment.

Parameters:
text - The comment.
Throws:
java.io.IOException - if an error occurs.

writeEndDocument

public void writeEndDocument()
                      throws java.io.IOException
Write the end of the document.

It makes a flush()

Throws:
java.io.IOException - if an error occurs.

writeEndElement

public void writeEndElement()
                     throws java.io.IOException
Write the end element to the output.

Throws:
java.io.IOException - if an error occurs.

writeFormatAttribute

public void writeFormatAttribute(java.lang.String name,
                                 double value)
                          throws java.io.IOException
Write a attribute to the element and use the formatter.

Parameters:
name - The name of the attribute.
value - The value of the attribute.
Throws:
java.io.IOException - if an error occurs.

writeIntArrayAsEntries

public void writeIntArrayAsEntries(int[] array)
                            throws java.io.IOException
Write a int array as entries (hex).

Parameters:
array - The int array.
Throws:
java.io.IOException - if an error occurs.

writeShortArray

public void writeShortArray(short[] shorts)
                     throws java.io.IOException
Write a short array with hex values to the output.

Parameters:
shorts - The short array.
Throws:
java.io.IOException - if an error occurs.

writeStartDocument

public void writeStartDocument()
                        throws java.io.IOException
Write the start of the document.

A newline is write after the header, without attend the beauty-flag.

Throws:
java.io.IOException - if an error occurs.

writeStartElement

public void writeStartElement(java.lang.String element)
                       throws java.io.IOException
Write the start element to the output.

Parameters:
element - the element
Throws:
java.io.IOException - if an error occurs.

writeStartElement

public void writeStartElement(java.lang.String ns,
                              java.lang.String element)
                       throws java.io.IOException
Write the start element to the output.

Parameters:
ns - the name space
element - the element
Throws:
java.io.IOException - if an error occurs.