|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.sim.util.ByteCodeBuilder
public class ByteCodeBuilder
A factory class for dynamically creating instances of a few object types. This factory generates the bytecode for the classes, and then instantiates instances of those classes. Reflection is not used, and the created objects should be just as fast as manually coded counterparts.
This class is primarily used by the scheduling mechanism and DataRecorder to dynamically create BasicActions, DataSources, and NumericDataSources.
| Field Summary | |
|---|---|
static RSClassLoader |
loader
|
| Constructor Summary | |
|---|---|
ByteCodeBuilder()
|
|
| Method Summary | |
|---|---|
static StatCalculator |
generateAvgCalculator(java.lang.Class clazz,
java.util.List list,
java.lang.String methodName)
|
static StatCalculator |
generateAvgCalculator(java.util.List list,
java.lang.String methodName)
|
static BasicAction |
generateBasicAction(java.lang.Object target,
java.lang.String methodName)
Dynamically creates a BasicAction object whose execute method calls the specified method on the specified object. |
static BasicAction |
generateBasicActionForList(java.util.List list,
java.lang.String methodName)
Dynamically creates a BasicAction object whose execute method will iterate through the specifed list and call the specified method on each object in that list. |
static BasicAction |
generateBasicActionForList(java.util.List list,
java.lang.String methodName,
java.lang.Class clazz,
boolean randomize)
Dynamically creates a BasicAction object whose execute method will iterate through the specifed list and call the specified method on each object in that list. |
static BasicAction |
generateBasicActionForListRnd(java.util.List list,
java.lang.String methodName)
Dynamically creates a BasicAction object whose execute method will shuffle the specified list with uchicago.src.sim.util.SimUtilites.shuffle and then iterate through the specifed list, calling the specified method on each object in that list. |
static BinDataSource |
generateBinDataSource(java.lang.Object target,
java.lang.String methodName)
Dynamically creates a BinDataSource object whose getBinValue method calls the specified method on the specified object. |
static DataSource |
generateDataSource(java.lang.Object target,
java.lang.String methodName)
Dynamically creates a DataSource object whose execute method calls the specified method on the specified object. |
static StatCalculator |
generateMaxCalculator(java.lang.Class clazz,
java.util.List list,
java.lang.String methodName)
|
static StatCalculator |
generateMaxCalculator(java.util.List list,
java.lang.String methodName)
|
static ObjectPicker |
generateMaxObjectPicker(java.lang.Class clazz,
java.util.List list,
java.lang.String methodName)
|
static ObjectPicker |
generateMaxObjectPicker(java.util.List list,
java.lang.String methodName)
|
static StatCalculator |
generateMinCalculator(java.lang.Class clazz,
java.util.List list,
java.lang.String methodName)
|
static StatCalculator |
generateMinCalculator(java.util.List list,
java.lang.String methodName)
|
static ObjectPicker |
generateMinObjectPicker(java.lang.Class clazz,
java.util.List list,
java.lang.String methodName)
|
static ObjectPicker |
generateMinObjectPicker(java.util.List list,
java.lang.String methodName)
|
static BinDataSource |
generateNoTargetBinDataSource(java.lang.Object param,
java.lang.String methodName)
Dynamically creates a BinDataSource object whose getBinValue method is passed an Object of whatever type param is. |
static NumericDataSource |
generateNumericDataSource(java.lang.Object target,
java.lang.String methodName)
Dynamically creates a NumericDataSource object whose execute method calls the specified method on the specified object. |
static Sequence |
generateSequence(java.lang.Object target,
java.lang.String methodName)
Dynamically creates a Sequence object whose execute method calls the specified method on the specified object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static RSClassLoader loader
| Constructor Detail |
|---|
public ByteCodeBuilder()
| Method Detail |
|---|
public static StatCalculator generateMinCalculator(java.util.List list,
java.lang.String methodName)
throws GeneratorException
GeneratorException
public static StatCalculator generateMinCalculator(java.lang.Class clazz,
java.util.List list,
java.lang.String methodName)
throws GeneratorException
GeneratorException
public static StatCalculator generateMaxCalculator(java.util.List list,
java.lang.String methodName)
throws GeneratorException
GeneratorException
public static StatCalculator generateMaxCalculator(java.lang.Class clazz,
java.util.List list,
java.lang.String methodName)
throws GeneratorException
GeneratorException
public static StatCalculator generateAvgCalculator(java.util.List list,
java.lang.String methodName)
throws GeneratorException
GeneratorException
public static StatCalculator generateAvgCalculator(java.lang.Class clazz,
java.util.List list,
java.lang.String methodName)
throws GeneratorException
GeneratorException
public static ObjectPicker generateMinObjectPicker(java.util.List list,
java.lang.String methodName)
throws GeneratorException
GeneratorException
public static ObjectPicker generateMinObjectPicker(java.lang.Class clazz,
java.util.List list,
java.lang.String methodName)
throws GeneratorException
GeneratorException
public static ObjectPicker generateMaxObjectPicker(java.util.List list,
java.lang.String methodName)
throws GeneratorException
GeneratorException
public static ObjectPicker generateMaxObjectPicker(java.lang.Class clazz,
java.util.List list,
java.lang.String methodName)
throws GeneratorException
GeneratorException
public static BasicAction generateBasicActionForList(java.util.List list,
java.lang.String methodName)
throws GeneratorException
public class a_synthetic_name extends BasicAction {
private List target;
public a_synthetic_name(List target) {
this.target = target;
}
public void execute() {
int size = target.size();
for (int i = 0; i < size; i++) {
ObjectType x = (ObjectType)target.get(i);
x.SomeMethod();
}
}
}
where ObjectType is the class of the object returned by list.get(0).
, and SomeMethod is the method whose name is specified
in the parameters below.Note that the size of the list is computed once. If the specified method call alters the size of the list, the effect of this BasicAction is undefined, but not good.
list - the list containing the objects on which to call the specified
methodmethodName - the name of the method to call on the objects in the
specified list
GeneratorException
public static BasicAction generateBasicActionForListRnd(java.util.List list,
java.lang.String methodName)
throws GeneratorException
public class a_synthetic_name extends BasicAction {
private List target;
public a_synthetic_name(List target) {
this.target = target;
}
public void execute() {
int size = target.size();
SimUtilities.shuffle(target);
for (int i = 0; i < size; i++) {
ObjectType x = (ObjectType)target.get(i);
x.SomeMethod();
}
}
}
where ObjectType is the class of the object returned by list.get(0).
, and SomeMethod is the method whose name is specified
in the parameters below.Note that the size of the list is computed once. If the specified method call alters the size of the list, the effect of this BasicAction is undefined, but not good.
list - the list containing the objects on which to call the specified
methodmethodName - the name of the method to call on the objects in the
specified list
GeneratorException
public static BasicAction generateBasicActionForList(java.util.List list,
java.lang.String methodName,
java.lang.Class clazz,
boolean randomize)
throws GeneratorException
public class a_synthetic_name extends BasicAction {
private List target;
public a_synthetic_name(List target) {
this.target = target;
}
public void execute() {
int size = target.size();
for (int i = 0; i < size; i++) {
ObjectType x = (ObjectType)target.get(i);
x.SomeMethod();
}
}
}
where ObjectType is the specified class, and SomeMethod is
the method whose name is specified in the parameters below. Specifying
the class allows for the generation of bytecode that invokes a super-class
or interface method on the objects in the specified list.Note that the size of the list is computed once. If the specified method call alters the size of the list, the effect of this BasicAction is undefined, but not good.
list - the list containing the objects on which to call the specified
methodmethodName - the name of the method to call on the objects in the
specified listclazz - the common type of the objects in the specified listrandomize - whether the list should be randomized (shuffled) before
iterating through it. Shuffling is done via SimUtilities.shuffle(List)
GeneratorException
public static BasicAction generateBasicAction(java.lang.Object target,
java.lang.String methodName)
throws GeneratorException
public class a_synthetic_name extends BasicAction {
private ObjectType target
public a_synthetic_name(ObjectType target) {
this.target = target;
}
public void execute() {
target.someMethod();
}
}
where ObjectType is the class of the object specified in the parameters
below, and SomeMethod is
the method whose name is specified in the parameters below.
target - the object on which to call the methodmethodName - the name of the method to call on the specified
object
GeneratorException
public static DataSource generateDataSource(java.lang.Object target,
java.lang.String methodName)
throws GeneratorException
public class a_synthetic_name implements DataSource {
private ObjectType target
public a_synthetic_name(ObjectType target) {
this.target = target;
}
public Object execute() {
return target.someMethod();
}
}
where ObjectType is the class of the object specified in the parameters
below, and SomeMethod is
the method whose name is specified in the parameters below.
target - the object on which to call the methodmethodName - the name of the method to call on the specified
object. The method must return an object
GeneratorException
public static NumericDataSource generateNumericDataSource(java.lang.Object target,
java.lang.String methodName)
throws GeneratorException
public class a_synthetic_name implements NumericDataSource {
private ObjectType target
public a_synthetic_name(ObjectType target) {
this.target = target;
}
public double execute() {
return target.someMethod();
}
}
where ObjectType is the class of the object specified in the parameters
below, and SomeMethod is
the method whose name is specified in the parameters below.
target - the object on which to call the methodmethodName - the name of the method to call on the specified
object. The method must return a double
GeneratorException
public static BinDataSource generateNoTargetBinDataSource(java.lang.Object param,
java.lang.String methodName)
throws GeneratorException
public class a_synthetic_name implements BinDataSource {
public a_synthetic_name() {}
public double getBinValue(Object obj) {
return ((param_type)o).someMethod();
}
}
where SomeMethod is
the method whose name is specified in the parameters below. This may
also add a cast to the result of target.someMethod if that is a
primitive non-double numeric value
param - a prototypical on which to call the methodmethodName - the name of the method to call on the specified
object. The method must return a numeric value
GeneratorException
public static BinDataSource generateBinDataSource(java.lang.Object target,
java.lang.String methodName)
throws GeneratorException
public class a_synthetic_name implements BinDataSource {
private ObjectType target
public a_synthetic_name(ObjectType target) {
this.target = target;
}
public double getBinValue(Object obj) {
return target.someMethod(obj);
}
}
where ObjectType is the class of the target specified in the parameters
below, and SomeMethod is
the method whose name is specified in the parameters below. This may
also add a cast to the result of target.someMethod if that is a
primitive non-double numeric value
target - the object on which to call the methodmethodName - the name of the method to call on the specified
object. The method must return a numeric value
GeneratorException
public static Sequence generateSequence(java.lang.Object target,
java.lang.String methodName)
throws GeneratorException
public class a_synthetic_name implements Sequence {
private ObjectType target
public a_synthetic_name(ObjectType target) {
this.target = target;
}
public double getSValue() {
return target.someMethod();
}
}
where ObjectType is the class of the object specified in the parameters
below, and SomeMethod is
the method whose name is specified in the parameters below. This may
also add a cast to the result of target.someMethod if that is a primitive non-double
numeric value
target - the object on which to call the methodmethodName - the name of the method to call on the specified
object. The method must return a numeric value
GeneratorException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||