net.sourceforge.nite.gui.util
Class NXTConfig

java.lang.Object
  extended by net.sourceforge.nite.gui.util.NXTConfig

public class NXTConfig
extends java.lang.Object

This class facilitates access to the configuration file that is used to customize subclasses of AbstractCallableTool.
NXTConfig is used for accessing the customizations to the tools that can be made by the user. These customizations are stored in XML (default in the file nxtConfig.xml, somewhere on the classpath). Each tool defines its own element directly below the XML root of the file. For example, the AMI DialogueActCoder defines the element DACoderConfig. In this element three types of children are allowed:

A tool can access these settings directly, or through the appropriate AbstractCallableToolConfig subclass. The documentation of the class AbstractCallableToolConfig provides some more documentation of the configuration possibilities for AbstractCallableTool.

Method summary

By default, the NXTConfig will use the settings in the file "nxtConfig.xml", if it can be found on the classpath.
loadConfig(String fileName) allows you to load a different configuration file.
reloadConfig() will reload the current configuration file. This is useful if the config file was modified externally.
setConfigRoot(String newRoot) determines which configuration element should be used.
setMetaDataFile(String fileName) determines which metadata file is currently opened.
The 'active' corpus and gui settings are those contained in the correct root element (configRoot), that are linked to the current metadata file through a metadatafile element.
getCorpusSettings() returns an XML Node for the active corpussettings.
getGuiSettings() returns an XML Node for the active guisettings.

Use pattern

NB: There is no suppport yet for MODIFYING the configFile, at the moment that should be done in a text editor. This might be added in the future.

Author:
Dennis Reidsma, UTwente

Field Summary
static java.lang.String DEFAULT_CONFIG
           
 
Constructor Summary
NXTConfig()
          INIT: no longer loads the default config file.
 
Method Summary
 void checkSave()
          Not yet implemented.
 org.w3c.dom.Node getCorpusSettings()
          Give the current config root and metadata filename, returns the appropriate corpus settings Node.
 java.lang.String getCorpusSettingValue(java.lang.String attribute)
          Easy access method for attribute values of the corpus settings node
 org.w3c.dom.Node getGuiSettings()
          Give the current config root and metadata filename, returns the appropriate gui settings Node.
 java.lang.String getGuiSettingValue(java.lang.String attribute)
          Easy access method for attribute values of the gui settings node
 void loadConfig(java.lang.String fileName)
          Load the given config file.
 void reloadConfig()
          Reload the current config file.
 void setConfigRoot(java.lang.String rootName)
          Every tool can define its own settings.
 void setCorpusSettings(java.lang.String csi)
          set the ID of the corpus-settings node to use.
 void setGUISettings(java.lang.String guid)
          set the ID of the gui-settings node to use.
 void setMetaDataFile(java.lang.String fileName)
          The config file contains separate entries to couple a metadata file to certain corpus settings and gui settings, in ordr to allow several metadata files to share the same settings.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONFIG

public static java.lang.String DEFAULT_CONFIG
Constructor Detail

NXTConfig

public NXTConfig()
INIT: no longer loads the default config file. jonathan 5.4.5 - we only attempt to load config once: when initializeCorpus is called.

Method Detail

setCorpusSettings

public void setCorpusSettings(java.lang.String csi)
set the ID of the corpus-settings node to use. This is normally done via an argument to AbstractCallableTool, and means we can avoid depending on a correct metadata entry in the config file (if we get it right!) - jonathan 8.4.5


setGUISettings

public void setGUISettings(java.lang.String guid)
set the ID of the gui-settings node to use. This is normally done via an argument to AbstractCallableTool, and means we can avoid depending on a correct metadata entry in the config file (if we get it right!) - jonathan 8.4.5


loadConfig

public void loadConfig(java.lang.String fileName)
                throws java.io.IOException,
                       org.xml.sax.SAXException
Load the given config file. Necessary when the file has been changed. NB: The tool (whichever) should probably also reload the corpus and re-initialize everyting when the config file has been changed!
IOException - If any IO errors occur. SAXException - If any parse errors occur. IllegalArgumentException - If the InputStream is null

Throws:
java.io.IOException
org.xml.sax.SAXException

reloadConfig

public void reloadConfig()
                  throws java.io.IOException,
                         org.xml.sax.SAXException
Reload the current config file. Necessary when the file has been changed externally. NO SAVE CHECK HERE! NB: The tool (whichever) should probably also reload the corpus and re-initialize everyting when the config file has been changed!
IOException - If any IO errors occur. SAXException - If any parse errors occur. IllegalArgumentException - If the InputStream is null

Throws:
java.io.IOException
org.xml.sax.SAXException

setConfigRoot

public void setConfigRoot(java.lang.String rootName)
Every tool can define its own settings. These settings are stored in an element directly below the root . This method determines which element should be used for the settings of the 'current' tool.
If the root is unknown in the config file, getGUISettings or getCorpussettings will return null.
Example: The DACoder (AMI Dialogue Act Coder) stores its settings in the element named "DACoderConfig". Therefore, somewhere in the initialization of that tool, setConfigRoot("DACoderConfig") will be called.


setMetaDataFile

public void setMetaDataFile(java.lang.String fileName)
The config file contains separate entries to couple a metadata file to certain corpus settings and gui settings, in ordr to allow several metadata files to share the same settings. This method is used to determine which metadata file is currently loaded in the tool. The NXTConfig object will use that information to retrieve the appropriate corpussettings and guisettings Nodes (on request).
If the metadata file is unknown in the config file, getGUISettings or getCorpussettings will return null.


getCorpusSettings

public org.w3c.dom.Node getCorpusSettings()
Give the current config root and metadata filename, returns the appropriate corpus settings Node. If either is unknown or the config file was not loaded properly, this method returns null.


getGuiSettings

public org.w3c.dom.Node getGuiSettings()
Give the current config root and metadata filename, returns the appropriate gui settings Node. If either is unknown or the config file was not loaded properly, this method returns null.


getCorpusSettingValue

public java.lang.String getCorpusSettingValue(java.lang.String attribute)
Easy access method for attribute values of the corpus settings node


getGuiSettingValue

public java.lang.String getGuiSettingValue(java.lang.String attribute)
Easy access method for attribute values of the gui settings node


checkSave

public void checkSave()
Not yet implemented. Should check whether the settings have been changed, and if so, ask the user whether the changes should be saved.