From 51a1ebf7500163268f51001b49972b19d7e8a9e3 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Mon, 14 Mar 2016 11:58:15 +0000 Subject: [PATCH] Fix some IntelliJ warnings and adjust Javadoc of readFully() slightly to describe the behavior better. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1734924 13f79535-47bb-0310-9956-ffa450edef68 --- .../record/aggregates/CFRecordsAggregate.java | 22 ++++++++----------- src/java/org/apache/poi/util/IOUtils.java | 10 +++++---- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java index 3e1eab8a4d..b0112306ff 100644 --- a/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java +++ b/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java @@ -28,7 +28,6 @@ import org.apache.poi.hssf.record.CFRule12Record; import org.apache.poi.hssf.record.CFRuleBase; import org.apache.poi.hssf.record.CFRuleRecord; import org.apache.poi.hssf.record.Record; -import org.apache.poi.hssf.record.RecordFormatException; import org.apache.poi.ss.formula.FormulaShifter; import org.apache.poi.ss.formula.ptg.AreaErrPtg; import org.apache.poi.ss.formula.ptg.AreaPtg; @@ -36,6 +35,7 @@ import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; +import org.apache.poi.util.RecordFormatException; /** *

CFRecordsAggregate - aggregates Conditional Formatting records CFHeaderRecord @@ -73,9 +73,9 @@ public final class CFRecordsAggregate extends RecordAggregate { } header = pHeader; rules = new ArrayList(pRules.length); - for (int i = 0; i < pRules.length; i++) { - checkRuleType(pRules[i]); - rules.add(pRules[i]); + for (CFRuleBase pRule : pRules) { + checkRuleType(pRule); + rules.add(pRule); } } @@ -183,7 +183,7 @@ public final class CFRecordsAggregate extends RecordAggregate { * String representation of CFRecordsAggregate */ public String toString() { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); String type = "CF"; if (header instanceof CFHeader12Record) { type = "CF12"; @@ -193,8 +193,7 @@ public final class CFRecordsAggregate extends RecordAggregate { if( header != null ) { buffer.append(header.toString()); } - for(int i=0; i temp = new ArrayList(); - for (int i = 0; i < cellRanges.length; i++) { - CellRangeAddress craOld = cellRanges[i]; + for (CellRangeAddress craOld : cellRanges) { CellRangeAddress craNew = shiftRange(shifter, craOld, currentExternSheetIx); if (craNew == null) { changed = true; @@ -239,8 +236,7 @@ public final class CFRecordsAggregate extends RecordAggregate { header.setCellRanges(newRanges); } - for(int i=0; ichannel.read(b), but tries to ensure - * that the entire len number of bytes is read. + * that the buffer is filled completely if possible, i.e. b.remaining() + * returns 0. *

* If the end of file is reached before any bytes are read, returns -1. If * the end of the file is reached after some bytes are read, returns the - * number of bytes read. If the end of the file isn't reached before len - * bytes have been read, will return len bytes. + * number of bytes read. If the end of the file isn't reached before the + * buffer has no more remaining capacity, will return the number of bytes + * that were read. */ public static int readFully(ReadableByteChannel channel, ByteBuffer b) throws IOException { int total = 0; @@ -192,7 +194,7 @@ public final class IOUtils { } } return sum.getValue(); - } + } /** -- 2.39.5