Class CodepointHelper
- java.lang.Object
-
- com.helger.commons.text.codepoint.CodepointHelper
-
@Immutable public final class CodepointHelper extends Object
General utilities for dealing with Unicode characters- Author:
- Apache Abdera
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CodepointcodepointAt(CharSequence aSeq, int nIndex)static StringgetAsString(int nCodepoint)static chargetHighSurrogate(int nCodepoint)static intgetIndex(int[] aCodepointSet, int nValue)static chargetLowSurrogate(int nCodepoint)static booleaninRange(char[] aChars, char cLow, char cHigh)static booleaninRange(char[] aChars, int nLow, int nHigh)static booleaninRange(int nCodepoint, int nLow, int nHigh)static voidinsert(CharSequence aSeq, int nIndex, int nCodepoint)Insert a codepoint into the buffer, automatically dealing with surrogate pairsstatic voidinsert(CharSequence aSeq, int nIndex, Codepoint aCodepoint)Insert a codepoint into the buffer, automatically dealing with surrogate pairsstatic booleaninverseSetContains(int[] aCodepointSet, int value)Treats the specified int array as an Inversion Set and returnstrueif the value is located within the set.static booleanis_ifragment(int codepoint)static booleanis_ihost(int codepoint)static booleanis_ipath(int codepoint)static booleanis_ipathnodelims(int codepoint)static booleanis_ipchar(int codepoint)static booleanis_ipliteral(int codepoint)static booleanis_iprivate(int codepoint)static booleanis_iquery(int codepoint)static booleanis_iregname(int codepoint)static booleanis_iserver(int codepoint)static booleanis_iunreserved(int codepoint)static booleanis_iuserinfo(int codepoint)static booleanis_regname(int codepoint)static booleanis_ucschar(int codepoint)static booleanisBidi(int nCodepoint)static booleanisFragment(int codepoint)static booleanisGenDelim(int codepoint)static booleanisHex(int nCodepoint)static booleanisMark(int codepoint)static booleanisPath(int codepoint)static booleanisPathNoDelims(int codepoint)static booleanisPchar(int codepoint)static booleanisPctEnc(int codepoint)static booleanisQuery(int codepoint)static booleanisReserved(int codepoint)static booleanisScheme(int codepoint)static booleanisSubDelim(int codepoint)static booleanisUnreserved(int codepoint)static booleanisUserInfo(int codepoint)static intlength(char[] aArray)static intlength(AbstractCodepointIterator aIter)static intlength(CharSequence aSeq)static voidsetChar(CharSequence aSeq, int nIndex, int nCodepoint)Set the character at a given location, automatically dealing with surrogate pairsstatic voidsetChar(CharSequence aSeq, int nIndex, Codepoint aCodepoint)Set the character at a given location, automatically dealing with surrogate pairsstatic StringstripBidi(String sStr)Removes leading and trailing bidi controls from the stringstatic StringstripBidiInternal(String sStr)Removes bidi controls from within a stringstatic voidverify(char[] aArray, ECodepointProfile eProfile)Verifies a sequence of codepoints using the specified profilestatic voidverify(AbstractCodepointIterator aIter, ECodepointProfile eProfile)Verifies a sequence of codepoints using the specified filterstatic voidverify(AbstractCodepointIterator aIter, IntPredicate aFilter)Verifies a sequence of codepoints using the specified filterstatic voidverify(String sStr, ECodepointProfile eProfile)Verifies a sequence of codepoints using the specified profilestatic voidverifyNot(char[] aArray, ECodepointProfile eProfile)Verifies a sequence of codepoints using the specified profilestatic voidverifyNot(ICodepointIterator aIter, ECodepointProfile eProfile)Verifies a sequence of codepoints using the specified profilestatic voidverifyNot(ICodepointIterator aIter, IntPredicate aFilter)Verifies a sequence of codepoints using the specified filterstatic StringwrapBidi(String sStr, char cChar)Wrap the string with the specified bidi control
-
-
-
Field Detail
-
LRE
public static final char LRE
- See Also:
- Constant Field Values
-
RLE
public static final char RLE
- See Also:
- Constant Field Values
-
LRO
public static final char LRO
- See Also:
- Constant Field Values
-
RLO
public static final char RLO
- See Also:
- Constant Field Values
-
LRM
public static final char LRM
- See Also:
- Constant Field Values
-
RLM
public static final char RLM
- See Also:
- Constant Field Values
-
PDF
public static final char PDF
- See Also:
- Constant Field Values
-
-
Method Detail
-
inRange
public static boolean inRange(@Nonnull char[] aChars, char cLow, char cHigh)
- Parameters:
aChars- char arraycLow- Low indexcHigh- high index- Returns:
trueif all the characters in chars are within the set [low,high]
-
inRange
public static boolean inRange(char[] aChars, int nLow, int nHigh)- Parameters:
aChars- char arraynLow- Low indexnHigh- high index- Returns:
trueif all the characters in chars are within the set [low,high]
-
inRange
public static boolean inRange(int nCodepoint, int nLow, int nHigh)- Parameters:
nCodepoint- codepointnLow- Low indexnHigh- high index- Returns:
trueif the codepoint is within the set [low,high]
-
getHighSurrogate
public static char getHighSurrogate(int nCodepoint)
- Parameters:
nCodepoint- Codepoint- Returns:
- Get the high surrogate for a particular unicode codepoint
-
getLowSurrogate
public static char getLowSurrogate(int nCodepoint)
- Parameters:
nCodepoint- Codepoint- Returns:
- Get the low surrogate for a particular unicode codepoint
-
codepointAt
@Nonnull public static Codepoint codepointAt(@Nonnull CharSequence aSeq, int nIndex)
- Parameters:
aSeq- source sequencenIndex- index- Returns:
- the codepoint at the given location, automatically dealing with surrogate pairs
-
insert
public static void insert(CharSequence aSeq, int nIndex, @Nonnull Codepoint aCodepoint)
Insert a codepoint into the buffer, automatically dealing with surrogate pairs- Parameters:
aSeq- source sequencenIndex- indexaCodepoint- codepoint to be inserted
-
insert
public static void insert(@Nonnull CharSequence aSeq, int nIndex, int nCodepoint)
Insert a codepoint into the buffer, automatically dealing with surrogate pairs- Parameters:
aSeq- source sequencenIndex- indexnCodepoint- codepoint to be inserted
-
setChar
public static void setChar(@Nonnull CharSequence aSeq, int nIndex, @Nonnull Codepoint aCodepoint)
Set the character at a given location, automatically dealing with surrogate pairs- Parameters:
aSeq- source sequencenIndex- indexaCodepoint- codepoint to be set
-
setChar
public static void setChar(@Nonnull CharSequence aSeq, int nIndex, int nCodepoint)
Set the character at a given location, automatically dealing with surrogate pairs- Parameters:
aSeq- source sequencenIndex- indexnCodepoint- codepoint to be set
-
length
@Nonnegative public static int length(@Nonnull CharSequence aSeq)
- Parameters:
aSeq- source sequence- Returns:
- the total number of codepoints in the buffer. Each surrogate pair counts as a single codepoint
-
length
@Nonnegative public static int length(@Nonnull char[] aArray)
- Parameters:
aArray- source array- Returns:
- the total number of codepoints in the buffer. Each surrogate pair counts as a single codepoint
-
length
@Nonnegative public static int length(@Nonnull AbstractCodepointIterator aIter)
-
getAsString
@Nonnull @Nonempty public static String getAsString(int nCodepoint)
- Parameters:
nCodepoint- codepoint- Returns:
- the String representation of the codepoint, automatically dealing with surrogate pairs
-
stripBidi
@Nullable public static String stripBidi(@Nullable String sStr)
Removes leading and trailing bidi controls from the string- Parameters:
sStr- Source string- Returns:
- the modified string
-
stripBidiInternal
@Nonnull public static String stripBidiInternal(@Nonnull String sStr)
Removes bidi controls from within a string- Parameters:
sStr- Source string- Returns:
- the modified string
-
wrapBidi
@Nullable public static String wrapBidi(@Nullable String sStr, char cChar)
Wrap the string with the specified bidi control- Parameters:
sStr- source stringcChar- source char- Returns:
- The wrapped string
-
isHex
public static boolean isHex(int nCodepoint)
-
isBidi
public static boolean isBidi(int nCodepoint)
- Parameters:
nCodepoint- codepoint- Returns:
trueif the codepoint is a bidi control character
-
getIndex
@CheckForSigned public static int getIndex(@Nonnull int[] aCodepointSet, int nValue)
-
inverseSetContains
public static boolean inverseSetContains(@Nonnull int[] aCodepointSet, int value)
Treats the specified int array as an Inversion Set and returnstrueif the value is located within the set. This will only work correctly if the values in the int array are monotonically increasing- Parameters:
aCodepointSet- Source setvalue- Value to check- Returns:
trueif the value is located within the set
-
isPctEnc
public static boolean isPctEnc(int codepoint)
-
isMark
public static boolean isMark(int codepoint)
-
isUnreserved
public static boolean isUnreserved(int codepoint)
-
isReserved
public static boolean isReserved(int codepoint)
-
isGenDelim
public static boolean isGenDelim(int codepoint)
-
isSubDelim
public static boolean isSubDelim(int codepoint)
-
isPchar
public static boolean isPchar(int codepoint)
-
isPath
public static boolean isPath(int codepoint)
-
isPathNoDelims
public static boolean isPathNoDelims(int codepoint)
-
isScheme
public static boolean isScheme(int codepoint)
-
isUserInfo
public static boolean isUserInfo(int codepoint)
-
isQuery
public static boolean isQuery(int codepoint)
-
isFragment
public static boolean isFragment(int codepoint)
-
is_ucschar
public static boolean is_ucschar(int codepoint)
-
is_iprivate
public static boolean is_iprivate(int codepoint)
-
is_iunreserved
public static boolean is_iunreserved(int codepoint)
-
is_ipchar
public static boolean is_ipchar(int codepoint)
-
is_ipath
public static boolean is_ipath(int codepoint)
-
is_ipathnodelims
public static boolean is_ipathnodelims(int codepoint)
-
is_iquery
public static boolean is_iquery(int codepoint)
-
is_ifragment
public static boolean is_ifragment(int codepoint)
-
is_iregname
public static boolean is_iregname(int codepoint)
-
is_ipliteral
public static boolean is_ipliteral(int codepoint)
-
is_ihost
public static boolean is_ihost(int codepoint)
-
is_regname
public static boolean is_regname(int codepoint)
-
is_iuserinfo
public static boolean is_iuserinfo(int codepoint)
-
is_iserver
public static boolean is_iserver(int codepoint)
-
verify
public static void verify(AbstractCodepointIterator aIter, IntPredicate aFilter)
Verifies a sequence of codepoints using the specified filter- Parameters:
aIter- Codepointer iteratoraFilter- filter
-
verify
public static void verify(AbstractCodepointIterator aIter, @Nonnull ECodepointProfile eProfile)
Verifies a sequence of codepoints using the specified filter- Parameters:
aIter- codepoint iteratoreProfile- profile to use
-
verify
public static void verify(@Nullable char[] aArray, @Nonnull ECodepointProfile eProfile)
Verifies a sequence of codepoints using the specified profile- Parameters:
aArray- char arrayeProfile- profile to use
-
verify
public static void verify(@Nullable String sStr, @Nonnull ECodepointProfile eProfile)
Verifies a sequence of codepoints using the specified profile- Parameters:
sStr- StringeProfile- profile to use
-
verifyNot
public static void verifyNot(ICodepointIterator aIter, IntPredicate aFilter)
Verifies a sequence of codepoints using the specified filter- Parameters:
aIter- Codepoint iteratoraFilter- Filter to use
-
verifyNot
public static void verifyNot(ICodepointIterator aIter, @Nonnull ECodepointProfile eProfile)
Verifies a sequence of codepoints using the specified profile- Parameters:
aIter- Codepoint iteratoreProfile- profile to use
-
verifyNot
public static void verifyNot(char[] aArray, @Nonnull ECodepointProfile eProfile)Verifies a sequence of codepoints using the specified profile- Parameters:
aArray- char arrayeProfile- profile to use
-
-