okapi.util
Class OkapiXMLDocument

java.lang.Object
  extended by okapi.util.OkapiXMLDocument

public class OkapiXMLDocument
extends java.lang.Object

Creates a string of formatted XML by sequentially adding tags and content. An OkapiXMLDocument is a wrapper around a StringBuffer that adds standard indentation as tags and text are added to the document. Tags are indented past their parent tag on the following line, with end tags indented to line up with their matching start tags, except for tags which contain content, which are placed on the same line with their text and end tags. This class only adds formatting. It is intended only to create more human readable XML documents. It does not check for well-formedness and does not maintain the document in a modifiable format. This class does not support mixed-content elements.

Version:
$Revision: 31044 $, $Date: 2008-09-02 17:08:01 -0400 (Tue, 02 Sep 2008) $
Author:
MIT Stellar team

Constructor Summary
OkapiXMLDocument()
          Create a new OkapiXMLDocument whose first line will not indented.
OkapiXMLDocument(int startLevel)
          Create a new OkapiXMLDocument whose first line will be indented indents.
 
Method Summary
 void addCData(java.lang.String content)
          Adds to the document.
 void addContent(java.lang.String element, boolean content)
          Adds content to the document, converting content to a string.
 void addContent(java.lang.String element, double content)
          Adds content to the document, converting content to a string.
 void addContent(java.lang.String element, int content)
          Adds content to the document, converting content to a string.
 void addContent(java.lang.String element, long content)
          Adds content to the document, converting content to a string.
 void addContent(java.lang.String element, java.lang.Object content)
          Adds content to the document, converting content to a string using OkapiXMLDocument.dateFormat.
 void addContent(java.lang.String element, java.lang.String content)
          Adds content to the document, adding the necessary escapes to content.
 void addEmptyTag(java.lang.String element)
          Adds to the document.
 void addEndTag(java.lang.String element)
          Adds to the document.
 void addProlog()
          Adds to the document
 void addStartTag(java.lang.String element)
          Adds to the document.
 void addStartTag(java.lang.String element, java.lang.String attributes)
          Adds to the document.
 void addXml(java.lang.String xml)
          Inserts a string of xml into the document.
static java.lang.String escapeXml(java.lang.String content)
          just escapes string.
 int getLevel()
          Method getLevel
 java.lang.String toString()
          Method toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OkapiXMLDocument

public OkapiXMLDocument()
Create a new OkapiXMLDocument whose first line will not indented.


OkapiXMLDocument

public OkapiXMLDocument(int startLevel)
Create a new OkapiXMLDocument whose first line will be indented indents. Allows an OkapiXMLDocument to be inserted into another XML document at a certain level.

Method Detail

addProlog

public void addProlog()
Adds to the document


addStartTag

public void addStartTag(java.lang.String element)
Adds to the document.


addStartTag

public void addStartTag(java.lang.String element,
                        java.lang.String attributes)
Adds to the document.


addEndTag

public void addEndTag(java.lang.String element)
Adds to the document.


addEmptyTag

public void addEmptyTag(java.lang.String element)
Adds to the document.


addContent

public void addContent(java.lang.String element,
                       java.lang.String content)
Adds content to the document, adding the necessary escapes to content.


escapeXml

public static java.lang.String escapeXml(java.lang.String content)
just escapes string.


addContent

public void addContent(java.lang.String element,
                       java.lang.Object content)
Adds content to the document, converting content to a string using OkapiXMLDocument.dateFormat.


addContent

public void addContent(java.lang.String element,
                       int content)
Adds content to the document, converting content to a string.


addContent

public void addContent(java.lang.String element,
                       long content)
Adds content to the document, converting content to a string.


addContent

public void addContent(java.lang.String element,
                       boolean content)
Adds content to the document, converting content to a string.


addContent

public void addContent(java.lang.String element,
                       double content)
Adds content to the document, converting content to a string.


addXml

public void addXml(java.lang.String xml)
Inserts a string of xml into the document. The user is responsible for ensuring that the xml is indented appropriately. If the xml was created by an OkapiXMLDocument, it should have been created with a start level equal to the value returned by getLevel() at the point of insertion.


addCData

public void addCData(java.lang.String content)
Adds to the document.


getLevel

public int getLevel()
Method getLevel

Returns:
int

toString

public java.lang.String toString()
Method toString

Overrides:
toString in class java.lang.Object
Returns:
String


Copyright ? 2001-2009 MIT. All Rights Reserved.