com.unitesk.atp.text.generation
Interface Generator

All Known Subinterfaces:
TextGenerator
All Known Implementing Classes:
BasicGenerator, TextGeneratorClient, TextGeneratorServer, TextGeneratorVisitor

public interface Generator

The text generator that process text patterns and generates text. See txt(String) for the description of patterns.

Version:
$Id: Generator.java,v 1.2 2004/10/11 15:00:43 all-x Exp $
Author:
Alexey Demakov

Field Summary
static String DEFAULT_NAME
           
 
Method Summary
 Function getFunction(String name)
          Returns function by name.
 Object getVariable(String name)
          Returns variable by name.
 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.
 

Field Detail

DEFAULT_NAME

static final String DEFAULT_NAME
See Also:
Constant Field Values
Method Detail

setFunction

Function setFunction(String name,
                     Function func)
Registers function for the usage in patterns.

Parameters:
name - The name of function. Must be valid identifier or empty string.
func - The implementation of function.
Returns:
If function with this name was registered already - return it. Otherwise return null.

getFunction

Function getFunction(String name)
Returns function by name.

Parameters:
name - The name of function.
Returns:
If function with this name is registered - return it. Otherwise return null.

setVariable

Object setVariable(String name,
                   Object var)
Registers variable for the usage in patterns.

Parameters:
name - The name of variable. Must be valid identifier or empty string.
var - The value of variable.
Returns:
If variable with this name was registered already - return it. Otherwise return null.

getVariable

Object getVariable(String name)
Returns variable by name.

Parameters:
name - The name of variable.
Returns:
If variable with this name is registered - return it. Otherwise return null.

txt

void txt(String str)
Processes text pattern and generates text. The pattern has parameters of the following form:

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:

Parameters:
str - The specified pattern.
Throws:
UndefinedFunctionException - If function name is undefined.
com.unitesk.atp.beanutils.PropertyException - When problem with attribute path occurs.
See Also:
getFunction(String), getVariable(String)

txtAsIs

void txtAsIs(String str)
Print string as is, don't treat it as pattern. This method is used for printing values of parameters.

Parameters:
str - The string to pass as is.


Copyright © 2001-2006 ISP RAS, RedVerst Group. All Rights Reserved.