Class CombinationConfigKey


  • public class CombinationConfigKey
    extends ConfigKey<boolean[]>
    Config key that can select zero or more items from a short fixed list. The string representation is an unordered list of the first letters (lowercased) of each of the given option labels. So the labels had better have different initial letters.

    Typically this is used for axes.

    Since:
    5 Oct 2013
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      CombinationConfigKey​(ConfigMeta meta, boolean[] dflt, java.lang.String[] optNames, java.lang.String nullLabel)
      Constructs an instance with a specified default.
      CombinationConfigKey​(ConfigMeta meta, java.lang.String[] optNames)
      Constructs an instance where all the default inclusion flags are true and a null value is not permitted.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Specifier<boolean[]> createSpecifier()
      Constructs a graphical control with which the user can specify a suitable value for association with this key.
      int optCharToIndex​(char c)
      Gets the option index from an initial character.
      char optIndexToChar​(int io)
      Gets the initial letter from the option index.
      boolean[] stringToValue​(java.lang.String txt)
      Decodes a string value to the value type of this key.
      java.lang.String valueToString​(boolean[] opts)
      Reports a value as a string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CombinationConfigKey

        public CombinationConfigKey​(ConfigMeta meta,
                                    boolean[] dflt,
                                    java.lang.String[] optNames,
                                    java.lang.String nullLabel)
        Constructs an instance with a specified default.
        Parameters:
        meta - metadata
        dflt - default array of selection flags
        optNames - labels for each of the options that may be selected, same length as dflt
        nullLabel - label for a specifer option indicating the null value; null is a permitted value only if this parameter is non-null
      • CombinationConfigKey

        public CombinationConfigKey​(ConfigMeta meta,
                                    java.lang.String[] optNames)
        Constructs an instance where all the default inclusion flags are true and a null value is not permitted.
        Parameters:
        meta - metadata
        optNames - labels for each of the options that may be selected,
    • Method Detail

      • stringToValue

        public boolean[] stringToValue​(java.lang.String txt)
                                throws ConfigException
        Description copied from class: ConfigKey
        Decodes a string value to the value type of this key. An empty string should be interpreted as a null value, but this may cause an exception if null is not a permissible value for this key.
        Specified by:
        stringToValue in class ConfigKey<boolean[]>
        Parameters:
        txt - string representation of value
        Returns:
        value
        Throws:
        ConfigException
      • valueToString

        public java.lang.String valueToString​(boolean[] opts)
        Description copied from class: ConfigKey
        Reports a value as a string. If at all possible the roundtripping should be possible, so stringToValue(valueToString(v)).equals(v). A null value, if permitted, should be represented as an empty string.
        Specified by:
        valueToString in class ConfigKey<boolean[]>
        Parameters:
        opts - possible value associated with this key
        Returns:
        string representation
      • createSpecifier

        public Specifier<boolean[]> createSpecifier()
        Description copied from class: ConfigKey
        Constructs a graphical control with which the user can specify a suitable value for association with this key.
        Specified by:
        createSpecifier in class ConfigKey<boolean[]>
        Returns:
        new specifier
      • optCharToIndex

        public int optCharToIndex​(char c)
                           throws ConfigException
        Gets the option index from an initial character.
        Parameters:
        c - label character, case unimportant
        Returns:
        option index
        Throws:
        ConfigException - if no index is indicated (unknown letter)
      • optIndexToChar

        public char optIndexToChar​(int io)
        Gets the initial letter from the option index.
        Parameters:
        io - option index
        Returns:
        lowercased initial letter