Class AbstractNamedBeanManagerConfigXML
- java.lang.Object
-
- jmri.configurexml.AbstractXmlAdapter
-
- jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML
-
- All Implemented Interfaces:
XmlAdapter
- Direct Known Subclasses:
AbstractAudioManagerConfigXML
,AbstractDebuggerMaleSocketXml
,AbstractLightManagerConfigXML
,AbstractMaleSocketXml
,AbstractManagerXml
,AbstractMemoryManagerConfigXML
,AbstractMeterManagerXml
,AbstractReporterManagerConfigXML
,AbstractSensorManagerConfigXML
,AbstractSignalHeadManagerXml
,AbstractTurnoutManagerConfigXML
,AcelaSignalHeadXml
,ActionAudioIconXml
,ActionAudioXml
,ActionBlockXml
,ActionClearSlotsXml
,ActionClockRateXml
,ActionClockXml
,ActionCreateBeansFromTableXml
,ActionDispatcherXml
,ActionEntryExitXml
,ActionFindTableRowOrColumnXml
,ActionLayoutTurnoutXml
,ActionLightIntensityXml
,ActionLightXml
,ActionListenOnBeansLocalVariableXml
,ActionListenOnBeansTableXml
,ActionListenOnBeansXml
,ActionLocalVariableXml
,ActionMemoryXml
,ActionOBlockXml
,ActionPositionableByClassXml
,ActionPositionableXml
,ActionPowerXml
,ActionReporterXml
,ActionRequestUpdateAllSensorsXml
,ActionRequestUpdateOfSensorXml
,ActionScriptXml
,ActionSensorXml
,ActionSetReporterXml
,ActionShutDownTaskXml
,ActionSignalHeadXml
,ActionSignalMastXml
,ActionSoundXml
,ActionTableXml
,ActionThrottleFunctionXml
,ActionThrottleXml
,ActionTimerXml
,ActionTurnoutLockXml
,ActionTurnoutXml
,ActionUpdateSlotsXml
,ActionWarrantXml
,AnalogActionLightIntensityXml
,AnalogActionMemoryXml
,AnalogExpressionAnalogIOXml
,AnalogExpressionConstantXml
,AnalogExpressionLocalVariableXml
,AnalogExpressionMemoryXml
,AnalogFormulaXml
,AnalogManyXml
,AndXml
,AntecedentXml
,BiDiBSignalMastXml
,BreakXml
,ClipboardManyXml
,ConnectionNameXml
,ContinueXml
,CtcManagerXml
,DccSignalHeadXml
,DccSignalMastXml
,DefaultConditionalManagerXml
,DefaultConditionalNGManagerXml
,DefaultCsvNamedTableXml
,DefaultGlobalVariableXml
,DefaultLogixManagerXml
,DefaultLogixNGManagerXml
,DefaultModuleXml
,DefaultRouteManagerXml
,DefaultSectionManagerXml
,DefaultSignalGroupManagerXml
,DefaultSignalMastLogicManagerXml
,DefaultSignalMastManagerXml
,DefaultTransitManagerXml
,DefaultVariableLightManagerXml
,DigitalBooleanLogixActionXml
,DigitalBooleanManyXml
,DigitalCallModuleXml
,DigitalCallModuleXml
,DigitalFormulaXml
,DigitalFormulaXml
,DigitalManyXml
,DoAnalogActionXml
,DoStringActionXml
,DoubleTurnoutSignalHeadXml
,EcosLocoAddressManagerXml
,EnableLogixNGXml
,EnableLogixXml
,ErrorXml
,ExecuteActionXml
,ExecuteDelayedXml
,ExitXml
,ExpressionAudioXml
,ExpressionBlockXml
,ExpressionClockXml
,ExpressionConditionalXml
,ExpressionDispatcherXml
,ExpressionEntryExitXml
,ExpressionLightXml
,ExpressionLinuxLinePowerXml
,ExpressionLocalVariableXml
,ExpressionMemoryXml
,ExpressionOBlockXml
,ExpressionPowerXml
,ExpressionReferenceXml
,ExpressionReporterXml
,ExpressionScriptXml
,ExpressionSectionXml
,ExpressionSensorEdgeXml
,ExpressionSensorXml
,ExpressionSignalHeadXml
,ExpressionSignalMastXml
,ExpressionSlotUsageXml
,ExpressionTransitXml
,ExpressionTurnoutXml
,ExpressionWarrantXml
,FalseXml
,FileAsFlagXml
,ForEachXml
,ForXml
,HoldXml
,IfThenElseXml
,InternalAnalogIOManagerXml
,JsonDecodeXml
,LastResultOfDigitalExpressionXml
,LayoutBlockManagerXml
,LnStringIOManagerXml
,LogDataXml
,LogDataXml
,LogixXml
,LogLocalVariablesXml
,LsDecSignalHeadXml
,MatrixSignalMastXml
,MergSD2SignalHeadXml
,MqttSignalMastXml
,NotXml
,OlcbSignalMastXml
,OrXml
,ProgramOnMainXml
,PublishXml
,ReturnXml
,RunOnceXml
,SE8cSignalHeadXml
,SE8cSignalHeadXml
,SequenceXml
,SerialSignalHeadXml
,SetSpeedZeroXml
,ShowDialogXml
,ShutdownComputerXml
,SignalHeadSignalMastXml
,SimulateTurnoutFeedbackXml
,SingleTurnoutSignalHeadXml
,StringActionMemoryXml
,StringActionStringIOXml
,StringExpressionConstantXml
,StringExpressionMemoryXml
,StringFormulaXml
,StringManyXml
,SubscribeXml
,TableForEachXml
,TimeoutXml
,TimerXml
,TimeSinceMidnightXml
,TriggerOnceXml
,TriggerRouteXml
,TrueXml
,TurnoutSignalMastXml
,VirtualSignalHeadXml
,VirtualSignalMastXml
,WebBrowserXml
,WebRequestXml
,WindowManagementXml
public abstract class AbstractNamedBeanManagerConfigXML extends AbstractXmlAdapter
Provides services for configuring NamedBean manager storage.Not a full abstract implementation by any means, rather this class provides various common service routines to eventual type-specific subclasses.
- Since:
- 2.3.1
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.configurexml.AbstractXmlAdapter
AbstractXmlAdapter.EnumIO<T extends java.lang.Enum<T>>, AbstractXmlAdapter.EnumIoMapped<T extends java.lang.Enum<T>>, AbstractXmlAdapter.EnumIoNames<T extends java.lang.Enum<T>>, AbstractXmlAdapter.EnumIoNamesNumbers<T extends java.lang.Enum<T>>, AbstractXmlAdapter.EnumIoOrdinals<T extends java.lang.Enum<T>>
-
-
Constructor Summary
Constructors Constructor Description AbstractNamedBeanManagerConfigXML()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends NamedBean>
NamedBeanHandle<T>checkedNamedBeanHandle(java.lang.String name, T type, Manager<T> m)
Service method to load a NamedBeanHandle to a NamedBean by name, check it for validity, and if need be notify about errors.<T extends NamedBean>
java.lang.StringcheckedNamedBeanName(java.lang.String name, T type, Manager<T> m)
Service method to reference to a NamedBean by name, and if need be notify about errors.<T extends NamedBean>
TcheckedNamedBeanReference(java.lang.String name, T type, Manager<T> m)
Service method to load a reference to a NamedBean by name, check it for validity, and if need be notify about errors.(package private) <T extends NamedBean>
voidcheckNameNormalization(java.lang.String rawSystemName, java.lang.String rawUserName, Manager<T> manager)
Common service routine to check for and report on normalization (errors) in the incoming NamedBean's name(s)(package private) boolean
getAttributeBool(org.jdom2.Element elem, java.lang.String name, boolean def)
Convenience method to get a boolean value from an Attribute in an Element defining a NamedBean.(package private) java.lang.String
getAttributeString(org.jdom2.Element elem, java.lang.String name)
Convenience method to get a String value from an Attribute in an Element defining a NamedBean.protected java.lang.String
getSystemName(org.jdom2.Element elem)
Service method to load a system name.protected java.lang.String
getUserName(java.util.List<org.jdom2.Element> beanList, int i)
Get the username attribute from one element of a list of Elements defining NamedBeans.protected java.lang.String
getUserName(org.jdom2.Element elem)
Service method to load a user name, check it for validity, and if need be notify about errors.(package private) void
loadComment(NamedBean t, java.util.List<org.jdom2.Element> beanList, int i)
Load the comment attribute into a NamedBean from one element of a list of Elements defining NamedBeans(package private) void
loadComment(NamedBean t, org.jdom2.Element elem)
Load the comment attribute into a NamedBean from an Element defining a NamedBeanprotected void
loadCommon(NamedBean t, org.jdom2.Element elem)
Load common items: comment The username is not loaded, because it had to be provided in the ctor earlier.(package private) boolean
loadInAdapter(java.util.List<org.jdom2.Element> list, org.jdom2.Element perNode)
Load all attribute properties from a list.(package private) void
loadProperties(NamedBean t, org.jdom2.Element elem)
Load all key/value properties(package private) void
storeComment(NamedBean t, org.jdom2.Element elem)
Store the comment parameter from a NamedBeanprotected void
storeCommon(NamedBean t, org.jdom2.Element elem)
Store common items: user name comment(package private) void
storeProperties(NamedBean t, org.jdom2.Element elem)
Store all key/value properties.(package private) void
storeUserName(NamedBean t, org.jdom2.Element elem)
Store the username parameter from a NamedBean.-
Methods inherited from class jmri.configurexml.AbstractXmlAdapter
getAttributeBooleanValue, getAttributeDoubleValue, getAttributeFloatValue, getAttributeIntegerValue, getExceptionHandler, handleException, load, load, load, load, loadDeferred, loadOrder, setExceptionHandler, store
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.configurexml.XmlAdapter
store
-
-
-
-
Constructor Detail
-
AbstractNamedBeanManagerConfigXML
public AbstractNamedBeanManagerConfigXML()
-
-
Method Detail
-
storeCommon
protected void storeCommon(NamedBean t, org.jdom2.Element elem)
Store common items:- user name
- comment
- Parameters:
t
- The NamedBean being storedelem
- The JDOM element for storing the NamedBean
-
loadCommon
protected void loadCommon(NamedBean t, org.jdom2.Element elem)
Load common items:- comment
- Parameters:
t
- The NamedBean being loadedelem
- The JDOM element containing the NamedBean
-
storeComment
void storeComment(NamedBean t, org.jdom2.Element elem)
Store the comment parameter from a NamedBean- Parameters:
t
- The NamedBean being storedelem
- The JDOM element for storing the NamedBean
-
storeUserName
void storeUserName(NamedBean t, org.jdom2.Element elem)
Store the username parameter from a NamedBean.- Before 2.9.6, this was an attribute
- Starting in 2.9.6, this was stored as both attribute and element
- Starting in 3.1/2.11.1, this will be just an element
- Parameters:
t
- The NamedBean being storedelem
- The JDOM element for storing the NamedBean
-
getUserName
protected java.lang.String getUserName(java.util.List<org.jdom2.Element> beanList, int i)
Get the username attribute from one element of a list of Elements defining NamedBeans.- Parameters:
beanList
- list of Elementsi
- index of Element in list to examine- Returns:
- the user name of bean in beanList at i or null
-
getUserName
protected java.lang.String getUserName(@Nonnull org.jdom2.Element elem)
Service method to load a user name, check it for validity, and if need be notify about errors.The name can be empty, but if present, has to be valid.
There's no check to make sure the name corresponds to an existing bean, as sometimes this is used to check validity before creating the bean.
- Before 2.9.6, this was stored as an attribute
- Starting in 2.9.6, this was stored as both attribute and element
- Starting in 3.1/2.11.1, this is stored as an element
- Parameters:
elem
- The existing Element- Returns:
- the user name of bean or null
-
getSystemName
protected java.lang.String getSystemName(@Nonnull org.jdom2.Element elem)
Service method to load a system name.There's no check to make sure the name corresponds to an existing bean, as sometimes this is used to check validity before creating the bean. Validity (format) checks are deferred to later, see
checkNameNormalization(java.lang.String, java.lang.String, jmri.Manager<T>)
.- Before 2.9.6, this was stored as an attribute
- Starting in 2.9.6, this was stored as both attribute and element
- Starting in 3.1/2.10.1, this is stored as an element
- Parameters:
elem
- The existing Element- Returns:
- the system name or null if not defined
-
checkNameNormalization
<T extends NamedBean> void checkNameNormalization(@Nonnull java.lang.String rawSystemName, java.lang.String rawUserName, @Nonnull Manager<T> manager)
Common service routine to check for and report on normalization (errors) in the incoming NamedBean's name(s)If NamedBeam.normalizeUserName changes, this may want to be updated.
Right now, this just logs. Someday, perhaps it should notify upward of found issues by throwing an exception.
Package-level access to allow testing
- Type Parameters:
T
- The type of NamedBean being checked, i.e. Turnout, Sensor, etc- Parameters:
rawSystemName
- The proposed system name string, before normalizationrawUserName
- The proposed user name string, before normalizationmanager
- The NamedBeanManager that will be storing this
-
checkedNamedBeanReference
public <T extends NamedBean> T checkedNamedBeanReference(java.lang.String name, @Nonnull T type, @Nonnull Manager<T> m)
Service method to load a reference to a NamedBean by name, check it for validity, and if need be notify about errors.The name can be empty (method returns null), but if present, has to resolve to an existing bean.
- Type Parameters:
T
- The type of NamedBean to return- Parameters:
name
- System name, User name, empty string or nulltype
- A reference to the desired type, typically the name of the various being loaded, e.g. a Sensor referencem
- Manager used to check name for validity and existence- Returns:
- the requested NamedBean or null if name was null
-
checkedNamedBeanHandle
public <T extends NamedBean> NamedBeanHandle<T> checkedNamedBeanHandle(java.lang.String name, @Nonnull T type, @Nonnull Manager<T> m)
Service method to load a NamedBeanHandle to a NamedBean by name, check it for validity, and if need be notify about errors.The name can be empty (method returns null), but if present, has to resolve to an existing bean.
- Type Parameters:
T
- The type of NamedBean to return a handle for- Parameters:
name
- System name, User name, empty string or nulltype
- A reference to the desired type, typically the name of the various being loaded, e.g. a Sensor referencem
- Manager used to check name for validity and existence- Returns:
- a handle for the requested NamedBean or null
-
checkedNamedBeanName
public <T extends NamedBean> java.lang.String checkedNamedBeanName(java.lang.String name, T type, @Nonnull Manager<T> m)
Service method to reference to a NamedBean by name, and if need be notify about errors.The name can be empty (method returns null), but if present, has to resolve to an existing bean. or new).
- Type Parameters:
T
- The type of the NamedBean- Parameters:
name
- System name, User name, empty string or nulltype
- A reference to the desired type, typically the name of the various being loaded, e.g. a Sensor reference; may have null value, but has to be typedm
- Manager used to check name for validity and existence- Returns:
- name if a matching NamedBean can be found or null
-
loadComment
void loadComment(NamedBean t, java.util.List<org.jdom2.Element> beanList, int i)
Load the comment attribute into a NamedBean from one element of a list of Elements defining NamedBeans- Parameters:
t
- The NamedBean being loadedbeanList
- List, where each entry is an Elementi
- index of Element in list to examine
-
loadComment
void loadComment(NamedBean t, org.jdom2.Element elem)
Load the comment attribute into a NamedBean from an Element defining a NamedBean- Parameters:
t
- The NamedBean being loadedelem
- The existing Element
-
getAttributeString
java.lang.String getAttributeString(org.jdom2.Element elem, java.lang.String name)
Convenience method to get a String value from an Attribute in an Element defining a NamedBean.- Parameters:
elem
- existing Elementname
- name of desired Attribute- Returns:
- attribute value or null if name is not an attribute of elem
-
getAttributeBool
boolean getAttributeBool(org.jdom2.Element elem, java.lang.String name, boolean def)
Convenience method to get a boolean value from an Attribute in an Element defining a NamedBean.- Parameters:
elem
- existing Elementname
- name of desired Attributedef
- default value for attribute- Returns:
- value of attribute name or def if name is not an attribute of elem
-
storeProperties
void storeProperties(NamedBean t, org.jdom2.Element elem)
Store all key/value properties.- Parameters:
t
- The NamedBean being loadedelem
- The existing Element
-
loadProperties
void loadProperties(NamedBean t, org.jdom2.Element elem)
Load all key/value properties- Parameters:
t
- The NamedBean being loadedelem
- The existing Element
-
loadInAdapter
boolean loadInAdapter(java.util.List<org.jdom2.Element> list, org.jdom2.Element perNode)
Load all attribute properties from a list. TODO make abstract (remove logging) and move method to XmlAdapter so it can be used from PanelEditorXml et al- Parameters:
list
- list of Elements read from xmlperNode
- Top-level XML element containing the private, single-node elements of the description. always null in current application, included to use for Element panel in jmri.jmrit.display- Returns:
- true if the load was successful
-
-