| Revision 76,
1.6 KB
checked in by bmcguffin, 9 years ago
(diff) |
|
Added javadoc for several files.
|
| Line | |
|---|
| 1 | package scriptbuilder.structures; |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * |
|---|
| 5 | * @author Bryan McGuffin |
|---|
| 6 | */ |
|---|
| 7 | public class XMLWriter |
|---|
| 8 | { |
|---|
| 9 | |
|---|
| 10 | /** |
|---|
| 11 | * XML-style opening tag. Example: if given string "my_tag", returns |
|---|
| 12 | * "<my_tag>". |
|---|
| 13 | * |
|---|
| 14 | * @param s the XML element to be included in the tag. |
|---|
| 15 | * @return the properly formatted tag |
|---|
| 16 | */ |
|---|
| 17 | public static String openTag(String s) |
|---|
| 18 | { |
|---|
| 19 | return "<" + s + ">"; |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | /** |
|---|
| 23 | * XML-style closing tag. Example: if given string "my_tag", returns |
|---|
| 24 | * "</my_tag>". |
|---|
| 25 | * |
|---|
| 26 | * @param s the XML element to be included in the tag. |
|---|
| 27 | * @return the properly formatted tag |
|---|
| 28 | */ |
|---|
| 29 | public static String closeTag(String s) |
|---|
| 30 | { |
|---|
| 31 | return "</" + s + ">\n"; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | /** |
|---|
| 35 | * XML-style empty tag. Example: if given string "my_tag", returns |
|---|
| 36 | * "<my_tag/>". |
|---|
| 37 | * |
|---|
| 38 | * @param s the XML element to be included in the tag. |
|---|
| 39 | * @return the properly formatted tag |
|---|
| 40 | */ |
|---|
| 41 | public static String emptyTag(String s) |
|---|
| 42 | { |
|---|
| 43 | return "<" + s + "/>\n"; |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | /** |
|---|
| 47 | * Creates a pair of XML open and close tags to wrap a simple line of data. |
|---|
| 48 | * Useful if only one element need be enclosed in this particular tag. |
|---|
| 49 | * |
|---|
| 50 | * @param s the data to be wrapped |
|---|
| 51 | * @param e the XML element represented by the data |
|---|
| 52 | * @return an XML string of the format <my_tag>some_data_goes_here</my_tag> |
|---|
| 53 | */ |
|---|
| 54 | public static String simpleTag(String s, ELEMENT e) |
|---|
| 55 | { |
|---|
| 56 | String output = ""; |
|---|
| 57 | if (s == null) |
|---|
| 58 | { |
|---|
| 59 | s = ""; |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | output += openTag(e.tag); |
|---|
| 63 | output += s; |
|---|
| 64 | output += closeTag(e.tag); |
|---|
| 65 | |
|---|
| 66 | return output; |
|---|
| 67 | } |
|---|
| 68 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.