|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.schmant.support.text.PropertyValueTextStrategy
public class PropertyValueTextStrategy
This ReplacementTextStrategy
takes the text captured by the
n:th capturing group and uses it as a key for looking up a property
value in a supplied Properties
object. The replacement text is that
property value.
By default, if a property does not exist, this object throws an
SchmantException
. It can be configured to return an empty string
instead by using the
PropertyValueTextStrategy(Properties, int, boolean)
constructor.
The task factory reference contains an example of how this strategy can be used.
Constructor Summary | |
---|---|
PropertyValueTextStrategy(Properties props)
Create a new property value text strategy that uses the value of the first capturing group as the property key. |
|
PropertyValueTextStrategy(Properties props,
int capturingGroupNo,
boolean ignoreMissingProperties)
Create a new property value text strategy that uses the value of the supplied capturing group number as the property key. |
Method Summary | |
---|---|
String |
getReplace(String text,
Matcher m)
Get the replacement text for the supplied text. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PropertyValueTextStrategy(Properties props)
props
- The property object that this object uses.public PropertyValueTextStrategy(Properties props, int capturingGroupNo, boolean ignoreMissingProperties)
props
- The property object.capturingGroupNo
- The number of the capturing group that this
strategy uses as the property key when looking up values. The first
capturing group is number one. The zeroth capturing group contains the
entire matched pattern.ignoreMissingProperties
- If this is set to true, this object
returns an empty string instead of throwing an exception if a property is
missing. Use with care!Method Detail |
---|
public String getReplace(String text, Matcher m) throws SchmantException
ReplacementTextStrategy
getReplace
in interface ReplacementTextStrategy
text
- The text.m
- The Matcher
that matches the current text. This object
can only be read from. Its state must not be updated.
SchmantException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |