Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Fixed "Unchecked conversion" compilation warnings.
luccioman527d494c1abe
diff --git a/source/net/yacy/cora/federate/solr/responsewriter/FlatJSONResponseWriter.java b/source/net/yacy/cora/federate/solr/responsewriter/FlatJSONResponseWriter.javaindex 4921fcd1e..e30a566a8 100644--- a/source/net/yacy/cora/federate/solr/responsewriter/FlatJSONResponseWriter.java+++ b/source/net/yacy/cora/federate/solr/responsewriter/FlatJSONResponseWriter.java@@ -31,8 +31,6 @@ import org.apache.lucene.document.Document;import org.apache.lucene.index.IndexableField;import org.apache.solr.common.SolrDocument;import org.apache.solr.common.util.NamedList;-import org.apache.solr.common.util.SimpleOrderedMap;-import org.apache.solr.common.util.XML;import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.response.QueryResponseWriter;import org.apache.solr.response.ResultContext;diff --git a/source/net/yacy/cora/util/JSONArray.java b/source/net/yacy/cora/util/JSONArray.javaindex 9e7448a84..ae55e3891 100644--- a/source/net/yacy/cora/util/JSONArray.java+++ b/source/net/yacy/cora/util/JSONArray.java@@ -150,10 +150,10 @@ public class JSONArray {* @param collection* A Collection.*/- public JSONArray(Collection<Object> collection) {+ public JSONArray(Collection<?> collection) {this.myArrayList = new ArrayList<Object>();if (collection != null) {- Iterator<Object> iter = collection.iterator();+ Iterator<?> iter = collection.iterator();while (iter.hasNext()) {this.myArrayList.add(JSONObject.wrap(iter.next()));}@@ -593,7 +593,7 @@ public class JSONArray {* A Collection value.* @return this.*/- public JSONArray put(Collection<Object> value) {+ public JSONArray put(Collection<?> value) {this.put(new JSONArray(value));return this;}@@ -646,7 +646,7 @@ public class JSONArray {* A Map value.* @return this.*/- public JSONArray put(Map<String, Object> value) {+ public JSONArray put(Map<String, ?> value) {this.put(new JSONObject(value));return this;}@@ -695,7 +695,7 @@ public class JSONArray {* @throws JSONException* If the index is negative or if the value is not finite.*/- public JSONArray put(int index, Collection<Object> value) throws JSONException {+ public JSONArray put(int index, Collection<?> value) throws JSONException {this.put(index, new JSONArray(value));return this;}@@ -767,7 +767,7 @@ public class JSONArray {* If the index is negative or if the the value is an invalid* number.*/- public JSONArray put(int index, Map<String, Object> value) throws JSONException {+ public JSONArray put(int index, Map<String, ?> value) throws JSONException {this.put(index, new JSONObject(value));return this;}diff --git a/source/net/yacy/cora/util/JSONObject.java b/source/net/yacy/cora/util/JSONObject.javaindex 80dadbd2c..e5e27b8ca 100644--- a/source/net/yacy/cora/util/JSONObject.java+++ b/source/net/yacy/cora/util/JSONObject.java@@ -249,15 +249,15 @@ public class JSONObject {* the JSONObject.* @throws JSONException*/- public JSONObject(Map<String, Object> map) {+ public<KEY_TYPE, VALUE_TYPE> JSONObject(Map<KEY_TYPE, VALUE_TYPE> map) {this.map = new LinkedHashMap<String, Object>();if (map != null) {- Iterator<Entry<String, Object>> i = map.entrySet().iterator();+ Iterator<Entry<KEY_TYPE, VALUE_TYPE>> i = map.entrySet().iterator();while (i.hasNext()) {- Entry<String, Object> entry = i.next();+ Entry<KEY_TYPE, VALUE_TYPE> entry = i.next();Object value = entry.getValue();- if (value != null) {- this.map.put(entry.getKey(), wrap(value));+ if (value != null && entry.getKey() instanceof String) {+ this.map.put((String)entry.getKey(), wrap(value));}}}@@ -1063,7 +1063,7 @@ public class JSONObject {* @return this.* @throws JSONException*/- public JSONObject put(String key, Collection<Object> value) throws JSONException {+ public JSONObject put(String key, Collection<?> value) throws JSONException {this.put(key, new JSONArray(value));return this;}@@ -1127,7 +1127,7 @@ public class JSONObject {* @return this.* @throws JSONException*/- public JSONObject put(String key, Map<String, Object> value) throws JSONException {+ public JSONObject put(String key, Map<String, ?> value) throws JSONException {this.put(key, new JSONObject(value));return this;}@@ -1498,7 +1498,6 @@ public class JSONObject {* @throws JSONException* If the value is or contains an invalid number.*/- @SuppressWarnings("unchecked")public static String valueToString(Object value) throws JSONException {if (value == null || value.equals(null)) {return "null";@@ -1523,10 +1522,10 @@ public class JSONObject {return value.toString();}if (value instanceof Map) {- return new JSONObject((Map<String, Object>)value).toString();+ return new JSONObject((Map<?, ?>)value).toString();}if (value instanceof Collection) {- return new JSONArray((Collection<Object>) value).toString();+ return new JSONArray((Collection<?>) value).toString();}if (value.getClass().isArray()) {return new JSONArray(value).toString();@@ -1546,7 +1545,6 @@ public class JSONObject {* The object to wrap* @return The wrapped value*/- @SuppressWarnings("unchecked")public static Object wrap(Object object) {try {if (object == null) {@@ -1563,13 +1561,13 @@ public class JSONObject {}if (object instanceof Collection) {- return new JSONArray((Collection<Object>) object);+ return new JSONArray((Collection<?>) object);}if (object.getClass().isArray()) {return new JSONArray(object);}if (object instanceof Map) {- return new JSONObject((Map<String, Object>) object);+ return new JSONObject((Map<?, ?>) object);}Package objectPackage = object.getClass().getPackage();String objectPackageName = objectPackage != null ? objectPackage@@ -1598,7 +1596,6 @@ public class JSONObject {return this.write(writer, 0, 0);}- @SuppressWarnings("unchecked")static final Writer writeValue(Writer writer, Object value,int indentFactor, int indent) throws JSONException, IOException {if (value == null || value.equals(null)) {@@ -1608,9 +1605,9 @@ public class JSONObject {} else if (value instanceof JSONArray) {((JSONArray) value).write(writer, indentFactor, indent);} else if (value instanceof Map) {- new JSONObject((Map<String, Object>) value).write(writer, indentFactor, indent);+ new JSONObject((Map<?, ?>) value).write(writer, indentFactor, indent);} else if (value instanceof Collection) {- new JSONArray((Collection<Object>) value).write(writer, indentFactor,+ new JSONArray((Collection<?>) value).write(writer, indentFactor,indent);} else if (value.getClass().isArray()) {new JSONArray(value).write(writer, indentFactor, indent);diff --git a/source/net/yacy/document/parser/pdfParser.java b/source/net/yacy/document/parser/pdfParser.javaindex 4f173326e..58929bf9f 100644--- a/source/net/yacy/document/parser/pdfParser.java+++ b/source/net/yacy/document/parser/pdfParser.java@@ -146,11 +146,10 @@ public class pdfParser extends AbstractParser implements Parser {docKeywords = docKeywordStr.split(" |,");}- Collection<AnchorURL>[] pdflinks = null;Document[] result = null;try {// get the links- pdflinks = extractPdfLinks(pdfDoc);+ final List<Collection<AnchorURL>> pdflinks = extractPdfLinks(pdfDoc);// get the fulltext (either per document or for each page)final PDFTextStripper stripper = new PDFTextStripper(/*StandardCharsets.UTF_8.name()*/);@@ -170,8 +169,8 @@ public class pdfParser extends AbstractParser implements Parser {}// create individual documents for each page- assert pages.length == pdflinks.length : "pages.length = " + pages.length + ", pdflinks.length = " + pdflinks.length;- result = new Document[Math.min(pages.length, pdflinks.length)];+ assert pages.length == pdflinks.size() : "pages.length = " + pages.length + ", pdflinks.length = " + pdflinks.size();+ result = new Document[Math.min(pages.length, pdflinks.size())];String loc = location.toNormalform(true);for (int page = 0; page < result.length; page++) {result[page] = new Document(@@ -188,7 +187,7 @@ public class pdfParser extends AbstractParser implements Parser {null,0.0d, 0.0d,pages == null || page > pages.length ? new byte[0] : UTF8.getBytes(pages[page]),- pdflinks == null || page >= pdflinks.length ? null : pdflinks[page],+ pdflinks == null || page >= pdflinks.size() ? null : pdflinks.get(page),null,null,false,@@ -272,9 +271,8 @@ public class pdfParser extends AbstractParser implements Parser {* @param pdf the document to parse* @return all detected links*/- private Collection<AnchorURL>[] extractPdfLinks(final PDDocument pdf) {- Collection<AnchorURL>[] linkCollections = (Collection<AnchorURL>[]) new Collection<?>[pdf.getNumberOfPages()];- int pagecount = 0;+ private List<Collection<AnchorURL>> extractPdfLinks(final PDDocument pdf) {+ List<Collection<AnchorURL>> linkCollections = new ArrayList<>(pdf.getNumberOfPages());for (PDPage page : pdf.getPages()) {final Collection<AnchorURL> pdflinks = new ArrayList<AnchorURL>();try {@@ -293,7 +291,7 @@ public class pdfParser extends AbstractParser implements Parser {}}} catch (IOException ex) {}- linkCollections[pagecount++] = pdflinks;+ linkCollections.add(pdflinks);}return linkCollections;}diff --git a/source/net/yacy/search/navigator/FileTypeNavigator.java b/source/net/yacy/search/navigator/FileTypeNavigator.javaindex 73c632274..bf89438e0 100644--- a/source/net/yacy/search/navigator/FileTypeNavigator.java+++ b/source/net/yacy/search/navigator/FileTypeNavigator.java@@ -66,12 +66,15 @@ public class FileTypeNavigator extends StringNavigator implements Navigator {if (field != null) {Object val = doc.getFieldValue(field.getSolrFieldName());if (val instanceof Collection) {- Collection<String> ll = (Collection) val;- for (String s : ll) {- // remove all filetypes that we don't know- if (Classification.isAnyKnownExtension(s)) {- this.inc(s);- }+ Collection<?> ll = (Collection<?>) val;+ for (Object obj : ll) {+ if(obj instanceof String) {+ final String s = (String)obj;+ // remove all filetypes that we don't know+ if (Classification.isAnyKnownExtension(s)) {+ this.inc(s);+ }+ }}} else {if (val != null) {diff --git a/source/net/yacy/search/navigator/HostNavigator.java b/source/net/yacy/search/navigator/HostNavigator.javaindex 361831710..ab950799c 100644--- a/source/net/yacy/search/navigator/HostNavigator.java+++ b/source/net/yacy/search/navigator/HostNavigator.java@@ -64,12 +64,15 @@ public class HostNavigator extends StringNavigator implements Navigator {Object val = doc.getFieldValue(field.getSolrFieldName());if (val != null) {if (val instanceof Collection) {- Collection<String> ll = (Collection) val;- for (String s : ll) {- if (s.startsWith("www.")) {- s = s.substring(4);- }- this.inc(s);+ Collection<?> ll = (Collection<?>) val;+ for (Object obj : ll) {+ if(obj instanceof String) {+ String s = (String)obj;+ if (s.startsWith("www.")) {+ s = s.substring(4);+ }+ this.inc(s);+ }}} else {String host = (String) val;diff --git a/source/net/yacy/search/navigator/StringNavigator.java b/source/net/yacy/search/navigator/StringNavigator.javaindex 4720890bc..c0d5c78eb 100644--- a/source/net/yacy/search/navigator/StringNavigator.java+++ b/source/net/yacy/search/navigator/StringNavigator.java@@ -114,7 +114,7 @@ public class StringNavigator extends ConcurrentScoreMap<String> implements Navi/*** Increase the score for the key value contained in the defined field in* the doc.- * @param doc Solrdocument with field for the key content+ * @param doc URIMetadataNode with field for the key content*/@Overridepublic void incDoc(URIMetadataNode doc) {@@ -122,11 +122,14 @@ public class StringNavigator extends ConcurrentScoreMap<String> implements NaviObject val = doc.getFieldValue(field.getSolrFieldName());if (val != null) {if (val instanceof Collection) {- Collection<String> ll = (Collection) val;- for (String s : ll) {- if (!s.isEmpty()) {- this.inc(s);- }+ Collection<?> ll = (Collection<?>) val;+ for (Object obj : ll) {+ if(obj instanceof String) {+ final String s = (String)obj;+ if (!s.isEmpty()) {+ this.inc(s);+ }+ }}} else {this.inc((String) val);diff --git a/source/net/yacy/search/navigator/TokenizedStringNavigator.java b/source/net/yacy/search/navigator/TokenizedStringNavigator.javaindex 2298ea37b..6a788f292 100644--- a/source/net/yacy/search/navigator/TokenizedStringNavigator.java+++ b/source/net/yacy/search/navigator/TokenizedStringNavigator.java@@ -50,17 +50,20 @@ public class TokenizedStringNavigator extends StringNavigator implements NavigaObject val = doc.getFieldValue(field.getSolrFieldName());if (val != null) {if (val instanceof Collection) {- Collection<String> ll = (Collection) val;- for (String s : ll) {- if (!s.isEmpty()) {- StringTokenizer token = new StringTokenizer(s.toLowerCase()," ,;"); // StringTokenizer faster than regex pattern- while (token.hasMoreTokens()) {- String word = token.nextToken();- if (word.length() > 1 && !Switchboard.stopwords.contains(word)) {- this.inc(word);- }- }- }+ Collection<?> ll = (Collection<?>) val;+ for (Object obj : ll) {+ if(obj instanceof String) {+ final String s = (String)obj;+ if (!s.isEmpty()) {+ StringTokenizer token = new StringTokenizer(s.toLowerCase()," ,;"); // StringTokenizer faster than regex pattern+ while (token.hasMoreTokens()) {+ String word = token.nextToken();+ if (word.length() > 1 && !Switchboard.stopwords.contains(word)) {+ this.inc(word);+ }+ }+ }+ }}} else {StringTokenizer token = new StringTokenizer((String) val, " ,;");diff --git a/source/net/yacy/search/navigator/YearNavigator.java b/source/net/yacy/search/navigator/YearNavigator.javaindex b3ccab367..edaec4c20 100644--- a/source/net/yacy/search/navigator/YearNavigator.java+++ b/source/net/yacy/search/navigator/YearNavigator.java@@ -100,7 +100,7 @@ public class YearNavigator extends StringNavigator implements Navigator {if (val != null) {Calendar cal = Calendar.getInstance();if (val instanceof Collection) {- Collection<Object> ll = (Collection) val;+ Collection<?> ll = (Collection<?>) val;for (Object o : ll) {if (o instanceof String) {this.inc((String) o);