Package jmri.managers

Class DefaultConditionalManager

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

        public Conditional createNewConditional​(java.lang.String systemName,
                                                java.lang.String userName)
        Method to create a new Conditional if the Conditional does not exist If the parent Logix cannot be found, the userName cannot be checked, but the Conditional is still created. The scenario can happen when a Logix is loaded from a file after its Conditionals.
        Specified by:
        createNewConditional in interface ConditionalManager
        Parameters:
        systemName - properly formatted system name for the new Conditional
        userName - must not be null, use "" instead
        Returns:
        null if a Conditional with the same systemName or userName already exists, or if there is trouble creating a new Conditional
      • getParentLogix

        public Logix getParentLogix​(java.lang.String name)
        Parses the Conditional system name to get the parent Logix system name, then gets the parent Logix, and returns it. For sensor groups, the parent Logix name is 'SYS'. LRoutes and exported Routes (RTX prefix) require special logic
        Specified by:
        getParentLogix in interface ConditionalManager
        Parameters:
        name - system name of Conditionals
        Returns:
        the parent Logix or null
      • getConditional

        public Conditional getConditional​(Logix x,
                                          java.lang.String name)
        Method to get an existing Conditional. First looks up assuming that name is a User Name. Note: the parent Logix must be passed in x for user name lookup. If this fails, or if x == null, looks up assuming that name is a System Name. If both fail, returns null.
        Specified by:
        getConditional in interface ConditionalManager
        Parameters:
        x - parent Logix (may be null)
        name - name to look up
        Returns:
        null if no match 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<Conditional>
        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

        public java.lang.Class<ConditionalgetNamedBeanClass()
        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<Conditional>
        Returns:
        the class supported by this Manager.
      • addWhereUsed

        public void addWhereUsed​(java.lang.String target,
                                 java.lang.String reference)
        Add a conditional reference to the array indicated by the target system name.
        Specified by:
        addWhereUsed in interface ConditionalManager
        Parameters:
        target - The system name for the target conditional
        reference - The system name of the conditional that contains the conditional reference
        Since:
        4.7.4
      • getWhereUsed

        public java.util.ArrayList<java.lang.String> getWhereUsed​(java.lang.String target)
        Get a list of conditional references for the indicated conditional
        Specified by:
        getWhereUsed in interface ConditionalManager
        Parameters:
        target - The target conditional for a conditional reference
        Returns:
        an ArrayList or null if none
        Since:
        4.7.4
      • removeWhereUsed

        public void removeWhereUsed​(java.lang.String target,
                                    java.lang.String reference)
        Remove a conditional reference from the array indicated by the target system name.
        Specified by:
        removeWhereUsed in interface ConditionalManager
        Parameters:
        target - The system name for the target conditional
        reference - The system name of the conditional that contains the conditional reference
        Since:
        4.7.4
      • getTargetList

        public java.util.ArrayList<java.lang.String> getTargetList​(java.lang.String reference)
        Get the target system names used by this conditional
        Specified by:
        getTargetList in interface ConditionalManager
        Parameters:
        reference - The system name of the conditional the refers to other conditionals.
        Returns:
        a list of the target conditionals
        Since:
        4.7.4