de.dv.sbu.filehandler.ftl
Class FtlFileHandler

java.lang.Object
  extended by de.dv.sbu.filehandler.ftl.FtlFileHandler
All Implemented Interfaces:
IFileHandler

public class FtlFileHandler
extends java.lang.Object
implements IFileHandler

Handler for FREEMARKER template related files. By default a DefaultSourceParser instance will be used for source file parsing. When running the layoutTemplate (default is 'layout.ftl') on a source file the parsing result will be provided to the template. The following list of FTL root map entries is available for the template during that process:

The source parser might add additional entries. All properties can be overwritten by overlays.

Author:
Daniel Vogtland

Field Summary
static java.lang.String CONFIGURATION_NAME
          The builder configuration FTL root map entry name: 'configuration'.
static java.lang.String CONTENT_NAME
          The content-related FTL root map entry name: 'content'.
static java.lang.String DATAPROVIDERS_NAME
          The data-provider-related FTL root map entry name: 'dataprovider'.
static java.lang.String FILE_NAME
          The FTL root map name for the current source file information: 'file'.
static java.lang.String HANDLER_NAME
          The FTL root map name for the current FtlFileHandler instance : 'handlerinstance'.
 
Constructor Summary
FtlFileHandler()
           
 
Method Summary
 java.util.Map<java.lang.String,IDataProvider> getDataProviders()
          Returns the registered data provider instances mapped by names.
 java.lang.String getEncoding()
          Returns the used charset.
 java.lang.String getForcedSuffix()
          If this property is set, the target files will have this suffix - either by replacing the existing one or by adding it if no suffix is present.
 java.lang.String getLayoutTemplate()
          Returns the layout template path.
 java.util.Locale getLocale()
          Returns the used locale.
 java.util.List<Overlay> getOverlays()
          Returns the list of overlays.
 ISourceParser getSourceParser()
          Returns the used source parser.
 void handleFile(SourceFileInformation fileInfo)
          Handles a source file and will proceed related output file(s).
 void init(BuilderConfiguration builderConfiguration)
          Called once for each processing job.
 void setDataProviders(java.util.Map<java.lang.String,IDataProvider> dataProviders)
          Sets the data providers.
 void setEncoding(java.lang.String encoding)
          sets the charset.
 void setForcedSuffix(java.lang.String forcedSuffix)
          Sets or removes the forced file suffix.
 void setLayoutTemplate(java.lang.String layoutTemplate)
          Sets the layout template path.
 void setLocale(java.util.Locale locale)
          Sets the locale to use.
 void setOverlays(java.util.List<Overlay> overlays)
          Sets the list of overlays.
 void setSourceParser(ISourceParser sourceParser)
          Sets the source parser to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURATION_NAME

public static final java.lang.String CONFIGURATION_NAME
The builder configuration FTL root map entry name: 'configuration'.

See Also:
Constant Field Values

DATAPROVIDERS_NAME

public static final java.lang.String DATAPROVIDERS_NAME
The data-provider-related FTL root map entry name: 'dataprovider'.

See Also:
Constant Field Values

CONTENT_NAME

public static final java.lang.String CONTENT_NAME
The content-related FTL root map entry name: 'content'. This variable is only used during layouting and contains the source content.

See Also:
Constant Field Values

FILE_NAME

public static final java.lang.String FILE_NAME
The FTL root map name for the current source file information: 'file'.

See Also:
Constant Field Values

HANDLER_NAME

public static final java.lang.String HANDLER_NAME
The FTL root map name for the current FtlFileHandler instance : 'handlerinstance'.

See Also:
Constant Field Values
Constructor Detail

FtlFileHandler

public FtlFileHandler()
Method Detail

getLayoutTemplate

public java.lang.String getLayoutTemplate()
Returns the layout template path.

Returns:
The layout template path.

setLayoutTemplate

public void setLayoutTemplate(java.lang.String layoutTemplate)
                       throws java.lang.NullPointerException
Sets the layout template path.

Parameters:
layoutTemplate - The path to set. Relative to the resource root.
Throws:
java.lang.NullPointerException - The argument is null.

getEncoding

public java.lang.String getEncoding()
Returns the used charset. The default is 'ISO8859_15'.

Returns:
The used encoding.

setEncoding

public void setEncoding(java.lang.String encoding)
                 throws java.lang.NullPointerException
sets the charset.

Parameters:
encoding - The encoding to set.
Throws:
java.lang.NullPointerException - The encoding is null.

getLocale

public java.util.Locale getLocale()
Returns the used locale.

Returns:
the used locale.

setLocale

public void setLocale(java.util.Locale locale)
               throws java.lang.NullPointerException
Sets the locale to use.

Parameters:
locale - The locale to use.
Throws:
java.lang.NullPointerException - The locale is null.

getForcedSuffix

public java.lang.String getForcedSuffix()
If this property is set, the target files will have this suffix - either by replacing the existing one or by adding it if no suffix is present. The suffix is defined without the leading dot.

Returns:
The forced suffix or null.

setForcedSuffix

public void setForcedSuffix(java.lang.String forcedSuffix)
Sets or removes the forced file suffix. If this property is set, the target files will have this suffix - either by replacing the existing one or by adding it if no suffix is present. The suffix must be defined without the leading dot.

Parameters:
forcedSuffix - The suffix to force or null.

getDataProviders

public java.util.Map<java.lang.String,IDataProvider> getDataProviders()
Returns the registered data provider instances mapped by names.

Returns:
The registered data providers.

setDataProviders

public void setDataProviders(java.util.Map<java.lang.String,IDataProvider> dataProviders)
                      throws java.lang.NullPointerException
Sets the data providers.

Parameters:
dataProviders - The mapping to set. Not expected to contain null values.
Throws:
java.lang.NullPointerException - The mapping is null.

getSourceParser

public ISourceParser getSourceParser()
Returns the used source parser.

Returns:
The used source parser.

setSourceParser

public void setSourceParser(ISourceParser sourceParser)
                     throws java.lang.NullPointerException
Sets the source parser to use.

Parameters:
sourceParser - The instance to set.
Throws:
java.lang.NullPointerException - The argument is null.

getOverlays

public java.util.List<Overlay> getOverlays()
Returns the list of overlays.

Returns:
Optional overlays.

setOverlays

public void setOverlays(java.util.List<Overlay> overlays)
Sets the list of overlays. This list might be empty.

Parameters:
overlays - The overlays to use.

init

public void init(BuilderConfiguration builderConfiguration)
Called once for each processing job.

Specified by:
init in interface IFileHandler
Parameters:
builderConfiguration - The used builder configuration.
See Also:
IFileHandler.init(de.dv.sbu.builder.BuilderConfiguration)

handleFile

public void handleFile(SourceFileInformation fileInfo)
                throws java.lang.Exception
Handles a source file and will proceed related output file(s).

Specified by:
handleFile in interface IFileHandler
Parameters:
fileInfo - The file information of the related file.
Throws:
java.lang.Exception - Any exception to forward.
See Also:
IFileHandler.handleFile(de.dv.sbu.SourceFileInformation)