Skip to content

Commit

Permalink
Fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
avazirna committed Feb 28, 2023
1 parent aac1874 commit 31ba9ba
Show file tree
Hide file tree
Showing 35 changed files with 227 additions and 226 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public LedgerPurgeFilter(IStorageUtilityIndexed<Ledger> ledgerStorage, IStorageU
try {
caseStorage.getRecordForValue(Case.INDEX_CASE_ID, s.getEntiyId());
} catch (NoSuchElementException nsee) {
idsToRemove.addElement(new Integer(s.getID()));
idsToRemove.addElement(Integer.valueOf(s.getID()));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/commcare/cases/util/CasePurgeFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void setIdsToRemoveWithNewExtensions(DAG<String, int[], String> graph) t
for (Enumeration iterator = internalCaseDAG.getNodes(); iterator.hasMoreElements(); ) {
int[] node = (int[])iterator.nextElement();
if (!caseStatusIs(node[0], STATUS_ALIVE)) {
idsToRemove.addElement(new Integer(node[1]));
idsToRemove.addElement(Integer.valueOf(node[1]));
}
}
}
Expand Down Expand Up @@ -337,7 +337,7 @@ private void removeNodeAndPropagate(String indexOfRemovedNode,
// DAG, and add it to the list of cases to be purged
if (casesRemovedDueToMissingCases.indexOf(indexOfRemovedNode) == -1) {
int storageIdOfRemovedNode = internalCaseDAG.removeNode(indexOfRemovedNode)[1];
idsToRemove.addElement(new Integer(storageIdOfRemovedNode));
idsToRemove.addElement(Integer.valueOf(storageIdOfRemovedNode));
casesRemovedDueToMissingCases.addElement(indexOfRemovedNode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/commcare/xml/GridParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public Integer parse() throws InvalidStructureException, IOException, XmlPullPar
//exit grid block
parser.nextTag();

return new Integer(1);
return Integer.valueOf(1);
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/commcare/xml/MarkupParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public Integer parse() throws InvalidStructureException, IOException, XmlPullPar
//exit grid block
parser.nextTag();

return new Integer(1);
return Integer.valueOf(1);
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/commcare/xml/StyleParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public Integer parse() throws InvalidStructureException, IOException, XmlPullPar

parser.nextTag();

return new Integer(1);
return Integer.valueOf(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ public void setVariable(String name, Object value) {
//Some datatypes can be trivially converted to a first order
//xpath datatype
if (value instanceof Integer) {
variables.put(name, new Double(((Integer)value).doubleValue()));
variables.put(name, Double.valueOf(((Integer)value).doubleValue()));
return;
}
if (value instanceof Float) {
variables.put(name, new Double(((Float)value).doubleValue()));
variables.put(name, Double.valueOf(((Float)value).doubleValue()));
} else {
//Otherwise we just hope for the best, I suppose? Should we log this?
variables.put(name, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String getDisplayText() {

@Override
public Object getValue() {
return new Double(d);
return Double.valueOf(d);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/core/model/data/LongData.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void writeExternal(DataOutputStream out) throws IOException {

@Override
public UncastData uncast() {
return new UncastData(new Long(n).toString());
return new UncastData(Long.valueOf(n).toString());
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/core/model/utils/DateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private static String formatDateISO8601(DateFields f) {
}

private static String formatDateColloquial(DateFields f) {
String year = new Integer(f.year).toString();
String year = Integer.valueOf(f.year).toString();

//Normal Date
if (year.length() == 4) {
Expand Down Expand Up @@ -869,7 +869,7 @@ public static Double fractionalDaysSinceEpoch(Date a) {
//correct for any drift in the offsets. This can also present if timezone definitions
//have drifted over time
long timeZoneAdjust = (a.getTimezoneOffset() - EPOCH_DATE.getTimezoneOffset()) * 60* 1000;
return new Double(((a.getTime() - EPOCH_DATE.getTime()) - timeZoneAdjust) / (double)DAY_IN_MS);
return Double.valueOf(((a.getTime() - EPOCH_DATE.getTime()) - timeZoneAdjust) / (double)DAY_IN_MS);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/form/api/FormEntryCaption.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public String getRepeatText(String typeKey) {

Hashtable<String, Object> vars = new Hashtable<>();
vars.put("name", title);
vars.put("n", new Integer(count));
vars.put("n", Integer.valueOf(count));
return form.fillTemplateString(caption, index.getReference(), vars);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/javarosa/form/api/FormEntryModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ private boolean setRepeatNextMultiplicity(Vector<IFormElement> elements, Vector<
TreeElement parentNode = form.getMainInstance().resolveReference(nodeRef.getParentRef());
mult = parentNode.getChildMultiplicity(name);
}
multiplicities.setElementAt(new Integer(repeatStructure == REPEAT_STRUCTURE_NON_LINEAR ? TreeReference.INDEX_REPEAT_JUNCTURE : mult), multiplicities.size() - 1);
multiplicities.setElementAt(Integer.valueOf(repeatStructure == REPEAT_STRUCTURE_NON_LINEAR ?
TreeReference.INDEX_REPEAT_JUNCTURE : mult), multiplicities.size() - 1);
return true;
} else {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/xml/TreeElementParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public TreeElement parse() throws InvalidStructureException, IOException,
} else {
val = 0;
}
multiplicities.put(name, new Integer(val));
multiplicities.put(name, Integer.valueOf(val));

TreeElement kid = new TreeElementParser(parser, val, instanceId).parse();
element.addChild(kid);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/xpath/XPathLazyNodeset.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class XPathLazyNodeset extends XPathNodeset {

//Since we're using this as a lock, we need to be very careful to ensure that each
//nodeset gets its own new object.
private Boolean evaluated = new Boolean(false);
private Boolean evaluated = Boolean.valueOf(false);
private final TreeReference unExpandedRef;

/**
Expand All @@ -57,7 +57,7 @@ private void performEvaluation() {
}
}
this.setReferences(nodes);
evaluated = new Boolean(true);
evaluated = Boolean.valueOf(true);
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/javarosa/xpath/expr/FunctionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ public static Object InferType(String attrValue) {
try {
// Don't process strings with scientific notation or +/- Infinity as doubles
if (checkForInvalidNumericOrDatestringCharacters(attrValue)) {
mDoubleParseCache.register(attrValue, new Double(Double.NaN));
mDoubleParseCache.register(attrValue, Double.valueOf(Double.NaN));
return attrValue;
}
Double ret = Double.parseDouble(attrValue);
mDoubleParseCache.register(attrValue, ret);
return ret;
} catch (NumberFormatException ife) {
//Not a double
mDoubleParseCache.register(attrValue, new Double(Double.NaN));
mDoubleParseCache.register(attrValue, Double.valueOf(Double.NaN));
}
//TODO: What about dates? That is a _super_ expensive
//operation to be testing, though...
Expand Down Expand Up @@ -223,25 +223,25 @@ public static Double toNumeric(Object o) {
o = unpack(o);

if (o instanceof Boolean) {
val = new Double(((Boolean)o).booleanValue() ? 1 : 0);
val = Double.valueOf(((Boolean)o).booleanValue() ? 1 : 0);
} else if (o instanceof Double) {
val = (Double)o;
} else if (o instanceof String) {
String s = ((String)o).trim();
if (checkForInvalidNumericOrDatestringCharacters(s)) {
return new Double(Double.NaN);
return Double.valueOf(Double.NaN);
}
try {
val = new Double(Double.parseDouble(s));
val = Double.valueOf(Double.parseDouble(s));
} catch (NumberFormatException nfe) {
try {
val = attemptDateConversion(s);
} catch (XPathTypeMismatchException e) {
val = new Double(Double.NaN);
val = Double.valueOf(Double.NaN);
}
}
} else if (o instanceof Date) {
val = new Double(DateUtils.daysSinceEpoch((Date)o));
val = Double.valueOf(DateUtils.daysSinceEpoch((Date)o));
} else if (o instanceof IExprDataType) {
val = ((IExprDataType)o).toNumeric();
}
Expand Down Expand Up @@ -290,9 +290,9 @@ public static Double toInt(Object o) {
return val;
} else {
long l = val.longValue();
Double dbl = new Double(l);
if (l == 0 && (val < 0. || val.equals(new Double(-0.)))) {
dbl = new Double(-0.);
Double dbl = Double.valueOf(l);
if (l == 0 && (val < 0. || val.equals(Double.valueOf(-0.)))) {
dbl = Double.valueOf(-0.);
}
return dbl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/xpath/expr/XPathArithExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected Object evalRaw(DataInstance model, EvaluationContext evalContext) {
result = aval % bval;
break;
}
return new Double(result);
return Double.valueOf(result);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public XPathCeilingFunc(XPathExpression[] args) throws XPathSyntaxException {

@Override
public Object evalBody(DataInstance model, EvaluationContext evalContext, Object[] evaluatedArgs) {
return new Double(Math.ceil(FunctionUtils.toDouble(evaluatedArgs[0])));
return Double.valueOf(Math.ceil(FunctionUtils.toDouble(evaluatedArgs[0])));
}

}
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/xpath/expr/XPathCmpExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ private boolean handled(Object a, Object b, Object sentinal, Vector<Object> pivo
} else if (b instanceof Float) {
val = ((Float)b).doubleValue();
} else if (b instanceof Short) {
val = new Double((Short)b);
val = Double.valueOf((Short)b);
} else if (b instanceof Byte) {
val = new Double((Byte)b);
val = Double.valueOf((Byte)b);
} else {
if (b instanceof String) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/xpath/expr/XPathCountFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public XPathCountFunc(XPathExpression[] args) throws XPathSyntaxException {
@Override
public Object evalBody(DataInstance model, EvaluationContext evalContext, Object[] evaluatedArgs) {
if (evaluatedArgs[0] instanceof XPathNodeset) {
return new Double(((XPathNodeset)evaluatedArgs[0]).size());
return Double.valueOf(((XPathNodeset)evaluatedArgs[0]).size());
} else {
throw new XPathTypeMismatchException("uses an invalid reference inside a count function");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Object evalBody(DataInstance model, EvaluationContext evalContext, Object
}

String s = (String)evalResult;
return new Double(DataUtil.splitOnSpaces(s).length);
return Double.valueOf(DataUtil.splitOnSpaces(s).length);
}

}
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/xpath/expr/XPathDistanceFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public static Double distance(Object from, Object to) {
String unpackedTo = (String)FunctionUtils.unpack(to);

if (unpackedFrom == null || "".equals(unpackedFrom) || unpackedTo == null || "".equals(unpackedTo)) {
return new Double(-1.0);
return Double.valueOf(-1.0);
}

try {
// Casting and uncasting seems strange but is consistent with the codebase
GeoPointData castedFrom = new GeoPointData().cast(new UncastData(unpackedFrom));
GeoPointData castedTo = new GeoPointData().cast(new UncastData(unpackedTo));

return new Double(GeoPointUtils.computeDistanceBetween(castedFrom, castedTo));
return Double.valueOf(GeoPointUtils.computeDistanceBetween(castedFrom, castedTo));
} catch (NumberFormatException e) {
throw new XPathTypeMismatchException("distance() function requires arguments containing " +
"numeric values only, but received arguments: " + unpackedFrom + " and " + unpackedTo);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/xpath/expr/XPathFloorFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public XPathFloorFunc(XPathExpression[] args) throws XPathSyntaxException {

@Override
public Object evalBody(DataInstance model, EvaluationContext evalContext, Object[] evaluatedArgs) {
return new Double(Math.floor(FunctionUtils.toDouble(evaluatedArgs[0])));
return Double.valueOf(Math.floor(FunctionUtils.toDouble(evaluatedArgs[0])));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Object evalBody(DataInstance model, EvaluationContext evalContext, Object

for(int i = 0 ; i < argList.length ; ++i) {
if(argList[i].equals(indexedItem)) {
return new Double(i);
return Double.valueOf(i);
}
}
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public XPathNumericLiteral(Double d) {

@Override
protected Object evalRaw(DataInstance model, EvaluationContext evalContext) {
return new Double(d);
return Double.valueOf(d);
}

@Override
Expand All @@ -45,7 +45,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return (new Long(Double.doubleToLongBits(d))).hashCode();
return (Long.valueOf(Double.doubleToLongBits(d))).hashCode();
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/xpath/expr/XPathPositionFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public Object evalBody(DataInstance model, EvaluationContext evalContext, Object
}
}
} else if (evalContext.getContextPosition() != -1) {
return new Double(evalContext.getContextPosition());
return Double.valueOf(evalContext.getContextPosition());
} else {
return position(evalContext.getContextRef());
}
}

private static Double position(TreeReference refAt) {
return new Double(refAt.getMultLast());
return Double.valueOf(refAt.getMultLast());
}

}
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/xpath/expr/XPathRandomFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public XPathRandomFunc(XPathExpression[] args) throws XPathSyntaxException {
@Override
public Object evalBody(DataInstance model, EvaluationContext evalContext, Object[] evaluatedArgs) {
//calculated expressions may be recomputed w/o warning! use with caution!!
return new Double(MathUtils.getRand().nextDouble());
return Double.valueOf(MathUtils.getRand().nextDouble());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/xpath/expr/XPathRoundFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public XPathRoundFunc(XPathExpression[] args) throws XPathSyntaxException {

@Override
public Object evalBody(DataInstance model, EvaluationContext evalContext, Object[] evaluatedArgs) {
return new Double(Math.floor(FunctionUtils.toDouble(evaluatedArgs[0]) + 0.5));
return Double.valueOf(Math.floor(FunctionUtils.toDouble(evaluatedArgs[0]) + 0.5));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public XPathStringLengthFunc(XPathExpression[] args) throws XPathSyntaxException
public Object evalBody(DataInstance model, EvaluationContext evalContext, Object[] evaluatedArgs) {
String s = FunctionUtils.toString(evaluatedArgs[0]);
if (s == null) {
return new Double(0.0);
return Double.valueOf(0.0);
}
return new Double(s.length());
return Double.valueOf(s.length());
}

}
6 changes: 3 additions & 3 deletions src/main/java/org/javarosa/xpath/expr/XPathTranslateFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ private static String translate(Object o1, Object o2, Object o3) {

Hashtable<Character, Character> map = new Hashtable<>();
for (int i = 0; i < Math.min(from.length(), to.length()); i++) {
if (!map.containsKey(new Character(from.charAt(i)))) {
map.put(new Character(from.charAt(i)), new Character(to.charAt(i)));
if (!map.containsKey(Character.valueOf(from.charAt(i)))) {
map.put(Character.valueOf(from.charAt(i)), Character.valueOf(to.charAt(i)));
}
}
String toDelete = from.substring(Math.min(from.length(), to.length()));

String returnValue = "";
for (int i = 0; i < source.length(); i++) {
Character current = new Character(source.charAt(i));
Character current = Character.valueOf(source.charAt(i));
if (toDelete.indexOf(current) == -1) {
if (map.containsKey(current)) {
current = map.get(current);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class IntegerDataTests {

@BeforeClass
public static void setUp() {
one = new Integer(1);
two = new Integer(2);
one = Integer.valueOf(1);
two = Integer.valueOf(2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public void testAnswerQuestion() {
}

if (q.getTextID().equals("constraint-max-label")){
assertConstraintMaxMin(new Integer(30), null);
assertConstraintMaxMin(Integer.valueOf(30), null);
} else if (q.getTextID().equals("constraint-min-label")){
assertConstraintMaxMin(null, new Integer(10));
assertConstraintMaxMin(null, Integer.valueOf(10));
} else if (q.getTextID().equals("constraint-max-or-min-label")){
assertUnpivotable();
} else if (q.getTextID().equals("constraint-max-and-min-label")){
Expand Down
Loading

0 comments on commit 31ba9ba

Please sign in to comment.