Package org.onemind.commons.java.text
Class SimpleTextGenerator
- java.lang.Object
-
- org.onemind.commons.java.text.SimpleTextGenerator
-
- All Implemented Interfaces:
TextGenerator
public class SimpleTextGenerator extends java.lang.Object implements TextGenerator
A simple implementation of generator- Author:
- TiongHiang Lee (thlee@onemindsoft.org)
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
_delimiter
the delimiterprivate java.util.Map
_generators
attr generators *private java.lang.String
_subDelimiter
sub delimiter
-
Constructor Summary
Constructors Constructor Description SimpleTextGenerator(java.lang.String delimiter, java.lang.String subDelimiter)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGenerator(java.lang.String subSpec, TextGenerator gen)
add text generator to the sub specificationjava.lang.StringBuffer
generateText(java.lang.String spec, java.lang.Object obj)
void
generateText(java.lang.String spec, java.lang.Object obj, java.lang.StringBuffer sb)
Generate some text through the spec passed inTextGenerator
getGenerator(java.lang.String subSpec)
Get the generator for subSpec
-
-
-
Method Detail
-
addGenerator
public void addGenerator(java.lang.String subSpec, TextGenerator gen)
add text generator to the sub specification- Parameters:
subSpec
- the sub specgen
- the sub generator
-
generateText
public java.lang.StringBuffer generateText(java.lang.String spec, java.lang.Object obj)
-
generateText
public void generateText(java.lang.String spec, java.lang.Object obj, java.lang.StringBuffer sb)
Generate some text through the spec passed in- Specified by:
generateText
in interfaceTextGenerator
- Parameters:
spec
- the specificationobj
- the target object where the text should be generate towards
-
getGenerator
public TextGenerator getGenerator(java.lang.String subSpec)
Get the generator for subSpec- Parameters:
subSpec
- the sub spec- Returns:
- the generator for the sub spec
-
-