|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.clearsilver.jsilver.functions.FunctionRegistry
public class FunctionRegistry
Simple implementation of FunctionFinder that you can register your own functions with.
FunctionExecutor
Field Summary | |
---|---|
protected Map<String,TextFilter> |
escapers
|
protected Map<String,Function> |
functions
|
Constructor Summary | |
---|---|
FunctionRegistry()
|
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map<String,Function> functions
protected Map<String,TextFilter> escapers
Constructor Detail |
---|
public FunctionRegistry()
Method Detail |
---|
public Value executeFunction(String name, Value... args)
FunctionExecutor
executeFunction
in interface FunctionExecutor
public void escape(String name, String input, Appendable output) throws IOException
FunctionExecutor
escape
in interface FunctionExecutor
name
- 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.
IOException
public boolean isEscapingFunction(String name)
FunctionExecutor
isEscapingFunction
in interface FunctionExecutor
protected 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |