Class 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 Detail

      • EMPTY_WRAPPERS

        private static final Wrapper[] EMPTY_WRAPPERS
      • EMPTY_GUARDS

        private static final Guard[] EMPTY_GUARDS
      • MAP_METHOD

        protected static final java.lang.reflect.Method MAP_METHOD
    • Constructor Detail

      • ReflectionObjectHandler

        public ReflectionObjectHandler()
    • Method Detail

      • find

        public Wrapper find​(java.lang.String name,
                            java.util.List<java.lang.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,
                                      java.util.List<Guard> guards,
                                      java.lang.Object scope,
                                      java.lang.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​(java.lang.String name,
                                                      java.util.List<Guard> guards)
      • createDotGuard

        protected DotGuard createDotGuard​(int i,
                                          java.lang.Object scope,
                                          java.lang.String lookup)
      • createWrappedGuard

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

        protected NullGuard createNullGuard()
      • createDepthGuard

        protected DepthGuard createDepthGuard​(int length)
      • createClassGuard

        protected ClassGuard createClassGuard​(int i,
                                              java.lang.Object scope)
      • createMapGuard

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

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

        public Binding createBinding​(java.lang.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​(java.util.Map<?,​?> map)