org.bibeault.jrjournal.ccc
Class ClassConstantInspector

java.lang.Object
  extended byorg.bibeault.jrjournal.ccc.ClassConstantInspector

public class ClassConstantInspector
extends java.lang.Object

Service class that looks up the value of class constants. This class considers "class constant" to mean a field with modifiers: public, static and final.

Author:
Bear Bibeault

Constructor Summary
ClassConstantInspector(java.lang.String constantPath)
          Constructs a class constant inspector for the passed field.
 
Method Summary
 java.lang.Object getValue()
          Returns the value of the inspected class constant.
static java.lang.Object getValue(java.lang.String constantName)
          Static convenience method to obtain the value of a constant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassConstantInspector

public ClassConstantInspector(java.lang.String constantPath)
                       throws java.lang.ClassNotFoundException,
                              java.lang.NoSuchFieldException
Constructs a class constant inspector for the passed field. The field is checked to ensure that it is a public static final field.

Parameters:
constantPath - the fully qualified name of the class class constant
Throws:
java.lang.ClassNotFoundException - if the named class does not exist
java.lang.NoSuchFieldException - if the named field does not exists
java.lang.IllegalArgumentException - if the class or field fails to meet the constrictions described above
Method Detail

getValue

public java.lang.Object getValue()
                          throws java.lang.IllegalAccessException,
                                 java.lang.InstantiationException
Returns the value of the inspected class constant.

Returns:
the value of the inspected constant
Throws:
java.lang.IllegalAccessException - if the field cannot be accessed
java.lang.InstantiationException - if the class cannot be instantiated

getValue

public static java.lang.Object getValue(java.lang.String constantName)
                                 throws java.lang.NoSuchFieldException,
                                        java.lang.ClassNotFoundException,
                                        java.lang.IllegalAccessException,
                                        java.lang.InstantiationException
Static convenience method to obtain the value of a constant. Suitable for use as an EL function.

Parameters:
constantName - the fully qualified name of the class class constant
Returns:
the value of the inspected constant
Throws:
java.lang.NoSuchFieldException - if the field does not exist
java.lang.ClassNotFoundException - if the class does not exist
java.lang.IllegalAccessException - if the field cannot be accessed
java.lang.InstantiationException - if the class cannot be instantiated