Jacson

de.spieleck.config
Class ConfigNodeImpl

java.lang.Object
  extended byde.spieleck.config.ConfigNodeImpl
All Implemented Interfaces:
ConfigNode, java.io.Serializable
Direct Known Subclasses:
ConfigFileNode

public class ConfigNodeImpl
extends java.lang.Object
implements ConfigNode

Basic Data container in a Config environment.

Not that most enhanced classes will be subnodes of this or otherwise have to do a reimplementation of many methods

Version:
?
Author:
fsn
See Also:
Serialized Form

Nested Class Summary
protected  class ConfigNodeImpl.ConfigIterator
           
 
Field Summary
protected  java.util.List children
          And cound your children!
protected  java.lang.String name
          Node name
protected  ConfigNode parent
          Remember your parent(s), boy
static char PATHSEP
          Separator for path strings used in the Config-System
protected  ConfigParamMap pm
          A Parameter-Mapping class
protected  int sourceLine
          Source line for this node
protected  java.lang.String value
          Node value
 
Constructor Summary
ConfigNodeImpl(java.lang.String name, java.lang.String value, ConfigParamMap pm)
          Create a ConfigNodeImplementation.
ConfigNodeImpl(java.lang.String name, java.lang.String value, ConfigParamMap pm, int line)
          Create a ConfigNodeImplementation.
 
Method Summary
 ConfigNodeImpl addChild(ConfigNodeImpl child)
          add a child to this node and
 ConfigNodeImpl addChild(java.lang.String name, java.lang.String value)
          create a new child add it to this node and
 ConfigNodeImpl addChild(java.lang.String name, java.lang.String value, int line)
          create a new child add it to this node and
 java.util.Iterator children()
          Enumerate my children.
 java.util.Iterator childrenNamed(java.lang.String key)
          Enumerate children of me, having a certain name.
 void copyChildren(ConfigNode next)
           
 int countChildren()
          Count the number of children we have.
 int countChildrenNamed(java.lang.String key)
          Count the number of children we have.
 boolean getBoolean()
          Get (expanded) value as a boolean.
 boolean getBoolean(java.lang.String path, boolean deflt)
          Get (expanded) value of subnode as boolean, using default if necessary.
 ConfigFileNode getBranchNode()
          Getting the node responsible for reading the file.
 double getDouble()
          Get (expanded) value as a double.
 double getDouble(java.lang.String path, double deflt)
          Get (expanded) value of subnode as double, using default when necessary.
 boolean getInhBoolean(java.lang.String path, boolean deflt)
          Get (expanded) value of subnode as boolean searching parent nodes before using default.
 double getInhDouble(java.lang.String path, double deflt)
          Get (expanded) value of subnode as double searching parent nodes before using default.
 int getInhInt(java.lang.String path, int deflt)
          Get (expanded) value of subnode as int searching parent nodes before using default.
 java.lang.String getInhString(java.lang.String path, java.lang.String deflt)
          Get (expanded) value of subnode as String searching parent nodes before using default.
 int getInt()
          Get (expanded) value as an integer.
 int getInt(java.lang.String path, int deflt)
          Get (expanded) value of subnode as integer, using default when necessary.
 java.lang.String getName()
          Get the name of the node.
 ConfigNode getParent()
          Get the node above.
 java.lang.String getPath()
          Get the complete path of the node.
 java.lang.String getSourceDescription()
          Get something describing the source location of this node.
 java.lang.String getSourceFileName()
           
 int getSourceLine()
           
 java.lang.String getString()
          Get (expanded) value as String.
 java.lang.String getString(java.lang.String path, java.lang.String deflt)
          Get (expanded) value of subnode as String, using default when necessary.
 java.lang.String getUnexpanded()
          Get (expanded) value as String.
protected  java.lang.String getValue()
           
 ConfigNode node(java.lang.String path)
          Find the very first child, grandchild, ... that matches a path!
 ConfigNode nodeInh(java.lang.String path)
          Find the very first child of this node or a parent fullfilling the path.
 void printXML(java.io.PrintWriter os)
          Print a XML represenation of this node.
protected  void setParent(ConfigNode p)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PATHSEP

public static final char PATHSEP
Separator for path strings used in the Config-System

See Also:
Constant Field Values

parent

protected ConfigNode parent
Remember your parent(s), boy


children

protected java.util.List children
And cound your children!


name

protected java.lang.String name
Node name


value

protected java.lang.String value
Node value


pm

protected ConfigParamMap pm
A Parameter-Mapping class


sourceLine

protected int sourceLine
Source line for this node

Constructor Detail

ConfigNodeImpl

public ConfigNodeImpl(java.lang.String name,
                      java.lang.String value,
                      ConfigParamMap pm)
Create a ConfigNodeImplementation.

Parameters:
name - Name of the node
value - Value of the node
pm - Parameter map used to expand parameter values.

ConfigNodeImpl

public ConfigNodeImpl(java.lang.String name,
                      java.lang.String value,
                      ConfigParamMap pm,
                      int line)
Create a ConfigNodeImplementation.

Parameters:
name - Name of the node
value - Value of the node
pm - Parameter map used to expand parameter values.
line - The source line where the node was generated
Method Detail

getSourceLine

public int getSourceLine()
Returns:
the SourceLine

getSourceFileName

public java.lang.String getSourceFileName()
Returns:
the name of the XML source where this node comes from.

getSourceDescription

public java.lang.String getSourceDescription()
Description copied from interface: ConfigNode
Get something describing the source location of this node.

Specified by:
getSourceDescription in interface ConfigNode

getBranchNode

public ConfigFileNode getBranchNode()
Getting the node responsible for reading the file. This API is used so rarely that we do not keep a member to hold that node any more. We search the node every time we need it.

Specified by:
getBranchNode in interface ConfigNode
Returns:
the node responsible for reading the file.

getName

public java.lang.String getName()
Description copied from interface: ConfigNode
Get the name of the node.

Specified by:
getName in interface ConfigNode
Returns:
the (interned) name of this node

getPath

public java.lang.String getPath()
Description copied from interface: ConfigNode
Get the complete path of the node.

Specified by:
getPath in interface ConfigNode
Returns:
the full path of this path with in the root config.

getUnexpanded

public java.lang.String getUnexpanded()
Description copied from interface: ConfigNode
Get (expanded) value as String.

Specified by:
getUnexpanded in interface ConfigNode
Returns:
the unexpanded value of the node.

getValue

protected java.lang.String getValue()

getParent

public ConfigNode getParent()
Description copied from interface: ConfigNode
Get the node above.

Specified by:
getParent in interface ConfigNode

setParent

protected void setParent(ConfigNode p)

getBoolean

public boolean getBoolean()
Description copied from interface: ConfigNode
Get (expanded) value as a boolean.

Specified by:
getBoolean in interface ConfigNode

getBoolean

public boolean getBoolean(java.lang.String path,
                          boolean deflt)
Description copied from interface: ConfigNode
Get (expanded) value of subnode as boolean, using default if necessary.

Specified by:
getBoolean in interface ConfigNode

getInhBoolean

public boolean getInhBoolean(java.lang.String path,
                             boolean deflt)
Description copied from interface: ConfigNode
Get (expanded) value of subnode as boolean searching parent nodes before using default.

Specified by:
getInhBoolean in interface ConfigNode

getInt

public int getInt()
Description copied from interface: ConfigNode
Get (expanded) value as an integer.

Specified by:
getInt in interface ConfigNode

getInt

public int getInt(java.lang.String path,
                  int deflt)
Description copied from interface: ConfigNode
Get (expanded) value of subnode as integer, using default when necessary.

Specified by:
getInt in interface ConfigNode

getInhInt

public int getInhInt(java.lang.String path,
                     int deflt)
Description copied from interface: ConfigNode
Get (expanded) value of subnode as int searching parent nodes before using default.

Specified by:
getInhInt in interface ConfigNode

getDouble

public double getDouble()
Description copied from interface: ConfigNode
Get (expanded) value as a double.

Specified by:
getDouble in interface ConfigNode

getDouble

public double getDouble(java.lang.String path,
                        double deflt)
Description copied from interface: ConfigNode
Get (expanded) value of subnode as double, using default when necessary.

Specified by:
getDouble in interface ConfigNode

getInhDouble

public double getInhDouble(java.lang.String path,
                           double deflt)
Description copied from interface: ConfigNode
Get (expanded) value of subnode as double searching parent nodes before using default.

Specified by:
getInhDouble in interface ConfigNode

getString

public java.lang.String getString()
Description copied from interface: ConfigNode
Get (expanded) value as String.

Specified by:
getString in interface ConfigNode

getString

public java.lang.String getString(java.lang.String path,
                                  java.lang.String deflt)
Description copied from interface: ConfigNode
Get (expanded) value of subnode as String, using default when necessary.

Specified by:
getString in interface ConfigNode

getInhString

public java.lang.String getInhString(java.lang.String path,
                                     java.lang.String deflt)
Description copied from interface: ConfigNode
Get (expanded) value of subnode as String searching parent nodes before using default.

Specified by:
getInhString in interface ConfigNode

node

public ConfigNode node(java.lang.String path)
Find the very first child, grandchild, ... that matches a path! Node this is fairly involved and not at all fast! But appropriate for setup files in general.

Specified by:
node in interface ConfigNode

nodeInh

public ConfigNode nodeInh(java.lang.String path)
Find the very first child of this node or a parent fullfilling the path.

Specified by:
nodeInh in interface ConfigNode

countChildren

public int countChildren()
Description copied from interface: ConfigNode
Count the number of children we have.

Specified by:
countChildren in interface ConfigNode
Returns:
the number children of this node.

children

public java.util.Iterator children()
Description copied from interface: ConfigNode
Enumerate my children.

Specified by:
children in interface ConfigNode
Returns:
an Iterator over all children of this node.

childrenNamed

public java.util.Iterator childrenNamed(java.lang.String key)
Description copied from interface: ConfigNode
Enumerate children of me, having a certain name.

Specified by:
childrenNamed in interface ConfigNode

countChildrenNamed

public int countChildrenNamed(java.lang.String key)
Description copied from interface: ConfigNode
Count the number of children we have.

Specified by:
countChildrenNamed in interface ConfigNode

copyChildren

public void copyChildren(ConfigNode next)

addChild

public ConfigNodeImpl addChild(java.lang.String name,
                               java.lang.String value,
                               int line)
create a new child add it to this node and

Returns:
the new node.

addChild

public ConfigNodeImpl addChild(java.lang.String name,
                               java.lang.String value)
create a new child add it to this node and

Returns:
the new node.

addChild

public ConfigNodeImpl addChild(ConfigNodeImpl child)
add a child to this node and

Returns:
the new node.

printXML

public void printXML(java.io.PrintWriter os)
              throws java.io.IOException
Print a XML represenation of this node. Caution: Encoding is not properly used, as is quoting of attributes.

Specified by:
printXML in interface ConfigNode
Throws:
java.io.IOException

toString

public java.lang.String toString()

Spieleck

Copyleft 2002 spieleck.de.