Class AbstractNamedBeanManagerConfigXML

    • Method Detail

      • storeCommon

        protected void storeCommon​(NamedBean t,
                                   org.jdom2.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,
                                  org.jdom2.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,
                          org.jdom2.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,
                           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 stored
        elem - 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 Elements
        i - 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 normalization
        rawUserName - The proposed user name string, before normalization
        manager - 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 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 NamedBeanNamedBeanHandle<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 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> 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 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,
                         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 loaded
        beanList - List, where each entry is an Element
        i - 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 loaded
        elem - 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 Element
        name - 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 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,
                             org.jdom2.Element elem)
        Store all key/value properties.
        Parameters:
        t - The NamedBean being loaded
        elem - The existing Element
      • loadProperties

        void loadProperties​(NamedBean t,
                            org.jdom2.Element elem)
        Load all key/value properties
        Parameters:
        t - The NamedBean being loaded
        elem - 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 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