replaced new Number(Number) with Number.instanceOf

to remove deprecation warnings for Java 9
This commit is contained in:
Michael Peter Christen 2021-08-08 00:39:03 +02:00
parent 9e13d77de4
commit e9c5e78868
10 changed files with 685 additions and 685 deletions

View File

@ -117,7 +117,7 @@ public class IntVector {
int oldValue = data[index]; int oldValue = data[index];
int numMoved = elt - index - 1; int numMoved = elt - index - 1;
Integer n = new Integer(elt); Integer n = Integer.valueOf(elt);
if (numMoved > 0) if (numMoved > 0)
System.arraycopy(n, index+1, n, index,numMoved); System.arraycopy(n, index+1, n, index,numMoved);
elt = n.intValue(); elt = n.intValue();

View File

@ -114,7 +114,7 @@ public class LongVector {
long oldValue = data[index]; long oldValue = data[index];
int numMoved = elt - index - 1; int numMoved = elt - index - 1;
Integer n = new Integer(elt); Integer n = Integer.valueOf(elt);
if (numMoved > 0) if (numMoved > 0)
System.arraycopy(n, index+1, n, index,numMoved); System.arraycopy(n, index+1, n, index,numMoved);
elt = n.intValue(); elt = n.intValue();

View File

@ -322,11 +322,11 @@ public class ArchiveDB {
Folder folder = (Folder)folders.get(i); Folder folder = (Folder)folders.get(i);
if (numSubstreams == 1 && folder.UnPackCRCDefined) { if (numSubstreams == 1 && folder.UnPackCRCDefined) {
bsizes.add(Boolean.TRUE); bsizes.add(Boolean.TRUE);
sizes.add(new Integer(folder.UnPackCRC)); sizes.add(Integer.valueOf(folder.UnPackCRC));
} else { } else {
for (int j=0; j<numSubstreams; j++, digestIndex++) { for (int j=0; j<numSubstreams; j++, digestIndex++) {
bsizes.add(new Boolean(digestsDefined2.get(digestIndex))); bsizes.add(Boolean.valueOf(digestsDefined2.get(digestIndex)));
sizes.add(new Integer(digests2.get(digestIndex))); sizes.add(Integer.valueOf(digests2.get(digestIndex)));
} }
} }
} }

View File

@ -1406,7 +1406,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
*@exception IOException Description of the Exception *@exception IOException Description of the Exception
*/ */
public void push(float value) throws IOException { public void push(float value) throws IOException {
pushValues.add(new Float(value)); pushValues.add(Float.valueOf(value));
if (flashVersion < 5) { if (flashVersion < 5) {
flushPushValues(); flushPushValues();
} }

View File

@ -29,11 +29,11 @@ public enum SolrType {
date("dt", "dts"), // date format as in http://www.w3.org/TR/xmlschema-2/#dateTime with trailing 'Z' date("dt", "dts"), // date format as in http://www.w3.org/TR/xmlschema-2/#dateTime with trailing 'Z'
bool("b", "bs", "boolean"), bool("b", "bs", "boolean"),
num_integer("i", "val", "int"), num_integer("i", "val", "int"),
num_long("l", "ls", "long"), num_long("l", "ls", "long"),
num_float("f", "fs", "float"), num_float("f", "fs", "float"),
num_double("d", "ds", "double"), num_double("d", "ds", "double"),
coordinate("coordinate", "coordinatex", "tdouble"); coordinate("coordinate", "coordinatex", "tdouble");
private String printName, singlevalExt, multivalExt; private String printName, singlevalExt, multivalExt;
private SolrType(final String singlevalExt, final String multivalExt) { private SolrType(final String singlevalExt, final String multivalExt) {
this.printName = this.name(); this.printName = this.name();
@ -49,21 +49,21 @@ public enum SolrType {
return this.printName; return this.printName;
} }
public boolean appropriateName(final SchemaDeclaration collectionSchema) { public boolean appropriateName(final SchemaDeclaration collectionSchema) {
String field = collectionSchema.name(); final String field = collectionSchema.name();
int p = field.indexOf('_'); final int p = field.indexOf('_');
if (p < 0 || field.length() - p > 4) return true; // special names may have no type extension if (p < 0 || field.length() - p > 4) return true; // special names may have no type extension
String ext = field.substring(p + 1); final String ext = field.substring(p + 1);
boolean ok = collectionSchema.isMultiValued() ? this.multivalExt.equals(ext) : this.singlevalExt.equals(ext); boolean ok = collectionSchema.isMultiValued() ? this.multivalExt.equals(ext) : this.singlevalExt.equals(ext);
assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + new Boolean(collectionSchema.isMultiValued()).toString() + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt; assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + Boolean.toString(collectionSchema.isMultiValued()) + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
if (!ok) return ok; if (!ok) return ok;
ok = !"s".equals(this.singlevalExt) || collectionSchema.isMultiValued() || field.endsWith("s"); ok = !"s".equals(this.singlevalExt) || collectionSchema.isMultiValued() || field.endsWith("s");
assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + new Boolean(collectionSchema.isMultiValued()).toString() + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt; assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + Boolean.toString(collectionSchema.isMultiValued()) + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
if (!ok) return ok; if (!ok) return ok;
ok = !"sxt".equals(this.singlevalExt) || !collectionSchema.isMultiValued() || field.endsWith("sxt"); ok = !"sxt".equals(this.singlevalExt) || !collectionSchema.isMultiValued() || field.endsWith("sxt");
assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + new Boolean(collectionSchema.isMultiValued()).toString() + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt; assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + Boolean.toString(collectionSchema.isMultiValued()) + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
if (!ok) return ok; if (!ok) return ok;
ok = !"t".equals(this.singlevalExt) || collectionSchema.isMultiValued() || field.endsWith("t"); ok = !"t".equals(this.singlevalExt) || collectionSchema.isMultiValued() || field.endsWith("t");
assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + new Boolean(collectionSchema.isMultiValued()).toString() + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt; assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + Boolean.toString(collectionSchema.isMultiValued()) + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
if (!ok) return ok; if (!ok) return ok;
return ok; return ok;
} }

View File

@ -133,14 +133,14 @@ public class Array {
@Override @Override
public Integer buffer() { public Integer buffer() {
return new Integer(0); return Integer.valueOf(0);
} }
@Override @Override
public void swap(final int i, final int j, Integer buffer) { public void swap(final int i, final int j, Integer buffer) {
buffer = get(i); buffer = this.get(i);
set(i, get(j)); this.set(i, this.get(j));
set(j, buffer); this.set(j, buffer);
} }
@Override @Override
@ -150,7 +150,7 @@ public class Array {
@Override @Override
public Integer get(final int i, final boolean clone) { public Integer get(final int i, final boolean clone) {
return get(i); return this.get(i);
} }
} }

View File

@ -7,12 +7,12 @@
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with this program in the file lgpl21.txt * along with this program in the file lgpl21.txt
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
@ -34,7 +34,7 @@ public class LargeNumberCache {
// fill the cache // fill the cache
static { static {
integerCache = new Integer[integerCacheLimit]; integerCache = new Integer[integerCacheLimit];
for (int i = 0; i < integerCache.length; i++) integerCache[i] = new Integer(i); for (int i = 0; i < integerCache.length; i++) integerCache[i] = Integer.valueOf(i);
} }
/** /**
@ -50,8 +50,8 @@ public class LargeNumberCache {
*/ */
public final static Integer valueOf(final int i) { public final static Integer valueOf(final int i) {
if (i < 0) return Integer.valueOf(i); if (i < 0) return Integer.valueOf(i);
if (i >= integerCacheLimit) return new Integer(i); if (i >= integerCacheLimit) return Integer.valueOf(i);
return integerCache[i]; return integerCache[i];
} }
} }

View File

@ -83,10 +83,10 @@ public class MapDataMining extends MapHeap {
ScoreMap<String>[] cluster = null; ScoreMap<String>[] cluster = null;
if (sortfields == null) this.sortClusterMap = null; else { if (sortfields == null) this.sortClusterMap = null; else {
this.sortClusterMap = new ConcurrentHashMap<String, ScoreMap<String>>(); this.sortClusterMap = new ConcurrentHashMap<>();
cluster = (ScoreMap<String>[]) Array.newInstance(ScoreMap.class, sortfields.length); cluster = (ScoreMap<String>[]) Array.newInstance(ScoreMap.class, sortfields.length);
for (int i = 0; i < sortfields.length; i++) { for (int i = 0; i < sortfields.length; i++) {
cluster[i] = new ConcurrentScoreMap<String>(); cluster[i] = new ConcurrentScoreMap<>();
} }
} }
@ -95,7 +95,7 @@ public class MapDataMining extends MapHeap {
if (longaccfields == null) { if (longaccfields == null) {
this.accLong = null; this.accLong = null;
} else { } else {
this.accLong = new ConcurrentHashMap<String, Long>(); this.accLong = new ConcurrentHashMap<>();
longaccumulator = new Long[longaccfields.length]; longaccumulator = new Long[longaccfields.length];
for (int i = 0; i < longaccfields.length; i++) { for (int i = 0; i < longaccfields.length; i++) {
longaccumulator[i] = LONG0; longaccumulator[i] = LONG0;
@ -104,7 +104,7 @@ public class MapDataMining extends MapHeap {
if (floataccfields == null) { if (floataccfields == null) {
this.accFloat = null; this.accFloat = null;
} else { } else {
this.accFloat = new ConcurrentHashMap<String, Float>(); this.accFloat = new ConcurrentHashMap<>();
floataccumulator = new Float[floataccfields.length]; floataccumulator = new Float[floataccfields.length];
for (int i = 0; i < floataccfields.length; i++) { for (int i = 0; i < floataccfields.length; i++) {
floataccumulator[i] = FLOAT0; floataccumulator[i] = FLOAT0;
@ -153,7 +153,7 @@ public class MapDataMining extends MapHeap {
valued = 0f; valued = 0f;
if (cell != null) try { if (cell != null) try {
valued = Float.parseFloat(cell); valued = Float.parseFloat(cell);
floataccumulator[i] = new Float(floataccumulator[i].floatValue() + valued); floataccumulator[i] = Float.valueOf(floataccumulator[i].floatValue() + valued);
} catch (final NumberFormatException e) {} } catch (final NumberFormatException e) {}
} }
} }
@ -178,7 +178,7 @@ public class MapDataMining extends MapHeap {
public synchronized void clear() { public synchronized void clear() {
super.clear(); super.clear();
if (this.sortfields == null) this.sortClusterMap = null; else { if (this.sortfields == null) this.sortClusterMap = null; else {
this.sortClusterMap = new HashMap<String, ScoreMap<String>>(); this.sortClusterMap = new HashMap<>();
for (final String sortfield : this.sortfields) { for (final String sortfield : this.sortfields) {
this.sortClusterMap.put(sortfield, new ConcurrentScoreMap<String>()); this.sortClusterMap.put(sortfield, new ConcurrentScoreMap<String>());
} }
@ -187,7 +187,7 @@ public class MapDataMining extends MapHeap {
if (this.longaccfields == null) { if (this.longaccfields == null) {
this.accLong = null; this.accLong = null;
} else { } else {
this.accLong = new HashMap<String, Long>(); this.accLong = new HashMap<>();
for (final String longaccfield : this.longaccfields) { for (final String longaccfield : this.longaccfields) {
this.accLong.put(longaccfield, LONG0); this.accLong.put(longaccfield, LONG0);
} }
@ -195,7 +195,7 @@ public class MapDataMining extends MapHeap {
if (this.floataccfields == null) { if (this.floataccfields == null) {
this.accFloat = null; this.accFloat = null;
} else { } else {
this.accFloat = new HashMap<String, Float>(); this.accFloat = new HashMap<>();
for (final String floataccfield : this.floataccfields) { for (final String floataccfield : this.floataccfields) {
this.accFloat.put(floataccfield, FLOAT0); this.accFloat.put(floataccfield, FLOAT0);
} }
@ -215,17 +215,17 @@ public class MapDataMining extends MapHeap {
final Map<String, String> oldMap = super.get(key, false); final Map<String, String> oldMap = super.get(key, false);
if (oldMap != null) { if (oldMap != null) {
// element exists, update acc // element exists, update acc
updateAcc(oldMap, false); this.updateAcc(oldMap, false);
} }
// update accumulators with new values (add) // update accumulators with new values (add)
updateAcc(newMap, true); this.updateAcc(newMap, true);
} }
super.insert(key, newMap); super.insert(key, newMap);
// update sortCluster // update sortCluster
if (this.sortClusterMap != null) updateSortCluster(UTF8.String(key), newMap); if (this.sortClusterMap != null) this.updateSortCluster(UTF8.String(key), newMap);
this.columnIndex.update(key, newMap); this.columnIndex.update(key, newMap);
} }
@ -295,10 +295,10 @@ public class MapDataMining extends MapHeap {
if (map != null) { if (map != null) {
// update accumulators (subtract) // update accumulators (subtract)
if (this.longaccfields != null || this.floataccfields != null) updateAcc(map, false); if (this.longaccfields != null || this.floataccfields != null) this.updateAcc(map, false);
// remove from sortCluster // remove from sortCluster
if (this.sortfields != null) deleteSortCluster(UTF8.String(key)); if (this.sortfields != null) this.deleteSortCluster(UTF8.String(key));
} }
} catch (final SpaceExceededException e) { } catch (final SpaceExceededException e) {
map = null; map = null;
@ -365,7 +365,7 @@ public class MapDataMining extends MapHeap {
try { try {
idx = this.columnIndex.getIndex(whereKey, isValue); idx = this.columnIndex.getIndex(whereKey, isValue);
} catch (final UnsupportedOperationException e) { } catch (final UnsupportedOperationException e) {
this.columnIndex.init(whereKey, isValue, new FullMapIterator(keys())); this.columnIndex.init(whereKey, isValue, new FullMapIterator(this.keys()));
try { try {
idx = this.columnIndex.getIndex(whereKey, isValue); idx = this.columnIndex.getIndex(whereKey, isValue);
} catch (final UnsupportedOperationException ee) { } catch (final UnsupportedOperationException ee) {
@ -376,7 +376,7 @@ public class MapDataMining extends MapHeap {
} }
public synchronized Iterator<Map.Entry<byte[], Map<String, String>>> entries(final boolean up, final String field) { public synchronized Iterator<Map.Entry<byte[], Map<String, String>>> entries(final boolean up, final String field) {
return new FullMapIterator(keys(up, field)); return new FullMapIterator(this.keys(up, field));
} }
public synchronized long getLongAcc(final String field) { public synchronized long getLongAcc(final String field) {
@ -412,7 +412,7 @@ public class MapDataMining extends MapHeap {
super.close(); super.close();
} }
private static final long minutemillis = 60000; private static final long minutemillis = 60000;
private static long date2000 = 0; private static long date2000 = 0;
@ -499,17 +499,17 @@ public class MapDataMining extends MapHeap {
public static void main(final String[] args) { public static void main(final String[] args) {
try { try {
File f = new File("/tmp/MapDataMinig.test.db"); final File f = new File("/tmp/MapDataMinig.test.db");
f.delete(); f.delete();
final MapDataMining db = new MapDataMining(f, Word.commonHashLength, Base64Order.enhancedCoder, 1024 * 512, 500, new String[] {"X"}, new String[] {"X"}, new String[] {}); final MapDataMining db = new MapDataMining(f, Word.commonHashLength, Base64Order.enhancedCoder, 1024 * 512, 500, new String[] {"X"}, new String[] {"X"}, new String[] {});
final Map<String, String> m1 = new HashMap<String, String>(); final Map<String, String> m1 = new HashMap<>();
long t = System.currentTimeMillis(); final long t = System.currentTimeMillis();
m1.put("X", Long.toString(t)); m1.put("X", Long.toString(t));
db.put("abcdefghijk1".getBytes(), m1); db.put("abcdefghijk1".getBytes(), m1);
final Map<String, String> m2 = new HashMap<String, String>(); final Map<String, String> m2 = new HashMap<>();
m2.put("X", Long.toString(t - 1000)); m2.put("X", Long.toString(t - 1000));
db.put("abcdefghijk2".getBytes(), m2); db.put("abcdefghijk2".getBytes(), m2);
final Map<String, String> m3 = new HashMap<String, String>(); final Map<String, String> m3 = new HashMap<>();
m3.put("X", Long.toString(t + 2000)); m3.put("X", Long.toString(t + 2000));
db.put("abcdefghijk3".getBytes(), m3); db.put("abcdefghijk3".getBytes(), m3);

View File

@ -213,10 +213,10 @@ public final class LogParser {
private long DHTSendTraffic=0; private long DHTSendTraffic=0;
private int DHTSendURLs=0; private int DHTSendURLs=0;
private int RWIRejectCount=0; private int RWIRejectCount=0;
private final Set<String> RWIRejectPeerNames = new HashSet<String>(); private final Set<String> RWIRejectPeerNames = new HashSet<>();
private final Set<String> RWIRejectPeerHashs = new HashSet<String>(); private final Set<String> RWIRejectPeerHashs = new HashSet<>();
private final Set<String> DHTPeerNames = new HashSet<String>(); private final Set<String> DHTPeerNames = new HashSet<>();
private final Set<String> DHTPeerHashs = new HashSet<String>(); private final Set<String> DHTPeerHashs = new HashSet<>();
private int DHTSelectionTargetCount = 1; private int DHTSelectionTargetCount = 1;
private int DHTSelectionWordsCount = 0; private int DHTSelectionWordsCount = 0;
private int DHTSelectionWordsTimeCount = 0; private int DHTSelectionWordsTimeCount = 0;
@ -437,7 +437,7 @@ public final class LogParser {
} }
public final Map<String, Object> getResults() { public final Map<String, Object> getResults() {
final Map<String, Object> results = new HashMap<String, Object>(); final Map<String, Object> results = new HashMap<>();
results.put(PARSER_VERSION , Float.valueOf(parserVersion)); results.put(PARSER_VERSION , Float.valueOf(parserVersion));
results.put(URLS_RECEIVED , Integer.valueOf(this.urlSum)); results.put(URLS_RECEIVED , Integer.valueOf(this.urlSum));
results.put(URLS_REQUESTED , Integer.valueOf(this.urlReqSum)); results.put(URLS_REQUESTED , Integer.valueOf(this.urlReqSum));
@ -473,10 +473,10 @@ public final class LogParser {
results.put(INDEXED_WORDS , Integer.valueOf(this.indexedWordSum)); results.put(INDEXED_WORDS , Integer.valueOf(this.indexedWordSum));
results.put(INDEXED_SITES_SIZE , Integer.valueOf(this.indexedSiteSizeSum)); results.put(INDEXED_SITES_SIZE , Integer.valueOf(this.indexedSiteSizeSum));
results.put(INDEXED_ANCHORS , Integer.valueOf(this.indexedAnchorsCount)); results.put(INDEXED_ANCHORS , Integer.valueOf(this.indexedAnchorsCount));
// results.put(INDEXED_STACK_TIME , new Integer(indexedStackingTime)); // results.put(INDEXED_STACK_TIME , Integer.valueOf(indexedStackingTime));
// results.put(INDEXED_PARSE_TIME , new Integer(indexedParsingTime)); // results.put(INDEXED_PARSE_TIME , Integer.valueOf(indexedParsingTime));
// results.put(INDEXED_INDEX_TIME , new Integer(indexedIndexingTime)); // results.put(INDEXED_INDEX_TIME , Integer.valueOf(indexedIndexingTime));
// results.put(INDEXED_STORE_TIME , new Integer(indexedStorageTime)); // results.put(INDEXED_STORE_TIME , Integer.valueOf(indexedStorageTime));
results.put(INDEXED_LINKSTORE_TIME , Integer.valueOf(this.indexedLinkStorageTime)); results.put(INDEXED_LINKSTORE_TIME , Integer.valueOf(this.indexedLinkStorageTime));
results.put(INDEXED_INDEXSTORE_TIME, Integer.valueOf(this.indexedIndexStorageTime)); results.put(INDEXED_INDEXSTORE_TIME, Integer.valueOf(this.indexedIndexStorageTime));
results.put(TOTAL_PARSER_TIME , Long.valueOf(this.totalParserTime)); results.put(TOTAL_PARSER_TIME , Long.valueOf(this.totalParserTime));

File diff suppressed because it is too large Load Diff