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

Quick Search    Search Deep

com.lutris.util
Class KeywordValueTable  view KeywordValueTable download KeywordValueTable.java

java.lang.Object
  extended bycom.lutris.util.KeywordValueTable
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Config

public class KeywordValueTable
extends java.lang.Object
implements java.io.Serializable

Class that implements a recursive keyword/value table. The key is a string that is restricted to be a valid Java identifier. That is, starting with an letter and containing letters or digits. The characters '_' and '$' are also allowed and are treated as letters. The value maybe any object. A keyword and its value are collectively referred to as a field The table is recursive. Values of class KeywordValueTable are referred to as sections. A field of a section maybe addressed from the parent object using a dot ('.') separated name path.

Since:
Harmony 1.0
Version:
$Revision: 1.23.12.1 $

Field Summary
private  java.util.Hashtable hashTable
           
 
Constructor Summary
KeywordValueTable()
          Constructor.
 
Method Summary
 boolean containsKey(java.lang.String keyword)
          Determine if the a field with the specified keyword exists.
private  KeywordValueTable findSection(java.lang.String[] keywordPath, boolean create, int pathIdx)
          Recursively locate the section named by a keyword path.
private  java.lang.String formatArrayAsHtml(java.lang.Object arrayObj)
          Format an array section as a HTML ordered list, appending it to the list.
private  java.lang.String formatFieldAsHtml(java.lang.Object fieldObj)
          Format an field.
private  java.lang.String formatObjectAsHtml(java.lang.Object obj)
          Format an object as HTML.
 java.lang.Object get(java.lang.String keyword)
          Get the value of a field as an object.
 java.lang.Object get(java.lang.String keyword, java.lang.Object defaultValue)
          Get the value of a field as an object, return a default if it does not exist.
 KeywordValueTable getSection(java.lang.String keyword)
          Get the value of a section.
 java.lang.String getString(java.lang.String keyword)
          Get the value of a field as a string
 java.lang.String getString(java.lang.String keyword, java.lang.String defaultValue)
          Get the value of a field as a string, return a default if it does not exist.
 java.lang.String[] keys()
          Get the keywords in the table.
 java.lang.String[] leafKeys()
          Recursively get the keywords for the entire table.
protected  KeywordValueTable newSection()
          Allocate a new section.
 void remove(java.lang.String keyword)
          Delete a field, if the field does not exist, the operation is ignored.
 void set(java.lang.String keyword, java.lang.Object value)
          Set the value of a field.
 void setDefault(java.lang.String keyword, java.lang.Object defaultValue)
          Sets a default value for a keyword.
 java.lang.String toHtml()
          Convert to an Html representation.
 java.lang.String toString()
          Convert to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hashTable

private java.util.Hashtable hashTable
Constructor Detail

KeywordValueTable

public KeywordValueTable()
Constructor.

Method Detail

findSection

private KeywordValueTable findSection(java.lang.String[] keywordPath,
                                      boolean create,
                                      int pathIdx)
                               throws KeywordValueException
Recursively locate the section named by a keyword path. This finds the section containing the last component of the path.


newSection

protected KeywordValueTable newSection()
Allocate a new section. The default implementation of this method returns a new KeywordValueTable object. A class derived from KeywordValueTable overrides this method to create a new object of the derived type. Sections are only allocated by this method.


get

public java.lang.Object get(java.lang.String keyword)
                     throws KeywordValueException
Get the value of a field as an object.


get

public java.lang.Object get(java.lang.String keyword,
                            java.lang.Object defaultValue)
                     throws KeywordValueException
Get the value of a field as an object, return a default if it does not exist.


getString

public java.lang.String getString(java.lang.String keyword)
                           throws KeywordValueException
Get the value of a field as a string


getString

public java.lang.String getString(java.lang.String keyword,
                                  java.lang.String defaultValue)
                           throws KeywordValueException
Get the value of a field as a string, return a default if it does not exist.


getSection

public KeywordValueTable getSection(java.lang.String keyword)
                             throws KeywordValueException
Get the value of a section. The section is a value that is another KeywordValueTable object.


set

public void set(java.lang.String keyword,
                java.lang.Object value)
         throws KeywordValueException
Set the value of a field. If a keyword path is specified and the subsections do not exist, they are created. If a field other than a KeywordValueTable is one of the intermediate sections in the path, it will be deleted and replaced by a section.


setDefault

public void setDefault(java.lang.String keyword,
                       java.lang.Object defaultValue)
                throws KeywordValueException
Sets a default value for a keyword. This method only sets a value for the specified keyword if a value is not already set for that keyword. If a value is not set for the keyword, then if a keyword path is specified and the subsections do not exist, they are created. If a field other than a KeywordValueTable is one of the intermediate sections in the path, it will be deleted and replaced by a section.


containsKey

public boolean containsKey(java.lang.String keyword)
                    throws KeywordValueException
Determine if the a field with the specified keyword exists.


keys

public java.lang.String[] keys()
Get the keywords in the table. This is only the keywords at the top level, its doesn't recurse.


leafKeys

public java.lang.String[] leafKeys()
Recursively get the keywords for the entire table. This returns the full keyword of all leaf values.


remove

public void remove(java.lang.String keyword)
            throws KeywordValueException
Delete a field, if the field does not exist, the operation is ignored.


toString

public java.lang.String toString()
Convert to a string.


toHtml

public java.lang.String toHtml()
Convert to an Html representation.


formatArrayAsHtml

private java.lang.String formatArrayAsHtml(java.lang.Object arrayObj)
Format an array section as a HTML ordered list, appending it to the list.


formatObjectAsHtml

private java.lang.String formatObjectAsHtml(java.lang.Object obj)
Format an object as HTML. Known printable objects are converted to a string, while others are simple listed as <Object>.


formatFieldAsHtml

private java.lang.String formatFieldAsHtml(java.lang.Object fieldObj)
Format an field. Normally just append toString the object. However, arrays and recursive data are formatted.