|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.reflect.ReflectExceptionVisitor<T>
public abstract class ReflectExceptionVisitor<T>
A visitor for ReflectExceptions. By default, each method simply defers to the defaultCase(java.lang.Exception)
method. An implementation should define defaultCase and override any methods corresponding to
exceptions that deserve special treatment.
If, as is often the case in exception handling, no return value is required, the return type can be
specified as Void, and all methods should simply return null.
| Constructor Summary | |
|---|---|
ReflectExceptionVisitor()
|
|
| Method Summary | |
|---|---|
protected abstract T |
defaultCase(Exception e)
|
T |
forClassCast(ClassCastException e)
Handle a ClassCastException, which can occur when attempting to dynamically cast
an object to the generic type of a class object. |
T |
forClassNotFound(ClassNotFoundException e)
Handle a ClassNotFoundException, which can occur if a class name does not refer to
any available classes. |
T |
forIllegalAccess(IllegalAccessException e)
Handle an IllegalAccessException, which occurs when an attempt is made to write to a
final field or to access an inaccessible class or class member. |
T |
forIllegalArgument(IllegalArgumentException e)
Handle an IllegalArgumentException, which can occur if an object whose member is
being accessed does not have the required type, or if the arguments to a method or constructor
do not match the required signature. |
T |
forInstantiation(InstantiationException e)
Handle an InstantiationException, which can occur if an attempt is made to construct
a non-constructable class (such as an abstract class). |
T |
forInvocationTarget(InvocationTargetException e)
Handle an InvocationTargetException, which occurs whenever a Throwable
is thrown by a reflectively-executed method or constructor. |
T |
forNoSuchField(NoSuchFieldException e)
Handle a NoSuchFieldException, which can occur when a field name does not refer to
a publicly-accessible field of a class. |
T |
forNoSuchMethod(NoSuchMethodException e)
Handle a NoSuchMethodException, which can occur when a method or constructor name
and signature do not refer to a publicly-accessible method of a class. |
T |
forNullPointer(NullPointerException e)
Handle a NullPointerException, which can occur when statically accessing a non-static
member, or when attempting to access a member of the object null. |
T |
forSecurity(SecurityException e)
Handle a SecurityException, which can occur whenever a security manager restricts access
to reflection operations. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReflectExceptionVisitor()
| Method Detail |
|---|
protected abstract T defaultCase(Exception e)
public T forClassNotFound(ClassNotFoundException e)
ClassNotFoundException, which can occur if a class name does not refer to
any available classes.
public T forNoSuchField(NoSuchFieldException e)
NoSuchFieldException, which can occur when a field name does not refer to
a publicly-accessible field of a class.
public T forNoSuchMethod(NoSuchMethodException e)
NoSuchMethodException, which can occur when a method or constructor name
and signature do not refer to a publicly-accessible method of a class.
public T forIllegalArgument(IllegalArgumentException e)
IllegalArgumentException, which can occur if an object whose member is
being accessed does not have the required type, or if the arguments to a method or constructor
do not match the required signature. (It can also occur in the rare circumstance that an
accessible enum constructor reflectively is invoked.)
public T forNullPointer(NullPointerException e)
NullPointerException, which can occur when statically accessing a non-static
member, or when attempting to access a member of the object null.
public T forClassCast(ClassCastException e)
ClassCastException, which can occur when attempting to dynamically cast
an object to the generic type of a class object.
ReflectUtil.cast(java.lang.Class extends T>, java.lang.Object)public T forInvocationTarget(InvocationTargetException e)
InvocationTargetException, which occurs whenever a Throwable
is thrown by a reflectively-executed method or constructor. Note that all throwables
are wrapped in this way, and so a good practice would be to re-throw any that are unexpected
(such as errors). Because InvocationTargetException allows construction without
a cause parameter, e.getCause() may be null.
public T forInstantiation(InstantiationException e)
InstantiationException, which can occur if an attempt is made to construct
a non-constructable class (such as an abstract class).
public T forIllegalAccess(IllegalAccessException e)
IllegalAccessException, which occurs when an attempt is made to write to a
final field or to access an inaccessible class or class member.
public T forSecurity(SecurityException e)
SecurityException, which can occur whenever a security manager restricts access
to reflection operations.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||