- java.lang.Object
-
- java.lang.Enum<CaseConversion>
-
- io.github.mmm.base.text.CaseConversion
-
- All Implemented Interfaces:
Serializable
,Comparable<CaseConversion>
public enum CaseConversion extends Enum<CaseConversion>
Represents the different character cases and allowsconversion
.- Since:
- 7.4.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
-
Enum Constant Summary
Enum Constants Enum Constant Description LOWER_CASE
Convertto lower case
.ORIGINAL_CASE
Do not convert (keep original case).UPPER_CASE
Convertto upper case
.
-
Field Summary
Fields Modifier and Type Field Description static char
EXAMPLE_CHAR_FOR_ORIGINAL_CASE
The character representingORIGINAL_CASE
inexamples
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
areIncompatible(CaseConversion case1, CaseConversion case2)
char
asExample(char c)
char
convert(char c)
String
convert(String string)
String
convert(String string, Locale locale)
static boolean
isCaseChange(CaseConversion caseConversion)
static CaseConversion
ofExample(char c, boolean strict)
static CaseConversion
valueOf(String name)
Returns the enum constant of this type with the specified name.static CaseConversion[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
LOWER_CASE
public static final CaseConversion LOWER_CASE
Convertto lower case
.
-
UPPER_CASE
public static final CaseConversion UPPER_CASE
Convertto upper case
.
-
ORIGINAL_CASE
public static final CaseConversion ORIGINAL_CASE
Do not convert (keep original case).
-
-
Field Detail
-
EXAMPLE_CHAR_FOR_ORIGINAL_CASE
public static final char EXAMPLE_CHAR_FOR_ORIGINAL_CASE
The character representingORIGINAL_CASE
inexamples
. Was chosen so it can be used in java names (including packages), paths and URIs but is unlikely to conflict with other semantical usage. However, this choice is arbitrarily.- See Also:
- Constant Field Values
-
-
Method Detail
-
values
public static CaseConversion[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (CaseConversion c : CaseConversion.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static CaseConversion valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
convert
public String convert(String string, Locale locale)
- Parameters:
string
- the originalString
.locale
- the explicitLocale
to use. In most cases you want to useconvert(String)
instead.- Returns:
- the converted
String
.
-
convert
public char convert(char c)
- Parameters:
c
- the original character.- Returns:
- the converted character.
-
asExample
public char asExample(char c)
- Parameters:
c
- the character toconvert
.- Returns:
- the
converted
characterc
butEXAMPLE_CHAR_FOR_ORIGINAL_CASE
if this isORIGINAL_CASE
.
-
ofExample
public static CaseConversion ofExample(char c, boolean strict)
- Parameters:
c
- the example character.strict
- if the character has to be an upper/lower case letter orEXAMPLE_CHAR_FOR_ORIGINAL_CASE
.- Returns:
UPPER_CASE
if the given character isupper case
,LOWER_CASE
if the given character islower case
, andORIGINAL_CASE
otherwise (might need to be remapped or handled specially).
-
isCaseChange
public static boolean isCaseChange(CaseConversion caseConversion)
- Parameters:
caseConversion
- theCaseConversion
to test. May benull
.- Returns:
true
if the givenCaseConversion
isLOWER_CASE
orUPPER_CASE
.
-
areIncompatible
public static boolean areIncompatible(CaseConversion case1, CaseConversion case2)
- Parameters:
case1
- the firstCaseConversion
.case2
- the secondCaseConversion
.- Returns:
true
if bothCaseConversion
s are incompatible to each other. This means they are not same and are bothcase changing
. Otherwisefalse
.
-
-