edu.ksu.cis.kdd.util
Class Settings

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byedu.ksu.cis.kdd.util.Settings
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class Settings
extends java.util.Hashtable

Class for saving, loading, and querying the settings.

The setting is stored in an XML file with the following DTD:
See config.xml for details.

The XML parser is implemented using visitor pattern, which is natural for recursive structures.

Consequently:

And so forth.

It is evident that a lot of this code is just copy-and-paste.

Version:
0.00001
Author:
Roby Joehanes
See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable BNJSettings
           
protected  java.util.Hashtable buttonGroups
           
protected  java.util.Hashtable classOptions
           
protected  TableSet converterTable
           
protected  TableSet dataConverterTable
           
protected  java.util.Hashtable dataDesc2Format
           
protected  java.util.List dataDescriptionList
           
protected  java.util.List dataExtensionList
           
static boolean DEBUG
           
protected static boolean isGUI
           
static java.lang.String license
           
static java.lang.String ln
           
protected  java.util.Hashtable netDesc2Format
           
protected  java.util.List netDescriptionList
           
protected  java.util.List netExtensionList
           
static MersenneTwisterFast random
           
static long randomSeed
           
protected  java.util.LinkedList RegisteredBBNs
           
static java.lang.String versionString
           
protected  java.util.Hashtable windowTable
           
 
Constructor Summary
Settings()
           
 
Method Summary
static java.util.Hashtable getBNJSettings()
          Get BNJ general setting.
static java.util.Hashtable getClassOptions(java.lang.String tag)
           
static TableSet getConverterTable()
          Get the Converter Table
static TableSet getDataConverterTable()
          Get the Data Converter Table
static java.util.List getDataDescriptionList()
           
static java.lang.String getDataExtensionFromDescription(java.lang.String desc)
           
static java.util.List getDataExtensionList()
           
static java.util.List getNetDescriptionList()
           
static java.lang.String getNetExtensionFromDescription(java.lang.String desc)
           
static java.util.List getNetExtensionList()
           
static java.util.LinkedList getRegisteredBBNs()
          gets options from config.xml which set the layout of the Options GUI for each BBN class.
static java.util.Hashtable getWindowSettings(java.lang.String name)
          Get window setting
static boolean isDebug()
           
static boolean isLoaded()
          Whether the settings has already loaded (for GUI)
static void load()
          Load the default configuration file
static void load(boolean forGUI)
          Load the default configuration file
 void load(java.io.InputStream stream, boolean forGUI)
          Load the default configuration file
static void load(java.lang.String filename, boolean forGUI)
           
static void loadEnglishGUISettings()
           
protected  javax.swing.ImageIcon loadImage(java.lang.String url)
           
protected  void registerBBN(org.w3c.dom.Node parent, java.util.LinkedList list)
           
static void save()
           
static void setClassOptions(java.lang.String tag, java.util.Hashtable t)
           
static void setDebug(boolean debug)
           
static void setLanguage(java.util.Locale locale, boolean forGUI)
           
static void setRandomSeed(long seed)
           
protected  void visitColorSettings(org.w3c.dom.Node parent, java.util.Hashtable prop)
          Visit the <COLORSETTING>.
protected  void visitConverter(org.w3c.dom.Node parent)
          Visit the <CONVERTER>.
protected  void visitConverters(org.w3c.dom.Node parent)
          Visit the <CONVERTERS>.
protected  void visitDataConverter(org.w3c.dom.Node parent)
          Visit the <DATACONVERTER>.
protected  void visitDataConverters(org.w3c.dom.Node parent)
          Visit the <DATACONVERTERS>.
protected  void visitDocument(org.w3c.dom.Node parent)
          Visit the configuration document body.
protected  void visitFontSettings(org.w3c.dom.Node parent, java.util.Hashtable prop)
          Visit the <FONTSETTING>.
protected  void visitIconSettings(org.w3c.dom.Node parent, java.util.Hashtable prop)
          Visit the <ICONSETTING>.
