]> source.dussan.org Git - poi.git/commitdiff
Improve information contained in exception in CellRangeAddress()
authorDominik Stadler <centic@apache.org>
Sun, 30 Apr 2017 09:12:44 +0000 (09:12 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 30 Apr 2017 09:12:44 +0000 (09:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1793252 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/util/CellRangeAddress.java

index aee9f82b4ccac46ee5832ae73656f079e413cd28..761120ed4f75596d58dba59e1e464b28f7763310 100644 (file)
@@ -32,9 +32,6 @@ import org.apache.poi.util.LittleEndianOutput;
  * @author Dragos Buleandra (dragos.buleandra@trade2b.ro)
  */
 public class CellRangeAddress extends CellRangeAddressBase {
-       /*
-        * TODO - replace  org.apache.poi.hssf.util.Region
-        */
        public static final int ENCODED_SIZE = 8;
 
        /**
@@ -48,8 +45,10 @@ public class CellRangeAddress extends CellRangeAddressBase {
        public CellRangeAddress(int firstRow, int lastRow, int firstCol, int lastCol) {
                super(firstRow, lastRow, firstCol, lastCol);
                
-               if (lastRow < firstRow || lastCol < firstCol)
-                   throw new IllegalArgumentException("lastRow < firstRow || lastCol < firstCol");
+               if (lastRow < firstRow || lastCol < firstCol) {
+                       throw new IllegalArgumentException("Invalid cell range, having lastRow < firstRow || lastCol < firstCol, " +
+                                       "had rows " + lastRow + " >= " + firstRow + " or cells " + lastCol + " >= " + firstCol);
+               }
        }
 
        public void serialize(LittleEndianOutput out) {
@@ -91,7 +90,7 @@ public class CellRangeAddress extends CellRangeAddressBase {
      * @return the text format of this range using specified sheet name.
      */
     public String formatAsString(String sheetName, boolean useAbsoluteAddress) {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         if (sheetName != null) {
             sb.append(SheetNameFormatter.format(sheetName));
             sb.append("!");