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
This commit is contained in:
Dominik Stadler 2016-03-14 11:58:15 +00:00
parent 3f4f58829d
commit d853210049
2 changed files with 15 additions and 17 deletions

View File

@ -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;
/**
* <p>CFRecordsAggregate - aggregates Conditional Formatting records CFHeaderRecord
@ -73,9 +73,9 @@ public final class CFRecordsAggregate extends RecordAggregate {
}
header = pHeader;
rules = new ArrayList<CFRuleBase>(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<rules.size(); i++) {
CFRuleBase cfRule = rules.get(i);
for (CFRuleBase cfRule : rules) {
buffer.append(cfRule.toString());
}
buffer.append("[/").append(type).append("]\n");
@ -203,8 +202,7 @@ public final class CFRecordsAggregate extends RecordAggregate {
public void visitContainedRecords(RecordVisitor rv) {
rv.visitRecord(header);
for(int i=0; i<rules.size(); i++) {
CFRuleBase rule = rules.get(i);
for (CFRuleBase rule : rules) {
rv.visitRecord(rule);
}
}
@ -216,8 +214,7 @@ public final class CFRecordsAggregate extends RecordAggregate {
CellRangeAddress[] cellRanges = header.getCellRanges();
boolean changed = false;
List<CellRangeAddress> temp = new ArrayList<CellRangeAddress>();
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; i<rules.size(); i++) {
CFRuleBase rule = rules.get(i);
for (CFRuleBase rule : rules) {
Ptg[] ptgs;
ptgs = rule.getParsedExpression1();
if (ptgs != null && shifter.adjustFormula(ptgs, currentExternSheetIx)) {

View File

@ -131,12 +131,14 @@ public final class IOUtils {
/**
* Same as the normal <tt>channel.read(b)</tt>, 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.
* <p>
* 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();
}
}
/**