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;
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
}
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);
}
}
* String representation of CFRecordsAggregate
*/
public String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
String type = "CF";
if (header instanceof CFHeader12Record) {
type = "CF12";
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");
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);
}
}
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;
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)) {
/**
* 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;
}
}
return sum.getValue();
- }
+ }
/**