Package org.rrd4j.core
Class XmlTemplate
java.lang.Object
org.rrd4j.core.XmlTemplate
- Direct Known Subclasses:
RrdDefTemplate
Class used as a base class for various XML template related classes. Class provides
methods for XML source parsing and XML tree traversing. XML source may have unlimited
number of placeholders (variables) in the format
${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.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedXmlTemplate(File xmlFile) Constructor for XmlTemplate.protectedXmlTemplate(String xmlString) Constructor for XmlTemplate.protectedXmlTemplate(InputSource xmlSource) Constructor for XmlTemplate. -
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves all placeholder-value mappings.protected static Node[]getChildNodes(Node parentNode) getChildNodes.protected static Node[]getChildNodes(Node parentNode, String childName) getChildNodes.protected StringgetChildValue(Node parentNode, String childName) getChildValue.protected StringgetChildValue(Node parentNode, String childName, boolean trim) getChildValue.protected booleangetChildValueAsBoolean(Node parentNode, String childName) getChildValueAsBoolean.protected doublegetChildValueAsDouble(Node parentNode, String childName) getChildValueAsDouble.protected intgetChildValueAsInt(Node parentNode, String childName) getChildValueAsInt.protected longgetChildValueAsLong(Node parentNode, String childName) getChildValueAsLong.protected static NodegetFirstChildNode(Node parentNode, String childName) getFirstChildNode.protected StringgetValue.protected StringgetValue.protected booleangetValueAsBoolean(Node parentNode) getValueAsBoolean.protected PaintgetValueAsColor(Node parentNode) getValueAsColor.protected doublegetValueAsDouble(Node parentNode) getValueAsDouble.protected intgetValueAsInt(Node parentNode) getValueAsInt.protected longgetValueAsLong(Node parentNode) getValueAsLong.String[]Returns the list of variables that should be set in this template.protected booleanhasChildNode(Node parentNode, String childName) hasChildNode.booleanSearches the XML template to see if there are variables in there that will need to be set.protected booleanisEmptyNode(Node node) isEmptyNode.voidsetVariable(String name, boolean value) Sets value for a single XML template variable.voidsetVariable(String name, double value) Sets value for a single XML template variable.voidsetVariable(String name, int value) Sets value for a single XML template variable.voidsetVariable(String name, long value) Sets value for a single XML template variable.voidsetVariable(String name, Color value) Sets value for a single XML template variable.voidsetVariable(String name, String value) Sets value for a single XML template variable.voidsetVariable(String name, Calendar value) Sets value for a single XML template variable.voidsetVariable(String name, Date value) Sets value for a single XML template variable.protected voidvalidateTagsOnlyOnce(Node parentNode, String[] allowedChildNames) validateTagsOnlyOnce.
-
Field Details
-
root
-
-
Constructor Details
-
XmlTemplate
Constructor for XmlTemplate.
- Parameters:
xmlSource- aInputSourceobject.- Throws:
IOException- if any.
-
XmlTemplate
Constructor for XmlTemplate.
- Parameters:
xmlString- aStringobject.- Throws:
IOException- if any.
-
XmlTemplate
Constructor for XmlTemplate.
- Parameters:
xmlFile- aFileobject.- Throws:
IOException- if any.
-
-
Method Details
-
clearValues
public void clearValues()Removes all placeholder-value mappings. -
setVariable
Sets value for a single XML template variable. Variable name should be specified without leading '${' and ending '}' placeholder markers. For example, for a placeholder${start}, specifystartfor thenameparameter.- Parameters:
name- variable namevalue- value to be set in the XML template
-
setVariable
Sets value for a single XML template variable. Variable name should be specified without leading '${' and ending '}' placeholder markers. For example, for a placeholder${start}, specifystartfor thenameparameter.- Parameters:
name- variable namevalue- value to be set in the XML template
-
setVariable
Sets value for a single XML template variable. Variable name should be specified without leading '${' and ending '}' placeholder markers. For example, for a placeholder${start}, specifystartfor thenameparameter.- Parameters:
name- variable namevalue- value to be set in the XML template
-
setVariable
Sets value for a single XML template variable. Variable name should be specified without leading '${' and ending '}' placeholder markers. For example, for a placeholder${start}, specifystartfor thenameparameter.- Parameters:
name- variable namevalue- value to be set in the XML template
-
setVariable
Sets value for a single XML template variable. Variable name should be specified without leading '${' and ending '}' placeholder markers. For example, for a placeholder${start}, specifystartfor thenameparameter.- Parameters:
name- variable namevalue- value to be set in the XML template
-
setVariable
Sets value for a single XML template variable. Variable name should be specified without leading '${' and ending '}' placeholder markers. For example, for a placeholder${start}, specifystartfor thenameparameter.- Parameters:
name- variable namevalue- value to be set in the XML template
-
setVariable
Sets value for a single XML template variable. Variable name should be specified without leading '${' and ending '}' placeholder markers. For example, for a placeholder${start}, specifystartfor thenameparameter.- Parameters:
name- variable namevalue- value to be set in the XML template
-
setVariable
Sets value for a single XML template variable. Variable name should be specified without leading '${' and ending '}' placeholder markers. For example, for a placeholder${start}, specifystartfor thenameparameter.- Parameters:
name- variable namevalue- value to be set in the XML template
-
hasVariables
public boolean hasVariables()Searches the XML template to see if there are variables in there that will need to be set.- Returns:
- True if variables were detected, false if not.
-
getVariables
Returns the list of variables that should be set in this template.- Returns:
- List of variable names as an array of strings.
-
getChildNodes
getChildNodes.
-
getChildNodes
getChildNodes.
-
getFirstChildNode
getFirstChildNode.
-
hasChildNode
hasChildNode.
-
getChildValue
getChildValue.
-
getChildValue
getChildValue.
-
getValue
getValue.
-
getValue
getValue.
-
getChildValueAsInt
getChildValueAsInt. -
getValueAsInt
getValueAsInt.- Parameters:
parentNode- aNodeobject.- Returns:
- a int.
-
getChildValueAsLong
getChildValueAsLong. -
getValueAsLong
getValueAsLong.- Parameters:
parentNode- aNodeobject.- Returns:
- a long.
-
getChildValueAsDouble
getChildValueAsDouble. -
getValueAsDouble
getValueAsDouble.- Parameters:
parentNode- aNodeobject.- Returns:
- a double.
-
getChildValueAsBoolean
getChildValueAsBoolean. -
getValueAsBoolean
getValueAsBoolean.- Parameters:
parentNode- aNodeobject.- Returns:
- a boolean.
-
getValueAsColor
getValueAsColor. -
isEmptyNode
isEmptyNode.- Parameters:
node- aNodeobject.- Returns:
- a boolean.
-
validateTagsOnlyOnce
validateTagsOnlyOnce.
-