|
||||||||||
| 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 | |
|---|---|
(package private) Map<Object,Integer> |
clist
|
(package private) String |
defaultBackupDirectory
|
(package private) static ErrorHandler |
handler
|
(package private) ArrayList<org.jdom.Element> |
loadDeferredList
|
(package private) static org.slf4j.Logger |
log
|
(package private) ArrayList<Object> |
plist
|
(package private) File |
prefsFile
|
static String |
schemaVersion
Define the current DTD version string for the layout-config DTD. |
(package private) ArrayList<Object> |
tlist
|
(package private) ArrayList<Object> |
ulist
|
(package private) ArrayList<Object> |
uplist
|
| 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 boolean |
addConfigStore(org.jdom.Element root)
|
protected void |
addPrefsStore(org.jdom.Element root)
|
protected boolean |
addToolsStore(org.jdom.Element root)
|
protected void |
addUserPrefsStore(org.jdom.Element root)
|
protected boolean |
addUserStore(org.jdom.Element root)
|
(package private) void |
confirmAdapterAvailable(Object o)
Common check routine to confirm an adapter is available as part of registration process. |
static void |
creationErrorEncountered(XmlAdapter adapter,
String operation,
String description,
String systemName,
String userName,
Throwable exception)
Invoke common handling of errors that happen during the "load" process. |
void |
deregister(Object o)
|
static org.jdom.Element |
elementFromObject(Object o)
|
protected boolean |
finalStore(org.jdom.Element root,
File file)
|
URL |
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(org.jdom.Element root)
|
protected org.jdom.Element |
initStore()
|
boolean |
load(File fi)
Load a file. |
boolean |
load(File fi,
boolean registerDeferred)
Load a file. |
boolean |
load(URL url)
Create the objects defined in a particular configuration file |
boolean |
load(URL url,
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 |
loadDeferred(URL url)
Create the objects defined in a particular configuration file that have been deferred until after basic GUI construction completed |
(package private) void |
locateClassFailed(Throwable ex,
String adapterName,
Object o)
Handle failure to load adapter class. |
(package private) void |
locateFileFailed(String f)
Report a failure to find a file. |
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. |
boolean |
storeAll(File file)
Writes config, tools and user to a file. |
boolean |
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. |
boolean |
storeUser(File file)
Writes user and config info to a file. |
void |
storeUserPrefs(File file)
Stores just user preferences information. |
static void |
storingErrorEncountered(XmlAdapter adapter,
String operation,
String description,
String systemName,
String userName,
Throwable exception)
Invoke common handling of errors that happen during the "store" process. |
| Methods inherited from class jmri.jmrit.XmlFile |
|---|
addDefaultInfo, backupFileName, checkFile, createFileNameWithDate, dumpElement, findFile, getBuilder, getRoot, getRoot, getVerify, makeBackupFile, makeBackupFile, newDocument, newDocument, revertBackupFile, rootFromFile, rootFromInputStream, rootFromName, rootFromURL, setVerify, userFileChooser, userFileChooser, userFileChooser, userFileChooser, writeXML, xmlDir |
| 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
ArrayList<Object> plist
Map<Object,Integer> clist
ArrayList<Object> tlist
ArrayList<Object> ulist
ArrayList<Object> uplist
ArrayList<org.jdom.Element> loadDeferredList
File prefsFile
String defaultBackupDirectory
static ErrorHandler handler
static org.slf4j.Logger log
| Constructor Detail |
|---|
public ConfigXmlManager()
| Method Detail |
|---|
public void registerConfig(Object o)
registerConfig in interface ConfigureManagerpublic void registerPref(Object o)
registerPref in interface ConfigureManagervoid confirmAdapterAvailable(Object o)
public 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
void locateClassFailed(Throwable ex,
String adapterName,
Object o)
protected org.jdom.Element initStore()
protected void addPrefsStore(org.jdom.Element root)
protected boolean addConfigStore(org.jdom.Element root)
protected boolean addToolsStore(org.jdom.Element root)
protected boolean addUserStore(org.jdom.Element root)
protected void addUserPrefsStore(org.jdom.Element root)
protected void includeHistory(org.jdom.Element root)
protected boolean finalStore(org.jdom.Element root,
File file)
public boolean 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 boolean storeConfig(File file)
storeConfig in interface ConfigureManagerfile - public boolean 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 org.jdom.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(URL url)
throws JmriConfigureXmlException
ConfigureManager
load in interface ConfigureManagerurl - Input URL
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 load(URL url,
boolean registerDeferred)
throws JmriConfigureXmlException
Handles problems locally to the extent that it can, by routing them to the creationErrorEncountered method.
load in interface ConfigureManagerurl - URL of 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 boolean loadDeferred(URL url)
ConfigureManager
loadDeferred in interface ConfigureManagerurl - Input URL
XmlAdapter.loadDeferred()public URL find(String f)
find in interface ConfigureManagerf - Local filename, perhaps without path information
void locateFileFailed(String f)
f - Name of file not located.
public static void creationErrorEncountered(XmlAdapter adapter,
String operation,
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 null
public static void storingErrorEncountered(XmlAdapter adapter,
String operation,
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 | |||||||||