Class OBlockManager

All Implemented Interfaces:
PropertyChangeListener, VetoableChangeListener, EventListener, PropertyChangeFirer, PropertyChangeProvider, SilenceablePropertyChangeProvider, VetoableChangeFirer, VetoableChangeProvider, InstanceManagerAutoDefault, Manager<OBlock>, ProvidingManager<OBlock>

Basic Implementation of an OBlockManager.

Note that this does not enforce any particular system naming convention.

Note this is a concrete class, there are now 2 types of Blocks (LayoutBlocks use a Block member and inheritance). Perhaps now the proxyManager strategy of interface/implementation pairs like other Managers should be implemented.

  • Constructor Details

  • Method Details

    • 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<OBlock>
      Returns:
      write order for this Manager; larger is later.
    • typeLetter

      public char typeLetter()
      Specified by:
      typeLetter in interface Manager<OBlock>
      Returns:
      The type letter for a specific implementation
    • createNewOBlock

      Create a new OBlock if it does not exist.
      Parameters:
      systemName - System name
      userName - User name
      Returns:
      newly created OBlock, or null if an OBlock with the same systemName or userName already exists, or if there is trouble creating a new OBlock
    • createNewOBlock

      Create a new OBlock using an automatically incrementing system name.
      Parameters:
      userName - the user name for the new OBlock
      Returns:
      null if an OBlock with the same systemName or userName already exists, or if there is trouble creating a new OBlock.
    • getOBlock

      Get an existing OBlock by a given name. First looks up assuming that name is a User Name. If this fails looks up assuming that name is a System Name. If both fail, returns null.
      Parameters:
      name - OBlock name
      Returns:
      the OBlock, or null if not found.
    • provide

      public OBlock provide(@Nonnull String name)
      Description copied from interface: ProvidingManager
      Get an existing instance via user name, then system name; if no matching instance is found, create a new NameBean from the system name.

      If the name is a valid system name, it will be used for the new NamedBean. Otherwise, the Manager.makeSystemName(java.lang.String) method will attempt to turn it into a valid system name which the manager will attempt to use. If that fails, an exception is thrown.

      This is similar to the specific methods found in certain type-specific managers: TurnoutManager.provideTurnout(java.lang.String), SensorManager.provideSensor(java.lang.String), et al. Those might be more mnemonic; this one is more generic. Neither is preferred nor deprecated; use your choice.

      Specified by:
      provide in interface ProvidingManager<OBlock>
      Parameters:
      name - User name, system name, or address which can be promoted to system name
      Returns:
      Never null
    • provideOBlock

    • getBeanTypeHandled

      @Nonnull public 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<OBlock>
      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
    • getNamedBeanClass

      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<OBlock>
      Returns:
      the class supported by this Manager.