FreeHEP API
Version current

org.freehep.xml.util
Class XMLWriter

java.lang.Object
  extended byorg.freehep.xml.util.XMLWriter
Direct Known Subclasses:
AidaStyleXMLWriter, XHTMLWriter, XMLYappiWriter

public class XMLWriter
extends Object

A class that makes it easy to write XML documents.

Version:
$Id: XMLWriter.java,v 1.16 2003/06/28 20:45:40 duns Exp $
Author:
Tony Johnson, Mark Donszelmann
Source Code:
XMLWriter.java

Field Summary
protected  boolean closed
           
protected  String defaultNameSpace
           
protected  IndentPrintWriter writer
           
 
Constructor Summary
XMLWriter(Writer w)
           
XMLWriter(Writer w, String indentString)
           
XMLWriter(Writer w, String indentString, String defaultNameSpace)
           
 
Method Summary
protected  void checkNameValid(String s)
           
 void close()
          closes the writer
 void closeDoc()
          Closes the document, and checks if you closed all the tags
 void closeTag()
          Closes the current XML tag and decreases the indentation level
static String normalize(String s)
          Normalizes the given string for an Attribute value
static String normalizeText(String s)
          Normalizes the given string for Text
 void openDoc()
          Opens the document with an xml header
 void openDoc(String version, String encoding, boolean standalone)
          Opens the document with an xml header
 void openTag(String name)
          Prints a new XML tag and increases the identation level
 void openTag(String namespace, String name)
          Prints a new XML tag and increases the identation level
 void print(Node node)
          Prints a DOM node, recursively.
 void print(String text)
          Prints character data, while escaping < and >
protected  void printAttributes(int tagLength)
           
 void printComment(String comment)
          Print a comment
 void println(String text)
          Prints character data, while escaping < and >
 void printTag(String name)
          Prints an empty XML tag.
 void printTag(String namespace, String name)
          Prints an empty XML tag.
 void referToDTD(String name, String system)
          Writes a reference to a DTD
 void referToDTD(String name, String pid, String ref)
          Writes a reference to a DTD
 void setAttribute(String name, boolean value)
           
 void setAttribute(String name, byte value)
           
 void setAttribute(String name, char value)
           
 void setAttribute(String name, double value)
           
 void setAttribute(String name, float value)
           
 void setAttribute(String name, int value)
           
 void setAttribute(String name, long value)
           
 void setAttribute(String name, short value)
           
 void setAttribute(String name, String value)
          Sets an attribute which will be included in the next tag printed by openTag or printTag
 void setAttribute(String ns, String name, boolean value)
           
 void setAttribute(String ns, String name, double value)
           
 void setAttribute(String ns, String name, int value)
           
 void setAttribute(String namespace, String name, String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

closed

protected boolean closed

writer

protected IndentPrintWriter writer

defaultNameSpace

protected String defaultNameSpace
Constructor Detail

XMLWriter

public XMLWriter(Writer w,
                 String indentString,
                 String defaultNameSpace)

XMLWriter

public XMLWriter(Writer w,
                 String indentString)

XMLWriter

public XMLWriter(Writer w)
Method Detail

close

public void close()
           throws IOException
closes the writer

Throws:
IOException

openDoc

public void openDoc()
Opens the document with an xml header


openDoc

public void openDoc(String version,
                    String encoding,
                    boolean standalone)
Opens the document with an xml header


referToDTD

public void referToDTD(String name,
                       String pid,
                       String ref)
Writes a reference to a DTD


referToDTD

public void referToDTD(String name,
                       String system)
Writes a reference to a DTD


closeDoc

public void closeDoc()
Closes the document, and checks if you closed all the tags


printComment

public void printComment(String comment)
Print a comment


print

public void print(String text)
Prints character data, while escaping < and >


println

public void println(String text)
Prints character data, while escaping < and >


openTag

public void openTag(String namespace,
                    String name)
Prints a new XML tag and increases the identation level


openTag

public void openTag(String name)
Prints a new XML tag and increases the identation level


closeTag

public void closeTag()
Closes the current XML tag and decreases the indentation level


printTag

public void printTag(String namespace,
                     String name)
Prints an empty XML tag.


printTag

public void printTag(String name)
Prints an empty XML tag.


setAttribute

public void setAttribute(String name,
                         String value)
Sets an attribute which will be included in the next tag printed by openTag or printTag


setAttribute

public void setAttribute(String namespace,
                         String name,
                         String value)

setAttribute

public void setAttribute(String name,
                         double value)

setAttribute

public void setAttribute(String name,
                         float value)

setAttribute

public void setAttribute(String name,
                         int value)

setAttribute

public void setAttribute(String name,
                         long value)

setAttribute

public void setAttribute(String name,
                         short value)

setAttribute

public void setAttribute(String name,
                         boolean value)

setAttribute

public void setAttribute(String name,
                         byte value)

setAttribute

public void setAttribute(String name,
                         char value)

setAttribute

public void setAttribute(String ns,
                         String name,
                         double value)

setAttribute

public void setAttribute(String ns,
                         String name,
                         int value)

setAttribute

public void setAttribute(String ns,
                         String name,
                         boolean value)

printAttributes

protected void printAttributes(int tagLength)

print

public void print(Node node)
Prints a DOM node, recursively. No support for a document node


normalize

public static String normalize(String s)
Normalizes the given string for an Attribute value


normalizeText

public static String normalizeText(String s)
Normalizes the given string for Text


checkNameValid

protected void checkNameValid(String s)

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.