Package com.nomagic.magicreport
Class TemplateEngineFactory
java.lang.Object
com.nomagic.magicreport.TemplateEngineFactory
This is the factory for template engine. It is the single access point for all functionality. It applied the
singleton pattern.
- Since:
- Jun 12, 2007 12:23:05 AM
- Version:
- 1.0 Jun 12, 2007
-
Method Summary
Modifier and TypeMethodDescriptionvoidcopy(ITemplateEngine dest, ITemplateEngine source) Copies all properties and context from source engine to destination engine.voidcopy(ITemplateEngine dest, ITemplateEngine source, boolean copyRuntimeInstance, boolean copyFormatterRuntimeInstance) Copies all properties and context from source engine to destination engine.createTemplateEngine(Class<? extends ITemplateEngine> clazz) Create a new instance of template engine associated with given class.createTemplateEngine(String type) Create a new instance of template engine associated with given type.getDefaultTemplateEngineClassName(String engineName) Return default template engine class name.static TemplateEngineFactoryReturn instance of this class.Class<? extends ITemplateEngine> getRegisterTemplateEngine(String extension) Return a registered template engine class.String[]Return an array of the alias names of default template engine.getTemplateEngine(Class<? extends ITemplateEngine> clazz) Return template engine associated with given class or create a new instance if it doesn't created.getTemplateEngine(String type) Return template engine associated with given type or create a new instance if it doesn't created.Class<? extends ITemplateEngine> getTemplateEngineClass(String type) Return class of template engine associated with given type.voidregisterTemplateEngine(String extension, Class<? extends ITemplateEngine> templateEngineClass) Registers the given class name with theTemplateEngineFactory.voidunregisterTemplateEngine(String extension) Unregister the given file extension.
-
Method Details
-
getInstance
Return instance of this class.- Returns:
- instance of this class.
-
getDefaultTemplateEngineClassName
Return default template engine class name.- Parameters:
engineName- name.- Returns:
- default template engine class name.
-
getTemplateAliasNames
Return an array of the alias names of default template engine.String[] aliasNames = TemplateEngineFactory.getInstance().getTemplateAliasNames();- Returns:
- an array of the alias names and description
-
registerTemplateEngine
public void registerTemplateEngine(String extension, Class<? extends ITemplateEngine> templateEngineClass) Registers the given class name with theTemplateEngineFactory. A newly-loaded engine class should call the method registerTemplateEngine to make itself known to the TemplateEngineFactory.- Parameters:
extension- template file extensiontemplateEngineClass- the newITemplateEnginethat is to be registered with theTemplateEngineFactory
-
unregisterTemplateEngine
Unregister the given file extension.- Parameters:
extension- file extension.
-
getRegisterTemplateEngine
Return a registered template engine class.- Parameters:
extension- template file extension- Returns:
- a template engine class
ITemplateEngine
-
getTemplateEngine
public ITemplateEngine getTemplateEngine(Class<? extends ITemplateEngine> clazz) throws InitializationEngineException Return template engine associated with given class or create a new instance if it doesn't created.- Parameters:
clazz- associated class for template engine.- Returns:
- template engine
- Throws:
InitializationEngineException- error while creating template engine.
-
getTemplateEngine
Return template engine associated with given type or create a new instance if it doesn't created. If no associated type found, text engineTextEnginewill be return as default engine.- Parameters:
type- engine type.- Returns:
- template engine
- Throws:
InitializationEngineException- error while creating template engine.
-
getTemplateEngineClass
Return class of template engine associated with given type. If no associated type found, text engineTextEnginewill be return as default engine.- Parameters:
type- engine type.- Returns:
- template engine class
-
createTemplateEngine
Create a new instance of template engine associated with given type. If no associated type found, text engineTextEnginewill be return as default engine.This method always return new instance.
- Parameters:
type- engine type.- Returns:
- template engine
- Throws:
InitializationEngineException- error while creating template engine.
-
createTemplateEngine
public ITemplateEngine createTemplateEngine(Class<? extends ITemplateEngine> clazz) throws InitializationEngineException Create a new instance of template engine associated with given class.This method always return new instance.
- Parameters:
clazz- engine Class.- Returns:
- template engine
- Throws:
InitializationEngineException- error while creating template engine.
-
copy
Copies all properties and context from source engine to destination engine.This method will perform shallow copy of context. The reference to context of new engine will not remain the same as source engine. In order to copy, all object inside context requires implement clone() method.
- Parameters:
dest- the destination engine.source- source engine.
-
copy
public void copy(ITemplateEngine dest, ITemplateEngine source, boolean copyRuntimeInstance, boolean copyFormatterRuntimeInstance) Copies all properties and context from source engine to destination engine.This method will perform shallow copy of context. The reference to context of new engine will not remain the same as source engine. In order to copy, all object inside context requires implement clone() method.
- Parameters:
dest- the destination engine.source- source engine.copyRuntimeInstance- true to copy RuntimeInstance of source to destination engine if both are instance of IRuntimeInstanceVelocityEnginecopyFormatterRuntimeInstance- true to copy Formatter of source to destination engine if both are instance of DefaultTemplateEngine
-