public class DeleteAnnotationRedaction extends Redaction
Represents a text redaction that deletes annotations if text is matching given regular expression (optionally deletes all annotations).
Learn more
The following example demonstrates how to remove all annotations containing words "use", "show" or "describe" from document (and leave others).
try (Redactor redactor = new Redactor("D:\\test.docx"))
{
redactor.apply(new DeleteAnnotationRedaction("(?im:(use|show|describe))"));
redactor.save()
}
Constructor and Description |
---|
DeleteAnnotationRedaction()
Initializes a new instance of DeleteAnnotationRedaction class, with settings to delete all annotations (matching everything).
|
DeleteAnnotationRedaction(Pattern regex)
Initializes a new instance of DeleteAnnotationRedaction class, deleting annotations matching given expression.
|
DeleteAnnotationRedaction(String pattern)
Initializes a new instance of DeleteAnnotationRedaction class, deleting annotations matching given expression.
|
Modifier and Type | Method and Description |
---|---|
RedactorLogEntry |
applyTo(DocumentFormatInstance formatInstance)
Applies the redaction to a given format instance.
|
String |
getDescription()
Returns a string, describing the redaction and its parameters.
|
Pattern |
getExpression()
Gets the regular expression to match.
|
public DeleteAnnotationRedaction()
Initializes a new instance of DeleteAnnotationRedaction class, with settings to delete all annotations (matching everything).
public DeleteAnnotationRedaction(String pattern)
Initializes a new instance of DeleteAnnotationRedaction class, deleting annotations matching given expression.
pattern
- Regular expressionpublic DeleteAnnotationRedaction(Pattern regex)
Initializes a new instance of DeleteAnnotationRedaction class, deleting annotations matching given expression.
regex
- Regular expressionpublic final Pattern getExpression()
Gets the regular expression to match.
public String getDescription()
Returns a string, describing the redaction and its parameters.
getDescription
in class Redaction
public RedactorLogEntry applyTo(DocumentFormatInstance formatInstance)
Applies the redaction to a given format instance.