freemarker.core
abstract public class: TemplateObject [javadoc |
source]
java.lang.Object
freemarker.core.TemplateObject
Direct Known Subclasses:
AssignmentInstruction, sort_byBI, seq_index_ofBI, Expression, keysBI, last_index_ofBI, is_stringBI, ArithmeticExpression, ParentheticalExpression, SequenceBuiltIn, chop_linebreakBI, is_directiveBI, rootBI, TextBlock, RecurseNode, ends_withBI, NotExpression, lastBI, firstBI, js_stringBI, j_stringBI, valuesBI, floatBI, replaceBI, NumericalOutput, is_macroBI, IteratorBlock, lengthBI, node_nameBI, is_hash_exBI, MethodCall, AddConcatExpression, TransformBlock, childrenBI, floorBI, cap_firstBI, cBI, BooleanExpression, AndExpression, right_padBI, is_collectionBI, ReturnInstruction, is_indexableBI, ConditionalBlock, NewBI, evalBI, matchesBI, TrimInstruction, Dot, ListLiteral, dateBI, NodeBuiltIn, IfBlock, upper_caseBI, split_reBI, DefaultToExpression, stringBI, existsBI, OrExpression, containsBI, byteBI, replace_reBI, defaultBI, doubleBI, BlockAssignment, Interpret, MixedContent, substringBI, if_existsBI, BuiltIn, VisitNode, has_contentBI, HashLiteral, FlushInstruction, Assignment, longBI, is_transformBI, UnaryPlusMinusExpression, DebugBreak, groupsBI, BodyInstruction, starts_withBI, splitBI, UnifiedCall, sortBI, shortBI, parentBI, StringBuiltIn, intBI, Macro, Case, ExistsExpression, sizeBI, seq_containsBI, is_booleanBI, namespaceBI, PropertySetting, Identifier, SwitchBlock, AttemptBlock, node_typeBI, is_methodBI, is_hashBI, numberBI, Range, ComparisonExpression, ceilingBI, DollarVariable, is_dateBI, StopInstruction, BooleanLiteral, Include, index_ofBI, is_nodeBI, roundBI, NoEscapeBlock, NumberBuiltIn, LibraryLoad, CompressedBlock, uncap_firstBI, node_namespaceBI, chunkBI, reverseBI, NumberLiteral, BuiltinVariable, lower_caseBI, Comment, StringLiteral, is_numberBI, ancestorsBI, is_sequenceBI, TemplateElement, left_padBI, capitalizeBI, BreakInstruction, is_enumerableBI, DynamicKeyName, RecoveryBlock, word_listBI, EscapeBlock, FallbackInstruction
Objects that represent instructions or expressions
in the compiled tree representation of the template
all descend from this abstract base class.
| Field Summary |
|---|
| int | beginColumn | |
| int | beginLine | |
| int | endColumn | |
| int | endLine | |
| Method from freemarker.core.TemplateObject Summary: |
|---|
|
assertNonNull, contains, copyLocationFrom, getBeginColumn, getBeginLine, getCanonicalForm, getEndColumn, getEndLine, getEndLocation, getSource, getStartLocation, getTemplate, invalidTypeException, setLocation, setLocation, setLocation, setLocation, setLocation, toString |
| Method from freemarker.core.TemplateObject Detail: |
static void assertNonNull(TemplateModel model,
Expression exp,
Environment env) throws InvalidReferenceException {
if (model == null) {
throw new InvalidReferenceException(
"Expression " + exp + " is undefined " +
exp.getStartLocation() + ".", env);
}
}
|
public boolean contains(int column,
int line) {
if (line < beginLine || line > endLine) {
return false;
}
if (line == beginLine) {
if (column < beginColumn) {
return false;
}
}
if (line == endLine) {
if (column > endColumn) {
return false;
}
}
return true;
}
|
TemplateObject copyLocationFrom(TemplateObject from) {
template = from.template;
beginColumn = from.beginColumn;
beginLine = from.beginLine;
endColumn = from.endColumn;
endLine = from.endLine;
return this;
}
|
public final int getBeginColumn() {
return beginColumn;
}
|
public final int getBeginLine() {
return beginLine;
}
|
abstract public String getCanonicalForm()
|
public final int getEndColumn() {
return endColumn;
}
|
public final int getEndLine() {
return endLine;
}
|
public String getEndLocation() {
String templateName = template != null ? template.getName() : "input";
return "on line "
+ endLine
+ ", column "
+ endColumn
+ " in "
+ templateName;
}
|
public final String getSource() {
if (template != null) {
return template.getSource(beginColumn, beginLine, endColumn, endLine);
} else {
return getCanonicalForm();
}
}
|
public String getStartLocation() {
String templateName = template != null ? template.getName() : "input";
return "on line "
+ beginLine
+ ", column "
+ beginColumn
+ " in "
+ templateName;
}
Returns a string that indicates
where in the template source, this object is. |
public Template getTemplate() {
return template;
}
|
static TemplateException invalidTypeException(TemplateModel model,
Expression exp,
Environment env,
String expected) throws TemplateException {
assertNonNull(model, exp, env);
return new TemplateException(
"Expected " + expected + ". " +
exp + " evaluated instead to " +
model.getClass().getName() + " " +
exp.getStartLocation() + ".", env);
}
|
final void setLocation(Template template,
Token begin,
Token end) throws ParseException {
setLocation(template, begin.beginColumn, begin.beginLine, end.endColumn, end.endLine);
}
|
final void setLocation(Template template,
Token begin,
TemplateObject end) throws ParseException {
setLocation(template, begin.beginColumn, begin.beginLine, end.endColumn, end.endLine);
}
|
final void setLocation(Template template,
TemplateObject begin,
Token end) throws ParseException {
setLocation(template, begin.beginColumn, begin.beginLine, end.endColumn, end.endLine);
}
|
final void setLocation(Template template,
TemplateObject begin,
TemplateObject end) throws ParseException {
setLocation(template, begin.beginColumn, begin.beginLine, end.endColumn, end.endLine);
}
|
void setLocation(Template template,
int beginColumn,
int beginLine,
int endColumn,
int endLine) throws ParseException {
this.template = template;
this.beginColumn = beginColumn;
this.beginLine = beginLine;
this.endColumn = endColumn;
this.endLine = endLine;
}
|
public String toString() {
try {
return getSource();
} catch (Exception e) { // REVISIT: A bit of a hack? (JR)
return getCanonicalForm();
}
}
|