Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.port80.util
Class Conf  view Conf download Conf.java

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bycom.port80.util.Conf
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class Conf
extends org.xml.sax.helpers.DefaultHandler

Configuation file read/write. This class parse an config. file in XML format. Multiple calls to read() can be used to merge any number of config. files. . Replace cl_conf class. Usage: cl_conf cf = new cl_conf(); cf.read(global_rcfname); cf.read(local_rcfname); ...

Version:
0.1 07/07/2000

Field Summary
private  java.lang.StringBuffer cell
           
private static java.lang.String CLASS
           
private static java.lang.String CLASSNAME
           
private  java.util.Map conf
           
private  boolean DEBUG
           
private  java.util.Stack keys
           
private static boolean NEVER
           
private  java.util.Stack objs
           
private  java.util.Stack ops
           
private static java.lang.String PACKAGENAME
           
private static java.lang.String tCf
           
private static java.lang.String tKey
           
private static java.lang.String tMap
           
private static java.lang.String tValue
           
private static java.lang.String tVector
           
private static java.lang.String Usage
           
private  java.lang.Object value
           
private  boolean VERBOSE
           
 
Constructor Summary
Conf()
           
 
Method Summary
 void characters(char[] c, int start, int len)
          Receive notification of character data inside an element.
 void clear()
           
static java.lang.Object clone(java.lang.Object object)
          Clone a tree of data structure consists of String, Vector and Map.
 void endElement(java.lang.String uri, java.lang.String localname, java.lang.String name)
          Receive notification of the end of an element.
static java.lang.Object foreach(java.lang.Object object, java.lang.Object userdata, TreeWalkerCallback a)
          The foreach() function transverse the Conf tree.
 java.lang.Object get(java.lang.String path)
           
 java.lang.Object get(java.lang.String[] path)
           
 java.lang.Object get(java.lang.String[] path, java.lang.Object cf)
          Get entry inside a config.
 java.lang.Object get(java.lang.String path, java.lang.Object cf)
           
 int getHex(java.lang.String path)
           
 int getHex(java.lang.String[] path)
           
 int getHex(java.lang.String[] path, int def)
           
 int getHex(java.lang.String path, int def)
           
 int getInt(java.lang.String path)
           
 int getInt(java.lang.String[] path)
           
 int getInt(java.lang.String[] path, int def)
           
 int getInt(java.lang.String path, int def)
           
 java.lang.String getString(java.lang.String path)
           
 java.lang.String getString(java.lang.String[] path)
           
 java.util.SortedSet keySet()
           
 java.util.SortedSet keySet(java.lang.Object cf)
          Get valid keys in the config.
static void main(java.lang.String[] args)
           
 void read(java.io.File file)
           
 void read(java.io.InputStream is)
           
 void read(java.lang.String fpath)
           
(package private) static java.lang.Object real_foreach(java.lang.Object object, java.lang.Object userdata, TreeWalkerCallback a, java.lang.String k)
           
 java.lang.Object set(java.lang.String[] path, java.lang.Object value)
           
 java.lang.Object set(java.lang.String path, java.lang.Object value)
           
 java.lang.Object setInt(java.lang.String[] path, int value)
           
 java.lang.Object setInt(java.lang.String path, int value)
           
(package private)  void setValue()
           
private  java.lang.String[] splitString(java.lang.String path)
          Split input string.
 void startElement(java.lang.String uri, java.lang.String localname, java.lang.String name, org.xml.sax.Attributes a)
          Receive notification of the start of an element.
 void test()
           
 java.lang.String toCf()
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
static java.lang.String toXml(java.lang.Object object, java.lang.String tag, java.lang.String indent, java.lang.String tab)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PACKAGENAME

private static final java.lang.String PACKAGENAME
See Also:
Constant Field Values

CLASS

private static final java.lang.String CLASS
See Also:
Constant Field Values

CLASSNAME

private static final java.lang.String CLASSNAME
See Also:
Constant Field Values

Usage

private static final java.lang.String Usage
See Also:
Constant Field Values

tCf

private static final java.lang.String tCf
See Also:
Constant Field Values

tMap

