public class StringTransformerChain extends Object implements Transformer<String>
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).| Modifier and Type | Class and Description |
|---|---|
protected static class |
StringTransformerChain.State
This inner class contains the state of a transformation.
|
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
StringTransformerChain()
The non-arg constructor.
|
StringTransformerChain(String id,
StringTransformerChain parent,
StringTransformerRule... rules)
The constructor.
|
StringTransformerChain(StringTransformerRule... rules)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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. |
private StringTransformerChain parent
null.private StringTransformerRule[] rules
public StringTransformerChain()
public StringTransformerChain(StringTransformerRule... rules)
rules - are the rules of this chain.public StringTransformerChain(String id, StringTransformerChain parent, StringTransformerRule... rules)
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.Copyright © 2001–2015 mmm-Team. All rights reserved.