@ParametersAreNonnullByDefault public abstract class AbstractGenerateSoyEscapingDirectiveCode extends org.apache.tools.ant.Task
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractGenerateSoyEscapingDirectiveCode.FileRef
A file reference like
<input path="foo.txt"/>. |
static class |
AbstractGenerateSoyEscapingDirectiveCode.FunctionNamePredicate
A wrapper around a library function name predicate like
<libdefined name="goog.*"/>. |
| Modifier and Type | Field and Description |
|---|---|
protected com.google.common.base.Predicate<String> |
availableIdentifiers
Matches functions available in the environment in which output will be run including things
like
EscapingConventions.CrossLanguageStringXform.getLangFunctionNames(com.google.template.soy.shared.internal.EscapingConventions.EscapingLanguage). |
| Constructor and Description |
|---|
AbstractGenerateSoyEscapingDirectiveCode() |
| Modifier and Type | Method and Description |
|---|---|
void |
addConfiguredLibdefined(AbstractGenerateSoyEscapingDirectiveCode.FunctionNamePredicate p)
Called reflectively when Ant sees
<libdefined>. |
protected void |
configure(String[] args)
Setup method to read arguments and setup initial configuration.
|
protected abstract String |
convertFromJavaRegex(Pattern javaPattern)
Converts the given pattern from a Java Pattern syntax to the language specific syntax.
|
AbstractGenerateSoyEscapingDirectiveCode.FileRef |
createInput()
Called reflectively when Ant sees
<input> to specify a file that uses the generated
helper functions. |
AbstractGenerateSoyEscapingDirectiveCode.FileRef |
createOutput()
Called reflectively when Ant sees
<output> to specify the file that should receive the
output. |
protected abstract String |
escapeOutputString(String input)
Escape a generated string being outputted based on the current language being generated.
|
void |
execute()
Called to actually build the output by Ant.
|
protected abstract void |
generateCharacterMapSignature(StringBuilder outputCode,
String mapName)
Generate the signature to a map object to hold character mapping.
|
protected abstract void |
generateCommonConstants(StringBuilder outputCode)
Generate common constants used elsewhere by the utility.
|
protected abstract void |
generateFilter(StringBuilder outputCode,
String name,
String filter)
Generate the constant to store the given filter regular expression.
|
protected abstract void |
generateHelperFunction(StringBuilder outputCode,
DirectiveDigest digest)
Generate the helper function to execute the escaping, filtering, and replacing.
|
protected abstract void |
generateMatcher(StringBuilder outputCode,
String name,
String matcher)
Generate the constant to store the given matcher regular expression.
|
protected void |
generatePrefix(StringBuilder outputCode)
Generate any prefix needed to precede the escapers.
|
protected abstract void |
generateReplacerFunction(StringBuilder outputCode,
String mapName)
Generate the function to handle replacement of a given character.
|
com.google.common.base.Predicate<String> |
getAvailableIdentifiers()
A matcher for functions available in the environment in which output will be run including
things like
EscapingConventions.CrossLanguageStringXform.getLangFunctionNames(com.google.template.soy.shared.internal.EscapingConventions.EscapingLanguage). |
protected abstract EscapingConventions.EscapingLanguage |
getLanguage()
Get the language being generated here.
|
protected abstract String |
getLineCommentSyntax()
Return the syntax for starting a one line comment.
|
protected abstract String |
getLineEndSyntax()
Return the syntax for ending a line.
|
protected abstract String |
getRegexEnd()
Return the syntax for ending a regex string.
|
protected abstract String |
getRegexStart()
Return the syntax for starting a regex string.
|
protected abstract void |
useExistingLibraryFunction(StringBuilder outputCode,
String identifier,
String existingFunction)
Use an existing library function to execute the escaping, filtering, and replacing.
|
protected void |
writeStringLiteral(String value,
StringBuilder out)
Appends a string literal with the given value onto the given buffer.
|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeprotected com.google.common.base.Predicate<String> availableIdentifiers
EscapingConventions.CrossLanguageStringXform.getLangFunctionNames(com.google.template.soy.shared.internal.EscapingConventions.EscapingLanguage).public AbstractGenerateSoyEscapingDirectiveCode()
public com.google.common.base.Predicate<String> getAvailableIdentifiers()
EscapingConventions.CrossLanguageStringXform.getLangFunctionNames(com.google.template.soy.shared.internal.EscapingConventions.EscapingLanguage).public AbstractGenerateSoyEscapingDirectiveCode.FileRef createInput()
<input> to specify a file that uses the generated
helper functions.public AbstractGenerateSoyEscapingDirectiveCode.FileRef createOutput()
<output> to specify the file that should receive the
output.public void addConfiguredLibdefined(AbstractGenerateSoyEscapingDirectiveCode.FunctionNamePredicate p)
<libdefined>.protected void configure(String[] args) throws IOException
args - Main method input arguments.IOExceptionpublic void execute()
execute in class org.apache.tools.ant.Taskprotected void writeStringLiteral(String value, StringBuilder out)
protected abstract EscapingConventions.EscapingLanguage getLanguage()
protected abstract String getLineCommentSyntax()
protected abstract String getLineEndSyntax()
protected abstract String getRegexStart()
protected abstract String getRegexEnd()
protected abstract String escapeOutputString(String input)
protected abstract String convertFromJavaRegex(Pattern javaPattern)
javaPattern - The Java regular expression to convert.protected void generatePrefix(StringBuilder outputCode)
outputCode - The StringBuilder where generated code should be appended.protected abstract void generateCharacterMapSignature(StringBuilder outputCode, String mapName)
For example. In Javascript the following should be returned:
/**
* Maps characters to the escaped versions for the named escape directives.\n")
* @type {Object}\n")
* @private\n")
*\/
soy.esc.$$ESCAPE_MAP_FOR_<NAME>_
outputCode - The StringBuilder where generated code should be appended.mapName - The name of this map.protected abstract void generateMatcher(StringBuilder outputCode, String name, String matcher)
outputCode - The StringBuilder where generated code should be appended.name - The name of the current matcher.matcher - The regular expression string.protected abstract void generateFilter(StringBuilder outputCode, String name, String filter)
outputCode - The StringBuilder where generated code should be appended.name - The name of the current filter.filter - The regular expression string.protected abstract void generateReplacerFunction(StringBuilder outputCode, String mapName)
outputCode - The StringBuilder where generated code should be appended.mapName - The name of the map to use for replacement.protected abstract void useExistingLibraryFunction(StringBuilder outputCode, String identifier, String existingFunction)
outputCode - The StringBuilder where generated code should be appended.identifier - The identifier of the escape directive.existingFunction - The existing function to reuse.protected abstract void generateHelperFunction(StringBuilder outputCode, DirectiveDigest digest)
outputCode - The StringBuilder where generated code should be appended.digest - The DirectiveDigest which contains the appropriate patterns and replacer keys.protected abstract void generateCommonConstants(StringBuilder outputCode)
outputCode - The StringBuilder where generated code should be appended.