|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.engine.FMEngine
public final class FMEngine
This class provides services to an application developer, such as:
The methods in this class were developed to allow easy access to FM-Classic facilities without elaborate object construction.
This class provides can be used either as separate, new-able instances
of this engine, or as a singleton using the singleton()
static method.
Please ensure that you call one of the init() variants. This is critical for proper behavior.
Constructor Summary | |
---|---|
FMEngine()
Create a new FM-Classic engine. |
Method Summary | |
---|---|
TemplateProcessor.ExitStatus |
apply(java.lang.String templateName,
FMModel model,
java.io.Writer writer)
Apply the given model to the named template, writing the result to the given writer. |
TemplateProcessor.ExitStatus |
apply(java.lang.String templateName,
TemplateWriteableHashModel model,
java.io.Writer writer)
Apply the given model to the named template, writing the result to the given writer. |
TemplateProcessor.ExitStatus |
apply(Template template,
FMModel model,
java.io.Writer writer)
Apply the given model to the given template, writing the result to the given writer. |
TemplateProcessor.ExitStatus |
apply(Template template,
TemplateWriteableHashModel model,
java.io.Writer writer)
Apply the given model to the given template, writing the result to the given writer. |
FMModel |
createModel(java.util.Properties properties)
A simple way of creating objects and adding them to a new template model, using class named supplied from a properties object. |
Cache |
getCache()
Get the template cache initialized by this engine. |
Cacheable |
getItem(java.lang.String name)
Return the named cacheable item from the cache. |
Cacheable |
getItem(java.lang.String name,
java.lang.String type)
Return the named, typed cacheable item from the cache. |
java.lang.String |
getProperty(java.lang.String key)
Get a property using one of the property keys from the PropertyConstants class. |
Template |
getTemplate(java.lang.String name)
Return the named template from the cache. |
FMEngine |
init()
Initialize this engine using properties set using the setProperty(String, String) method. |
FMEngine |
init(java.util.Properties properties)
Initialize this engine using properties supplied from the given properties object. |
static void |
main(java.lang.String[] args)
|
java.lang.Object |
newInstanceFromClassName(java.lang.String c)
Create a new instance of the named class using reflection. |
void |
setObject(java.lang.String propertyName,
java.lang.Object objValue)
Sets an object property using constants from the PropertyObjectConstants class. |
FMEngine |
setProperty(java.lang.String key,
java.lang.String value)
Set a property using one of the property keys from the PropertyConstants class. |
static FMEngine |
singleton()
Return a singleton instance of a FM-Classic engine. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FMEngine()
Method Detail |
---|
public static FMEngine singleton()
public FMEngine setProperty(java.lang.String key, java.lang.String value)
PropertyConstants
class.
key
- the property name from PropertyConstants
value
- the string value corresponding to the given key
java.lang.IllegalStateException
- the engine's init() method has
already been calledpublic java.lang.String getProperty(java.lang.String key)
PropertyConstants
class.
key
- the property name from PropertyConstants
public FMEngine init(java.util.Properties properties)
properties
- the properties to initialize this engine, using
property keys from the PropertyConstants
class
java.lang.IllegalStateException
- the engine's init() method has
already been calledpublic FMEngine init()
setProperty(String, String)
method. Default properties
are supplied from the PropertyConstants.getDefaultProperties()
method.
java.lang.IllegalStateException
- the engine's init() method has
already been calledpublic void setObject(java.lang.String propertyName, java.lang.Object objValue)
PropertyObjectConstants
class.
propertyName
- a property name from the PropertyObjectConstants
classobjValue
- the object value to be setpublic Cache getCache()
public Template getTemplate(java.lang.String name)
name
- the name of the template
null
if it is not foundpublic Cacheable getItem(java.lang.String name)
name
- the name of the cacheable item
null
if it is not foundpublic Cacheable getItem(java.lang.String name, java.lang.String type)
name
- the name of the cacheable itemtype
- the type of the cacheable item
null
if it is not foundpublic TemplateProcessor.ExitStatus apply(java.lang.String templateName, FMModel model, java.io.Writer writer) throws java.io.IOException
templateName
- the name of the template to be loaded from the cachemodel
- the model to apply to the templatewriter
- the result of applying the model to the template
java.io.IOException
- there was a problem writing the result to the writerpublic TemplateProcessor.ExitStatus apply(Template template, FMModel model, java.io.Writer writer) throws java.io.IOException
template
- the template applied against the modelmodel
- the model to apply to the templatewriter
- the result of applying the model to the template
java.io.IOException
- there was a problem writing the result to the writerpublic TemplateProcessor.ExitStatus apply(java.lang.String templateName, TemplateWriteableHashModel model, java.io.Writer writer) throws java.io.IOException
templateName
- the name of the template to be loaded from the cachemodel
- the model to apply to the templatewriter
- the result of applying the model to the template
java.io.IOException
- there was a problem writing the result to the writerpublic TemplateProcessor.ExitStatus apply(Template template, TemplateWriteableHashModel model, java.io.Writer writer) throws java.io.IOException
template
- the template applied against the modelmodel
- the model to apply to the templatewriter
- the result of applying the model to the template
java.io.IOException
- there was a problem writing the result to the writerpublic FMModel createModel(java.util.Properties properties)
properties
- a key-value pairing of names to class names to be
loaded and added to the new template model
public java.lang.Object newInstanceFromClassName(java.lang.String c)
PropertyConstants
class for details on how the reflection
code creates the object.
c
- the named class to be loaded
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |