程序包 weka.gui

类 HierarchyPropertyParser

java.lang.Object
weka.gui.HierarchyPropertyParser
所有已实现的接口:
Serializable

public class HierarchyPropertyParser extends Object implements Serializable
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).

版本:
$Revision: 9917 $
作者:
Xin Xu (xx5@cs.waikato.ac.nz)
另请参阅:
  • 构造器概要

    构造器
    构造器
    说明
    Default constructor
    Constructor that builds a tree from the given property with the given delimitor
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    add(String property)
    Add the given item of property to the tree
    void
    build(String p, String delim)
    Build a tree from the given property with the given delimitor
    The value in the children nodes.
    boolean
    contains(String string)
    Whether the HierarchyPropertyParser contains the given string
    The context of the current node, i.e.
    int
    Get the depth of the tree, i.e.
    The full value of the current node, i.e.
    int
    Get the level of current node.
    Get the seperator between levels.
    Get the value of current node
    boolean
    goDown(String path)
    Go to a certain node of the tree down from the current node according to the specified relative path.
    boolean
    goTo(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
    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
    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
    Go to the root of the tree
    boolean
    Whether the given string has a hierachy structure with the seperators
    boolean
    Whether the current position is a leaf
    boolean
    Whether the current position is the root
    static void
    main(String[] args)
    Tests out the parser.
    int
    The number of the children nodes.
    The value in the parent node.
    int
    search(Vector vct, 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
    Set the seperator between levels.
    Show the whole tree in text format
    tokenize(String rawString)
    Tokenize the given string based on the seperator and put the tokens into an array of strings

    从类继承的方法 java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • HierarchyPropertyParser

      public HierarchyPropertyParser()
      Default constructor
    • HierarchyPropertyParser

      public HierarchyPropertyParser(String p, String delim) throws Exception
      Constructor that builds a tree from the given property with the given delimitor
      参数:
      p - the given property string
      delim - the given dilimitor
      抛出:
      Exception
  • 方法详细资料

    • setSeperator

      public void setSeperator(String s)
      Set the seperator between levels. Default is dot.
      参数:
      s - the seperator symbol
    • getSeperator

      public String getSeperator()
      Get the seperator between levels. Default is dot.
      返回:
      the seperator symbol
    • build

      public void build(String p, String delim) throws Exception
      Build a tree from the given property with the given delimitor
      参数:
      p - the given property
      delim - the given delimitor
      抛出:
      Exception
    • add

      public void add(String property)
      Add the given item of property to the tree
      参数:
      property - the given item
    • tokenize

      public String[] tokenize(String rawString)
      Tokenize the given string based on the seperator and put the tokens into an array of strings
      参数:
      rawString - the given string
      返回:
      an array of strings
    • contains

      public boolean contains(String string)
      Whether the HierarchyPropertyParser contains the given string
      参数:
      string - the given string
      返回:
      whether contains
    • isHierachic

      public boolean isHierachic(String string)
      Whether the given string has a hierachy structure with the seperators
      参数:
      string - the given string
    • search

      public int search(Vector vct, 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. If such elements are found the first index is returned, otherwise -1
      参数:
      vct - the given vector
      target - the given target string
      返回:
      the index of the found element, -1 if not found
    • goTo

      public boolean goTo(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.
      For relative path, see goDown(String path).
      参数:
      path - the given absolute path
      返回:
      whether the path exists, if false the current position does not move
    • goDown

      public boolean goDown(String path)
      Go to a certain node of the tree down from the current node according to the specified relative path. The path does not contain the value of current node
      参数:
      path - the given relative path
      返回:
      whether the path exists, if false the current position does not move
    • goToRoot

      public void goToRoot()
      Go to the root of the tree
    • goToParent

      public 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
    • goToChild

      public boolean goToChild(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. If false, the current position does not change
      参数:
      value - the value of the given child
      返回:
      whether the child can be found
    • goToChild

      public void goToChild(int pos) throws Exception
      Go to one child node from the current position in the tree according to the given position
      参数:
      pos - the position of the given child
      抛出:
      Exception - if the position is out of range or leaf is reached
    • numChildren

      public int numChildren()
      The number of the children nodes. If current node is leaf, it returns 0.
      返回:
      the number of the children nodes of the current position
    • childrenValues

      public String[] childrenValues()
      The value in the children nodes. If current node is leaf, it returns null.
      返回:
      the value in the children nodes
    • parentValue

      public String parentValue()
      The value in the parent node. If current node is root, it returns null.
      返回:
      the value in the parent node
    • isLeafReached

      public boolean isLeafReached()
      Whether the current position is a leaf
      返回:
      whether the current position is a leaf
    • isRootReached

      public boolean isRootReached()
      Whether the current position is the root
      返回:
      whether the current position is the root
    • getValue

      public String getValue()
      Get the value of current node
      返回:
      value level
    • getLevel

      public int getLevel()
      Get the level of current node. Note the level starts from 0
      返回:
      the level
    • depth

      public int depth()
      Get the depth of the tree, i.e. (the largest level)+1
      返回:
      the depth of the tree
    • context

      public String context()
      The context of the current node, i.e. the path from the root to the parent node of the current node, seperated by the seperator. If root, it returns null
      返回:
      the context path
    • fullValue

      public String fullValue()
      The full value of the current node, i.e. its context + seperator + its value. For root, only its value.
      返回:
      the context path
    • showTree

      public String showTree()
      Show the whole tree in text format
      返回:
      the whole tree in text format
    • main

      public static void main(String[] args)
      Tests out the parser.
      参数:
      args - should contain nothing