public final class NormalizedString extends Object implements Serializable, Comparable<NormalizedString>, CharSequence
NormalizedString allows representing text in a normalized fashion. Strings
with different character case or surrounding whitespace are considered the same.
Used to represent groups of fields, where users may refer to their names using
different character cases or whitespaces.
Where the character case or the surrounding space is relevant, the NormalizedString
will have its isLiteral() method return true, meaning the exact
character case and surrounding whitespaces are required for matching it.
Invoking valueOf(String) with a String surrounded by single quotes
will create a literal NormalizedString. Use literalValueOf(String)
to obtain the same NormalizedString without having to introduce single quotes.| Modifier and Type | Method and Description |
|---|---|
char |
charAt(int index) |
int |
compareTo(NormalizedString o) |
int |
compareTo(String o)
Compares a
NormalizedString against a String lexicographically. |
boolean |
equals(Object anObject) |
static StringCache<NormalizedString> |
getCache()
Returns the internal string cache to allow users to tweak its size limit or clear it when appropriate
|
int |
hashCode() |
static boolean |
identifyLiterals(NormalizedString[] strings)
Analyzes a group of NormalizedString to identify any instances whose normalized content will generate
clashes.
|
static boolean |
identifyLiterals(NormalizedString[] strings,
boolean lowercaseIdentifiers,
boolean uppercaseIdentifiers)
Analyzes a group of NormalizedString to identify any instances whose normalized content will generate
clashes.
|
boolean |
isLiteral() |
int |
length() |
static NormalizedString |
literalValueOf(String string)
Creates a literal
NormalizedString, meaning it will only match with
other String or NormalizedString if they have the exact same content
including character case and surrounding whitespaces. |
CharSequence |
subSequence(int start,
int end) |
static NormalizedString[] |
toArray(Collection<String> args)
Converts a collection of plain strings into an array of
NormalizedString |
static String[] |
toArray(NormalizedString... args)
Converts multiple normalized strings into an array of
String. |
static NormalizedString[] |
toArray(String... args)
Converts multiple plain strings into an array of
NormalizedString. |
static ArrayList<NormalizedString> |
toArrayList(Collection<String> args)
Converts multiple plain strings into an
ArrayList of NormalizedString. |
static ArrayList<NormalizedString> |
toArrayList(String... args)
Converts multiple plain strings into an
ArrayList of NormalizedString. |
static ArrayList<String> |
toArrayListOfStrings(Collection<NormalizedString> args)
Converts multiple normalized strings into a
HashSet of String. |
static ArrayList<String> |
toArrayListOfStrings(NormalizedString... args)
Converts multiple normalized strings into a
HashSet of String. |
static HashSet<NormalizedString> |
toHashSet(Collection<String> args)
Converts multiple plain strings into a
HashSet of NormalizedString. |
static HashSet<NormalizedString> |
toHashSet(String... args)
Converts multiple plain strings into a
HashSet of NormalizedString. |
static HashSet<String> |
toHashSetOfStrings(Collection<NormalizedString> args)
Converts multiple normalized strings into a
HashSet of String. |
static HashSet<String> |
toHashSetOfStrings(NormalizedString... args)
Converts multiple normalized strings into a
HashSet of String. |
static NormalizedString[] |
toIdentifierGroupArray(NormalizedString[] strings)
Analyzes a group of NormalizedString to identify any instances whose normalized content will generate
clashes.
|
static NormalizedString[] |
toIdentifierGroupArray(String[] strings)
Analyzes a group of String to identify any instances whose normalized content will generate
clashes.
|
static LinkedHashSet<NormalizedString> |
toLinkedHashSet(Collection<String> args)
Converts multiple plain strings into a
LinkedHashSet of NormalizedString. |
static LinkedHashSet<NormalizedString> |
toLinkedHashSet(String... args)
Converts multiple plain strings into a
LinkedHashSet of NormalizedString. |
static LinkedHashSet<String> |
toLinkedHashSetOfStrings(Collection<NormalizedString> args)
Converts multiple normalized strings into a
LinkedHashSet of String. |
static LinkedHashSet<String> |
toLinkedHashSetOfStrings(NormalizedString... args)
Converts multiple normalized strings into a
LinkedHashSet of String. |
NormalizedString |
toLiteral()
Returns the literal representation of this
NormalizedString, meaning it will only match with
other String or NormalizedString if they have the exact same content
including character case and surrounding whitespaces. |
String |
toString() |
static String[] |
toStringArray(Collection<NormalizedString> args)
Converts a collection of normalized strings into an array of
String |
static TreeSet<NormalizedString> |
toTreeSet(Collection<String> args)
Converts multiple plain strings into a
TreeSet of NormalizedString. |
static TreeSet<NormalizedString> |
toTreeSet(String... args)
Converts multiple plain strings into a
TreeSet of NormalizedString. |
static TreeSet<String> |
toTreeSetOfStrings(Collection<NormalizedString> args)
Converts multiple normalized strings into a
HashSet of String. |
static TreeSet<String> |
toTreeSetOfStrings(NormalizedString... args)
Converts multiple normalized strings into a
HashSet of String. |
static NormalizedString[] |
toUniqueArray(String... args)
Converts multiple plain strings into an array of
NormalizedString, ensuring
no duplicate NormalizedString elements exist, even if their original Strings
are different. |
static String |
valueOf(NormalizedString string)
Converts a
NormalizedString back to its original String representation |
static NormalizedString |
valueOf(Object o)
Creates a non-literal
NormalizedString, meaning it will match with
other String or NormalizedString regardless of different
including character case and surrounding whitespaces. |
static NormalizedString |
valueOf(String string)
Creates a non-literal
NormalizedString, meaning it will match with
other String or NormalizedString regardless of different
including character case and surrounding whitespaces. |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitchars, codePointspublic boolean isLiteral()
public int length()
length in interface CharSequencepublic char charAt(int index)
charAt in interface CharSequencepublic CharSequence subSequence(int start, int end)
subSequence in interface CharSequencepublic int compareTo(NormalizedString o)
compareTo in interface Comparable<NormalizedString>public int compareTo(String o)
NormalizedString against a String lexicographically.o - a plain StringString.compareTo(String). If this NormalizedString
is a literal, the original argument string will be compared. If this NormalizedString
is not a literal, the result will be from the comparison of the normalized content of both strings
(i.e. surrounding whitespaces and character case differences will be ignored).public String toString()
toString in interface CharSequencetoString in class Objectpublic static NormalizedString literalValueOf(String string)
NormalizedString, meaning it will only match with
other String or NormalizedString if they have the exact same content
including character case and surrounding whitespaces.string - the input StringNormalizedString version of the given string.public static NormalizedString valueOf(Object o)
NormalizedString, meaning it will match with
other String or NormalizedString regardless of different
including character case and surrounding whitespaces.
If the input value is enclosed with single quotes, a literal NormalizedString
will be returned, as described in literalValueOf(String)o - the input object whose String representation will be usedNormalizedString of the given object.public static NormalizedString valueOf(String string)
NormalizedString, meaning it will match with
other String or NormalizedString regardless of different
including character case and surrounding whitespaces.
If the input string is enclosed with single quotes, a literal NormalizedString
will be returned, as described in literalValueOf(String)string - the input stringNormalizedString of the given string.public static String valueOf(NormalizedString string)
NormalizedString back to its original String representationstring - the normalized stringpublic static NormalizedString[] toArray(Collection<String> args)
NormalizedStringargs - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static String[] toStringArray(Collection<NormalizedString> args)
Stringargs - the normalized strings to convert back to to StringString representations of all normalized strings.public static NormalizedString[] toUniqueArray(String... args)
NormalizedString, ensuring
no duplicate NormalizedString elements exist, even if their original Strings
are different.args - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static NormalizedString[] toArray(String... args)
NormalizedString.args - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static String[] toArray(NormalizedString... args)
String.args - the normalized strings to convert to StringString representations of all input strings.public static ArrayList<NormalizedString> toArrayList(String... args)
ArrayList of NormalizedString.args - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static ArrayList<NormalizedString> toArrayList(Collection<String> args)
ArrayList of NormalizedString.args - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static ArrayList<String> toArrayListOfStrings(NormalizedString... args)
HashSet of String.args - the normalized strings to convert to StringStrings of all input normalized strings.public static ArrayList<String> toArrayListOfStrings(Collection<NormalizedString> args)
HashSet of String.args - the normalized strings to convert to StringStrings of all input normalized strings.public static TreeSet<NormalizedString> toTreeSet(String... args)
TreeSet of NormalizedString.args - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static TreeSet<NormalizedString> toTreeSet(Collection<String> args)
TreeSet of NormalizedString.args - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static TreeSet<String> toTreeSetOfStrings(NormalizedString... args)
HashSet of String.args - the normalized strings to convert to StringStrings of all input normalized strings.public static TreeSet<String> toTreeSetOfStrings(Collection<NormalizedString> args)
HashSet of String.args - the normalized strings to convert to StringStrings of all input normalized strings.public static HashSet<NormalizedString> toHashSet(String... args)
HashSet of NormalizedString.args - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static HashSet<NormalizedString> toHashSet(Collection<String> args)
HashSet of NormalizedString.args - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static HashSet<String> toHashSetOfStrings(NormalizedString... args)
HashSet of String.args - the normalized strings to convert to StringStrings of all input normalized strings.public static HashSet<String> toHashSetOfStrings(Collection<NormalizedString> args)
HashSet of String.args - the normalized strings to convert to StringStrings of all input normalized strings.public static LinkedHashSet<NormalizedString> toLinkedHashSet(String... args)
LinkedHashSet of NormalizedString.args - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static LinkedHashSet<NormalizedString> toLinkedHashSet(Collection<String> args)
LinkedHashSet of NormalizedString.args - the strings to convert to NormalizedStringNormalizedString representations of all input strings.public static LinkedHashSet<String> toLinkedHashSetOfStrings(NormalizedString... args)
LinkedHashSet of String.args - the normalized strings to convert to StringStrings of all input normalized strings.public static LinkedHashSet<String> toLinkedHashSetOfStrings(Collection<NormalizedString> args)
LinkedHashSet of String.args - the normalized strings to convert to StringStrings of all input normalized strings.public NormalizedString toLiteral()
NormalizedString, meaning it will only match with
other String or NormalizedString if they have the exact same content
including character case and surrounding whitespaces.NormalizedStringpublic static NormalizedString[] toIdentifierGroupArray(NormalizedString[] strings)
toLiteral()),
making it possible to identify one from the other.strings - a group of identifiers that may contain ambiguous entries if their character case or surrounding whitespaces is not considered.
This array will be modified.NormalizedString literals in the positions where clashes would originally occur.public static NormalizedString[] toIdentifierGroupArray(String[] strings)
toLiteral()),
making it possible to identify one from the other.strings - a group of identifiers that may contain ambiguous entries if their character case or surrounding whitespaces is not considered.NormalizedString array with literals in the positions where clashes would originally occur.public static boolean identifyLiterals(NormalizedString[] strings)
toLiteral()),
making it possible to identify one from the other.strings - a group of identifiers that may contain ambiguous entries if their character case or surrounding whitespaces is not considered.
This array will be modified.true if any entry has been modified to be a literal, otherwise falsepublic static boolean identifyLiterals(NormalizedString[] strings, boolean lowercaseIdentifiers, boolean uppercaseIdentifiers)
toLiteral()),
making it possible to identify one from the other.strings - a group of identifiers that may contain ambiguous entries if their character case or surrounding whitespaces is not considered.
This array will be modified.lowercaseIdentifiers - flag indicating that identifiers are stored in lower case (for compatibility with databases).
If a string has a uppercase character, it means it must become a literal.uppercaseIdentifiers - flag indicating that identifiers are stored in upper case (for compatibility with databases).
If a string has a lowercase character, it means it must become a literal.true if any entry has been modified to be a literal, otherwise falsepublic static StringCache<NormalizedString> getCache()
NormalizedString instances associated with their original String.Copyright © 2019 Univocity Software Pty Ltd. All rights reserved.