summaryrefslogtreecommitdiffstats
path: root/text/src
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-03-18 18:25:22 -0700
committerElliott Hughes <enh@google.com>2010-03-19 14:29:35 -0700
commit9672b4887f2972c1b7c5f3d1a6cf882deccf857f (patch)
tree281cee3f9379a3f79370ae0ec400ee14d74bd9d0 /text/src
parent69f16dc7ebc4caff5c67245b2ea034dfc5ee4217 (diff)
downloadlibcore-9672b4887f2972c1b7c5f3d1a6cf882deccf857f.zip
libcore-9672b4887f2972c1b7c5f3d1a6cf882deccf857f.tar.gz
libcore-9672b4887f2972c1b7c5f3d1a6cf882deccf857f.tar.bz2
Clean up the Java side of the ICU interface a bit.
My original intention was just to add the missing "final" on a few classes, but our BreakIterator implementation struck me as excessively bloated and confusing. Change-Id: I2d2dccafe8ec91124f3c83909c9ec647cc2d51e2
Diffstat (limited to 'text/src')
-rw-r--r--text/src/main/java/java/text/BreakIterator.java50
-rw-r--r--text/src/main/java/java/text/RuleBasedBreakIterator.java17
2 files changed, 22 insertions, 45 deletions
diff --git a/text/src/main/java/java/text/BreakIterator.java b/text/src/main/java/java/text/BreakIterator.java
index 78870f0..55ef31d 100644
--- a/text/src/main/java/java/text/BreakIterator.java
+++ b/text/src/main/java/java/text/BreakIterator.java
@@ -21,8 +21,8 @@
package java.text;
+import com.ibm.icu4jni.text.NativeBreakIterator;
import java.util.Locale;
-
import org.apache.harmony.text.internal.nls.Messages;
/**
@@ -241,7 +241,7 @@ public abstract class BreakIterator implements Cloneable {
private static final int SHORT_LENGTH = 2;
// the wrapped ICU implementation
- com.ibm.icu4jni.text.BreakIterator wrapped;
+ NativeBreakIterator wrapped;
/**
* Default constructor, just for invocation by a subclass.
@@ -253,7 +253,7 @@ public abstract class BreakIterator implements Cloneable {
/*
* wrapping constructor
*/
- BreakIterator(com.ibm.icu4jni.text.BreakIterator iterator) {
+ BreakIterator(NativeBreakIterator iterator) {
wrapped = iterator;
}
@@ -263,7 +263,7 @@ public abstract class BreakIterator implements Cloneable {
* @return all supported locales.
*/
public static Locale[] getAvailableLocales() {
- return com.ibm.icu4jni.text.BreakIterator.getAvailableLocales();
+ return NativeBreakIterator.getAvailableLocales();
}
/**
@@ -273,8 +273,7 @@ public abstract class BreakIterator implements Cloneable {
* @return a new instance of {@code BreakIterator} using the default locale.
*/
public static BreakIterator getCharacterInstance() {
- return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
- .getCharacterInstance());
+ return getCharacterInstance(Locale.getDefault());
}
/**
@@ -286,12 +285,7 @@ public abstract class BreakIterator implements Cloneable {
* @return a new instance of {@code BreakIterator} using the given locale.
*/
public static BreakIterator getCharacterInstance(Locale where) {
- if (where == null) {
- throw new NullPointerException();
- }
-
- return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
- .getCharacterInstance(where));
+ return new RuleBasedBreakIterator(NativeBreakIterator.getCharacterInstance(where));
}
/**
@@ -301,8 +295,7 @@ public abstract class BreakIterator implements Cloneable {
* @return a new instance of {@code BreakIterator} using the default locale.
*/
public static BreakIterator getLineInstance() {
- return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
- .getLineInstance());
+ return getLineInstance(Locale.getDefault());
}
/**
@@ -315,12 +308,7 @@ public abstract class BreakIterator implements Cloneable {
* @throws NullPointerException if {@code where} is {@code null}.
*/
public static BreakIterator getLineInstance(Locale where) {
- if (where == null) {
- throw new NullPointerException();
- }
-
- return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
- .getLineInstance(where));
+ return new RuleBasedBreakIterator(NativeBreakIterator.getLineInstance(where));
}
/**
@@ -330,8 +318,7 @@ public abstract class BreakIterator implements Cloneable {
* @return a new instance of {@code BreakIterator} using the default locale.
*/
public static BreakIterator getSentenceInstance() {
- return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
- .getSentenceInstance());
+ return getSentenceInstance(Locale.getDefault());
}
/**
@@ -344,12 +331,7 @@ public abstract class BreakIterator implements Cloneable {
* @throws NullPointerException if {@code where} is {@code null}.
*/
public static BreakIterator getSentenceInstance(Locale where) {
- if (where == null) {
- throw new NullPointerException();
- }
-
- return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
- .getSentenceInstance(where));
+ return new RuleBasedBreakIterator(NativeBreakIterator.getSentenceInstance(where));
}
/**
@@ -359,8 +341,7 @@ public abstract class BreakIterator implements Cloneable {
* @return a new instance of {@code BreakIterator} using the default locale.
*/
public static BreakIterator getWordInstance() {
- return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
- .getWordInstance());
+ return getWordInstance(Locale.getDefault());
}
/**
@@ -373,12 +354,7 @@ public abstract class BreakIterator implements Cloneable {
* @throws NullPointerException if {@code where} is {@code null}.
*/
public static BreakIterator getWordInstance(Locale where) {
- if (where == null) {
- throw new NullPointerException();
- }
-
- return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
- .getWordInstance(where));
+ return new RuleBasedBreakIterator(NativeBreakIterator.getWordInstance(where));
}
/**
@@ -521,7 +497,7 @@ public abstract class BreakIterator implements Cloneable {
public Object clone() {
try {
BreakIterator cloned = (BreakIterator) super.clone();
- cloned.wrapped = (com.ibm.icu4jni.text.BreakIterator) wrapped.clone();
+ cloned.wrapped = (NativeBreakIterator) wrapped.clone();
return cloned;
} catch (CloneNotSupportedException e) {
throw new AssertionError(e); // android-changed
diff --git a/text/src/main/java/java/text/RuleBasedBreakIterator.java b/text/src/main/java/java/text/RuleBasedBreakIterator.java
index 2ca6f9b..ed8a7c1 100644
--- a/text/src/main/java/java/text/RuleBasedBreakIterator.java
+++ b/text/src/main/java/java/text/RuleBasedBreakIterator.java
@@ -21,17 +21,20 @@
package java.text;
+import com.ibm.icu4jni.text.NativeBreakIterator;
+
/*
- * Default implementation of BreakIterator, wrap
- * com.ibm.icu4jni.text.RuleBasedBreakIterator
- *
+ * Default implementation of BreakIterator. Wraps com.ibm.icu4jni.text.NativeBreakIterator.
+ * We need this because BreakIterator.isBoundary and BreakIterator.preceding are non-abstract,
+ * and we don't have Java implementations of those methods (other than the current ones, which
+ * forward to the wrapped NativeBreakIterator).
*/
class RuleBasedBreakIterator extends BreakIterator {
/*
- * Wrapping construction
+ * Wrapping constructor.
*/
- RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator iterator) {
+ RuleBasedBreakIterator(NativeBreakIterator iterator) {
super(iterator);
}
@@ -201,9 +204,7 @@ class RuleBasedBreakIterator extends BreakIterator {
@Override
public Object clone() {
RuleBasedBreakIterator cloned = (RuleBasedBreakIterator) super.clone();
- cloned.wrapped = (com.ibm.icu4jni.text.RuleBasedBreakIterator) wrapped
- .clone();
+ cloned.wrapped = (NativeBreakIterator) wrapped.clone();
return cloned;
}
-
}