|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.jmrit.XmlFile
jmri.configurexml.ConfigXmlManager
public class ConfigXmlManager
Provides the mechanisms for storing an entire layout configuration to XML. "Layout" refers to the hardware: Specific communcation systems, etc.
| Field Summary | |
|---|---|
static String |
schemaVersion
Define the current DTD version string for the layout-config DTD. |
| 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 |
addUserPrefsStore(Element root)
|
protected void |
addUserStore(Element root)
|
static void |
creationErrorEncountered(XmlAdapter adapter,
String operation,
Level level,
String description,
String systemName,
String userName,
Throwable exception)
Invoke common handling of errors that happen during the "load" process. |
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. |
ArrayList<Object> |
getInstanceList(Class<?> c)
Returns a list of instances stored for a given class. |
protected void |
includeHistory(Element root)
|
protected Element |
initStore()
|
boolean |
load(File fi)
Load a file. |
boolean |
load(File fi,
boolean registerDeferred)
Load a file. |
boolean |
loadDeferred(File fi)
Create the objects defined in a particular configuration file that have been deferred until after basic GUI construction completed |
boolean |
makeBackup(File file)
Make a backup file. |
void |
registerConfig(Object o)
|
void |
registerConfig(Object o,
int x)
|
void |
registerPref(Object o)
|
void |
registerTool(Object o)
|
void |
registerUser(Object o)
Register an object whose state is to be tracked. |
void |
registerUserPrefs(Object o)
|
void |
removePrefItems()
Remove the registered preference items. |
static void |
setErrorHandler(ErrorHandler handler)
|
void |
setPrefsLocation(File prefsFile)
Set location for preferences file. |
void |
storeAll(File file)
Writes config, tools and user to a file. |
void |
storeConfig(File file)
Writes prefs to a file. |
void |
storePrefs()
Writes prefs to a predefined File location. |
void |
storePrefs(File file)
Stores just preferences information. |
void |
storeUser(File file)
Writes user and config info to a file. |
void |
storeUserPrefs(File file)
Stores just user preferences information. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String schemaVersion
| Constructor Detail |
|---|
public ConfigXmlManager()
| Method Detail |
|---|
public void registerConfig(Object o)
registerConfig in interface ConfigureManagerpublic void registerPref(Object o)
registerPref in interface ConfigureManagerpublic void removePrefItems()
removePrefItems in interface ConfigureManager
public Object findInstance(Class<?> c,
int index)
ConfigureManagerNote 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.
findInstance in interface ConfigureManagerc - Class of the desired objectsindex - a 1-based index of the object to return
public ArrayList<Object> getInstanceList(Class<?> c)
ConfigureManager
getInstanceList in interface ConfigureManagerc - Class of the desired objects
public void registerConfig(Object o,
int x)
registerConfig in interface ConfigureManagerpublic void registerTool(Object o)
registerTool in interface ConfigureManagerpublic void registerUser(Object o)
registerUser in interface ConfigureManagero - The object, which must have an
associated adapter class.public void registerUserPrefs(Object o)
registerUserPrefs in interface ConfigureManagerpublic void deregister(Object o)
deregister in interface ConfigureManagerpublic static String adapterName(Object o)
o - object of a configurable type
protected Element initStore()
protected void addPrefsStore(Element root)
protected void addConfigStore(Element root)
protected void addToolsStore(Element root)
protected void addUserStore(Element root)
protected void addUserPrefsStore(Element root)
protected void includeHistory(Element root)
protected void finalStore(Element root,
File file)
public void storeAll(File file)
storeAll in interface ConfigureManagerfile - public void storePrefs()
storePrefs in interface ConfigureManagerpublic void storePrefs(File file)
ConfigureManager
storePrefs in interface ConfigureManagerpublic void storeUserPrefs(File file)
ConfigureManager
storeUserPrefs in interface ConfigureManagerpublic void setPrefsLocation(File prefsFile)
File need not exist, but location must be writable when storePrefs() called.
public void storeConfig(File file)
storeConfig in interface ConfigureManagerfile - public void storeUser(File 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.
storeUser in interface ConfigureManagerfile - public boolean makeBackup(File file)
ConfigureManager
makeBackup in interface ConfigureManagerfile - to be backed up
public static Element elementFromObject(Object o)
public boolean load(File fi)
throws JmriConfigureXmlException
Handles problems locally to the extent that it can, by routing them to the creationErrorEncountered method.
load in interface ConfigureManagerfi - Input file
JmriConfigureXmlException
public boolean load(File fi,
boolean registerDeferred)
throws JmriConfigureXmlException
Handles problems locally to the extent that it can, by routing them to the creationErrorEncountered method.
load in interface ConfigureManagerfi - file to loadregisterDeferred - true to register objects to defer
JmriConfigureXmlExceptionXmlAdapter.loadDeferred()public boolean loadDeferred(File fi)
ConfigureManager
loadDeferred in interface ConfigureManagerfi - Input file
XmlAdapter.loadDeferred()public File find(String f)
find in interface ConfigureManagerf - Local filename, perhaps without path information
public static void creationErrorEncountered(XmlAdapter adapter,
String operation,
Level level,
String description,
String systemName,
String userName,
Throwable exception)
Generally, this is invoked by XmlAdapter
implementations of their creationErrorEncountered()
method (note different arguemments, though). The
standard implemenation of that is in AbstractXmlAdapter.
Exceptions passed into this are absorbed.
adapter - Object that encountered the error (for reporting),
may be nulloperation - description of the operation being attempted,
may be nulldescription - description of error encounteredsystemName - System name of bean being handled, may be nulluserName - used name of the bean being handled, may be nullexception - Any exception being handled in the processing, may be nullpublic static void setErrorHandler(ErrorHandler handler)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||