--- projects/cms/source/host/java/XMLFormatter.java 2000/12/07 18:25:53 1.2 +++ projects/cms/source/host/java/XMLFormatter.java 2002/05/21 16:47:12 1.8 @@ -1,3 +1,23 @@ +/* + * i-scream central monitoring system + * http://www.i-scream.org.uk + * Copyright (C) 2000-2002 i-scream + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + //---PACKAGE DECLARATION--- //---IMPORTS--- @@ -5,13 +25,14 @@ import java.util.*; /** * Formats data into valid XML - * By calling either addElement() or addNest() you can use this - * class to create valid xml. When all elements have been added - * calling returnXML() will return a string containing the xml. + * By calling either addElement() or addNest() you can use + * this class to create valid xml. When all elements have + * been added calling returnXML() will return a string + * containing the xml. * * - * @author $Author: ab11 $ - * @version $Id: XMLFormatter.java,v 1.2 2000/12/07 18:25:53 ab11 Exp $ + * @author $Author: tdb $ + * @version $Id: XMLFormatter.java,v 1.8 2002/05/21 16:47:12 tdb Exp $ */ class XMLFormatter { @@ -20,7 +41,7 @@ class XMLFormatter { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.2 $"; + public final String REVISION = "$Revision: 1.8 $"; //---STATIC METHODS--- @@ -31,10 +52,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,8 +82,18 @@ class XMLFormatter { hostInfo = null; } - //---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