Package com.ms.xml.util
 In this topic

*Constructors

*Methods

*Fields

 

Packages
  PreviousThis Package
Package com.ms.xml.util   Previous This
Package

 


Class XMLOutputStream

public class XMLOutputStream extends OutputStream
{
  // Fields
  public static int COMPACT;
  public static int PRETTY;

  // Constructors
  public XMLOutputStream( OutputStream out );

  // Methods
  public void addIndent(int offset);
  public void close() throws IOException;
  public void flush() throws IOException;
  public int getOutputStyle();
  public void setEncoding( String encoding, boolean littleendian,
        boolean byteOrderMark ) throws IOException;
  public void setOutputStyle(int style);
  public void write( int c ) throws IOException;
  public void writeChars( String str ) throws IOException;
  public void writeIndent() throws IOException;
  public void writeNewLine() throws IOException;
  public void writeQualifiedName(Name n, Name ns) throws IOException;
  public void writeQuotedString( String str ) throws IOException;
}

This class is an output stream writer that is specifically designed for XML including XML encoding, little endian files, XML namespaces, and white-space handling.

OutputStream
  |
  +--XMLOutputStream

Constructors

XMLOutputStream

public XMLOutputStream( OutputStream out );

Constructs the XMLOutputStream object as a standard UTF-8 output stream. A subsequent call to the setEncoding method will specify the correct character encoding that is required. Create an XMLOutputStream by using the createOutputStream method of the XMLInputStream class.

ParameterDescription
out An output stream to use to create the XMLOutputStream.

Methods

addIndent

public void addIndent(int offset);

Sets the relative indentation level (for example, addIndent(+1) or addIndent(-1)). The indent level controls what the writeIndent writes.

Return Value:

No return value.

ParameterDescription
offset A signed value for the indentation level.

close

public void close() throws IOException;

Closes the XMLOutputStream and frees any system resources that are associated with the stream.

Return Value:

No return value.

Exceptions:

IOException if an I/O error occurs.

flush

public void flush() throws IOException;

Flushes the XMLOutputStream.

Return Value:

No return value.

Exceptions:

IOException if an I/O error occurred.

getOutputStyle

public int getOutputStyle();

Retrieves the current output style for the output stream.

Return Value:

Returns either the COMPACT or the PRETTY output style.

setEncoding

public void setEncoding( String encoding, boolean littleendian,
        boolean byteOrderMark ) throws IOException;

Defines the character encoding of the output stream.

Return Value:

No return value.

ParameterDescription
encoding The type of character encoding. This may be one of the following formats:
  • UTF-8
  • Shift_JIS
  • ISO-8859-1
  • ISO-10646-UCS-4 (not yet supported)
  • UCS-2

The default character encoding is ASCII.

littleendian Set this parameter to true to specify whether the stream is in little endian format.
byteOrderMark This flag is only relevant if the character encoding type is UCS-2. Otherwise, it is ignored.

Exceptions:

IOException if the encoding type is not supported by the currently installed virtual machine.

setOutputStyle

public void setOutputStyle(int style);

Sets the output style for the output stream.

Return Value:

No return value.

ParameterDescription
style The output style. This can be either PRETTY or COMPACT.

write

public void write( int c ) throws IOException;

Writes a character to the output stream according to the current write state. In order to avoid an extra conditional in every UCS-2 write, an extra state for a UCS-2 write operation that requires a ByteOrderMark is used. The ByteOrderMark is written only once at the beginning of the file.

Return Value:

No return value.

ParameterDescription
c The character to write to the output stream.

Exceptions:

IOException if there was an error writing to the stream.

writeChars

public void writeChars( String str ) throws IOException;

Writes the given string to the output stream.

Return Value:

No return value.

ParameterDescription
str The String to write to the output stream.

Exceptions:

IOException if there was an error writing to the output stream.

writeIndent

public void writeIndent() throws IOException;

Writes the appropriate indent, according to the indentation level that is specified by the addIndent method. If the output style is COMPACT, the method performs no operation.

Return Value:

No return value.

Exceptions:

IOException if there was an error writing to the output stream.

writeNewLine

public void writeNewLine() throws IOException;

Writes a new line. If the output style is COMPACT, the method performs no operation.

Return Value:

No return value.

Exceptions:

IOException if there was an error writing to the output stream.

writeQualifiedName

public void writeQualifiedName(Name n, Name ns) throws IOException;

Writes out the fully qualified name, using the appropriate short name syntax.

Return Value:

No return value.

ParameterDescription
n The Name being written.
ns The namespace that defines the context in which the name was defined.

Exceptions:

IOException if there was an error writing to the stream.

writeQuotedString

public void writeQuotedString( String str ) throws IOException;

Writes out the string enclosed in quotation marks. This method uses quotation marks that are appropriate for the string (for example, if a string contains a single quotation mark ('), the method uses a double quotation mark ("), and so on).

Return Value:

No return value.

ParameterDescription
str The String to write to the output stream.

Fields

COMPACT
An ouput style that specifies that no newline characters or tabs are used in the output stream.
PRETTY
The default output style. Newlines and tabs are used when writing to the output stream.

upnrm.gif