org.foray.common
Class UnicodeChar

java.lang.Object
  extended by org.foray.common.UnicodeChar

public final class UnicodeChar
extends Object

Utility class for various Unicode-related character computations.


Method Summary
static int firstPrintable(char[] inputChars)
          Finds the first printable Unicode code point in a given array of chars.
static int firstPrintable(CharSequence inputChars)
          Finds the first printable Unicode code point in a given array of chars.
static boolean isPrintable(int codePoint)
          Indicates whether a given Unicode code point is printable.
static boolean isValidUnparsedCodePoint(String unparsed)
          Indicates whether a given string is a valid unparsed Unicode code point, that is, a string in the form "U+nnnn" where "nnnn" represents a string of 1 to 5 hex characters (0-9, a-z, A-Z).
static int parseCodePoint(String unparsed)
          Parses a Unicode codepoint from a given String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

firstPrintable

public static int firstPrintable(char[] inputChars)
Finds the first printable Unicode code point in a given array of chars. "Printable" for this purpose is defined as a code point that would require a glyph.

Parameters:
inputChars - The array of chars to be checked.
Returns:
The first printable Unicode code point in the array, or WKConstants.INVALID_UNICODE_CHARACTER if there is no printable code point.

firstPrintable

public static int firstPrintable(CharSequence inputChars)
Finds the first printable Unicode code point in a given array of chars. "Printable" for this purpose is defined as a code point that would require a glyph.

Parameters:
inputChars - The array of chars to be checked.
Returns:
The first printable Unicode code point in the array, or WKConstants.INVALID_UNICODE_CHARACTER if there is no printable code point.

isPrintable

public static boolean isPrintable(int codePoint)
Indicates whether a given Unicode code point is printable. "Printable" for this purpose is defined as a code point that would require a glyph.

Parameters:
codePoint - The Unicode code point to be tested.
Returns:
True iff the given code point is printable.

isValidUnparsedCodePoint

public static boolean isValidUnparsedCodePoint(String unparsed)
Indicates whether a given string is a valid unparsed Unicode code point, that is, a string in the form "U+nnnn" where "nnnn" represents a string of 1 to 5 hex characters (0-9, a-z, A-Z).

Parameters:
unparsed - The unparsed String to be tested.
Returns:
True iff unparsed is a valid Unicode value String.

parseCodePoint

public static int parseCodePoint(String unparsed)
Parses a Unicode codepoint from a given String.

Parameters:
unparsed - The unparsed String, which must be in the form of "U+nnnn", where "nnnn" is from 1 to 4 hex digits representing the codepoint. If not in the propert form, throws an IllegalArgumentException. Use isValidUnparsedCodePoint(String) to test for this condition first.
Returns:
The Unicode code point.


Copyright © 2017. All rights reserved.