eliminate some compiler unchecked and deprecation warnings

in nav plugins by explicite type declaration and replacing date.getYear
with Calendar.get
pull/114/head
reger 8 years ago
parent 6eb7d27449
commit 9b6d1abd9e

@ -39,7 +39,7 @@ public class NavigatorPlugins {
* @return Map key=navigatorCfgname, value=std.DisplayName
*/
static public Map<String, String> listAvailable() {
Map<String, String> defaultnavplugins = new TreeMap();
Map<String, String> defaultnavplugins = new TreeMap<String, String>();
defaultnavplugins.put("filetype", "Filetype");
// defaultnavplugins.put("hosts", "Provider");
// defaultnavplugins.put("language", "Language");

@ -22,6 +22,7 @@
*/
package net.yacy.search.navigator;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@ -97,20 +98,21 @@ public class YearNavigator extends StringNavigator implements Navigator {
if (field.getType() == SolrType.date) {
Object val = doc.getFieldValue(field.getSolrFieldName());
if (val != null) {
Calendar cal = Calendar.getInstance();
if (val instanceof Collection) {
Collection<Object> ll = (Collection) val;
for (Object o : ll) {
if (o instanceof String) {
this.inc((String) o);
} else if (o instanceof Date) {
Date dd = (Date) o;
String year = Integer.toString(dd.getYear() + 1900);
cal.setTime((Date) o);
String year = Integer.toString(cal.get(Calendar.YEAR));
this.inc(year);
}
}
} else {
Date dd = (Date) val;
String year = Integer.toString(dd.getYear() + 1900);
cal.setTime((Date) val);
String year = Integer.toString(cal.get(Calendar.YEAR));
this.inc(year);
}
}
@ -131,7 +133,7 @@ public class YearNavigator extends StringNavigator implements Navigator {
if (up) {
years = new TreeSet<String>();
} else {
years = new TreeSet(Collections.reverseOrder());
years = new TreeSet<String>(Collections.reverseOrder());
}
// make sure keys with high score are included (display may be limited in size)

Loading…
Cancel
Save