ICU-11918 Fixed compiler warnings.

X-SVN-Rev: 37977
This commit is contained in:
Yoshito Umaoka 2015-09-22 00:32:25 +00:00
parent 87970fe888
commit e5105c7f84
6 changed files with 38 additions and 48 deletions

View File

@ -12,7 +12,6 @@
package com.ibm.icu.impl.coll;
import java.util.Map;
import java.util.MissingResourceException;
import com.ibm.icu.impl.Norm2AllModes;
import com.ibm.icu.impl.Normalizer2Impl;

View File

@ -1,6 +1,6 @@
#*******************************************************************************
#* Copyright (C) 2009-2012, International Business Machines Corporation and *
#* Copyright (C) 2009-2015, International Business Machines Corporation and *
#* others. All Rights Reserved. *
#*******************************************************************************
shared.dir = ../../shared
javac.compilerarg = -Xlint:all,-deprecation,-dep-ann,-options
javac.compilerarg = -Xlint:all,-deprecation,-dep-ann,-options,-overrides

View File

@ -31,32 +31,33 @@ import com.ibm.icu.util.Freezable;
public class Relation<K, V> implements Freezable<Relation<K,V>> { // TODO: add , Map<K, Collection<V>>, but requires API changes
private Map<K, Set<V>> data;
Constructor<Set<V>> setCreator;
Constructor<? extends Set<V>> setCreator;
Object[] setComparatorParam;
public static <K,V> Relation<K, V> of(Map<K, Set<V>> map, Class<?> setCreator) {
return new Relation(map, setCreator);
public static <K, V> Relation<K, V> of(Map<K, Set<V>> map, Class<?> setCreator) {
return new Relation<K, V>(map, setCreator);
}
public static <K,V> Relation<K, V> of(Map<K, Set<V>> map, Class setCreator, Comparator<V> setComparator) {
return new Relation(map, setCreator, setComparator);
public static <K,V> Relation<K, V> of(Map<K, Set<V>> map, Class<?> setCreator, Comparator<V> setComparator) {
return new Relation<K, V>(map, setCreator, setComparator);
}
public Relation(Map<K, Set<V>> map, Class<Set<V>> setCreator) {
public Relation(Map<K, Set<V>> map, Class<?> setCreator) {
this(map, setCreator, null);
}
public Relation(Map<K, Set<V>> map, Class<Set<V>> setCreator, Comparator<V> setComparator) {
@SuppressWarnings("unchecked")
public Relation(Map<K, Set<V>> map, Class<?> setCreator, Comparator<V> setComparator) {
try {
setComparatorParam = setComparator == null ? null : new Object[]{setComparator};
if (setComparator == null) {
this.setCreator = setCreator.getConstructor();
this.setCreator = ((Class<? extends Set<V>>)setCreator).getConstructor();
this.setCreator.newInstance(setComparatorParam); // check to make sure compiles
} else {
this.setCreator = setCreator.getConstructor(Comparator.class);
this.setCreator = ((Class<? extends Set<V>>)setCreator).getConstructor(Comparator.class);
this.setCreator.newInstance(setComparatorParam); // check to make sure compiles
}
data = map == null ? new HashMap() : map;
data = map == null ? new HashMap<K, Set<V>>() : map;
} catch (Exception e) {
throw (RuntimeException) new IllegalArgumentException("Can't create new set").initCause(e);
}
@ -88,10 +89,10 @@ public class Relation<K, V> implements Freezable<Relation<K,V>> { // TODO: add ,
}
public Set<Entry<K, V>> keyValueSet() {
Set<Entry<K, V>> result = new LinkedHashSet();
Set<Entry<K, V>> result = new LinkedHashSet<Entry<K, V>>();
for (K key : data.keySet()) {
for (V value : data.get(key)) {
result.add(new SimpleEntry(key, value));
result.add(new SimpleEntry<K, V>(key, value));
}
}
return result;
@ -102,7 +103,7 @@ public class Relation<K, V> implements Freezable<Relation<K,V>> { // TODO: add ,
return false;
if (o.getClass() != this.getClass())
return false;
return data.equals(((Relation) o).data);
return data.equals(((Relation<?, ?>) o).data);
}
// public V get(Object key) {
@ -209,7 +210,7 @@ public class Relation<K, V> implements Freezable<Relation<K,V>> { // TODO: add ,
}
public Set<V> values() {
return values(new LinkedHashSet());
return values(new LinkedHashSet<V>());
}
public <C extends Collection<V>> C values(C result) {
@ -321,7 +322,7 @@ public class Relation<K, V> implements Freezable<Relation<K,V>> { // TODO: add ,
}
public Set<V> removeAll(Collection<K> toBeRemoved) {
Set<V> result = new LinkedHashSet();
Set<V> result = new LinkedHashSet<V>();
for (K key : toBeRemoved) {
try {
final Set<V> removals = data.remove(key);

View File

@ -13,7 +13,6 @@ import com.ibm.icu.impl.CharacterIteratorWrapper;
import com.ibm.icu.impl.ReplaceableUCharacterIterator;
import com.ibm.icu.impl.UCharArrayIterator;
import com.ibm.icu.impl.UCharacterIteratorWrapper;
import com.ibm.icu.impl.UCharacterProperty;
/**

View File

@ -579,7 +579,9 @@ public class LocaleMatcherTest extends TestFmwk {
int iterations = i == 0 ? 1000 : 100000;
boolean showMessage = i != 0;
long timeShort = timeLocaleMatcher("Duration (few supported):\t", desired, matcherShort, showMessage, iterations, 0);
@SuppressWarnings("unused")
long timeMedium = timeLocaleMatcher("Duration (med. supported):\t", desired, matcherLong, showMessage, iterations, timeShort);
@SuppressWarnings("unused")
long timeLong = timeLocaleMatcher("Duration (many supported):\t", desired, matcherVeryLong, showMessage, iterations, timeShort);
}
}

View File

@ -8,51 +8,40 @@ package com.ibm.icu.dev.tool.docs;
import com.sun.javadoc.Doc;
import com.sun.javadoc.Tag;
import com.sun.tools.doclets.formats.html.markup.RawHtml;
import com.sun.tools.doclets.internal.toolkit.Content;
import com.sun.tools.doclets.internal.toolkit.taglets.Taglet;
import com.sun.tools.doclets.internal.toolkit.taglets.TagletOutput;
import com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter;
/**
* The ICUTagletAdapter class is the abstract base class that adapts the ICUTaglet class to different implementations of the JavaDoc API.
* The methods in this class are meant to minimize the dual maintenance nature of supporting multiple JavaDoc APIs.
*
* This adapter supports the v8 JavaDoc API
* This adapter supports the v7 and earlier JavaDoc API
*/
public abstract class ICUTagletAdapter implements Taglet {
public abstract String toString(Tag tag);
public abstract String toString(Tag[] tags);
public Content getTagletOutput(Tag tag, TagletWriter writer)
throws IllegalArgumentException {
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer)
throws IllegalArgumentException {
// addContext doesn't except nulls so filter them out
String encodedText = toString(tag);
if(encodedText == null) return null;
Content out = writer.getOutputInstance();
out.addContent(new RawHtml(encodedText));
return out;
}
public Content getTagletOutput(Doc holder, TagletWriter writer)
throws IllegalArgumentException {
Content out = writer.getOutputInstance();
Tag[] tags = holder.tags(getName());
if (tags.length == 0) {
return null;
TagletOutput out = writer.getTagletOutputInstance();
out.setOutput(toString(tag));
return out;
}
// addContext doesn't except nulls so filter them out
String encodedText = toString(tags[0]);
if(encodedText == null) return null;
public TagletOutput getTagletOutput(Doc holder, TagletWriter writer)
throws IllegalArgumentException {
out.addContent(new RawHtml(encodedText));
return out;
}
TagletOutput out = writer.getTagletOutputInstance();
Tag[] tags = holder.tags(getName());
if (tags.length == 0) {
return null;
}
out.setOutput(toString(tags[0]));
return out;
}
}