ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/java/XMLFormatter.java
(Generate patch)

Comparing projects/cms/source/host/java/XMLFormatter.java (file contents):
Revision 1.1 by ab11, Mon Nov 27 19:44:00 2000 UTC vs.
Revision 1.8 by tdb, Tue May 21 16:47:12 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
4 + * Copyright (C) 2000-2002 i-scream
5 + *
6 + * This program is free software; you can redistribute it and/or
7 + * modify it under the terms of the GNU General Public License
8 + * as published by the Free Software Foundation; either version 2
9 + * of the License, or (at your option) any later version.
10 + *
11 + * This program is distributed in the hope that it will be useful,
12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 + * GNU General Public License for more details.
15 + *
16 + * You should have received a copy of the GNU General Public License
17 + * along with this program; if not, write to the Free Software
18 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + */
20 +
21   //---PACKAGE DECLARATION---
22  
23   //---IMPORTS---
# Line 5 | Line 25 | import java.util.*;
25  
26   /**
27   * Formats data into valid XML
28 < * By calling either addElement() or addNest() you can use this
29 < * class to create valid xml. When all elements have been added
30 < * calling returnXML() will return a string containing the xml.
28 > * By calling either addElement() or addNest() you can use
29 > * this class to create valid xml. When all elements have
30 > * been added calling returnXML() will return a string
31 > * containing the xml.
32   *
33   *
34   * @author  $Author$
# Line 31 | Line 52 | class XMLFormatter {
52      * Takes in one arguement which can contain any valid non xml character ( "<",">" )
53      * an example for rootInfo would be "Host"
54      */
55 <    public XMLFormatter(String rootInfo){
55 >    public XMLFormatter(String rootInfo, String attributes){
56  
57          myStack = new Stack();
58          xmlData = new String();
59 +        xmlData = "<"+rootInfo+" "+attributes+">";
60 +        hostInfo = rootInfo;
61 +    }
62 +
63 +    /**
64 +    * Public Constructor for the class
65 +    * Takes in one arguement which can contain any valid non xml character ( "<",">" )
66 +    * an example for rootInfo would be "Host"
67 +    */
68 +    public XMLFormatter(String rootInfo){
69 +        myStack = new Stack();
70 +        xmlData = new String();
71          xmlData = "<"+rootInfo+">";
72          hostInfo = rootInfo;
73      }
# Line 49 | Line 82 | class XMLFormatter {
82          hostInfo = null;
83      }        
84  
52
85   //---PUBLIC METHODS---
86  
87     /**
88 +   * addEement, adds an element to the XML string with attributes
89 +   *
90 +   */
91 +   public void addElement(String name, String attributes, String value){
92 +        // check that the strings contain valid data first
93 +        if (( name.length() != 0 ) && ( value.length() != 0 )){
94 +            xmlData += "<"+name+" "+attributes+">"+value+"</"+name+">";
95 +        }
96 +    }
97 +
98 +   /**
99     * addEement, adds an element to the XML string
100     *
101     */
# Line 72 | Line 115 | class XMLFormatter {
115          xmlData += "<"+name+">";
116          myStack.push(name);
117      }
118 +
119 +    /**
120 +    * addString, adds a string into the XML packet no further processing is carried out
121 +    */
122 +    public void addString(String name){
123 +        xmlData += name;
124 +    }
125 +
126  
127      /**
128      * closeNest will close the currently opened nest (by writing </nest name> to

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines