com.vgrs.xcode.common
Class Unicode

java.lang.Object
  extended by com.vgrs.xcode.common.Unicode

public class Unicode
extends java.lang.Object

A class that provides algorithms to encode/decode a UTF 16 to/from Unicode.


Field Summary
static int MAX
          This is the maximum value a Unicode codepoint can assume.
static int MIN
          This is the minumum value a Unicode codepoint can assume.
 
Constructor Summary
Unicode()
           
 
Method Summary
static void assertValid(int aInput)
          Assert that the specified value is a Unicode codepoint
static void assertValid(int[] aInput)
          Assert that the specified values are Unicode codepoints
static void assertValid(Range aRange)
          Assert that the specified values are Unicode codepoints
static char[] decode(int aInput)
          Convert one unicode to two characters
static char[] decode(int[] aInput)
          Decode a sequence of unicode to a character sequence
static int[] encode(char[] aInput)
          Encode a character sequence to an array of unicode
static int encode(char aHigh, char aLow)
          Convert two characters to one unicode.
static boolean isValid(int aInput)
          Assert that the specified value is a Unicode codepoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX

public static final int MAX
This is the maximum value a Unicode codepoint can assume.
This variable is hard-coded with the value 0x10ffff.

See Also:
Constant Field Values

MIN

public static final int MIN
This is the minumum value a Unicode codepoint can assume.
This variable is hard-coded with the value 0.

See Also:
Constant Field Values
Constructor Detail

Unicode

public Unicode()
Method Detail

assertValid

public static void assertValid(int aInput)
                        throws XcodeException
Assert that the specified value is a Unicode codepoint

Parameters:
aInput - A potential Unicode value
Throws:
XcodeException - if the input is not a Unicode codepoint.

assertValid

public static void assertValid(int[] aInput)
                        throws XcodeException
Assert that the specified values are Unicode codepoints

Parameters:
aInput - An array of potential Unicode values
Throws:
XcodeException - if any input value is not a Unicode codepoint.

assertValid

public static void assertValid(Range aRange)
                        throws XcodeException
Assert that the specified values are Unicode codepoints

Parameters:
aRange - An array of potential Unicode values contained within the given range.
Throws:
XcodeException - if any input value is not a Unicode codepoint.

decode

public static char[] decode(int aInput)
                     throws XcodeException
Convert one unicode to two characters

Parameters:
aInput - a unicode value
Returns:
A surrogate pair comprised of two 16-bit surrogate values.
Throws:
XcodeException

decode

public static char[] decode(int[] aInput)
                     throws XcodeException
Decode a sequence of unicode to a character sequence

Parameters:
aInput - array of unicode
Returns:
a character sequence
Throws:
XcodeException - if the array of unicode is null or empty

encode

public static int encode(char aHigh,
                         char aLow)
Convert two characters to one unicode.

Parameters:
aHigh - The character serves as high 8 bits of a unicode
aLow - The character serves as low 8 bits of a unicode
Returns:
a unicode

encode

public static int[] encode(char[] aInput)
                    throws XcodeException
Encode a character sequence to an array of unicode

Parameters:
aInput - a character sequence
Returns:
array of unicode
Throws:
XcodeException - if the input array is null or empty

isValid

public static boolean isValid(int aInput)
Assert that the specified value is a Unicode codepoint

Parameters:
aInput - A potential Unicode value


Copyright © 2000-2010 VeriSign Inc. All Rights Reserved