More information


de.spieleck.config
Class ConfigNodeImpl

java.lang.Object
  |
  +--de.spieleck.config.ConfigNodeImpl
All Implemented Interfaces:
ConfigNode
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


Inner 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
           
protected  ConfigParamMap pm
          A Parameter-Mapping class
protected  java.lang.String value
          Node value
 
Constructor Summary
ConfigNodeImpl(java.lang.String name, java.lang.String value, ConfigParamMap pm)
           
 
Method Summary
 ConfigNodeImpl addChild(ConfigNodeImpl child)
           
 ConfigNodeImpl addChild(java.lang.String name, java.lang.String value)
           
 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 value as a boolean.
 boolean getBoolean(java.lang.String path, boolean deflt)
          Get value of subnode as boolean, using default if necessary.
 ConfigFileNode getBranchNode()
          Getting the node responsible for reading the file.
 double getDouble()
          Get value as a double.
 double getDouble(java.lang.String path, double deflt)
          Get value of subnode as double, using default when necessary.
 boolean getInhBoolean(java.lang.String path, boolean deflt)
          Get value of subnode as boolean searching parent nodes before using default.
 double getInhDouble(java.lang.String path, double deflt)
          Get value of subnode as double searching parent nodes before using default.
 int getInhInt(java.lang.String path, int deflt)
          Get value of subnode as int searching parent nodes before using default.
 java.lang.String getInhString(java.lang.String path, java.lang.String deflt)
          Get value of subnode as String searching parent nodes before using default.
 int getInt()
          Get value as an integer.
 int getInt(java.lang.String path, int deflt)
          Get 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 getSourceFileName()
           
 java.lang.String getString()
          Get value as String.
 java.lang.String getString(java.lang.String path, java.lang.String deflt)
          Get value of subnode as String, using default when necessary.
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 print(java.io.PrintWriter os)
          Pretty print this node with its whole subtree.
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

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
Constructor Detail

ConfigNodeImpl

public ConfigNodeImpl(java.lang.String name,
                      java.lang.String value,
                      ConfigParamMap pm)
Method Detail

getSourceFileName

public java.lang.String getSourceFileName()

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

getName

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

getPath

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

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

children

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

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)

addChild

public ConfigNodeImpl addChild(ConfigNodeImpl child)

print

public void print(java.io.PrintWriter os)
           throws java.io.IOException
Description copied from interface: ConfigNode
Pretty print this node with its whole subtree.
Specified by:
print in interface ConfigNode

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

More information