Top Description Inners Fields Constructors Methods
org.jboss.classfilewriter.code

public Class LookupSwitchBuilder

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collections, .List, java.util.concurrent.atomic.AtomicReference

builder class used to build a lookupswitch statement.
Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final AtomicReference<BranchEnd>
private final CodeLocation
private final List<LookupSwitchBuilder.ValuePair>

Constructor Summary

AccessConstructor and Description
public
LookupSwitchBuilder()

Builds a lookup switch statement with no specified default location.

public
LookupSwitchBuilder(final CodeLocation
The default location
defaultLocation
)

Builds a lookup switch statement, specifying the default location

Method Summary

Modifier and TypeMethod and Description
public AtomicReference<BranchEnd>

Returns:

A reference to the BranchEnd that will be created.
add
(int
The value to add to the lookup table
value
)

Adds a value to the table that is at a location yet to be written.

public LookupSwitchBuilder
add(int
The value to add to the lookup table
value
,
final CodeLocation location)

Adds a value to the table

public AtomicReference<BranchEnd>
public CodeLocation
public List<LookupSwitchBuilder.ValuePair>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultBranchEndback to summary
private final AtomicReference<BranchEnd> defaultBranchEnd
defaultLocationback to summary
private final CodeLocation defaultLocation
valuesback to summary
private final List<LookupSwitchBuilder.ValuePair> values

Constructor Detail

LookupSwitchBuilderback to summary
public LookupSwitchBuilder()

Builds a lookup switch statement with no specified default location. When the lookup switch is added to the code attribute a BranchEnd will be returned that can be used to set the location.

LookupSwitchBuilderback to summary
public LookupSwitchBuilder(final CodeLocation defaultLocation)

Builds a lookup switch statement, specifying the default location

Parameters
defaultLocation:CodeLocation

The default location

Method Detail

addback to summary
public AtomicReference<BranchEnd> add(int value)

Adds a value to the table that is at a location yet to be written. After this lookup switch has been written then the BranchEnd can be retrieved from the returned reference.

Parameters
value:int

The value to add to the lookup table

Returns:AtomicReference<BranchEnd>

A reference to the BranchEnd that will be created.

addback to summary
public LookupSwitchBuilder add(int value, final CodeLocation location)

Adds a value to the table

Parameters
value:int

The value to add to the lookup table

getDefaultBranchEndback to summary
public AtomicReference<BranchEnd> getDefaultBranchEnd()
getDefaultLocationback to summary
public CodeLocation getDefaultLocation()
getValuesback to summary
public List<LookupSwitchBuilder.ValuePair> getValues()
org.jboss.classfilewriter.code back to summary

public Class LookupSwitchBuilder.ValuePair

extends Object
implements Comparable<LookupSwitchBuilder.ValuePair>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable

Field Summary

Modifier and TypeField and Description
private final AtomicReference<BranchEnd>
private final CodeLocation
private final int

Constructor Summary

AccessConstructor and Description
public
ValuePair(final int value, final AtomicReference<BranchEnd> branchEnd)

public
ValuePair(final int value, final CodeLocation location)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(final LookupSwitchBuilder.ValuePair
the object to be compared.
o
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.
public AtomicReference<BranchEnd>
public CodeLocation
public int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

branchEndback to summary
private final AtomicReference<BranchEnd> branchEnd
locationback to summary
private final CodeLocation location
valueback to summary
private final int value

Constructor Detail

ValuePairback to summary
public ValuePair(final int value, final AtomicReference<BranchEnd> branchEnd)
ValuePairback to summary
public ValuePair(final int value, final CodeLocation location)

Method Detail

compareToback to summary
public int compareTo(final LookupSwitchBuilder.ValuePair o)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
o:LookupSwitchBuilder.ValuePair

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
getBranchEndback to summary
public AtomicReference<BranchEnd> getBranchEnd()
getLocationback to summary
public CodeLocation getLocation()
getValueback to summary
public int getValue()