executor = new GetExecutor(log, introspector, claz, identifier);
/** * @param log * @param introspector * @param clazz * @param property * @since 1.5 */ public GetExecutor(final Logger log, final Introspector introspector, final Class clazz, final String property) { this.log = log; this.introspector = introspector; // If you passed in null as property, we don't use the value // for parameter lookup. Instead we just look for get() without // any parameters. // // In any other case, the following condition will set up an array // for looking up get(String) on the class. if (property != null) { this.params = new Object[] { property }; } discover(clazz); }
/** * @since 1.5 */ protected void discover(final Class clazz) { try { setMethod(introspector.getMethod(clazz, "get", params)); } /** * pass through application level runtime exceptions */ catch( RuntimeException e ) { throw e; } catch(Exception e) { String msg = "Exception while looking for get('" + params[0] + "') method"; log.error(msg, e); throw new VelocityException(msg, e); } }
/** * @since 1.5 */ protected void discover(final Class clazz) { try { setMethod(introspector.getMethod(clazz, "get", params)); } /** * pass through application level runtime exceptions */ catch( RuntimeException e ) { throw e; } catch(Exception e) { String msg = "Exception while looking for get('" + params[0] + "') method"; log.error(msg, e); throw new VelocityException(msg, e); } }
executor = new GetExecutor(log, introspector, claz, identifier);
/** * @param log * @param introspector * @param clazz * @param property * @since 1.5 */ public GetExecutor(final Log log, final Introspector introspector, final Class clazz, final String property) { this.log = log; this.introspector = introspector; // If you passed in null as property, we don't use the value // for parameter lookup. Instead we just look for get() without // any parameters. // // In any other case, the following condition will set up an array // for looking up get(String) on the class. if (property != null) { this.params = new Object[] { property }; } discover(clazz); }
/** * Property getter */ public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) throws Exception { AbstractExecutor executor; Class claz = obj.getClass(); /* * first try for a getFoo() type of property * (also getfoo() ) */ executor = new PropertyExecutor(rlog,introspector, claz, identifier); /* * if that didn't work, look for get("foo") */ if (executor.isAlive() == false) { executor = new GetExecutor(rlog, introspector, claz, identifier); } /* * finally, look for boolean isFoo() */ if( executor.isAlive() == false) { executor = new BooleanPropertyExecutor(rlog, introspector, claz, identifier); } return (executor != null) ? new VelGetterImpl(executor) : null; }
/** * @param log * @param introspector * @param clazz * @param property * @since 1.5 */ public GetExecutor(final Log log, final Introspector introspector, final Class clazz, final String property) { this.log = log; this.introspector = introspector; // If you passed in null as property, we don't use the value // for parameter lookup. Instead we just look for get() without // any parameters. // // In any other case, the following condition will set up an array // for looking up get(String) on the class. if (property != null) { this.params = new Object[] { property }; } discover(clazz); }
/***********************************************************************/ 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); } /***********************************************************************/
executor = new GetExecutor(log, introspector, claz, identifier);
executor = new GetExecutor(log, introspector, claz, identifier);
executor = new GetExecutor(log, introspector, claz, identifier);
executor = new GetExecutor(log, introspector, claz, identifier);