org.jostraca
Class BasicTemplate

java.lang.Object
  extended byorg.jostraca.BasicTemplate
All Implemented Interfaces:
Template
Direct Known Subclasses:
VirtualTemplate

public class BasicTemplate
extends java.lang.Object
implements Template

Basic implementation of template functionality. The text of the the file generated by the template can be accessed using getResult() but only if the template script is Java and the template is executed internally in the Jostraca process. Also, the template can chose to return a custom data structure with getResult.


Field Summary
protected  TemplatePath[] iAlsoGenerate
           
protected  BuildResource iBuildResource
           
protected  boolean iCodeWriterChanged
           
protected  FileRef iCodeWriterExecRef
           
protected  FileRef iCodeWriterRef
           
protected  java.lang.String iCodeWriterSource
           
protected  RegExp iConfRegExp
           
protected  java.lang.Object iContext
           
protected  java.lang.String iForcedIncludeBase
           
protected  boolean iForceIncludeBase
           
protected  RegExp iIncludeBaseRegExp
           
protected  RegExp iIncludeBlockRegExp
           
protected  RegExp iIncludeRegExp
           
protected  long iLastMod
           
protected  java.io.File iMetaFile
           
static java.lang.String INCLUDE_MOD_if_exists
           
static java.lang.String INCLUDE_MOD_output_relative
           
static java.lang.String INCLUDE_MOD_template_relative
           
protected  OrderedPropertySetManager iOrderedPSM
           
protected  java.lang.String iPath
           
protected  java.lang.Object iResult
           
protected  java.util.List iSavedFiles
           
protected  SectionSet iSectionSet
           
protected  java.lang.String iSource
           
protected  TemplatePath iTemplatePath
           
protected  TemplateScript iTemplateScript
           
 
Fields inherited from interface org.jostraca.Template
CN, MN_setCodeWriter
 
Constructor Summary
BasicTemplate()
          Create with empty template path
BasicTemplate(java.lang.String pName)
          Create with name of template.
BasicTemplate(TemplatePath pTemplatePath)
          Create a template using a TemplatePath object.
 
Method Summary
 void forceIncludeBase(java.lang.String pIncludeBase)
          Force template to use a specified include base.
 TemplatePath[] getAlsoGenerate()
          Get list of templates to which should also be generated.
 BuildResource getBuildResource()
          Get the set of build resources for this template
 boolean getCodeWriterChanged()
           
 java.io.File getCodeWriterExecutablePath()
           
 java.lang.String getCodeWriterLang()
          Get code writer lang if defined, else return empty String.
 java.io.File getCodeWriterPath()
           
 java.lang.String getCodeWriterSource()
           
 java.lang.Object getContext()
          Get context object for internal code writers.
 long getLastMod()
          Get last modified date of template source file
 PropertySet getMergedPropertySet()
           
 java.io.File getMetaFile()
           
 PropertySet getPropertySet(java.lang.String pConfName)
          Get template PropertySet.
 java.lang.Object getResult()
          Get result object from CodeWriter (may be null).
 java.util.List getSavedFiles()
           
 SectionSet getSectionSet()
          Get the data cotnainer for the insert section text of this template.
 java.lang.String getSource()
          Get template source.
 TemplatePath getTemplatePath()
          Get the TemplatePath to this template
 boolean hasMetaFile()
           
 void load(TemplatePath pTemplatePath)
          Load template and parse for PropertySet.
 void modifyForOldVersion()
          Modify template properties to handle older template versions.
 void setCodeWriterChanged(boolean pChanged)
           
 void setCodeWriterExecutablePath(java.io.File pCodeWriterExecutablePath)
           
 void setCodeWriterPath(java.io.File pCodeWriter)
          Set the code writer when known
 void setCodeWriterSource(java.lang.String pCodeWriterSource)
           
 void setContext(java.lang.Object pContext)
          Set context object for internal code writers.
 void setMetaFile(java.io.File pMetaFile)
           
 void setPropertySet(java.lang.String pConfName, PropertySet pPropertySet)
           
 void setResult(java.lang.Object pResult)
          Set result object from CodeWriter (optional).
 void setSavedFiles(java.util.List pSavedFiles)
           
 void setSectionSet(SectionSet pSectionSet)
          Set the data container for the insert section text of this template.
 void setSource(java.lang.String pSource)
          Set template source and parse for PropertySet.
 java.lang.String toString()
          Provide a user-friendly description of the template.
 java.lang.String traceProperty(java.lang.String pName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INCLUDE_MOD_if_exists

public static final java.lang.String INCLUDE_MOD_if_exists
See Also:
Constant Field Values

INCLUDE_MOD_template_relative

public static final java.lang.String INCLUDE_MOD_template_relative
See Also:
Constant Field Values

INCLUDE_MOD_output_relative

public static final java.lang.String INCLUDE_MOD_output_relative
See Also:
Constant Field Values

iTemplatePath

protected TemplatePath iTemplatePath

iTemplateScript

protected TemplateScript iTemplateScript

iPath

protected java.lang.String iPath

iSource

protected java.lang.String iSource

iForceIncludeBase

protected boolean iForceIncludeBase

iForcedIncludeBase

protected java.lang.String iForcedIncludeBase

iConfRegExp

protected RegExp iConfRegExp

iIncludeRegExp

protected RegExp iIncludeRegExp

iIncludeBaseRegExp

protected RegExp iIncludeBaseRegExp

iIncludeBlockRegExp

protected RegExp iIncludeBlockRegExp

iAlsoGenerate

protected TemplatePath[] iAlsoGenerate

iSectionSet

protected SectionSet iSectionSet

iLastMod

protected long iLastMod

iBuildResource

protected BuildResource iBuildResource

iContext

protected java.lang.Object iContext

iResult

protected java.lang.Object iResult

iCodeWriterSource

protected java.lang.String iCodeWriterSource

iCodeWriterChanged

protected boolean iCodeWriterChanged

iCodeWriterRef

protected FileRef iCodeWriterRef

iCodeWriterExecRef

protected FileRef iCodeWriterExecRef

iOrderedPSM

protected OrderedPropertySetManager iOrderedPSM

iSavedFiles

protected java.util.List iSavedFiles

iMetaFile

protected java.io.File iMetaFile
Constructor Detail

BasicTemplate

public BasicTemplate()
Create with empty template path


BasicTemplate

public BasicTemplate(java.lang.String pName)
Create with name of template. This assumes that the template name refers to a file of the same name in the current folder.


BasicTemplate

public BasicTemplate(TemplatePath pTemplatePath)
Create a template using a TemplatePath object. This is the standard method for creating template objects, as the TemplatePath object does path and library resolution.

Method Detail

setSectionSet

public void setSectionSet(SectionSet pSectionSet)
Description copied from interface: Template
Set the data container for the insert section text of this template.

Specified by:
setSectionSet in interface Template
Parameters:
pSectionSet - container for section text

getSectionSet

public SectionSet getSectionSet()
Description copied from interface: Template
Get the data cotnainer for the insert section text of this template.

Specified by:
getSectionSet in interface Template

setContext

public void setContext(java.lang.Object pContext)
Description copied from interface: Template
Set context object for internal code writers.

Specified by:
setContext in interface Template
Parameters:
pContext - context object

getContext

public java.lang.Object getContext()
Description copied from interface: Template
Get context object for internal code writers. NOTE: may be null.

Specified by:
getContext in interface Template

setResult

public void setResult(java.lang.Object pResult)
Description copied from interface: Template
Set result object from CodeWriter (optional).

Specified by:
setResult in interface Template

getResult

public java.lang.Object getResult()
Description copied from interface: Template
Get result object from CodeWriter (may be null).

Specified by:
getResult in interface Template

load

public void load(TemplatePath pTemplatePath)
          throws TemplateException
Description copied from interface: Template
Load template and parse for PropertySet.

Specified by:
load in interface Template
Parameters:
pTemplatePath - Path to load template from.
Throws:
TemplateException

getTemplatePath

public TemplatePath getTemplatePath()
Description copied from interface: Template
Get the TemplatePath to this template

Specified by:
getTemplatePath in interface Template

setSource

public void setSource(java.lang.String pSource)
               throws TemplateException
Description copied from interface: Template
Set template source and parse for PropertySet.

Specified by:
setSource in interface Template
Throws:
TemplateException

getSource

public java.lang.String getSource()
Description copied from interface: Template
Get template source.

Specified by:
getSource in interface Template

getPropertySet

public PropertySet getPropertySet(java.lang.String pConfName)
Description copied from interface: Template
Get template PropertySet.

Specified by:
getPropertySet in interface Template

setPropertySet

public void setPropertySet(java.lang.String pConfName,
                           PropertySet pPropertySet)
Specified by:
setPropertySet in interface Template

getMergedPropertySet

public PropertySet getMergedPropertySet()
Specified by:
getMergedPropertySet in interface Template

traceProperty

public java.lang.String traceProperty(java.lang.String pName)
Specified by:
traceProperty in interface Template

getAlsoGenerate

public TemplatePath[] getAlsoGenerate()
Description copied from interface: Template
Get list of templates to which should also be generated.

Specified by:
getAlsoGenerate in interface Template

getCodeWriterLang

public java.lang.String getCodeWriterLang()
Description copied from interface: Template
Get code writer lang if defined, else return empty String.

Specified by:
getCodeWriterLang in interface Template

getLastMod

public long getLastMod()
Description copied from interface: Template
Get last modified date of template source file

Specified by:
getLastMod in interface Template

getBuildResource

public BuildResource getBuildResource()
Description copied from interface: Template
Get the set of build resources for this template

Specified by:
getBuildResource in interface Template

setCodeWriterPath

public void setCodeWriterPath(java.io.File pCodeWriter)
Description copied from interface: Template
Set the code writer when known

Specified by:
setCodeWriterPath in interface Template

getCodeWriterPath

public java.io.File getCodeWriterPath()
Specified by:
getCodeWriterPath in interface Template

setCodeWriterSource

public void setCodeWriterSource(java.lang.String pCodeWriterSource)
Specified by:
setCodeWriterSource in interface Template

getCodeWriterSource

public java.lang.String getCodeWriterSource()
Specified by:
getCodeWriterSource in interface Template

setCodeWriterChanged

public void setCodeWriterChanged(boolean pChanged)
Specified by:
setCodeWriterChanged in interface Template

getCodeWriterChanged

public boolean getCodeWriterChanged()
Specified by:
getCodeWriterChanged in interface Template

setCodeWriterExecutablePath

public void setCodeWriterExecutablePath(java.io.File pCodeWriterExecutablePath)
Specified by:
setCodeWriterExecutablePath in interface Template

getCodeWriterExecutablePath

public java.io.File getCodeWriterExecutablePath()
Specified by:
getCodeWriterExecutablePath in interface Template

setSavedFiles

public void setSavedFiles(java.util.List pSavedFiles)
Specified by:
setSavedFiles in interface Template

getSavedFiles

public java.util.List getSavedFiles()
Specified by:
getSavedFiles in interface Template

setMetaFile

public void setMetaFile(java.io.File pMetaFile)
Specified by:
setMetaFile in interface Template

getMetaFile

public java.io.File getMetaFile()
Specified by:
getMetaFile in interface Template

hasMetaFile

public boolean hasMetaFile()
Specified by:
hasMetaFile in interface Template

toString

public java.lang.String toString()
Description copied from interface: Template
Provide a user-friendly description of the template.

Specified by:
toString in interface Template

forceIncludeBase

public void forceIncludeBase(java.lang.String pIncludeBase)
Force template to use a specified include base. Any includebase actions in template will be ignored

Parameters:
pIncludeBase - include base folder path

modifyForOldVersion

public void modifyForOldVersion()
Modify template properties to handle older template versions.

Specified by:
modifyForOldVersion in interface Template


Copyright © 2000-2002 Richard Rodger