@ParametersAreNonnullByDefault public final class GeneratePySanitizeEscapingDirectiveCode extends AbstractGenerateSoyEscapingDirectiveCode
This is an ant task and can be invoked as:
In the above, the first <taskdef> is an Ant builtin which links the element named
<gen.escape.directives> to this class.
That element contains zero or more <input>s which are Python source files that may use
the helper functions generated by this task.
There must be exactly one <output> element which specifies where the output should be
written. That output contains the input sources and the generated helper functions.
AbstractGenerateSoyEscapingDirectiveCode.FileRef, AbstractGenerateSoyEscapingDirectiveCode.FunctionNamePredicateavailableIdentifiers| Constructor and Description |
|---|
GeneratePySanitizeEscapingDirectiveCode() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
convertFromJavaRegex(Pattern javaPattern)
Converts the given pattern from a Java Pattern syntax to the language specific syntax.
|
protected String |
escapeOutputString(String input)
Escape a generated string being outputted based on the current language being generated.
|
protected void |
generateCharacterMapSignature(StringBuilder outputCode,
String mapName)
Generate the signature to a map object to hold character mapping.
|
protected void |
generateCommonConstants(StringBuilder outputCode)
Generate common constants used elsewhere by the utility.
|
protected void |
generateFilter(StringBuilder outputCode,
String name,
String filter)
Generate the constant to store the given filter regular expression.
|
protected void |
generateHelperFunction(StringBuilder outputCode,
DirectiveDigest digest)
Generate the helper function to execute the escaping, filtering, and replacing.
|
protected 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 void |
generateReplacerFunction(StringBuilder outputCode,
String mapName)
Generate the function to handle replacement of a given character.
|
protected EscapingConventions.EscapingLanguage |
getLanguage()
Get the language being generated here.
|
protected String |
getLineCommentSyntax()
Return the syntax for starting a one line comment.
|
protected String |
getLineEndSyntax()
Return the syntax for ending a line.
|
protected String |
getRegexEnd()
Return the syntax for ending a regex string.
|
protected String |
getRegexStart()
Return the syntax for starting a regex string.
|
static void |
main(String[] args)
A non Ant interface for this class.
|
protected void |
useExistingLibraryFunction(StringBuilder outputCode,
String identifier,
String existingFunction)
Use an existing library function to execute the escaping, filtering, and replacing.
|
addConfiguredLibdefined, configure, createInput, createOutput, execute, getAvailableIdentifiers, writeStringLiteralbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypepublic GeneratePySanitizeEscapingDirectiveCode()
protected EscapingConventions.EscapingLanguage getLanguage()
AbstractGenerateSoyEscapingDirectiveCodegetLanguage in class AbstractGenerateSoyEscapingDirectiveCodeprotected String getLineCommentSyntax()
AbstractGenerateSoyEscapingDirectiveCodegetLineCommentSyntax in class AbstractGenerateSoyEscapingDirectiveCodeprotected String getLineEndSyntax()
AbstractGenerateSoyEscapingDirectiveCodegetLineEndSyntax in class AbstractGenerateSoyEscapingDirectiveCodeprotected String getRegexStart()
AbstractGenerateSoyEscapingDirectiveCodegetRegexStart in class AbstractGenerateSoyEscapingDirectiveCodeprotected String getRegexEnd()
AbstractGenerateSoyEscapingDirectiveCodegetRegexEnd in class AbstractGenerateSoyEscapingDirectiveCodeprotected String escapeOutputString(String input)
AbstractGenerateSoyEscapingDirectiveCodeescapeOutputString in class AbstractGenerateSoyEscapingDirectiveCodeprotected String convertFromJavaRegex(Pattern javaPattern)
AbstractGenerateSoyEscapingDirectiveCodeconvertFromJavaRegex in class AbstractGenerateSoyEscapingDirectiveCodejavaPattern - The Java regular expression to convert.protected void generatePrefix(StringBuilder outputCode)
AbstractGenerateSoyEscapingDirectiveCodegeneratePrefix in class AbstractGenerateSoyEscapingDirectiveCodeoutputCode - The StringBuilder where generated code should be appended.protected void generateCharacterMapSignature(StringBuilder outputCode, String mapName)
AbstractGenerateSoyEscapingDirectiveCodeFor 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>_
generateCharacterMapSignature in class AbstractGenerateSoyEscapingDirectiveCodeoutputCode - The StringBuilder where generated code should be appended.mapName - The name of this map.protected void generateMatcher(StringBuilder outputCode, String name, String matcher)
AbstractGenerateSoyEscapingDirectiveCodegenerateMatcher in class AbstractGenerateSoyEscapingDirectiveCodeoutputCode - The StringBuilder where generated code should be appended.name - The name of the current matcher.matcher - The regular expression string.protected void generateFilter(StringBuilder outputCode, String name, String filter)
AbstractGenerateSoyEscapingDirectiveCodegenerateFilter in class AbstractGenerateSoyEscapingDirectiveCodeoutputCode - The StringBuilder where generated code should be appended.name - The name of the current filter.filter - The regular expression string.protected void generateReplacerFunction(StringBuilder outputCode, String mapName)
AbstractGenerateSoyEscapingDirectiveCodegenerateReplacerFunction in class AbstractGenerateSoyEscapingDirectiveCodeoutputCode - The StringBuilder where generated code should be appended.mapName - The name of the map to use for replacement.protected void useExistingLibraryFunction(StringBuilder outputCode, String identifier, String existingFunction)
AbstractGenerateSoyEscapingDirectiveCodeuseExistingLibraryFunction in class AbstractGenerateSoyEscapingDirectiveCodeoutputCode - The StringBuilder where generated code should be appended.identifier - The identifier of the escape directive.existingFunction - The existing function to reuse.protected void generateHelperFunction(StringBuilder outputCode, DirectiveDigest digest)
AbstractGenerateSoyEscapingDirectiveCodegenerateHelperFunction in class AbstractGenerateSoyEscapingDirectiveCodeoutputCode - The StringBuilder where generated code should be appended.digest - The DirectiveDigest which contains the appropriate patterns and replacer keys.protected void generateCommonConstants(StringBuilder outputCode)
AbstractGenerateSoyEscapingDirectiveCodegenerateCommonConstants in class AbstractGenerateSoyEscapingDirectiveCodeoutputCode - The StringBuilder where generated code should be appended.public static void main(String[] args) throws IOException
IOException