Fix some Eclipse warnings and adjust use of Generics, Comments, close()

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691308 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2015-07-16 03:41:57 +00:00
parent c54cc66158
commit 0c410544a9
7 changed files with 202 additions and 191 deletions

View File

@ -50,5 +50,7 @@ public class CreateCells {
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
wb.close();
}
}

View File

@ -168,25 +168,29 @@ public class BigGridDemo {
private static void substitute(File zipfile, File tmpfile, String entry, OutputStream out) throws IOException {
ZipFile zip = ZipHelper.openZipFile(zipfile);
ZipOutputStream zos = new ZipOutputStream(out);
try {
ZipOutputStream zos = new ZipOutputStream(out);
@SuppressWarnings("unchecked")
Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
while (en.hasMoreElements()) {
ZipEntry ze = en.nextElement();
if(!ze.getName().equals(entry)){
zos.putNextEntry(new ZipEntry(ze.getName()));
InputStream is = zip.getInputStream(ze);
copyStream(is, zos);
is.close();
@SuppressWarnings("unchecked")
Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
while (en.hasMoreElements()) {
ZipEntry ze = en.nextElement();
if(!ze.getName().equals(entry)){
zos.putNextEntry(new ZipEntry(ze.getName()));
InputStream is = zip.getInputStream(ze);
copyStream(is, zos);
is.close();
}
}
zos.putNextEntry(new ZipEntry(entry));
InputStream is = new FileInputStream(tmpfile);
copyStream(is, zos);
is.close();
zos.close();
} finally {
zip.close();
}
zos.putNextEntry(new ZipEntry(entry));
InputStream is = new FileInputStream(tmpfile);
copyStream(is, zos);
is.close();
zos.close();
}
private static void copyStream(InputStream in, OutputStream out) throws IOException {

View File

@ -285,7 +285,7 @@ public class Section
/*
* Extract the dictionary (if available).
*/
dictionary = (Map) getProperty(0);
dictionary = (Map<Long,String>) getProperty(0);
}

View File

@ -57,7 +57,7 @@ public final class OperandResolver {
*/
public static ValueEval getSingleValue(ValueEval arg, int srcCellRow, int srcCellCol)
throws EvaluationException {
ValueEval result;
final ValueEval result;
if (arg instanceof RefEval) {
result = chooseSingleElementFromRef((RefEval) arg);
} else if (arg instanceof AreaEval) {

View File

@ -491,7 +491,7 @@ public final class Countif extends Fixed2ArgFunction {
*/
private static ValueEval evaluateCriteriaArg(ValueEval arg, int srcRowIndex, int srcColumnIndex) {
try {
return OperandResolver.getSingleValue(arg, srcRowIndex, (short)srcColumnIndex);
return OperandResolver.getSingleValue(arg, srcRowIndex, srcColumnIndex);
} catch (EvaluationException e) {
return e.getErrorEval();
}

View File

@ -54,6 +54,7 @@ public final class Sumifs implements FreeRefFunction {
public static final FreeRefFunction instance = new Sumifs();
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
// need at least 3 arguments and need to have an odd number of arguments (sum-range plus x*(criteria_range, criteria))
if(args.length < 3 || args.length % 2 == 0) {
return ErrorEval.VALUE_INVALID;
}

File diff suppressed because it is too large Load Diff