org.logicalcobwebs.cglib.util
Class StringSwitcher.Generator

java.lang.Object
  extended by org.logicalcobwebs.cglib.core.AbstractClassGenerator
      extended by org.logicalcobwebs.cglib.util.StringSwitcher.Generator
All Implemented Interfaces:
ClassGenerator
Enclosing class:
StringSwitcher

public static class StringSwitcher.Generator
extends AbstractClassGenerator


Nested Class Summary
 
Nested classes/interfaces inherited from class org.logicalcobwebs.cglib.core.AbstractClassGenerator
AbstractClassGenerator.Source
 
Field Summary
private  boolean fixedInput
           
private  int[] ints
           
private static AbstractClassGenerator.Source SOURCE
           
private  java.lang.String[] strings
           
 
Constructor Summary
StringSwitcher.Generator()
           
 
Method Summary
 StringSwitcher create()
          Generate the StringSwitcher.
protected  java.lang.Object firstInstance(java.lang.Class type)
           
 void generateClass(ClassVisitor v)
           
protected  java.lang.ClassLoader getDefaultClassLoader()
           
protected  java.lang.Object nextInstance(java.lang.Object instance)
           
 void setFixedInput(boolean fixedInput)
          Configure how unknown String keys will be handled.
 void setInts(int[] ints)
          Set the array of integer results.
 void setStrings(java.lang.String[] strings)
          Set the array of recognized Strings.
 
Methods inherited from class org.logicalcobwebs.cglib.core.AbstractClassGenerator
create, getClassLoader, getClassName, setClassLoader, setNamePrefix, setNamingPolicy, setStrategy, setUseCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE

private static final AbstractClassGenerator.Source SOURCE

strings

private java.lang.String[] strings

ints

private int[] ints

fixedInput

private boolean fixedInput
Constructor Detail

StringSwitcher.Generator

public StringSwitcher.Generator()
Method Detail

setStrings

public void setStrings(java.lang.String[] strings)
Set the array of recognized Strings.

Parameters:
strings - the array of String keys; must be the same length as the value array
See Also:
setInts(int[])

setInts

public void setInts(int[] ints)
Set the array of integer results.

Parameters:
ints - the array of integer results; must be the same length as the key array
See Also:
setStrings(java.lang.String[])

setFixedInput

public void setFixedInput(boolean fixedInput)
Configure how unknown String keys will be handled.

Parameters:
fixedInput - if false, an unknown key will be returned from StringSwitcher.intValue(java.lang.String) as -1; if true, the result will be undefined, and the resulting code will be faster

getDefaultClassLoader

protected java.lang.ClassLoader getDefaultClassLoader()
Specified by:
getDefaultClassLoader in class AbstractClassGenerator

create

public StringSwitcher create()
Generate the StringSwitcher.


generateClass

public void generateClass(ClassVisitor v)
                   throws java.lang.Exception
Throws:
java.lang.Exception

firstInstance

protected java.lang.Object firstInstance(java.lang.Class type)
Specified by:
firstInstance in class AbstractClassGenerator

nextInstance

protected java.lang.Object nextInstance(java.lang.Object instance)
Specified by:
nextInstance in class AbstractClassGenerator