Class ReflectionObjectHandler

java.lang.Object
com.github.mustachejava.reflect.BaseObjectHandler
com.github.mustachejava.reflect.ReflectionObjectHandler
All Implemented Interfaces:
ObjectHandler

public class ReflectionObjectHandler extends BaseObjectHandler
Lookup objects using reflection and execute them the same way. User: sam Date: 7/24/11 Time: 3:02 PM
  • Field Details

    • EMPTY_WRAPPERS

      private static final Wrapper[] EMPTY_WRAPPERS
    • EMPTY_GUARDS

      private static final Guard[] EMPTY_GUARDS
    • MAP_METHOD

      protected static final Method 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

      public Wrapper find(String name, List<Object> scopes)
      Description copied from interface: ObjectHandler
      Find a value named "name" in the array of scopes in reverse order.
      Parameters:
      name - the variable name
      scopes - 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 array
      wrappers - the current set of wrappers to get here
      guards - the list of guards used to find this
      scope - the current scope
      name - the name in the scope
      Returns:
      null if not found, otherwise a wrapper for this scope and name
    • createMissingWrapper

      protected MissingWrapper createMissingWrapper(String name, List<Guard> guards)
    • createDotGuard

      protected DotGuard createDotGuard(int i, Object scope, String lookup)
    • createWrappedGuard

      protected WrappedGuard createWrappedGuard(int i, List<Wrapper> wrappers, List<Guard> wrapperGuard)
    • createNullGuard

      protected NullGuard createNullGuard()
    • createDepthGuard

      protected DepthGuard createDepthGuard(int length)
    • createClassGuard

      protected ClassGuard createClassGuard(int i, Object scope)
    • createMapGuard

      protected MapGuard createMapGuard(int scopeIndex, Wrapper[] wrappers, String name, boolean contains)
    • createWrapper

      protected Wrapper createWrapper(int scopeIndex, Wrapper[] wrappers, List<? extends Guard> guard, AccessibleObject member, Object[] arguments)
    • createBinding

      public Binding createBinding(String name, TemplateContext tc, Code code)
      Description copied from interface: ObjectHandler
      Each call site has its own binding to allow for fine grained caching without a separate parallel hierarchy of objects.
      Specified by:
      createBinding in interface ObjectHandler
      Specified by:
      createBinding in class BaseObjectHandler
      Parameters:
      name - the name that we bound
      tc - the textual context of the binding site
      code - the code that was bound
      Returns:
      the binding
    • areMethodsAccessible

      protected boolean areMethodsAccessible(Map<?,?> map)