org.jwalk
Class GeneratorException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.jwalk.JWalkException
              extended by org.jwalk.GeneratorException
All Implemented Interfaces:
java.io.Serializable

public class GeneratorException
extends JWalkException

GeneratorException signals when a Generator could not synthesise a value. This exception may be raised if eventually none of the generators know how to synthesis a value of a given type, or if the type itself refuses permission to be instantiated. This is the most common kind of exception, arising from requests to synthesise values for unknown interface-types, or for types which are abstract, or subject to security restrictions. Furthermore, a GeneratorException may be raised if the JWalker engine can detect that a (custom) generator has failed internally. This may happen, since users may supply their own generators. The exception may be queried before it is handled, to support giving different feedback. If creationFailed() is true, the synthesis attempt failed for the given type; and the most likely remedy is to provide a custom generator. If generatorFailed() is true, one of the custom generators is most likely to have failed internally, and needs reparing. Access is provided to the class type for which a value could not be synthesised.

Version:
1.1
Author:
Anthony Simons
See Also:
Serialized Form

Constructor Summary
GeneratorException(java.lang.Class<?> type)
          Creates a GeneratorException reporting the inability to synthesise a value for a particular type.
GeneratorException(java.lang.Class<?> type, Generator generator)
          Creates a GeneratorException reporting that a (custom) generator failed during synthesis.
 
Method Summary
 boolean creationFailed()
          Reports that synthesis failed for a given type.
 boolean generatorFailed()
          Reports that the generator failed in its operation.
 Generator getGenerator()
          Returns the generator which failed during execution, or null.
 java.lang.Class<?> getType()
          Returns the type that could not be synthesised.
 
Methods inherited from class org.jwalk.JWalkException
getError
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneratorException

public GeneratorException(java.lang.Class<?> type)
Creates a GeneratorException reporting the inability to synthesise a value for a particular type. This is the normal constructor to use, when reporting that no generator could eventually synthesise the requested type. The most frequent cause is that the type is abstract, or an unknown interface type.

Parameters:
type - the type that could not be synthesised.

GeneratorException

public GeneratorException(java.lang.Class<?> type,
                          Generator generator)
Creates a GeneratorException reporting that a (custom) generator failed during synthesis. This constructor is typically called internally by ObjectGenerator, to report that one of the custom generators supplied by the user has failed for any other reason than inability to synthesise a value of a given type.

Parameters:
type - the type that could not be synthesised.
generator - the (custom) generator that failed internally.
Method Detail

creationFailed

public boolean creationFailed()
Reports that synthesis failed for a given type. This highlights the specific cases where the type was unknown, or refused permission to be instantiated.

Returns:
true, if the type could not be instantiated.

generatorFailed

public boolean generatorFailed()
Reports that the generator failed in its operation. This highlights the specific cases where faults were encountered during the execution of a (custom) generator.

Returns:
true, if the generator failed to work correctly.

getType

public java.lang.Class<?> getType()
Returns the type that could not be synthesised.

Returns:
the type that could not be synthesised.

getGenerator

public Generator getGenerator()
Returns the generator which failed during execution, or null. If the exception was raised by generator failure, returns the generator.

Returns:
the generator which failed during execution, or null.