public abstract class CodeletTemplateBase extends SimpleDebuggable
What the fully-processed output (source-code, console output, or plain-file text) is put into--The rendered template is what actually replaces the codelet-taglet.
Codelet: Templates: OverviewCodelet templates have one or two required "body" gaps, where the fully-processed text (source-code, console output, or plain-file text) is placed. The {@codelet.and.out} template has two body gaps, the rest have one. Each template type defines "optional-default" gaps, which you may place in your templates at your discretion. "Extra user-created" gaps are permitted if explicitely configured.
All gaps, in all Codelet templates (including user-created), are automatically filled.
aliteralmind __DASH__ github __AT__ yahoo __DOT__ com), dual-licensed under the LGPL (version 3.0 or later) or the ASL (version 2.0). See source code for details. http://codelet.aliteralmind.com, https://github.com/aliteralmind/codelet| Constructor and Description |
|---|
CodeletTemplateBase(CodeletTemplateBase to_copy,
Appendable debugDest_ifNonNull)
Create a new instance as a duplicate of another.
|
CodeletTemplateBase(CodeletTemplateBase to_copy,
FeatherTemplate template,
String tmpl_path)
Create the second or subsequent instance.
|
CodeletTemplateBase(CodeletType type,
FeatherTemplate template,
String tmpl_path,
String[] required_bodyGapNames,
CodeletGap[] optional_defaultGaps,
UserExtraGapGetter userExtra_gapGetter)
Create the first instance only.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addCustomGaps(Map<String,CodeletGap> optionalDefault_gapMap,
CodeletGap[] gap_array)
Add custom gaps to the template.
|
void |
fillBodyGap(String body_gapName,
String body_text)
Fill a body gap.
|
int |
getGapCount()
The number of gaps actually in the template.
|
abstract CodeletTemplateBase |
getObjectCopy(Appendable debugDest_ifNonNull) |
String |
getPath() |
String |
getRendered(CodeletInstance instance)
ReplacedInEachInput all default-optional and user-extra gaps with their values, resets the template, and returns its fully-rendered text--This is what actually replaces the codelet-taglet.
|
protected FeatherTemplate |
getTemplate()
The template.
|
CodeletType |
getType()
The type of this template.
|
static Map<String,CodeletGap> |
newGapMapFromArray(CodeletGap[] gap_array)
Create a new map of all gap objects.
|
static FeatherTemplate |
newTemplateFromPath(String path,
String path_varName,
String... required_gaps)
Read in and parse a template given its path.
|
void |
setDebug(Appendable destination,
boolean is_on) |
void |
setDebugOn(boolean is_on) |
appendToString, debug, debugln, getDebugApbl, getDebugAptr, getObjectCopy, isDebugOn, onIfNonNull, toString, zsetDebugDB, zsetDebugOnDBpublic CodeletTemplateBase(CodeletType type, FeatherTemplate template, String tmpl_path, String[] required_bodyGapNames, CodeletGap[] optional_defaultGaps, UserExtraGapGetter userExtra_gapGetter)
Create the first instance only. To avoid circular dependencies, this class cannot have any references to CodeletBaseConfig.
type - May not be null. Get with getType().template - May not be null, must be resettable, and must contain all body gaps, and no gaps that are not either optional-default or user-extra. This is duplicated (defensively copied). Get with getTemplate().tmpl_path - The full path to the template file. May not be null or empty. Get with getPath()required_bodyGapNames - The one or two required body-gap names.optional_defaultGaps - The optional-default gaps for the codelet type. May not be null or contain null elements, and all gap names must be unique.userExtra_gapGetter - Extra user-configured gaps. If null, there are no extra. Otherwise, the gaps its function (of type type) returns may not be null or contain null elements, and all gap names must be unique and not equal to the body gaps or those in optional_defaultGaps.IncorrectGapsException - Ifrequired_bodyGapNames is invalidIllegalArgumentException - If the userExtra_gapGetter function of type type returns null.CodeletTemplateBase(CodeletTemplateBase, FeatherTemplate, String),
CodeletTemplateBase(CodeletTemplateBase, Appendable)public CodeletTemplateBase(CodeletTemplateBase to_copy, FeatherTemplate template, String tmpl_path)
Create the second or subsequent instance.
zzCodeletTemplateBase.templateparseandfill: constructorFeatherTemplate.
to_copy - May not be null.template - May not be null, must have all body gaps, and may not have any gaps that are not either optional-default or user-extra. This is duplicated (defensively copied). Get with getTemplate().CodeletTemplateBase(CodeletType, FeatherTemplate, String, String[], CodeletGap[], UserExtraGapGetter),
CodeletTemplateBase(CodeletTemplateBase, Appendable)public CodeletTemplateBase(CodeletTemplateBase to_copy, Appendable debugDest_ifNonNull)
Create a new instance as a duplicate of another.
This calls
this(to_copy, to_copy.getTemplate(), to_copy.getPath())onIfNonNull(debugDest_ifNonNull)public CodeletType getType()
The type of this template.
public void fillBodyGap(String body_gapName, String body_text)
body_gapName - The body gap name. Must not have already been filled.body_text - May not be null or empty.public String getRendered(CodeletInstance instance)
ReplacedInEachInput all default-optional and user-extra gaps with their values, resets the template, and returns its fully-rendered text--This is what actually replaces the codelet-taglet.
instance - May not be null.IllegalArgumentException - If any gaps are already filled, or if the com.github.aliteralmind.codelet.CodeletGap#getFillText(CodeletInstance) fill text is null or empty.fillBodyGap(String, String)public int getGapCount()
The number of gaps actually in the template.
getTemplate().getGapMap().size()protected FeatherTemplate getTemplate()
The template.
public abstract CodeletTemplateBase getObjectCopy(Appendable debugDest_ifNonNull)
public static final Map<String,CodeletGap> newGapMapFromArray(CodeletGap[] gap_array)
Create a new map of all gap objects.
gap_array - May not be null or contain null elements, and all gap names must be unique.IllegalArgumentException - If a gap name is used more than once.addCustomGaps(Map, CodeletGap[])public static final void addCustomGaps(Map<String,CodeletGap> optionalDefault_gapMap, CodeletGap[] gap_array)
Add custom gaps to the template.
optionalDefault_gapMap - May not be null, and must contain only the ...default gaps....gap_array - May not be null or contain null elements, and all gap names must be unique and not contain any in optionalDefault_gapMap.IllegalArgumentException - If gap_array contains a duplicate or default gap name (or they've already been added to the template!).public static final FeatherTemplate newTemplateFromPath(String path, String path_varName, String... required_gaps)
Read in and parse a template given its path.
zzCodeletTemplateBase.newTemplateFromPath.
loading: "Loading template from [path]..."templateparseandfill: FeatherTemplate.constructorpublic void setDebug(Appendable destination, boolean is_on)
setDebug in interface DebuggablesetDebug in class SimpleDebuggablepublic void setDebugOn(boolean is_on)
setDebugOn in interface DebuggablesetDebugOn in class SimpleDebuggableCopyright 2014, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.
https://github.com/aliteralmind/codelet