Java 类org.apache.velocity.util.introspection.VelPropertyGet 实例源码

项目:oap    文件:Uberspector.java   
public VelPropertyGet getPropertyGet( Object object, String name, Info i ) throws Exception {
    VelPropertyGet getter = super.getPropertyGet( object, name, i );
    try {
        getter.getMethodName();
        return getter;
    } catch( NullPointerException notfound ) {
        final Field field = object.getClass().getField( name );
        if( field != null ) {
            AbstractExecutor executor = new AbstractExecutor() {
                public Object execute( Object o ) throws IllegalAccessException {
                    return field.get( o );
                }
            };
            return new VelGetterImpl( executor );
        }
    }
    return null;
}
项目:TeachingKidsProgramming.Source.Java    文件:TestableUberspect.java   
@Override
public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) throws Exception
{
  AbstractExecutor executor;
  if (obj == null) { throw new VelocityParsingError("tried " + getPropertyText("null", identifier), i); }
  Class<?> type = obj.getClass();
  // trying getFoo()
  executor = new PropertyExecutor(log, introspectorWithLog, type, identifier);
  if (!executor.isAlive())
  {
    // trying get("foo")
    executor = new GetExecutor(log, introspectorWithLog, type, identifier);
  }
  if (!executor.isAlive())
  {
    // trying isFoo()
    executor = new BooleanPropertyExecutor(log, introspectorWithLog, type, identifier);
  }
  if (!executor.isAlive()) { throw new VelocityParsingError("Did not find "
      + getPropertyText(obj.getClass().getName(), identifier), i); }
  return new VelGetterImpl(executor);
}
项目:ApprovalTests.Java    文件:TestableUberspect.java   
/***********************************************************************/
public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) throws Exception
{
  AbstractExecutor executor;
  if (obj == null) { throw new VelocityParsingError("tried " + getPropertyText("null", identifier), i); }
  Class<? extends Object> claz = obj.getClass();
  // trying getFoo()
  executor = new PropertyExecutor(log, introspectorWithLog, claz, identifier);
  if (!executor.isAlive())
  {
    // trying  get("foo")
    executor = new GetExecutor(log, introspectorWithLog, claz, identifier);
  }
  if (!executor.isAlive())
  {
    // trying  isFoo()
    executor = new BooleanPropertyExecutor(log, introspectorWithLog, claz, identifier);
  }
  if (!executor.isAlive()) { throw new VelocityParsingError("Did not find " + getPropertyText(obj.getClass().getName(), identifier), i); }
  return new VelGetterImpl(executor);
}