package scriptbuilder.structures;
/**
*
* @author Bryan McGuffin
*/
public class XMLWriter
{
/**
* XML-style opening tag. Example: if given string "my_tag", returns
* "".
*
* @param s the XML element to be included in the tag.
* @return the properly formatted tag
*/
public static String openTag(String s)
{
return "<" + s + ">";
}
/**
* XML-style closing tag. Example: if given string "my_tag", returns
* "".
*
* @param s the XML element to be included in the tag.
* @return the properly formatted tag
*/
public static String closeTag(String s)
{
return "" + s + ">\n";
}
/**
* XML-style empty tag. Example: if given string "my_tag", returns
* "".
*
* @param s the XML element to be included in the tag.
* @return the properly formatted tag
*/
public static String emptyTag(String s)
{
return "<" + s + "/>\n";
}
/**
* Creates a pair of XML open and close tags to wrap a simple line of data.
* Useful if only one element need be enclosed in this particular tag.
*
* @param s the data to be wrapped
* @param e the XML element represented by the data
* @return an XML string of the format some_data_goes_here
*/
public static String simpleTag(String s, ELEMENT e)
{
String output = "";
if (s == null)
{
s = "";
}
output += openTag(e.tag);
output += s;
output += closeTag(e.tag);
return output;
}
}