sk.uniba.euromath.config
Class EuromathConfig

java.lang.Object
  extended by sk.uniba.euromath.config.EuromathConfig

public final class EuromathConfig
extends Object

Ensures that the emConfig.xml configuration file is properly loaded. Before the initInstance(), one of the setPluginRoot functions must be called to set the root of the plugin.

Implementation note: Error messages must not be localized in order for them to display always correctly.

Author:
Martin Vysny

Constructor Summary
EuromathConfig()
           
 
Method Summary
static sk.uniba.euromath.config.bind.Config getConfig()
          Returns in-memory representation of emConfig.xml configuration file.
static URL getConfigFile()
          Returns URL, determining position of config file.
static Locale getLocale()
          Returns locale as configured in the config file.
static sk.uniba.euromath.config.bind.NamespaceType getNamespace(String namespaceURI)
          Returns the namespace definition for given namespace URI.
static URLDir getPluginRoot()
          Returns directory where the plugin is located.
static URLDir getSchemaLoc()
          Returns the schema directory location.
static URLDir getStylesheetLoc()
          Returns the stylesheet directory location.
static File getUserConfigFile()
          Returns user-specific config file, or null if the file does not exist.
static String getUserConfigFileName()
          Returns user-specific config file, or null if user does not have home directory.
static void initInstance()
          Loads the configuration file.
static boolean isInitialized()
          Checks whether the class has been initialized.
static void setPluginRoot()
          Sets root of plugin to current dir.
static void setPluginRoot(URLDir url)
          Sets root of plugin.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EuromathConfig

public EuromathConfig()
Method Detail

getConfig

public static sk.uniba.euromath.config.bind.Config getConfig()
Returns in-memory representation of emConfig.xml configuration file.

Returns:
config.

getConfigFile

public static URL getConfigFile()
Returns URL, determining position of config file.

Returns:
URL denoting EuroMath config file.

getUserConfigFileName

public static String getUserConfigFileName()
Returns user-specific config file, or null if user does not have home directory.

Returns:
File object pointing to user-specific config file.

getUserConfigFile

public static File getUserConfigFile()
Returns user-specific config file, or null if the file does not exist.

Returns:
File object pointing to user-specific config file.

getPluginRoot

public static URLDir getPluginRoot()
Returns directory where the plugin is located.

Returns:
plugin root directory.

getStylesheetLoc

public static URLDir getStylesheetLoc()
Returns the stylesheet directory location. Valid after the initInstance() call.

Returns:
absolute path to stylesheet directory.

getSchemaLoc

public static URLDir getSchemaLoc()
Returns the schema directory location. Valid after the initInstance() call.

Returns:
absolute path to schema directory.

initInstance

public static void initInstance()
                         throws javax.xml.bind.JAXBException,
                                IOException,
                                URISyntaxException
Loads the configuration file.

Throws:
javax.xml.bind.JAXBException - if config file is not valid, well formed, etc.
IOException - if I/O error occurs.
URISyntaxException - if config file contains invalid URIs.

getNamespace

public static sk.uniba.euromath.config.bind.NamespaceType getNamespace(String namespaceURI)
Returns the namespace definition for given namespace URI.

Parameters:
namespaceURI - the namespace identifier
Returns:
the namespace description object or null if such namespace is not defined.

setPluginRoot

public static void setPluginRoot(URLDir url)
Sets root of plugin. Should be called before initInstance(), to set other root than current directory.

Parameters:
url - address to the root of plugin.

setPluginRoot

public static void setPluginRoot()
Sets root of plugin to current dir.


isInitialized

public static boolean isInitialized()
Checks whether the class has been initialized.

Returns:
true if the config file is parsed and can be accessed, false if initInstance() was not yet called.

getLocale

public static Locale getLocale()
Returns locale as configured in the config file.

Returns:
locale constructed from the config file.


Copyright © 2003-2006 null. All Rights Reserved.