Author: centic
Date: Mon Mar 14 11:58:15 2016
New Revision: 1734924

URL: http://svn.apache.org/viewvc?rev=1734924&view=rev
Log:
Fix some IntelliJ warnings and adjust Javadoc of readFully() slightly to 
describe the behavior better.

Modified:
    
poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java
    poi/trunk/src/java/org/apache/poi/util/IOUtils.java

Modified: 
poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java?rev=1734924&r1=1734923&r2=1734924&view=diff
==============================================================================
--- 
poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java
 (original)
+++ 
poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java
 Mon Mar 14 11:58:15 2016
@@ -28,7 +28,6 @@ import org.apache.poi.hssf.record.CFRule
 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 ex
         }
         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 ex
      * 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 ex
         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 ex
 
     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 ex
         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 ex
             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)) {

Modified: poi/trunk/src/java/org/apache/poi/util/IOUtils.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/IOUtils.java?rev=1734924&r1=1734923&r2=1734924&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/IOUtils.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/IOUtils.java Mon Mar 14 11:58:15 2016
@@ -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();
-    }    
+    }
     
     
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to