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.6 by ab11, Mon Mar 19 17:30:17 2001 UTC

# Line 5 | Line 5 | import java.util.*;
5  
6   /**
7   * Formats data into valid XML
8 < * By calling either addElement() or addNest() you can use this
9 < * class to create valid xml. When all elements have been added
10 < * calling returnXML() will return a string containing the xml.
8 > * By calling either addElement() or addNest() you can use
9 > * this class to create valid xml. When all elements have
10 > * been added calling returnXML() will return a string
11 > * containing the xml.
12   *
13   *
14   * @author  $Author$
# Line 31 | Line 32 | class XMLFormatter {
32      * Takes in one arguement which can contain any valid non xml character ( "<",">" )
33      * an example for rootInfo would be "Host"
34      */
35 <    public XMLFormatter(String rootInfo){
35 >    public XMLFormatter(String rootInfo, String attributes){
36  
37          myStack = new Stack();
38          xmlData = new String();
39 +        xmlData = "<"+rootInfo+" "+attributes+">";
40 +        hostInfo = rootInfo;
41 +    }
42 +
43 +    /**
44 +    * Public Constructor for the class
45 +    * Takes in one arguement which can contain any valid non xml character ( "<",">" )
46 +    * an example for rootInfo would be "Host"
47 +    */
48 +    public XMLFormatter(String rootInfo){
49 +        myStack = new Stack();
50 +        xmlData = new String();
51          xmlData = "<"+rootInfo+">";
52          hostInfo = rootInfo;
53      }
# Line 49 | Line 62 | class XMLFormatter {
62          hostInfo = null;
63      }        
64  
52
65   //---PUBLIC METHODS---
66  
67     /**
68 +   * addEement, adds an element to the XML string with attributes
69 +   *
70 +   */
71 +   public void addElement(String name, String attributes, String value){
72 +        // check that the strings contain valid data first
73 +        if (( name.length() != 0 ) && ( value.length() != 0 )){
74 +            xmlData += "<"+name+" "+attributes+">"+value+"</"+name+">";
75 +        }
76 +    }
77 +
78 +   /**
79     * addEement, adds an element to the XML string
80     *
81     */
# Line 72 | Line 95 | class XMLFormatter {
95          xmlData += "<"+name+">";
96          myStack.push(name);
97      }
98 +
99 +    /**
100 +    * addString, adds a string into the XML packet no further processing is carried out
101 +    */
102 +    public void addString(String name){
103 +        xmlData += name;
104 +    }
105 +
106  
107      /**
108      * closeNest will close the currently opened nest (by writing </nest name> to

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines