com.groupdocs.redaction.redactions

Class MetadataSearchRedaction



  • public class MetadataSearchRedaction
    extends MetadataRedaction

    Represents a metadata redaction that searches and redacts metadata using regular expressions, matching keys and/or values.


    Learn more

    The following example demonstrates how to search and redact certain text in specific metadata.

    try (Redactor redactor = new Redactor("C:\\sample.docx"))
     {
        MetadataSearchRedaction redaction = new MetadataSearchRedaction("Company Ltd.", "--company--");
        // If not set, applies to all metadata items
        redaction.setFilter( MetadataFilters.Company );
        redactor.apply(redaction);
        redactor.save();
     }
      
    • Constructor Detail

      • MetadataSearchRedaction

        public MetadataSearchRedaction(String valuePattern,
                               String replacement)

        Initializes a new instance of MetadataSearchRedaction class, using value to match redacted items.

        Parameters:
        valuePattern - Regular expression to search and replace
        replacement - Textual replacement
      • MetadataSearchRedaction

        public MetadataSearchRedaction(String valuePattern,
                               String replacement,
                               String keyPattern)

        Initializes a new instance of MetadataSearchRedaction class, using item name and value to match redacted items.

        Parameters:
        valuePattern - Regular expression to search and replace metadata item value
        replacement - Textual replacement
        keyPattern - Regular expression to search and replace metadata item name
      • MetadataSearchRedaction

        public MetadataSearchRedaction(Pattern valueRegex,
                               String replacement)

        Initializes a new instance of MetadataSearchRedaction class, using value to match redacted items.

        Parameters:
        valueRegex - Regular expression to search and replace
        replacement - Textual replacement
      • MetadataSearchRedaction

        public MetadataSearchRedaction(Pattern valueRegex,
                               String replacement,
                               Pattern keyRegex)

        Initializes a new instance of MetadataSearchRedaction class, using item name and value to match redacted items.

        Parameters:
        valueRegex - Regular expression to search and replace metadata item value
        replacement - Textual replacement
        keyRegex - Regular expression to search and replace metadata item name
    • Method Detail

      • getValueExpression

        public final Pattern getValueExpression()

        Gets the regular expression to match value text of a metadata item.

        Returns:
        The regular expression to match value text of a metadata item.
      • getReplacement

        public final String getReplacement()

        Gets the textual replacement value.

        Returns:
        The textual replacement value.
      • getKeyExpression

        public final Pattern getKeyExpression()

        Gets the regular expression to match name (key) of metadata item.

        Returns:
        The regular expression to match name (key) of metadata item.
      • getDescription

        public String getDescription()

        Returns a string, describing the redaction and its parameters.

        Overrides:
        getDescription in class Redaction
        Returns:
        Text, containing redaction name and parameters.
      • isApplicableTo

        protected boolean isApplicableTo(MetadataItem item)

        Checks if this redaction could be applied to a given metadata item.

        Specified by:
        isApplicableTo in class MetadataRedaction
        Parameters:
        item - Metadata item
        Returns:
        True if redaction can be applied