Class 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 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.

    • Constructor Detail

      • ReplaceMetadataValue

        public ReplaceMetadataValue()
      • ReplaceMetadataValue

        public ReplaceMetadataValue​(java.lang.String regexp,
                                    java.lang.String searchFor,
                                    boolean all,
                                    java.lang.String replacement)
    • Method Detail

      • reformat

        public java.lang.String reformat​(java.lang.String src,
                                         AdaptrisMessage msg)
                                  throws java.lang.Exception
        Description copied from interface: MetadataReformatter
        Reformat a metadata value
        Parameters:
        src - the string to reformat
        msg - 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 $n to 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 of setSearchValue(String)
        Parameters:
        s - true to replace all occurences.