Class TextUtil


  • public final class TextUtil
    extends java.lang.Object
    This file is a helper class for internal usage only. Be aware that its API and functionality may be changed in future.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private TextUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean charsetIsSupported​(java.lang.String charsetName)  
      static java.lang.String charToString​(char ch)  
      static char[] convertFromUtf32​(int codePoint)
      Converts a UTF32 code point value to a char array with the corresponding character(s).
      static java.lang.String convertFromUtf32​(int[] text, int startPos, int endPos)
      /** Converts a UTF32 code point sequence to a String with the corresponding character(s).
      static char[] convertFromUtf32ToCharArray​(int codePoint)
      Converts a UTF32 code point value to a char array with the corresponding character(s).
      static int convertToUtf32​(char[] text, int idx)
      Converts a unicode character in a character array to a UTF 32 code point value.
      static int convertToUtf32​(char highSurrogate, char lowSurrogate)
      Returns the code point of a UTF32 character corresponding with a high and a low surrogate value.
      static int[] convertToUtf32​(java.lang.String text)  
      static int convertToUtf32​(java.lang.String text, int idx)
      Converts a unicode character in a String to a UTF32 code point value
      static char highSurrogate​(int codePoint)  
      static boolean isCarriageReturnFollowedByLineFeed​(GlyphLine glyphLine, int carriageReturnPosition)  
      static boolean isDiacritic​(int codePoint)
      Checks if the passed code point corresponds to diacritic.
      static boolean isLetterOrDigit​(Glyph glyph)  
      static boolean isMark​(Glyph glyph)  
      static boolean isNewLine​(char c)
      Check if a character is a newline by checking if it's integer value is a newline in unicode
      static boolean isNewLine​(int unicode)
      Check if a character is a newline by checking if it's integer value is a newline in unicode
      static boolean isNewLine​(Glyph glyph)
      Check if a glyph is a newline by checking if it's unicode value is a newline
      static boolean isNonBreakingHyphen​(Glyph glyph)  
      static boolean isNonPrintable​(int c)  
      static boolean isSpace​(Glyph glyph)  
      static boolean isSpaceOrWhitespace​(Glyph glyph)  
      static boolean isSurrogateHigh​(char c)
      Check if the value of a character belongs to a certain interval that indicates it's the higher part of a surrogate pair.
      static boolean isSurrogateLow​(char c)
      Check if the value of a character belongs to a certain interval that indicates it's the lower part of a surrogate pair.
      static boolean isSurrogatePair​(char[] text, int idx)
      Checks if two subsequent characters in a character array are the higher and the lower character in a surrogate pair (and therefore eligible for conversion to a UTF 32 character).
      static boolean isSurrogatePair​(java.lang.String text, int idx)
      Checks if two subsequent characters in a String are the higher and the lower character in a surrogate pair (and therefore eligible for conversion to a UTF 32 character).
      static boolean isUni0020​(Glyph g)  
      static boolean isWhitespace​(Glyph glyph)  
      static boolean isWhitespaceOrNonPrintable​(int code)  
      static char lowSurrogate​(int codePoint)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TextUtil

        private TextUtil()
    • Method Detail

      • isDiacritic

        public static boolean isDiacritic​(int codePoint)
        Checks if the passed code point corresponds to diacritic.
        Parameters:
        codePoint - the code point to check
        Returns:
        true if passed code point is diacritic, false otherwise
      • isSurrogateHigh

        public static boolean isSurrogateHigh​(char c)
        Check if the value of a character belongs to a certain interval that indicates it's the higher part of a surrogate pair.
        Parameters:
        c - the character
        Returns:
        true if the character belongs to the interval
      • isSurrogateLow

        public static boolean isSurrogateLow​(char c)
        Check if the value of a character belongs to a certain interval that indicates it's the lower part of a surrogate pair.
        Parameters:
        c - the character
        Returns:
        true if the character belongs to the interval
      • highSurrogate

        public static char highSurrogate​(int codePoint)
      • lowSurrogate

        public static char lowSurrogate​(int codePoint)
      • isSurrogatePair

        public static boolean isSurrogatePair​(java.lang.String text,
                                              int idx)
        Checks if two subsequent characters in a String are the higher and the lower character in a surrogate pair (and therefore eligible for conversion to a UTF 32 character).
        Parameters:
        text - the String with the high and low surrogate characters
        idx - the index of the 'high' character in the pair
        Returns:
        true if the characters are surrogate pairs
      • isSurrogatePair

        public static boolean isSurrogatePair​(char[] text,
                                              int idx)
        Checks if two subsequent characters in a character array are the higher and the lower character in a surrogate pair (and therefore eligible for conversion to a UTF 32 character).
        Parameters:
        text - the character array with the high and low surrogate characters
        idx - the index of the 'high' character in the pair
        Returns:
        true if the characters are surrogate pairs
      • convertToUtf32

        public static int convertToUtf32​(char highSurrogate,
                                         char lowSurrogate)
        Returns the code point of a UTF32 character corresponding with a high and a low surrogate value.
        Parameters:
        highSurrogate - the high surrogate value
        lowSurrogate - the low surrogate value
        Returns:
        a code point value
      • convertToUtf32

        public static int convertToUtf32​(char[] text,
                                         int idx)
        Converts a unicode character in a character array to a UTF 32 code point value.
        Parameters:
        text - a character array that has the unicode character(s)
        idx - the index of the 'high' character
        Returns:
        the code point value
      • convertToUtf32

        public static int convertToUtf32​(java.lang.String text,
                                         int idx)
        Converts a unicode character in a String to a UTF32 code point value
        Parameters:
        text - a String that has the unicode character(s)
        idx - the index of the 'high' character
        Returns:
        the codepoint value
      • convertToUtf32

        public static int[] convertToUtf32​(java.lang.String text)
      • convertFromUtf32

        public static char[] convertFromUtf32​(int codePoint)
        Converts a UTF32 code point value to a char array with the corresponding character(s).
        Parameters:
        codePoint - a Unicode value
        Returns:
        the corresponding char array
      • convertFromUtf32

        public static java.lang.String convertFromUtf32​(int[] text,
                                                        int startPos,
                                                        int endPos)
        /** Converts a UTF32 code point sequence to a String with the corresponding character(s).
        Parameters:
        text - a Unicode text sequence
        startPos - start position of text to convert, inclusive
        endPos - end position of txt to convert, exclusive
        Returns:
        the corresponding characters in a String
      • convertFromUtf32ToCharArray

        public static char[] convertFromUtf32ToCharArray​(int codePoint)
        Converts a UTF32 code point value to a char array with the corresponding character(s).
        Parameters:
        codePoint - a Unicode value
        Returns:
        the corresponding characters in a char arrat
      • charToString

        public static java.lang.String charToString​(char ch)
      • isNewLine

        public static boolean isNewLine​(Glyph glyph)
        Check if a glyph is a newline by checking if it's unicode value is a newline
        Parameters:
        glyph - glyph to check
        Returns:
        True if the glyph represents a newline, false otherwise
      • isNewLine

        public static boolean isNewLine​(char c)
        Check if a character is a newline by checking if it's integer value is a newline in unicode
        Parameters:
        c - character to check
        Returns:
        True if the character represents a newline, false otherwise
      • isNewLine

        public static boolean isNewLine​(int unicode)
        Check if a character is a newline by checking if it's integer value is a newline in unicode
        Parameters:
        unicode - unicode value to check
        Returns:
        True if the character represents a newline, false otherwise
      • isCarriageReturnFollowedByLineFeed

        public static boolean isCarriageReturnFollowedByLineFeed​(GlyphLine glyphLine,
                                                                 int carriageReturnPosition)
      • isSpaceOrWhitespace

        public static boolean isSpaceOrWhitespace​(Glyph glyph)
      • isWhitespace

        public static boolean isWhitespace​(Glyph glyph)
      • isNonBreakingHyphen

        public static boolean isNonBreakingHyphen​(Glyph glyph)
      • isSpace

        public static boolean isSpace​(Glyph glyph)
      • isUni0020

        public static boolean isUni0020​(Glyph g)
      • isNonPrintable

        public static boolean isNonPrintable​(int c)
      • isWhitespaceOrNonPrintable

        public static boolean isWhitespaceOrNonPrintable​(int code)
      • isLetterOrDigit

        public static boolean isLetterOrDigit​(Glyph glyph)
      • isMark

        public static boolean isMark​(Glyph glyph)
      • charsetIsSupported

        public static boolean charsetIsSupported​(java.lang.String charsetName)