|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.transformer.base.StringTransformerChain
public class StringTransformerChain
This class represents a Transformer for Strings that is build
out of a list of rules. It performs its
transformation by passing the given value to the
first rule and its result to the next rule and so on. If a rule matched, it
can stop further proceeding via the
stop-on-match flag and cause
its result to be returned immediately. Otherwise the result of the last rule
in the chain is returned (like a left associative operator).
| Nested Class Summary | |
|---|---|
protected static class |
StringTransformerChain.State
This inner class contains the state of a transformation. |
| Field Summary | |
|---|---|
private String |
id
|
private StringTransformerChain |
parent
The parent that is extended by this chain or null. |
private StringTransformerRule[] |
rules
The rules of this chain. |
| Constructor Summary | |
|---|---|
StringTransformerChain()
The non-arg constructor. |
|
StringTransformerChain(String id,
StringTransformerChain parent,
StringTransformerRule... rules)
The constructor. |
|
StringTransformerChain(StringTransformerRule... rules)
The constructor. |
|
| Method Summary | |
|---|---|
StringTransformerChain |
extend(StringTransformerRule... additionalRules)
This method extends this chain with additionalRules. |
String |
getId()
This method gets the ID used to identify this chain. |
String |
transform(String original)
This method transforms a given original value. |
private String |
transformRecursive(String original,
StringTransformerChain.State state)
This method implements transform(String) recursively. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private String id
getId()private StringTransformerChain parent
null.
private StringTransformerRule[] rules
| Constructor Detail |
|---|
public StringTransformerChain()
public StringTransformerChain(StringTransformerRule... rules)
rules - are the rules of this chain.
public StringTransformerChain(String id,
StringTransformerChain parent,
StringTransformerRule... rules)
id - the ID of this chain.parent - is the parent chain to extend
or null for a root-chain.rules - are the rules of this chain.| Method Detail |
|---|
public String transform(String original)
original value. This value must
NOT be modified by this method. To change the original value a
new value has to be created and returned instead. If the value should NOT
be changed, the original value (the exact same instance)
should be returned.
transform in interface Transformer<String>original - is the original value.
null if explicitly
documented by the implementation. The receiver of a
Transformer should also document if null is a
legal result.
private String transformRecursive(String original,
StringTransformerChain.State state)
transform(String) recursively.
original - is the original value.state - is the StringTransformerChain.State used to indicate if a
rule causes the chain to
StringTransformerChain.State.stop.
public String getId()
null if undefined.public StringTransformerChain extend(StringTransformerRule... additionalRules)
additionalRules.StringTransformerChain(String, StringTransformerChain, StringTransformerRule...)
instead.
additionalRules - are the rules to add.
additionalRules if none
of this rules match.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||