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 Details

    • 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 - Bytes
      aEncoding - 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 surrogate
      cLow - 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 Details

    • getValue

      @Nonnegative public final int getValue()
      Returns:
      The codepoint value
    • isSupplementary

      public final boolean isSupplementary()
      Returns:
      true if this codepoint is supplementary (> 0xffff)
    • isLowSurrogate

      public final boolean isLowSurrogate()
      Returns:
      true if this codepoint is a low surrogate
    • isHighSurrogate

      public final boolean isHighSurrogate()
      Returns:
      true if 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:
      true if this Codepoint is a bidi control char
    • isDigit

      public boolean isDigit()
    • isAlpha

      public boolean isAlpha()
    • isAlphaDigit

      public boolean isAlphaDigit()
    • getAsString

      @Nonnull @Nonempty public String getAsString()
    • 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.
    • getAsBytes

      @Nonnull public byte[] getAsBytes(@Nonnull Charset aCharset)
    • 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
    • next

      @Nonnull public final Codepoint next()
      Returns:
      Get the next codepoint
    • previous

      @Nonnull public final Codepoint previous()
      Returns:
      Get the previous codepoint
    • appendTo

      public void appendTo(@Nonnull StringBuilder aSB)
    • compareTo

      public int compareTo(@Nonnull Codepoint o)
      Specified by:
      compareTo in interface Comparable<Codepoint>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object