类 StringSwitcher


  • public abstract class StringSwitcher
    extends java.lang.Object
    This class implements a simple String->int mapping for a fixed set of keys.
    • 构造器概要

      构造器 
      限定符 构造器 说明
      protected StringSwitcher()  
    • 方法概要

      所有方法 静态方法 实例方法 抽象方法 具体方法 
      修饰符和类型 方法 说明
      static StringSwitcher create​(java.lang.String[] strings, int[] ints, boolean fixedInput)
      Helper method to create a StringSwitcher.
      abstract int intValue​(java.lang.String s)
      Return the integer associated with the given key.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • StringSwitcher

        protected StringSwitcher()
    • 方法详细资料

      • create

        public static StringSwitcher create​(java.lang.String[] strings,
                                            int[] ints,
                                            boolean fixedInput)
        Helper method to create a StringSwitcher. For finer control over the generated instance, use a new instance of StringSwitcher.Generator instead of this static method.
        参数:
        strings - the array of String keys; must be the same length as the value array
        ints - the array of integer results; must be the same length as the key array
        fixedInput - if false, an unknown key will be returned from intValue(java.lang.String) as -1; if true, the result will be undefined, and the resulting code will be faster
      • intValue

        public abstract int intValue​(java.lang.String s)
        Return the integer associated with the given key.
        参数:
        s - the key
        返回:
        the associated integer value, or -1 if the key is unknown (unless fixedInput was specified when this StringSwitcher was created, in which case the return value for an unknown key is undefined)