XmlTemplate
Keywords: org.jrobin.core.XmlTemplate class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jrobin.core
Class XmlTemplate

    java.lang.Object
      org.jrobin.core.XmlTemplate

Direct Known Subclasses:
  RrdDefTemplate, RrdExportDefTemplate, RrdGraphDefTemplate

public abstract class XmlTemplate
extends java.lang.Object

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 org.w3c.dom.Element` | `root`

Constructor Summary
`protected` | `XmlTemplate(java.io.File xmlFile)`
`protected` | `XmlTemplate(org.xml.sax.InputSource xmlSource)`
`protected` | `XmlTemplate(java.lang.String xmlString)`

Method Summary
`void` | `clearValues()` Removes all placeholder-value mappings.
`protected static org.w3c.dom.Node[]` | `getChildNodes(org.w3c.dom.Node parentNode)`
`protected static org.w3c.dom.Node[]` | `getChildNodes(org.w3c.dom.Node parentNode, java.lang.String childName)`
`protected java.lang.String` | `getChildValue(org.w3c.dom.Node parentNode, java.lang.String childName)`
`protected java.lang.String` | `getChildValue(org.w3c.dom.Node parentNode, java.lang.String childName, boolean trim)`
`protected boolean` | `getChildValueAsBoolean(org.w3c.dom.Node parentNode, java.lang.String childName)`
`protected double` | `getChildValueAsDouble(org.w3c.dom.Node parentNode, java.lang.String childName)`
`protected int` | `getChildValueAsInt(org.w3c.dom.Node parentNode, java.lang.String childName)`
`protected long` | `getChildValueAsLong(org.w3c.dom.Node parentNode, java.lang.String childName)`
`protected static org.w3c.dom.Node` | `getFirstChildNode(org.w3c.dom.Node parentNode, java.lang.String childName)`
`protected java.lang.String` | `getValue(org.w3c.dom.Node parentNode)`
`protected java.lang.String` | `getValue(org.w3c.dom.Node parentNode, boolean trim)`
`protected boolean` | `getValueAsBoolean(org.w3c.dom.Node parentNode)`
`protected double` | `getValueAsDouble(org.w3c.dom.Node parentNode)`
`protected int` | `getValueAsInt(org.w3c.dom.Node parentNode)`
`protected long` | `getValueAsLong(org.w3c.dom.Node parentNode)`
`java.lang.String[]` | `getVariables()` Returns the list of variables that should be set in this template.
`protected boolean` | `hasChildNode(org.w3c.dom.Node parentNode, java.lang.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(org.w3c.dom.Node node)`
`void` | `setVariable(java.lang.String name, boolean value)` Sets value for a single XML template variable.
`void` | `setVariable(java.lang.String name, java.awt.Color value)` Sets value for a single XML template variable.
`void` | `setVariable(java.lang.String name, java.util.Date value)` Sets value for a single XML template variable.
`void` | `setVariable(java.lang.String name, double value)` Sets value for a single XML template variable.
`void` | `setVariable(java.lang.String name, java.util.GregorianCalendar value)` Sets value for a single XML template variable.
`void` | `setVariable(java.lang.String name, int value)` Sets value for a single XML template variable.
`void` | `setVariable(java.lang.String name, long value)` Sets value for a single XML template variable.
`void` | `setVariable(java.lang.String name, java.lang.String value)` Sets value for a single XML template variable.
`protected void` | `validateTagsOnlyOnce(org.w3c.dom.Node parentNode, java.lang.String[] allowedChildNames)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### root

    protected org.w3c.dom.Element root

Constructor Detail

### XmlTemplate

    protected XmlTemplate(org.xml.sax.InputSource xmlSource)
                   throws java.io.IOException,
                          RrdException

### XmlTemplate

    protected XmlTemplate(java.lang.String xmlString)
                   throws java.io.IOException,
                          RrdException

### XmlTemplate

    protected XmlTemplate(java.io.File xmlFile)
                   throws java.io.IOException,
                          RrdException

Method Detail

### clearValues

    public void clearValues()

  Removes all placeholder-value mappings.

### setVariable

    public void setVariable(java.lang.String name,
                            java.lang.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

### setVariable

    public void setVariable(java.lang.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

### setVariable

    public void setVariable(java.lang.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

### setVariable

    public void setVariable(java.lang.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

### setVariable

    public void setVariable(java.lang.String name,
                            java.awt.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

### setVariable

    public void setVariable(java.lang.String name,
                            java.util.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

### setVariable

    public void setVariable(java.lang.String name,
                            java.util.GregorianCalendar 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

### setVariable

    public void setVariable(java.lang.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

### 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

    public java.lang.String[] getVariables()

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

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

### getChildNodes

    protected static org.w3c.dom.Node[] getChildNodes(org.w3c.dom.Node parentNode,
                                                      java.lang.String childName)

### getChildNodes

    protected static org.w3c.dom.Node[] getChildNodes(org.w3c.dom.Node parentNode)

### getFirstChildNode

    protected static org.w3c.dom.Node getFirstChildNode(org.w3c.dom.Node parentNode,
                                                        java.lang.String childName)
                                                 throws RrdException

  Throws:
    `RrdException`

### hasChildNode

    protected boolean hasChildNode(org.w3c.dom.Node parentNode,
                                   java.lang.String childName)

### getChildValue

    protected java.lang.String getChildValue(org.w3c.dom.Node parentNode,
                                             java.lang.String childName)
                                      throws RrdException

  Throws:
    `RrdException`

### getChildValue

    protected java.lang.String getChildValue(org.w3c.dom.Node parentNode,
                                             java.lang.String childName,
                                             boolean trim)
                                      throws RrdException

  Throws:
    `RrdException`

### getValue

    protected java.lang.String getValue(org.w3c.dom.Node parentNode)

### getValue

    protected java.lang.String getValue(org.w3c.dom.Node parentNode,
                                        boolean trim)

### getChildValueAsInt

    protected int getChildValueAsInt(org.w3c.dom.Node parentNode,
                                     java.lang.String childName)
                              throws RrdException

  Throws:
    `RrdException`

### getValueAsInt

    protected int getValueAsInt(org.w3c.dom.Node parentNode)

### getChildValueAsLong

    protected long getChildValueAsLong(org.w3c.dom.Node parentNode,
                                       java.lang.String childName)
                                throws RrdException

  Throws:
    `RrdException`

### getValueAsLong

    protected long getValueAsLong(org.w3c.dom.Node parentNode)

### getChildValueAsDouble

    protected double getChildValueAsDouble(org.w3c.dom.Node parentNode,
                                           java.lang.String childName)
                                    throws RrdException

  Throws:
    `RrdException`

### getValueAsDouble

    protected double getValueAsDouble(org.w3c.dom.Node parentNode)

### getChildValueAsBoolean

    protected boolean getChildValueAsBoolean(org.w3c.dom.Node parentNode,
                                             java.lang.String childName)
                                      throws RrdException

  Throws:
    `RrdException`

### getValueAsBoolean

    protected boolean getValueAsBoolean(org.w3c.dom.Node parentNode)

### isEmptyNode

    protected boolean isEmptyNode(org.w3c.dom.Node node)

### validateTagsOnlyOnce

    protected void validateTagsOnlyOnce(org.w3c.dom.Node parentNode,
                                        java.lang.String[] allowedChildNames)
                                 throws RrdException

  Throws:
    `RrdException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD