|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.rrd4j.core.XmlTemplate
public abstract class XmlTemplate
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 | |
---|---|
protected Element |
root
|
Constructor Summary | |
---|---|
protected |
XmlTemplate(File xmlFile)
|
protected |
XmlTemplate(InputSource xmlSource)
|
protected |
XmlTemplate(String xmlString)
|
Method Summary | |
---|---|
void |
clearValues()
Removes all placeholder-value mappings. |
protected static Node[] |
getChildNodes(Node parentNode)
|
protected static Node[] |
getChildNodes(Node parentNode,
String childName)
|
protected String |
getChildValue(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 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)
|
String[] |
getVariables()
Returns the list of variables that should be set in this template. |
protected boolean |
hasChildNode(Node parentNode,
String childName)
|
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)
|
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Element root
Constructor Detail |
---|
protected XmlTemplate(InputSource xmlSource) throws IOException
IOException
protected XmlTemplate(String xmlString) throws IOException
IOException
protected XmlTemplate(File xmlFile) throws IOException
IOException
Method Detail |
---|
public void clearValues()
public void setVariable(String name, String 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, double 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, Calendar value)
${start}
, specify start
for the name
parameter.
name
- variable namevalue
- value to be set in the XML templatepublic void setVariable(String name, boolean value)
${start}
, specify start
for the name
parameter.
name
- variable namevalue
- value to be set in the XML templatepublic boolean hasVariables()
public String[] getVariables()
protected static Node[] getChildNodes(Node parentNode, String childName)
protected static Node[] getChildNodes(Node parentNode)
protected static Node getFirstChildNode(Node parentNode, String childName)
protected boolean hasChildNode(Node parentNode, String childName)
protected String getChildValue(Node parentNode, String childName)
protected String getChildValue(Node parentNode, String childName, boolean trim)
protected String getValue(Node parentNode)
protected String getValue(Node parentNode, boolean trim)
protected int getChildValueAsInt(Node parentNode, String childName)
protected int getValueAsInt(Node parentNode)
protected long getChildValueAsLong(Node parentNode, String childName)
protected long getValueAsLong(Node parentNode)
protected double getChildValueAsDouble(Node parentNode, String childName)
protected double getValueAsDouble(Node parentNode)
protected boolean getChildValueAsBoolean(Node parentNode, String childName)
protected boolean getValueAsBoolean(Node parentNode)
protected Paint getValueAsColor(Node parentNode)
protected boolean isEmptyNode(Node node)
protected void validateTagsOnlyOnce(Node parentNode, String[] allowedChildNames)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |