common-util

local.tomas.common.dom
Class DomConfiguration

java.lang.Object
  extended by local.tomas.common.dom.DomConfiguration

public class DomConfiguration
extends Object

Configuration data stored in a DOM structure.

Author:
tomas

Field Summary
protected  Node root
          The root node.
 
Constructor Summary
DomConfiguration(File file)
          Construct configuration loaded from file.
DomConfiguration(InputSource in)
          Construct configuration loaded from input source.
DomConfiguration(InputStream in)
          Construct configuration loaded from input stream.
DomConfiguration(Node root)
          Construct configuration with specified root node.
DomConfiguration(URL url)
          Construct configuration loaded from URL.
 
Method Summary
 Attr createAttribute(String name, String value)
          Create attribute of configuration node.
 Element createElement(String tagName)
          Create new configuration element.
 void dump(PrintStream out)
          Write configuration to print stream.
static Node getNode(Node node, String path)
          Get descendant node.
 Node getNode(String path)
          Get DOM node.
static Node[] getNodeArray(Node node, String path)
          Get array of nodes.
 Node[] getNodeArray(String path)
          Get array of nodes.
static Properties getProperties(Node node, String path)
          Load properties from configuration.
 Properties getProperties(String path)
          Get properties.
static DomConfiguration getSubConfiguration(Node node, String path)
          Get subconfiguration.
 DomConfiguration getSubConfiguration(String path)
          Get subconfiguration of this configuration.
static String getValue(Node node, String path)
          Get value.
 String getValue(String path)
          Get value.
static String[] getValueArray(Node node, String path)
          Get array of values.
 String[] getValueArray(String path)
          Get array of values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected Node root
The root node.

Constructor Detail

DomConfiguration

public DomConfiguration(Node root)
Construct configuration with specified root node.

Parameters:
root - the root node

DomConfiguration

public DomConfiguration(URL url)
                 throws IOException,
                        SAXException
Construct configuration loaded from URL.

Parameters:
url - URL to load from
Throws:
IOException
SAXException

DomConfiguration

public DomConfiguration(File file)
                 throws IOException,
                        SAXException
Construct configuration loaded from file.

Parameters:
file - file to load from
Throws:
IOException
SAXException

DomConfiguration

public DomConfiguration(InputStream in)
                 throws SAXException,
                        IOException
Construct configuration loaded from input stream.

Parameters:
in - the input stream
Throws:
SAXException
IOException

DomConfiguration

public DomConfiguration(InputSource in)
                 throws SAXException,
                        IOException
Construct configuration loaded from input source.

Parameters:
in - the input source
Throws:
SAXException
IOException
Method Detail

dump

public void dump(PrintStream out)
Write configuration to print stream.

Parameters:
out - the print stream

createElement

public Element createElement(String tagName)
Create new configuration element.

Parameters:
tagName - tag name of new element
Returns:
the new element

createAttribute

public Attr createAttribute(String name,
                            String value)
Create attribute of configuration node.

Parameters:
name - attribute name
value - attribute value
Returns:
the attribute

getNode

public Node getNode(String path)
Get DOM node.

Parameters:
path - xpath to node
Returns:
the node

getNodeArray

public Node[] getNodeArray(String path)
Get array of nodes.

Parameters:
path - xpath to nodes
Returns:
array of nodes

getNodeArray

public static Node[] getNodeArray(Node node,
                                  String path)
Get array of nodes.

Parameters:
node - root node
path - xpath to nodes
Returns:
array of nodes

getValue

public String getValue(String path)
Get value.

Parameters:
path - xpath to value
Returns:
tne value

getValue

public static String getValue(Node node,
                              String path)
Get value.

Parameters:
node - root for path
path - xpath to value
Returns:

getValueArray

public String[] getValueArray(String path)
Get array of values.

Parameters:
path - xpath to values
Returns:
array of values

getValueArray

public static String[] getValueArray(Node node,
                                     String path)
Get array of values.

Parameters:
node - root for path
path - xpath to values
Returns:
array of values

getNode

public static Node getNode(Node node,
                           String path)
Get descendant node.

Parameters:
node - root for path
path - xpath to descendant
Returns:
descendant node

getSubConfiguration

public static DomConfiguration getSubConfiguration(Node node,
                                                   String path)
Get subconfiguration.

Parameters:
node - root for path
path - xpath to subconfiguration
Returns:
subconfiguration

getSubConfiguration

public DomConfiguration getSubConfiguration(String path)
Get subconfiguration of this configuration.

Parameters:
path - xpath to subconfiguration
Returns:
subconfiguration

getProperties

public static Properties getProperties(Node node,
                                       String path)
Load properties from configuration.

Parameters:
node - root of configuration
path - xpath to properties
Returns:
the properties

getProperties

public Properties getProperties(String path)
Get properties.

Parameters:
path - path to properties
Returns:
the properties

common-util

Copyright © 2007 null. All Rights Reserved.