|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--weka.gui.HierarchyPropertyParser
This class implements a parser to read properties that have
a hierarchy(i.e. tree) structure. Conceptually it's similar to
the XML DOM/SAX parser but of course is much simpler and
uses dot as the seperator of levels instead of back-slash.
It provides interfaces to both build a parser tree and traverse
the tree.
Note that this implementation does not lock the tree when different
threads are traversing it simultaneously, i.e. it's NOT synchronized
and multi-thread safe. It is recommended that later implementation
extending this class provide a locking scheme and override the
functions with the "synchronized" modifier (most of them are
goToXXX() and information accessing functions).
Constructor Summary | |
HierarchyPropertyParser()
Default constructor |
|
HierarchyPropertyParser(java.lang.String p,
java.lang.String delim)
Constructor that builds a tree from the given property with the given delimitor |
Method Summary | |
void |
add(java.lang.String property)
Add the given item of property to the tree |
void |
build(java.lang.String p,
java.lang.String delim)
Build a tree from the given property with the given delimitor |
java.lang.String[] |
childrenValues()
The value in the children nodes. |
boolean |
contains(java.lang.String string)
Whether the HierarchyPropertyParser contains the given string |
java.lang.String |
context()
The context of the current node, i.e. |
int |
depth()
Get the depth of the tree, i.e. |
java.lang.String |
fullValue()
The full value of the current node, i.e. |
int |
getLevel()
Get the level of current node. |
java.lang.String |
getSeperator()
Get the seperator between levels. |
java.lang.String |
getValue()
Get the value of current node |
boolean |
goDown(java.lang.String path)
Go to a certain node of the tree down from the current node according to the specified relative path. |
boolean |
goTo(java.lang.String path)
Go to a certain node of the tree according to the specified path Note that the path must be absolute path from the root. |
void |
goToChild(int pos)
Go to one child node from the current position in the tree according to the given position |
boolean |
goToChild(java.lang.String value)
Go to one child node from the current position in the tree according to the given value If the child node with the given value cannot be found it returns false, true otherwise. |
void |
goToParent()
Go to the parent from the current position in the tree If the current position is the root, it stays there and does not move |
void |
goToRoot()
Go to the root of the tree |
boolean |
isHierachic(java.lang.String string)
Whether the given string has a hierachy structure with the seperators |
boolean |
isLeafReached()
Whether the current position is a leaf |
boolean |
isRootReached()
Whether the current position is the root |
static void |
main(java.lang.String[] args)
Tests out the parser. |
int |
numChildren()
The number of the children nodes. |
java.lang.String |
parentValue()
The value in the parent node. |
int |
search(java.util.Vector vct,
java.lang.String target)
Helper function to search for the given target string in a given vector in which the elements' value may hopefully is equal to the target. |
void |
setSeperator(java.lang.String s)
Set the seperator between levels. |
java.lang.String |
showTree()
Show the whole tree in text format |
java.lang.String[] |
tokenize(java.lang.String rawString)
Tokenize the given string based on the seperator and put the tokens into an array of strings |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HierarchyPropertyParser()
public HierarchyPropertyParser(java.lang.String p, java.lang.String delim) throws java.lang.Exception
p
- the given property stringdelim
- the given dilimitorMethod Detail |
public void setSeperator(java.lang.String s)
s
- the seperator symbolpublic java.lang.String getSeperator()
public void build(java.lang.String p, java.lang.String delim) throws java.lang.Exception
p
- the given propertydelim
- the given delimitor
java.lang.Exception
public void add(java.lang.String property)
property
- the given itempublic java.lang.String[] tokenize(java.lang.String rawString)
rawString
- the given string
public boolean contains(java.lang.String string)
string
- the given string
public boolean isHierachic(java.lang.String string)
string
- the given stringpublic int search(java.util.Vector vct, java.lang.String target)
vct
- the given vectortarget
- the given target string
public boolean goTo(java.lang.String path)
path
- the given absolute path
public boolean goDown(java.lang.String path)
path
- the given relative path
public void goToRoot()
public void goToParent()
public boolean goToChild(java.lang.String value)
value
- the value of the given child
public void goToChild(int pos) throws java.lang.Exception
pos
- the position of the given child
if
- the position is out of range or leaf is reached
java.lang.Exception
public int numChildren()
public java.lang.String[] childrenValues()
public java.lang.String parentValue()
public boolean isLeafReached()
public boolean isRootReached()
public java.lang.String getValue()
public int getLevel()
public int depth()
public java.lang.String context()
public java.lang.String fullValue()
public java.lang.String showTree()
public static void main(java.lang.String[] args)
args
- should contain nothing
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) 2003 David Lindsay, Computer Learning Research Centre, Dept. Computer Science, Royal Holloway, University of London