JTools

org.jtools.tmpl.compiler
Class SimpleTemplate

java.lang.Object
  extended by org.jtools.tmpl.compiler.SimpleTemplate
All Implemented Interfaces:
CompilerItemCallback, MacroCallback, ParserCallback, Template

public class SimpleTemplate
extends Object
implements Template, ParserCallback, MacroCallback, CompilerItemCallback


Field Summary
protected  String Extends
           
protected  List<String> global
           
protected  List<String> header
           
protected  Set<String> Impl_Set
           
protected  List<String> Implements
           
protected  MacroManager macroManager
           
protected  List<CompilerItem.MethodBody> methodBody
           
 
Constructor Summary
SimpleTemplate(Compiler compiler, String sourceFilename, String templateClassname, TmplLanguage tmplLanguage, DestLanguage destLanguage, SimpleInfoSupport support, boolean omitOnIdent, String includePath, Collection<SimpleMacroDescriptor> macroDescriptors)
           
 
Method Summary
 void add(CompilerItem item)
           
 void addCode(char[] comment, InfoSupport support)
           
 void addComment(char[] comment, InfoSupport support)
           
 void addExpression(char[] code, InfoSupport support)
           
 void addGlobalCode(String x)
           
 void addHeaderCode(String x)
           
 void addImage(char[] image, InfoSupport support)
           
 boolean addImplements(String classname)
           
 void addLinebreak(InfoSupport support)
           
 void addMacro(Macro macro)
           
 void addMacro(Macro macro, String groupName, String groupClass)
           
 void addMacro(Macro macro, String macroName, String macroClass, String groupName, String groupClass)
           
 void addMacro(SimpleMacroDescriptor macro, InfoSupport support)
           
 int addMacros(MacroLib macroSet)
           
 int addMacros(MacroLib macrog, String groupName, String groupClass)
           
 boolean addMethodBody(CompilerItem.MethodBody.MBBegin x)
           
 boolean addMethodBody(CompilerItem.MethodBody.MBCode x)
           
 boolean addMethodBody(CompilerItem.MethodBody.MBComment x)
           
 boolean addMethodBody(CompilerItem.MethodBody.MBEnd x)
           
 boolean addMethodBody(CompilerItem.MethodBody.MBExpression x)
           
 boolean addMethodBody(CompilerItem.MethodBody.MBImage x)
           
 boolean addMethodBody(CompilerItem.MethodBody.MBLinebreak x)
           
 void addStatement(Parser parser, char[][] statementlines, Collection<StatementReader.Factory> readerfactory, InfoSupport support)
           
 PrintStreamOutput.Result compile(PrintStreamOutput out)
           
 Parser createParser()
           
 int decSkipLevel()
           
protected  void execute(CompilerItem item)
           
 Macro findMacro(MacroIdentifier macroID, ArgumentValues arguments, InfoSupport support)
           
 Compiler getCompiler()
          Gets the compiler.
protected  ParserFactory getDefaultParserFactory()
           
 DestLanguage getDestLanguage()
          Gets the DestLanguage of the current Template.
 Map<Object,Object> getFeatures()
          Gets a map of features.
 String getIncludePath()
           
 String getParserTarget()
           
 Properties getProperties()
          Gets the properties.
 InfoPublisher getPublisher()
          Gets the info publisher.
 String getSourceFilename()
          Gets the source filename.
 InfoSupport getSupport()
           
 Template getTemplate()
           
 String getTemplateClassname()
          Gets the dest filename.
 TmplLanguage getTmplLanguage()
          Gets the template language.
protected  Collection<URL> getUrlIncludePath()
           
 int incSkipLevel()
          Increments the skip level.
 boolean isOmitOnIdent()
           
 boolean isSkip()
          Indicates the current skip state.
protected  void load(String FileName, boolean useIncludePath)
           
 void load(String FileName, CompilerItem.IncludeItem parent)
           
protected  void load(String FileName, InputStream input)
           
protected  InputStream open(String filename, boolean useIncludePath)
           
 boolean setExtends(String classname)
           
 void setIncludePath(String path)
          Sets the include path.
 void setOmitOnIdent(boolean onOff)
          Sets the omit on ident flag.
 void setParserFactory(ParserFactory parserFactory)
           
 void setParserTarget(String target)
           
 void setProperties(Properties properties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Extends

protected String Extends

global

protected final List<String> global

header

protected final List<String> header

Impl_Set

protected final Set<String> Impl_Set

Implements

protected final List<String> Implements

macroManager

protected MacroManager macroManager

methodBody

protected final List<CompilerItem.MethodBody> methodBody
Constructor Detail

SimpleTemplate

public SimpleTemplate(Compiler compiler,
                      String sourceFilename,
                      String templateClassname,
                      TmplLanguage tmplLanguage,
                      DestLanguage destLanguage,
                      SimpleInfoSupport support,
                      boolean omitOnIdent,
                      String includePath,
                      Collection<SimpleMacroDescriptor> macroDescriptors)
Method Detail

add

public void add(CompilerItem item)
         throws IOException,
                CompilerException
Specified by:
add in interface MacroCallback
Throws:
IOException
CompilerException

addCode

public void addCode(char[] comment,
                    InfoSupport support)
             throws IOException,
                    CompilerException
Specified by:
addCode in interface ParserCallback
Throws:
IOException
CompilerException

addComment

public void addComment(char[] comment,
                       InfoSupport support)
                throws IOException,
                       CompilerException
Specified by:
addComment in interface ParserCallback
Throws:
IOException
CompilerException

addExpression

public void addExpression(char[] code,
                          InfoSupport support)
                   throws IOException,
                          CompilerException
Specified by:
addExpression in interface ParserCallback
Throws:
IOException
CompilerException

addGlobalCode

public void addGlobalCode(String x)
                   throws CompilerException
Specified by:
addGlobalCode in interface CompilerItemCallback
Throws:
CompilerException

addHeaderCode

public void addHeaderCode(String x)
                   throws CompilerException
Specified by:
addHeaderCode in interface CompilerItemCallback
Throws:
CompilerException

addImage

public void addImage(char[] image,
                     InfoSupport support)
              throws IOException,
                     CompilerException
Specified by:
addImage in interface ParserCallback
Throws:
IOException
CompilerException

addImplements

public boolean addImplements(String classname)
                      throws CompilerException
Specified by:
addImplements in interface CompilerItemCallback
Throws:
CompilerException

addLinebreak

public void addLinebreak(InfoSupport support)
                  throws IOException,
                         CompilerException
Specified by:
addLinebreak in interface ParserCallback
Throws:
IOException
CompilerException

addMacro

public void addMacro(Macro macro)

addMacro

public void addMacro(Macro macro,
                     String groupName,
                     String groupClass)

addMacro

public void addMacro(Macro macro,
                     String macroName,
                     String macroClass,
                     String groupName,
                     String groupClass)

addMacro

public void addMacro(SimpleMacroDescriptor macro,
                     InfoSupport support)

addMacros

public int addMacros(MacroLib macroSet)

addMacros

public int addMacros(MacroLib macrog,
                     String groupName,
                     String groupClass)
Specified by:
addMacros in interface Template

addMethodBody

public boolean addMethodBody(CompilerItem.MethodBody.MBBegin x)
                      throws CompilerException
Specified by:
addMethodBody in interface CompilerItemCallback
Throws:
CompilerException

addMethodBody

public boolean addMethodBody(CompilerItem.MethodBody.MBCode x)
                      throws CompilerException
Specified by:
addMethodBody in interface CompilerItemCallback
Throws:
CompilerException

addMethodBody

public boolean addMethodBody(CompilerItem.MethodBody.MBComment x)
                      throws CompilerException
Specified by:
addMethodBody in interface CompilerItemCallback
Throws:
CompilerException

addMethodBody

public boolean addMethodBody(CompilerItem.MethodBody.MBEnd x)
                      throws CompilerException
Specified by:
addMethodBody in interface CompilerItemCallback
Throws:
CompilerException

addMethodBody

public boolean addMethodBody(CompilerItem.MethodBody.MBExpression x)
                      throws CompilerException
Specified by:
addMethodBody in interface CompilerItemCallback
Throws:
CompilerException

addMethodBody

public boolean addMethodBody(CompilerItem.MethodBody.MBImage x)
                      throws CompilerException
Specified by:
addMethodBody in interface CompilerItemCallback
Throws:
CompilerException

addMethodBody

public boolean addMethodBody(CompilerItem.MethodBody.MBLinebreak x)
                      throws CompilerException
Specified by:
addMethodBody in interface CompilerItemCallback
Throws:
CompilerException

addStatement

public void addStatement(Parser parser,
                         char[][] statementlines,
                         Collection<StatementReader.Factory> readerfactory,
                         InfoSupport support)
                  throws IOException,
                         CompilerException
Specified by:
addStatement in interface ParserCallback
Throws:
IOException
CompilerException

compile

public PrintStreamOutput.Result compile(PrintStreamOutput out)
                                 throws IOException,
                                        CompilerException
Specified by:
compile in interface Template
Throws:
IOException
CompilerException

createParser

public Parser createParser()

decSkipLevel

public int decSkipLevel()
                 throws CompilerException
Specified by:
decSkipLevel in interface Template
Throws:
CompilerException

execute

protected void execute(CompilerItem item)
                throws IOException,
                       CompilerException
Throws:
IOException
CompilerException

findMacro

public Macro findMacro(MacroIdentifier macroID,
                       ArgumentValues arguments,
                       InfoSupport support)
                throws CompilerException
Specified by:
findMacro in interface CompilerItemCallback
Throws:
CompilerException

getCompiler

public Compiler getCompiler()
Description copied from interface: Template
Gets the compiler.

Specified by:
getCompiler in interface Template
Returns:
The compiler.

getDefaultParserFactory

protected ParserFactory getDefaultParserFactory()

getDestLanguage

public DestLanguage getDestLanguage()
Description copied from interface: Template
Gets the DestLanguage of the current Template.

Specified by:
getDestLanguage in interface Template
Returns:
The DestLanguage.

getFeatures

public Map<Object,Object> getFeatures()
Description copied from interface: Template
Gets a map of features.

Specified by:
getFeatures in interface Template
Returns:
Feature map.

getIncludePath

public String getIncludePath()
Specified by:
getIncludePath in interface Template

getParserTarget

public String getParserTarget()

getProperties

public Properties getProperties()
Description copied from interface: Template
Gets the properties.

Specified by:
getProperties in interface Template
Returns:
The properties.

getPublisher

public InfoPublisher getPublisher()
Description copied from interface: Template
Gets the info publisher.

Specified by:
getPublisher in interface Template
Returns:
The info publisher.

getSourceFilename

public String getSourceFilename()
Description copied from interface: Template
Gets the source filename.

Specified by:
getSourceFilename in interface Template
Returns:
THe source filename.

getSupport

public InfoSupport getSupport()
Specified by:
getSupport in interface Template

getTemplate

public Template getTemplate()
Specified by:
getTemplate in interface CompilerItemCallback

getTemplateClassname

public String getTemplateClassname()
Description copied from interface: Template
Gets the dest filename.

Specified by:
getTemplateClassname in interface Template
Returns:
The dest filename.

getTmplLanguage

public TmplLanguage getTmplLanguage()
Description copied from interface: Template
Gets the template language.

Specified by:
getTmplLanguage in interface Template
Returns:
The template language.

getUrlIncludePath

protected Collection<URL> getUrlIncludePath()

incSkipLevel

public int incSkipLevel()
                 throws CompilerException
Description copied from interface: Template
Increments the skip level.

Specified by:
incSkipLevel in interface Template
Returns:
New skip level.
Throws:
CompilerException

isOmitOnIdent

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

isSkip

public boolean isSkip()
Description copied from interface: Template
Indicates the current skip state.

Specified by:
isSkip in interface Template
Returns:
True if if the skip level is 1 or higher, false otherwise.

load

protected void load(String FileName,
                    boolean useIncludePath)
             throws IOException,
                    CompilerException
Throws:
IOException
CompilerException

load

protected void load(String FileName,
                    InputStream input)
             throws IOException,
                    CompilerException
Throws:
IOException
CompilerException

load

public void load(String FileName,
                 CompilerItem.IncludeItem parent)
          throws IOException,
                 CompilerException
Specified by:
load in interface CompilerItemCallback
Throws:
IOException
CompilerException

open

protected InputStream open(String filename,
                           boolean useIncludePath)
                    throws IOException
Throws:
IOException

setExtends

public boolean setExtends(String classname)
                   throws CompilerException
Specified by:
setExtends in interface CompilerItemCallback
Throws:
CompilerException

setIncludePath

public void setIncludePath(String path)
Description copied from interface: Template
Sets the include path.

Specified by:
setIncludePath in interface Template
Parameters:
path - The include path.

setOmitOnIdent

public void setOmitOnIdent(boolean onOff)
Description copied from interface: Template
Sets the omit on ident flag.

Specified by:
setOmitOnIdent in interface Template
Parameters:
onOff - True to switch omit on ident on, false to set it off.

setParserFactory

public void setParserFactory(ParserFactory parserFactory)
Specified by:
setParserFactory in interface Template

setParserTarget

public void setParserTarget(String target)

setProperties

public void setProperties(Properties properties)
Specified by:
setProperties in interface Template

JTools

© 2000-2006, JTools.org.