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, ActionBlockXml, ActionClearSlotsXml, ActionEntryExitXml, ActionLightXml, ActionListenOnBeansXml, ActionLocalVariableXml, ActionMemoryXml, ActionPowerXml, ActionScriptXml, ActionSensorXml, ActionSignalHeadXml, ActionSignalMastXml, ActionSimpleScriptXml, ActionThrottleXml, ActionTimerXml, ActionTurnoutLockXml, ActionTurnoutXml, ActionUpdateSlotsXml, AnalogActionMemoryXml, AnalogExpressionConstantXml, AnalogExpressionMemoryXml, AnalogFormulaXml, AnalogManyXml, AndXml, AntecedentXml, ClipboardManyXml, CtcManagerXml, DccSignalHeadXml, DccSignalMastXml, DefaultConditionalManagerXml, DefaultConditionalNGManagerXml, DefaultCsvNamedTableXml, DefaultLogixManagerXml, DefaultLogixNGManagerXml, DefaultModuleXml, DefaultRouteManagerXml, DefaultSignalGroupManagerXml, DefaultSignalMastLogicManagerXml, DefaultSignalMastManagerXml, DigitalBooleanManyXml, DigitalBooleanOnChangeXml, DigitalCallModuleXml, DigitalFormulaXml, DigitalManyXml, DoAnalogActionXml, DoStringActionXml, DoubleTurnoutSignalHeadXml, EcosLocoAddressManagerXml, EnableLogixXml, ExecuteDelayedXml, ExpressionBlockXml, ExpressionClockXml, ExpressionConditionalXml, ExpressionEntryExitXml, ExpressionLightXml, ExpressionLocalVariableXml, ExpressionMemoryXml, ExpressionOBlockXml, ExpressionPowerXml, ExpressionReferenceXml, ExpressionScriptXml, ExpressionSensorXml, ExpressionSignalHeadXml, ExpressionSignalMastXml, ExpressionSlotUsageXml, ExpressionTurnoutXml, ExpressionWarrantXml, FalseXml, ForXml, HoldXml, IfThenElseXml, LastResultOfDigitalExpressionXml, LayoutBlockManagerXml, LogixXml, LogLocalVariablesXml, LsDecSignalHeadXml, MatrixSignalMastXml, MergSD2SignalHeadXml, NotXml, OlcbSignalMastXml, OrXml, SE8cSignalHeadXml, SE8cSignalHeadXml, SectionManagerXml, SequenceXml, SerialSignalHeadXml, ShutdownComputerXml, SignalHeadSignalMastXml, SingleTurnoutSignalHeadXml, StringActionMemoryXml, StringExpressionConstantXml, StringExpressionMemoryXml, StringFormulaXml, StringManyXml, TableForEachXml, TransitManagerXml, TriggerOnceXml, TriggerRouteXml, TrueXml, TurnoutSignalMastXml, VirtualSignalHeadXml, VirtualSignalMastXml, WebBrowserXml

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
  • Constructor Details

  • Method Details

    • storeCommon

      protected void storeCommon​(NamedBean t, Element elem)
      Store common items:
      • user name
      • comment
      Parameters:
      t - The NamedBean being stored
      elem - The JDOM element for storing the NamedBean
    • loadCommon

      protected void loadCommon​(NamedBean t, Element elem)
      Load common items:
      • comment
      The username is not loaded, because it had to be provided in the ctor earlier.
      Parameters:
      t - The NamedBean being loaded
      elem - The JDOM element containing the NamedBean
    • storeComment

      void storeComment​(NamedBean t, Element elem)
      Store the comment parameter from a NamedBean
      Parameters:
      t - The NamedBean being stored
      elem - The JDOM element for storing the NamedBean
    • storeUserName

      void storeUserName​(NamedBean t, 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 stored
      elem - The JDOM element for storing the NamedBean
    • getUserName

      protected String getUserName​(List<Element> beanList, int i)
      Get the username attribute from one element of a list of Elements defining NamedBeans.
      Parameters:
      beanList - list of Elements
      i - index of Element in list to examine
      Returns:
      the user name of bean in beanList at i or null
    • getUserName

      protected String getUserName​(@Nonnull 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 String getSystemName​(@Nonnull 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).

      • 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

      void checkNameNormalization​(@Nonnull String rawSystemName, String rawUserName, @Nonnull Manager 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

      Parameters:
      rawSystemName - The proposed system name string, before normalization
      rawUserName - The proposed user name string, before normalization
      manager - The NamedBeanManager that will be storing this
    • checkedNamedBeanReference

      public <T extends NamedBean> T checkedNamedBeanReference​(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 null
      type - A reference to the desired type, typically the name of the various being loaded, e.g. a Sensor reference
      m - 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​(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 null
      type - A reference to the desired type, typically the name of the various being loaded, e.g. a Sensor reference
      m - Manager used to check name for validity and existence
      Returns:
      a handle for the requested NamedBean or null
    • checkedNamedBeanName

      public <T extends NamedBean> String checkedNamedBeanName​(String name, T type, @Nonnull Manager 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 null
      type - 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 typed
      m - 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, List<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 loaded
      beanList - List, where each entry is an Element
      i - index of Element in list to examine
    • loadComment

      void loadComment​(NamedBean t, Element elem)
      Load the comment attribute into a NamedBean from an Element defining a NamedBean
      Parameters:
      t - The NamedBean being loaded
      elem - The existing Element
    • getAttributeString

      Convenience method to get a String value from an Attribute in an Element defining a NamedBean.
      Parameters:
      elem - existing Element
      name - name of desired Attribute
      Returns:
      attribute value or null if name is not an attribute of elem
    • getAttributeBool

      boolean getAttributeBool​(Element elem, String name, boolean def)
      Convenience method to get a boolean value from an Attribute in an Element defining a NamedBean.
      Parameters:
      elem - existing Element
      name - name of desired Attribute
      def - default value for attribute
      Returns:
      value of attribute name or def if name is not an attribute of elem
    • storeProperties

      void storeProperties​(NamedBean t, Element elem)
      Store all key/value properties.
      Parameters:
      t - The NamedBean being loaded
      elem - The existing Element
    • loadProperties

      void loadProperties​(NamedBean t, Element elem)
      Load all key/value properties
      Parameters:
      t - The NamedBean being loaded
      elem - The existing Element
    • loadInAdapter

      boolean loadInAdapter​(List<Element> list, 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 xml
      perNode - 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