private static final java.lang.String tMap
See Also:
Constant Field Values

tVector

private static final java.lang.String tVector
See Also:
Constant Field Values

tKey

private static final java.lang.String tKey
See Also:
Constant Field Values

tValue

private static final java.lang.String tValue
See Also:
Constant Field Values

NEVER

private static final boolean NEVER
See Also:
Constant Field Values

DEBUG

private boolean DEBUG

VERBOSE

private boolean VERBOSE

conf

private java.util.Map conf

cell

private java.lang.StringBuffer cell

value

private java.lang.Object value

keys

private java.util.Stack keys

objs

private java.util.Stack objs

ops

private java.util.Stack ops
Constructor Detail

Conf

public Conf()
Method Detail

toCf

public java.lang.String toCf()

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


toXml

public static java.lang.String toXml(java.lang.Object object,
                                     java.lang.String tag,
                                     java.lang.String indent,
                                     java.lang.String tab)

foreach

public static java.lang.Object foreach(java.lang.Object object,
                                       java.lang.Object userdata,
                                       TreeWalkerCallback a)
The foreach() function transverse the Conf tree. . Conf tree are consists of Map,List(folder) and Strings(left). . The TreeWalkerCallback interface defines the callbacks functions that would be called when enter(push),exit(pop) a folder and when visit(leaf) a leaf.


real_foreach

static java.lang.Object real_foreach(java.lang.Object object,
                                     java.lang.Object userdata,
                                     TreeWalkerCallback a,
                                     java.lang.String k)

clone

public static java.lang.Object clone(java.lang.Object object)
Clone a tree of data structure consists of String, Vector and Map.


read

public void read(java.lang.String fpath)
          throws java.lang.Exception

read

public void read(java.io.File file)
          throws java.lang.Exception

read

public void read(java.io.InputStream is)
          throws java.lang.Exception

set

public java.lang.Object set(java.lang.String[] path,
                            java.lang.Object value)

setInt

public java.lang.Object setInt(java.lang.String[] path,
                               int value)

get

public java.lang.Object get(java.lang.String[] path,
                            java.lang.Object cf)
Get entry inside a config. tree object (which is conf or a subtree in conf).


getInt

public int getInt(java.lang.String[] path,
                  int def)

getHex

public int getHex(java.lang.String[] path,
                  int def)

keySet

public java.util.SortedSet keySet()

set

public java.lang.Object set(java.lang.String path,
                            java.lang.Object value)

setInt

public java.lang.Object setInt(java.lang.String path,
                               int value)

get

public java.lang.Object get(java.lang.String path,
                            java.lang.Object cf)

getInt

public int getInt(java.lang.String path,
                  int def)

getHex

public int getHex(java.lang.String path,
                  int def)

get

public java.lang.Object get(java.lang.String[] path)

getInt

public int getInt(java.lang.String[] path)

getHex

public int getHex(java.lang.String[] path)

getString

public java.lang.String getString(java.lang.String[] path)

get

public java.lang.Object get(java.lang.String path)

getInt

public int getInt(java.lang.String path)

getHex

public int getHex(java.lang.String path)

getString

public java.lang.String getString(java.lang.String path)

clear

public void clear()

keySet

public java.util.SortedSet keySet(java.lang.Object cf)
Get valid keys in the config. tree object (which is conf or a subtree in conf).


startElement

public void startElement(java.lang.String uri,
                         java.lang.String localname,
                         java.lang.String name,
                         org.xml.sax.Attributes a)
Description copied from class: org.xml.sax.helpers.DefaultHandler
Receive notification of the start of an element.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).


endElement

public void endElement(java.lang.String uri,
                       java.lang.String localname,
                       java.lang.String name)
Description copied from class: org.xml.sax.helpers.DefaultHandler
Receive notification of the end of an element.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).


characters

public void characters(char[] c,
                       int start,
                       int len)
Description copied from class: org.xml.sax.helpers.DefaultHandler
Receive notification of character data inside an element.

By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).


setValue

void setValue()

splitString

private java.lang.String[] splitString(java.lang.String path)
Split input string.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception

test

public void test()