@ComponentProfile(summary="Perform a find and replace on metadata", tag="service,metadata") public class ReplaceMetadataValue extends ReformatMetadata
Implementation of Service
that adds a performs a simple find and replace on the specified metadata value.
Each matching metadata key from ReformatMetadata.getMetadataKeyRegexp()
will taken and if the search-value matches, then
the replacement-value will be used as the replacement.
You can specify matchgroups as part of the replacment by using the standard $n
syntax. It also supports the special
syntax of {n}
to indicate match groups, but this is not guaranteed to work in all instances and is only made
available for legacy purposes.
In the adapter configuration file this class is aliased as replace-metadata-value which is the preferred alternative to the fully qualified classname when building your configuration.
MetadataServiceImpl.LogWrapper
DEBUG, ERROR, INFO, TRACE, WARN
log
Constructor and Description |
---|
ReplaceMetadataValue() |
ReplaceMetadataValue(java.lang.String regexp,
java.lang.String searchFor,
boolean all,
java.lang.String replacement) |
Modifier and Type | Method and Description |
---|---|
java.lang.Boolean |
getReplaceAll() |
java.lang.String |
getReplacementValue() |
java.lang.String |
getSearchValue() |
protected void |
initService() |
java.lang.String |
reformat(java.lang.String src,
AdaptrisMessage msg)
Reformat a metadata value
|
protected java.lang.String |
replacementValue() |
void |
setReplaceAll(java.lang.Boolean s)
Specify whether or not to replace all occurences of
setSearchValue(String) |
void |
setReplacementValue(java.lang.String s)
The replacement value.
|
void |
setSearchValue(java.lang.String s)
The value to search for within the metadata value.
|
doService, getMetadataKeyRegexp, setMetadataKeyRegexp
closeService, getMetadataLogger, logMetadata, logMetadata, logMetadata, logMetadata, prepare, setMetadataLogger, withMetadataLogger
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
reformat
public ReplaceMetadataValue()
public ReplaceMetadataValue(java.lang.String regexp, java.lang.String searchFor, boolean all, java.lang.String replacement)
protected void initService() throws CoreException
initService
in class MetadataServiceImpl
CoreException
public java.lang.String reformat(java.lang.String src, AdaptrisMessage msg) throws java.lang.Exception
MetadataReformatter
src
- the string to reformatmsg
- the current Mesage.java.lang.Exception
public java.lang.String getSearchValue()
public void setSearchValue(java.lang.String s)
s
- the regular expression to search for.public java.lang.String getReplacementValue()
public void setReplacementValue(java.lang.String s)
The standard java regexp behaviour of using $n
to indicate the corresponding match group is supported.
s
- the replacement value.protected java.lang.String replacementValue()
public java.lang.Boolean getReplaceAll()
public void setReplaceAll(java.lang.Boolean s)
setSearchValue(String)
s
- true to replace all occurences.