public static Object valueFromClassConstant(String key,Object defaultValue){
  Configuration conf=instance();
  String val=valueFor(key);
  if (val == null) {
    return defaultValue;
  }
  int idx=val.lastIndexOf(".");
  String klassname;
  String cnst;
  try {
    klassname=val.substring(0,idx);
    cnst=val.substring(idx + 1);
  }
 catch (  IndexOutOfBoundsException e) {
    conf.warning("Property key " + key + " for object value constant is not properly formatted; "+ "should be FQN<dot>constant, is "+ val);
    return defaultValue;
  }
  Class klass;
  try {
    klass=Class.forName(klassname);
  }
 catch (  ClassNotFoundException e) {
    conf.warning("Property for object value constant " + key + " is not a FQN: "+ klassname);
    return defaultValue;
  }
  Object cnstVal;
  try {
    Field fld=klass.getDeclaredField(cnst);
    try {
      cnstVal=fld.get(klass);
    }
 catch (    IllegalAccessException e) {
      conf.warning("Property for object value constant " + key + ", field is not public: "+ klassname+ "."+ cnst);
      return defaultValue;
    }
  }
 catch (  NoSuchFieldException e) {
    conf.warning("Property for object value constant " + key + " is not a FQN: "+ klassname);
    return defaultValue;
  }
  return cnstVal;
}

public static Object valueFromClassConstant ( String key , Object defaultValue ) { Configuration conf = instance ( ) ; String val = valueFor ( key ) ; if ( val == null ) { return defaultValue ; } int idx = val . lastIndexOf ( "." ) ; String klassname ; String cnst ; try { klassname = val . substring ( 0 , idx ) ; cnst = val . substring ( idx + 1 ) ; } catch ( IndexOutOfBoundsException e ) { conf . warning ( "Property key " + key + " for object value constant is not properly formatted; " + "should be FQN<dot>constant, is " + val ) ; return defaultValue ; } Class klass ; try { klass = Class . forName ( klassname ) ; } catch ( ClassNotFoundException e ) { conf . warning ( "Property for object value constant " + key + " is not a FQN: " + klassname ) ; return defaultValue ; } Object cnstVal ; try { Field fld = klass . getDeclaredField ( cnst ) ; try { cnstVal = fld . get ( klass ) ; } catch ( IllegalAccessException e ) { conf . warning ( "Property for object value constant " + key + ", field is not public: " + klassname + "." + cnst ) ; return defaultValue ; } } catch ( NoSuchFieldException e ) { conf . warning ( "Property for object value constant " + key + " is not a FQN: " + klassname ) ; return defaultValue ; } return cnstVal ; }
given a property , resolves the value to a public constant field on some class , where the field is of type object . the property value must the the fqn of the class and field , e . g . akey = java . awt . renderinghints . value_interpolation_nearest_neighbor will return the value of the value_interpolation_nearest_neighbor constant on the rendinghints class .
