MetadataSearchRedaction

Inheritance: java.lang.Object, com.groupdocs.redaction.Redaction, com.groupdocs.redaction.redactions.MetadataRedaction

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();
 }
 

Constructors

Constructor Description
MetadataSearchRedaction(String valuePattern, String replacement) Initializes a new instance of MetadataSearchRedaction class, using value to match redacted items.
MetadataSearchRedaction(String valuePattern, String replacement, String keyPattern) Initializes a new instance of MetadataSearchRedaction class, using item name and value to match redacted items.
MetadataSearchRedaction(Pattern valueRegex, String replacement) Initializes a new instance of MetadataSearchRedaction class, using value to match redacted items.
MetadataSearchRedaction(Pattern valueRegex, String replacement, Pattern keyRegex) Initializes a new instance of MetadataSearchRedaction class, using item name and value to match redacted items.

Methods

Method Description
getValueExpression() Gets the regular expression to match value text of a metadata item.
getReplacement() Gets the textual replacement value.
getKeyExpression() Gets the regular expression to match name (key) of metadata item.
getDescription() Returns a string, describing the redaction and its parameters.

MetadataSearchRedaction(String valuePattern, String replacement)

public MetadataSearchRedaction(String valuePattern, String replacement)

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

Parameters:

Parameter Type Description
valuePattern java.lang.String Regular expression to search and replace
replacement java.lang.String Textual replacement

MetadataSearchRedaction(String valuePattern, String replacement, String keyPattern)

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:

Parameter Type Description
valuePattern java.lang.String Regular expression to search and replace metadata item value
replacement java.lang.String Textual replacement
keyPattern java.lang.String Regular expression to search and replace metadata item name

MetadataSearchRedaction(Pattern valueRegex, String replacement)

public MetadataSearchRedaction(Pattern valueRegex, String replacement)

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

Parameters:

Parameter Type Description
valueRegex java.util.regex.Pattern Regular expression to search and replace
replacement java.lang.String Textual replacement

MetadataSearchRedaction(Pattern valueRegex, String replacement, Pattern keyRegex)

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:

Parameter Type Description
valueRegex java.util.regex.Pattern Regular expression to search and replace metadata item value
replacement java.lang.String Textual replacement
keyRegex java.util.regex.Pattern Regular expression to search and replace metadata item name

getValueExpression()

public final Pattern getValueExpression()

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

Returns: java.util.regex.Pattern - The regular expression to match value text of a metadata item.

getReplacement()

public final String getReplacement()

Gets the textual replacement value.

Returns: java.lang.String - The textual replacement value.

getKeyExpression()

public final Pattern getKeyExpression()

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

Returns: java.util.regex.Pattern - The regular expression to match name (key) of metadata item.

getDescription()

public String getDescription()

Returns a string, describing the redaction and its parameters.

Returns: java.lang.String - Text, containing redaction name and parameters.