public abstract class XmlTemplate extends Object
${variable_name}. Methods are provided to specify variable
values at runtime. Note that this class has limited functionality: XML source gets parsed, and
variable values are collected. You have to extend this class to do something more useful.| Modifier | Constructor and Description |
|---|---|
protected |
XmlTemplate(File xmlFile)
Constructor for XmlTemplate.
|
protected |
XmlTemplate(InputSource xmlSource)
Constructor for XmlTemplate.
|
protected |
XmlTemplate(String xmlString)
Constructor for XmlTemplate.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearValues()
Removes all placeholder-value mappings.
|
protected static Node[] |
getChildNodes(Node parentNode)
getChildNodes.
|
protected static Node[] |
getChildNodes(Node parentNode,
String childName)
getChildNodes.
|
protected String |
getChildValue(Node parentNode,
String childName)
getChildValue.
|
protected String |
getChildValue(Node parentNode,
String childName,
boolean trim)
getChildValue.
|
protected boolean |
getChildValueAsBoolean(Node parentNode,
String childName)
getChildValueAsBoolean.
|
protected double |
getChildValueAsDouble(Node parentNode,
String childName)
getChildValueAsDouble.
|
protected int |
getChildValueAsInt(Node parentNode,
String childName)
getChildValueAsInt.
|
protected long |
getChildValueAsLong(Node parentNode,
String childName)
getChildValueAsLong.
|
protected static Node |
getFirstChildNode(Node parentNode,
String childName)
getFirstChildNode.
|
protected String |
getValue(Node parentNode)
getValue.
|
protected String |
getValue(Node parentNode,
boolean trim)
getValue.
|
protected boolean |
getValueAsBoolean(Node parentNode)
getValueAsBoolean.
|
protected Paint |
getValueAsColor(Node parentNode)
getValueAsColor.
|
protected double |
getValueAsDouble(Node parentNode)
getValueAsDouble.
|
protected int |
getValueAsInt(Node parentNode)
getValueAsInt.
|
protected long |
getValueAsLong(Node parentNode)
getValueAsLong.
|
String[] |
getVariables()
Returns the list of variables that should be set in this template.
|
protected boolean |
hasChildNode(Node parentNode,
String childName)
hasChildNode.
|
boolean |
hasVariables()
Searches the XML template to see if there are variables in there that will need to be set.
|
protected boolean |
isEmptyNode(Node node)
isEmptyNode.
|
void |
setVariable(String name,
boolean value)
Sets value for a single XML template variable.
|
void |
setVariable(String name,
Calendar value)
Sets value for a single XML template variable.
|
void |
setVariable(String name,
Color value)
Sets value for a single XML template variable.
|
void |
setVariable(String name,
Date value)
Sets value for a single XML template variable.
|
void |
setVariable(String name,
double value)
Sets value for a single XML template variable.
|
void |
setVariable(String name,
int value)
Sets value for a single XML template variable.
|
void |
setVariable(String name,
long value)
Sets value for a single XML template variable.
|
void |
setVariable(String name,
String value)
Sets value for a single XML template variable.
|
protected void |
validateTagsOnlyOnce(Node parentNode,
String[] allowedChildNames)
validateTagsOnlyOnce.
|
protected Element root
protected XmlTemplate(File xmlFile) throws IOException
xmlFile - a File object.IOException - if any.protected XmlTemplate(InputSource xmlSource) throws IOException
xmlSource - a InputSource object.IOException - if any.protected XmlTemplate(String xmlString) throws IOException
xmlString - a String object.IOException - if any.public void clearValues()
protected static Node[] getChildNodes(Node parentNode, String childName)
protected String getChildValue(Node parentNode, String childName, boolean trim)
protected boolean getChildValueAsBoolean(Node parentNode, String childName)
protected double getChildValueAsDouble(Node parentNode, String childName)
protected int getChildValueAsInt(Node parentNode, String childName)
protected long getChildValueAsLong(Node parentNode, String childName)
protected static Node getFirstChildNode(Node parentNode, String childName)
protected boolean getValueAsBoolean(Node parentNode)
parentNode - a Node object.protected double getValueAsDouble(Node parentNode)
parentNode - a Node object.protected int getValueAsInt(Node parentNode)
parentNode - a Node object.protected long getValueAsLong(Node parentNode)
parentNode - a Node object.public String[] getVariables()
public boolean hasVariables()
protected boolean isEmptyNode(Node node)
node - a Node object.public void setVariable(String name, boolean value)
${start}, specify start for the name parameter.name - variable namevalue - value to be set in the XML templatepublic void setVariable(String name, Calendar value)
${start}, specify start for the name parameter.name - variable namevalue - value to be set in the XML templatepublic void setVariable(String name, Color value)
${start}, specify start for the name parameter.name - variable namevalue - value to be set in the XML templatepublic void setVariable(String name, Date value)
${start}, specify start for the name parameter.name - variable namevalue - value to be set in the XML templatepublic void setVariable(String name, double value)
${start}, specify start for the name parameter.name - variable namevalue - value to be set in the XML templatepublic void setVariable(String name, int value)
${start}, specify start for the name parameter.name - variable namevalue - value to be set in the XML templatepublic void setVariable(String name, long value)
${start}, specify start for the name parameter.name - variable namevalue - value to be set in the XML templatepublic void setVariable(String name, String value)
${start}, specify start for the name parameter.name - variable namevalue - value to be set in the XML template