org.apache.velocity.runtime.parser.node.AbstractExecutor Java Examples
The following examples show how to use
org.apache.velocity.runtime.parser.node.AbstractExecutor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestableUberspect.java From ApprovalTests.Java with Apache License 2.0 | 6 votes |
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); }
Example #2
Source File: WebappUberspector.java From velocity-tools with Apache License 2.0 | 6 votes |
/** * Property getter * @param obj target object * @param identifier property key * @param i tool info * @return A Velocity Getter Method. */ public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) { if (obj == null) { return null; } VelPropertyGet ret = super.getPropertyGet(obj,identifier,i); if(ret == null) { Class claz = obj.getClass(); if(obj instanceof HttpServletRequest || obj instanceof HttpSession || obj instanceof ServletContext) { AbstractExecutor executor = new GetAttributeExecutor(log, introspector, claz, identifier); ret = executor.isAlive() ? new VelGetterImpl(executor) : null; } } return ret; }
Example #3
Source File: TestableUberspect.java From ApprovalTests.Java with Apache License 2.0 | 4 votes |
public VelGetterImpl(AbstractExecutor exec) { ae = exec; }
Example #4
Source File: UberspectImpl.java From velocity-engine with Apache License 2.0 | 4 votes |
/** * Property getter * @param obj * @param identifier * @param i * @return A Velocity Getter Method. */ public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) { if (obj == null) { return null; } Class claz = obj.getClass(); /* * first try for a getFoo() type of property * (also getfoo() ) */ AbstractExecutor executor = new PropertyExecutor(log, introspector, claz, identifier); /* * Let's see if we are a map... */ if (!executor.isAlive()) { executor = new MapGetExecutor(log, obj, identifier); } /* * if that didn't work, look for get("foo") */ if (!executor.isAlive()) { executor = new GetExecutor(log, introspector, claz, identifier); } /* * finally, look for boolean isFoo() */ if (!executor.isAlive()) { executor = new BooleanPropertyExecutor(log, introspector, claz, identifier); } /* * and idem on an array */ if (!executor.isAlive() && obj.getClass().isArray()) { executor = new BooleanPropertyExecutor(log, introspector, ArrayListWrapper.class, identifier, true); } return (executor.isAlive()) ? new VelGetterImpl(executor) : null; }
Example #5
Source File: UberspectImpl.java From velocity-engine with Apache License 2.0 | 4 votes |
/** * @param exec */ public VelGetterImpl(AbstractExecutor exec) { getExecutor = exec; }