summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/java/lang/Character.java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main/java/java/lang/Character.java')
-rw-r--r--luni/src/main/java/java/lang/Character.java38
1 files changed, 23 insertions, 15 deletions
diff --git a/luni/src/main/java/java/lang/Character.java b/luni/src/main/java/java/lang/Character.java
index 5762bd4..2046ba8 100644
--- a/luni/src/main/java/java/lang/Character.java
+++ b/luni/src/main/java/java/lang/Character.java
@@ -46,7 +46,7 @@ import java.util.Arrays;
* point or a UTF-16 unit that's part of a surrogate pair. The {@code int} type
* is used to represent all Unicode code points.
*
- * <a name="unicode_categories"><h3>Unicode categories</h3></a>
+ * <a name="unicode_categories"></a><h3>Unicode categories</h3>
* <p>Here's a list of the Unicode character categories and the corresponding Java constant,
* grouped semantically to provide a convenient overview. This table is also useful in
* conjunction with {@code \p} and {@code \P} in {@link java.util.regex.Pattern regular expressions}.
@@ -1489,7 +1489,7 @@ public final class Character implements Serializable, Comparable<Character> {
if (blockName == null) {
throw new NullPointerException("blockName == null");
}
- int block = forNameImpl(blockName);
+ int block = unicodeBlockForName(blockName);
if (block == -1) {
throw new IllegalArgumentException("Unknown block: " + blockName);
}
@@ -1510,7 +1510,7 @@ public final class Character implements Serializable, Comparable<Character> {
*/
public static UnicodeBlock of(int codePoint) {
checkValidCodePoint(codePoint);
- int block = ofImpl(codePoint);
+ int block = unicodeBlockForCodePoint(codePoint);
if (block == -1 || block >= BLOCKS.length) {
return null;
}
@@ -1522,9 +1522,14 @@ public final class Character implements Serializable, Comparable<Character> {
}
}
- private static native int forNameImpl(String blockName);
+ private static native int unicodeBlockForName(String blockName);
+
+ private static native int unicodeBlockForCodePoint(int codePoint);
+
+ private static native int unicodeScriptForName(String blockName);
+
+ private static native int unicodeScriptForCodePoint(int codePoint);
- private static native int ofImpl(int codePoint);
/**
* Constructs a new {@code Character} with the specified primitive char
@@ -2525,25 +2530,28 @@ public final class Character implements Serializable, Comparable<Character> {
}
/**
- * Gets the Unicode directionality of the specified character.
- *
- * @param codePoint
- * the Unicode code point to get the directionality of.
- * @return the Unicode directionality of {@code codePoint}.
+ * Returns the Unicode directionality of the given code point.
+ * This will be one of the {@code DIRECTIONALITY_} constants.
+ * For characters whose directionality is undefined, or whose
+ * directionality has no appropriate constant in this class,
+ * {@code DIRECTIONALITY_UNDEFINED} is returned.
*/
public static byte getDirectionality(int codePoint) {
if (getType(codePoint) == Character.UNASSIGNED) {
return Character.DIRECTIONALITY_UNDEFINED;
}
- byte directionality = getDirectionalityImpl(codePoint);
- if (directionality == -1) {
- return -1;
+ byte directionality = getIcuDirectionality(codePoint);
+ if (directionality >= 0 && directionality < DIRECTIONALITY.length) {
+ return DIRECTIONALITY[directionality];
}
- return DIRECTIONALITY[directionality];
+ return Character.DIRECTIONALITY_UNDEFINED;
}
- private static native byte getDirectionalityImpl(int codePoint);
+ /**
+ * @hide - internal use only.
+ */
+ public static native byte getIcuDirectionality(int codePoint);
/**
* Indicates whether the specified character is mirrored.