31 |
|
* Takes in one arguement which can contain any valid non xml character ( "<",">" ) |
32 |
|
* an example for rootInfo would be "Host" |
33 |
|
*/ |
34 |
< |
public XMLFormatter(String rootInfo){ |
34 |
> |
public XMLFormatter(String rootInfo, String attributes){ |
35 |
|
|
36 |
|
myStack = new Stack(); |
37 |
|
xmlData = new String(); |
38 |
+ |
xmlData = "<"+rootInfo+" "+attributes+">"; |
39 |
+ |
hostInfo = rootInfo; |
40 |
+ |
} |
41 |
+ |
|
42 |
+ |
/** |
43 |
+ |
* Public Constructor for the class |
44 |
+ |
* Takes in one arguement which can contain any valid non xml character ( "<",">" ) |
45 |
+ |
* an example for rootInfo would be "Host" |
46 |
+ |
*/ |
47 |
+ |
public XMLFormatter(String rootInfo){ |
48 |
+ |
myStack = new Stack(); |
49 |
+ |
xmlData = new String(); |
50 |
|
xmlData = "<"+rootInfo+">"; |
51 |
|
hostInfo = rootInfo; |
52 |
|
} |
61 |
|
hostInfo = null; |
62 |
|
} |
63 |
|
|
52 |
– |
|
64 |
|
//---PUBLIC METHODS--- |
65 |
|
|
66 |
|
/** |
67 |
+ |
* addEement, adds an element to the XML string with attributes |
68 |
+ |
* |
69 |
+ |
*/ |
70 |
+ |
public void addElement(String name, String attributes, String value){ |
71 |
+ |
// check that the strings contain valid data first |
72 |
+ |
if (( name.length() != 0 ) && ( value.length() != 0 )){ |
73 |
+ |
xmlData += "<"+name+" "+attributes+">"+value+"</"+name+">"; |
74 |
+ |
} |
75 |
+ |
} |
76 |
+ |
|
77 |
+ |
/** |
78 |
|
* addEement, adds an element to the XML string |
79 |
|
* |
80 |
|
*/ |
94 |
|
xmlData += "<"+name+">"; |
95 |
|
myStack.push(name); |
96 |
|
} |
97 |
+ |
|
98 |
+ |
/** |
99 |
+ |
* addString, adds a string into the XML packet no further processing is carried out |
100 |
+ |
*/ |
101 |
+ |
public void addString(String name){ |
102 |
+ |
xmlData += name; |
103 |
+ |
} |
104 |
+ |
|
105 |
|
|
106 |
|
/** |
107 |
|
* closeNest will close the currently opened nest (by writing </nest name> to |