|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unitesk.atp.text.generation.BasicGenerator
public class BasicGenerator
The basic implementation of Generator
interface.
Processed text is passed to client text receiver
.
Field Summary | |
---|---|
protected TextReceiver |
client
|
protected Map |
name_to_func
|
protected Map |
name_to_var
|
protected PatternFilter |
pattern_filter
|
protected Attributed |
variable_map
|
Fields inherited from interface com.unitesk.atp.text.generation.Generator |
---|
DEFAULT_NAME |
Constructor Summary | |
---|---|
BasicGenerator(TextReceiver client)
Constructs generator with the specified client. |
|
BasicGenerator(TextReceiver client,
Function default_func,
String par_start,
String par_end)
Constructs generator with the specified parameters. |
Method Summary | |
---|---|
Function |
getFunction(String name)
Returns function by name. |
Object |
getVariable(String name)
Returns variable by name. |
protected void |
mustBeID(String id)
|
void |
param(String param)
Receives pattern parameter (without delimeters) |
Function |
setFunction(String name,
Function func)
Registers function for the usage in patterns. |
Object |
setVariable(String name,
Object var)
Registers variable for the usage in patterns. |
void |
txt(String str)
Processes text pattern and generates text. |
void |
txtAsIs(String str)
Print string as is, don't treat it as pattern. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map name_to_func
protected Map name_to_var
protected Attributed variable_map
protected PatternFilter pattern_filter
protected TextReceiver client
Constructor Detail |
---|
public BasicGenerator(TextReceiver client)
client
- The client text receiver.public BasicGenerator(TextReceiver client, Function default_func, String par_start, String par_end)
client
- The client text receiver.default_func
- The default functionpar_start
- The parameter start delimemter
NullPointerException
- If client == nullMethod Detail |
---|
public Function setFunction(String name, Function func)
setFunction
in interface Generator
name
- The name of function.
Must be valid identifier
or empty string.func
- The implementation of function.
null
.public Function getFunction(String name)
getFunction
in interface Generator
name
- The name of function.
null
.public Object setVariable(String name, Object var)
setVariable
in interface Generator
name
- The name of variable.
Must be valid identifier
or empty string.var
- The value of variable.
null
.public Object getVariable(String name)
getVariable
in interface Generator
name
- The name of variable.
null
.public void txt(String str)
pattern ::= "${" ( <func:ID> ":" )? ( "." )? path "}" ;
path ::= attribute ( "." attribute )* ;
attribute ::= <attr_name:ID> ( "[" index "]" )? ;
index ::= <index_var:ID> | number ;
number ::= ( "-" )? ( <digit> )+ ;
The parameter of pattern is processed in the following way:
var
is specified use it as an attributed object
otherwise use the current variable.path
func
is specified use it
otherwise use the default function.
Run the function at the attribute value.
txt
in interface Generator
str
- The specified pattern.Generator.getFunction(String)
,
Generator.getVariable(String)
public void txtAsIs(String str)
txtAsIs
in interface Generator
str
- The string to pass as is.public void param(String param)
param
in interface PatternFilter.ParameterProcessor
param
- the pattern parameters.protected void mustBeID(String id)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |