Verified Owner
Top Fields Constructors Methods
org.jabref.logic.formatter.bibtexfields

public Class RegexFormatter

extends Formatter
Class Inheritance
Imports
java.util.ArrayList, .List, java.util.regex.Matcher, .Pattern, .PatternSyntaxException, org.jabref.logic.formatter.Formatter, org.jabref.logic.l10n.Localization, org.jspecify.annotations.NonNull, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private static final Pattern
CONSTRUCTOR_ARGUMENT

Matches a valid argument to the constructor.

private static final Pattern
ENCLOSED_IN_CURLY_BRACES

Matches text enclosed in curly brackets.

private static final Pattern
private static final Pattern
public static final String
private static final Logger
private static final String
private static final String
private static final String
private static final String
private final String
private static final String
private final String
private static final String

Constructor Summary

AccessConstructor and Description
public
RegexFormatter(@NonNull String
the regular expressions for matching and replacing given in the form ("<regex>", "<replace>").
input
)

Constructs a new regular expression-based formatter with the given RegEx.

Method Summary

Modifier and TypeMethod and Description
public String
format(final @NonNull String input)

public String
getDescription()

Implements abstract org.jabref.logic.formatter.Formatter.getDescription.

Returns a description of the formatter.

public String
getExampleInput()

Implements abstract org.jabref.logic.formatter.Formatter.getExampleInput.

Returns an example input string of the formatter.

public String
getKey()

Implements abstract org.jabref.logic.formatter.Formatter.getKey.

Returns a unique key for the formatter that can be used for its identification

public String
getName()

Implements abstract org.jabref.logic.formatter.Formatter.getName.

Returns a human readable name of the formatter usable for e.g. in the GUI

private String
Inherited from org.jabref.logic.formatter.Formatter:
equalsformathashCode

Field Detail

CONSTRUCTOR_ARGUMENTback to summary
private static final Pattern CONSTRUCTOR_ARGUMENT

Matches a valid argument to the constructor. Two capturing groups are used to parse the RegexFormatter#regex and RegexFormatter#replacement used in RegexFormatter#format(String)

ENCLOSED_IN_CURLY_BRACESback to summary
private static final Pattern ENCLOSED_IN_CURLY_BRACES

Matches text enclosed in curly brackets. The capturing group is used to prevent part of the input from being replaced.

ESCAPED_CLOSING_CURLY_BRACEback to summary
private static final Pattern ESCAPED_CLOSING_CURLY_BRACE
ESCAPED_OPENING_CURLY_BRACEback to summary
private static final Pattern ESCAPED_OPENING_CURLY_BRACE
KEYback to summary
public static final String KEY
LOGGERback to summary
private static final Logger LOGGER
PLACEHOLDER_FOR_CLOSING_CURLY_BRACEback to summary
private static final String PLACEHOLDER_FOR_CLOSING_CURLY_BRACE
PLACEHOLDER_FOR_OPENING_CURLY_BRACEback to summary
private static final String PLACEHOLDER_FOR_OPENING_CURLY_BRACE
PLACEHOLDER_FOR_PROTECTED_GROUPback to summary
private static final String PLACEHOLDER_FOR_PROTECTED_GROUP
PLACEHOLDER_FOR_QUOTE_SIGNback to summary
private static final String PLACEHOLDER_FOR_QUOTE_SIGN
regexback to summary
private final String regex
REGEX_CAPTURING_GROUPback to summary
private static final String REGEX_CAPTURING_GROUP
replacementback to summary
private final String replacement
REPLACEMENT_CAPTURING_GROUPback to summary
private static final String REPLACEMENT_CAPTURING_GROUP

Constructor Detail

RegexFormatterback to summary
public RegexFormatter(@NonNull String input)

Constructs a new regular expression-based formatter with the given RegEx.

Parameters
input:@NonNull String

the regular expressions for matching and replacing given in the form ("<regex>", "<replace>").

Method Detail

formatback to summary
public String format(final @NonNull String input)
Annotations
@Override
getDescriptionback to summary
public String getDescription()

Implements abstract org.jabref.logic.formatter.Formatter.getDescription.

Doc from org.jabref.logic.formatter.Formatter.getDescription.

Returns a description of the formatter.

Annotations
@Override
getExampleInputback to summary
public String getExampleInput()

Implements abstract org.jabref.logic.formatter.Formatter.getExampleInput.

Doc from org.jabref.logic.formatter.Formatter.getExampleInput.

Returns an example input string of the formatter. This example is used as input to the formatter to demonstrate its functionality

Annotations
@Override
getKeyback to summary
public String getKey()

Implements abstract org.jabref.logic.formatter.Formatter.getKey.

Doc from org.jabref.logic.formatter.Formatter.getKey.

Returns a unique key for the formatter that can be used for its identification

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract org.jabref.logic.formatter.Formatter.getName.

Doc from org.jabref.logic.formatter.Formatter.getName.

Returns a human readable name of the formatter usable for e.g. in the GUI

Annotations
@Override
replaceHonoringProtectedGroupsback to summary
private String replaceHonoringProtectedGroups(final String input)