--- projects/cms/source/host/java/XMLFormatter.java 2000/11/27 19:44:00 1.1 +++ projects/cms/source/host/java/XMLFormatter.java 2000/12/08 12:21:11 1.4 @@ -11,7 +11,7 @@ import java.util.*; * * * @author $Author: ab11 $ - * @version $Id: XMLFormatter.java,v 1.1 2000/11/27 19:44:00 ab11 Exp $ + * @version $Id: XMLFormatter.java,v 1.4 2000/12/08 12:21:11 ab11 Exp $ */ class XMLFormatter { @@ -20,7 +20,7 @@ class XMLFormatter { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.1 $"; + public final String REVISION = "$Revision: 1.4 $"; //---STATIC METHODS--- @@ -31,10 +31,22 @@ class XMLFormatter { * Takes in one arguement which can contain any valid non xml character ( "<",">" ) * an example for rootInfo would be "Host" */ - public XMLFormatter(String rootInfo){ + public XMLFormatter(String rootInfo, String attributes){ myStack = new Stack(); xmlData = new String(); + xmlData = "<"+rootInfo+" "+attributes+">"; + hostInfo = rootInfo; + } + + /** + * Public Constructor for the class + * Takes in one arguement which can contain any valid non xml character ( "<",">" ) + * an example for rootInfo would be "Host" + */ + public XMLFormatter(String rootInfo){ + myStack = new Stack(); + xmlData = new String(); xmlData = "<"+rootInfo+">"; hostInfo = rootInfo; } @@ -49,10 +61,31 @@ class XMLFormatter { hostInfo = null; } + /** + * Public Constructor for the class + * Takes a second parameter containing the root attributes. + */ + public XMLFormatter(String rootInfo, String rootAttributes){ + myStack = new Stack(); + xmlData = new String(); + xmlData = "<"+rootInfo+" "+rootAttributes+">"; + hostInfo = rootInfo; + } //---PUBLIC METHODS--- /** + * addEement, adds an element to the XML string with attributes + * + */ + public void addElement(String name, String attributes, String value){ + // check that the strings contain valid data first + if (( name.length() != 0 ) && ( value.length() != 0 )){ + xmlData += "<"+name+" "+attributes+">"+value+""; + } + } + + /** * addEement, adds an element to the XML string * */ @@ -72,6 +105,14 @@ class XMLFormatter { xmlData += "<"+name+">"; myStack.push(name); } + + /** + * addString, adds a string into the XML packet no further processing is carried out + */ + public void addString(String name){ + xmlData += name; + } + /** * closeNest will close the currently opened nest (by writing to