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; }
@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); }
/***********************************************************************/ 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); }