protected  javax.swing.JMenuBar visitMenu(org.w3c.dom.Node parent)
          Visit the <MENU>.
protected  javax.swing.JMenu visitMenuEntry(org.w3c.dom.Node parent)
          Visit the <MENUENTRY>.
protected  javax.swing.JMenuItem visitMenuItem(org.w3c.dom.Node parent)
          Visit the <MENUITEM>.
protected  void visitPopupMenu(org.w3c.dom.Node parent, java.util.Hashtable prop)
          Visit the <POPUPMENU>.
protected  void visitSettings(org.w3c.dom.Node parent, java.util.Hashtable prop)
          Visit the <SETTING>.
protected  javax.swing.JToolBar visitToolBar(org.w3c.dom.Node parent)
          Visit the <TOOLBAR>.
protected  javax.swing.JButton visitToolBarButton(org.w3c.dom.Node parent)
          Visit the <MENUITEM>.
protected  javax.swing.JToggleButton visitToolBarToggleButton(org.w3c.dom.Node parent)
           
protected  void visitWindow(org.w3c.dom.Node parent)
          Visit the <WINDOW>.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG

random

public static MersenneTwisterFast random

randomSeed

public static long randomSeed

versionString

public static java.lang.String versionString

ln

public static java.lang.String ln

isGUI

protected static boolean isGUI

converterTable

protected TableSet converterTable

dataConverterTable

protected TableSet dataConverterTable

windowTable

protected java.util.Hashtable windowTable

BNJSettings

protected java.util.Hashtable BNJSettings

RegisteredBBNs

protected java.util.LinkedList RegisteredBBNs

buttonGroups

protected java.util.Hashtable buttonGroups

netExtensionList

protected java.util.List netExtensionList

dataExtensionList

protected java.util.List dataExtensionList

netDescriptionList

protected java.util.List netDescriptionList

dataDescriptionList

protected java.util.List dataDescriptionList

dataDesc2Format

protected java.util.Hashtable dataDesc2Format

netDesc2Format

protected java.util.Hashtable netDesc2Format

classOptions

protected java.util.Hashtable classOptions

license

public static final java.lang.String license
Constructor Detail

Settings

public Settings()
Method Detail

isLoaded

public static boolean isLoaded()
Whether the settings has already loaded (for GUI)

Returns:

load

public static void load()
Load the default configuration file


load

public static void load(boolean forGUI)
Load the default configuration file

Parameters:
forGUI - specify whether GUI elements should be loaded too or not

load

public static void load(java.lang.String filename,
                        boolean forGUI)

load

public void load(java.io.InputStream stream,
                 boolean forGUI)
Load the default configuration file

Parameters:
stream - The input stream.
forGUI - specify whether GUI elements should be loaded too or not

setLanguage

public static void setLanguage(java.util.Locale locale,
                               boolean forGUI)

loadEnglishGUISettings

public static void loadEnglishGUISettings()

save

public static void save()

getClassOptions

public static java.util.Hashtable getClassOptions(java.lang.String tag)

setClassOptions

public static void setClassOptions(java.lang.String tag,
                                   java.util.Hashtable t)

setRandomSeed

public static void setRandomSeed(long seed)

visitDocument

protected void visitDocument(org.w3c.dom.Node parent)
Visit the configuration document body. Contains <WINDOW>, <CONVERTERS>, <SETTING>.

Parameters:
parent - The node to traverse

registerBBN

protected void registerBBN(org.w3c.dom.Node parent,
                           java.util.LinkedList list)

visitWindow

protected void visitWindow(org.w3c.dom.Node parent)
Visit the <WINDOW>. Contains <MENU>, <TOOLBAR>, and <SETTING>.

Parameters:
parent - The node to traverse

visitMenu

protected javax.swing.JMenuBar visitMenu(org.w3c.dom.Node parent)
Visit the <MENU>. Contains <MENUENTRY>.

Parameters:
parent - The node to traverse

visitMenuEntry

protected javax.swing.JMenu visitMenuEntry(org.w3c.dom.Node parent)
Visit the <MENUENTRY>. Contains <MENUENTRY>, < MENUITEM>, <SEPARATOR>.

