Top Description Inners Fields Constructors Methods
org.springframework.cglib.util

public abstract Class StringSwitcher

extends Object
Class Inheritance
Annotations
@SuppressWarnings:rawtypes, unchecked
Imports
java.util.Arrays, .List, org.springframework.asm.ClassVisitor, .Label, .Type, org.springframework.cglib.core.AbstractClassGenerator, .ClassEmitter, .CodeEmitter, .Constants, .EmitUtils, .KeyFactory, .ObjectSwitchCallback, .ReflectUtils, .Signature, .TypeUtils

This class implements a simple String → int mapping for a fixed set of keys.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
pack-priv static interface

Field Summary

Modifier and TypeField and Description
private static final Signature
private static final StringSwitcher.StringSwitcherKey
private static final Type

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static StringSwitcher
create(String[]
the array of String keys; must be the same length as the value array
strings
,
int[]
the array of integer results; must be the same length as the key array
ints
,
boolean
if false, an unknown key will be returned from intValue as -1; if true, the result will be undefined, and the resulting code will be faster
fixedInput
)

Helper method to create a StringSwitcher.

public abstract int

Returns:

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)
intValue
(String
the key
s
)

Return the integer associated with the given key.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INT_VALUEback to summary
private static final Signature INT_VALUE
KEY_FACTORYback to summary
private static final StringSwitcher.StringSwitcherKey KEY_FACTORY
STRING_SWITCHERback to summary
private static final Type STRING_SWITCHER

Constructor Detail

StringSwitcherback to summary
protected StringSwitcher()

Method Detail

createback to summary
public static StringSwitcher create(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:String[]

the array of String keys; must be the same length as the value array

ints:int[]

the array of integer results; must be the same length as the key array

fixedInput:boolean

if false, an unknown key will be returned from intValue as -1; if true, the result will be undefined, and the resulting code will be faster

intValueback to summary
public abstract int intValue(String s)

Return the integer associated with the given key.

Parameters
s:String

the key

Returns:int

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)

org.springframework.cglib.util back to summary

public Class StringSwitcher.Generator

extends AbstractClassGenerator
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
private int[]
private static final AbstractClassGenerator.Source
private String[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public StringSwitcher
create()

Generate the StringSwitcher.

protected Object
public void
protected ClassLoader
protected Object
public void
setFixedInput(boolean
if false, an unknown key will be returned from intValue as -1; if true, the result will be undefined, and the resulting code will be faster
fixedInput
)

Configure how unknown String keys will be handled.

public void
setInts(int[]
the array of integer results; must be the same length as the key array
ints
)

Set the array of integer results.

public void
setStrings(String[]
the array of String keys; must be the same length as the value array
strings
)

Set the array of recognized Strings.

Inherited from org.springframework.cglib.core.AbstractClassGenerator:
creategenerategetAttemptLoadgetClassLoadergetClassNamegetCurrentgetNamingPolicygetProtectionDomaingetStrategygetUseCachesetAttemptLoadsetClassLoadersetContextClasssetNamePrefixsetNamingPolicysetStrategysetUseCacheunwrapCachedValuewrapCachedClass

Field Detail

fixedInputback to summary
private boolean fixedInput
intsback to summary
private int[] ints
SOURCEback to summary
private static final AbstractClassGenerator.Source SOURCE
stringsback to summary
private String[] strings

Constructor Detail

Generatorback to summary
public Generator()

Method Detail

createback to summary
public StringSwitcher create()

Generate the StringSwitcher.

firstInstanceback to summary
protected Object firstInstance(Class<T> type)

Implements abstract org.springframework.cglib.core.AbstractClassGenerator.firstInstance.

Annotations
@Override
generateClassback to summary
public void generateClass(ClassVisitor v) throws Exception

Implements org.springframework.cglib.core.ClassGenerator.generateClass.

Annotations
@Override
getDefaultClassLoaderback to summary
protected ClassLoader getDefaultClassLoader()

Implements abstract org.springframework.cglib.core.AbstractClassGenerator.getDefaultClassLoader.

Annotations
@Override
nextInstanceback to summary
protected Object nextInstance(Object instance)

Implements abstract org.springframework.cglib.core.AbstractClassGenerator.nextInstance.

Annotations
@Override
setFixedInputback to summary
public void setFixedInput(boolean fixedInput)

Configure how unknown String keys will be handled.

Parameters
fixedInput:boolean

if false, an unknown key will be returned from intValue as -1; if true, the result will be undefined, and the resulting code will be faster

setIntsback to summary
public void setInts(int[] ints)

Set the array of integer results.

Parameters
ints:int[]

the array of integer results; must be the same length as the key array

See Also
setStrings
setStringsback to summary
public void setStrings(String[] strings)

Set the array of recognized Strings.

Parameters
strings:String[]

the array of String keys; must be the same length as the value array

See Also
setInts
org.springframework.cglib.util back to summary

pack-priv Interface StringSwitcher.StringSwitcherKey


Method Summary

Modifier and TypeMethod and Description
public Object
newInstance(String[] strings, int[] ints, boolean fixedInput)

Method Detail

newInstanceback to summary
public Object newInstance(String[] strings, int[] ints, boolean fixedInput)