Top Inners Fields Constructors Methods
org.jabref.logic.bst.util

public final Class BstCaseChanger

extends Object
Class Inheritance
Imports
java.util.Locale, .Optional, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private int
private static final Logger
private boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String
changeCase(String
the string to handle
s
,
BstCaseChanger.FormatMode
the format
format
)

Changes case of the given string s

private int

Returns:

the new position
convertAccented
(char[] c, int start, String s, StringBuilder sb, BstCaseChanger.FormatMode format)

Convert the given string according to the format character (title, lower, up) and append the result to the stringBuffer, return the updated position.

private int
private int
convertNonControl(char[] c, int start, StringBuilder sb, BstCaseChanger.FormatMode format)

private int
convertSpecialChar(StringBuilder sb, char[] c, int
the current position. It points to the opening brace
start
,
BstCaseChanger.FormatMode format)

We're dealing with a special character (usually either an undotted `\i' or `\j', or an accent like one in Table~3.1 of the \LaTeX\ manual, or a foreign character like one in Table~3.2) if the first character after the |left_brace| is a |backslash|; the special character ends with the matching |right_brace|.

private String
public static Optional<String>

Returns:

the special LaTeX character or null
findSpecialChar
(char[]
the current "String"
c
,
int
the position
pos
)

Determine whether there starts a special char at pos (e.g., oe, AE).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

braceLevelback to summary
private int braceLevel
LOGGERback to summary
private static final Logger LOGGER
prevColonback to summary
private boolean prevColon

Constructor Detail

BstCaseChangerback to summary
private BstCaseChanger()

Method Detail

changeCaseback to summary
public static String changeCase(String s, BstCaseChanger.FormatMode format)

Changes case of the given string s

Parameters
s:String

the string to handle

format:BstCaseChanger.FormatMode

the format

convertAccentedback to summary
private int convertAccented(char[] c, int start, String s, StringBuilder sb, BstCaseChanger.FormatMode format)

Convert the given string according to the format character (title, lower, up) and append the result to the stringBuffer, return the updated position.

Returns:int

the new position

convertCharIfBraceLevelIsZeroback to summary
private int convertCharIfBraceLevelIsZero(char[] c, int start, StringBuilder sb, BstCaseChanger.FormatMode format)
convertNonControlback to summary
private int convertNonControl(char[] c, int start, StringBuilder sb, BstCaseChanger.FormatMode format)
convertSpecialCharback to summary
private int convertSpecialChar(StringBuilder sb, char[] c, int start, BstCaseChanger.FormatMode format)

We're dealing with a special character (usually either an undotted `\i' or `\j', or an accent like one in Table~3.1 of the \LaTeX\ manual, or a foreign character like one in Table~3.2) if the first character after the |left_brace| is a |backslash|; the special character ends with the matching |right_brace|. How we handle what is in between depends on the special character. In general, this code will do reasonably well if there is other stuff, too, between braces, but it doesn't try to do anything special with |colon|s.

Parameters
start:int

the current position. It points to the opening brace

doChangeCaseback to summary
private String doChangeCase(String s, BstCaseChanger.FormatMode format)
findSpecialCharback to summary
public static Optional<String> findSpecialChar(char[] c, int pos)

Determine whether there starts a special char at pos (e.g., oe, AE). Return it as string. If nothing found, return Optional.empty()

Also used by BibtexPurify

Parameters
c:char[]

the current "String"

pos:int

the position

Returns:Optional<String>

the special LaTeX character or null

org.jabref.logic.bst.util back to summary

public final Enum BstCaseChanger.FormatMode

extends Enum<BstCaseChanger.FormatMode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final BstCaseChanger.FormatMode
public static final BstCaseChanger.FormatMode
private final char
public static final BstCaseChanger.FormatMode

Constructor Summary

AccessConstructor and Description
private
FormatMode(char asChar)

Method Summary

Modifier and TypeMethod and Description
public char
public static BstCaseChanger.FormatMode
of(final char bstFormat)

Convert bstFormat char into ENUM

public static BstCaseChanger.FormatMode
of(final String bstFormat)

public static BstCaseChanger.FormatMode
public static BstCaseChanger.FormatMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALL_LOWERSback to summary
public static final BstCaseChanger.FormatMode ALL_LOWERS
ALL_UPPERSback to summary
public static final BstCaseChanger.FormatMode ALL_UPPERS
asCharback to summary
private final char asChar
TITLE_LOWERSback to summary
public static final BstCaseChanger.FormatMode TITLE_LOWERS

Constructor Detail

FormatModeback to summary
private FormatMode(char asChar)

Method Detail

asCharback to summary
public char asChar()
ofback to summary
public static BstCaseChanger.FormatMode of(final char bstFormat)

Convert bstFormat char into ENUM

Exceptions
IllegalArgumentException:
if char is not 't', 'l', 'u'
ofback to summary
public static BstCaseChanger.FormatMode of(final String bstFormat)
valueOfback to summary
public static BstCaseChanger.FormatMode valueOf(String name)
valuesback to summary
public static BstCaseChanger.FormatMode[] values()