Class BlockManagerXml

  • All Implemented Interfaces:
    XmlAdapter

    public class BlockManagerXml
    extends AbstractMemoryManagerConfigXML
    Persistency implementation for BlockManager persistence.

    The Block objects are not yet read in, pending a reliable write out!

    Every block is written twice. First, the list of blocks is written without contents, so that we're sure they're all created on read-back. Then, they're written out again with contents, including the block references in the path elements.

    Since:
    2.1.2
    • Method Detail

      • setStoreElementClass

        public void setStoreElementClass​(org.jdom2.Element memories)
        Subclass provides implementation to create the correct top element, including the type information. Default implementation is to use the local class here.
        Specified by:
        setStoreElementClass in class AbstractMemoryManagerConfigXML
        Parameters:
        memories - The top-level element being created
      • store

        public org.jdom2.Element store​(java.lang.Object o)
        Store the contents of a BlockManager.
        Specified by:
        store in interface XmlAdapter
        Overrides:
        store in class AbstractMemoryManagerConfigXML
        Parameters:
        o - Object to store, of type BlockManager
        Returns:
        Element containing the complete info
      • load

        public boolean load​(org.jdom2.Element sharedBlocks,
                            org.jdom2.Element perNodeBlocks)
                     throws JmriConfigureXmlException
        Load Blocks into the existing BlockManager.

        The BlockManager in the InstanceManager is created automatically.

        Specified by:
        load in interface XmlAdapter
        Specified by:
        load in class AbstractMemoryManagerConfigXML
        Parameters:
        sharedBlocks - Element containing the block elements to load
        perNodeBlocks - Per-node block elements to load
        Returns:
        true if successful
        Throws:
        JmriConfigureXmlException - if error during load
      • loadBlock

        public void loadBlock​(org.jdom2.Element element)
                       throws JmriConfigureXmlException
        Utility method to load the individual Block objects.
        Parameters:
        element - Element containing one block
        Throws:
        JmriConfigureXmlException - if element contains malformed or schematically invalid XMl
      • loadPath

        public boolean loadPath​(Block block,
                                org.jdom2.Element element)
                         throws JmriConfigureXmlException
        Load path into an existing Block from XML.
        Parameters:
        block - Block to receive path
        element - Element containing path information
        Returns:
        true if path added to block; false otherwise
        Throws:
        JmriConfigureXmlException - if element contains malformed or schematically invalid XMl
      • loadBeanSetting

        public void loadBeanSetting​(Path path,
                                    org.jdom2.Element element)
        Load BeanSetting into an existing Path.
        Parameters:
        path - Path to receive BeanSetting
        element - Element containing beansetting information