Class ReplaceMetadataValue
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.metadata.MetadataServiceImpl
-
- com.adaptris.core.services.metadata.ReformatMetadata
-
- com.adaptris.core.services.metadata.ReplaceMetadataValue
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,MessageEventGenerator,Service,MetadataReformatter,StateManagedComponent
@ComponentProfile(summary="Perform a find and replace on metadata", tag="service,metadata") public class ReplaceMetadataValue extends ReformatMetadataImplementation of
Servicethat 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
$nsyntax. 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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
MetadataServiceImpl.LogWrapper
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
DEBUG, ERROR, INFO, TRACE, WARN
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description ReplaceMetadataValue()ReplaceMetadataValue(java.lang.String regexp, java.lang.String searchFor, boolean all, java.lang.String replacement)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.BooleangetReplaceAll()java.lang.StringgetReplacementValue()java.lang.StringgetSearchValue()protected voidinitService()java.lang.Stringreformat(java.lang.String src, AdaptrisMessage msg)Reformat a metadata valueprotected java.lang.StringreplacementValue()voidsetReplaceAll(java.lang.Boolean s)Specify whether or not to replace all occurences ofsetSearchValue(String)voidsetReplacementValue(java.lang.String s)The replacement value.voidsetSearchValue(java.lang.String s)The value to search for within the metadata value.-
Methods inherited from class com.adaptris.core.services.metadata.ReformatMetadata
doService, getMetadataKeyRegexp, setMetadataKeyRegexp
-
Methods inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
closeService, getMetadataLogger, logMetadata, logMetadata, logMetadata, logMetadata, prepare, setMetadataLogger, withMetadataLogger
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.services.metadata.MetadataReformatter
reformat
-
-
-
-
Method Detail
-
initService
protected void initService() throws CoreException- Overrides:
initServicein classMetadataServiceImpl- Throws:
CoreException
-
reformat
public java.lang.String reformat(java.lang.String src, AdaptrisMessage msg) throws java.lang.ExceptionDescription copied from interface:MetadataReformatterReformat a metadata value- Parameters:
src- the string to reformatmsg- the current Mesage.- Returns:
- the replacment string.
- Throws:
java.lang.Exception
-
getSearchValue
public java.lang.String getSearchValue()
-
setSearchValue
public void setSearchValue(java.lang.String s)
The value to search for within the metadata value.- Parameters:
s- the regular expression to search for.
-
getReplacementValue
public java.lang.String getReplacementValue()
-
setReplacementValue
public void setReplacementValue(java.lang.String s)
The replacement value.The standard java regexp behaviour of using
$nto indicate the corresponding match group is supported.- Parameters:
s- the replacement value.
-
replacementValue
protected java.lang.String replacementValue()
-
getReplaceAll
public java.lang.Boolean getReplaceAll()
-
setReplaceAll
public void setReplaceAll(java.lang.Boolean s)
Specify whether or not to replace all occurences ofsetSearchValue(String)- Parameters:
s- true to replace all occurences.
-
-