]> source.dussan.org Git - poi.git/commitdiff
Fix Eclipse warnings, unnecessary casts, use generics, static access...
authorDominik Stadler <centic@apache.org>
Sun, 28 Dec 2014 09:06:12 +0000 (09:06 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 28 Dec 2014 09:06:12 +0000 (09:06 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1648156 13f79535-47bb-0310-9956-ffa450edef68

44 files changed:
src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java
src/examples/src/org/apache/poi/hssf/usermodel/examples/EventExample.java
src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java
src/java/org/apache/poi/ddf/EscherChildAnchorRecord.java
src/java/org/apache/poi/ddf/EscherDgRecord.java
src/java/org/apache/poi/ddf/EscherSpRecord.java
src/java/org/apache/poi/hpsf/CustomProperties.java
src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
src/java/org/apache/poi/hpsf/MutableSection.java
src/java/org/apache/poi/hpsf/Section.java
src/java/org/apache/poi/hpsf/Variant.java
src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java
src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java
src/java/org/apache/poi/hssf/dev/ReSave.java
src/java/org/apache/poi/hssf/model/DrawingManager2.java
src/java/org/apache/poi/hssf/model/RecordStream.java
src/java/org/apache/poi/hssf/record/TextObjectRecord.java
src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java
src/java/org/apache/poi/hssf/record/aggregates/DataValidityTable.java
src/java/org/apache/poi/hssf/usermodel/DVConstraint.java
src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java
src/java/org/apache/poi/ss/formula/eval/ErrorEval.java
src/java/org/apache/poi/ss/formula/ptg/ErrPtg.java
src/java/org/apache/poi/ss/util/AreaReference.java
src/java/org/apache/poi/ss/util/CellRangeAddressList.java
src/java/org/apache/poi/util/BinaryTree.java
src/ooxml/java/org/apache/poi/xslf/usermodel/TextFragment.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java
src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFHeader.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java
src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
src/testcases/org/apache/poi/ss/formula/eval/TestEqualEval.java
src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java
src/testcases/org/apache/poi/ss/formula/eval/TestMinusZeroResult.java
src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java
src/testcases/org/apache/poi/ss/formula/functions/TestRoundFuncs.java
src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestDataValidation.java
src/testcases/org/apache/poi/util/DummyPOILogger.java

index 3981a145daa07ee40fcef2c61a22a477d6bbda94..14575aa007fbbd383f261b47651c32ff95c4de97 100644 (file)
@@ -19,6 +19,8 @@ package org.apache.poi.hssf.usermodel.examples;
 
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
 
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -57,14 +59,14 @@ public class BigExample {
         f.setColor(HSSFColor.RED.index);
         // make it bold
         //arial is the default font
-        f.setBoldweight(f.BOLDWEIGHT_BOLD);
+        f.setBoldweight(Font.BOLDWEIGHT_BOLD);
 
         //set font 2 to 10 point type
         f2.setFontHeightInPoints((short) 10);
         //make it the color at palette index 0xf (white)
         f2.setColor(HSSFColor.WHITE.index);
         //make it bold
-        f2.setBoldweight(f2.BOLDWEIGHT_BOLD);
+        f2.setBoldweight(Font.BOLDWEIGHT_BOLD);
 
         //set cell stlye
         cs.setFont(f);
@@ -72,7 +74,7 @@ public class BigExample {
         cs.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
 
         //set a thin border
-        cs2.setBorderBottom(cs2.BORDER_THIN);
+        cs2.setBorderBottom(CellStyle.BORDER_THIN);
         //fill w fg fill color
         cs2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
         // set foreground fill to red
@@ -141,7 +143,7 @@ public class BigExample {
 
         // define the third style to be the default
         // except with a thick black border at the bottom
-        cs3.setBorderBottom(cs3.BORDER_THICK);
+        cs3.setBorderBottom(CellStyle.BORDER_THICK);
 
         //create 50 cells
         for (int cellnum =0; cellnum < 50; cellnum++) {
index c5644c95973c73f7d42b4494701956aabc3a06d0..7dd5ee3ca9d17d660e345250f1736dbbe6be9b7e 100644 (file)
@@ -47,11 +47,11 @@ public class EventExample
             // the BOFRecord can represent either the beginning of a sheet or the workbook
             case BOFRecord.sid:
                 BOFRecord bof = (BOFRecord) record;
-                if (bof.getType() == bof.TYPE_WORKBOOK)
+                if (bof.getType() == BOFRecord.TYPE_WORKBOOK)
                 {
                     System.out.println("Encountered workbook");
                     // assigned to the class level member
-                } else if (bof.getType() == bof.TYPE_WORKSHEET)
+                } else if (bof.getType() == BOFRecord.TYPE_WORKSHEET)
                 {
                     System.out.println("Encountered sheet reference");
                 }
index 1b580d35f013345d89499ebf233d4b9a0c8d54c6..907d0f759410ac4aed3795099b186b9293c47e62 100644 (file)
@@ -164,7 +164,7 @@ public class OfficeDrawing {
         HSSFPicture picture = patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4s.png", wb ));
         //Reset the image to the original size.
         picture.resize();
-        picture.setLineStyle( picture.LINESTYLE_DASHDOTGEL );
+        picture.setLineStyle( HSSFShape.LINESTYLE_DASHDOTGEL );
 
     }
 
index 6aa0efde93e175b68d314470663666f483a57dd3..b6193cea4eea7f1b591f145cafb8240efddef072 100644 (file)
@@ -40,7 +40,7 @@ public class EscherChildAnchorRecord
     private int field_4_dy2;
 
     public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
-        int bytesRemaining = readHeader( data, offset );
+        /*int bytesRemaining =*/ readHeader( data, offset );
         int pos            = offset + 8;
         int size           = 0;
         field_1_dx1    =  LittleEndian.getInt( data, pos + size );size+=4;
index a4447dc016174fc29c0da97a65c1abf7e51fd74a..c269ad4461bddba4888a44baade54fca1f9bdeb4 100644 (file)
@@ -37,7 +37,7 @@ public class EscherDgRecord
     private int field_2_lastMSOSPID;
 
     public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
-        int bytesRemaining = readHeader( data, offset );
+        /*int bytesRemaining =*/ readHeader( data, offset );
         int pos            = offset + 8;
         int size           = 0;
         field_1_numShapes   =  LittleEndian.getInt( data, pos + size );     size += 4;
index 7d4dd5cfba88c9aa5cf31b3a4118575441502086..870bf575e1cb3e4500038a115410c1a0496dcd0d 100644 (file)
@@ -49,7 +49,7 @@ public class EscherSpRecord
     private int field_2_flags;
 
     public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
-        int bytesRemaining = readHeader( data, offset );
+        /*int bytesRemaining =*/ readHeader( data, offset );
         int pos            = offset + 8;
         int size           = 0;
         field_1_shapeId    =  LittleEndian.getInt( data, pos + size );     size += 4;
index 83858eb736f6b36755eaf061bdcda4e01be0e446..9642e0dbcf9286a4fe1de927e908b156d894e7dc 100644 (file)
@@ -131,7 +131,7 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
         final String name = customProperty.getName();
 
         /* Check whether a property with this name is in the map already. */
-        final Long oldId = (Long) dictionaryNameToID.get(name);
+        final Long oldId = dictionaryNameToID.get(name);
         if (oldId != null)
             customProperty.setID(oldId.longValue());
         else
@@ -159,7 +159,7 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
      */
     public Object remove(final String name)
     {
-        final Long id = (Long) dictionaryNameToID.get(name);
+        final Long id = dictionaryNameToID.get(name);
         if (id == null)
             return null;
         dictionaryIDToName.remove(id);
@@ -267,8 +267,8 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
      */
     public Object get(final String name)
     {
-        final Long id = (Long) dictionaryNameToID.get(name);
-        final CustomProperty cp = (CustomProperty) super.get(id);
+        final Long id = dictionaryNameToID.get(name);
+        final CustomProperty cp = super.get(id);
         return cp != null ? cp.getValue() : null;
     }
 
@@ -351,10 +351,10 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
      */
    public boolean containsKey(Object key) {
       if(key instanceof Long) {
-         return super.containsKey((Long)key);
+         return super.containsKey(key);
       }
       if(key instanceof String) {
-         return super.containsKey((Long)dictionaryNameToID.get(key));
+         return super.containsKey(dictionaryNameToID.get(key));
       }
       return false;
    }
@@ -364,7 +364,7 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
     */
    public boolean containsValue(Object value) {
       if(value instanceof CustomProperty) {
-         return super.containsValue((CustomProperty)value);
+         return super.containsValue(value);
       } else {
          for(CustomProperty cp : super.values()) {
             if(cp.getValue() == value) {
index 4a8303098acff138482a0d3320c12d514dcdbe4a..0dacd0d97c38a61cf34f0c037ebe3c1bb7ad5c51 100644 (file)
@@ -569,7 +569,7 @@ public class DocumentSummaryInformation extends SpecialPropertySet
         if (getSectionCount() >= 2)
         {
             cps = new CustomProperties();
-            final Section section = (Section) getSections().get(1);
+            final Section section = getSections().get(1);
             final Map<Long,String> dictionary = section.getDictionary();
             final Property[] properties = section.getProperties();
             int propertyCount = 0;
index 49eaa3227281c118eaa5c5b6bad5abcdc4ad166c..a1b38246663af2f93c71cd1ad3d61cd54cfeb6b0 100644 (file)
@@ -576,7 +576,7 @@ public class MutableSection extends Section
      */
     public Property[] getProperties()
     {
-        properties = (Property[]) preprops.toArray(new Property[0]);
+        properties = preprops.toArray(new Property[0]);
         return properties;
     }
 
index 945cdf567cd1c1c9a82a2147115a58b78a0bdcab..0c97a0e68adc6d2ca642c49f7162c166aa08e8eb 100644 (file)
@@ -448,7 +448,7 @@ public class Section
     {
         String s = null;
         if (dictionary != null)
-            s = (String) dictionary.get(Long.valueOf(pid));
+            s = dictionary.get(Long.valueOf(pid));
         if (s == null)
             s = SectionIDMap.getPIDString(getFormatID().getBytes(), pid);
         if (s == null)
index 8330a6d5a9b0b5b9de95ef1b8b3cf11727b848f9..fd1539ec0fa30b99b710f17d701c312cc0742886 100644 (file)
@@ -352,9 +352,9 @@ public class Variant
      * <p>Maps the numbers denoting the variant types to their corresponding
      * variant type names.</p>
      */
-    private static Map numberToName;
+    private static Map<Long,String> numberToName;
 
-    private static Map numberToLength;
+    private static Map<Long,Integer> numberToLength;
 
     /**
      * <p>Denotes a variant type with a length that is unknown to HPSF yet.</p>
@@ -391,7 +391,7 @@ public class Variant
     static
     {
         /* Initialize the number-to-name map: */
-        Map tm1 = new HashMap();
+        Map<Long,String> tm1 = new HashMap<Long,String>();
         tm1.put(Long.valueOf(0), "VT_EMPTY");
         tm1.put(Long.valueOf(1), "VT_NULL");
         tm1.put(Long.valueOf(2), "VT_I2");
@@ -432,55 +432,55 @@ public class Variant
         tm1.put(Long.valueOf(70), "VT_BLOB_OBJECT");
         tm1.put(Long.valueOf(71), "VT_CF");
         tm1.put(Long.valueOf(72), "VT_CLSID");
-        Map tm2 = new HashMap(tm1.size(), 1.0F);
+        Map<Long,String> tm2 = new HashMap<Long,String>(tm1.size(), 1.0F);
         tm2.putAll(tm1);
         numberToName = Collections.unmodifiableMap(tm2);
 
         /* Initialize the number-to-length map: */
-        tm1.clear();
-        tm1.put(Long.valueOf(0), LENGTH_0);
-        tm1.put(Long.valueOf(1), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(2), LENGTH_2);
-        tm1.put(Long.valueOf(3), LENGTH_4);
-        tm1.put(Long.valueOf(4), LENGTH_4);
-        tm1.put(Long.valueOf(5), LENGTH_8);
-        tm1.put(Long.valueOf(6), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(7), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(8), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(9), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(10), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(11), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(12), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(13), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(14), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(16), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(17), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(18), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(19), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(20), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(21), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(22), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(23), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(24), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(25), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(26), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(27), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(28), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(29), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(30), LENGTH_VARIABLE);
-        tm1.put(Long.valueOf(31), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(64), LENGTH_8);
-        tm1.put(Long.valueOf(65), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(66), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(67), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(68), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(69), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(70), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(71), LENGTH_UNKNOWN);
-        tm1.put(Long.valueOf(72), LENGTH_UNKNOWN);
-        tm2 = new HashMap(tm1.size(), 1.0F);
-        tm2.putAll(tm1);
-        numberToLength = Collections.unmodifiableMap(tm2);
+        Map<Long,Integer> tm3 = new HashMap<Long,Integer>();
+        tm3.put(Long.valueOf(0), LENGTH_0);
+        tm3.put(Long.valueOf(1), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(2), LENGTH_2);
+        tm3.put(Long.valueOf(3), LENGTH_4);
+        tm3.put(Long.valueOf(4), LENGTH_4);
+        tm3.put(Long.valueOf(5), LENGTH_8);
+        tm3.put(Long.valueOf(6), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(7), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(8), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(9), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(10), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(11), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(12), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(13), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(14), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(16), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(17), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(18), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(19), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(20), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(21), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(22), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(23), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(24), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(25), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(26), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(27), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(28), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(29), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(30), LENGTH_VARIABLE);
+        tm3.put(Long.valueOf(31), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(64), LENGTH_8);
+        tm3.put(Long.valueOf(65), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(66), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(67), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(68), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(69), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(70), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(71), LENGTH_UNKNOWN);
+        tm3.put(Long.valueOf(72), LENGTH_UNKNOWN);
+        Map<Long,Integer> tm4 = new HashMap<Long,Integer>(tm1.size(), 1.0F);
+        tm4.putAll(tm3);
+        numberToLength = Collections.unmodifiableMap(tm4);
     }
 
 
@@ -494,7 +494,7 @@ public class Variant
      */
     public static String getVariantName(final long variantType)
     {
-        final String name = (String) numberToName.get(Long.valueOf(variantType));
+        final String name = numberToName.get(Long.valueOf(variantType));
         return name != null ? name : "unknown variant type";
     }
 
@@ -510,7 +510,7 @@ public class Variant
     public static int getVariantLength(final long variantType)
     {
         final Long key = Long.valueOf((int) variantType);
-        final Long length = (Long) numberToLength.get(key);
+        final Integer length = numberToLength.get(key);
         if (length == null)
             return -2;
         return length.intValue();
index 7150b6c1c93dea7951168e4221b786c8590f836d..ce5301ac608a5ede0cabd7e3dd05f7d3290d888b 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.apache.poi.hpsf.extractor;
 
+import java.io.Closeable;
 import java.io.File;
 import java.io.IOException;
 import java.util.Iterator;
@@ -39,6 +40,8 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  *  textual form.
  */
 public class HPSFPropertiesExtractor extends POITextExtractor {
+    private Closeable toClose;
+
     public HPSFPropertiesExtractor(POITextExtractor mainExtractor) {
         super(mainExtractor);
     }
@@ -50,6 +53,7 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
     }
     public HPSFPropertiesExtractor(NPOIFSFileSystem fs) {
         super(new HPSFPropertiesOnlyDocument(fs));
+        this.toClose = fs;
     }
 
     public String getDocumentSummaryInformationText() {
@@ -119,6 +123,19 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
         throw new IllegalStateException("You already have the Metadata Text Extractor, not recursing!");
     }
     
+    
+    
+    public void close() throws IOException {
+        super.close();
+        
+        if(toClose != null) {
+            toClose.close();
+            toClose = null;
+        }
+    }
+
+
+
     private static abstract class HelperPropertySet extends SpecialPropertySet {
         public HelperPropertySet() {
             super(null);
@@ -135,7 +152,11 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
         for (String file : args) {
             HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(
                     new NPOIFSFileSystem(new File(file)));
-            System.out.println(ext.getText());
+            try {
+                System.out.println(ext.getText());
+            } finally {
+                ext.close();
+            }
         }
     }
 }
index 4eef8c4b02ad74d093dd4ead8ebdfeeff0af10d0..02b73f329e01543912d7c9464b231a87c65895b1 100644 (file)
@@ -34,7 +34,7 @@ import java.util.Map;
  * @author Rainer Klute <a
  * href="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
  */
-public class PropertyIDMap extends HashMap {
+public class PropertyIDMap extends HashMap<Long,String> {
 
     /*
      * The following definitions are for property IDs in the first
@@ -271,7 +271,7 @@ public class PropertyIDMap extends HashMap {
      *
      * @param map The instance to be created is backed by this map.
      */
-    public PropertyIDMap(final Map map)
+    public PropertyIDMap(final Map<Long,String> map)
     {
         super(map);
     }
index 340d7b987c784ba3cab84e03ded3f7f995a85ab8..7e74b7a3a66460eee370fc604a52034357087e82 100644 (file)
 
 package org.apache.poi.hssf.dev;
 
-import org.apache.poi.hssf.usermodel.HSSFPatriarch;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+
 /**
  *  Utility to test that POI produces readable output
  *  after re-saving xls files.
@@ -40,22 +39,28 @@ public class ReSave {
                 System.out.print("reading " + arg + "...");
                 FileInputStream is = new FileInputStream(arg);
                 HSSFWorkbook wb = new HSSFWorkbook(is);
-                is.close();
-                System.out.println("done");
-
-                for(int i = 0; i < wb.getNumberOfSheets(); i++){
-                    HSSFSheet sheet = wb.getSheetAt(i);
-                    if(initDrawing) {
-                        HSSFPatriarch dg = sheet.getDrawingPatriarch();
+                try {
+                    System.out.println("done");
+    
+                    for(int i = 0; i < wb.getNumberOfSheets(); i++){
+                        HSSFSheet sheet = wb.getSheetAt(i);
+                        if(initDrawing) {
+                            /*HSSFPatriarch dg =*/ sheet.getDrawingPatriarch();
+                        }
                     }
+    
+                    String outputFile = arg.replace(".xls", "-saved.xls");
+                    System.out.print("saving to " + outputFile + "...");
+                    FileOutputStream out = new FileOutputStream(outputFile);
+                    try {
+                        wb.write(out);
+                    } finally {
+                        out.close();
+                    }
+                    System.out.println("done");
+                } finally {
+                    wb.close();
                 }
-
-                String outputFile = arg.replace(".xls", "-saved.xls");
-                System.out.print("saving to " + outputFile + "...");
-                FileOutputStream out = new FileOutputStream(outputFile);
-                wb.write(out);
-                out.close();
-                System.out.println("done");
             }
         }
     }
index 8b2292e9511ca41a80c6baeb63bcab4a4c5d9865..51abcde5b9294e3d5f43abbf13474f6140c55340 100644 (file)
@@ -30,7 +30,7 @@ import java.util.ArrayList;
 public class DrawingManager2
 {
     EscherDggRecord dgg;
-    List drawingGroups = new ArrayList( );
+    List<EscherDgRecord> drawingGroups = new ArrayList<EscherDgRecord>();
 
 
     public DrawingManager2( EscherDggRecord dgg )
@@ -120,7 +120,7 @@ public class DrawingManager2
 
     EscherDgRecord getDrawingGroup(int drawingGroupId)
     {
-        return (EscherDgRecord) drawingGroups.get(drawingGroupId-1);
+        return drawingGroups.get(drawingGroupId-1);
     }
 
     boolean drawingGroupExists( short dgId )
index d9f04f7e6e517ce2452e8a09917496d5e1693477..7c9dc8a60f5fc7020fc8bfcd5acaf7bba27f6acd 100644 (file)
@@ -53,7 +53,7 @@ public final class RecordStream {
                        throw new RuntimeException("Attempt to read past end of record stream");
                }
                _countRead ++;
-               return (Record) _list.get(_nextIndex++);
+               return _list.get(_nextIndex++);
        }
 
        /**
@@ -73,7 +73,7 @@ public final class RecordStream {
                if(!hasNext()) {
                        return -1;
                }
-               return ((Record)_list.get(_nextIndex)).getSid();
+               return _list.get(_nextIndex).getSid();
        }
 
        public int getCountRead() {
index 8bc254855f366add207bc94f500c5ffa9625b782..56bc7bf8d2aa3d0e0643c50cfe971eed15bbf301 100644 (file)
@@ -212,7 +212,7 @@ public final class TextObjectRecord extends ContinuableRecord {
                for (int i = 0; i < nRuns; i++) {
                        out.writeShort(str.getIndexOfFormattingRun(i));
                        int fontIndex = str.getFontOfFormattingRun(i);
-                       out.writeShort(fontIndex == str.NO_FONT ? 0 : fontIndex);
+                       out.writeShort(fontIndex == HSSFRichTextString.NO_FONT ? 0 : fontIndex);
                        out.writeInt(0); // skip reserved
                }
                out.writeShort(str.length());
index 1ad0488ce7434ee856e456db3ff1e6165ca1c6ef..6aed70faa1285dd48455770957977d74b8fc748c 100644 (file)
@@ -32,16 +32,16 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
        /**
         * List of {@link ColumnInfoRecord}s assumed to be in order
         */
-       private final List records;
+       private final List<ColumnInfoRecord> records;
 
 
-       private static final class CIRComparator implements Comparator {
-               public static final Comparator instance = new CIRComparator();
+       private static final class CIRComparator implements Comparator<ColumnInfoRecord> {
+               public static final Comparator<ColumnInfoRecord> instance = new CIRComparator();
                private CIRComparator() {
                        // enforce singleton
                }
-               public int compare(Object a, Object b) {
-                       return compareColInfos((ColumnInfoRecord)a, (ColumnInfoRecord)b);
+               public int compare(ColumnInfoRecord a, ColumnInfoRecord b) {
+                       return compareColInfos(a, b);
                }
                public static int compareColInfos(ColumnInfoRecord a, ColumnInfoRecord b) {
                        return a.getFirstColumn()-b.getFirstColumn();
@@ -52,7 +52,7 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
         * Creates an empty aggregate
         */
        public ColumnInfoRecordsAggregate() {
-               records = new ArrayList();
+               records = new ArrayList<ColumnInfoRecord>();
        }
        public ColumnInfoRecordsAggregate(RecordStream rs) {
                this();
@@ -81,8 +81,8 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
        public Object clone() {
                ColumnInfoRecordsAggregate rec = new ColumnInfoRecordsAggregate();
                for (int k = 0; k < records.size(); k++) {
-                       ColumnInfoRecord ci = ( ColumnInfoRecord ) records.get(k);
-                       rec.records.add(ci.clone());
+                       ColumnInfoRecord ci = records.get(k);
+                       rec.records.add((ColumnInfoRecord) ci.clone());
                }
                return rec;
        }
@@ -114,7 +114,7 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
                }
                ColumnInfoRecord cirPrev = null;
                for(int i=0; i<nItems; i++) {
-                       ColumnInfoRecord cir = (ColumnInfoRecord)records.get(i);
+                       ColumnInfoRecord cir = records.get(i);
                        rv.visitRecord(cir);
                        if (cirPrev != null && CIRComparator.compareColInfos(cirPrev, cir) > 0) {
                                // Excel probably wouldn't mind, but there is much logic in this class
@@ -127,11 +127,11 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
 
        private int findStartOfColumnOutlineGroup(int pIdx) {
                // Find the start of the group.
-               ColumnInfoRecord columnInfo = (ColumnInfoRecord) records.get(pIdx);
+               ColumnInfoRecord columnInfo = records.get(pIdx);
                int level = columnInfo.getOutlineLevel();
                int idx = pIdx;
                while (idx != 0) {
-                       ColumnInfoRecord prevColumnInfo = (ColumnInfoRecord) records.get(idx - 1);
+                       ColumnInfoRecord prevColumnInfo = records.get(idx - 1);
                        if (!prevColumnInfo.isAdjacentBefore(columnInfo)) {
                                break;
                        }
@@ -147,11 +147,11 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
 
        private int findEndOfColumnOutlineGroup(int colInfoIndex) {
                // Find the end of the group.
-               ColumnInfoRecord columnInfo = (ColumnInfoRecord) records.get(colInfoIndex);
+               ColumnInfoRecord columnInfo = records.get(colInfoIndex);
                int level = columnInfo.getOutlineLevel();
                int idx = colInfoIndex;
                while (idx < records.size() - 1) {
-                       ColumnInfoRecord nextColumnInfo = (ColumnInfoRecord) records.get(idx + 1);
+                       ColumnInfoRecord nextColumnInfo = records.get(idx + 1);
                        if (!columnInfo.isAdjacentBefore(nextColumnInfo)) {
                                break;
                        }
@@ -165,7 +165,7 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
        }
 
        private ColumnInfoRecord getColInfo(int idx) {
-               return (ColumnInfoRecord) records.get( idx );
+               return records.get( idx );
        }
 
        /**
@@ -305,7 +305,7 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
                int k  = 0;
 
                for (k = 0; k < records.size(); k++) {
-                       ColumnInfoRecord tci = (ColumnInfoRecord) records.get(k);
+                       ColumnInfoRecord tci = records.get(k);
                        if (tci.containsColumn(targetColumnIx)) {
                                ci = tci;
                                break;
index cffa34173cb98c8ae88e0b4a42b6c966c23f28c4..33a2f7b2949cc79ef7782a48d4fde57a2e79f37f 100644 (file)
@@ -33,18 +33,18 @@ import org.apache.poi.ss.formula.FormulaShifter;
  */
 public final class ConditionalFormattingTable extends RecordAggregate {
 
-       private final List _cfHeaders;
+       private final List<CFRecordsAggregate> _cfHeaders;
 
        /**
         * Creates an empty ConditionalFormattingTable
         */
        public ConditionalFormattingTable() {
-               _cfHeaders = new ArrayList();
+               _cfHeaders = new ArrayList<CFRecordsAggregate>();
        }
 
        public ConditionalFormattingTable(RecordStream rs) {
 
-               List temp = new ArrayList();
+               List<CFRecordsAggregate> temp = new ArrayList<CFRecordsAggregate>();
                while (rs.peekNextClass() == CFHeaderRecord.class) {
                        temp.add(CFRecordsAggregate.createCFAggregate(rs));
                }
@@ -53,7 +53,7 @@ public final class ConditionalFormattingTable extends RecordAggregate {
 
        public void visitContainedRecords(RecordVisitor rv) {
                for (int i = 0; i < _cfHeaders.size(); i++) {
-                       CFRecordsAggregate subAgg = (CFRecordsAggregate) _cfHeaders.get(i);
+                       CFRecordsAggregate subAgg = _cfHeaders.get(i);
                        subAgg.visitContainedRecords(rv);
                }
        }
@@ -72,7 +72,7 @@ public final class ConditionalFormattingTable extends RecordAggregate {
 
        public CFRecordsAggregate get(int index) {
                checkIndex(index);
-               return (CFRecordsAggregate) _cfHeaders.get(index);
+               return _cfHeaders.get(index);
        }
 
        public void remove(int index) {
@@ -89,7 +89,7 @@ public final class ConditionalFormattingTable extends RecordAggregate {
 
        public void updateFormulasAfterCellShift(FormulaShifter shifter, int externSheetIndex) {
                for (int i = 0; i < _cfHeaders.size(); i++) {
-                       CFRecordsAggregate subAgg = (CFRecordsAggregate) _cfHeaders.get(i);
+                       CFRecordsAggregate subAgg = _cfHeaders.get(i);
                        boolean shouldKeep = subAgg.updateFormulasAfterCellShift(shifter, externSheetIndex);
                        if (!shouldKeep) {
                                _cfHeaders.remove(i);
index e2dfcd6d35370b13095fc0c1321af6212f8868d4..ff5b9604b630e6439bb71842e57f068ce5da5c20 100644 (file)
@@ -23,7 +23,6 @@ import java.util.List;
 import org.apache.poi.hssf.model.RecordStream;
 import org.apache.poi.hssf.record.DVALRecord;
 import org.apache.poi.hssf.record.DVRecord;
-import org.apache.poi.hssf.record.Record;
 
 /**
  * Manages the DVALRecord and DVRecords for a single sheet<br/>
@@ -37,20 +36,20 @@ public final class DataValidityTable extends RecordAggregate {
         * The list of data validations for the current sheet.
         * Note - this may be empty (contrary to OOO documentation)
         */
-       private final List _validationList;
+       private final List<DVRecord> _validationList;
 
        public DataValidityTable(RecordStream rs) {
                _headerRec = (DVALRecord) rs.getNext();
-               List temp = new ArrayList();
+               List<DVRecord> temp = new ArrayList<DVRecord>();
                while (rs.peekNextClass() == DVRecord.class) {
-                       temp.add(rs.getNext());
+                       temp.add((DVRecord) rs.getNext());
                }
                _validationList = temp;
        }
 
        public DataValidityTable() {
                _headerRec = new DVALRecord();
-               _validationList = new ArrayList();
+               _validationList = new ArrayList<DVRecord>();
        }
 
        public void visitContainedRecords(RecordVisitor rv) {
@@ -59,7 +58,7 @@ public final class DataValidityTable extends RecordAggregate {
                }
                rv.visitRecord(_headerRec);
                for (int i = 0; i < _validationList.size(); i++) {
-                       rv.visitRecord((Record) _validationList.get(i));
+                       rv.visitRecord(_validationList.get(i));
                }
        }
 
index 8b6f564188acfb3de762bcf47cf644c4949ffefa..8e322ce8032303899ffa8e0bf850a2de3ea8bfe3 100644 (file)
@@ -162,7 +162,7 @@ public class DVConstraint implements DataValidationConstraint {
                // formula2 and value2 are mutually exclusive
                String formula2 = getFormulaFromTextExpression(expr2);
                Double value2 = formula2 == null ? convertTime(expr2) : null;
-               return new DVConstraint(VT.TIME, comparisonOperator, formula1, formula2, value1, value2, null);
+               return new DVConstraint(ValidationType.TIME, comparisonOperator, formula1, formula2, value1, value2, null);
        }
        
        /**
@@ -192,7 +192,7 @@ public class DVConstraint implements DataValidationConstraint {
                // formula2 and value2 are mutually exclusive
                String formula2 = getFormulaFromTextExpression(expr2);
                Double value2 = formula2 == null ? convertDate(expr2, df) : null;
-               return new DVConstraint(VT.DATE, comparisonOperator, formula1, formula2, value1, value2, null);
+               return new DVConstraint(ValidationType.DATE, comparisonOperator, formula1, formula2, value1, value2, null);
        }
        
        /**
@@ -270,7 +270,7 @@ public class DVConstraint implements DataValidationConstraint {
                if (formula == null) {
                        throw new IllegalArgumentException("formula must be supplied");
                }
-               return new DVConstraint(VT.FORMULA, OperatorType.IGNORED, formula, null, null, null, null);
+               return new DVConstraint(ValidationType.FORMULA, OperatorType.IGNORED, formula, null, null, null, null);
        }
        
        /* (non-Javadoc)
@@ -284,14 +284,14 @@ public class DVConstraint implements DataValidationConstraint {
         * @return <code>true</code> if this constraint is a 'list' validation
         */
        public boolean isListValidationType() {
-               return _validationType == VT.LIST;
+               return _validationType == ValidationType.LIST;
        }
        /**
         * Convenience method
         * @return <code>true</code> if this constraint is a 'list' validation with explicit values
         */
        public boolean isExplicitList() {
-               return _validationType == VT.LIST && _explicitListValues != null;
+               return _validationType == ValidationType.LIST && _explicitListValues != null;
        }
        /* (non-Javadoc)
         * @see org.apache.poi.hssf.usermodel.DataValidationConstraint#getOperator()
@@ -316,7 +316,7 @@ public class DVConstraint implements DataValidationConstraint {
         * @see org.apache.poi.hssf.usermodel.DataValidationConstraint#setExplicitListValues(java.lang.String[])
         */
        public void setExplicitListValues(String[] explicitListValues) {
-               if (_validationType != VT.LIST) {
+               if (_validationType != ValidationType.LIST) {
                        throw new RuntimeException("Cannot setExplicitListValues on non-list constraint");
                }
                _formula1 = null;
index b3c7ee72079039564a94b07e898fe32272ba4b75..67b876923164b9bbbaafc71f45e9d8a810fe514f 100644 (file)
@@ -33,13 +33,20 @@ public class ErrorConstant {
        // convenient access to name space
        private static final ErrorConstants EC = null;
 
-       private static final ErrorConstant NULL = new ErrorConstant(EC.ERROR_NULL);
-       private static final ErrorConstant DIV_0 = new ErrorConstant(EC.ERROR_DIV_0);
-       private static final ErrorConstant VALUE = new ErrorConstant(EC.ERROR_VALUE);
-       private static final ErrorConstant REF = new ErrorConstant(EC.ERROR_REF);
-       private static final ErrorConstant NAME = new ErrorConstant(EC.ERROR_NAME);
-       private static final ErrorConstant NUM = new ErrorConstant(EC.ERROR_NUM);
-       private static final ErrorConstant NA = new ErrorConstant(EC.ERROR_NA);
+       @SuppressWarnings("static-access")
+    private static final ErrorConstant NULL = new ErrorConstant(EC.ERROR_NULL);
+       @SuppressWarnings("static-access")
+    private static final ErrorConstant DIV_0 = new ErrorConstant(EC.ERROR_DIV_0);
+       @SuppressWarnings("static-access")
+    private static final ErrorConstant VALUE = new ErrorConstant(EC.ERROR_VALUE);
+       @SuppressWarnings("static-access")
+    private static final ErrorConstant REF = new ErrorConstant(EC.ERROR_REF);
+       @SuppressWarnings("static-access")
+    private static final ErrorConstant NAME = new ErrorConstant(EC.ERROR_NAME);
+       @SuppressWarnings("static-access")
+    private static final ErrorConstant NUM = new ErrorConstant(EC.ERROR_NUM);
+       @SuppressWarnings("static-access")
+    private static final ErrorConstant NA = new ErrorConstant(EC.ERROR_NA);
 
        private final int _errorCode;
 
index 6cc8136b3706bd9a51c298abd02bd784ebdd3275..b2a46d831bce3c01b8e3e6e54961458c53d5f403 100644 (file)
@@ -29,18 +29,25 @@ public final class ErrorEval implements ValueEval {
     private static final ErrorConstants EC = null;
 
     /** <b>#NULL!</b>  - Intersection of two cell ranges is empty */
+    @SuppressWarnings("static-access")
     public static final ErrorEval NULL_INTERSECTION = new ErrorEval(EC.ERROR_NULL);
     /** <b>#DIV/0!</b> - Division by zero */
+    @SuppressWarnings("static-access")
     public static final ErrorEval DIV_ZERO = new ErrorEval(EC.ERROR_DIV_0);
     /** <b>#VALUE!</b> - Wrong type of operand */
+    @SuppressWarnings("static-access")
     public static final ErrorEval VALUE_INVALID = new ErrorEval(EC.ERROR_VALUE);
     /** <b>#REF!</b> - Illegal or deleted cell reference */
+    @SuppressWarnings("static-access")
     public static final ErrorEval REF_INVALID = new ErrorEval(EC.ERROR_REF);
     /** <b>#NAME?</b> - Wrong function or range name */
+    @SuppressWarnings("static-access")
     public static final ErrorEval NAME_INVALID = new ErrorEval(EC.ERROR_NAME);
     /** <b>#NUM!</b> - Value range overflow */
+    @SuppressWarnings("static-access")
     public static final ErrorEval NUM_ERROR = new ErrorEval(EC.ERROR_NUM);
     /** <b>#N/A</b> - Argument or function not available */
+    @SuppressWarnings("static-access")
     public static final ErrorEval NA = new ErrorEval(EC.ERROR_NA);
 
 
index 2e38c33083f562e494ecda35c4ec0eeeaa5dc751..ebe656f3970097250a9703f24fe1da562f781a67 100644 (file)
@@ -30,18 +30,25 @@ public final class ErrPtg extends ScalarConstantPtg {
     private static final ErrorConstants EC = null;
 
     /** <b>#NULL!</b>  - Intersection of two cell ranges is empty */
+    @SuppressWarnings("static-access")
     public static final ErrPtg NULL_INTERSECTION = new ErrPtg(EC.ERROR_NULL);
     /** <b>#DIV/0!</b> - Division by zero */
+    @SuppressWarnings("static-access")
     public static final ErrPtg DIV_ZERO = new ErrPtg(EC.ERROR_DIV_0);
     /** <b>#VALUE!</b> - Wrong type of operand */
+    @SuppressWarnings("static-access")
     public static final ErrPtg VALUE_INVALID = new ErrPtg(EC.ERROR_VALUE);
     /** <b>#REF!</b> - Illegal or deleted cell reference */
+    @SuppressWarnings("static-access")
     public static final ErrPtg REF_INVALID = new ErrPtg(EC.ERROR_REF);
     /** <b>#NAME?</b> - Wrong function or range name */
+    @SuppressWarnings("static-access")
     public static final ErrPtg NAME_INVALID = new ErrPtg(EC.ERROR_NAME);
     /** <b>#NUM!</b> - Value range overflow */
+    @SuppressWarnings("static-access")
     public static final ErrPtg NUM_ERROR = new ErrPtg(EC.ERROR_NUM);
     /** <b>#N/A</b> - Argument or function not available */
+    @SuppressWarnings("static-access")
     public static final ErrPtg N_A = new ErrPtg(EC.ERROR_NA);
 
 
index 5d747c59caa9351dc67f38232a256a0425e2e897..d593888730e857e63b52094428db9c813ab25157 100644 (file)
 
 package org.apache.poi.ss.util;
 
-import org.apache.poi.ss.SpreadsheetVersion;
-
 import java.util.ArrayList;
+import java.util.List;
 import java.util.StringTokenizer;
 
+import org.apache.poi.ss.SpreadsheetVersion;
+
 public class AreaReference {
 
     /** The character (!) that separates sheet names from cell references */ 
@@ -199,14 +200,14 @@ public class AreaReference {
      *  returns an array of contiguous area references.
      */
     public static AreaReference[] generateContiguous(String reference) {
-        ArrayList refs = new ArrayList();
+        List<AreaReference> refs = new ArrayList<AreaReference>();
         StringTokenizer st = new StringTokenizer(reference, ",");
         while(st.hasMoreTokens()) {
             refs.add(
                     new AreaReference(st.nextToken())
             );
         }
-        return (AreaReference[])refs.toArray(new AreaReference[refs.size()]);
+        return refs.toArray(new AreaReference[refs.size()]);
     }
 
     /**
@@ -250,14 +251,14 @@ public class AreaReference {
         int maxCol = Math.max(_firstCell.getCol(), _lastCell.getCol());
         String sheetName = _firstCell.getSheetName();
         
-        ArrayList refs = new ArrayList();
+        List<CellReference> refs = new ArrayList<CellReference>();
         for(int row=minRow; row<=maxRow; row++) {
             for(int col=minCol; col<=maxCol; col++) {
                 CellReference ref = new CellReference(sheetName, row, col, _firstCell.isRowAbsolute(), _firstCell.isColAbsolute());
                 refs.add(ref);
             }
         }
-        return (CellReference[])refs.toArray(new CellReference[refs.size()]);
+        return refs.toArray(new CellReference[refs.size()]);
     }
 
     /**
index 54112c7d1ce121e9e6374950e27e13fd7d69f665..8d99198234d3d22f81863dca29b35664b8b40372 100644 (file)
@@ -42,10 +42,10 @@ public class CellRangeAddressList {
        /**
         * List of <tt>CellRangeAddress</tt>es. Each structure represents a cell range
         */
-       protected final List _list;
+       protected final List<CellRangeAddress> _list;
 
        public CellRangeAddressList() {
-               _list = new ArrayList();
+               _list = new ArrayList<CellRangeAddress>();
        }
        /**
         * Convenience constructor for creating a <tt>CellRangeAddressList</tt> with a single 
@@ -101,14 +101,14 @@ public class CellRangeAddressList {
                        throw new RuntimeException("Range index (" + rangeIndex 
                                        + ") is outside allowable range (0.." + (_list.size()-1) + ")");
                }
-               return (CellRangeAddress) _list.remove(rangeIndex);
+               return _list.remove(rangeIndex);
        }
 
        /**
         * @return <tt>CellRangeAddress</tt> at the given index
         */
        public CellRangeAddress getCellRangeAddress(int index) {
-               return (CellRangeAddress) _list.get(index);
+               return _list.get(index);
        }
 
        public int getSize() {
@@ -131,7 +131,7 @@ public class CellRangeAddressList {
                int nItems = _list.size();
                out.writeShort(nItems);
                for (int k = 0; k < nItems; k++) {
-                       CellRangeAddress region = (CellRangeAddress) _list.get(k);
+                       CellRangeAddress region = _list.get(k);
                        region.serialize(out);
                }
        }
@@ -142,7 +142,7 @@ public class CellRangeAddressList {
                
                int nItems = _list.size();
                for (int k = 0; k < nItems; k++) {
-                       CellRangeAddress region = (CellRangeAddress) _list.get(k);
+                       CellRangeAddress region = _list.get(k);
                        result.addCellRangeAddress(region.copy());
                }
                return result;
index 551d588789fe2e02145ac6f34fcd050d1529375c..e2ae5e58c02c8a9721f89d232f6234004c31e15b 100644 (file)
@@ -88,6 +88,7 @@ import java.util.*;
  * @author Marc Johnson (mjohnson at apache dot org)
  */
 //for performance
+@SuppressWarnings("rawtypes")
 public class BinaryTree extends AbstractMap {
     final Node[] _root;
     int _size = 0;
index 6bdf45ae109acead370b46024bd69aabadb9f3cd..1114b8944569510796522d175a9549cde5ea5e54 100644 (file)
@@ -23,6 +23,7 @@ import java.awt.*;
 import java.awt.font.TextLayout;\r
 import java.text.AttributedCharacterIterator;\r
 import java.text.AttributedString;\r
+import java.text.CharacterIterator;\r
 \r
 /**\r
  * a renderable text fragment\r
@@ -76,7 +77,7 @@ class TextFragment {
 \r
         AttributedCharacterIterator it = _str.getIterator();\r
          StringBuffer buf = new StringBuffer();\r
-         for (char c = it.first(); c != it.DONE; c = it.next()) {\r
+         for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {\r
              buf.append(c);\r
          }\r
         return buf.toString();\r
index bfa4c6d6787317fea6daaf39944d5810ea5fdb0e..32eab8dc6bfd49198f2805d59b1e07dafac4e6c7 100644 (file)
@@ -33,7 +33,6 @@ import org.apache.poi.ss.formula.udf.UDFFinder;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
-import org.apache.poi.ss.usermodel.Workbook;
 
 /**
  * Evaluates formula cells.<p/>
@@ -239,7 +238,7 @@ public class XSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
         *  cells, and calling evaluateFormulaCell on each one.
         */
        public static void evaluateAllFormulaCells(XSSFWorkbook wb) {
-          HSSFFormulaEvaluator.evaluateAllFormulaCells((Workbook)wb);
+          HSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
        }
    /**
     * Loops over all cells in all sheets of the supplied
index 6727f5257cedd50d6c9e1ff2b0f7c8b839ae142d..15783163eab1bdbd873ce2ba6dd11e241457014a 100644 (file)
@@ -312,7 +312,7 @@ public class XWPFHeaderFooterPolicy {
 
 
     private XmlOptions commit(XWPFHeaderFooter wrapper) {
-        XmlOptions xmlOptions = new XmlOptions(wrapper.DEFAULT_XML_OPTIONS);
+        XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
         Map<String, String> map = new HashMap<String, String>();
         map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m");
         map.put("urn:schemas-microsoft-com:office:office", "o");
index a99e0f75ebc3eb5c98d0414712445d1b330b4ff5..b4ab2834e2456639bb0d5c2f6390ab5814601bf4 100644 (file)
@@ -109,7 +109,7 @@ public final class TestColumnHelper extends TestCase {
         assertEquals(9, cols1.sizeOfColArray());
         assertEquals(20, cols1.getColArray(8).getMin());
         assertEquals(30, cols1.getColArray(8).getMax());
-        helper.sortColumns(cols1);
+        ColumnHelper.sortColumns(cols1);
         assertEquals(9, cols1.sizeOfColArray());
         assertEquals(25, cols1.getColArray(8).getMin());
         assertEquals(27, cols1.getColArray(8).getMax());
index cac18fa9680c6eb133dca9ed323b89db9adad283..a607d0e3fd7106ebef3e2b62cfe98f618f20bfb8 100644 (file)
@@ -93,10 +93,10 @@ public final class TestXWPFHeader extends TestCase {
         pars2[1] = p3;
 
         // Set headers
-        XWPFHeader headerD = policy.createHeader(policy.DEFAULT, pars);
-        XWPFHeader headerF = policy.createHeader(policy.FIRST);
+        XWPFHeader headerD = policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT, pars);
+        XWPFHeader headerF = policy.createHeader(XWPFHeaderFooterPolicy.FIRST);
         // Set a default footer and capture the returned XWPFFooter object.
-        XWPFFooter footer = policy.createFooter(policy.DEFAULT, pars2);
+        XWPFFooter footer = policy.createFooter(XWPFHeaderFooterPolicy.DEFAULT, pars2);
 
         // Ensure the headers and footer were set correctly....
         assertNotNull(policy.getDefaultHeader());
index cca2022a79d103bfac8136529d772d4684558612..317ea8bf00d9844c1058f0967342a9cce1cc7307 100644 (file)
@@ -22,7 +22,9 @@ import java.lang.reflect.Field;
 import java.util.Arrays;
 
 import junit.framework.TestCase;
+
 import org.apache.poi.hwpf.HWPFDocFixture;
+import org.apache.poi.hwpf.model.types.DOPAbstractType;
 
 public final class TestDocumentProperties
   extends TestCase
@@ -33,7 +35,7 @@ public final class TestDocumentProperties
   public void testReadWrite()
     throws Exception
   {
-    int size = _documentProperties.getSize();
+    int size = DOPAbstractType.getSize();
     byte[] buf = new byte[size];
 
     _documentProperties.serialize(buf, 0);
index 1d71ca5c6f6ea804e05bd0947bd276f4097c4dfc..b3bfc534ed9499d7c2bae630e761d00b7bc6bfd5 100644 (file)
@@ -45,6 +45,9 @@ import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.DataValidation.ErrorStyle;
+import org.apache.poi.ss.usermodel.DataValidationConstraint.OperatorType;
 import org.apache.poi.ss.util.CellRangeAddressList;
 
 /**
@@ -149,11 +152,11 @@ public final class TestDataValidation extends BaseTestDataValidation {
                int dvRow = 0;
                Sheet sheet = wb.getSheetAt(0);
                DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
-               DataValidationConstraint dc = dataValidationHelper.createIntegerConstraint(OP.EQUAL, "42", null);
+               DataValidationConstraint dc = dataValidationHelper.createIntegerConstraint(OperatorType.EQUAL, "42", null);
                DataValidation dv = dataValidationHelper.createValidation(dc,new CellRangeAddressList(dvRow, dvRow, 0, 0));
                
                dv.setEmptyCellAllowed(false);
-               dv.setErrorStyle(ES.STOP);
+               dv.setErrorStyle(ErrorStyle.STOP);
                dv.setShowPromptBox(true);
                dv.createErrorBox("Xxx", "Yyy");
                dv.setSuppressDropDownArrow(true);
index c9ce13fca32595a827593d09c59da4dccc61f7d0..7fdb4bd7521a7b0194ba2388c55ef64440b2c720 100644 (file)
@@ -31,6 +31,7 @@ import org.apache.poi.hssf.record.LabelSSTRecord;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.Region;
 import org.apache.poi.util.TempFile;
@@ -395,7 +396,7 @@ public final class TestWorkbook extends TestCase {
         HSSFCell        c  = s.getRow(0).getCell(0);
         int             a  = c.getCellType();
 
-        assertEquals(a, c.CELL_TYPE_NUMERIC);
+        assertEquals(a, Cell.CELL_TYPE_NUMERIC);
     }
 
     /**
index 7eaa3e9132a5e0f0f8719666b9f47279f0e3eab9..e10de014cd2cc8d4e16cdd7924d3e2d74e9b6f50 100644 (file)
@@ -43,7 +43,7 @@ public final class TestEqualEval extends TestCase {
                        EvalFactory.createAreaEval("B1:B1", values),
                        BoolEval.FALSE,
                };
-               ValueEval result = evaluate(EI.Equal, args, 10, 10);
+               ValueEval result = evaluate(EvalInstances.Equal, args, 10, 10);
                if (result instanceof ErrorEval) {
                        if (result == ErrorEval.VALUE_INVALID) {
                                throw new AssertionFailedError("Identified bug in evaluation of 1x1 area");
@@ -61,7 +61,7 @@ public final class TestEqualEval extends TestCase {
                        new StringEval(""),
                        BlankEval.instance,
                };
-               ValueEval result = evaluate(EI.Equal, args, 10, 10);
+               ValueEval result = evaluate(EvalInstances.Equal, args, 10, 10);
                assertEquals(BoolEval.class, result.getClass());
                BoolEval be = (BoolEval) result;
                if (!be.getBooleanValue()) {
@@ -74,14 +74,14 @@ public final class TestEqualEval extends TestCase {
         * Test for bug 46613 (observable at svn r737248)
         */
        public void testStringInsensitive_bug46613() {
-               if (!evalStringCmp("abc", "aBc", EI.Equal)) {
+               if (!evalStringCmp("abc", "aBc", EvalInstances.Equal)) {
                        throw new AssertionFailedError("Identified bug 46613");
                }
-               assertTrue(evalStringCmp("abc", "aBc", EI.Equal));
-               assertTrue(evalStringCmp("ABC", "azz", EI.LessThan));
-               assertTrue(evalStringCmp("abc", "AZZ", EI.LessThan));
-               assertTrue(evalStringCmp("ABC", "aaa", EI.GreaterThan));
-               assertTrue(evalStringCmp("abc", "AAA", EI.GreaterThan));
+               assertTrue(evalStringCmp("abc", "aBc", EvalInstances.Equal));
+               assertTrue(evalStringCmp("ABC", "azz", EvalInstances.LessThan));
+               assertTrue(evalStringCmp("abc", "AZZ", EvalInstances.LessThan));
+               assertTrue(evalStringCmp("ABC", "aaa", EvalInstances.GreaterThan));
+               assertTrue(evalStringCmp("abc", "AAA", EvalInstances.GreaterThan));
        }
 
        private static boolean evalStringCmp(String a, String b, Function cmpOp) {
@@ -107,17 +107,17 @@ public final class TestEqualEval extends TestCase {
                confirmCompares(BoolEval.FALSE, BoolEval.FALSE, 0);
        }
        private static void confirmCompares(ValueEval a, ValueEval b, int expRes) {
-               confirm(a, b, expRes>0,  EI.GreaterThan);
-               confirm(a, b, expRes>=0, EI.GreaterEqual);
-               confirm(a, b, expRes==0, EI.Equal);
-               confirm(a, b, expRes<=0, EI.LessEqual);
-               confirm(a, b, expRes<0,  EI.LessThan);
-
-               confirm(b, a, expRes<0,  EI.GreaterThan);
-               confirm(b, a, expRes<=0, EI.GreaterEqual);
-               confirm(b, a, expRes==0, EI.Equal);
-               confirm(b, a, expRes>=0, EI.LessEqual);
-               confirm(b, a, expRes>0,  EI.LessThan);
+               confirm(a, b, expRes>0,  EvalInstances.GreaterThan);
+               confirm(a, b, expRes>=0, EvalInstances.GreaterEqual);
+               confirm(a, b, expRes==0, EvalInstances.Equal);
+               confirm(a, b, expRes<=0, EvalInstances.LessEqual);
+               confirm(a, b, expRes<0,  EvalInstances.LessThan);
+
+               confirm(b, a, expRes<0,  EvalInstances.GreaterThan);
+               confirm(b, a, expRes<=0, EvalInstances.GreaterEqual);
+               confirm(b, a, expRes==0, EvalInstances.Equal);
+               confirm(b, a, expRes>=0, EvalInstances.LessEqual);
+               confirm(b, a, expRes>0,  EvalInstances.LessThan);
        }
        private static void confirm(ValueEval a, ValueEval b, boolean expectedResult, Function cmpOp) {
                ValueEval[] args = { a, b, };
@@ -142,7 +142,7 @@ public final class TestEqualEval extends TestCase {
                        throw new AssertionFailedError("Identified bug 47198: unary minus should convert -0.0 to 0.0");
                }
                ValueEval[] args = { zero, mZero, };
-               BoolEval result = (BoolEval) evaluate(EI.Equal, args, 0, 0);
+               BoolEval result = (BoolEval) evaluate(EvalInstances.Equal, args, 0, 0);
                if (!result.getBooleanValue()) {
                        throw new AssertionFailedError("Identified bug 47198: -0.0 != 0.0");
                }
@@ -157,7 +157,7 @@ public final class TestEqualEval extends TestCase {
                assertEquals("1.0055", b.getStringValue());
 
                ValueEval[] args = { a, b, };
-               BoolEval result = (BoolEval) evaluate(EI.Equal, args, 0, 0);
+               BoolEval result = (BoolEval) evaluate(EvalInstances.Equal, args, 0, 0);
                if (!result.getBooleanValue()) {
                        throw new AssertionFailedError("Identified bug 47598: 1+1.0028-0.9973 != 1.0055");
                }
index 824c8aba5d5c35e00f8b87961ea1a509ef98d0ca..31ad51246beb802f189f8476e29c9980560a9f7b 100644 (file)
@@ -124,49 +124,54 @@ public final class TestFormulaBugs extends TestCase {
 
        /**
         * Bug 42448 - Can't parse SUMPRODUCT(A!C7:A!C67, B8:B68) / B69 <p/>
+        * @throws IOException 
         */
-       public void test42448() {
+       public void test42448() throws IOException {
                HSSFWorkbook wb = new HSSFWorkbook();
-               HSSFSheet sheet1 = wb.createSheet("Sheet1");
-
-               HSSFRow row = sheet1.createRow(0);
-               HSSFCell cell = row.createCell(0);
-
-               // it's important to create the referenced sheet first
-               HSSFSheet sheet2 = wb.createSheet("A"); // note name 'A'
-               // TODO - POI crashes if the formula is added before this sheet
-               // RuntimeException("Zero length string is an invalid sheet name")
-               // Excel doesn't crash but the formula doesn't work until it is
-               // re-entered
-
-               String inputFormula = "SUMPRODUCT(A!C7:A!C67, B8:B68) / B69"; // as per bug report
                try {
-                       cell.setCellFormula(inputFormula); 
-               } catch (StringIndexOutOfBoundsException e) {
-                       throw new AssertionFailedError("Identified bug 42448");
+               HSSFSheet sheet1 = wb.createSheet("Sheet1");
+    
+               HSSFRow row = sheet1.createRow(0);
+               HSSFCell cell = row.createCell(0);
+    
+               // it's important to create the referenced sheet first
+               HSSFSheet sheet2 = wb.createSheet("A"); // note name 'A'
+               // TODO - POI crashes if the formula is added before this sheet
+               // RuntimeException("Zero length string is an invalid sheet name")
+               // Excel doesn't crash but the formula doesn't work until it is
+               // re-entered
+    
+               String inputFormula = "SUMPRODUCT(A!C7:A!C67, B8:B68) / B69"; // as per bug report
+               try {
+                       cell.setCellFormula(inputFormula); 
+               } catch (StringIndexOutOfBoundsException e) {
+                       throw new AssertionFailedError("Identified bug 42448");
+               }
+    
+               assertEquals("SUMPRODUCT(A!C7:A!C67,B8:B68)/B69", cell.getCellFormula());
+    
+               // might as well evaluate the sucker...
+    
+               addCell(sheet2, 5, 2, 3.0); // A!C6
+               addCell(sheet2, 6, 2, 4.0); // A!C7
+               addCell(sheet2, 66, 2, 5.0); // A!C67
+               addCell(sheet2, 67, 2, 6.0); // A!C68
+    
+               addCell(sheet1, 6, 1, 7.0); // B7
+               addCell(sheet1, 7, 1, 8.0); // B8
+               addCell(sheet1, 67, 1, 9.0); // B68
+               addCell(sheet1, 68, 1, 10.0); // B69
+    
+               double expectedResult = (4.0 * 8.0 + 5.0 * 9.0) / 10.0;
+    
+               HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
+               CellValue cv = fe.evaluate(cell);
+    
+               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
+               assertEquals(expectedResult, cv.getNumberValue(), 0.0);
+               } finally {
+                   wb.close();
                }
-
-               assertEquals("SUMPRODUCT(A!C7:A!C67,B8:B68)/B69", cell.getCellFormula());
-
-               // might as well evaluate the sucker...
-
-               addCell(sheet2, 5, 2, 3.0); // A!C6
-               addCell(sheet2, 6, 2, 4.0); // A!C7
-               addCell(sheet2, 66, 2, 5.0); // A!C67
-               addCell(sheet2, 67, 2, 6.0); // A!C68
-
-               addCell(sheet1, 6, 1, 7.0); // B7
-               addCell(sheet1, 7, 1, 8.0); // B8
-               addCell(sheet1, 67, 1, 9.0); // B68
-               addCell(sheet1, 68, 1, 10.0); // B69
-
-               double expectedResult = (4.0 * 8.0 + 5.0 * 9.0) / 10.0;
-
-               HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
-               CellValue cv = fe.evaluate(cell);
-
-               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
-               assertEquals(expectedResult, cv.getNumberValue(), 0.0);
        }
 
        private static void addCell(HSSFSheet sheet, int rowIx, int colIx,
index 656c47dfd65b74cdd8ac0b20303d00b69e10cb4d..1ee9b45a8c450bc786d5a2be645e750a21258cfe 100644 (file)
@@ -40,24 +40,21 @@ import org.apache.poi.util.HexDump;
 public final class TestMinusZeroResult extends TestCase {
        private static final double MINUS_ZERO = -0.0;
 
-       // convenient access to namepace
-       private static final EvalInstances EI = null;
-
        public void testSimpleOperators() {
 
                // unary plus is a no-op
                checkEval(MINUS_ZERO, UnaryPlusEval.instance, MINUS_ZERO);
 
                // most simple operators convert -0.0 to +0.0
-               checkEval(0.0, EI.UnaryMinus, 0.0);
-               checkEval(0.0, EI.Percent, MINUS_ZERO);
-               checkEval(0.0, EI.Multiply, MINUS_ZERO, 1.0);
-               checkEval(0.0, EI.Divide, MINUS_ZERO, 1.0);
-               checkEval(0.0, EI.Power, MINUS_ZERO, 1.0);
+               checkEval(0.0, EvalInstances.UnaryMinus, 0.0);
+               checkEval(0.0, EvalInstances.Percent, MINUS_ZERO);
+               checkEval(0.0, EvalInstances.Multiply, MINUS_ZERO, 1.0);
+               checkEval(0.0, EvalInstances.Divide, MINUS_ZERO, 1.0);
+               checkEval(0.0, EvalInstances.Power, MINUS_ZERO, 1.0);
 
                // but SubtractEval does not convert -0.0, so '-' and '+' work like java
-               checkEval(MINUS_ZERO, EI.Subtract, MINUS_ZERO, 0.0); // this is the main point of bug 47198
-               checkEval(0.0, EI.Add, MINUS_ZERO, 0.0);
+               checkEval(MINUS_ZERO, EvalInstances.Subtract, MINUS_ZERO, 0.0); // this is the main point of bug 47198
+               checkEval(0.0, EvalInstances.Add, MINUS_ZERO, 0.0);
        }
 
        /**
@@ -65,9 +62,9 @@ public final class TestMinusZeroResult extends TestCase {
         * gets to the comparison operator)
         */
        public void testComparisonOperators() {
-               checkEval(false, EI.Equal, 0.0, MINUS_ZERO);
-               checkEval(true, EI.GreaterThan, 0.0, MINUS_ZERO);
-               checkEval(true, EI.LessThan, MINUS_ZERO, 0.0);
+               checkEval(false, EvalInstances.Equal, 0.0, MINUS_ZERO);
+               checkEval(true, EvalInstances.GreaterThan, 0.0, MINUS_ZERO);
+               checkEval(true, EvalInstances.LessThan, MINUS_ZERO, 0.0);
        }
 
        public void testTextRendering() {
@@ -81,7 +78,7 @@ public final class TestMinusZeroResult extends TestCase {
         */
        private static void confirmTextRendering(String expRendering, double d) {
                ValueEval[] args = { StringEval.EMPTY_INSTANCE, new NumberEval(d), };
-               StringEval se = (StringEval) EI.Concat.evaluate(args, -1, (short)-1);
+               StringEval se = (StringEval) EvalInstances.Concat.evaluate(args, -1, (short)-1);
                String result = se.getStringValue();
                assertEquals(expRendering, result);
        }
index 3a35ed942d0e127fdfc1ea63d5e944b98c790e17..2c4de24749e399c0d93dae3ea3469ceafbac03bf 100644 (file)
@@ -118,31 +118,31 @@ public final class TestIndirect extends TestCase {
                // simple error propagation:
 
                // arg0 is evaluated to text first
-               confirm(feA, c, "INDIRECT(#DIV/0!)", EE.DIV_ZERO);
-               confirm(feA, c, "INDIRECT(#DIV/0!)", EE.DIV_ZERO);
-               confirm(feA, c, "INDIRECT(#NAME?, \"x\")", EE.NAME_INVALID);
-               confirm(feA, c, "INDIRECT(#NUM!, #N/A)", EE.NUM_ERROR);
+               confirm(feA, c, "INDIRECT(#DIV/0!)", ErrorEval.DIV_ZERO);
+               confirm(feA, c, "INDIRECT(#DIV/0!)", ErrorEval.DIV_ZERO);
+               confirm(feA, c, "INDIRECT(#NAME?, \"x\")", ErrorEval.NAME_INVALID);
+               confirm(feA, c, "INDIRECT(#NUM!, #N/A)", ErrorEval.NUM_ERROR);
 
                // arg1 is evaluated to boolean before arg0 is decoded
-               confirm(feA, c, "INDIRECT(\"garbage\", #N/A)", EE.NA);
-               confirm(feA, c, "INDIRECT(\"garbage\", \"\")", EE.VALUE_INVALID); // empty string is not valid boolean
-               confirm(feA, c, "INDIRECT(\"garbage\", \"flase\")", EE.VALUE_INVALID); // must be "TRUE" or "FALSE"
+               confirm(feA, c, "INDIRECT(\"garbage\", #N/A)", ErrorEval.NA);
+               confirm(feA, c, "INDIRECT(\"garbage\", \"\")", ErrorEval.VALUE_INVALID); // empty string is not valid boolean
+               confirm(feA, c, "INDIRECT(\"garbage\", \"flase\")", ErrorEval.VALUE_INVALID); // must be "TRUE" or "FALSE"
 
 
                // spaces around sheet name (with or without quotes makes no difference)
-               confirm(feA, c, "INDIRECT(\"'Sheet1 '!D3\")", EE.REF_INVALID);
-               confirm(feA, c, "INDIRECT(\" Sheet1!D3\")", EE.REF_INVALID);
-               confirm(feA, c, "INDIRECT(\"'Sheet1' !D3\")", EE.REF_INVALID);
+               confirm(feA, c, "INDIRECT(\"'Sheet1 '!D3\")", ErrorEval.REF_INVALID);
+               confirm(feA, c, "INDIRECT(\" Sheet1!D3\")", ErrorEval.REF_INVALID);
+               confirm(feA, c, "INDIRECT(\"'Sheet1' !D3\")", ErrorEval.REF_INVALID);
 
 
-               confirm(feA, c, "SUM(INDIRECT(\"'John's sales'!A1:C1\"))", EE.REF_INVALID); // bad quote escaping
-               confirm(feA, c, "INDIRECT(\"[Book1]Sheet1!A1\")", EE.REF_INVALID); // unknown external workbook
-               confirm(feA, c, "INDIRECT(\"Sheet3!A1\")", EE.REF_INVALID); // unknown sheet
+               confirm(feA, c, "SUM(INDIRECT(\"'John's sales'!A1:C1\"))", ErrorEval.REF_INVALID); // bad quote escaping
+               confirm(feA, c, "INDIRECT(\"[Book1]Sheet1!A1\")", ErrorEval.REF_INVALID); // unknown external workbook
+               confirm(feA, c, "INDIRECT(\"Sheet3!A1\")", ErrorEval.REF_INVALID); // unknown sheet
                if (false) { // TODO - support evaluation of defined names
-                       confirm(feA, c, "INDIRECT(\"Sheet1!IW1\")", EE.REF_INVALID); // bad column
-                       confirm(feA, c, "INDIRECT(\"Sheet1!A65537\")", EE.REF_INVALID); // bad row
+                       confirm(feA, c, "INDIRECT(\"Sheet1!IW1\")", ErrorEval.REF_INVALID); // bad column
+                       confirm(feA, c, "INDIRECT(\"Sheet1!A65537\")", ErrorEval.REF_INVALID); // bad row
                }
-               confirm(feA, c, "INDIRECT(\"Sheet1!A 1\")", EE.REF_INVALID); // space in cell ref
+               confirm(feA, c, "INDIRECT(\"Sheet1!A 1\")", ErrorEval.REF_INVALID); // space in cell ref
        }
 
        public void testMultipleWorkbooks() {
@@ -186,7 +186,7 @@ public final class TestIndirect extends TestCase {
                }
                int expCode = expectedResult.getErrorCode();
                if (cv.getErrorValue() != expCode) {
-                       throw new AssertionFailedError("Expected error '" + EE.getText(expCode)
+                       throw new AssertionFailedError("Expected error '" + ErrorEval.getText(expCode)
                                        + "' but got '" + cv.formatAsString() + "'.");
                }
        }
index 10166eee0dc1e4a9c076332406c06d409807b967..5d2398d2be2b2892406ef708582776ab5e5a087d 100644 (file)
@@ -35,7 +35,7 @@ public final class TestRoundFuncs extends TestCase {
 
                ValueEval strArg = new StringEval("abc");
                ValueEval[] args = { strArg, new NumberEval(2), };
-               ValueEval result = F.ROUNDDOWN.evaluate(args, -1, (short)-1);
+               ValueEval result = NumericFunction.ROUNDDOWN.evaluate(args, -1, (short)-1);
                assertEquals(ErrorEval.VALUE_INVALID, result);
        }
 
@@ -43,7 +43,7 @@ public final class TestRoundFuncs extends TestCase {
 
                ValueEval strArg = new StringEval("abc");
                ValueEval[] args = { strArg, new NumberEval(2), };
-               ValueEval result = F.ROUNDUP.evaluate(args, -1, (short)-1);
+               ValueEval result = NumericFunction.ROUNDUP.evaluate(args, -1, (short)-1);
                assertEquals(ErrorEval.VALUE_INVALID, result);
        }
 
index 55360b96c433f24826dc48c8ae270bbafb5e619d..91bb8e7d7f766a22eeb0125cbb358c1010ce0481 100644 (file)
@@ -33,7 +33,7 @@ public final class TestTrunc extends AbstractNumericTestCase {
 
                ValueEval strArg = new StringEval("abc");
                ValueEval[] args = { strArg, new NumberEval(2) };
-               ValueEval result = F.TRUNC.evaluate(args, -1, (short)-1);
+               ValueEval result = NumericFunction.TRUNC.evaluate(args, -1, (short)-1);
                assertEquals(ErrorEval.VALUE_INVALID, result);
        }
 
@@ -53,7 +53,7 @@ public final class TestTrunc extends AbstractNumericTestCase {
        
        public void testTruncWithDecimalNumberOneArg() {
                ValueEval[] args = { new NumberEval(2.612777) };
-               ValueEval result = F.TRUNC.evaluate(args, -1, (short)-1);
+               ValueEval result = NumericFunction.TRUNC.evaluate(args, -1, (short)-1);
                assertEquals("TRUNC", (new NumberEval(2d)).getNumberValue(), ((NumberEval)result).getNumberValue());
        }
 
index 14f70295a626b8d1997f9b7b7f8d37f65c6a6b67..a93c330fd9e34423342c5eb4a9a871234683e15c 100644 (file)
@@ -178,7 +178,7 @@ public abstract class BaseTestCell extends TestCase {
                Font f = wb.createFont();
                f.setFontHeightInPoints((short) 20);
                f.setColor(IndexedColors.RED.getIndex());
-               f.setBoldweight(f.BOLDWEIGHT_BOLD);
+               f.setBoldweight(Font.BOLDWEIGHT_BOLD);
                f.setFontName("Arial Unicode MS");
                cs.setFillBackgroundColor((short)3);
                cs.setFont(f);
@@ -197,7 +197,7 @@ public abstract class BaseTestCell extends TestCase {
                r = s.getRow(0);
                c = r.getCell(0);
 
-               assertTrue("Formula Cell at 0,0", (c.getCellType()==c.CELL_TYPE_FORMULA));
+               assertTrue("Formula Cell at 0,0", (c.getCellType()==Cell.CELL_TYPE_FORMULA));
                cs = c.getCellStyle();
 
                assertNotNull("Formula Cell Style", cs);
index 40893c9dc68a137d34728df6a9244d8f2cdac7b6..e73befca4342eff4175746bb6698fe5f01230756 100644 (file)
@@ -20,6 +20,9 @@ package org.apache.poi.ss.usermodel;
 import junit.framework.TestCase;
 
 import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.usermodel.DataValidation.ErrorStyle;
+import org.apache.poi.ss.usermodel.DataValidationConstraint.OperatorType;
+import org.apache.poi.ss.usermodel.DataValidationConstraint.ValidationType;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellRangeAddressList;
 import org.apache.poi.util.POILogFactory;
@@ -107,29 +110,29 @@ public abstract class BaseTestDataValidation extends TestCase {
                }
                private DataValidationConstraint createConstraint(DataValidationHelper dataValidationHelper,int operatorType, String firstFormula,
                                String secondFormula, String[] explicitListValues) {
-                       if (_validationType == VT.LIST) {
+                       if (_validationType == ValidationType.LIST) {
                                if (explicitListValues != null) {
                                        return dataValidationHelper.createExplicitListConstraint(explicitListValues);
                                }
                                return dataValidationHelper.createFormulaListConstraint(firstFormula);
                        }
-                       if (_validationType == VT.TIME) {
+                       if (_validationType == ValidationType.TIME) {
                                return dataValidationHelper.createTimeConstraint(operatorType, firstFormula, secondFormula);
                        }
-                       if (_validationType == VT.DATE) {
+                       if (_validationType == ValidationType.DATE) {
                                return dataValidationHelper.createDateConstraint(operatorType, firstFormula, secondFormula, null);
                        }
-                       if (_validationType == VT.FORMULA) {
+                       if (_validationType == ValidationType.FORMULA) {
                                return dataValidationHelper.createCustomConstraint(firstFormula);
                        }
 
-                       if( _validationType == VT.INTEGER) {
+                       if( _validationType == ValidationType.INTEGER) {
                                return dataValidationHelper.createIntegerConstraint(operatorType, firstFormula, secondFormula);
                        }
-                       if( _validationType == VT.DECIMAL) {
+                       if( _validationType == ValidationType.DECIMAL) {
                                return dataValidationHelper.createDecimalConstraint(operatorType, firstFormula, secondFormula);
                        }
-                       if( _validationType == VT.TEXT_LENGTH) {
+                       if( _validationType == ValidationType.TEXT_LENGTH) {
                                return dataValidationHelper.createTextLengthConstraint(operatorType, firstFormula, secondFormula);
                        }
                        return null;
@@ -170,7 +173,7 @@ public abstract class BaseTestDataValidation extends TestCase {
                                boolean allowEmpty, boolean suppressDropDown) {
                        String promptDescr = (allowEmpty ? "empty ok" : "not empty")
                                        + ", " + (suppressDropDown ? "no drop-down" : "drop-down");
-                       addValidationInternal(VT.LIST, listFormula, null, ES.STOP, listValsDescr, promptDescr,
+                       addValidationInternal(ValidationType.LIST, listFormula, null, ErrorStyle.STOP, listValsDescr, promptDescr,
                                        allowEmpty, false, true, suppressDropDown, explicitListValues);
                }
        }
@@ -312,9 +315,9 @@ public abstract class BaseTestDataValidation extends TestCase {
                wf.createSheet("Custom");
                wf.createHeaderRow();
 
-               ValidationAdder va = wf.createValidationAdder(null, VT.FORMULA);
-               va.addValidation(OP.BETWEEN, "ISNUMBER($A2)", null, ES.STOP, "ISNUMBER(A2)", "Error box type = STOP", true, true, true);
-               va.addValidation(OP.BETWEEN, "IF(SUM(A2:A3)=5,TRUE,FALSE)", null, ES.WARNING, "IF(SUM(A2:A3)=5,TRUE,FALSE)", "Error box type = WARNING", false, false, true);
+               ValidationAdder va = wf.createValidationAdder(null, ValidationType.FORMULA);
+               va.addValidation(OperatorType.BETWEEN, "ISNUMBER($A2)", null, ErrorStyle.STOP, "ISNUMBER(A2)", "Error box type = STOP", true, true, true);
+               va.addValidation(OperatorType.BETWEEN, "IF(SUM(A2:A3)=5,TRUE,FALSE)", null, ErrorStyle.WARNING, "IF(SUM(A2:A3)=5,TRUE,FALSE)", "Error box type = WARNING", false, false, true);
        }
 
        private static void addSimpleNumericValidations(WorkbookFormatter wf) {
@@ -325,29 +328,29 @@ public abstract class BaseTestDataValidation extends TestCase {
                wf.createDVTypeRow("Whole number");
                wf.createHeaderRow();
 
-               ValidationAdder va = wf.createValidationAdder(null, VT.INTEGER);
-               va.addValidation(OP.BETWEEN, "2", "6", ES.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
-               va.addValidation(OP.NOT_BETWEEN, "2", "6", ES.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
-               va.addValidation(OP.EQUAL, "=3+2", null, ES.WARNING, "Equal to (3+2)", "Error box type = WARNING", false, false, true);
-               va.addValidation(OP.NOT_EQUAL, "3", null, ES.WARNING, "Not equal to 3", "-", false, false, false);
-               va.addValidation(OP.GREATER_THAN, "3", null, ES.WARNING, "Greater than 3", "-", true, false, false);
-               va.addValidation(OP.LESS_THAN, "3", null, ES.WARNING, "Less than 3", "-", true, true, false);
-               va.addValidation(OP.GREATER_OR_EQUAL, "4", null, ES.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
-               va.addValidation(OP.LESS_OR_EQUAL, "4", null, ES.STOP, "Less than or equal to 4", "-", false, true, false);
+               ValidationAdder va = wf.createValidationAdder(null, ValidationType.INTEGER);
+               va.addValidation(OperatorType.BETWEEN, "2", "6", ErrorStyle.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
+               va.addValidation(OperatorType.NOT_BETWEEN, "2", "6", ErrorStyle.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
+               va.addValidation(OperatorType.EQUAL, "=3+2", null, ErrorStyle.WARNING, "Equal to (3+2)", "Error box type = WARNING", false, false, true);
+               va.addValidation(OperatorType.NOT_EQUAL, "3", null, ErrorStyle.WARNING, "Not equal to 3", "-", false, false, false);
+               va.addValidation(OperatorType.GREATER_THAN, "3", null, ErrorStyle.WARNING, "Greater than 3", "-", true, false, false);
+               va.addValidation(OperatorType.LESS_THAN, "3", null, ErrorStyle.WARNING, "Less than 3", "-", true, true, false);
+               va.addValidation(OperatorType.GREATER_OR_EQUAL, "4", null, ErrorStyle.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
+               va.addValidation(OperatorType.LESS_OR_EQUAL, "4", null, ErrorStyle.STOP, "Less than or equal to 4", "-", false, true, false);
 
                // "Decimal" validation type
                wf.createDVTypeRow("Decimal");
                wf.createHeaderRow();
 
-               va = wf.createValidationAdder(null, VT.DECIMAL);
-               va.addValidation(OP.BETWEEN, "2", "6", ES.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
-               va.addValidation(OP.NOT_BETWEEN, "2", "6", ES.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
-               va.addValidation(OP.EQUAL, "3", null, ES.WARNING, "Equal to 3", "Error box type = WARNING", false, false, true);
-               va.addValidation(OP.NOT_EQUAL, "3", null, ES.WARNING, "Not equal to 3", "-", false, false, false);
-               va.addValidation(OP.GREATER_THAN, "=12/6", null, ES.WARNING, "Greater than (12/6)", "-", true, false, false);
-               va.addValidation(OP.LESS_THAN, "3", null, ES.WARNING, "Less than 3", "-", true, true, false);
-               va.addValidation(OP.GREATER_OR_EQUAL, "4", null, ES.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
-               va.addValidation(OP.LESS_OR_EQUAL, "4", null, ES.STOP, "Less than or equal to 4", "-", false, true, false);
+               va = wf.createValidationAdder(null, ValidationType.DECIMAL);
+               va.addValidation(OperatorType.BETWEEN, "2", "6", ErrorStyle.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
+               va.addValidation(OperatorType.NOT_BETWEEN, "2", "6", ErrorStyle.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
+               va.addValidation(OperatorType.EQUAL, "3", null, ErrorStyle.WARNING, "Equal to 3", "Error box type = WARNING", false, false, true);
+               va.addValidation(OperatorType.NOT_EQUAL, "3", null, ErrorStyle.WARNING, "Not equal to 3", "-", false, false, false);
+               va.addValidation(OperatorType.GREATER_THAN, "=12/6", null, ErrorStyle.WARNING, "Greater than (12/6)", "-", true, false, false);
+               va.addValidation(OperatorType.LESS_THAN, "3", null, ErrorStyle.WARNING, "Less than 3", "-", true, true, false);
+               va.addValidation(OperatorType.GREATER_OR_EQUAL, "4", null, ErrorStyle.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
+               va.addValidation(OperatorType.LESS_OR_EQUAL, "4", null, ErrorStyle.STOP, "Less than or equal to 4", "-", false, true, false);
        }
 
        private static void addListValidations(WorkbookFormatter wf, Workbook wb) {
@@ -366,7 +369,7 @@ public abstract class BaseTestDataValidation extends TestCase {
                wf.createDVDescriptionRow("Disadvantage - sum of item's length should be less than 255 characters");
                wf.createHeaderRow();
 
-               ValidationAdder va = wf.createValidationAdder(null, VT.LIST);
+               ValidationAdder va = wf.createValidationAdder(null, ValidationType.LIST);
                String listValsDescr = "POIFS,HSSF,HWPF,HPSF";
                String[] listVals = listValsDescr.split(",");
                va.addListValidation(listVals, null, listValsDescr, false, false);
@@ -379,7 +382,7 @@ public abstract class BaseTestDataValidation extends TestCase {
                wf.createDVTypeRow("Reference lists - list items are taken from others cells");
                wf.createDVDescriptionRow("Advantage - no restriction regarding the sum of item's length");
                wf.createHeaderRow();
-               va = wf.createValidationAdder(null, VT.LIST);
+               va = wf.createValidationAdder(null, ValidationType.LIST);
                String strFormula = "$A$30:$A$39";
                va.addListValidation(null, strFormula, strFormula, false, false);
 
@@ -422,44 +425,44 @@ public abstract class BaseTestDataValidation extends TestCase {
                wf.createDVTypeRow("Date ( cells are already formated as date - m/d/yyyy)");
                wf.createHeaderRow();
 
-               ValidationAdder va = wf.createValidationAdder(cellStyle_date, VT.DATE);
-               va.addValidation(OP.BETWEEN,     "2004/01/02", "2004/01/06", ES.STOP, "Between 1/2/2004 and 1/6/2004 ", "Error box type = STOP", true, true, true);
-               va.addValidation(OP.NOT_BETWEEN, "2004/01/01", "2004/01/06", ES.INFO, "Not between 1/2/2004 and 1/6/2004 ", "Error box type = INFO", false, true, true);
-               va.addValidation(OP.EQUAL,       "2004/03/02", null,       ES.WARNING, "Equal to 3/2/2004", "Error box type = WARNING", false, false, true);
-               va.addValidation(OP.NOT_EQUAL,   "2004/03/02", null,       ES.WARNING, "Not equal to 3/2/2004", "-", false, false, false);
-               va.addValidation(OP.GREATER_THAN,"=DATEVALUE(\"4-Jul-2001\")", null,       ES.WARNING, "Greater than DATEVALUE('4-Jul-2001')", "-", true, false, false);
-               va.addValidation(OP.LESS_THAN,   "2004/03/02", null,       ES.WARNING, "Less than 3/2/2004", "-", true, true, false);
-               va.addValidation(OP.GREATER_OR_EQUAL, "2004/03/02", null,       ES.STOP, "Greater than or equal to 3/2/2004", "Error box type = STOP", true, false, true);
-               va.addValidation(OP.LESS_OR_EQUAL, "2004/03/04", null,       ES.STOP, "Less than or equal to 3/4/2004", "-", false, true, false);
+               ValidationAdder va = wf.createValidationAdder(cellStyle_date, ValidationType.DATE);
+               va.addValidation(OperatorType.BETWEEN,     "2004/01/02", "2004/01/06", ErrorStyle.STOP, "Between 1/2/2004 and 1/6/2004 ", "Error box type = STOP", true, true, true);
+               va.addValidation(OperatorType.NOT_BETWEEN, "2004/01/01", "2004/01/06", ErrorStyle.INFO, "Not between 1/2/2004 and 1/6/2004 ", "Error box type = INFO", false, true, true);
+               va.addValidation(OperatorType.EQUAL,       "2004/03/02", null,       ErrorStyle.WARNING, "Equal to 3/2/2004", "Error box type = WARNING", false, false, true);
+               va.addValidation(OperatorType.NOT_EQUAL,   "2004/03/02", null,       ErrorStyle.WARNING, "Not equal to 3/2/2004", "-", false, false, false);
+               va.addValidation(OperatorType.GREATER_THAN,"=DATEVALUE(\"4-Jul-2001\")", null,       ErrorStyle.WARNING, "Greater than DATEVALUE('4-Jul-2001')", "-", true, false, false);
+               va.addValidation(OperatorType.LESS_THAN,   "2004/03/02", null,       ErrorStyle.WARNING, "Less than 3/2/2004", "-", true, true, false);
+               va.addValidation(OperatorType.GREATER_OR_EQUAL, "2004/03/02", null,       ErrorStyle.STOP, "Greater than or equal to 3/2/2004", "Error box type = STOP", true, false, true);
+               va.addValidation(OperatorType.LESS_OR_EQUAL, "2004/03/04", null,       ErrorStyle.STOP, "Less than or equal to 3/4/2004", "-", false, true, false);
 
                // "Time" validation type
                wf.createDVTypeRow("Time ( cells are already formated as time - h:mm)");
                wf.createHeaderRow();
 
-               va = wf.createValidationAdder(cellStyle_time, VT.TIME);
-               va.addValidation(OP.BETWEEN,     "12:00", "16:00", ES.STOP, "Between 12:00 and 16:00 ", "Error box type = STOP", true, true, true);
-               va.addValidation(OP.NOT_BETWEEN, "12:00", "16:00", ES.INFO, "Not between 12:00 and 16:00 ", "Error box type = INFO", false, true, true);
-               va.addValidation(OP.EQUAL,       "13:35", null,    ES.WARNING, "Equal to 13:35", "Error box type = WARNING", false, false, true);
-               va.addValidation(OP.NOT_EQUAL,   "13:35", null,    ES.WARNING, "Not equal to 13:35", "-", false, false, false);
-               va.addValidation(OP.GREATER_THAN,"12:00", null,    ES.WARNING, "Greater than 12:00", "-", true, false, false);
-               va.addValidation(OP.LESS_THAN,   "=1/2", null,    ES.WARNING, "Less than (1/2) -> 12:00", "-", true, true, false);
-               va.addValidation(OP.GREATER_OR_EQUAL, "14:00", null,    ES.STOP, "Greater than or equal to 14:00", "Error box type = STOP", true, false, true);
-               va.addValidation(OP.LESS_OR_EQUAL,"14:00", null,    ES.STOP, "Less than or equal to 14:00", "-", false, true, false);
+               va = wf.createValidationAdder(cellStyle_time, ValidationType.TIME);
+               va.addValidation(OperatorType.BETWEEN,     "12:00", "16:00", ErrorStyle.STOP, "Between 12:00 and 16:00 ", "Error box type = STOP", true, true, true);
+               va.addValidation(OperatorType.NOT_BETWEEN, "12:00", "16:00", ErrorStyle.INFO, "Not between 12:00 and 16:00 ", "Error box type = INFO", false, true, true);
+               va.addValidation(OperatorType.EQUAL,       "13:35", null,    ErrorStyle.WARNING, "Equal to 13:35", "Error box type = WARNING", false, false, true);
+               va.addValidation(OperatorType.NOT_EQUAL,   "13:35", null,    ErrorStyle.WARNING, "Not equal to 13:35", "-", false, false, false);
+               va.addValidation(OperatorType.GREATER_THAN,"12:00", null,    ErrorStyle.WARNING, "Greater than 12:00", "-", true, false, false);
+               va.addValidation(OperatorType.LESS_THAN,   "=1/2", null,    ErrorStyle.WARNING, "Less than (1/2) -> 12:00", "-", true, true, false);
+               va.addValidation(OperatorType.GREATER_OR_EQUAL, "14:00", null,    ErrorStyle.STOP, "Greater than or equal to 14:00", "Error box type = STOP", true, false, true);
+               va.addValidation(OperatorType.LESS_OR_EQUAL,"14:00", null,    ErrorStyle.STOP, "Less than or equal to 14:00", "-", false, true, false);
        }
 
        private static void addTextLengthValidations(WorkbookFormatter wf) {
                wf.createSheet("Text lengths");
                wf.createHeaderRow();
 
-               ValidationAdder va = wf.createValidationAdder(null, VT.TEXT_LENGTH);
-               va.addValidation(OP.BETWEEN, "2", "6", ES.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
-               va.addValidation(OP.NOT_BETWEEN, "2", "6", ES.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
-               va.addValidation(OP.EQUAL, "3", null, ES.WARNING, "Equal to 3", "Error box type = WARNING", false, false, true);
-               va.addValidation(OP.NOT_EQUAL, "3", null, ES.WARNING, "Not equal to 3", "-", false, false, false);
-               va.addValidation(OP.GREATER_THAN, "3", null, ES.WARNING, "Greater than 3", "-", true, false, false);
-               va.addValidation(OP.LESS_THAN, "3", null, ES.WARNING, "Less than 3", "-", true, true, false);
-               va.addValidation(OP.GREATER_OR_EQUAL, "4", null, ES.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
-               va.addValidation(OP.LESS_OR_EQUAL, "4", null, ES.STOP, "Less than or equal to 4", "-", false, true, false);
+               ValidationAdder va = wf.createValidationAdder(null, ValidationType.TEXT_LENGTH);
+               va.addValidation(OperatorType.BETWEEN, "2", "6", ErrorStyle.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
+               va.addValidation(OperatorType.NOT_BETWEEN, "2", "6", ErrorStyle.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
+               va.addValidation(OperatorType.EQUAL, "3", null, ErrorStyle.WARNING, "Equal to 3", "Error box type = WARNING", false, false, true);
+               va.addValidation(OperatorType.NOT_EQUAL, "3", null, ErrorStyle.WARNING, "Not equal to 3", "-", false, false, false);
+               va.addValidation(OperatorType.GREATER_THAN, "3", null, ErrorStyle.WARNING, "Greater than 3", "-", true, false, false);
+               va.addValidation(OperatorType.LESS_THAN, "3", null, ErrorStyle.WARNING, "Less than 3", "-", true, true, false);
+               va.addValidation(OperatorType.GREATER_OR_EQUAL, "4", null, ErrorStyle.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
+               va.addValidation(OperatorType.LESS_OR_EQUAL, "4", null, ErrorStyle.STOP, "Less than or equal to 4", "-", false, true, false);
        }
 
        public void testDataValidation() {
index f72e37b512267eef7dc869b78bd9adc907367ca6..976c7d918e2a05352c8e045f8d0b396c44dfa67b 100644 (file)
@@ -24,10 +24,10 @@ import java.util.List;
  *  tests can see what got logged
  */
 public class DummyPOILogger extends POILogger {
-       public List logged = new ArrayList(); 
+       public List<String>logged = new ArrayList<String>(); 
 
        public void reset() {
-               logged = new ArrayList();
+               logged = new ArrayList<String>();
        }
        
        public boolean check(int level) {