com.google.template.soy.soytree
Class SoyFileNode

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.AbstractParentSoyNode<TemplateNode>
              extended by com.google.template.soy.soytree.SoyFileNode
All Implemented Interfaces:
Node, ParentNode<TemplateNode>, SoyNode, SoyNode.ParentSoyNode<TemplateNode>, SoyNode.SplitLevelTopNode<TemplateNode>

public class SoyFileNode
extends AbstractParentSoyNode<TemplateNode>
implements SoyNode.SplitLevelTopNode<TemplateNode>

Node representing a Soy file.

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


Nested Class Summary
 
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
 
Fields inherited from class com.google.template.soy.basetree.AbstractNode
SPACES
 
Constructor Summary
  SoyFileNode(int id, SoyFileKind soyFileKind, String delpackageCmdText, String namespaceCmdText, List<String> aliasCmdTexts)
           
protected SoyFileNode(SoyFileNode orig)
          Copy constructor.
 
Method Summary
 SoyFileNode clone()
          Clones this node.
 com.google.common.collect.ImmutableMap<String,String> getAliasToNamespaceMap()
          Returns the map from aliases to namespaces for this file.
 AutoescapeMode getDefaultAutoescapeMode()
          Returns the default autoescaping mode for contained templates.
 String getDelPackageName()
          Returns the name of the containing delegate package, or null if none.
 String getFileName()
          Returns this Soy file's name (null if not supplied).
 String getFilePath()
          Returns the path to the source Soy file ("unknown" if not supplied).
 SoyNode.Kind getKind()
          Returns this node's kind (corresponding to this node's specific type).
 String getNamespace()
          Returns this Soy file's namespace, or null if syntax version V1.
 SoyFileSetNode getParent()
          Gets this node's parent.
 SoyFileKind getSoyFileKind()
          Returns the kind of this Soy file.
 void setFilePath(String filePath)
           
 void setSourceLocation(SourceLocation srcLoc)
          Sets the source location (file path and line number) for this node.
 String toSourceString()
          Builds a Soy source string that could be the source for this node.
 
Methods inherited from class com.google.template.soy.soytree.AbstractParentSoyNode
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.AbstractSoyNode
getId, getSourceLocation, getSyntaxVersion, maybeSetSyntaxVersion, setId, 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.ParentSoyNode
needsEnvFrameDuringInterp, setNeedsEnvFrameDuringInterp
 
Methods inherited from interface com.google.template.soy.soytree.SoyNode
getId, getSourceLocation, getSyntaxVersion, setId
 
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
 

Constructor Detail

SoyFileNode

public SoyFileNode(int id,
                   SoyFileKind soyFileKind,
                   @Nullable
                   String delpackageCmdText,
                   @Nullable
                   String namespaceCmdText,
                   @Nullable
                   List<String> aliasCmdTexts)
            throws SoySyntaxException
Parameters:
id - The id for this node.
soyFileKind - The kind of this Soy file.
delpackageCmdText - This Soy file's delegate package, or null if none.
namespaceCmdText - This Soy file's namespace and attributes. Nullable for backwards compatibility only.
aliasCmdTexts - The command texts of the 'alias' declarations. Allowed to be null.
Throws:
SoySyntaxException - If a syntax error is found.

SoyFileNode

protected SoyFileNode(SoyFileNode orig)
Copy constructor.

Parameters:
orig - The node to copy.
Method Detail

getKind

public SoyNode.Kind getKind()
Description copied from interface: SoyNode
Returns this node's kind (corresponding to this node's specific type).

Specified by:
getKind in interface SoyNode

getSoyFileKind

public SoyFileKind getSoyFileKind()
Returns the kind of this Soy file.


getDelPackageName

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


getNamespace

@Nullable
public String getNamespace()
Returns this Soy file's namespace, or null if syntax version V1.


getDefaultAutoescapeMode

public AutoescapeMode getDefaultAutoescapeMode()
Returns the default autoescaping mode for contained templates.


getAliasToNamespaceMap

public com.google.common.collect.ImmutableMap<String,String> getAliasToNamespaceMap()
Returns the map from aliases to namespaces for this file.


setSourceLocation

public void setSourceLocation(SourceLocation srcLoc)
Description copied from interface: SoyNode
Sets the source location (file path and line number) for this node.

Specified by:
setSourceLocation in interface SoyNode
Overrides:
setSourceLocation in class AbstractSoyNode
Parameters:
srcLoc - The source location for this node.

setFilePath

public void setFilePath(String filePath)
Parameters:
filePath - The path to the source Soy file.

getFilePath

public String getFilePath()
Returns the path to the source Soy file ("unknown" if not supplied).


getFileName

@Nullable
public String getFileName()
Returns this Soy file's name (null if not supplied).


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
Returns:
A Soy string that could be the source for this node.

getParent

public SoyFileSetNode 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.

clone

public SoyFileNode clone()
Description copied from interface: Node
Clones this node. The clone's parent pointer is set to null.

Specified by:
clone in interface Node
Specified by:
clone in interface SoyNode
Specified by:
clone in class AbstractSoyNode
Returns:
A clone of this code.