|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jrobin.core.XmlTemplate
org.jrobin.core.RrdDefTemplate
public class RrdDefTemplate
Class used to create an arbitrary number of RrdDef
(RRD definition) objects
from a single XML template. XML template can be supplied as an XML InputSource,
XML file or XML formatted string.
Here is an example of a properly formatted XML template with all available options in it (unwanted options can be removed):
<rrd_def> <path>test.rrd</path> <!-- not mandatory --> <start>1000123456</start> <!-- not mandatory --> <step>300</step> <!-- at least one datasource must be supplied --> <datasource> <name>input</name> <type>COUNTER</type> <heartbeat>300</heartbeat> <min>0</min> <max>U</max> </datasource> <datasource> <name>temperature</name> <type>GAUGE</type> <heartbeat>400</heartbeat> <min>U</min> <max>1000</max> </datasource> <!-- at least one archive must be supplied --> <archive> <cf>AVERAGE</cf> <xff>0.5</xff> <steps>1</steps> <rows>600</rows> </archive> <archive> <cf>MAX</cf> <xff>0.6</xff> <steps>6</steps> <rows>7000</rows> </archive> </rrd_def>Notes on the template syntax:
RrdDef
class methods. If you are not sure what some XML tag means, check javadoc
for the corresponding class.
<some_tag>
and
</some_tag>
) can be replaced with
a variable of the following form: ${variable_name}
. Use
setVariable()
methods from the base class to replace template variables with real values
at runtime.Typical usage scenario:
<rrd_def> <path>${path}</path> <step>300</step> ...
RrdDefTemplate t = new RrdDefTemplate(new File(template.xml));
t.setVariable("path", "demo/test.rrd");
RrdDef def = t.getRrdDef(); RrdDb rrd = new RrdDb(def); rrd.close();
Field Summary |
---|
Fields inherited from class org.jrobin.core.XmlTemplate |
---|
root |
Constructor Summary | |
---|---|
RrdDefTemplate(java.io.File xmlFile)
Creates RrdDefTemplate object from the file containing XML template. |
|
RrdDefTemplate(org.xml.sax.InputSource xmlInputSource)
Creates RrdDefTemplate object from any parsable XML input source. |
|
RrdDefTemplate(java.lang.String xmlString)
Creates RrdDefTemplate object from the string containing XML template. |
Method Summary | |
---|---|
RrdDef |
getRrdDef()
Returns RrdDef object constructed from the underlying XML template. |
Methods inherited from class org.jrobin.core.XmlTemplate |
---|
clearValues, getChildNodes, getChildNodes, getChildValue, getChildValue, getChildValueAsBoolean, getChildValueAsDouble, getChildValueAsInt, getChildValueAsLong, getFirstChildNode, getValue, getValue, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsLong, getVariables, hasChildNode, hasVariables, isEmptyNode, setVariable, setVariable, setVariable, setVariable, setVariable, setVariable, setVariable, setVariable, validateTagsOnlyOnce |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RrdDefTemplate(org.xml.sax.InputSource xmlInputSource) throws java.io.IOException, RrdException
xmlInputSource
- Xml input source
java.io.IOException
- Thrown in case of I/O error
RrdException
- Thrown in case of XML related error (parsing error, for example)public RrdDefTemplate(java.lang.String xmlString) throws java.io.IOException, RrdException
xmlString
- String containing XML template
java.io.IOException
- Thrown in case of I/O error
RrdException
- Thrown in case of XML related error (parsing error, for example)public RrdDefTemplate(java.io.File xmlFile) throws java.io.IOException, RrdException
xmlFile
- File object representing file with XML template
java.io.IOException
- Thrown in case of I/O error
RrdException
- Thrown in case of XML related error (parsing error, for example)Method Detail |
---|
public RrdDef getRrdDef() throws RrdException
setVariable()
methods. Once this method
returns, all placeholder values are preserved. To remove them all, call inhereted
clearValues()
method explicitly.
RrdException
- Thrown (in most cases) if the value for some placeholder
was not supplied through setVariable()
method call
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |