com.x5.template
Class Theme

java.lang.Object
  extended by com.x5.template.Theme
All Implemented Interfaces:
ChunkFactory, ContentSource

public class Theme
extends java.lang.Object
implements ContentSource, ChunkFactory


Constructor Summary
Theme()
           
Theme(ContentSource templates)
           
Theme(java.lang.String themeLayerNames)
           
Theme(java.lang.String themesFolder, java.lang.String themeLayerNames)
           
Theme(java.lang.String themesFolder, java.lang.String themeLayerNames, java.lang.String ext)
           
Theme(ThemeConfig config)
           
 
Method Summary
 void addLayer(ContentSource templates)
           
 void addProtocol(ContentSource src)
           
 java.lang.String fetch(java.lang.String itemName)
           
 java.util.Map<java.lang.String,ChunkFilter> getFilters()
           
 java.lang.String getLocale()
           
 java.lang.String getProtocol()
           
 Snippet getSnippet(java.lang.String itemName)
           
 Snippet getSnippet(java.lang.String templateName, java.lang.String ext)
           
 Chunk makeChunk()
          Creates a Chunk with no starter template and sets its tag boundary markers to match the other templates in this set.
 Chunk makeChunk(java.lang.String templateName)
          Creates a Chunk with a starting template.
 Chunk makeChunk(java.lang.String templateName, java.lang.String extension)
          Creates a Chunk with a starting template.
 boolean provides(java.lang.String itemName)
           
 void registerFilter(ChunkFilter filter)
           
 void setDefaultFileExtension(java.lang.String ext)
           
 void setDirtyInterval(int minutes)
           
 void setEncoding(java.lang.String encoding)
          What encoding do this theme's template files use? If not UTF-8, make sure to set this explicitly.
 void setErrorHandling(boolean renderErrs, java.io.PrintStream errLog)
           
 void setJarContext(java.lang.Class<?> classInSameJar)
          If your templates are packaged into a jar with your application code, then you should use this method to tell chunk where your templates are.
 void setJarContext(java.lang.Object ctx)
           
 void setLocale(java.lang.String localeCode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Theme

public Theme()

Theme

public Theme(ThemeConfig config)

Theme

public Theme(ContentSource templates)

Theme

public Theme(java.lang.String themeLayerNames)

Theme

public Theme(java.lang.String themesFolder,
             java.lang.String themeLayerNames)

Theme

public Theme(java.lang.String themesFolder,
             java.lang.String themeLayerNames,
             java.lang.String ext)
Method Detail

setDefaultFileExtension

public void setDefaultFileExtension(java.lang.String ext)

setLocale

public void setLocale(java.lang.String localeCode)

getLocale

public java.lang.String getLocale()

setEncoding

public void setEncoding(java.lang.String encoding)
What encoding do this theme's template files use? If not UTF-8, make sure to set this explicitly.


addLayer

public void addLayer(ContentSource templates)

setDirtyInterval

public void setDirtyInterval(int minutes)

getSnippet

public Snippet getSnippet(java.lang.String templateName,
                          java.lang.String ext)

getSnippet

public Snippet getSnippet(java.lang.String itemName)
Specified by:
getSnippet in interface ContentSource

provides

public boolean provides(java.lang.String itemName)
Specified by:
provides in interface ContentSource

fetch

public java.lang.String fetch(java.lang.String itemName)
Specified by:
fetch in interface ContentSource

getProtocol

public java.lang.String getProtocol()
Specified by:
getProtocol in interface ContentSource

makeChunk

public Chunk makeChunk()
Creates a Chunk with no starter template and sets its tag boundary markers to match the other templates in this set. The Chunk will need to obtain template pieces via its .append() method.

Specified by:
makeChunk in interface ChunkFactory
Returns:
blank Chunk.

makeChunk

public Chunk makeChunk(java.lang.String templateName)
Creates a Chunk with a starting template. If templateName contains one or more hashes (#) it is assumed that the template definition is nested inside another template. Everything up to the first hash is part of the filename (appends the DEFAULT extension to find the file) and everything after refers to a location within the file where the template contents are defined.

Specified by:
makeChunk in interface ChunkFactory
Parameters:
templateName - the location of the template definition.
Returns:
a Chunk pre-initialized with a snippet of template.

makeChunk

public Chunk makeChunk(java.lang.String templateName,
                       java.lang.String extension)
Creates a Chunk with a starting template. If templateName contains one or more hashes (#) it is assumed that the template definition is nested inside another template. Everything up to the first hash is part of the filename (appends the PASSED extension to find the file) and everything after refers to a location within the file where the template contents are defined.

Specified by:
makeChunk in interface ChunkFactory
Parameters:
templateName - the location of the template definition.
extension - the nonstandard extension which forms the template filename.
Returns:
a Chunk pre-initialized with a snippet of template.

addProtocol

public void addProtocol(ContentSource src)

setJarContext

public void setJarContext(java.lang.Class<?> classInSameJar)
If your templates are packaged into a jar with your application code, then you should use this method to tell chunk where your templates are. Chunk might still be able to find your templates but it will work a lot harder. Without this info, it has to peek into every jar in the classpath every time it loads a new template.

Parameters:
classInSameJar -

setJarContext

public void setJarContext(java.lang.Object ctx)

getFilters

public java.util.Map<java.lang.String,ChunkFilter> getFilters()
Specified by:
getFilters in interface ChunkFactory

registerFilter

public void registerFilter(ChunkFilter filter)

setErrorHandling

public void setErrorHandling(boolean renderErrs,
                             java.io.PrintStream errLog)


Copyright © 2015. All Rights Reserved.