Class ConfigXmlManager
- All Implemented Interfaces:
ConfigureManager
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrit.XmlFile
XmlFile.Validate -
Field Summary
FieldsModifier and TypeFieldDescription(package private) Filestatic final StringDefine the current schema version string for the layout-config schema.Fields inherited from class jmri.jmrit.XmlFile
dtdLocation, xsltLocation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringFind the name of the adapter class for an object.protected booleanaddConfigStore(org.jdom2.Element root) protected voidaddPrefsStore(org.jdom2.Element root) protected booleanaddToolsStore(org.jdom2.Element root) protected voidaddUserPrefsStore(org.jdom2.Element root) protected booleanaddUserStore(org.jdom2.Element root) (package private) voidCommon check routine to confirm an adapter is available as part of registration process.static voidcreationErrorEncountered(XmlAdapter adapter, String operation, String description, String systemName, String userName, Throwable exception) Invoke common handling of errors that happen during the "load" process.static StringcurrentClassName(String name) Handles ConfigureXml classes that have moved to a new package or been superseded.voidderegister(Object o) static org.jdom2.Elementstatic org.jdom2.ElementelementFromObject(Object object, boolean shared) protected booleanfinalStore(org.jdom2.Element root, File file) 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 directoryfindInstance(Class<?> c, int index) Find the ith instance of an object of particular class that's been registered for storage.getInstanceList(Class<?> c) Returns a list of instances stored for a given class.protected List<org.jdom2.Element>Whether to verify the DTD of this XML file when read.protected voidincludeHistory(org.jdom2.Element root, File file) protected org.jdom2.ElementbooleanLoad a file.booleanLoad a file.booleanCreate the objects defined in a particular configuration filebooleanLoad a file.booleanloadDeferred(File fi) Create the objects defined in a particular configuration file that have been deferred until after basic GUI construction completedbooleanloadDeferred(URL url) Create the objects defined in a particular configuration file that have been deferred until after basic GUI construction completed(package private) voidlocateClassFailed(Throwable ex, String adapterName, Object o) Handle failure to load adapter class.(package private) voidReport a failure to find a file.booleanmakeBackup(File file) Make a backup file.voidvoidregisterConfig(Object o, int x) voidvoidvoidRegister an object whose state is to be tracked.voidvoidstatic voidsetErrorHandler(ErrorHandler handler) voidsetPrefsLocation(File prefsFile) Set location for preferences file.voidControl the scope of validation of XML files when loading.booleanstoreConfig(File file) Stores just configuration information.voidStores just preferences information.voidstorePrefs(File file) Stores just preferences information.booleanStores user and config information.voidstoreUserPrefs(File file) Stores just user preferences information.static voidstoringErrorEncountered(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, getDefaultDtdLocation, getDefaultValidate, getDtdLocation, getProcessingInstructionHRef, getProcessingInstructionType, getRoot, makeBackupFile, makeBackupFile, newDocument, newDocument, revertBackupFile, rootFromFile, rootFromInputStream, rootFromName, rootFromURL, setDefaultDtdLocation, setDefaultValidate, setDtdLocation, userFileChooser, userFileChooser, writeXML, xmlDir
-
Field Details
-
schemaVersion
Define the current schema version string for the layout-config schema. See the Schema versioning discussion. Also controls the stylesheet file version.- See Also:
-
clist
-
prefsFile
-
-
Constructor Details
-
ConfigXmlManager
public ConfigXmlManager()
-
-
Method Details
-
registerConfig
- Specified by:
registerConfigin interfaceConfigureManager
-
registerPref
- Specified by:
registerPrefin interfaceConfigureManager
-
confirmAdapterAvailable
Common check routine to confirm an adapter is available as part of registration process.Note: Should only be called for debugging purposes, for example, when Log4J DEBUG level is selected, to load fewer classes at startup.
- Parameters:
o- object to confirm XML adapter exists for
-
currentClassName
Handles ConfigureXml classes that have moved to a new package or been superseded.- Parameters:
name- name of the moved or superceded ConfigureXml class- Returns:
- name of the ConfigureXml class in newer package or of superseding class
-
removePrefItems
- Specified by:
removePrefItemsin interfaceConfigureManager
-
findInstance
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:
findInstancein interfaceConfigureManager- Parameters:
c- Class of the desired objectsindex- a 1-based index of the object to return- Returns:
- an object of class c or null
-
getInstanceList
Returns a list of instances stored for a given class.- Specified by:
getInstanceListin interfaceConfigureManager- Parameters:
c- Class of the desired objects- Returns:
- an List of objects of class c or null
-
registerConfig
- Specified by:
registerConfigin interfaceConfigureManager
-
registerTool
- Specified by:
registerToolin interfaceConfigureManager
-
registerUser
Register an object whose state is to be tracked. It is not an error if the original object was already registered.- Specified by:
registerUserin interfaceConfigureManager- Parameters:
o- The object, which must have an associated adapter class.
-
registerUserPrefs
- Specified by:
registerUserPrefsin interfaceConfigureManager
-
deregister
- Specified by:
deregisterin interfaceConfigureManager
-
adapterName
Find the name of the adapter class for an object.- Parameters:
o- object of a configurable type- Returns:
- class name of adapter
-
locateClassFailed
Handle failure to load adapter class. Although only a one-liner in this class, it is a separate member to facilitate testing.- Parameters:
ex- the exception throw failing to load adapterName as oadapterName- name of the adapter classo- adapter object
-
initStore
-
addPrefsStore
-
addConfigStore
-
addToolsStore
-
addUserStore
-
addUserPrefsStore
-
includeHistory
-
finalStore
-
storePrefs
Stores just preferences information.Where that information is stored is implementation-specific.
- Specified by:
storePrefsin interfaceConfigureManager
-
storePrefs
Stores just preferences information.- Specified by:
storePrefsin interfaceConfigureManager- Parameters:
file- the to store preferences into
-
storeUserPrefs
Stores just user preferences information.- Specified by:
storeUserPrefsin interfaceConfigureManager- Parameters:
file- the file to store user preferences into
-
setPrefsLocation
Set location for preferences file.File need not exist, but location must be writable when storePrefs() called.
- Parameters:
prefsFile- new location for preferences file
-
storeConfig
Stores just configuration information.- Specified by:
storeConfigin interfaceConfigureManager- Parameters:
file- Output file- Returns:
- true if successful; false otherwise
-
storeUser
Stores user and config information.- Specified by:
storeUserin interfaceConfigureManager- Parameters:
file- Output file- Returns:
- true if succeeded
-
makeBackup
Make a backup file.- Specified by:
makeBackupin interfaceConfigureManager- Parameters:
file- to be backed up- Returns:
- true if successful
-
elementFromObject
- Parameters:
o- The object to get an XML representation of- Returns:
- An XML element representing o
-
elementFromObject
- Parameters:
object- The object to get an XML representation ofshared- true if the XML should be shared, false if the XML should be per-node- Returns:
- An XML element representing object
-
load
Load a file.Handles problems locally to the extent that it can, by routing them to the creationErrorEncountered method.
- Specified by:
loadin interfaceConfigureManager- Parameters:
fi- file to load- Returns:
- true if no problems during the load
- Throws:
JmriConfigureXmlException- if unable to load file
-
load
Create the objects defined in a particular configuration file- Specified by:
loadin interfaceConfigureManager- Parameters:
url- Input URL- Returns:
- true if succeeded
- Throws:
JmriConfigureXmlException
-
load
Load a file.Handles problems locally to the extent that it can, by routing them to the creationErrorEncountered method.
- Specified by:
loadin interfaceConfigureManager- Parameters:
fi- file to loadregisterDeferred- true to register objects to defer- Returns:
- true if no problems during the load
- Throws:
JmriConfigureXmlException- if problem during load- Since:
- 2.11.2
- See Also:
-
load
Load a file.Handles problems locally to the extent that it can, by routing them to the creationErrorEncountered method.
Always processes on Swing thread
- Specified by:
loadin interfaceConfigureManager- Parameters:
url- URL of file to loadregisterDeferred- true to register objects to defer- Returns:
- true if no problems during the load
- Throws:
JmriConfigureXmlException- if problem during load- Since:
- 3.3.2
- See Also:
-
setValidate
Control the scope of validation of XML files when loading.- Specified by:
setValidatein interfaceConfigureManager- Overrides:
setValidatein classXmlFile- Parameters:
v- the validation scope
-
getValidate
Whether to verify the DTD of this XML file when read.- Specified by:
getValidatein interfaceConfigureManager- Overrides:
getValidatein classXmlFile- Returns:
- the level of validation to apply to a file
-
loadDeferred
Create the objects defined in a particular configuration file that have been deferred until after basic GUI construction completed- Specified by:
loadDeferredin interfaceConfigureManager- Parameters:
fi- Input file- Returns:
- true if succeeded
- See Also:
-
loadDeferred
Create the objects defined in a particular configuration file that have been deferred until after basic GUI construction completed- Specified by:
loadDeferredin interfaceConfigureManager- Parameters:
url- Input URL- Returns:
- true if succeeded
- See Also:
-
find
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
- Specified by:
findin interfaceConfigureManager- Parameters:
f- Local filename, perhaps without path information- Returns:
- Corresponding File object
-
locateFileFailed
Report a failure to find a file. This is a separate member to ease testing.- Parameters:
f- Name of file not located.
-
creationErrorEncountered
public 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.Exceptions passed into this are absorbed.
- Parameters:
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
-
storingErrorEncountered
public 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.Exceptions passed into this are absorbed.
- Parameters:
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
-
setErrorHandler
-
getLoadDeferredList
- Returns:
- the loadDeferredList
-