public abstract class

XmlTemplate

extends Object
java.lang.Object
   ↳ org.rrd4j.core.XmlTemplate
Known Direct Subclasses

Class Overview

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.

Summary

Fields
protected Element root
Protected Constructors
XmlTemplate(InputSource xmlSource)
XmlTemplate(String xmlString)
XmlTemplate(File xmlFile)
Public Methods
void clearValues()
Removes all placeholder-value mappings.
String[] getVariables()
Returns the list of variables that should be set in this template.
boolean hasVariables()
Searches the XML template to see if there are variables in there that will need to be set.
void setVariable(String name, int value)
Sets value for a single XML template variable.
void setVariable(String name, boolean 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, long 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, String value)
Sets value for a single XML template variable.
void setVariable(String name, Calendar value)
Sets value for a single XML template variable.
Protected Methods
static Node[] getChildNodes(Node parentNode)
static Node[] getChildNodes(Node parentNode, String childName)
String getChildValue(Node parentNode, String childName, boolean trim)
String getChildValue(Node parentNode, String childName)
boolean getChildValueAsBoolean(Node parentNode, String childName)
double getChildValueAsDouble(Node parentNode, String childName)
int getChildValueAsInt(Node parentNode, String childName)
long getChildValueAsLong(Node parentNode, String childName)
static Node getFirstChildNode(Node parentNode, String childName)
String getValue(Node parentNode)
String getValue(Node parentNode, boolean trim)
boolean getValueAsBoolean(Node parentNode)
Paint getValueAsColor(Node parentNode)
double getValueAsDouble(Node parentNode)
int getValueAsInt(Node parentNode)
long getValueAsLong(Node parentNode)
boolean hasChildNode(Node parentNode, String childName)
boolean isEmptyNode(Node node)
void validateTagsOnlyOnce(Node parentNode, String[] allowedChildNames)
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected Element root

Protected Constructors

protected XmlTemplate (InputSource xmlSource)

Throws
IOException

protected XmlTemplate (String xmlString)

Throws
IOException

protected XmlTemplate (File xmlFile)

Throws
IOException

Public Methods

public void clearValues ()

Removes all placeholder-value mappings.

public String[] getVariables ()

Returns the list of variables that should be set in this template.

Returns
  • List of variable names as an array of strings.

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.

public void setVariable (String name, int value)

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}, specify start for the name parameter.

Parameters
name variable name
value value to be set in the XML template

public void setVariable (String name, boolean value)

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}, specify start for the name parameter.

Parameters
name variable name
value value to be set in the XML template

public void setVariable (String name, double value)

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}, specify start for the name parameter.

Parameters
name variable name
value value to be set in the XML template

public void setVariable (String name, long value)

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}, specify start for the name parameter.

Parameters
name variable name
value value to be set in the XML template

public void setVariable (String name, Color value)

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}, specify start for the name parameter.

Parameters
name variable name
value value to be set in the XML template

public void setVariable (String name, Date value)

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}, specify start for the name parameter.

Parameters
name variable name
value value to be set in the XML template

public void setVariable (String name, String value)

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}, specify start for the name parameter.

Parameters
name variable name
value value to be set in the XML template

public void setVariable (String name, Calendar value)

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}, specify start for the name parameter.

Parameters
name variable name
value value to be set in the XML template

Protected Methods

protected static Node[] getChildNodes (Node parentNode)

protected static Node[] getChildNodes (Node parentNode, String childName)

protected String getChildValue (Node parentNode, String childName, boolean trim)

protected String getChildValue (Node parentNode, String childName)

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 String getValue (Node parentNode)

protected String getValue (Node parentNode, boolean trim)

protected boolean getValueAsBoolean (Node parentNode)

protected Paint getValueAsColor (Node parentNode)

protected double getValueAsDouble (Node parentNode)

protected int getValueAsInt (Node parentNode)

protected long getValueAsLong (Node parentNode)

protected boolean hasChildNode (Node parentNode, String childName)

protected boolean isEmptyNode (Node node)

protected void validateTagsOnlyOnce (Node parentNode, String[] allowedChildNames)