org.eclipse.ocl.util
Class UnicodeSupport

java.lang.Object
  extended by org.eclipse.ocl.util.UnicodeSupport

public abstract class UnicodeSupport
extends java.lang.Object

A proxy interface to isolate dependencies on the ICU4J library for internationalization/UNICODE support. This enables deployments that delegate to standard Java APIs for text manipulation instead of the large ICU library.

Author:
Christian W. Damus (cdamus)

Method Summary
static int codePointAt(java.lang.StringBuffer buffer, int offset)
          Obtains the code point at the specified 16-bit character offset of a string buffer.
static void setCodePointAt(java.lang.StringBuffer buffer, int offset, int codePoint)
          Sets the code point at the specified 16-bit character offset of a string buffer.
static int shiftCodePointOffsetBy(java.lang.String text, int offset, int shift)
          Obtains the location of the code point shift positions from the specified 16-bit character offset of a string buffer.
static int toLowerCase(int codePoint)
          Converts a UNICODE code point to lower case.
static java.lang.String toLowerCase(java.lang.String text)
          Converts a UNICODE string to lower case.
static int toUpperCase(int codePoint)
          Converts a UNICODE code point to upper case.
static java.lang.String toUpperCase(java.lang.String text)
          Converts a UNICODE string to upper case.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

codePointAt

public static int codePointAt(java.lang.StringBuffer buffer,
                              int offset)
Obtains the code point at the specified 16-bit character offset of a string buffer.

Parameters:
buffer - a string buffer
offset - a 16-bit offset into the string buffer. Must be between 0 (inclusive) and the buffer's length (exclusive)
Returns:
the UNICODE code point at the specified offset

setCodePointAt

public static void setCodePointAt(java.lang.StringBuffer buffer,
                                  int offset,
                                  int codePoint)
Sets the code point at the specified 16-bit character offset of a string buffer. This will lengthen the buffer, in the case that the supplied code point is wider than the one it is replacing.

Parameters:
buffer - a string buffer
offset - a 16-bit offset into the string buffer. Must be between 0 (inclusive) and the buffer's length (exclusive)
codePoint - the new UNICODE code point value to substitute at the specified offset

shiftCodePointOffsetBy

public static int shiftCodePointOffsetBy(java.lang.String text,
                                         int offset,
                                         int shift)
Obtains the location of the code point shift positions from the specified 16-bit character offset of a string buffer.

Parameters:
text - a string of UNICODE text
offset - a 16-bit offset into the string buffer. Must be between 0 (inclusive) and the buffer's length (exclusive)
shift - a positive or negative index, as a count of code points, relative to the code point at the 16-bit offset
Returns:
the 16-bit index of the UNICODE code point at the specified location relative to the offset

toLowerCase

public static int toLowerCase(int codePoint)
Converts a UNICODE code point to lower case.

Parameters:
codePoint - a UNICODE code point
Returns:
the lower case equivalent

toUpperCase

public static int toUpperCase(int codePoint)
Converts a UNICODE code point to upper case.

Parameters:
codePoint - a UNICODE code point
Returns:
the upper case equivalent

toLowerCase

public static java.lang.String toLowerCase(java.lang.String text)
Converts a UNICODE string to lower case.

Parameters:
text - a UNICODE string
Returns:
the lower case equivalent

toUpperCase

public static java.lang.String toUpperCase(java.lang.String text)
Converts a UNICODE string to upper case.

Parameters:
text - a UNICODE string
Returns:
the upper case equivalent