- java.lang.Object
-
- com.samskivert.mustache.Template.Segment
-
- com.samskivert.mustache.Mustache.StringSegment
-
- Enclosing class:
- Mustache
protected static class Mustache.StringSegment extends Template.Segment
A simple segment that reproduces a string.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean_firstprotected int_leadBlankprotected java.lang.String_textprotected int_trailBlank
-
Constructor Summary
Constructors Constructor Description StringSegment(java.lang.String text, boolean first)StringSegment(java.lang.String text, int leadBlank, int trailBlank, boolean first)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static intblankPos(java.lang.String text, boolean leading, boolean first)voiddecompile(Mustache.Delims delims, java.lang.StringBuilder into)voidexecute(Template tmpl, Template.Context ctx, java.io.Writer out)(package private) java.lang.Stringindent()Calculate indent for partial idententation(package private) Mustache.StringSegmentindent(java.lang.String indent, boolean first, boolean last)Recursively indent by the parameter indent.(package private) booleanisStandalone()Whether or not the segment is standalone.booleanleadsBlank()private static java.lang.Stringreindent(java.lang.String input, java.lang.String indent, boolean first, boolean last)java.lang.StringtoString()booleantrailsBlank()Mustache.StringSegmenttrimLeadBlank()Mustache.StringSegmenttrimTrailBlank()voidvisit(Mustache.Visitor visitor)-
Methods inherited from class com.samskivert.mustache.Template.Segment
write
-
-
-
-
Method Detail
-
leadsBlank
public boolean leadsBlank()
-
trailsBlank
public boolean trailsBlank()
-
trimLeadBlank
public Mustache.StringSegment trimLeadBlank()
-
trimTrailBlank
public Mustache.StringSegment trimTrailBlank()
-
indent
java.lang.String indent()
Calculate indent for partial idententation- Returns:
- indent space or empty string
-
indent
Mustache.StringSegment indent(java.lang.String indent, boolean first, boolean last)
Description copied from class:Template.SegmentRecursively indent by the parameter indent.- Specified by:
indentin classTemplate.Segment- Parameters:
indent- should be space characters that are not\n.first- append indent to the first line (regardless if it has a\nor not).last- append indent on the last\nthat has no text after it.- Returns:
- a newly created segment or the same segment if nothing changed.
-
isStandalone
boolean isStandalone()
Description copied from class:Template.SegmentWhether or not the segment is standalone. The definition of standalone is defined by the mustache spec. String and variable tags are never standalone. For blocks this is based on the closing tag. Oncetrimis called, standalone tags are determined so that proper (re)indentation will work without reparsing the template.- Specified by:
isStandalonein classTemplate.Segment- Returns:
- true if the tag is standalone.
-
execute
public void execute(Template tmpl, Template.Context ctx, java.io.Writer out)
- Specified by:
executein classTemplate.Segment
-
decompile
public void decompile(Mustache.Delims delims, java.lang.StringBuilder into)
- Specified by:
decompilein classTemplate.Segment
-
visit
public void visit(Mustache.Visitor visitor)
- Specified by:
visitin classTemplate.Segment
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
reindent
private static java.lang.String reindent(java.lang.String input, java.lang.String indent, boolean first, boolean last)
-
blankPos
private static int blankPos(java.lang.String text, boolean leading, boolean first)
-
-