Package jmri.managers

Class DefaultSectionManager

  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.beans.VetoableChangeListener, java.util.EventListener, PropertyChangeFirer, PropertyChangeProvider, SilenceablePropertyChangeProvider, VetoableChangeFirer, VetoableChangeProvider, Manager<Section>, SectionManager

    public class DefaultSectionManager
    extends AbstractManager<Section>
    implements SectionManager
    Basic Implementation of a SectionManager.

    This doesn't have a "new" interface, since Sections are independently implemented, instead of being system-specific.

    Note that Section system names must begin with system prefix and type character, usually IY, and be followed by a string, usually, but not always, a number. This is enforced when a Section is created.


    This file is part of JMRI.

    JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

    JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    • Field Detail

      • blockList

        java.util.List<Block> blockList
        A list of blocks that will be used to create a block based section.
    • Method Detail

      • getXMLOrder

        public int getXMLOrder()
        Description copied from interface: Manager
        Determine the order that types should be written when storing panel files. Uses one of the constants defined in this class.

        Yes, that's an overly-centralized methodology, but it works for now.

        Specified by:
        getXMLOrder in interface Manager<Section>
        Returns:
        write order for this Manager; larger is later.
      • getNamedBeanClass

        public java.lang.Class<SectiongetNamedBeanClass()
        Description copied from interface: Manager
        Get the class of NamedBean supported by this Manager. This should be the generic class used in the Manager's class declaration.
        Specified by:
        getNamedBeanClass in interface Manager<Section>
        Returns:
        the class supported by this Manager.
      • createNewSection

        @Nonnull
        public Section createNewSection​(@Nonnull
                                        java.lang.String systemName,
                                        java.lang.String userName)
                                 throws java.lang.IllegalArgumentException
        Create a new Section if the Section does not exist.
        Specified by:
        createNewSection in interface SectionManager
        Parameters:
        systemName - the desired system name
        userName - the desired user name
        Returns:
        a new Section or
        Throws:
        java.lang.IllegalArgumentException - if a Section with the same systemName or userName already exists, or if there is trouble creating a new Section.
      • createNewSection

        @Nonnull
        public Section createNewSection​(java.lang.String userName)
                                 throws java.lang.IllegalArgumentException
        Create a New Section with Auto System Name.
        Specified by:
        createNewSection in interface SectionManager
        Parameters:
        userName - UserName for new Section
        Returns:
        new Section with Auto System Name.
        Throws:
        java.lang.IllegalArgumentException - if existing Section, or unable to create a new Section.
      • getSection

        public Section getSection​(java.lang.String name)
        Get an existing Section. First look up assuming that name is a User Name. If this fails look up assuming that name is a System Name.
        Specified by:
        getSection in interface SectionManager
        Parameters:
        name - the name to find; user names are searched for a match first, followed by system names
        Returns:
        the found section of null if no matching Section found
      • getBeanTypeHandled

        @Nonnull
        public java.lang.String getBeanTypeHandled​(boolean plural)
        Description copied from interface: Manager
        Get the user-readable name of the type of NamedBean handled by this manager.

        For instance, in the code where we are dealing with just a bean and a message that needs to be passed to the user or in a log.

        Specified by:
        getBeanTypeHandled in interface Manager<Section>
        Parameters:
        plural - true to return plural form of the type; false to return singular form
        Returns:
        a string of the bean type that the manager handles, eg Turnout, Sensor etc