Open SiteSearch 4.1.1
Final

ORG.oclc.xml.util
Class XMLOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--ORG.oclc.xml.util.XMLOutputStream

public class XMLOutputStream
extends OutputStream

A writer specifically designed for dealing with XML, incluing XML encoding as well as liitleendian files, and XML namespaces and white space handling.


Field Summary
static int COMPACT
           
static int DEFAULT
           
 DTD dtd
          needed for saving in correct format
 boolean mixed
           
 NameSpaceContext nameSpaceContext
          needed for saving in correct format
static int PRETTY
           
 boolean savingDTD
          whether we are in the scope of saving a DTD or not
 
Constructor Summary
XMLOutputStream(OutputStream out)
          Builds the XMLOutputStream.
 
Method Summary
 void addIndent(int offset)
          Set the relative indenting level.
 void close()
          Pass-through of inherited OutputStream method.
 void flush()
          Pass-through of inherited OutputStream method.
 int getOutputStyle()
          Return the current output style.
 void setEncoding(String encoding, boolean littleendian, boolean byteOrderMark)
          Defines the character encoding of the output stream.
 void setOutputStyle(int style)
          Set the output style (PRETTY or COMPACT).
 void write(int c)
          writes a character to the stream according to the current writeState.
 void writeChars(String str)
          Write the given string.
 void writeIndent()
          Write the appropriate indent - given current indent level, or do nothing if output style is COMPACT.
 void writeNewLine()
          Write a new line or do nothing if output style is COMPACT.
 void writeQualifiedName(Name n, Atom ns)
          This method writes out the fully qualified name, using the appropriate short name syntax.
 void writeQuotedString(String str)
          Write out the string with quotes around it.
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static int DEFAULT

PRETTY

public static int PRETTY

COMPACT

public static int COMPACT

mixed

public boolean mixed

dtd

public DTD dtd
needed for saving in correct format

nameSpaceContext

public NameSpaceContext nameSpaceContext
needed for saving in correct format

savingDTD

public boolean savingDTD
whether we are in the scope of saving a DTD or not
Constructor Detail

XMLOutputStream

public XMLOutputStream(OutputStream out)
Builds the XMLOutputStream. It is created as a standard UTF-8 output stream. A subsequent call to setEncoding will specify the correct character encoding required. XMLOutputStreams can be built by using the createOutputStream method contained in XMLInputStream.
Method Detail

flush

public void flush()
           throws IOException
Pass-through of inherited OutputStream method.
Overrides:
flush in class OutputStream

close

public void close()
           throws IOException
Pass-through of inherited OutputStream method.
Overrides:
close in class OutputStream

setEncoding

public void setEncoding(String encoding,
                        boolean littleendian,
                        boolean byteOrderMark)
                 throws IOException
Defines the character encoding of the output stream.

write

public void write(int c)
           throws IOException
writes a character to the stream according to the current writeState. There is an extra state for a UCS-2 requiring a ByteOrderMark so as to avoid an extra conditional in every UCS2 write. The ByteOrderMark will only be written once at the beginning of the file.
Overrides:
write in class OutputStream

writeQualifiedName

public void writeQualifiedName(Name n,
                               Atom ns)
                        throws IOException
This method writes out the fully qualified name, using the appropriate short name syntax. For example: "foo:bar".
Parameters:
n - the name being written
ns - the name space which defines the context in which the name was defined.

writeChars

public void writeChars(String str)
                throws IOException
Write the given string.

writeQuotedString

public void writeQuotedString(String str)
                       throws IOException
Write out the string with quotes around it. This method uses the quotes that are appropriate for the string. I.E. if the string contains a ' then it uses ", & vice versa.

writeNewLine

public void writeNewLine()
                  throws IOException
Write a new line or do nothing if output style is COMPACT.

addIndent

public void addIndent(int offset)
Set the relative indenting level. Eg indent(+1) or indent(-1). The indent level controls what writeIndent writes.

writeIndent

public void writeIndent()
                 throws IOException
Write the appropriate indent - given current indent level, or do nothing if output style is COMPACT.

setOutputStyle

public void setOutputStyle(int style)
Set the output style (PRETTY or COMPACT).

getOutputStyle

public int getOutputStyle()
Return the current output style.

Open SiteSearch 4.1.1
Final