Package net.sf.cglib.util
Class StringSwitcher
- java.lang.Object
-
- net.sf.cglib.util.StringSwitcher
-
public abstract class StringSwitcher extends java.lang.Object
This class implements a simple String->int mapping for a fixed set of keys.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StringSwitcher.Generator
(package private) static interface
StringSwitcher.StringSwitcherKey
-
Field Summary
Fields Modifier and Type Field Description private static Signature
INT_VALUE
private static StringSwitcher.StringSwitcherKey
KEY_FACTORY
private static org.objectweb.asm.Type
STRING_SWITCHER
-
Constructor Summary
Constructors Modifier Constructor Description protected
StringSwitcher()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
Field Detail
-
STRING_SWITCHER
private static final org.objectweb.asm.Type STRING_SWITCHER
-
INT_VALUE
private static final Signature INT_VALUE
-
KEY_FACTORY
private static final StringSwitcher.StringSwitcherKey KEY_FACTORY
-
-
Method Detail
-
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.- Parameters:
strings
- the array of String keys; must be the same length as the value arrayints
- the array of integer results; must be the same length as the key arrayfixedInput
- if false, an unknown key will be returned fromintValue(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.- Parameters:
s
- the key- Returns:
- the associated integer value, or
-1
if the key is unknown (unlessfixedInput
was specified when thisStringSwitcher
was created, in which case the return value for an unknown key is undefined)
-
-