Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
libcore
Commits
b6e8336a
Commit
b6e8336a
authored
11 years ago
by
Elliott Hughes
Committed by
Gerrit Code Review
11 years ago
Browse files
Options
Download
Plain Diff
Merge "Implement Character.isAlphabetic and Character.isIdeographic."
parents
9642a650
2d99feb3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
+41
-0
luni/src/main/java/java/lang/Character.java
luni/src/main/java/java/lang/Character.java
+13
-0
luni/src/main/native/java_lang_Character.cpp
luni/src/main/native/java_lang_Character.cpp
+10
-0
luni/src/test/java/libcore/java/lang/CharacterTest.java
luni/src/test/java/libcore/java/lang/CharacterTest.java
+18
-0
No files found.
luni/src/main/java/java/lang/Character.java
View file @
b6e8336a
...
...
@@ -2594,6 +2594,13 @@ public final class Character implements Serializable, Comparable<Character> {
return
(
char
)
((
codePoint
&
0x3ff
)
|
0xdc00
);
}
/**
* Returns true if the given code point is alphabetic. That is,
* if it is in any of the Lu, Ll, Lt, Lm, Lo, Nl, or Other_Alphabetic categories.
* @since 1.7
*/
public
static
native
boolean
isAlphabetic
(
int
codePoint
);
/**
* Returns true if the given code point is in the Basic Multilingual Plane (BMP).
* Such code points can be represented by a single {@code char}.
...
...
@@ -2676,6 +2683,12 @@ public final class Character implements Serializable, Comparable<Character> {
return
isIdentifierIgnorable
((
int
)
c
);
}
/**
* Returns true if the given code point is a CJKV ideographic character.
* @since 1.7
*/
public
static
native
boolean
isIdeographic
(
int
codePoint
);
/**
* Indicates whether the specified code point is ignorable in a Java or
* Unicode identifier.
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/native/java_lang_Character.cpp
View file @
b6e8336a
...
...
@@ -135,6 +135,14 @@ static int Character_ofImpl(JNIEnv*, jclass, jint codePoint) {
return
ublock_getCode
(
codePoint
);
}
static
jboolean
Character_isAlphabetic
(
JNIEnv
*
,
jclass
,
jint
codePoint
)
{
return
u_hasBinaryProperty
(
codePoint
,
UCHAR_ALPHABETIC
);
}
static
jboolean
Character_isIdeographic
(
JNIEnv
*
,
jclass
,
jint
codePoint
)
{
return
u_hasBinaryProperty
(
codePoint
,
UCHAR_IDEOGRAPHIC
);
}
static
JNINativeMethod
gMethods
[]
=
{
NATIVE_METHOD
(
Character
,
digitImpl
,
"!(II)I"
),
NATIVE_METHOD
(
Character
,
forNameImpl
,
"(Ljava/lang/String;)I"
),
...
...
@@ -142,9 +150,11 @@ static JNINativeMethod gMethods[] = {
NATIVE_METHOD
(
Character
,
getNameImpl
,
"(I)Ljava/lang/String;"
),
NATIVE_METHOD
(
Character
,
getNumericValueImpl
,
"!(I)I"
),
NATIVE_METHOD
(
Character
,
getTypeImpl
,
"!(I)I"
),
NATIVE_METHOD
(
Character
,
isAlphabetic
,
"!(I)Z"
),
NATIVE_METHOD
(
Character
,
isDefinedImpl
,
"!(I)Z"
),
NATIVE_METHOD
(
Character
,
isDigitImpl
,
"!(I)Z"
),
NATIVE_METHOD
(
Character
,
isIdentifierIgnorableImpl
,
"!(I)Z"
),
NATIVE_METHOD
(
Character
,
isIdeographic
,
"!(I)Z"
),
NATIVE_METHOD
(
Character
,
isLetterImpl
,
"!(I)Z"
),
NATIVE_METHOD
(
Character
,
isLetterOrDigitImpl
,
"!(I)Z"
),
NATIVE_METHOD
(
Character
,
isLowerCaseImpl
,
"!(I)Z"
),
...
...
This diff is collapsed.
Click to expand it.
luni/src/test/java/libcore/java/lang/CharacterTest.java
View file @
b6e8336a
...
...
@@ -171,4 +171,22 @@ public class CharacterTest extends junit.framework.TestCase {
assertEquals
(
Character
.
UnicodeBlock
.
CYRILLIC_SUPPLEMENTARY
,
Character
.
UnicodeBlock
.
forName
(
"Cyrillic Supplementary"
));
assertEquals
(
Character
.
UnicodeBlock
.
CYRILLIC_SUPPLEMENTARY
,
Character
.
UnicodeBlock
.
forName
(
"Cyrillic Supplement"
));
}
public
void
test_isAlphabetic
()
throws
Exception
{
assertTrue
(
Character
.
isAlphabetic
(
'A'
));
assertTrue
(
Character
.
isAlphabetic
(
'a'
));
assertFalse
(
Character
.
isAlphabetic
(
'1'
));
assertTrue
(
Character
.
isAlphabetic
(
0x113c
));
// Hangul j
}
public
void
test_isIdeographic
()
throws
Exception
{
assertFalse
(
Character
.
isIdeographic
(
'A'
));
assertFalse
(
Character
.
isIdeographic
(
'a'
));
assertFalse
(
Character
.
isIdeographic
(
'1'
));
assertFalse
(
Character
.
isIdeographic
(
0x113c
));
// Hangul j
assertTrue
(
Character
.
isIdeographic
(
0x4db5
));
assertTrue
(
Character
.
isIdeographic
(
0x2f999
));
assertFalse
(
Character
.
isIdeographic
(
0x2f99
));
// Kangxi radical shell
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment