Package com.github.mustachejava.reflect
Class ReflectionObjectHandler
java.lang.Object
com.github.mustachejava.reflect.BaseObjectHandler
com.github.mustachejava.reflect.ReflectionObjectHandler
- All Implemented Interfaces:
ObjectHandler
Lookup objects using reflection and execute them the same way.
User: sam
Date: 7/24/11
Time: 3:02 PM
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanareMethodsAccessible(Map<?, ?> map) createBinding(String name, TemplateContext tc, Code code) Each call site has its own binding to allow for fine grained caching without a separate parallel hierarchy of objects.protected ClassGuardcreateClassGuard(int i, Object scope) protected DepthGuardcreateDepthGuard(int length) protected DotGuardcreateDotGuard(int i, Object scope, String lookup) protected MapGuardcreateMapGuard(int scopeIndex, Wrapper[] wrappers, String name, boolean contains) protected MissingWrappercreateMissingWrapper(String name, List<Guard> guards) protected NullGuardprotected WrappedGuardcreateWrappedGuard(int i, List<Wrapper> wrappers, List<Guard> wrapperGuard) protected WrappercreateWrapper(int scopeIndex, Wrapper[] wrappers, List<? extends Guard> guard, AccessibleObject member, Object[] arguments) Find a value named "name" in the array of scopes in reverse order.protected WrapperFind a wrapper given the current context.static Objectunwrap(ObjectHandler oh, int scopeIndex, Wrapper[] wrappers, List<Object> scopes) Methods inherited from class com.github.mustachejava.reflect.BaseObjectHandler
checkClass, checkField, checkMethod, coerce, falsey, findMember, getField, getMethod, iterate, stringify
-
Field Details
-
EMPTY_WRAPPERS
-
EMPTY_GUARDS
-
MAP_METHOD
-
-
Constructor Details
-
ReflectionObjectHandler
public ReflectionObjectHandler()
-
-
Method Details
-
unwrap
public static Object unwrap(ObjectHandler oh, int scopeIndex, Wrapper[] wrappers, List<Object> scopes) throws GuardException - Throws:
GuardException
-
find
Description copied from interface:ObjectHandlerFind a value named "name" in the array of scopes in reverse order.- Parameters:
name- the variable namescopes- the ordered list of scopes- Returns:
- a wrapper that can be used to extract a value
-
findWrapper
protected Wrapper findWrapper(int scopeIndex, Wrapper[] wrappers, List<Guard> guards, Object scope, String name) Find a wrapper given the current context. If not found, return null.- Parameters:
scopeIndex- the index into the scope arraywrappers- the current set of wrappers to get hereguards- the list of guards used to find thisscope- the current scopename- the name in the scope- Returns:
- null if not found, otherwise a wrapper for this scope and name
-
createMissingWrapper
-
createDotGuard
-
createWrappedGuard
-
createNullGuard
-
createDepthGuard
-
createClassGuard
-
createMapGuard
-
createWrapper
-
createBinding
Description copied from interface:ObjectHandlerEach call site has its own binding to allow for fine grained caching without a separate parallel hierarchy of objects.- Specified by:
createBindingin interfaceObjectHandler- Specified by:
createBindingin classBaseObjectHandler- Parameters:
name- the name that we boundtc- the textual context of the binding sitecode- the code that was bound- Returns:
- the binding
-
areMethodsAccessible
-