jmri.configurexml
Class ConfigXmlManager

java.lang.Object
  extended by jmri.jmrit.XmlFile
      extended by jmri.configurexml.ConfigXmlManager
All Implemented Interfaces:
ConfigureManager

public class ConfigXmlManager
extends XmlFile
implements ConfigureManager

Provides the mechanisms for storing an entire layout configuration to XML. "Layout" refers to the hardware: Specific communcation systems, etc.

Author:
Bob Jacobsen Copyright (c) 2002, 2008
See Also:
Package summary for details of the overall structure

Field Summary
static String dtdVersion
          Define the current DTD version string for the layout-config DTD.
static String fileLocation
           
 
Fields inherited from class jmri.jmrit.XmlFile
dtdLocation, xsltLocation
 
Constructor Summary
ConfigXmlManager()
           
 
Method Summary
static String adapterName(Object o)
          Find the name of the adapter class for an object.
protected  void addConfigStore(Element root)
           
protected  void addPrefsStore(Element root)
           
protected  void addToolsStore(Element root)
           
protected  void addUserStore(Element root)
           
 void deregister(Object o)
           
static Element elementFromObject(Object o)
           
protected  void finalStore(Element root, File file)
           
 File find(String f)
          Find a file by looking in xml/layout/ in the preferences directory, if that exists in xml/layout/ in the application directory, if that exists in xml/ in the preferences directory, if that exists in xml/ in the application directory, if that exists at top level in the application directory
 Object findInstance(Class<?> c, int index)
          Find the ith instance of an object of particular class that's been registered for storage.
protected  Element initStore()
           
 boolean load(File fi)
          Create the objects defined in a particular configuration file
 boolean makeBackup(File file)
          Make a backup file.
 void registerConfig(Object o)
           
 void registerPref(Object o)
           
 void registerTool(Object o)
           
 void registerUser(Object o)
          Register an object whose state is to be tracked.
 void removePrefItems()
          Remove the registered preference items.
 void storeAll(File file)
          Writes config, tools and user to a file.
 void storeConfig(File file)
          Writes prefs to a file.
 void storePrefs(File file)
          Writes prefs to a file.
 void storeUser(File file)
          Writes user and config info to a file.
 
Methods inherited from class jmri.jmrit.XmlFile
addDefaultInfo, backupFileName, checkFile, createFileNameWithDate, dumpElement, ensurePrefsPresent, findFile, getRootViaURI, getVerify, makeBackupFile, makeBackupFile, newDocument, prefsDir, reportError1, reportError2, revertBackupFile, rootFromFile, rootFromName, rootFromURL, setVerify, userFileChooser, userFileChooser, userFileChooser, userFileChooser, userFileLocationDefault, writeXML, xmlDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dtdVersion

public static final String dtdVersion
Define the current DTD version string for the layout-config DTD. See the DTD versioning discussion

See Also:
Constant Field Values

fileLocation

public static String fileLocation
Constructor Detail

ConfigXmlManager

public ConfigXmlManager()
Method Detail

registerPref

public void registerPref(Object o)
Specified by:
registerPref in interface ConfigureManager

removePrefItems

public void removePrefItems()
Remove the registered preference items. This is used e.g. when a GUI wants to replace the preferences with new values.

Specified by:
removePrefItems in interface ConfigureManager

findInstance

public Object findInstance(Class<?> c,
                           int index)
Description copied from interface: ConfigureManager
Find the ith instance of an object of particular class that's been registered for storage.

Note that the index of an object can change when other objects are stored or removed. The index is for indexing over the objects stored at a moment, not for use as an identification number.

There may be synchronization issues associated with this, although they are expected to be rare in practice.

Specified by:
findInstance in interface ConfigureManager
Parameters:
c - Class of the desired objects
index - a 1-based index of the object to return
Returns:
an object of class c or null

registerConfig

public void registerConfig(Object o)
Specified by:
registerConfig in interface ConfigureManager

registerTool

public void registerTool(Object o)
Specified by:
registerTool in interface ConfigureManager

registerUser

public void registerUser(Object o)
Register an object whose state is to be tracked. It is not an error if the original object was already registered.

Specified by:
registerUser in interface ConfigureManager
Parameters:
o - The object, which must have an associated adapter class.

deregister

public void deregister(Object o)
Specified by:
deregister in interface ConfigureManager

adapterName

public static String adapterName(Object o)
Find the name of the adapter class for an object.

Parameters:
o - object of a configurable type
Returns:
class name of adapter

initStore

protected Element initStore()

addPrefsStore

protected void addPrefsStore(Element root)

addConfigStore

protected void addConfigStore(Element root)

addToolsStore

protected void addToolsStore(Element root)

addUserStore

protected void addUserStore(Element root)

finalStore

protected void finalStore(Element root,
                          File file)

storeAll

public void storeAll(File file)
Writes config, tools and user to a file.

Specified by:
storeAll in interface ConfigureManager
Parameters:
file -

storePrefs

public void storePrefs(File file)
Writes prefs to a file.

Specified by:
storePrefs in interface ConfigureManager
Parameters:
file -

storeConfig

public void storeConfig(File file)
Writes prefs to a file.

Specified by:
storeConfig in interface ConfigureManager
Parameters:
file -

storeUser

public void storeUser(File file)
Writes user and config info to a file.

Config is included here because it doesnt hurt to read it again, and the user data (typically a panel) requires it to be present first.

Specified by:
storeUser in interface ConfigureManager
Parameters:
file -

makeBackup

public boolean makeBackup(File file)
Description copied from interface: ConfigureManager
Make a backup file.

Specified by:
makeBackup in interface ConfigureManager
Parameters:
file - to be backed up
Returns:
true if successful

elementFromObject

public static Element elementFromObject(Object o)

load

public boolean load(File fi)
Description copied from interface: ConfigureManager
Create the objects defined in a particular configuration file

Specified by:
load in interface ConfigureManager
Parameters:
fi - Input file
Returns:
true if succeeded

find

public File find(String f)
Find a file by looking

Specified by:
find in interface ConfigureManager
Parameters:
f - Local filename, perhaps without path information
Returns:
Corresponding File object


Copyright © 1997 - 2009 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads