summaryrefslogtreecommitdiffstats
path: root/icu/src/main/native
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-03-26 14:46:11 -0700
committerElliott Hughes <enh@google.com>2010-03-26 16:05:02 -0700
commitebe438a0734f24ded1772778e5e712c820981234 (patch)
tree16344c6334deeeb6dd7f3f56565d3f1aa38c3fde /icu/src/main/native
parentbcf7c66e617ad0c33bb320184bb2401def517342 (diff)
downloadlibcore-ebe438a0734f24ded1772778e5e712c820981234.zip
libcore-ebe438a0734f24ded1772778e5e712c820981234.tar.gz
libcore-ebe438a0734f24ded1772778e5e712c820981234.tar.bz2
Java 6 changed CollationKey from final to abstract.
I've also taken the opportunity to tidy up our implementation a little, though my hands are tied by (a) the fact that our concrete classes are in a separate package from our abstract classes and (b) frameworks/base actually pokes about with our icu4jni collation code (http://b/2417080). I've also tidied up a bunch of dead code. In particular, it's silly for us to check parameters in Java that will be checked in native code (and that one would assume will be valid most of the time anyway). Bug: 1635883 Change-Id: I7db3c1ff1f0d23cb85604f9c8eb995e4488d7c0a
Diffstat (limited to 'icu/src/main/native')
-rw-r--r--icu/src/main/native/NativeCollation.cpp53
1 files changed, 13 insertions, 40 deletions
diff --git a/icu/src/main/native/NativeCollation.cpp b/icu/src/main/native/NativeCollation.cpp
index 52c1c7c..09f192b 100644
--- a/icu/src/main/native/NativeCollation.cpp
+++ b/icu/src/main/native/NativeCollation.cpp
@@ -84,31 +84,16 @@ static jint compare(JNIEnv *env, jclass obj, jint address,
return result;
}
-/**
-* Universal attribute getter
-* @param env JNI environment
-* @param obj RuleBasedCollatorJNI object
-* @param address address of the C collator
-* @param type type of attribute to be set
-* @return attribute value
-* @exception thrown when error occurs while getting attribute value
-*/
-static jint getAttribute(JNIEnv *env, jclass obj, jint address,
- jint type) {
-
+static jint getAttribute(JNIEnv *env, jclass, jint address, jint type) {
const UCollator *collator = (const UCollator *)(int)address;
- UErrorCode status = U_ZERO_ERROR;
- if(collator){
- jint result = (jint)ucol_getAttribute(collator, (UColAttribute)type,
- &status);
- if (icu4jni_error(env, status) != FALSE){
- return (jint)UCOL_DEFAULT;
- }
- return result;
- }else{
- icu4jni_error(env,U_ILLEGAL_ARGUMENT_ERROR);
+ if (!collator) {
+ icu4jni_error(env, U_ILLEGAL_ARGUMENT_ERROR);
+ return 0;
}
- return (jint)UCOL_DEFAULT;
+ UErrorCode status = U_ZERO_ERROR;
+ jint result = (jint)ucol_getAttribute(collator, (UColAttribute)type, &status);
+ icu4jni_error(env, status);
+ return result;
}
/**
@@ -463,23 +448,11 @@ static jint safeClone(JNIEnv *env, jclass obj, jint address) {
return result;
}
-/**
-* Universal attribute setter.
-* @param env JNI environment
-* @param obj RuleBasedCollatorJNI object
-* @param address address of the C collator
-* @param type type of attribute to be set
-* @param value attribute value
-* @exception thrown when error occurs while setting attribute value
-*/
-static void setAttribute(JNIEnv *env, jclass obj, jint address,
- jint type, jint value) {
-
- UCollator *collator = (UCollator *)(int)address;
- UErrorCode status = U_ZERO_ERROR;
- ucol_setAttribute(collator, (UColAttribute)type, (UColAttributeValue)value,
- &status);
- icu4jni_error(env, status);
+static void setAttribute(JNIEnv *env, jclass, jint address, jint type, jint value) {
+ UCollator *collator = (UCollator *)(int)address;
+ UErrorCode status = U_ZERO_ERROR;
+ ucol_setAttribute(collator, (UColAttribute)type, (UColAttributeValue)value, &status);
+ icu4jni_error(env, status);
}
/**