freemarker.template
Class TemplateFactory

java.lang.Object
  extended by freemarker.template.TemplateFactory
All Implemented Interfaces:
CompileableFactory<Template>

public final class TemplateFactory
extends java.lang.Object
implements CompileableFactory<Template>

A factory class that can create Template objects for various inputs.

Since:
1.9
Version:
$Id $
Author:
Nicholas Cull

Field Summary
static TemplateFactory INSTANCE
          The singleton instance of this TemplateFactory.
 
Method Summary
 Template create(CompileableFactoryParameters params)
          Create an instance of a Template object from the given InputStream, using the named character encoding.
 Template createFromFile(java.io.File file)
          Create an instance of a Template object from the given file, using the platform default character encoding.
 Template createFromFile(java.io.File file, java.lang.String encoding)
          Create an instance of a Template object from the given file, using the named character encoding.
 Template createFromFile(java.lang.String filePath)
          Create an instance of a Template object from the given file path, using the platform default character encoding.
 Template createFromFile(java.lang.String filePath, java.lang.String encoding)
          Create an instance of a Template object from the given file, using the named character encoding.
 Template createFromReader(java.io.Reader reader)
          Create an instance of a Template object from the given Reader.
 Template createFromStream(java.io.InputStream stream)
          Create an instance of a Template object from the given InputStream, using the platform default character encoding.
 Template createFromStream(java.io.InputStream stream, java.lang.String encoding)
          Create an instance of a Template object from the given InputStream, using the named character encoding.
 Template createFromString(java.lang.String str)
          Create an instance of a Template object from the given String.
 java.lang.String getName()
          Return a name for the compilable object created by this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final TemplateFactory INSTANCE
The singleton instance of this TemplateFactory.

Method Detail

getName

public java.lang.String getName()
Return a name for the compilable object created by this factory.

Specified by:
getName in interface CompileableFactory<Template>
Returns:
"template", to indicate this factory creates a template compilable object

create

public Template create(CompileableFactoryParameters params)
                throws java.io.IOException
Create an instance of a Template object from the given InputStream, using the named character encoding.

Specified by:
create in interface CompileableFactory<Template>
Parameters:
params -
Returns:
a newly created Template object from the given input stream
Throws:
java.io.IOException - there was a problem reading from the input stream

createFromStream

public Template createFromStream(java.io.InputStream stream)
                          throws java.io.IOException
Create an instance of a Template object from the given InputStream, using the platform default character encoding.

Parameters:
stream - the input stream from which the Template object will be created
Returns:
a newly created Template object from the given input stream
Throws:
java.io.IOException - there was a problem reading from the input stream

createFromStream

public Template createFromStream(java.io.InputStream stream,
                                 java.lang.String encoding)
                          throws java.io.IOException
Create an instance of a Template object from the given InputStream, using the named character encoding.

Parameters:
stream - the input stream from which the Template object will be created
encoding - the character encoding of the input stream
Returns:
a newly created Template object from the given input stream
Throws:
java.io.IOException - there was a problem reading from the input stream

createFromFile

public Template createFromFile(java.io.File file)
                        throws java.io.IOException
Create an instance of a Template object from the given file, using the platform default character encoding.

Parameters:
file - the file from which the Template object will be created
Returns:
a newly created Template object from the given file
Throws:
java.io.IOException - there was a problem reading from the file

createFromFile

public Template createFromFile(java.io.File file,
                               java.lang.String encoding)
                        throws java.io.IOException
Create an instance of a Template object from the given file, using the named character encoding.

Parameters:
file - the file from which the Template object will be created
encoding - the character encoding of the file
Returns:
a newly created Template object from the given file
Throws:
java.io.IOException - there was a problem reading from the file

createFromFile

public Template createFromFile(java.lang.String filePath)
                        throws java.io.IOException
Create an instance of a Template object from the given file path, using the platform default character encoding.

Parameters:
filePath - the file from which the Template object will be created
Returns:
a newly created Template object from the given file path
Throws:
java.io.IOException - there was a problem reading from the file path

createFromFile

public Template createFromFile(java.lang.String filePath,
                               java.lang.String encoding)
                        throws java.io.IOException
Create an instance of a Template object from the given file, using the named character encoding.

Parameters:
filePath - the file from which the Template object will be created
encoding - the character encoding of the file
Returns:
a newly created Template object from the given file
Throws:
java.io.IOException - there was a problem reading from the file

createFromReader

public Template createFromReader(java.io.Reader reader)
                          throws java.io.IOException
Create an instance of a Template object from the given Reader.

Parameters:
reader - the reader from which the Template object will be created
Returns:
a newly created Template object from the given reader
Throws:
java.io.IOException - there was a problem reading from the reader

createFromString

public Template createFromString(java.lang.String str)
                          throws java.io.IOException
Create an instance of a Template object from the given String.

Parameters:
str - the string from which the Template object will be created
Returns:
a newly created Template object from the given string
Throws:
java.io.IOException - there was a problem reading from the string