summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-12-08 19:19:13 -0800
committerElliott Hughes <enh@google.com>2010-12-08 19:19:13 -0800
commit866e7ae17a3da81a02b0b144e0c9c2b3196d293a (patch)
treed72bc28511f7796290a60b63c732e020d029e29c
parentc8104b0342382481704c6662af33968595ad6ab6 (diff)
downloadlibcore-866e7ae17a3da81a02b0b144e0c9c2b3196d293a.zip
libcore-866e7ae17a3da81a02b0b144e0c9c2b3196d293a.tar.gz
libcore-866e7ae17a3da81a02b0b144e0c9c2b3196d293a.tar.bz2
Fix a bunch of javac -Xlint warnings in our code.
I think "fallthrough" uncovered a couple of real bugs in the kxml code, but other than that there's nothing very exciting here. This addresses all but one of the non-xml warnings. I'm assuming that we'll move the xml cruft out into external at some point (since we're deliberately not maintaining it). Change-Id: Ice81253b019df7b19d6557e719663b7bdc11fb22
-rw-r--r--dalvik/src/main/java/dalvik/system/PathClassLoader.java27
-rw-r--r--dalvik/src/main/java/dalvik/system/VMDebug.java2
-rw-r--r--luni/src/main/java/java/lang/Class.java4
-rw-r--r--luni/src/main/java/java/lang/reflect/AccessibleObject.java10
-rw-r--r--luni/src/main/java/java/security/cert/PKIXParameters.java56
-rw-r--r--luni/src/main/java/java/security/cert/X509CertSelector.java15
-rw-r--r--luni/src/main/java/java/text/RuleBasedCollator.java8
-rw-r--r--luni/src/main/java/java/util/Properties.java24
-rw-r--r--luni/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java2
-rw-r--r--luni/src/main/java/java/util/zip/InflaterInputStream.java2
-rw-r--r--luni/src/main/java/libcore/icu/CharsetDecoderICU.java16
-rw-r--r--luni/src/main/java/libcore/icu/CharsetEncoderICU.java78
-rw-r--r--luni/src/main/java/libcore/icu/CollationElementIteratorICU.java22
-rw-r--r--luni/src/main/java/libcore/icu/NativeBreakIterator.java54
-rw-r--r--luni/src/main/java/libcore/icu/NativeDecimalFormat.java103
-rw-r--r--luni/src/main/java/org/apache/harmony/luni/internal/util/ZoneInfoDB.java4
-rw-r--r--luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java36
-rw-r--r--luni/src/main/java/org/apache/harmony/security/PolicyEntry.java2
-rw-r--r--luni/src/main/java/org/apache/harmony/security/fortress/DefaultPolicy.java7
-rw-r--r--luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_MessageDigestImpl.java9
-rw-r--r--luni/src/main/java/org/apache/harmony/security/x501/AttributeValue.java9
-rw-r--r--luni/src/main/java/org/apache/harmony/security/x501/Name.java3
-rw-r--r--luni/src/main/java/org/apache/harmony/security/x509/DNParser.java6
-rw-r--r--luni/src/main/java/org/apache/harmony/security/x509/Extensions.java18
-rw-r--r--luni/src/main/java/org/apache/harmony/security/x509/ReasonCode.java3
-rw-r--r--xml/src/main/java/org/kxml2/io/KXmlParser.java5
-rw-r--r--xml/src/main/java/org/kxml2/io/KXmlSerializer.java15
27 files changed, 207 insertions, 333 deletions
diff --git a/dalvik/src/main/java/dalvik/system/PathClassLoader.java b/dalvik/src/main/java/dalvik/system/PathClassLoader.java
index 96be57c..850fd4f 100644
--- a/dalvik/src/main/java/dalvik/system/PathClassLoader.java
+++ b/dalvik/src/main/java/dalvik/system/PathClassLoader.java
@@ -25,6 +25,7 @@ import java.io.RandomAccessFile;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.NoSuchElementException;
@@ -278,14 +279,13 @@ public class PathClassLoader extends ClassLoader {
protected Enumeration<URL> findResources(String resName) {
int length = mPaths.length;
ArrayList<URL> results = new ArrayList<URL>();
-
for (int i = 0; i < length; i++) {
URL result = findResource(resName, i);
if(result != null) {
results.add(result);
}
}
- return new EnumerateListArray<URL>(results);
+ return Collections.enumeration(results);
}
private URL findResource(String name, int i) {
@@ -446,32 +446,9 @@ public class PathClassLoader extends ClassLoader {
return pack;
}
}
-
return null;
}
- /*
- * Create an Enumeration for an ArrayList.
- */
- private static class EnumerateListArray<T> implements Enumeration<T> {
- private final ArrayList mList;
- private int i = 0;
-
- EnumerateListArray(ArrayList list) {
- mList = list;
- }
-
- public boolean hasMoreElements() {
- return i < mList.size();
- }
-
- public T nextElement() {
- if (i >= mList.size())
- throw new NoSuchElementException();
- return (T) mList.get(i++);
- }
- };
-
public String toString () {
return getClass().getName() + "[" + path + "]";
}
diff --git a/dalvik/src/main/java/dalvik/system/VMDebug.java b/dalvik/src/main/java/dalvik/system/VMDebug.java
index 1eb589e..1192871 100644
--- a/dalvik/src/main/java/dalvik/system/VMDebug.java
+++ b/dalvik/src/main/java/dalvik/system/VMDebug.java
@@ -36,6 +36,7 @@ public final class VMDebug {
*
* @deprecated only used in one place, which is unused and deprecated
*/
+ @Deprecated
static public final String DEFAULT_METHOD_TRACE_FILE_NAME = "/sdcard/dmtrace.trace";
/**
@@ -145,6 +146,7 @@ public final class VMDebug {
*
* @deprecated not used, not needed
*/
+ @Deprecated
public static void startMethodTracing() {
startMethodTracing(DEFAULT_METHOD_TRACE_FILE_NAME, 0, 0);
}
diff --git a/luni/src/main/java/java/lang/Class.java b/luni/src/main/java/java/lang/Class.java
index 0692850..8ade55d 100644
--- a/luni/src/main/java/java/lang/Class.java
+++ b/luni/src/main/java/java/lang/Class.java
@@ -317,10 +317,10 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe
for (int i = declaredAnnotations.length-1; i >= 0; --i) {
map.put(declaredAnnotations[i].annotationType(), declaredAnnotations[i]);
}
- for (Class sup = getSuperclass(); sup != null; sup = sup.getSuperclass()) {
+ for (Class<?> sup = getSuperclass(); sup != null; sup = sup.getSuperclass()) {
declaredAnnotations = sup.getDeclaredAnnotations();
for (int i = declaredAnnotations.length-1; i >= 0; --i) {
- Class clazz = declaredAnnotations[i].annotationType();
+ Class<?> clazz = declaredAnnotations[i].annotationType();
if (!map.containsKey(clazz) && clazz.isAnnotationPresent(Inherited.class)) {
map.put(clazz, declaredAnnotations[i]);
}
diff --git a/luni/src/main/java/java/lang/reflect/AccessibleObject.java b/luni/src/main/java/java/lang/reflect/AccessibleObject.java
index 5d9e11c..83763a2 100644
--- a/luni/src/main/java/java/lang/reflect/AccessibleObject.java
+++ b/luni/src/main/java/java/lang/reflect/AccessibleObject.java
@@ -193,10 +193,12 @@ public class AccessibleObject implements AnnotatedElement {
if (annotationType == null) {
throw new NullPointerException();
}
- Annotation[] annos = getAnnotations();
- for (int i = annos.length-1; i >= 0; --i) {
- if (annos[i].annotationType() == annotationType) {
- return (T) annos[i];
+ Annotation[] annotations = getAnnotations();
+ for (int i = annotations.length-1; i >= 0; --i) {
+ if (annotations[i].annotationType() == annotationType) {
+ @SuppressWarnings("unchecked")
+ T result = (T) annotations[i];
+ return result;
}
}
return null;
diff --git a/luni/src/main/java/java/security/cert/PKIXParameters.java b/luni/src/main/java/java/security/cert/PKIXParameters.java
index 639368e..2e9d4a2 100644
--- a/luni/src/main/java/java/security/cert/PKIXParameters.java
+++ b/luni/src/main/java/java/security/cert/PKIXParameters.java
@@ -114,9 +114,9 @@ public class PKIXParameters implements CertPathParameters {
String alias = (String) i.nextElement();
if (keyStore.isCertificateEntry(alias)) {
// this is trusted certificate entry
- // check if it is X509Cerificate
+ // check if it is X509Certificate
Certificate c = keyStore.getCertificate(alias);
- // add only X509Cerificate
+ // add only X509Certificate
// ignore all other types
if (c instanceof X509Certificate) {
trustAnchors.add(new TrustAnchor((X509Certificate)c, null));
@@ -195,11 +195,9 @@ public class PKIXParameters implements CertPathParameters {
return Collections.unmodifiableList(certPathCheckers);
}
// List is not empty - do deep copy
- ArrayList<PKIXCertPathChecker> modifiableList =
- new ArrayList<PKIXCertPathChecker>();
- for (Iterator<PKIXCertPathChecker> i
- = certPathCheckers.iterator(); i.hasNext();) {
- modifiableList.add((PKIXCertPathChecker)i.next().clone());
+ ArrayList<PKIXCertPathChecker> modifiableList = new ArrayList<PKIXCertPathChecker>();
+ for (PKIXCertPathChecker certPathChecker : certPathCheckers) {
+ modifiableList.add((PKIXCertPathChecker) certPathChecker.clone());
}
return Collections.unmodifiableList(modifiableList);
}
@@ -225,9 +223,8 @@ public class PKIXParameters implements CertPathParameters {
}
// non-empty list provided - do deep copy
this.certPathCheckers = new ArrayList<PKIXCertPathChecker>();
- for (Iterator<PKIXCertPathChecker> i
- = certPathCheckers.iterator(); i.hasNext();) {
- this.certPathCheckers.add((PKIXCertPathChecker)i.next().clone());
+ for (PKIXCertPathChecker certPathChecker : certPathCheckers) {
+ this.certPathCheckers.add((PKIXCertPathChecker) certPathChecker.clone());
}
}
@@ -291,13 +288,7 @@ public class PKIXParameters implements CertPathParameters {
return;
}
// non-empty list provided - do shallow copy
- this.certStores = new ArrayList(certStores);
- // check that all elements are CertStore
- for (Iterator i = this.certStores.iterator(); i.hasNext();) {
- if (!(i.next() instanceof CertStore)) {
- throw new ClassCastException("all list elements must be of type java.security.cert.CertStore");
- }
- }
+ this.certStores = new ArrayList<CertStore>(certStores);
}
/**
@@ -314,7 +305,7 @@ public class PKIXParameters implements CertPathParameters {
}
if (certStores == null) {
// set to empty List if has not been set yet
- certStores = new ArrayList();
+ certStores = new ArrayList<CertStore>();
}
// add store
certStores.add(store);
@@ -332,7 +323,7 @@ public class PKIXParameters implements CertPathParameters {
}
/**
- * Sets the time for which the validation of the certification path sould be
+ * Sets the time for which the validation of the certification path should be
* evaluated.
*
* @param date
@@ -376,7 +367,7 @@ public class PKIXParameters implements CertPathParameters {
public Set<String> getInitialPolicies() {
if (initialPolicies == null) {
// set to empty Set if has not been set yet
- initialPolicies = new HashSet();
+ initialPolicies = new HashSet<String>();
}
if (initialPolicies.isEmpty()) {
// no content - no need to copy,
@@ -385,7 +376,7 @@ public class PKIXParameters implements CertPathParameters {
return Collections.unmodifiableSet(initialPolicies);
}
// List is not empty - do shallow copy
- HashSet modifiableSet = new HashSet(initialPolicies);
+ HashSet<String> modifiableSet = new HashSet<String>(initialPolicies);
return Collections.unmodifiableSet(modifiableSet);
}
@@ -400,21 +391,14 @@ public class PKIXParameters implements CertPathParameters {
public void setInitialPolicies(Set<String> initialPolicies) {
if (initialPolicies == null || initialPolicies.isEmpty()) {
// empty list or null provided
- if (this.initialPolicies != null &&
- !this.initialPolicies.isEmpty()) {
+ if (this.initialPolicies != null && !this.initialPolicies.isEmpty()) {
// discard non-empty list
this.initialPolicies = null;
}
return;
}
// non-empty list provided - do shallow copy
- this.initialPolicies = new HashSet(initialPolicies);
- // check that all elements are String
- for (Iterator i = this.initialPolicies.iterator(); i.hasNext();) {
- if (!(i.next() instanceof String)) {
- throw new ClassCastException("all set elements must be of type java.lang.String");
- }
- }
+ this.initialPolicies = new HashSet<String>(initialPolicies);
}
/**
@@ -543,10 +527,10 @@ public class PKIXParameters implements CertPathParameters {
PKIXParameters ret = (PKIXParameters)super.clone();
// copy fields containing references to mutable objects
if (this.certStores != null) {
- ret.certStores = new ArrayList(this.certStores);
+ ret.certStores = new ArrayList<CertStore>(this.certStores);
}
if (this.certPathCheckers != null) {
- ret.certPathCheckers = new ArrayList(this.certPathCheckers);
+ ret.certPathCheckers = new ArrayList<PKIXCertPathChecker>(this.certPathCheckers);
}
return ret;
} catch (CloneNotSupportedException e) {
@@ -601,15 +585,9 @@ public class PKIXParameters implements CertPathParameters {
// only TrustAnchor instances.
// Throws InvalidAlgorithmParameterException if trustAnchors set is empty.
//
- private void checkTrustAnchors(Set trustAnchors)
- throws InvalidAlgorithmParameterException {
+ private void checkTrustAnchors(Set<TrustAnchor> trustAnchors) throws InvalidAlgorithmParameterException {
if (trustAnchors.isEmpty()) {
throw new InvalidAlgorithmParameterException("trustAnchors.isEmpty()");
}
- for (Iterator i = trustAnchors.iterator(); i.hasNext();) {
- if (!(i.next() instanceof TrustAnchor)) {
- throw new ClassCastException("all set elements must be of type java.security.cert.TrustAnchor");
- }
- }
}
}
diff --git a/luni/src/main/java/java/security/cert/X509CertSelector.java b/luni/src/main/java/java/security/cert/X509CertSelector.java
index 33e68c7..144e213 100644
--- a/luni/src/main/java/java/security/cert/X509CertSelector.java
+++ b/luni/src/main/java/java/security/cert/X509CertSelector.java
@@ -66,7 +66,7 @@ public class X509CertSelector implements CertSelector {
private int pathLen = -1;
private List[] subjectAltNames;
private NameConstraints nameConstraints;
- private Set policies;
+ private Set<String> policies;
private ArrayList pathToNames;
// needed to avoid needless encoding/decoding work
@@ -876,10 +876,10 @@ public class X509CertSelector implements CertSelector {
this.policies = null;
return;
}
- HashSet pols = new HashSet(policies.size());
- Iterator it = policies.iterator();
+ HashSet<String> pols = new HashSet<String>(policies.size());
+ Iterator<String> it = policies.iterator();
while (it.hasNext()) {
- String certPolicyId = (String) it.next();
+ String certPolicyId = it.next();
checkOID(certPolicyId);
pols.add(certPolicyId);
}
@@ -918,8 +918,7 @@ public class X509CertSelector implements CertSelector {
* @throws IOException
* if decoding fails.
*/
- public void setPathToNames(Collection<List<?>> names)
- throws IOException {
+ public void setPathToNames(Collection<List<?>> names) throws IOException {
pathToNames = null;
if ((names == null) || (names.size() == 0)) {
return;
@@ -1417,9 +1416,7 @@ public class X509CertSelector implements CertSelector {
}
}
}
- result.policies = (this.policies == null)
- ? null
- : new HashSet(this.policies);
+ result.policies = (this.policies == null) ? null : new HashSet<String>(this.policies);
result.pathToNames = (this.pathToNames == null)
? null
: new ArrayList(this.pathToNames);
diff --git a/luni/src/main/java/java/text/RuleBasedCollator.java b/luni/src/main/java/java/text/RuleBasedCollator.java
index f6a19f3..4fd8650 100644
--- a/luni/src/main/java/java/text/RuleBasedCollator.java
+++ b/luni/src/main/java/java/text/RuleBasedCollator.java
@@ -316,7 +316,7 @@ public class RuleBasedCollator extends Collator {
if (source == null) {
throw new NullPointerException();
}
- return new CollationElementIterator(((RuleBasedCollatorICU) icuColl).getCollationElementIterator(source));
+ return new CollationElementIterator(icuColl.getCollationElementIterator(source));
}
/**
@@ -330,7 +330,7 @@ public class RuleBasedCollator extends Collator {
if (source == null) {
throw new NullPointerException();
}
- return new CollationElementIterator(((RuleBasedCollatorICU) icuColl).getCollationElementIterator(source));
+ return new CollationElementIterator(icuColl.getCollationElementIterator(source));
}
/**
@@ -346,7 +346,7 @@ public class RuleBasedCollator extends Collator {
* @return the collation rules.
*/
public String getRules() {
- return ((RuleBasedCollatorICU) icuColl).getRules();
+ return icuColl.getRules();
}
/**
@@ -405,7 +405,7 @@ public class RuleBasedCollator extends Collator {
@Override
public int hashCode() {
- return ((RuleBasedCollatorICU) icuColl).getRules().hashCode();
+ return icuColl.getRules().hashCode();
}
/**
diff --git a/luni/src/main/java/java/util/Properties.java b/luni/src/main/java/java/util/Properties.java
index 34a8faa..bff7ebc 100644
--- a/luni/src/main/java/java/util/Properties.java
+++ b/luni/src/main/java/java/util/Properties.java
@@ -471,31 +471,25 @@ public class Properties extends Hashtable<Object, Object> {
* @since 1.6
*/
public Set<String> stringPropertyNames() {
- Hashtable<String, String> stringProperties = new Hashtable<String, String>();
+ Hashtable<String, Object> stringProperties = new Hashtable<String, Object>();
selectProperties(stringProperties, true);
return Collections.unmodifiableSet(stringProperties.keySet());
}
- private void selectProperties(Hashtable selectProperties, final boolean isStringOnly) {
+ private <K> void selectProperties(Hashtable<K, Object> selectProperties, final boolean isStringOnly) {
if (defaults != null) {
defaults.selectProperties(selectProperties, isStringOnly);
}
- Enumeration<?> keys = keys();
- Object key, value;
+ Enumeration<Object> keys = keys();
while (keys.hasMoreElements()) {
- key = keys.nextElement();
- if (isStringOnly) {
+ @SuppressWarnings("unchecked")
+ K key = (K) keys.nextElement();
+ if (isStringOnly && !(key instanceof String)) {
// Only select property with string key and value
- if (key instanceof String) {
- value = get(key);
- if (value instanceof String) {
- selectProperties.put(key, value);
- }
- }
- } else {
- value = get(key);
- selectProperties.put(key, value);
+ continue;
}
+ Object value = get(key);
+ selectProperties.put(key, value);
}
}
diff --git a/luni/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java b/luni/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java
index b421e1b..cc16ac7 100644
--- a/luni/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java
+++ b/luni/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java
@@ -114,7 +114,7 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
public final E getAndSet(int i, E newValue) {
long offset = checkedByteOffset(i);
while (true) {
- E current = (E) getRaw(offset);
+ E current = getRaw(offset);
if (compareAndSetRaw(offset, current, newValue))
return current;
}
diff --git a/luni/src/main/java/java/util/zip/InflaterInputStream.java b/luni/src/main/java/java/util/zip/InflaterInputStream.java
index 4b74f49..e506a8e 100644
--- a/luni/src/main/java/java/util/zip/InflaterInputStream.java
+++ b/luni/src/main/java/java/util/zip/InflaterInputStream.java
@@ -199,7 +199,7 @@ public class InflaterInputStream extends FilterInputStream {
synchronized (is.mSharedRaf) {
long len = is.mLength - is.mOffset;
if (len > nativeEndBufSize) len = nativeEndBufSize;
- int cnt = inf.setFileInput(is.mSharedRaf.getFD(), is.mOffset, (int)nativeEndBufSize);
+ int cnt = inf.setFileInput(is.mSharedRaf.getFD(), is.mOffset, nativeEndBufSize);
is.skip(cnt);
}
} else {
diff --git a/luni/src/main/java/libcore/icu/CharsetDecoderICU.java b/luni/src/main/java/libcore/icu/CharsetDecoderICU.java
index c008d0c..86ba13b 100644
--- a/luni/src/main/java/libcore/icu/CharsetDecoderICU.java
+++ b/luni/src/main/java/libcore/icu/CharsetDecoderICU.java
@@ -47,12 +47,8 @@ public final class CharsetDecoderICU extends CharsetDecoder {
private char[] allocatedOutput = null;
// END android-added
- // These instance variables are
- // always assigned in the methods
- // before being used. This class
- // inhrently multithread unsafe
- // so we dont have to worry about
- // synchronization
+ // These instance variables are always assigned in the methods before being used. This class
+ // is inherently thread-unsafe so we don't have to worry about synchronization.
private int inEnd;
private int outEnd;
private int ec;
@@ -247,7 +243,7 @@ public final class CharsetDecoderICU extends CharsetDecoder {
// private utility methods
//------------------------------------------
- private final int getArray(CharBuffer out){
+ private int getArray(CharBuffer out) {
if (out.hasArray()) {
// BEGIN android-changed: take arrayOffset into account
output = out.array();
@@ -269,7 +265,7 @@ public final class CharsetDecoderICU extends CharsetDecoder {
}
}
- private final int getArray(ByteBuffer in){
+ private int getArray(ByteBuffer in) {
if (in.hasArray()) {
// BEGIN android-changed: take arrayOffset into account
input = in.array();
@@ -296,7 +292,7 @@ public final class CharsetDecoderICU extends CharsetDecoder {
}
}
- private final void setPosition(CharBuffer out) {
+ private void setPosition(CharBuffer out) {
if (out.hasArray()) {
out.position(out.position() + data[OUTPUT_OFFSET] - out.arrayOffset());
} else {
@@ -306,7 +302,7 @@ public final class CharsetDecoderICU extends CharsetDecoder {
output = null;
}
- private final void setPosition(ByteBuffer in) {
+ private void setPosition(ByteBuffer in) {
// ok was there input held in the previous invocation of decodeLoop
// that resulted in output in this invocation?
in.position(in.position() + data[INPUT_OFFSET] + savedInputHeldLen - data[INPUT_HELD]);
diff --git a/luni/src/main/java/libcore/icu/CharsetEncoderICU.java b/luni/src/main/java/libcore/icu/CharsetEncoderICU.java
index 2284adf..2855a4c 100644
--- a/luni/src/main/java/libcore/icu/CharsetEncoderICU.java
+++ b/luni/src/main/java/libcore/icu/CharsetEncoderICU.java
@@ -61,12 +61,8 @@ public final class CharsetEncoderICU extends CharsetEncoder {
private byte[] allocatedOutput = null;
// END android-added
- // These instance variables are
- // always assigned in the methods
- // before being used. This class
- // inhrently multithread unsafe
- // so we dont have to worry about
- // synchronization
+ // These instance variables are always assigned in the methods before being used. This class
+ // is inherently thread-unsafe so we don't have to worry about synchronization.
private int inEnd;
private int outEnd;
private int ec;
@@ -249,60 +245,12 @@ public final class CharsetEncoderICU extends CharsetEncoder {
}
}
- /**
- * Ascertains if a given Unicode character can
- * be converted to the target encoding
- *
- * @param c the character to be converted
- * @return true if a character can be converted
- * @stable ICU 2.4
- *
- */
public boolean canEncode(char c) {
return canEncode((int) c);
}
- /**
- * Ascertains if a given Unicode code point (32bit value for handling surrogates)
- * can be converted to the target encoding. If the caller wants to test if a
- * surrogate pair can be converted to target encoding then the
- * responsibility of assembling the int value lies with the caller.
- * For assembling a code point the caller can use UTF16 class of ICU4J and do something like:
- * <pre>
- * while(i<mySource.length){
- * if(UTF16.isLeadSurrogate(mySource[i])&& i+1< mySource.length){
- * if(UTF16.isTrailSurrogate(mySource[i+1])){
- * int temp = UTF16.charAt(mySource,i,i+1,0);
- * if(!((CharsetEncoderICU) myConv).canEncode(temp)){
- * passed=false;
- * }
- * i++;
- * i++;
- * }
- * }
- * }
- * </pre>
- * or
- * <pre>
- * String src = new String(mySource);
- * int i,codepoint;
- * boolean passed = false;
- * while(i<src.length()){
- * codepoint = UTF16.charAt(src,i);
- * i+= (codepoint>0xfff)? 2:1;
- * if(!(CharsetEncoderICU) myConv).canEncode(codepoint)){
- * passed = false;
- * }
- * }
- * </pre>
- *
- * @param codepoint Unicode code point as int value
- * @return true if a character can be converted
- * @obsolete ICU 2.4
- * @deprecated ICU 3.4
- */
- public boolean canEncode(int codepoint) {
- return NativeConverter.canEncode(converterHandle, codepoint);
+ public boolean canEncode(int codePoint) {
+ return NativeConverter.canEncode(converterHandle, codePoint);
}
/**
@@ -322,14 +270,14 @@ public final class CharsetEncoderICU extends CharsetEncoder {
//------------------------------------------
// private utility methods
//------------------------------------------
- private final int getArray(ByteBuffer out) {
- if(out.hasArray()){
+ private int getArray(ByteBuffer out) {
+ if (out.hasArray()) {
// BEGIN android-changed: take arrayOffset into account
output = out.array();
outEnd = out.arrayOffset() + out.limit();
return out.arrayOffset() + out.position();
// END android-changed
- }else{
+ } else {
outEnd = out.remaining();
// BEGIN android-added
if (allocatedOutput == null || (outEnd > allocatedOutput.length)) {
@@ -344,14 +292,14 @@ public final class CharsetEncoderICU extends CharsetEncoder {
}
}
- private final int getArray(CharBuffer in) {
- if(in.hasArray()){
+ private int getArray(CharBuffer in) {
+ if (in.hasArray()) {
// BEGIN android-changed: take arrayOffset into account
input = in.array();
inEnd = in.arrayOffset() + in.limit();
return in.arrayOffset() + in.position() + savedInputHeldLen;/*exclude the number fo bytes held in previous conversion*/
// END android-changed
- }else{
+ } else {
inEnd = in.remaining();
// BEGIN android-added
if (allocatedInput == null || (inEnd > allocatedInput.length)) {
@@ -371,7 +319,7 @@ public final class CharsetEncoderICU extends CharsetEncoder {
}
}
- private final void setPosition(ByteBuffer out) {
+ private void setPosition(ByteBuffer out) {
if (out.hasArray()) {
// in getArray method we accessed the
@@ -389,7 +337,7 @@ public final class CharsetEncoderICU extends CharsetEncoder {
output = null;
// END android-added
}
- private final void setPosition(CharBuffer in){
+ private void setPosition(CharBuffer in){
// BEGIN android-removed
// // was there input held in the previous invocation of encodeLoop
@@ -407,7 +355,7 @@ public final class CharsetEncoderICU extends CharsetEncoder {
// BEGIN android-added
// Slightly rewired original code to make it cleaner. Also
- // added a fix for the problem where input charatcers got
+ // added a fix for the problem where input characters got
// lost when invalid characters were encountered. Not sure
// what happens when data[INVALID_CHARS] is > 1, though,
// since we never saw that happening.
diff --git a/luni/src/main/java/libcore/icu/CollationElementIteratorICU.java b/luni/src/main/java/libcore/icu/CollationElementIteratorICU.java
index bb5e809..6d85718 100644
--- a/luni/src/main/java/libcore/icu/CollationElementIteratorICU.java
+++ b/luni/src/main/java/libcore/icu/CollationElementIteratorICU.java
@@ -52,7 +52,7 @@ public final class CollationElementIteratorICU {
* @stable ICU 2.4
*/
public void reset() {
- NativeCollation.reset(m_collelemiterator_);
+ NativeCollation.reset(address);
}
/**
@@ -63,7 +63,7 @@ public final class CollationElementIteratorICU {
* @stable ICU 2.4
*/
public int next() {
- return NativeCollation.next(m_collelemiterator_);
+ return NativeCollation.next(address);
}
/**
@@ -74,7 +74,7 @@ public final class CollationElementIteratorICU {
* @stable ICU 2.4
*/
public int previous() {
- return NativeCollation.previous(m_collelemiterator_);
+ return NativeCollation.previous(address);
}
/**
@@ -87,7 +87,7 @@ public final class CollationElementIteratorICU {
* @stable ICU 2.4
*/
public int getMaxExpansion(int order) {
- return NativeCollation.getMaxExpansion(m_collelemiterator_, order);
+ return NativeCollation.getMaxExpansion(address, order);
}
/**
@@ -96,12 +96,12 @@ public final class CollationElementIteratorICU {
* @stable ICU 2.4
*/
public void setText(String source) {
- NativeCollation.setText(m_collelemiterator_, source);
+ NativeCollation.setText(address, source);
}
// BEGIN android-added
public void setText(CharacterIterator source) {
- NativeCollation.setText(m_collelemiterator_, source.toString());
+ NativeCollation.setText(address, source.toString());
}
// END android-added
@@ -113,7 +113,7 @@ public final class CollationElementIteratorICU {
* @stable ICU 2.4
*/
public int getOffset() {
- return NativeCollation.getOffset(m_collelemiterator_);
+ return NativeCollation.getOffset(address);
}
/**
@@ -123,7 +123,7 @@ public final class CollationElementIteratorICU {
* @stable ICU 2.4
*/
public void setOffset(int offset) {
- NativeCollation.setOffset(m_collelemiterator_, offset);
+ NativeCollation.setOffset(address, offset);
}
/**
@@ -163,7 +163,7 @@ public final class CollationElementIteratorICU {
}
private CollationElementIteratorICU(int address) {
- m_collelemiterator_ = address;
+ this.address = address;
}
// protected methods --------------------------------------------
@@ -175,7 +175,7 @@ public final class CollationElementIteratorICU {
*/
@Override protected void finalize() throws Throwable {
try {
- NativeCollation.closeElements(m_collelemiterator_);
+ NativeCollation.closeElements(address);
} finally {
super.finalize();
}
@@ -186,7 +186,7 @@ public final class CollationElementIteratorICU {
/**
* C collator
*/
- private int m_collelemiterator_;
+ private int address;
/**
* ICU constant primary order mask for collation elements
diff --git a/luni/src/main/java/libcore/icu/NativeBreakIterator.java b/luni/src/main/java/libcore/icu/NativeBreakIterator.java
index 86c6924..9c10461 100644
--- a/luni/src/main/java/libcore/icu/NativeBreakIterator.java
+++ b/luni/src/main/java/libcore/icu/NativeBreakIterator.java
@@ -27,19 +27,19 @@ public final class NativeBreakIterator implements Cloneable {
private static final int BI_LINE_INSTANCE = 3;
private static final int BI_SENT_INSTANCE = 4;
- private final int addr;
+ private final int address;
private final int type;
private CharacterIterator charIter;
- private NativeBreakIterator(int iterAddr, int type) {
- this.addr = iterAddr;
+ private NativeBreakIterator(int address, int type) {
+ this.address = address;
this.type = type;
this.charIter = new StringCharacterIterator("");
}
@Override
public Object clone() {
- int cloneAddr = cloneImpl(this.addr);
+ int cloneAddr = cloneImpl(this.address);
NativeBreakIterator clone = new NativeBreakIterator(cloneAddr, this.type);
// The RI doesn't clone the CharacterIterator.
clone.charIter = this.charIter;
@@ -66,44 +66,44 @@ public final class NativeBreakIterator implements Cloneable {
@Override protected void finalize() throws Throwable {
try {
- closeBreakIteratorImpl(this.addr);
+ closeBreakIteratorImpl(this.address);
} finally {
super.finalize();
}
}
public int current() {
- return currentImpl(this.addr);
+ return currentImpl(this.address);
}
public int first() {
- return firstImpl(this.addr);
+ return firstImpl(this.address);
}
public int following(int offset) {
- return followingImpl(this.addr, offset);
+ return followingImpl(this.address, offset);
}
public CharacterIterator getText() {
- int newLoc = currentImpl(this.addr);
+ int newLoc = currentImpl(this.address);
this.charIter.setIndex(newLoc);
return this.charIter;
}
public int last() {
- return lastImpl(this.addr);
+ return lastImpl(this.address);
}
public int next(int n) {
- return nextImpl(this.addr, n);
+ return nextImpl(this.address, n);
}
public int next() {
- return nextImpl(this.addr, 1);
+ return nextImpl(this.address, 1);
}
public int previous() {
- return previousImpl(this.addr);
+ return previousImpl(this.address);
}
public void setText(CharacterIterator newText) {
@@ -112,7 +112,7 @@ public final class NativeBreakIterator implements Cloneable {
for (char c = newText.first(); c != CharacterIterator.DONE; c = newText.next()) {
sb.append(c);
}
- setTextImpl(this.addr, sb.toString());
+ setTextImpl(this.address, sb.toString());
}
public void setText(String newText) {
@@ -120,11 +120,11 @@ public final class NativeBreakIterator implements Cloneable {
}
public boolean isBoundary(int offset) {
- return isBoundaryImpl(this.addr, offset);
+ return isBoundaryImpl(this.address, offset);
}
public int preceding(int offset) {
- return precedingImpl(this.addr, offset);
+ return precedingImpl(this.address, offset);
}
public static NativeBreakIterator getCharacterInstance(Locale where) {
@@ -147,15 +147,15 @@ public final class NativeBreakIterator implements Cloneable {
private static native int getWordInstanceImpl(String locale);
private static native int getLineInstanceImpl(String locale);
private static native int getSentenceInstanceImpl(String locale);
- private static native void closeBreakIteratorImpl(int addr);
- private static native void setTextImpl(int addr, String text);
- private static native int cloneImpl(int addr);
- private static native int precedingImpl(int addr, int offset);
- private static native boolean isBoundaryImpl(int addr, int offset);
- private static native int nextImpl(int addr, int n);
- private static native int previousImpl(int addr);
- private static native int currentImpl(int addr);
- private static native int firstImpl(int addr);
- private static native int followingImpl(int addr, int offset);
- private static native int lastImpl(int addr);
+ private static native void closeBreakIteratorImpl(int address);
+ private static native void setTextImpl(int address, String text);
+ private static native int cloneImpl(int address);
+ private static native int precedingImpl(int address, int offset);
+ private static native boolean isBoundaryImpl(int address, int offset);
+ private static native int nextImpl(int address, int n);
+ private static native int previousImpl(int address);
+ private static native int currentImpl(int address);
+ private static native int firstImpl(int address);
+ private static native int followingImpl(int address, int offset);
+ private static native int lastImpl(int address);
}
diff --git a/luni/src/main/java/libcore/icu/NativeDecimalFormat.java b/luni/src/main/java/libcore/icu/NativeDecimalFormat.java
index 1c92d97..14f291f 100644
--- a/luni/src/main/java/libcore/icu/NativeDecimalFormat.java
+++ b/luni/src/main/java/libcore/icu/NativeDecimalFormat.java
@@ -28,7 +28,6 @@ import java.text.NumberFormat;
import java.text.ParsePosition;
import java.util.Currency;
import java.util.NoSuchElementException;
-import libcore.icu.LocaleData;
public final class NativeDecimalFormat {
/**
@@ -95,7 +94,7 @@ public final class NativeDecimalFormat {
/**
* The address of the ICU DecimalFormat* on the native heap.
*/
- private int addr;
+ private int address;
/**
* The last pattern we gave to ICU, so we can make repeated applications cheap.
@@ -121,7 +120,7 @@ public final class NativeDecimalFormat {
public NativeDecimalFormat(String pattern, DecimalFormatSymbols dfs) {
try {
- this.addr = open(pattern, dfs.getCurrencySymbol(),
+ this.address = open(pattern, dfs.getCurrencySymbol(),
dfs.getDecimalSeparator(), dfs.getDigit(), dfs.getExponentSeparator(),
dfs.getGroupingSeparator(), dfs.getInfinity(),
dfs.getInternationalCurrencySymbol(), dfs.getMinusSign(),
@@ -137,7 +136,7 @@ public final class NativeDecimalFormat {
// Used so java.util.Formatter doesn't need to allocate DecimalFormatSymbols instances.
public NativeDecimalFormat(String pattern, LocaleData data) {
- this.addr = open(pattern, data.currencySymbol,
+ this.address = open(pattern, data.currencySymbol,
data.decimalSeparator, data.digit, data.exponentSeparator, data.groupingSeparator,
data.infinity, data.internationalCurrencySymbol, data.minusSign,
data.monetarySeparator, data.NaN, data.patternSeparator,
@@ -147,7 +146,7 @@ public final class NativeDecimalFormat {
// Used to implement clone.
private NativeDecimalFormat(NativeDecimalFormat other) {
- this.addr = cloneImpl(other.addr);
+ this.address = cloneImpl(other.address);
this.lastPattern = other.lastPattern;
this.negPrefNull = other.negPrefNull;
this.negSuffNull = other.negSuffNull;
@@ -162,9 +161,9 @@ public final class NativeDecimalFormat {
}
public synchronized void close() {
- if (addr != 0) {
- close(addr);
- addr = 0;
+ if (address != 0) {
+ close(address);
+ address = 0;
}
}
@@ -192,7 +191,7 @@ public final class NativeDecimalFormat {
return false;
}
NativeDecimalFormat obj = (NativeDecimalFormat) object;
- if (obj.addr == this.addr) {
+ if (obj.address == this.address) {
return true;
}
return obj.toPattern().equals(this.toPattern()) &&
@@ -214,7 +213,7 @@ public final class NativeDecimalFormat {
* Copies the DecimalFormatSymbols settings into our native peer in bulk.
*/
public void setDecimalFormatSymbols(final DecimalFormatSymbols dfs) {
- setDecimalFormatSymbols(this.addr, dfs.getCurrencySymbol(), dfs.getDecimalSeparator(),
+ setDecimalFormatSymbols(this.address, dfs.getCurrencySymbol(), dfs.getDecimalSeparator(),
dfs.getDigit(), dfs.getExponentSeparator(), dfs.getGroupingSeparator(),
dfs.getInfinity(), dfs.getInternationalCurrencySymbol(), dfs.getMinusSign(),
dfs.getMonetaryDecimalSeparator(), dfs.getNaN(), dfs.getPatternSeparator(),
@@ -222,7 +221,7 @@ public final class NativeDecimalFormat {
}
public void setDecimalFormatSymbols(final LocaleData localeData) {
- setDecimalFormatSymbols(this.addr, localeData.currencySymbol, localeData.decimalSeparator,
+ setDecimalFormatSymbols(this.address, localeData.currencySymbol, localeData.decimalSeparator,
localeData.digit, localeData.exponentSeparator, localeData.groupingSeparator,
localeData.infinity, localeData.internationalCurrencySymbol, localeData.minusSign,
localeData.monetarySeparator, localeData.NaN, localeData.patternSeparator,
@@ -231,7 +230,7 @@ public final class NativeDecimalFormat {
public char[] formatBigDecimal(BigDecimal value, FieldPosition field) {
FieldPositionIterator fpi = FieldPositionIterator.forFieldPosition(field);
- char[] result = formatDigitList(this.addr, value.toString(), fpi);
+ char[] result = formatDigitList(this.address, value.toString(), fpi);
if (fpi != null) {
FieldPositionIterator.setFieldPosition(fpi, field);
}
@@ -240,7 +239,7 @@ public final class NativeDecimalFormat {
public char[] formatBigInteger(BigInteger value, FieldPosition field) {
FieldPositionIterator fpi = FieldPositionIterator.forFieldPosition(field);
- char[] result = formatDigitList(this.addr, value.toString(10), fpi);
+ char[] result = formatDigitList(this.address, value.toString(10), fpi);
if (fpi != null) {
FieldPositionIterator.setFieldPosition(fpi, field);
}
@@ -249,7 +248,7 @@ public final class NativeDecimalFormat {
public char[] formatLong(long value, FieldPosition field) {
FieldPositionIterator fpi = FieldPositionIterator.forFieldPosition(field);
- char[] result = formatLong(this.addr, value, fpi);
+ char[] result = formatLong(this.address, value, fpi);
if (fpi != null) {
FieldPositionIterator.setFieldPosition(fpi, field);
}
@@ -258,7 +257,7 @@ public final class NativeDecimalFormat {
public char[] formatDouble(double value, FieldPosition field) {
FieldPositionIterator fpi = FieldPositionIterator.forFieldPosition(field);
- char[] result = formatDouble(this.addr, value, fpi);
+ char[] result = formatDouble(this.address, value, fpi);
if (fpi != null) {
FieldPositionIterator.setFieldPosition(fpi, field);
}
@@ -266,7 +265,7 @@ public final class NativeDecimalFormat {
}
public void applyLocalizedPattern(String pattern) {
- applyPattern(this.addr, true, pattern);
+ applyPattern(this.address, true, pattern);
lastPattern = null;
}
@@ -274,7 +273,7 @@ public final class NativeDecimalFormat {
if (lastPattern != null && pattern.equals(lastPattern)) {
return;
}
- applyPattern(this.addr, false, pattern);
+ applyPattern(this.address, false, pattern);
lastPattern = pattern;
}
@@ -286,13 +285,13 @@ public final class NativeDecimalFormat {
FieldPositionIterator fpIter = new FieldPositionIterator();
String text;
if (number instanceof BigInteger || number instanceof BigDecimal) {
- text = new String(formatDigitList(this.addr, number.toString(), fpIter));
+ text = new String(formatDigitList(this.address, number.toString(), fpIter));
} else if (number instanceof Double || number instanceof Float) {
double dv = number.doubleValue();
- text = new String(formatDouble(this.addr, dv, fpIter));
+ text = new String(formatDouble(this.address, dv, fpIter));
} else {
long lv = number.longValue();
- text = new String(formatLong(this.addr, lv, fpIter));
+ text = new String(formatLong(this.address, lv, fpIter));
}
AttributedString as = new AttributedString(text);
@@ -318,73 +317,73 @@ public final class NativeDecimalFormat {
}
public String toLocalizedPattern() {
- return toPatternImpl(this.addr, true);
+ return toPatternImpl(this.address, true);
}
public String toPattern() {
- return toPatternImpl(this.addr, false);
+ return toPatternImpl(this.address, false);
}
public Number parse(String string, ParsePosition position) {
- return parse(addr, string, position, parseBigDecimal);
+ return parse(address, string, position, parseBigDecimal);
}
// start getter and setter
public int getMaximumFractionDigits() {
- return getAttribute(this.addr, UNUM_MAX_FRACTION_DIGITS);
+ return getAttribute(this.address, UNUM_MAX_FRACTION_DIGITS);
}
public int getMaximumIntegerDigits() {
- return getAttribute(this.addr, UNUM_MAX_INTEGER_DIGITS);
+ return getAttribute(this.address, UNUM_MAX_INTEGER_DIGITS);
}
public int getMinimumFractionDigits() {
- return getAttribute(this.addr, UNUM_MIN_FRACTION_DIGITS);
+ return getAttribute(this.address, UNUM_MIN_FRACTION_DIGITS);
}
public int getMinimumIntegerDigits() {
- return getAttribute(this.addr, UNUM_MIN_INTEGER_DIGITS);
+ return getAttribute(this.address, UNUM_MIN_INTEGER_DIGITS);
}
public int getGroupingSize() {
- return getAttribute(this.addr, UNUM_GROUPING_SIZE);
+ return getAttribute(this.address, UNUM_GROUPING_SIZE);
}
public int getMultiplier() {
- return getAttribute(this.addr, UNUM_MULTIPLIER);
+ return getAttribute(this.address, UNUM_MULTIPLIER);
}
public String getNegativePrefix() {
if (negPrefNull) {
return null;
}
- return getTextAttribute(this.addr, UNUM_NEGATIVE_PREFIX);
+ return getTextAttribute(this.address, UNUM_NEGATIVE_PREFIX);
}
public String getNegativeSuffix() {
if (negSuffNull) {
return null;
}
- return getTextAttribute(this.addr, UNUM_NEGATIVE_SUFFIX);
+ return getTextAttribute(this.address, UNUM_NEGATIVE_SUFFIX);
}
public String getPositivePrefix() {
if (posPrefNull) {
return null;
}
- return getTextAttribute(this.addr, UNUM_POSITIVE_PREFIX);
+ return getTextAttribute(this.address, UNUM_POSITIVE_PREFIX);
}
public String getPositiveSuffix() {
if (posSuffNull) {
return null;
}
- return getTextAttribute(this.addr, UNUM_POSITIVE_SUFFIX);
+ return getTextAttribute(this.address, UNUM_POSITIVE_SUFFIX);
}
public boolean isDecimalSeparatorAlwaysShown() {
- return getAttribute(this.addr, UNUM_DECIMAL_ALWAYS_SHOWN) != 0;
+ return getAttribute(this.address, UNUM_DECIMAL_ALWAYS_SHOWN) != 0;
}
public boolean isParseBigDecimal() {
@@ -392,50 +391,50 @@ public final class NativeDecimalFormat {
}
public boolean isParseIntegerOnly() {
- return getAttribute(this.addr, UNUM_PARSE_INT_ONLY) != 0;
+ return getAttribute(this.address, UNUM_PARSE_INT_ONLY) != 0;
}
public boolean isGroupingUsed() {
- return getAttribute(this.addr, UNUM_GROUPING_USED) != 0;
+ return getAttribute(this.address, UNUM_GROUPING_USED) != 0;
}
public void setDecimalSeparatorAlwaysShown(boolean value) {
int i = value ? -1 : 0;
- setAttribute(this.addr, UNUM_DECIMAL_ALWAYS_SHOWN, i);
+ setAttribute(this.address, UNUM_DECIMAL_ALWAYS_SHOWN, i);
}
public void setCurrency(Currency currency) {
- setSymbol(this.addr, UNUM_CURRENCY_SYMBOL, currency.getSymbol());
- setSymbol(this.addr, UNUM_INTL_CURRENCY_SYMBOL, currency.getCurrencyCode());
+ setSymbol(this.address, UNUM_CURRENCY_SYMBOL, currency.getSymbol());
+ setSymbol(this.address, UNUM_INTL_CURRENCY_SYMBOL, currency.getCurrencyCode());
}
public void setGroupingSize(int value) {
- setAttribute(this.addr, UNUM_GROUPING_SIZE, value);
+ setAttribute(this.address, UNUM_GROUPING_SIZE, value);
}
public void setGroupingUsed(boolean value) {
int i = value ? -1 : 0;
- setAttribute(this.addr, UNUM_GROUPING_USED, i);
+ setAttribute(this.address, UNUM_GROUPING_USED, i);
}
public void setMaximumFractionDigits(int value) {
- setAttribute(this.addr, UNUM_MAX_FRACTION_DIGITS, value);
+ setAttribute(this.address, UNUM_MAX_FRACTION_DIGITS, value);
}
public void setMaximumIntegerDigits(int value) {
- setAttribute(this.addr, UNUM_MAX_INTEGER_DIGITS, value);
+ setAttribute(this.address, UNUM_MAX_INTEGER_DIGITS, value);
}
public void setMinimumFractionDigits(int value) {
- setAttribute(this.addr, UNUM_MIN_FRACTION_DIGITS, value);
+ setAttribute(this.address, UNUM_MIN_FRACTION_DIGITS, value);
}
public void setMinimumIntegerDigits(int value) {
- setAttribute(this.addr, UNUM_MIN_INTEGER_DIGITS, value);
+ setAttribute(this.address, UNUM_MIN_INTEGER_DIGITS, value);
}
public void setMultiplier(int value) {
- setAttribute(this.addr, UNUM_MULTIPLIER, value);
+ setAttribute(this.address, UNUM_MULTIPLIER, value);
// Update the cached BigDecimal for multiplier.
multiplierBigDecimal = BigDecimal.valueOf(value);
}
@@ -443,28 +442,28 @@ public final class NativeDecimalFormat {
public void setNegativePrefix(String value) {
negPrefNull = value == null;
if (!negPrefNull) {
- setTextAttribute(this.addr, UNUM_NEGATIVE_PREFIX, value);
+ setTextAttribute(this.address, UNUM_NEGATIVE_PREFIX, value);
}
}
public void setNegativeSuffix(String value) {
negSuffNull = value == null;
if (!negSuffNull) {
- setTextAttribute(this.addr, UNUM_NEGATIVE_SUFFIX, value);
+ setTextAttribute(this.address, UNUM_NEGATIVE_SUFFIX, value);
}
}
public void setPositivePrefix(String value) {
posPrefNull = value == null;
if (!posPrefNull) {
- setTextAttribute(this.addr, UNUM_POSITIVE_PREFIX, value);
+ setTextAttribute(this.address, UNUM_POSITIVE_PREFIX, value);
}
}
public void setPositiveSuffix(String value) {
posSuffNull = value == null;
if (!posSuffNull) {
- setTextAttribute(this.addr, UNUM_POSITIVE_SUFFIX, value);
+ setTextAttribute(this.address, UNUM_POSITIVE_SUFFIX, value);
}
}
@@ -474,7 +473,7 @@ public final class NativeDecimalFormat {
public void setParseIntegerOnly(boolean value) {
int i = value ? -1 : 0;
- setAttribute(this.addr, UNUM_PARSE_INT_ONLY, i);
+ setAttribute(this.address, UNUM_PARSE_INT_ONLY, i);
}
private static void applyPattern(int addr, boolean localized, String pattern) {
@@ -499,7 +498,7 @@ public final class NativeDecimalFormat {
case HALF_UP: nativeRoundingMode = 6; break;
default: throw new AssertionError();
}
- setRoundingMode(addr, nativeRoundingMode, roundingIncrement);
+ setRoundingMode(address, nativeRoundingMode, roundingIncrement);
}
// Utility to get information about field positions from native (ICU) code.
diff --git a/luni/src/main/java/org/apache/harmony/luni/internal/util/ZoneInfoDB.java b/luni/src/main/java/org/apache/harmony/luni/internal/util/ZoneInfoDB.java
index e20d82d..c91f597 100644
--- a/luni/src/main/java/org/apache/harmony/luni/internal/util/ZoneInfoDB.java
+++ b/luni/src/main/java/org/apache/harmony/luni/internal/util/ZoneInfoDB.java
@@ -125,7 +125,7 @@ public final class ZoneInfoDB {
final int SIZEOF_TZINT = 4;
byte[] idBytes = new byte[SIZEOF_TZNAME];
- int numEntries = (int) (mappedFile.size() / (SIZEOF_TZNAME + 3*SIZEOF_TZINT));
+ int numEntries = mappedFile.size() / (SIZEOF_TZNAME + 3*SIZEOF_TZINT);
char[] idChars = new char[numEntries * SIZEOF_TZNAME];
int[] idEnd = new int[numEntries];
@@ -233,7 +233,7 @@ public final class ZoneInfoDB {
}
public static String[] getAvailableIDs() {
- return (String[]) ids.clone();
+ return ids.clone();
}
public static String[] getAvailableIDs(int rawOffset) {
diff --git a/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java b/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
index 630436e..1feb323 100644
--- a/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
+++ b/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
@@ -207,20 +207,20 @@ public final class FloatingPointParser {
}
boolean negative = false;
- int cmpstart = 0;
- switch (namedDouble.charAt(0)) {
- case '-':
- negative = true; // fall through
- case '+':
- cmpstart = 1;
- default:
+ int i = 0;
+ char firstChar = namedDouble.charAt(i);
+ if (firstChar == '-') {
+ negative = true;
+ ++i;
+ } else if (firstChar == '+') {
+ ++i;
}
- if (namedDouble.regionMatches(false, cmpstart, "Infinity", 0, 8)) {
+ if (namedDouble.regionMatches(false, i, "Infinity", 0, 8)) {
return negative ? Double.NEGATIVE_INFINITY : Float.POSITIVE_INFINITY;
}
- if (namedDouble.regionMatches(false, cmpstart, "NaN", 0, 3)) {
+ if (namedDouble.regionMatches(false, i, "NaN", 0, 3)) {
return Double.NaN;
}
@@ -238,20 +238,20 @@ public final class FloatingPointParser {
}
boolean negative = false;
- int cmpstart = 0;
- switch (namedFloat.charAt(0)) {
- case '-':
- negative = true; // fall through
- case '+':
- cmpstart = 1;
- default:
+ int i = 0;
+ char firstChar = namedFloat.charAt(i);
+ if (firstChar == '-') {
+ negative = true;
+ ++i;
+ } else if (firstChar == '+') {
+ ++i;
}
- if (namedFloat.regionMatches(false, cmpstart, "Infinity", 0, 8)) {
+ if (namedFloat.regionMatches(false, i, "Infinity", 0, 8)) {
return negative ? Float.NEGATIVE_INFINITY : Float.POSITIVE_INFINITY;
}
- if (namedFloat.regionMatches(false, cmpstart, "NaN", 0, 3)) {
+ if (namedFloat.regionMatches(false, i, "NaN", 0, 3)) {
return Float.NaN;
}
diff --git a/luni/src/main/java/org/apache/harmony/security/PolicyEntry.java b/luni/src/main/java/org/apache/harmony/security/PolicyEntry.java
index 8470f58..32f15a3 100644
--- a/luni/src/main/java/org/apache/harmony/security/PolicyEntry.java
+++ b/luni/src/main/java/org/apache/harmony/security/PolicyEntry.java
@@ -57,7 +57,7 @@ public class PolicyEntry {
Collection<? extends Permission> permissions) {
this.cs = (cs != null) ? normalizeCodeSource(cs) : null;
this.principals = (prs == null || prs.isEmpty()) ? null
- : (Principal[]) prs.toArray(new Principal[prs.size()]);
+ : prs.toArray(new Principal[prs.size()]);
this.permissions = (permissions == null || permissions.isEmpty()) ? null
: Collections.unmodifiableCollection(permissions);
}
diff --git a/luni/src/main/java/org/apache/harmony/security/fortress/DefaultPolicy.java b/luni/src/main/java/org/apache/harmony/security/fortress/DefaultPolicy.java
index 7214e3f..ebdce53 100644
--- a/luni/src/main/java/org/apache/harmony/security/fortress/DefaultPolicy.java
+++ b/luni/src/main/java/org/apache/harmony/security/fortress/DefaultPolicy.java
@@ -209,7 +209,7 @@ public class DefaultPolicy extends Policy {
pc = new HashSet<Permission>();
Iterator<PolicyEntry> it = grants.iterator();
while (it.hasNext()) {
- PolicyEntry ge = (PolicyEntry)it.next();
+ PolicyEntry ge = it.next();
if (ge.impliesPrincipals(pd == null ? null : pd.getPrincipals())
&& ge.impliesCodeSource(pd == null ? null : pd.getCodeSource())) {
pc.addAll(ge.getPermissions());
@@ -248,9 +248,8 @@ public class DefaultPolicy extends Policy {
pc = new HashSet<Permission>();
Iterator<PolicyEntry> it = grants.iterator();
while (it.hasNext()) {
- PolicyEntry ge = (PolicyEntry)it.next();
- if (ge.impliesPrincipals(null)
- && ge.impliesCodeSource(cs)) {
+ PolicyEntry ge = it.next();
+ if (ge.impliesPrincipals(null) && ge.impliesCodeSource(cs)) {
pc.addAll(ge.getPermissions());
}
}
diff --git a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_MessageDigestImpl.java b/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_MessageDigestImpl.java
index 82e9e7a..1ccfd1f 100644
--- a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_MessageDigestImpl.java
+++ b/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_MessageDigestImpl.java
@@ -142,12 +142,9 @@ public class SHA1_MessageDigestImpl extends MessageDigestSpi implements Cloneabl
* a clone of this object
*/
public Object clone() throws CloneNotSupportedException {
-
SHA1_MessageDigestImpl cloneObj = (SHA1_MessageDigestImpl) super.clone();
-
- cloneObj.buffer = ( int[])buffer.clone();
- cloneObj.oneByte = (byte[])oneByte.clone();
-
+ cloneObj.buffer = buffer.clone();
+ cloneObj.oneByte = oneByte.clone();
return cloneObj;
}
@@ -163,9 +160,7 @@ public class SHA1_MessageDigestImpl extends MessageDigestSpi implements Cloneabl
* byte array containing message digest value
*/
protected byte[] engineDigest() {
-
byte[] hash = new byte[DIGEST_LENGTH];
-
processDigest(hash, 0);
return hash;
}
diff --git a/luni/src/main/java/org/apache/harmony/security/x501/AttributeValue.java b/luni/src/main/java/org/apache/harmony/security/x501/AttributeValue.java
index 94ffa45..ecce1e0 100644
--- a/luni/src/main/java/org/apache/harmony/security/x501/AttributeValue.java
+++ b/luni/src/main/java/org/apache/harmony/security/x501/AttributeValue.java
@@ -182,11 +182,8 @@ public class AttributeValue {
StringBuilder buf = new StringBuilder(length * 2);
for (int index = 0; index < length; index++) {
-
char ch = name.charAt(index);
-
switch (ch) {
-
case ' ':
if (index == 0 || index == (length - 1)) {
// escape first or last space
@@ -198,6 +195,9 @@ public class AttributeValue {
case '"':
case '\\':
hasQE = true;
+ buf.append('\\');
+ buf.append(ch);
+ break;
case ',':
case '+':
@@ -207,9 +207,12 @@ public class AttributeValue {
case '#': // required by RFC 1779
case '=': // required by RFC 1779
buf.append('\\');
+ buf.append(ch);
+ break;
default:
buf.append(ch);
+ break;
}
}
diff --git a/luni/src/main/java/org/apache/harmony/security/x501/Name.java b/luni/src/main/java/org/apache/harmony/security/x501/Name.java
index a29c3df..c3c4ffd 100644
--- a/luni/src/main/java/org/apache/harmony/security/x501/Name.java
+++ b/luni/src/main/java/org/apache/harmony/security/x501/Name.java
@@ -185,8 +185,7 @@ public class Name {
if (X500Principal.CANONICAL == format) {
List sortedList = new LinkedList(atavList);
- Collections.sort(sortedList,
- new AttributeTypeAndValueComparator());
+ Collections.sort(sortedList, new AttributeTypeAndValueComparator());
atavList = sortedList;
}
diff --git a/luni/src/main/java/org/apache/harmony/security/x509/DNParser.java b/luni/src/main/java/org/apache/harmony/security/x509/DNParser.java
index 71cf52c..4f2ccd8 100644
--- a/luni/src/main/java/org/apache/harmony/security/x509/DNParser.java
+++ b/luni/src/main/java/org/apache/harmony/security/x509/DNParser.java
@@ -273,10 +273,12 @@ public class DNParser {
throw new IOException("Invalid distinguished name string");
}
- switch (chars[pos]) {
+ char ch = chars[pos];
+ switch (ch) {
case '"':
case '\\':
hasQE = true;
+ return ch;
case ',':
case '=':
case '+':
@@ -289,7 +291,7 @@ public class DNParser {
case '%':
case '_':
//FIXME: escaping is allowed only for leading or trailing space char
- return chars[pos];
+ return ch;
default:
// RFC doesn't explicitly say that escaped hex pair is
// interpreted as UTF-8 char. It only contains an example of such DN.
diff --git a/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java b/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java
index 5d0603b..9bff5f2 100644
--- a/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java
+++ b/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java
@@ -53,8 +53,8 @@ public class Extensions {
// Supported critical extensions oids:
private static List SUPPORTED_CRITICAL = Arrays.asList(
- new String[] {"2.5.29.15", "2.5.29.19", "2.5.29.32", "2.5.29.17",
- "2.5.29.30", "2.5.29.36", "2.5.29.37", "2.5.29.54"});
+ "2.5.29.15", "2.5.29.19", "2.5.29.32", "2.5.29.17",
+ "2.5.29.30", "2.5.29.36", "2.5.29.37", "2.5.29.54");
// the values of extensions of the structure
private List<Extension> extensions;
@@ -82,18 +82,8 @@ public class Extensions {
this.extensions = extensions;
}
- /**
- * Returns the values of extensions.
- * @return extensions
- */
- public List getExtensions() {
- return extensions;
- }
-
public int size() {
- return (extensions == null)
- ? 0
- : extensions.size();
+ return (extensions == null) ? 0 : extensions.size();
}
/**
@@ -137,7 +127,7 @@ public class Extensions {
critical = new HashSet(size);
noncritical = new HashSet(size);
for (int i=0; i<size; i++) {
- Extension extn = (Extension) extensions.get(i);
+ Extension extn = extensions.get(i);
String oid = extn.getExtnID();
if (extn.getCritical()) {
if (!SUPPORTED_CRITICAL.contains(oid)) {
diff --git a/luni/src/main/java/org/apache/harmony/security/x509/ReasonCode.java b/luni/src/main/java/org/apache/harmony/security/x509/ReasonCode.java
index 2c8bae9..d94e8b3 100644
--- a/luni/src/main/java/org/apache/harmony/security/x509/ReasonCode.java
+++ b/luni/src/main/java/org/apache/harmony/security/x509/ReasonCode.java
@@ -78,7 +78,7 @@ public class ReasonCode extends ExtensionValue {
*/
public byte[] getEncoded() {
if (encoding == null) {
- encoding = ASN1.encode(new byte[] {(byte) code});
+ encoding = ASN1.encode(new byte[] { code });
}
return encoding;
}
@@ -129,4 +129,3 @@ public class ReasonCode extends ExtensionValue {
*/
public static final ASN1Type ASN1 = ASN1Enumerated.getInstance();
}
-
diff --git a/xml/src/main/java/org/kxml2/io/KXmlParser.java b/xml/src/main/java/org/kxml2/io/KXmlParser.java
index 5cd2810..9fb858b 100644
--- a/xml/src/main/java/org/kxml2/io/KXmlParser.java
+++ b/xml/src/main/java/org/kxml2/io/KXmlParser.java
@@ -992,14 +992,14 @@ public class KXmlParser implements XmlPullParser, Closeable {
return ELEMENTDECL; // <!EL
case 'N':
return ENTITYDECL; // <!EN
- default:
- throw new XmlPullParserException("Unexpected <!", this, null);
}
+ break;
case 'A':
return ATTLISTDECL; // <!A
case 'N':
return NOTATIONDECL; // <!N
}
+ throw new XmlPullParserException("Unexpected <!", this, null);
default:
return START_TAG; // <
}
@@ -1660,6 +1660,7 @@ public class KXmlParser implements XmlPullParser, Closeable {
break;
}
}
+ break;
default:
// handle a byte order mark followed by something other than <?
diff --git a/xml/src/main/java/org/kxml2/io/KXmlSerializer.java b/xml/src/main/java/org/kxml2/io/KXmlSerializer.java
index 68259e0..d676c41 100644
--- a/xml/src/main/java/org/kxml2/io/KXmlSerializer.java
+++ b/xml/src/main/java/org/kxml2/io/KXmlSerializer.java
@@ -91,9 +91,7 @@ public class KXmlSerializer implements XmlSerializer {
writer.write(close ? " />" : ">");
}
- private final void writeEscaped(String s, int quot)
- throws IOException {
-
+ private final void writeEscaped(String s, int quot) throws IOException {
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
switch (c) {
@@ -114,14 +112,11 @@ public class KXmlSerializer implements XmlSerializer {
case '<' :
writer.write("&lt;");
break;
- case '"' :
- case '\'' :
+ default:
if (c == quot) {
- writer.write(
- c == '"' ? "&quot;" : "&apos;");
+ writer.write(c == '"' ? "&quot;" : "&apos;");
break;
}
- default :
// BEGIN android-changed: refuse to output invalid characters
// See http://www.w3.org/TR/REC-xml/#charsets for definition.
// No other Java XML writer we know of does this, but no Java
@@ -164,9 +159,7 @@ public class KXmlSerializer implements XmlSerializer {
public void endDocument() throws IOException {
while (depth > 0) {
- endTag(
- elementStack[depth * 3 - 3],
- elementStack[depth * 3 - 1]);
+ endTag(elementStack[depth * 3 - 3], elementStack[depth * 3 - 1]);
}
flush();
}