Class Codepoint
- java.lang.Object
-
- com.helger.commons.text.codepoint.Codepoint
-
- All Implemented Interfaces:
IComparable<Codepoint>,Comparable<Codepoint>
@NotThreadSafe public class Codepoint extends Object implements IComparable<Codepoint>
Represents a single Unicode Codepoint- Author:
- Apache Abdera, Philip Helger
-
-
Constructor Summary
Constructors Modifier Constructor Description Codepoint(byte[] aBytes, Charset aEncoding)Create a Codepoint from a byte array with the specified charset encoding.Codepoint(char cChar)Create a codepoint from a single charCodepoint(char[] aChars)Create a Codepoint from a char array.Codepoint(char cHigh, char cLow)Create a codepoint from a surrogate pairCodepoint(int nValue)Create a codepoint from a specific integer valueprotectedCodepoint(int nValue, boolean bDummyUnchecked)Special protected constructor that allows creating special codepoints that are invalid.Codepoint(Codepoint aCodepoint)Create a codepoint as a copy of another codepointCodepoint(CharSequence aCS)Create a Codepoint from a CharSequence.Codepoint(String sValue)Create a Codepoint from a String.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendTo(StringBuilder aSB)intcompareTo(Codepoint o)booleanequals(Object o)byte[]getAsBytes(Charset aCharset)char[]getAsChars()StringgetAsString()intgetCharCount()chargetHighSurrogate()chargetLowSurrogate()intgetPlane()Plane 0 (0000–FFFF): Basic Multilingual Plane (BMP).intgetValue()inthashCode()booleanisAlpha()booleanisAlphaDigit()booleanisBidi()booleanisDigit()booleanisHighSurrogate()booleanisLowSurrogate()booleanisSupplementary()Codepointnext()Codepointprevious()StringtoString()
-
-
-
Constructor Detail
-
Codepoint
public Codepoint(@Nonnull byte[] aBytes, @Nonnull Charset aEncoding)
Create a Codepoint from a byte array with the specified charset encoding. Length must equal 1- Parameters:
aBytes- BytesaEncoding- Charset
-
Codepoint
public Codepoint(@Nonnull CharSequence aCS)
Create a Codepoint from a CharSequence. Length must equal 1 or 2- Parameters:
aCS-CharSequence
-
Codepoint
public Codepoint(@Nonnull String sValue)
Create a Codepoint from a String. Length must equal 1 or 2- Parameters:
sValue- String
-
Codepoint
public Codepoint(@Nonnull char[] aChars)
Create a Codepoint from a char array. Length must equal 1 or 2- Parameters:
aChars- char array
-
Codepoint
public Codepoint(char cChar)
Create a codepoint from a single char- Parameters:
cChar- single char
-
Codepoint
public Codepoint(char cHigh, char cLow)Create a codepoint from a surrogate pair- Parameters:
cHigh- high surrogatecLow- low surrogate
-
Codepoint
public Codepoint(@Nonnull Codepoint aCodepoint)
Create a codepoint as a copy of another codepoint- Parameters:
aCodepoint- Object to copy
-
Codepoint
public Codepoint(@Nonnegative int nValue)
Create a codepoint from a specific integer value- Parameters:
nValue- int value
-
Codepoint
protected Codepoint(@Nonnegative int nValue, boolean bDummyUnchecked)
Special protected constructor that allows creating special codepoints that are invalid.- Parameters:
nValue- The codepoint value to be used. Must not be a valid codepoint.bDummyUnchecked- Dummy parameter to create a different signature
-
-
Method Detail
-
getValue
@Nonnegative public final int getValue()
- Returns:
- The codepoint value
-
isSupplementary
public final boolean isSupplementary()
- Returns:
trueif this codepoint is supplementary (> 0xffff)
-
isLowSurrogate
public final boolean isLowSurrogate()
- Returns:
trueif this codepoint is a low surrogate
-
isHighSurrogate
public final boolean isHighSurrogate()
- Returns:
trueif this codepoint is a high surrogate
-
getHighSurrogate
public final char getHighSurrogate()
- Returns:
- Get the high surrogate of this Codepoint
-
getLowSurrogate
public final char getLowSurrogate()
- Returns:
- Get the low surrogate of this Codepoint
-
isBidi
public boolean isBidi()
- Returns:
trueif this Codepoint is a bidi control char
-
isDigit
public boolean isDigit()
-
isAlpha
public boolean isAlpha()
-
isAlphaDigit
public boolean isAlphaDigit()
-
getAsChars
@Nonnull @ReturnsMutableCopy public char[] getAsChars()
-
getCharCount
@Nonnegative public int getCharCount()
- Returns:
- The number of chars necessary to represent this codepoint. Returns 2 if this is a supplementary codepoint, 1 otherwise.
-
getPlane
public final int getPlane()
Plane 0 (0000–FFFF): Basic Multilingual Plane (BMP). This is the plane containing most of the character assignments so far. A primary objective for the BMP is to support the unification of prior character sets as well as characters for writing systems in current use.
Plane 1 (10000–1FFFF): Supplementary Multilingual Plane (SMP).
Plane 2 (20000–2FFFF): Supplementary Ideographic Plane (SIP)
Planes 3 to 13 (30000–DFFFF) are unassigned
Plane 14 (E0000–EFFFF): Supplementary Special-purpose Plane (SSP)
Plane 15 (F0000–FFFFF) reserved for the Private Use Area (PUA)
Plane 16 (100000–10FFFF), reserved for the Private Use Area (PUA)- Returns:
- Plane number
-
appendTo
public void appendTo(@Nonnull StringBuilder aSB)
-
compareTo
public int compareTo(@Nonnull Codepoint o)
- Specified by:
compareToin interfaceComparable<Codepoint>
-
-