Interface ObjectHandler

All Known Implementing Classes:
BaseObjectHandler, ReflectionObjectHandler, SimpleObjectHandler, TypeCheckingHandler

public interface ObjectHandler
The ObjectHandler is responsible for creating wrappers to find values in scopes at runtime and to coerce those results to the appropriate Java types
  • Method Details

    • find

      Wrapper find(String name, List<Object> scopes)
      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
    • coerce

      Object coerce(Object object)
      Coerce results to Java native iterables, functions, callables.
      Parameters:
      object - transform an unknown type to a known type
      Returns:
      the new object
    • iterate

      Writer iterate(Iteration iteration, Writer writer, Object object, List<Object> scopes)
      Iterate over an object by calling Iteration.next for each value.
      Parameters:
      iteration - callback for the next iteration
      writer - the writer to write to
      object - the current object
      scopes - the scopes present
      Returns:
      the current writer
    • falsey

      Writer falsey(Iteration iteration, Writer writer, Object object, List<Object> scopes)
      Call Iteration.next() either 0 (true) or 1 (fale) times.
      Parameters:
      iteration - callback for the next iteration
      writer - the writer to write to
      object - the current object
      scopes - the scopes present
      Returns:
      the current writer
    • createBinding

      Binding 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.
      Parameters:
      name - the name that we bound
      tc - the textual context of the binding site
      code - the code that was bound
      Returns:
      the binding
    • stringify

      String stringify(Object object)
      Turns an object into the string representation that should be displayed in templates.
      Parameters:
      object - the object to be displayed
      Returns:
      a string representation of the object.
    • makeList

      static List<Object> makeList(Object scope)