org.silverpeas.jstl.constant.reflect
Class ClassConstantInspector

java.lang.Object
  extended by org.silverpeas.jstl.constant.reflect.ClassConstantInspector

public class ClassConstantInspector
extends Object

Inspector class that analyses a class and extract its constant filed value.


Constructor Summary
ClassConstantInspector(String constantPath)
          Constructs a class constant inspector for the passed field.
 
Method Summary
 Object getValue()
          Returns the value of the inspected class constant.
static Object getValue(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(String constantPath)
                       throws ClassNotFoundException,
                              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:
ClassNotFoundException - if the named class does not exist
NoSuchFieldException - if the named field does not exists
IllegalArgumentException - if the class or field fails to meet the constrictions described above
Method Detail

getValue

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

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

getValue

public static Object getValue(String constantName)
                       throws NoSuchFieldException,
                              ClassNotFoundException,
                              IllegalAccessException,
                              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:
NoSuchFieldException - if the field does not exist
ClassNotFoundException - if the class does not exist
IllegalAccessException - if the field cannot be accessed
InstantiationException - if the class cannot be instantiated


Copyright © 2016 Silverpeas. All Rights Reserved.