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.7 by tdb, Sat May 18 18:15:57 2002 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines