Package ru.proninyaroslav.template
Class Template
java.lang.Object
ru.proninyaroslav.template.Template
Representation of a parsed template
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddParseTree(String name, Tree tree) Adds parse tree for template with given name and associates it with template.voidexecute(OutputStream os, Object data) Applies a parsed template to the specified data object, and writes the output to OutputStream.voidexecuteTemplate(OutputStream os, String name, Object data) Applies the template associated with this template that has the given name to the specified data object and writes the output to OutputStreamgetTemplate(String name) Template[]voidparse(InputStream input) voidNamed template definition ({define ...}) in text define additional templates associated with template and are removed from the definition of template itself.static TemplateCreate templates from the file liststatic TemplateCreate templates from the map, that represent pair (Name, InputStream)Create templates from the file list and append to this templateCreate templates from the map, that represent pair (Name, Text) and append to this templatevoid
-
Constructor Details
-
Template
-
Template
Allocates a new, undefined template associated with the given one and with the same delimiters. The association allows one template to invoke another with a {template} action- Parameters:
name- template nameparent- parent
-
-
Method Details
-
parse
Create templates from the file list- Parameters:
funcs- functionsfiles- template files- Returns:
- template
- Throws:
ParseException- in case of a parse errorIOException- in case of an I/O error
-
parse
Create templates from the map, that represent pair (Name, InputStream)- Parameters:
funcs- functionsinputs- list ofInputStream- Returns:
- template
- Throws:
ParseException- in case of a parse error
-
parse
Named template definition ({define ...}) in text define additional templates associated with template and are removed from the definition of template itself. Templates can be redefined in successive calls to parse. A template definition with a body containing only white space and comments is considered empty and will not replace an existing template's body.- Parameters:
text- template text- Throws:
InternalException- in case of an internal errorParseException- in case of a parse error
-
parse
-
parseTo
Create templates from the file list and append to this template- Parameters:
funcs- functionsfiles- template files- Returns:
- template
- Throws:
ParseException- in case of a parse errorIOException- in case of an I/O error
-
parseTo
Create templates from the map, that represent pair (Name, Text) and append to this template- Parameters:
funcs- functionstext- pair (Name, Text)- Returns:
- template
- Throws:
ParseException- in case of a parse error
-
execute
Applies a parsed template to the specified data object, and writes the output to OutputStream. If an error occurs executing the template or writing its output, execution stops, but partial results may already have been written to the output writer- Parameters:
os-OutputStreamobjectdata- data- Throws:
ExecException- in case of an execute error
-
executeTemplate
Applies the template associated with this template that has the given name to the specified data object and writes the output to OutputStream- Parameters:
os-OutputStreamobjectname- template namedata- data- Throws:
ExecException- in case of an execute error
-
addFuncs
-
setDelims
-
getTemplates
-
getTemplate
-
addParseTree
Adds parse tree for template with given name and associates it with template. If the template does not already exist, it will create a new one. If the template does exist, it will be replaced- Parameters:
name- template nametree- parse tree- Throws:
InternalException- in case of an internal errorParseException- in case of an execute error
-