com.google.template.soy
Class SoyFileSet.Builder

java.lang.Object
  extended by com.google.template.soy.SoyFileSet.Builder
Enclosing class:
SoyFileSet

public static final class SoyFileSet.Builder
extends Object

Builder for a SoyFileSet.


Constructor Summary
SoyFileSet.Builder()
          Constructs a builder that starts with a default SoyGeneralOptions object (options can be modified via methods on the builder).
SoyFileSet.Builder(SoyGeneralOptions generalOptions)
          Constructs a builder with a specified SoyGeneralOptions object.
 
Method Summary
 SoyFileSet.Builder add(CharSequence content, String filePath)
          Adds an input Soy file, given the file content provided as a string, as well as the desired file path for messages.
 SoyFileSet.Builder add(File inputFile)
          Adds an input Soy file, given a File.
 SoyFileSet.Builder add(com.google.common.io.InputSupplier<? extends Reader> contentSupplier, String filePath)
          Adds an input Soy file, given an InputSupplier for the file content, as well as the desired file path for messages.
 SoyFileSet.Builder add(URL inputFileUrl)
          Adds an input Soy file, given a resource URL.
 SoyFileSet.Builder add(URL inputFileUrl, String filePath)
          Adds an input Soy file, given a resource URL, as well as the desired file path for messages.
 SoyFileSet.Builder addVolatile(File inputFile)
          Adds an input Soy file that the system will watch for changes, given a File.
 SoyFileSet.Builder addVolatileWithKind(File inputFile, com.google.template.soy.base.SoyFileKind soyFileKind)
          Adds an input Soy file that the system will watch for changes, given a File.
 SoyFileSet.Builder addWithKind(CharSequence content, com.google.template.soy.base.SoyFileKind soyFileKind, String filePath)
          Adds an input Soy file, given the file content provided as a string, as well as the desired file path for messages.
 SoyFileSet.Builder addWithKind(File inputFile, com.google.template.soy.base.SoyFileKind soyFileKind)
          Adds an input Soy file, given a File.
 SoyFileSet.Builder addWithKind(com.google.common.io.InputSupplier<? extends Reader> contentSupplier, com.google.template.soy.base.SoyFileKind soyFileKind, String filePath)
          Adds an input Soy file, given an InputSupplier for the file content, as well as the desired file path for messages.
 SoyFileSet.Builder addWithKind(URL inputFileUrl, com.google.template.soy.base.SoyFileKind soyFileKind)
          Adds an input Soy file, given a resource URL.
 SoyFileSet.Builder addWithKind(URL inputFileUrl, com.google.template.soy.base.SoyFileKind soyFileKind, String filePath)
          Adds an input Soy file, given a resource URL, as well as the desired file path for messages.
 SoyFileSet build()
          Builds the new SoyFileSet.
 SoyFileSet.Builder setAllowExternalCalls(boolean allowExternalCalls)
          Sets whether to allow external calls (calls to undefined templates).
 SoyFileSet.Builder setCompileTimeGlobals(File compileTimeGlobalsFile)
          Sets the file containing compile-time globals.
 SoyFileSet.Builder setCompileTimeGlobals(Map<String,?> compileTimeGlobalsMap)
          Sets the map from compile-time global name to value.
 SoyFileSet.Builder setCompileTimeGlobals(URL compileTimeGlobalsResource)
          Sets the resource file containing compile-time globals.
 SoyFileSet.Builder setCssHandlingScheme(SoyGeneralOptions.CssHandlingScheme cssHandlingScheme)
          Sets the scheme for handling css commands.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoyFileSet.Builder

@Inject
public SoyFileSet.Builder()
Constructs a builder that starts with a default SoyGeneralOptions object (options can be modified via methods on the builder).


SoyFileSet.Builder

public SoyFileSet.Builder(SoyGeneralOptions generalOptions)
Constructs a builder with a specified SoyGeneralOptions object.

Parameters:
generalOptions - The SoyGeneralOptions object to use.
Method Detail

build

public SoyFileSet build()
Builds the new SoyFileSet.

Returns:
The new SoyFileSet.

addWithKind

public SoyFileSet.Builder addWithKind(com.google.common.io.InputSupplier<? extends Reader> contentSupplier,
                                      com.google.template.soy.base.SoyFileKind soyFileKind,
                                      String filePath)
Adds an input Soy file, given an InputSupplier for the file content, as well as the desired file path for messages.

Parameters:
contentSupplier - Supplier of a Reader for the Soy file content.
soyFileKind - The kind of this input Soy file.
filePath - The path to the Soy file (used for messages only).
Returns:
This builder.

add

public SoyFileSet.Builder add(com.google.common.io.InputSupplier<? extends Reader> contentSupplier,
                              String filePath)
Adds an input Soy file, given an InputSupplier for the file content, as well as the desired file path for messages.

Parameters:
contentSupplier - Supplier of a Reader for the Soy file content.
filePath - The path to the Soy file (used for messages only).
Returns:
This builder.

addWithKind

public SoyFileSet.Builder addWithKind(File inputFile,
                                      com.google.template.soy.base.SoyFileKind soyFileKind)
Adds an input Soy file, given a File.

Parameters:
inputFile - The Soy file.
soyFileKind - The kind of this input Soy file.
Returns:
This builder.

add

public SoyFileSet.Builder add(File inputFile)
Adds an input Soy file, given a File.

Parameters:
inputFile - The Soy file.
Returns:
This builder.

addVolatileWithKind

public SoyFileSet.Builder addVolatileWithKind(File inputFile,
                                              com.google.template.soy.base.SoyFileKind soyFileKind)
Adds an input Soy file that the system will watch for changes, given a File.

Parameters:
inputFile - The Soy file.
soyFileKind - The kind of this input Soy file.
Returns:
This builder.

addVolatile

public SoyFileSet.Builder addVolatile(File inputFile)
Adds an input Soy file that the system will watch for changes, given a File.

Parameters:
inputFile - The Soy file.
Returns:
This builder.

addWithKind

public SoyFileSet.Builder addWithKind(URL inputFileUrl,
                                      com.google.template.soy.base.SoyFileKind soyFileKind,
                                      String filePath)
Adds an input Soy file, given a resource URL, as well as the desired file path for messages.

Parameters:
inputFileUrl - The Soy file.
soyFileKind - The kind of this input Soy file.
filePath - The path to the Soy file (used for messages only).
Returns:
This builder.

add

public SoyFileSet.Builder add(URL inputFileUrl,
                              String filePath)
Adds an input Soy file, given a resource URL, as well as the desired file path for messages.

Parameters:
inputFileUrl - The Soy file.
filePath - The path to the Soy file (used for messages only).
Returns:
This builder.

addWithKind

public SoyFileSet.Builder addWithKind(URL inputFileUrl,
                                      com.google.template.soy.base.SoyFileKind soyFileKind)
Adds an input Soy file, given a resource URL.

Important: This function assumes that the desired file path is returned by inputFileUrl.toString(). If this is not the case, please use addWithKind(URL, SoyFileKind, String) instead.

Parameters:
inputFileUrl - The Soy file.
soyFileKind - The kind of this input Soy file.
Returns:
This builder.
See Also:
addWithKind(URL, SoyFileKind, String)

add

public SoyFileSet.Builder add(URL inputFileUrl)
Adds an input Soy file, given a resource URL.

Important: This function assumes that the desired file path is returned by inputFileUrl.toString(). If this is not the case, please use add(URL, String) instead.

Parameters:
inputFileUrl - The Soy file.
Returns:
This builder.
See Also:
add(URL, String)

addWithKind

public SoyFileSet.Builder addWithKind(CharSequence content,
                                      com.google.template.soy.base.SoyFileKind soyFileKind,
                                      String filePath)
Adds an input Soy file, given the file content provided as a string, as well as the desired file path for messages.

Parameters:
content - The Soy file content.
soyFileKind - The kind of this input Soy file.
filePath - The path to the Soy file (used for messages only).
Returns:
This builder.

add

public SoyFileSet.Builder add(CharSequence content,
                              String filePath)
Adds an input Soy file, given the file content provided as a string, as well as the desired file path for messages.

Parameters:
content - The Soy file content.
filePath - The path to the Soy file (used for messages only).
Returns:
This builder.

setAllowExternalCalls

public SoyFileSet.Builder setAllowExternalCalls(boolean allowExternalCalls)
Sets whether to allow external calls (calls to undefined templates).

Parameters:
allowExternalCalls - Whether to allow external calls (calls to undefined templates).
Returns:
This builder.

setCssHandlingScheme

public SoyFileSet.Builder setCssHandlingScheme(SoyGeneralOptions.CssHandlingScheme cssHandlingScheme)
Sets the scheme for handling css commands.

Parameters:
cssHandlingScheme - The scheme for handling css commands.
Returns:
This builder.

setCompileTimeGlobals

public SoyFileSet.Builder setCompileTimeGlobals(Map<String,?> compileTimeGlobalsMap)
Sets the map from compile-time global name to value.

The values can be any of the Soy primitive types: null, boolean, integer, float (Java double), or string.

Parameters:
compileTimeGlobalsMap - Map from compile-time global name to value. The values can be any of the Soy primitive types: null, boolean, integer, float (Java double), or string.
Returns:
This builder.
Throws:
SoySyntaxException - If one of the values is not a valid Soy primitive type.

setCompileTimeGlobals

public SoyFileSet.Builder setCompileTimeGlobals(File compileTimeGlobalsFile)
                                         throws IOException
Sets the file containing compile-time globals.

Each line of the file should have the format

     <global_name> = <primitive_data>
 
where primitive_data is a valid Soy expression literal for a primitive type (null, boolean, integer, float, or string). Empty lines and lines beginning with "//" are ignored. The file should be encoded in UTF-8.

If you need to generate a file in this format from Java, consider using the utility SoyUtils.generateCompileTimeGlobalsFile().

Parameters:
compileTimeGlobalsFile - The file containing compile-time globals.
Returns:
This builder.
Throws:
IOException - If there is an error reading the compile-time globals file.

setCompileTimeGlobals

public SoyFileSet.Builder setCompileTimeGlobals(URL compileTimeGlobalsResource)
                                         throws IOException
Sets the resource file containing compile-time globals.

Each line of the file should have the format

     <global_name> = <primitive_data>
 
where primitive_data is a valid Soy expression literal for a primitive type (null, boolean, integer, float, or string). Empty lines and lines beginning with "//" are ignored. The file should be encoded in UTF-8.

If you need to generate a file in this format from Java, consider using the utility SoyUtils.generateCompileTimeGlobalsFile().

Parameters:
compileTimeGlobalsResource - The resource containing compile-time globals.
Returns:
This builder.
Throws:
IOException - If there is an error reading the compile-time globals file.