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.3 by tdb, Thu Dec 7 23:22:17 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, 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();
# Line 48 | Line 62 | class XMLFormatter {
62          hostInfo = null;
63      }        
64  
51    /**
52    * Public Constructor for the class
53    * Takes a second parameter containing the root attributes.
54    */
55    public XMLFormatter(String rootInfo, String rootAttributes){
56        myStack = new Stack();
57        xmlData = new String();
58        xmlData = "<"+rootInfo+" "+rootAttributes+">";
59        hostInfo = rootInfo;
60    }
61
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines