| org.databene.benerator.Generator
Generator | public interface Generator (Code) | | This is the basic Generator interface, the mother of all generators.
Generator States
A Generator may be in one of three states:
- constructing: The generator is under construction.
This may take several steps, since generators need to be JavaBeans.
The generator may transit into the available state automatically
or manually when the validate() method is called.
- available: Generator construction is done and the generator is available.
The user may loop the Generator via available() and generate().
- unavailable: The Generator may become unavailable automatically if its value space is depleted or
manually when close() has been invoked. The Generator may be made available again by calling reset().
When unavailable, the generator must be in a state in which it can be safely garbage collected.
Developer Notes:
When implementing a custom generator, make it a JavaBean:
- Implement a public default (no-arg) constructor
- make each relevant property configurable by a set-method
Created: 07.06.2006 18:51:28
|
Method Summary | |
boolean | available() Tells if the Generator is in available state. | void | close() Closes the generator. | E | generate() Returns an instance of the generic tpe P. | Class<E> | getGeneratedType() Declares the type of the objects returned by the generate() method. | void | reset() Resets the generator to the initial state. | void | validate() This is a convenience method for checking the validity of a Generator's setup.
If setup is not alright, the validate() method is expected to throw an InvalidGeneratorSetupException.
Developer Notes:
If the method finishes without exception, the generator has to be available. |
available | boolean available()(Code) | | Tells if the Generator is in available state. If this returns true,
the next invocation of generate() must return a valid product.
|
close | void close()(Code) | | Closes the generator. After invocation the state is unavailable.
|
generate | E generate()(Code) | | Returns an instance of the generic tpe P. If the method is called in an inappropriate state
(constructing or unavailable), it will throw an IllegalGeneratorStateException.
|
getGeneratedType | Class<E> getGeneratedType()(Code) | | Declares the type of the objects returned by the generate() method.
|
reset | void reset()(Code) | | Resets the generator to the initial state.
When called, the Generator is expected to act as if 'restarted'.
After invocation the state has to be available.
|
validate | void validate()(Code) | | This is a convenience method for checking the validity of a Generator's setup.
If setup is not alright, the validate() method is expected to throw an InvalidGeneratorSetupException.
Developer Notes:
If the method finishes without exception, the generator has to be available. The next invocation of generate()
is expected to return a valid product and available() is expected to return true.
Be aware that this method does not need to be called by the user.
|
|
|