|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.progeeks.meta.format.AbstractPropertyFormat
org.progeeks.meta.format.FieldSubstitutionFormat
public class FieldSubstitutionFormat
A formatter that will substitute parameters of a format string
with the values contained in the MetaObject's properties.
For example:
some format comes in as
...person=@name@&place=@homeTown@
@name@would be replaced with the value contained in the name property of the MetaObject.
Likewise,@homeTown@would be replaced with the value contained in the homeTown property of the MetaObject.
The default token pattern used is: @.+?@
An optional flag is also available for Urlencoding parameter values that are substituted. This flag defaults tofalse
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_TOKEN_PATTERN
|
Constructor Summary | |
---|---|
FieldSubstitutionFormat()
Default constructor for a URLQueryFormat. |
|
FieldSubstitutionFormat(java.lang.String formatString)
Creates a FieldSubstitionFormat that will replace any @propertyName@ values in the formatString with meta-object properties matching the property name. |
|
FieldSubstitutionFormat(java.lang.String formatString,
java.lang.String tokenPattern)
|
|
FieldSubstitutionFormat(java.lang.String formatString,
java.lang.String tokenPattern,
boolean urlEncode)
|
Method Summary | |
---|---|
java.lang.String |
format(java.lang.Object obj)
Returns the formatted String for the specified Object, null if the Object cannot be formatted or
if any errors occur. |
FormatRegistry |
getFormatRegistry()
|
java.lang.String |
getFormatString()
|
java.lang.String |
getTokenPattern()
|
boolean |
isUrlEncoding()
|
java.lang.Object |
parseObject(java.lang.String source,
int index)
Parsing is not supported. |
void |
setFormatRegistry(FormatRegistry formatRegistry)
Sets an optional format registry that will be used to resolve the substitued field values. |
void |
setFormatString(java.lang.String formatString)
|
void |
setTokenPattern(java.lang.String tokenPattern)
|
void |
setUrlEncoding(boolean urlEncode)
|
java.lang.String |
toString()
String summary. |
Methods inherited from class org.progeeks.meta.format.AbstractPropertyFormat |
---|
format, parseObject |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_TOKEN_PATTERN
Constructor Detail |
---|
public FieldSubstitutionFormat()
public FieldSubstitutionFormat(java.lang.String formatString)
formatString
- is the full string whose tokens will be replaced.public FieldSubstitutionFormat(java.lang.String formatString, java.lang.String tokenPattern)
formatString
- is the full string whose tokens will be replaced.tokenPattern
- is the pattern searched and replaced the formatString.
Default value is: @.+?@ which will match @ delimited field values.public FieldSubstitutionFormat(java.lang.String formatString, java.lang.String tokenPattern, boolean urlEncode)
formatString
- is the full string whose tokens will be replaced.tokenPattern
- is the pattern searched and replaced the formatString.
Default value is: @.+?@ which will match @ delimited field values.urlEncode
- to indicate if substituted value(s) need to be url encoded.
Default value is: false.Method Detail |
---|
public void setFormatRegistry(FormatRegistry formatRegistry)
public FormatRegistry getFormatRegistry()
public void setTokenPattern(java.lang.String tokenPattern)
public java.lang.String getTokenPattern()
public void setFormatString(java.lang.String formatString)
public java.lang.String getFormatString()
public void setUrlEncoding(boolean urlEncode)
public boolean isUrlEncoding()
public java.lang.String format(java.lang.Object obj)
null
if the Object cannot be formatted or
if any errors occur.
format
in interface PropertyFormat
format
in class AbstractPropertyFormat
public java.lang.Object parseObject(java.lang.String source, int index)
parseObject
in interface PropertyFormat
parseObject
in class AbstractPropertyFormat
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |