public class DefaultMustacheFactory extends java.lang.Object implements MustacheFactory
| Modifier and Type | Class and Description |
|---|---|
protected class |
DefaultMustacheFactory.FragmentCacheLoader |
protected class |
DefaultMustacheFactory.MustacheCacheLoader |
| Modifier and Type | Field and Description |
|---|---|
protected com.google.common.util.concurrent.ListeningExecutorService |
les |
protected MustacheParser |
mc
This parser should work with any MustacheFactory
|
protected com.google.common.cache.LoadingCache<java.lang.String,Mustache> |
mustacheCache
Create the default cache for mustache compilations.
|
protected ObjectHandler |
oh
This is the default object handler.
|
protected com.google.common.cache.LoadingCache<FragmentKey,Mustache> |
templateCache
New templates that are generated at runtime are cached here.
|
| Constructor and Description |
|---|
DefaultMustacheFactory() |
DefaultMustacheFactory(java.io.File fileRoot)
Use the file system to resolve mustache templates.
|
DefaultMustacheFactory(java.lang.String resourceRoot)
Use the classpath to resolve mustache templates.
|
| Modifier and Type | Method and Description |
|---|---|
Mustache |
compile(java.io.Reader reader,
java.lang.String name)
Create a mustache given a reader and a name.
|
Mustache |
compile(java.io.Reader reader,
java.lang.String file,
java.lang.String sm,
java.lang.String em) |
Mustache |
compile(java.lang.String name)
Create a mustache given a resource name.
|
protected com.google.common.cache.LoadingCache<FragmentKey,Mustache> |
createLambdaCache() |
protected com.google.common.cache.LoadingCache<java.lang.String,Mustache> |
createMustacheCache() |
MustacheVisitor |
createMustacheVisitor()
Creates the visitor for compilation.
|
void |
encode(java.lang.String value,
java.io.Writer writer)
This defines how "encoded" values are encoded.
|
java.util.concurrent.ExecutorService |
getExecutorService()
There is an ExecutorService that is used when executing parallel
operations when a Callable is returned from a mustache value or iterable.
|
Mustache |
getFragment(FragmentKey templateKey) |
ObjectHandler |
getObjectHandler()
The object handler knows how to transform names into fields and methods.
|
java.io.Reader |
getReader(java.lang.String resourceName)
Given a resource name, construct a reader.
|
void |
setExecutorService(java.util.concurrent.ExecutorService es)
If you need to specify your own executor service you can.
|
void |
setObjectHandler(ObjectHandler oh)
You can override the default object handler post construction.
|
java.lang.String |
translate(java.lang.String from)
Converts your arbitrary name to another name.
|
protected final com.google.common.cache.LoadingCache<java.lang.String,Mustache> mustacheCache
protected ObjectHandler oh
protected final MustacheParser mc
protected final com.google.common.cache.LoadingCache<FragmentKey,Mustache> templateCache
protected com.google.common.util.concurrent.ListeningExecutorService les
public DefaultMustacheFactory()
public DefaultMustacheFactory(java.lang.String resourceRoot)
resourceRoot - public DefaultMustacheFactory(java.io.File fileRoot)
fileRoot - public MustacheVisitor createMustacheVisitor()
MustacheFactorycreateMustacheVisitor in interface MustacheFactorypublic java.io.Reader getReader(java.lang.String resourceName)
MustacheFactorygetReader in interface MustacheFactoryresourceName - used to find the resourcepublic void encode(java.lang.String value,
java.io.Writer writer)
MustacheFactoryencode in interface MustacheFactoryvalue - the unencoded valuewriter - where to encode the valuepublic ObjectHandler getObjectHandler()
MustacheFactorygetObjectHandler in interface MustacheFactorypublic void setObjectHandler(ObjectHandler oh)
oh - public java.util.concurrent.ExecutorService getExecutorService()
public void setExecutorService(java.util.concurrent.ExecutorService es)
es - public Mustache getFragment(FragmentKey templateKey)
public Mustache compile(java.lang.String name)
MustacheFactorycompile in interface MustacheFactoryname - the name of the resourcepublic Mustache compile(java.io.Reader reader, java.lang.String name)
MustacheFactorycompile in interface MustacheFactoryreader - the readername - the name of the resourcepublic Mustache compile(java.io.Reader reader, java.lang.String file, java.lang.String sm, java.lang.String em)
public java.lang.String translate(java.lang.String from)
MustacheFactorytranslate in interface MustacheFactoryfrom - the tag to replaceprotected com.google.common.cache.LoadingCache<java.lang.String,Mustache> createMustacheCache()
protected com.google.common.cache.LoadingCache<FragmentKey,Mustache> createLambdaCache()
Copyright © 2012. All Rights Reserved.