public class FunctionRegistry extends Object implements FunctionExecutor
FunctionExecutor| Modifier and Type | Field and Description |
|---|---|
protected Map<String,TextFilter> |
escapers |
protected Map<String,Function> |
functions |
| Constructor and Description |
|---|
FunctionRegistry() |
| Modifier and Type | Method and Description |
|---|---|
void |
escape(String name,
String input,
Appendable output)
Escapes some text.
|
Value |
executeFunction(String name,
Value... args)
Lookup a function by name, execute it and return the results.
|
boolean |
isEscapingFunction(String name)
Look up a function by name, and report whether it is an escaping function.
|
void |
registerEscapeMode(String name,
TextFilter escaper)
Registers an escaper, that is called when executing a <?cs escape ?> command.
|
void |
registerFunction(String name,
Function function)
Register a Function with a given name.
|
void |
registerFunction(String name,
TextFilter textFilter)
Register a TextFilter as a Function that takes a single String argument and returns the
filtered value.
|
void |
registerFunction(String name,
TextFilter textFilter,
boolean isEscaper) |
protected void |
setupDefaultFunctions()
Subclasses can override this to register their own functions.
|
protected Map<String,TextFilter> escapers
public Value executeFunction(String name, Value... args)
FunctionExecutorexecuteFunction in interface FunctionExecutorpublic void escape(String name, String input, Appendable output) throws IOException
FunctionExecutorescape in interface FunctionExecutorname - Strategy for escaping text. If null or "none", text will be left as is.input - Text to be escaped.output - Where to write the result to.IOExceptionpublic boolean isEscapingFunction(String name)
FunctionExecutorisEscapingFunction in interface FunctionExecutorprotected void setupDefaultFunctions()
public void registerFunction(String name, Function function)
public void registerFunction(String name, TextFilter textFilter)
public void registerFunction(String name, TextFilter textFilter, boolean isEscaper)
public void registerEscapeMode(String name, TextFilter escaper)
name - The name with which <?cs escape ?> will invoke this escaper.escaper - A TextFilter that implements the escaping functionality.Copyright © 2010–2015 Google. All rights reserved.