Class AbstractXmlAdapter

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean getAttributeBooleanValue​(Element element, java.lang.String name, boolean def)
      Service method to handle attribute input of boolean (true/yes vs false/no) values.
      double getAttributeDoubleValue​(Element element, java.lang.String name, double def)
      Service method to handle attribute input of double values.
      float getAttributeFloatValue​(Element element, java.lang.String name, float def)
      Service method to handle attribute input of float values.
      int getAttributeIntegerValue​(Element element, java.lang.String name, int def)
      Service method to handle attribute input of integer values.
      ErrorHandler getExceptionHandler()
      Get the current error handler.
      void handleException​(java.lang.String description, java.lang.String operation, java.lang.String systemName, java.lang.String userName, java.lang.Exception exception)
      Provide a simple handler for errors.
      boolean load​(Element e)
      Create a set of configured objects from their XML description
      void load​(Element e, java.lang.Object o)
      Create a set of configured objects from their XML description, using an auxiliary object.
      boolean load​(Element shared, Element perNode)
      Create a set of configured objects from their XML description.
      void load​(Element shared, Element perNode, java.lang.Object o)
      Create a set of configured objects from their XML description, using an auxiliary object.
      boolean loadDeferred()
      Determine if this set of configured objects should be loaded after basic GUI construction is completed.
      int loadOrder()
      void setExceptionHandler​(ErrorHandler errorHandler)
      Set the error handler that will handle any errors encountered while parsing the XML.
      Element store​(java.lang.Object o, boolean shared)
      Store the object in XML
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • handleException

        public void handleException​(java.lang.String description,
                                    java.lang.String operation,
                                    java.lang.String systemName,
                                    java.lang.String userName,
                                    java.lang.Exception exception)
        Provide a simple handler for errors. Calls the configured ErrorHandler with an ErrorMemo created using the provided parameters.
        Specified by:
        handleException in interface XmlAdapter
        Parameters:
        description - description of error encountered
        operation - the operation being performed, may be null
        systemName - system name of bean being handled, may be null
        userName - user name of the bean being handled, may be null
        exception - Any exception being handled in the processing, may be null
      • load

        public boolean load​(Element e)
                     throws JmriConfigureXmlException
        Create a set of configured objects from their XML description
        Specified by:
        load in interface XmlAdapter
        Parameters:
        e - Top-level XML element containing the description
        Returns:
        true if successful
        Throws:
        JmriConfigureXmlException - when a error prevents creating the objects as as required by the input XML.
      • load

        public void load​(Element e,
                         java.lang.Object o)
                  throws JmriConfigureXmlException
        Create a set of configured objects from their XML description, using an auxiliary object.

        For example, the auxilary object o might be a manager or GUI of some type that needs to be informed as each object is created.

        Specified by:
        load in interface XmlAdapter
        Parameters:
        e - Top-level XML element containing the description
        o - Implementation-specific Object needed for the conversion
        Throws:
        JmriConfigureXmlException - when a error prevents creating the objects as as required by the input XML
      • load

        public boolean load​(@Nonnull
                            Element shared,
                            Element perNode)
                     throws JmriConfigureXmlException
        Create a set of configured objects from their XML description.
        Specified by:
        load in interface XmlAdapter
        Parameters:
        shared - Top-level XML element containing the common, multi-node elements of the description
        perNode - Top-level XML element containing the private, single-node elements of the description
        Returns:
        true if successful
        Throws:
        JmriConfigureXmlException - when a error prevents creating the objects as as required by the input XML
      • load

        public void load​(@Nonnull
                         Element shared,
                         Element perNode,
                         java.lang.Object o)
                  throws JmriConfigureXmlException
        Create a set of configured objects from their XML description, using an auxiliary object.

        For example, the auxilary object o might be a manager or GUI of some type that needs to be informed as each object is created.

        Specified by:
        load in interface XmlAdapter
        Parameters:
        shared - Top-level XML element containing the common description
        perNode - Top-level XML element containing the per-node description
        o - Implementation-specific Object needed for the conversion
        Throws:
        JmriConfigureXmlException - when a error prevents creating the objects as as required by the input XML
      • loadDeferred

        public boolean loadDeferred()
        Determine if this set of configured objects should be loaded after basic GUI construction is completed.

        Default behavior is to load when requested. Classes that should wait until basic GUI is constructed should override this method and return true

        Specified by:
        loadDeferred in interface XmlAdapter
        Returns:
        true to defer loading
        Since:
        2.11.2
        See Also:
        XmlAdapter.loadDeferred()
      • store

        public Element store​(@Nonnull
                             java.lang.Object o,
                             boolean shared)
        Store the object in XML
        Specified by:
        store in interface XmlAdapter
        Parameters:
        o - The object to be recorded. Specific XmlAdapter implementations will require this to be of a specific type; that binding is done in ConfigXmlManager.
        shared - true if the returned element should be the common XML and false if the returned element should be per-node.
        Returns:
        The XML representation Element
      • setExceptionHandler

        public void setExceptionHandler​(ErrorHandler errorHandler)
        Set the error handler that will handle any errors encountered while parsing the XML. If not specified, the default error handler will be used.
        Specified by:
        setExceptionHandler in interface XmlAdapter
        Parameters:
        errorHandler - the error handler or null to ignore parser errors
      • getAttributeBooleanValue

        public final boolean getAttributeBooleanValue​(@Nonnull
                                                      Element element,
                                                      @Nonnull
                                                      java.lang.String name,
                                                      boolean def)
        Service method to handle attribute input of boolean (true/yes vs false/no) values. Not being present is not an error. Not parsing (which shouldn't happen due to the XML Schema checks) invokes the default error handler.
        Parameters:
        element - the element to parse.
        name - element attribute name.
        def - default value if name not present in element.
        Returns:
        boolean value of attribute, else default if not present or error.
      • getAttributeIntegerValue

        public final int getAttributeIntegerValue​(@Nonnull
                                                  Element element,
                                                  @Nonnull
                                                  java.lang.String name,
                                                  int def)
        Service method to handle attribute input of integer values. Not being present is not an error. Not parsing (which shouldn't happen due to the XML Schema checks) invokes the default error handler.
        Parameters:
        element - the element to parse.
        name - element attribute name.
        def - default value if name not present in element.
        Returns:
        integer value of attribute, else default if not present or error.
      • getAttributeDoubleValue

        public final double getAttributeDoubleValue​(@Nonnull
                                                    Element element,
                                                    @Nonnull
                                                    java.lang.String name,
                                                    double def)
        Service method to handle attribute input of double values. Not being present is not an error. Not parsing (which shouldn't happen due to the XML Schema checks) invokes the default error handler.
        Parameters:
        element - the element to parse.
        name - element attribute name.
        def - default value if name not present in element.
        Returns:
        double value of attribute, else default if not present or error.
      • getAttributeFloatValue

        public final float getAttributeFloatValue​(@Nonnull
                                                  Element element,
                                                  @Nonnull
                                                  java.lang.String name,
                                                  float def)
        Service method to handle attribute input of float values. Not being present is not an error. Not parsing (which shouldn't happen due to the XML Schema checks) invokes the default error handler.
        Parameters:
        element - the element to parse.
        name - element attribute name.
        def - default value if name not present in element.
        Returns:
        float value of attribute, else default if not present or error.