Package com.github.mustachejava
Interface ObjectHandler
-
- All Known Implementing Classes:
BaseObjectHandler,ReflectionObjectHandler,SimpleObjectHandler,TypeCheckingHandler
public interface ObjectHandlerThe ObjectHandler is responsible for creating wrappers to find values in scopes at runtime and to coerce those results to the appropriate Java types
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Objectcoerce(java.lang.Object object)Coerce results to Java native iterables, functions, callables.BindingcreateBinding(java.lang.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.java.io.Writerfalsey(Iteration iteration, java.io.Writer writer, java.lang.Object object, java.util.List<java.lang.Object> scopes)Call Iteration.next() either 0 (true) or 1 (fale) times.Wrapperfind(java.lang.String name, java.util.List<java.lang.Object> scopes)Find a value named "name" in the array of scopes in reverse order.java.io.Writeriterate(Iteration iteration, java.io.Writer writer, java.lang.Object object, java.util.List<java.lang.Object> scopes)Iterate over an object by calling Iteration.next for each value.static java.util.List<java.lang.Object>makeList(java.lang.Object scope)java.lang.Stringstringify(java.lang.Object object)Turns an object into the string representation that should be displayed in templates.
-
-
-
Method Detail
-
find
Wrapper find(java.lang.String name, java.util.List<java.lang.Object> scopes)
Find 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
-
coerce
java.lang.Object coerce(java.lang.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
java.io.Writer iterate(Iteration iteration, java.io.Writer writer, java.lang.Object object, java.util.List<java.lang.Object> scopes)
Iterate over an object by calling Iteration.next for each value.- Parameters:
iteration- callback for the next iterationwriter- the writer to write toobject- the current objectscopes- the scopes present- Returns:
- the current writer
-
falsey
java.io.Writer falsey(Iteration iteration, java.io.Writer writer, java.lang.Object object, java.util.List<java.lang.Object> scopes)
Call Iteration.next() either 0 (true) or 1 (fale) times.- Parameters:
iteration- callback for the next iterationwriter- the writer to write toobject- the current objectscopes- the scopes present- Returns:
- the current writer
-
createBinding
Binding createBinding(java.lang.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 boundtc- the textual context of the binding sitecode- the code that was bound- Returns:
- the binding
-
stringify
java.lang.String stringify(java.lang.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 java.util.List<java.lang.Object> makeList(java.lang.Object scope)
-
-