|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jwalk.core.ValueGenerator
public abstract class ValueGenerator
ValueGenerator is an abstract generator for synthesising simple values.
Since Generators can be quite complicated, the standard ObjectGenerator is
split into three parts, with ValueGenerator being the root of a hierarchy,
whose descendants are ArrayGenerator and finally ObjectGenerator.
ValueGenerator provides the basic facility to synthesise primitive types,
wrapped types, enumerated types and Strings. It cannot be instantiated
directly. The methods canCreate
and nextValue
are still abstract in ValueGenerator. ObjectGenerator is the first
MasterGenerator which may be used directly by JWalkers.
ValueGenerator provides the ability to synthesise values of every primitive
Java type from: {byte, boolean, char, int, short, long, float, double}.
It also provides the ability to synthesise values of every wrapped simple
value type from: {Byte, Boolean, Character, Integer, Short, Long, Float,
Double}. Other printable basic types, such as String and Enum, are handled
by custom generators.
Field Summary | |
---|---|
protected java.util.List<CustomGenerator> |
delegates
The list of CustomGenerator delegates. |
Constructor Summary | |
---|---|
protected |
ValueGenerator()
Initialises the ValueGenerator ancestor part of an ObjectGenerator. |
Method Summary | |
---|---|
void |
addDelegate(CustomGenerator generator)
Adds a delegate CustomGenerator to this ValueGenerator. |
protected java.lang.Object |
createPrimitive(java.lang.Class<?> type)
Creates an instance of a primitive Java type. |
protected java.lang.Object |
createWrapped(java.lang.Class<?> type)
Creates an instance of a wrapped Java type. |
protected boolean |
isEnumerated(java.lang.Class<?> type)
Reports if a type is an enumerated Java type. |
protected boolean |
isPrimitive(java.lang.Class<?> type)
Reports if a type is a primitive Java type. |
protected boolean |
isPrintable(java.lang.Class<?> type)
Reports whether a type is printable. |
protected boolean |
isWrapped(java.lang.Class<?> type)
Reports if a type is a wrapped primitive Java type. |
java.lang.String |
oracleValue(java.lang.Object object)
Converts any synthesised object into its oracle value format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.jwalk.gen.MasterGenerator |
---|
getJWalker, getTarget, getTargetType, logObject, logTarget |
Methods inherited from interface org.jwalk.Generator |
---|
canCreate, nextValue |
Field Detail |
---|
protected java.util.List<CustomGenerator> delegates
Constructor Detail |
---|
protected ValueGenerator()
Method Detail |
---|
protected boolean isPrimitive(java.lang.Class<?> type)
protected boolean isWrapped(java.lang.Class<?> type)
protected boolean isEnumerated(java.lang.Class<?> type)
protected boolean isPrintable(java.lang.Class<?> type)
type
- a type to be tested.
protected java.lang.Object createPrimitive(java.lang.Class<?> type) throws GeneratorException
type
- a primitive Java type.
GeneratorException,
- if no value could be synthesised.
GeneratorException
protected java.lang.Object createWrapped(java.lang.Class<?> type) throws GeneratorException
type
- a Java wrapper-type.
GeneratorException,
- if no value could be synthesised.
GeneratorException
public java.lang.String oracleValue(java.lang.Object object)
String.valueOf(object)
, which also works for null
and void (which may both be treated as values). Two kinds of value
are treated specially:
Character instances are conventionally surrounded by single quotes.
String instances are conventionally surrounded by double quotes.
oracleValue
in interface MasterGenerator
object
- a value created by this ValueGenerator.
public void addDelegate(CustomGenerator generator)
addDelegate
in interface MasterGenerator
generator
- the delegate CustomGenerator to add.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |