com.google.template.soy.soytree
Class TemplateNode

java.lang.Object
  extended by com.google.template.soy.basetree.AbstractNode
      extended by com.google.template.soy.soytree.AbstractSoyNode
          extended by com.google.template.soy.soytree.AbstractCommandNode
              extended by com.google.template.soy.soytree.AbstractParentCommandNode<SoyNode.StandaloneNode>
                  extended by com.google.template.soy.soytree.AbstractBlockCommandNode
                      extended by com.google.template.soy.soytree.TemplateNode
All Implemented Interfaces:
Node, ParentNode<SoyNode.StandaloneNode>, SoyNode, SoyNode.BlockCommandNode, SoyNode.BlockNode, SoyNode.CommandNode, SoyNode.ParentSoyNode<SoyNode.StandaloneNode>, SoyNode.RenderUnitNode
Direct Known Subclasses:
TemplateBasicNode, TemplateDelegateNode

public abstract class TemplateNode
extends AbstractBlockCommandNode
implements SoyNode.RenderUnitNode

Node representing a template.

Important: Do not use outside of Soy code (treat as superpackage-private).


Nested Class Summary
protected static class TemplateNode.CommandTextInfo
          Private helper class used by constructors.
static class TemplateNode.SoyDocParam
          Info for a parameter declaration in the SoyDoc.
static class TemplateNode.SoyFileHeaderInfo
          Info from the containing Soy file's delpackage and namespace declarations.
 
Nested classes/interfaces inherited from interface com.google.template.soy.soytree.SoyNode
SoyNode.BlockCommandNode, SoyNode.BlockNode, SoyNode.CommandNode, SoyNode.ConditionalBlockNode, SoyNode.ExprHolderNode, SoyNode.Kind, SoyNode.LocalVarBlockNode, SoyNode.LocalVarInlineNode, SoyNode.LocalVarNode, SoyNode.LoopNode, SoyNode.MsgBlockNode, SoyNode.MsgPlaceholderInitialNode, SoyNode.ParentSoyNode<N extends SoyNode>, SoyNode.RenderUnitNode, SoyNode.SplitLevelTopNode<N extends SoyNode>, SoyNode.StandaloneNode, SoyNode.StatementNode, SoyNode.SyntaxVersion
 
Field Summary
static int MAX_PRIORITY
          Priorities range from 0 to MAX_PRIORITY, inclusive.
 
Fields inherited from class com.google.template.soy.basetree.AbstractNode
SPACES
 
Constructor Summary
protected TemplateNode(int id, TemplateNode.SoyFileHeaderInfo soyFileHeaderInfo, String commandName, TemplateNode.CommandTextInfo commandTextInfo, String soyDoc)
          Protected constructor for use by subclasses.
protected TemplateNode(TemplateNode orig)
          Copy constructor.
 
Method Summary
 void clearSoyDocStrings()
          Clears the SoyDoc text, description, and param descriptions.
 AutoescapeMode getAutoescapeMode()
          Returns the mode of autoescaping, if any, done for this template.
 SanitizedContent.ContentKind getContentKind()
          Returns the content kind for strict autoescaping.
 String getDelPackageName()
          Returns the name of the containing delegate package, or null if none.
 com.google.common.collect.ImmutableList<String> getParamSrcsWithIncorrectSyntax()
          Returns the param source strings with incorrect syntax, or null if no SoyDoc.
 SoyFileNode getParent()
          Gets this node's parent.
 String getPartialTemplateName()
          Returns this template's partial name.
 String getSoyDoc()
          Returns the SoyDoc, or null.
 String getSoyDocDesc()
          Returns the description portion of the SoyDoc (before @param tags), or null.
 List<TemplateNode.SoyDocParam> getSoyDocParams()
          Returns the parameters listed in the SoyDoc, or null if no SoyDoc.
 TemplateNode.SoyFileHeaderInfo getSoyFileHeaderInfo()
          Returns info from the containing Soy file's header declarations.
 String getTemplateName()
          Returns this template's name.
abstract  String getTemplateNameForUserMsgs()
          Returns a template name suitable for display in user msgs.
 boolean isPrivate()
          Returns whether this template is private.
 String toSourceString()
          Builds a Soy source string that could be the source for this node.
 
Methods inherited from class com.google.template.soy.soytree.AbstractParentCommandNode
addChild, addChild, addChildren, addChildren, appendSourceStringForChildren, appendTreeStringForChildren, clearChildren, getChild, getChildIndex, getChildren, needsEnvFrameDuringInterp, numChildren, removeChild, removeChild, replaceChild, replaceChild, setNeedsEnvFrameDuringInterp, toTreeString
 
Methods inherited from class com.google.template.soy.soytree.AbstractCommandNode
buildTagStringHelper, buildTagStringHelper, getCommandName, getCommandText, getTagString
 
Methods inherited from class com.google.template.soy.soytree.AbstractSoyNode
clone, getId, getSourceLocation, getSyntaxVersion, maybeSetSyntaxVersion, setId, setSourceLocation, toString
 
Methods inherited from class com.google.template.soy.basetree.AbstractNode
getNearestAncestor, hasAncestor, setParent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.template.soy.soytree.SoyNode.CommandNode
getCommandName, getCommandText, getTagString
 
Methods inherited from interface com.google.template.soy.soytree.SoyNode.ParentSoyNode
needsEnvFrameDuringInterp, setNeedsEnvFrameDuringInterp
 
Methods inherited from interface com.google.template.soy.soytree.SoyNode
clone, getId, getKind, getSourceLocation, getSyntaxVersion, setId, setSourceLocation
 
Methods inherited from interface com.google.template.soy.basetree.ParentNode
addChild, addChild, addChildren, addChildren, appendSourceStringForChildren, appendTreeStringForChildren, clearChildren, getChild, getChildIndex, getChildren, numChildren, removeChild, removeChild, replaceChild, replaceChild
 
Methods inherited from interface com.google.template.soy.basetree.Node
getNearestAncestor, hasAncestor, setParent, toTreeString
 

Field Detail

MAX_PRIORITY

public static final int MAX_PRIORITY
Priorities range from 0 to MAX_PRIORITY, inclusive.

See Also:
Constant Field Values
Constructor Detail

TemplateNode

protected TemplateNode(int id,
                       TemplateNode.SoyFileHeaderInfo soyFileHeaderInfo,
                       String commandName,
                       TemplateNode.CommandTextInfo commandTextInfo,
                       @Nullable
                       String soyDoc)
Protected constructor for use by subclasses.

Parameters:
id - The id for this node.
soyFileHeaderInfo - Info from the containing Soy file's header declarations.
commandName - The command name, either template or deltemplate.
commandTextInfo - All the info derived from the command text.
soyDoc - The full SoyDoc, including the start/end tokens, or null if the template is not

TemplateNode

protected TemplateNode(TemplateNode orig)
Copy constructor.

Parameters:
orig - The node to copy.
Method Detail

getSoyFileHeaderInfo

public TemplateNode.SoyFileHeaderInfo getSoyFileHeaderInfo()
Returns info from the containing Soy file's header declarations.


getDelPackageName

public String getDelPackageName()
Returns the name of the containing delegate package, or null if none.


getTemplateNameForUserMsgs

public abstract String getTemplateNameForUserMsgs()
Returns a template name suitable for display in user msgs.


getTemplateName

public String getTemplateName()
Returns this template's name.


getPartialTemplateName

public String getPartialTemplateName()
Returns this template's partial name. Only applicable for V2 (null for V1).


isPrivate

public boolean isPrivate()
Returns whether this template is private.


getAutoescapeMode

public AutoescapeMode getAutoescapeMode()
Returns the mode of autoescaping, if any, done for this template.


getContentKind

@Nullable
public SanitizedContent.ContentKind getContentKind()
Returns the content kind for strict autoescaping. Nonnull iff autoescapeMode is strict.

Specified by:
getContentKind in interface SoyNode.RenderUnitNode

clearSoyDocStrings

public void clearSoyDocStrings()
Clears the SoyDoc text, description, and param descriptions.


getSoyDoc

public String getSoyDoc()
Returns the SoyDoc, or null.


getSoyDocDesc

public String getSoyDocDesc()
Returns the description portion of the SoyDoc (before @param tags), or null.


getSoyDocParams

public List<TemplateNode.SoyDocParam> getSoyDocParams()
Returns the parameters listed in the SoyDoc, or null if no SoyDoc.


getParamSrcsWithIncorrectSyntax

public com.google.common.collect.ImmutableList<String> getParamSrcsWithIncorrectSyntax()
Returns the param source strings with incorrect syntax, or null if no SoyDoc.


getParent

public SoyFileNode getParent()
Description copied from interface: Node
Gets this node's parent.

Specified by:
getParent in interface Node
Specified by:
getParent in interface SoyNode
Overrides:
getParent in class AbstractSoyNode
Returns:
This node's parent.

toSourceString

public String toSourceString()
Description copied from interface: Node
Builds a Soy source string that could be the source for this node. Note that this is not the actual original source string, but a (sort of) canonical equivalent. Note: Some nodes do not have a direct mapping to Soy source (such as nodes created during some optimization passes). Thus this method may not always be supported.

Specified by:
toSourceString in interface Node
Overrides:
toSourceString in class AbstractParentCommandNode<SoyNode.StandaloneNode>
Returns:
A Soy string that could be the source for this node.