Parameters:
parent - The node to traverse

visitMenuItem

protected javax.swing.JMenuItem visitMenuItem(org.w3c.dom.Node parent)
Visit the <MENUITEM>.

Parameters:
parent - The node to traverse

visitPopupMenu

protected void visitPopupMenu(org.w3c.dom.Node parent,
                              java.util.Hashtable prop)
Visit the <POPUPMENU>. Contains <MENUENTRY>.

Parameters:
parent - The node to traverse

visitToolBar

protected javax.swing.JToolBar visitToolBar(org.w3c.dom.Node parent)
Visit the <TOOLBAR>. Contains <TOOLBUTTON>.

Parameters:
parent - The node to traverse

visitToolBarButton

protected javax.swing.JButton visitToolBarButton(org.w3c.dom.Node parent)
Visit the <MENUITEM>.

Parameters:
parent - The node to traverse

visitToolBarToggleButton

protected javax.swing.JToggleButton visitToolBarToggleButton(org.w3c.dom.Node parent)

visitSettings

protected void visitSettings(org.w3c.dom.Node parent,
                             java.util.Hashtable prop)
Visit the <SETTING>.

Parameters:
parent - The node to traverse

visitColorSettings

protected void visitColorSettings(org.w3c.dom.Node parent,
                                  java.util.Hashtable prop)
Visit the <COLORSETTING>.

Parameters:
parent - The node to traverse

visitIconSettings

protected void visitIconSettings(org.w3c.dom.Node parent,
                                 java.util.Hashtable prop)
Visit the <ICONSETTING>.

Parameters:
parent - The node to traverse

visitFontSettings

protected void visitFontSettings(org.w3c.dom.Node parent,
                                 java.util.Hashtable prop)
Visit the <FONTSETTING>.

Parameters:
parent - The node to traverse

visitConverters

protected void visitConverters(org.w3c.dom.Node parent)
Visit the <CONVERTERS>. Contains <CONVERTER>.

Parameters:
parent - The node to traverse

visitDataConverters

protected void visitDataConverters(org.w3c.dom.Node parent)
Visit the <DATACONVERTERS>. Contains <DATACONVERTER>.

Parameters:
parent - The node to traverse

visitConverter

protected void visitConverter(org.w3c.dom.Node parent)
Visit the <CONVERTER>.

Parameters:
parent - The node to traverse

visitDataConverter

protected void visitDataConverter(org.w3c.dom.Node parent)
Visit the <DATACONVERTER>.

Parameters:
parent - The node to traverse

getConverterTable

public static TableSet getConverterTable()
Get the Converter Table

Returns:
TableSet

getDataConverterTable

public static TableSet getDataConverterTable()
Get the Data Converter Table

Returns:
TableSet

getWindowSettings

public static java.util.Hashtable getWindowSettings(java.lang.String name)
Get window setting

Parameters:
name - Window ID
Returns:
Hashtable The Settings

getBNJSettings

public static java.util.Hashtable getBNJSettings()
Get BNJ general setting. See <SETTING> tags in config.xml

Returns:
Hashtable The settings

getNetExtensionList

public static java.util.List getNetExtensionList()

getDataExtensionList

public static java.util.List getDataExtensionList()

getNetDescriptionList

public static java.util.List getNetDescriptionList()

getDataDescriptionList

public static java.util.List getDataDescriptionList()

getNetExtensionFromDescription

public static java.lang.String getNetExtensionFromDescription(java.lang.String desc)

getDataExtensionFromDescription

public static java.lang.String getDataExtensionFromDescription(java.lang.String desc)

getRegisteredBBNs

public static java.util.LinkedList getRegisteredBBNs()
gets options from config.xml which set the layout of the Options GUI for each BBN class.

Returns:

loadImage

protected javax.swing.ImageIcon loadImage(java.lang.String url)

setDebug

public static void setDebug(boolean debug)

isDebug

public static boolean isDebug()