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 and Description |
---|
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.
|
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.
|
Modifier and Type | Method and Description |
---|---|
protected RedactorLogEntry |
applyTo(MetadataItem item,
IMetadataAccess metadata)
Applies the redaction to a given metadata item.
|
String |
getDescription()
Returns a string, describing the redaction and its parameters.
|
Pattern |
getKeyExpression()
Gets the regular expression to match name (key) of metadata item.
|
String |
getReplacement()
Gets the textual replacement value.
|
Pattern |
getValueExpression()
Gets the regular expression to match value text of a metadata item.
|
protected boolean |
isApplicableTo(MetadataItem item)
Checks if this redaction could be applied to a given metadata item.
|
applyFilter, applyTo, getFilter, setFilter
public MetadataSearchRedaction(String valuePattern, String replacement)
Initializes a new instance of MetadataSearchRedaction class, using value to match redacted items.
valuePattern
- Regular expression to search and replacereplacement
- Textual replacementpublic MetadataSearchRedaction(String valuePattern, String replacement, String keyPattern)
Initializes a new instance of MetadataSearchRedaction class, using item name and value to match redacted items.
valuePattern
- Regular expression to search and replace metadata item valuereplacement
- Textual replacementkeyPattern
- Regular expression to search and replace metadata item namepublic MetadataSearchRedaction(Pattern valueRegex, String replacement)
Initializes a new instance of MetadataSearchRedaction class, using value to match redacted items.
valueRegex
- Regular expression to search and replacereplacement
- Textual replacementpublic MetadataSearchRedaction(Pattern valueRegex, String replacement, Pattern keyRegex)
Initializes a new instance of MetadataSearchRedaction class, using item name and value to match redacted items.
valueRegex
- Regular expression to search and replace metadata item valuereplacement
- Textual replacementkeyRegex
- Regular expression to search and replace metadata item namepublic final Pattern getValueExpression()
Gets the regular expression to match value text of a metadata item.
public final String getReplacement()
Gets the textual replacement value.
public final Pattern getKeyExpression()
Gets the regular expression to match name (key) of metadata item.
public String getDescription()
Returns a string, describing the redaction and its parameters.
getDescription
in class Redaction
protected boolean isApplicableTo(MetadataItem item)
Checks if this redaction could be applied to a given metadata item.
isApplicableTo
in class MetadataRedaction
item
- Metadata itemprotected RedactorLogEntry applyTo(MetadataItem item, IMetadataAccess metadata)
Applies the redaction to a given metadata item.
applyTo
in class MetadataRedaction
item
- Metadata itemmetadata
- Metadata access