|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unitesk.atp.tree.generation.TextGeneratorClient
public abstract class TextGeneratorClient
The base client implementing interface of text generation.
Delegates all text generation processing
to underlying TextGeneratorServer
that can be shared between several clients.
Abstract visit(Node)
method should be overridden
by inheritors to implement node processing.
Field Summary | |
---|---|
protected TextGeneratorServer |
server
|
Fields inherited from interface com.unitesk.atp.tree.generation.TextGenerator |
---|
endl |
Fields inherited from interface com.unitesk.atp.text.generation.Generator |
---|
DEFAULT_NAME |
Constructor Summary | |
---|---|
TextGeneratorClient()
|
Method Summary | |
---|---|
void |
decIndent()
Decreases indent level at one indent step. |
Function |
getFunction(String name)
Returns function by name. |
int |
getIndent()
Returns the current indent level. |
Node |
getNode()
Returns current node. |
Object |
getVariable(String name)
Returns variable by name. |
void |
incIndent()
Increases indent level at one indent step. |
void |
list(String index,
int start,
int end,
String str,
String separator)
Prints list of strings. |
void |
nl()
Starts a new line of text. |
void |
popIndent()
Restores previous indent level. |
void |
popNode()
Restore previous node. |
void |
process(Object arg)
Processes the specified object. |
void |
pushIndent(int indent)
Makes indent current indent level. |
void |
pushNode(Node node)
Sets default node for all operations with attributes. |
Function |
setFunction(String name,
Function func)
Registers function for the usage in patterns. |
void |
setGenerator(Generator generator)
Associates or deassociates this function with text generator. |
Object |
setVariable(String name,
Object var)
Registers variable for the usage in patterns. |
void |
txt(String t)
Processes text pattern and generates text. |
void |
txtAsIs(String t)
Print string as is, don't treat it as pattern. |
void |
txtif(boolean condition,
String t)
if condition is true calls
txt(t) |
void |
txtif(boolean condition,
String t,
String f)
if condition is true calls
txt(t) else txt(f) |
void |
txtif(Object object,
String t)
if object is not null calls
txt(t) |
void |
txtif(Object object,
String t,
String f)
if object is not null calls
txt(t) else txt(f) |
abstract void |
visit(Node node)
Process node. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected TextGeneratorServer server
Constructor Detail |
---|
public TextGeneratorClient()
Method Detail |
---|
public void setGenerator(Generator generator)
setGenerator
in interface Function
generator
- The specified text generator. If it is not null
- associate function with this text generator, otherwise
deassociate.public abstract void visit(Node node)
node
- public void process(Object arg)
process
in interface Function
arg
- The specified object.public final 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 final Function getFunction(String name)
getFunction
in interface Generator
name
- The name of function.
null
.public final 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 final Object getVariable(String name)
getVariable
in interface Generator
name
- The name of variable.
null
.public final void txt(String t)
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
t
- The specified pattern.Generator.getFunction(String)
,
Generator.getVariable(String)
public final void txtAsIs(String t)
txtAsIs
in interface Generator
t
- The string to pass as is.public final void pushNode(Node node)
node
for all operations with attributes.
pushNode
in interface TextGenerator
node
- The new default node.public final Node getNode()
getNode
in interface TextGenerator
public final void popNode()
popNode
in interface TextGenerator
public final void pushIndent(int indent)
indent
current indent level.
The previous indent level can be restored by TextGenerator.popIndent()
pushIndent
in interface TextGenerator
indent
- the new indent levelpublic final int getIndent()
getIndent
in interface TextGenerator
public final void incIndent()
TextGenerator.popIndent()
incIndent
in interface TextGenerator
public final void decIndent()
TextGenerator.popIndent()
decIndent
in interface TextGenerator
public final void popIndent()
popIndent
in interface TextGenerator
TextGenerator.pushIndent(int)
,
TextGenerator.incIndent()
,
TextGenerator.decIndent()
public final void list(String index, int start, int end, String str, String separator)
list
in interface TextGenerator
index
- The variable name to store current index of list element.start
- The starting value of an indexend
- if start < end thenstr
- The string to print for each list element using
txt( str )
separator
- The separator to print between strings
for list elements using
txt( str )
public final void nl()
nl
in interface TextGenerator
public final void txtif(boolean condition, String t)
condition
is true
calls
txt(t)
NullPointerException
- if t
is null
public final void txtif(boolean condition, String t, String f)
condition
is true
calls
txt(t)
else txt(f)
NullPointerException
- if t
or f
is null
public final void txtif(Object object, String t)
object
is not null
calls
txt(t)
NullPointerException
- if t
is null
public final void txtif(Object object, String t, String f)
object
is not null
calls
txt(t)
else txt(f)
NullPointerException
- if t
is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |