]> source.dussan.org Git - poi.git/commitdiff
Eclipse warnings, code formatting, missing @Overrides, Javadoc, missing close(), ...
authorDominik Stadler <centic@apache.org>
Thu, 20 Aug 2015 14:28:39 +0000 (14:28 +0000)
committerDominik Stadler <centic@apache.org>
Thu, 20 Aug 2015 14:28:39 +0000 (14:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1696794 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
src/java/org/apache/poi/ss/usermodel/Workbook.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java

index 65ec1a33e5740138c195ad65fd99b6673c9e3496..f7d2e93fddfa86903e9f74b37afcac6d6403b044 100644 (file)
@@ -197,8 +197,8 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * Given a POI POIFSFileSystem object, read in its Workbook along
      *  with all related nodes, and populate the high and low level models.
      * <p>This calls {@link #HSSFWorkbook(POIFSFileSystem, boolean)} with
-     *  preserve nodes set to true. 
-     * 
+     *  preserve nodes set to true.
+     *
      * @see #HSSFWorkbook(POIFSFileSystem, boolean)
      * @see org.apache.poi.poifs.filesystem.POIFSFileSystem
      * @exception IOException if the stream cannot be read
@@ -210,8 +210,8 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * Given a POI POIFSFileSystem object, read in its Workbook along
      *  with all related nodes, and populate the high and low level models.
      * <p>This calls {@link #HSSFWorkbook(POIFSFileSystem, boolean)} with
-     *  preserve nodes set to true. 
-     * 
+     *  preserve nodes set to true.
+     *
      * @see #HSSFWorkbook(POIFSFileSystem, boolean)
      * @see org.apache.poi.poifs.filesystem.POIFSFileSystem
      * @exception IOException if the stream cannot be read
@@ -221,7 +221,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
     }
 
     /**
-     * Given a POI POIFSFileSystem object, read in its Workbook and populate 
+     * Given a POI POIFSFileSystem object, read in its Workbook and populate
      * the high and low level models.  If you're reading in a workbook... start here!
      *
      * @param fs the POI filesystem that contains the Workbook stream.
@@ -259,7 +259,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
                 // continue - to try other options
             }
         }
-        
+
         // check for an encrypted .xlsx file - they get OLE2 wrapped
         try {
                directory.getEntry(Decryptor.DEFAULT_POIFS_ENTRY);
@@ -363,10 +363,10 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
     }
 
     /**
-     * Companion to HSSFWorkbook(POIFSFileSystem), this constructs the 
+     * Companion to HSSFWorkbook(POIFSFileSystem), this constructs the
      *  POI filesystem around your {@link InputStream}, including all nodes.
      * <p>This calls {@link #HSSFWorkbook(InputStream, boolean)} with
-     *  preserve nodes set to true. 
+     *  preserve nodes set to true.
      *
      * @see #HSSFWorkbook(InputStream, boolean)
      * @see #HSSFWorkbook(POIFSFileSystem)
@@ -378,7 +378,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
     }
 
     /**
-     * Companion to HSSFWorkbook(POIFSFileSystem), this constructs the 
+     * Companion to HSSFWorkbook(POIFSFileSystem), this constructs the
      * POI filesystem around your {@link InputStream}.
      *
      * @param s  the POI filesystem that contains the Workbook stream.
@@ -389,6 +389,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @see #HSSFWorkbook(POIFSFileSystem)
      * @exception IOException if the stream cannot be read
      */
+    @SuppressWarnings("resource")   // NPOIFSFileSystem always closes the stream
     public HSSFWorkbook(InputStream s, boolean preserveNodes)
             throws IOException
     {
@@ -457,6 +458,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * The default is to return blank and null cells.
      *  {@link MissingCellPolicy}
      */
+    @Override
     public MissingCellPolicy getMissingCellPolicy() {
         return missingCellPolicy;
     }
@@ -471,6 +473,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      *  iterators, only on when fetching Cells
      *  by their column index.
      */
+    @Override
     public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
         this.missingCellPolicy = missingCellPolicy;
     }
@@ -482,6 +485,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @param pos the position that we want to insert the sheet into (0 based)
      */
 
+    @Override
     public void setSheetOrder(String sheetname, int pos ) {
         int oldSheetIndex = getSheetIndex(sheetname);
         _sheets.add(pos,_sheets.remove(oldSheetIndex));
@@ -527,6 +531,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * Selects a single sheet. This may be different to
      * the 'active' sheet (which is the sheet with focus).
      */
+    @Override
     public void setSelectedTab(int index) {
 
         validateSheetIndex(index);
@@ -568,6 +573,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * which is currently displayed when the workbook is viewed in Excel.
      * 'Selected' sheet(s) is a distinct concept.
      */
+    @Override
     public void setActiveSheet(int index) {
 
         validateSheetIndex(index);
@@ -585,6 +591,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * in the tabs (at the bottom).
      * @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean)
      */
+    @Override
     public int getActiveSheetIndex() {
         return workbook.getWindowOne().getActiveSheetIndex();
     }
@@ -603,6 +610,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * in excel.
      * @param index
      */
+    @Override
     public void setFirstVisibleTab(int index) {
         workbook.getWindowOne().setFirstVisibleTab(index);
     }
@@ -618,6 +626,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
     /**
      * sets the first tab that is displayed in the list of tabs in excel.
      */
+    @Override
     public int getFirstVisibleTab() {
         return workbook.getWindowOne().getFirstVisibleTab();
     }
@@ -639,6 +648,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @see #createSheet(String)
      * @see org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)
      */
+    @Override
     public void setSheetName(int sheetIx, String name) {
         if (name == null) {
             throw new IllegalArgumentException("sheetName must not be null");
@@ -654,35 +664,42 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
     /**
      * @return Sheet name for the specified index
      */
+    @Override
     public String getSheetName(int sheetIndex) {
         validateSheetIndex(sheetIndex);
         return workbook.getSheetName(sheetIndex);
     }
 
+    @Override
     public boolean isHidden() {
         return workbook.getWindowOne().getHidden();
     }
 
+    @Override
     public void setHidden(boolean hiddenFlag) {
         workbook.getWindowOne().setHidden(hiddenFlag);
     }
 
+    @Override
     public boolean isSheetHidden(int sheetIx) {
         validateSheetIndex(sheetIx);
         return workbook.isSheetHidden(sheetIx);
     }
 
+    @Override
     public boolean isSheetVeryHidden(int sheetIx) {
         validateSheetIndex(sheetIx);
         return workbook.isSheetVeryHidden(sheetIx);
     }
 
 
+    @Override
     public void setSheetHidden(int sheetIx, boolean hidden) {
         validateSheetIndex(sheetIx);
         workbook.setSheetHidden(sheetIx, hidden);
     }
 
+    @Override
     public void setSheetHidden(int sheetIx, int hidden) {
         validateSheetIndex(sheetIx);
         WorkbookUtil.validateSheetState(hidden);
@@ -693,6 +710,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @param name the sheet name
      * @return index of the sheet (0 based)
      */
+    @Override
     public int getSheetIndex(String name){
         return workbook.getSheetIndex(name);
     }
@@ -701,6 +719,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @param sheet the sheet to look up
      * @return index of the sheet (0 based). <tt>-1</tt> if not found
      */
+    @Override
     public int getSheetIndex(org.apache.poi.ss.usermodel.Sheet sheet) {
         for(int i=0; i<_sheets.size(); i++) {
             if(_sheets.get(i) == sheet) {
@@ -753,6 +772,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @return HSSFSheet representing the new sheet.
      */
 
+    @Override
     public HSSFSheet createSheet()
     {
         HSSFSheet sheet = new HSSFSheet(this);
@@ -771,6 +791,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @return HSSFSheet representing the cloned sheet.
      */
 
+    @Override
     public HSSFSheet cloneSheet(int sheetIndex) {
         validateSheetIndex(sheetIndex);
         HSSFSheet srcSheet = _sheets.get(sheetIndex);
@@ -871,6 +892,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      *  or workbook already contains a sheet with this name
      * @see org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)
      */
+    @Override
     public HSSFSheet createSheet(String sheetname)
     {
         if (sheetname == null) {
@@ -895,6 +917,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @return number of sheets
      */
 
+    @Override
     public int getNumberOfSheets()
     {
         return _sheets.size();
@@ -922,6 +945,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @return HSSFSheet at the provided index
      */
 
+    @Override
     public HSSFSheet getSheetAt(int index)
     {
         validateSheetIndex(index);
@@ -934,6 +958,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @return HSSFSheet with the name provided or <code>null</code> if it does not exist
      */
 
+    @Override
     public HSSFSheet getSheet(String name)
     {
         HSSFSheet retval = null;
@@ -964,6 +989,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      *
      * @param index of the sheet  (0-based)
      */
+    @Override
     public void removeSheetAt(int index) {
         validateSheetIndex(index);
         boolean wasSelected = getSheetAt(index).isSelected();
@@ -1064,6 +1090,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @deprecated use {@link HSSFSheet#setRepeatingRows(CellRangeAddress)}
      *        or {@link HSSFSheet#setRepeatingColumns(CellRangeAddress)}
      */
+    @Override
     @Deprecated
        public void setRepeatingRowsAndColumns(int sheetIndex,
                                            int startColumn, int endColumn,
@@ -1126,6 +1153,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @return new font object
      */
 
+    @Override
     public HSSFFont createFont()
     {
         /*FontRecord font =*/ workbook.createNewFont();
@@ -1147,6 +1175,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
     /**
      * Finds a font that matches the one with the supplied attributes
      */
+    @Override
     public HSSFFont findFont(short boldWeight, short color, short fontHeight,
                              String name, boolean italic, boolean strikeout,
                              short typeOffset, byte underline)
@@ -1177,6 +1206,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @return number of fonts
      */
 
+    @Override
     public short getNumberOfFonts()
     {
         return (short) workbook.getNumberOfFontRecords();
@@ -1187,6 +1217,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @param idx  index number
      * @return HSSFFont at the index
      */
+    @Override
     public HSSFFont getFontAt(short idx) {
         if(fonts == null) fonts = new Hashtable<Short, HSSFFont>();
 
@@ -1220,9 +1251,9 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * You can define up to 4000 unique styles in a .xls workbook.
      *
      * @return the new Cell Style object
-     * @throws IllegalStateException if the maximum number of cell styles exceeded the limit
+     * @throws IllegalStateException if the number of cell styles exceeded the limit for this type of Workbook.
      */
-
+    @Override
     public HSSFCellStyle createCellStyle()
     {
         if(workbook.getNumExFormats() == MAX_STYLES) {
@@ -1241,6 +1272,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @return count of cell styles
      */
 
+    @Override
     public short getNumCellStyles()
     {
         return (short) workbook.getNumExFormats();
@@ -1251,6 +1283,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @param idx  index within the set of styles
      * @return HSSFCellStyle object at the index
      */
+    @Override
     public HSSFCellStyle getCellStyleAt(short idx)
     {
         ExtendedFormatRecord xfr = workbook.getExFormatAt(idx);
@@ -1258,7 +1291,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
 
         return style;
     }
-    
+
     /**
      * Closes the underlying {@link NPOIFSFileSystem} from which
      *  the Workbook was read, if any. Has no effect on Workbooks
@@ -1336,10 +1369,11 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
         public int getTotalSize() {
             return _totalSize;
         }
+        @Override
         public void visitRecord(Record r) {
             _list.add(r);
             _totalSize+=r.getRecordSize();
-            
+
         }
         public int serialize(int offset, byte[] data) {
             int result = 0;
@@ -1432,11 +1466,13 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
         return workbook;
     }
 
+    @Override
     public int getNumberOfNames(){
         int result = names.size();
         return result;
     }
 
+    @Override
     public HSSFName getName(String name) {
         int nameIndex = getNameIndex(name);
         if (nameIndex < 0) {
@@ -1445,6 +1481,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
         return names.get(nameIndex);
     }
 
+    @Override
     public HSSFName getNameAt(int nameIndex) {
         int nNames = names.size();
         if (nNames < 1) {
@@ -1478,6 +1515,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
      * @param reference Valid name Reference for the Print Area
      */
+    @Override
     public void setPrintArea(int sheetIndex, String reference)
     {
         NameRecord name = workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
@@ -1509,6 +1547,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @param startRow Row to begin the printarea
      * @param endRow Row to end the printarea
      */
+    @Override
     public void setPrintArea(int sheetIndex, int startColumn, int endColumn,
                               int startRow, int endRow) {
 
@@ -1528,6 +1567,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
      * @return String Null if no print area has been defined
      */
+    @Override
     public String getPrintArea(int sheetIndex) {
         NameRecord name = workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
         //adding one here because 0 indicates a global named region; doesn't make sense for print areas
@@ -1542,6 +1582,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * Delete the printarea for the sheet specified
      * @param sheetIndex Zero-based sheet index (0 = First Sheet)
      */
+    @Override
     public void removePrintArea(int sheetIndex) {
         getWorkbook().removeBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
     }
@@ -1549,6 +1590,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
     /** creates a new named range and add it to the model
      * @return named range high level
      */
+    @Override
     public HSSFName createName(){
         NameRecord nameRecord = workbook.createName();
 
@@ -1559,6 +1601,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
         return newName;
     }
 
+    @Override
     public int getNameIndex(String name) {
 
         for (int k = 0; k < names.size(); k++) {
@@ -1591,6 +1634,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
     }
 
 
+    @Override
     public void removeName(int index){
         names.remove(index);
         workbook.removeName(index);
@@ -1602,6 +1646,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @see org.apache.poi.hssf.record.FormatRecord
      * @see org.apache.poi.hssf.record.Record
      */
+    @Override
     public HSSFDataFormat createDataFormat() {
     if (formatter == null)
         formatter = new HSSFDataFormat(workbook);
@@ -1609,6 +1654,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
     }
 
 
+    @Override
     public void removeName(String name) {
         int index = getNameIndex(name);
         removeName(index);
@@ -1698,6 +1744,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      *
      * @return the index to this picture (1 based).
      */
+    @Override
     public int addPicture(byte[] pictureData, int format)
     {
         initDrawings();
@@ -1759,7 +1806,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
                 blipRecord.setOptions(HSSFPictureData.MSOBI_DIB);
                 break;
         }
-        
+
         EscherBSERecord r = new EscherBSERecord();
         r.setRecordId( EscherBSERecord.RECORD_ID );
         r.setOptions( (short) ( 0x0002 | ( format << 4 ) ) );
@@ -1771,7 +1818,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
         r.setRef( 0 );
         r.setOffset( 0 );
         r.setBlipRecord( blipRecord );
-        
+
         return workbook.addBSERecord( r );
     }
 
@@ -1780,6 +1827,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      *
      * @return the list of pictures (a list of {@link HSSFPictureData} objects.)
      */
+    @Override
     public List<HSSFPictureData> getAllPictures()
     {
         // The drawing group record always exists at the top level, so we won't need to do this recursively.
@@ -1836,7 +1884,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
        // ... to be continued
        return olemap;
     }
-    
+
     public int addOlePackage(POIFSFileSystem poiData, String label, String fileName, String command)
     throws IOException {
        DirectoryNode root = poiData.getRoot();
@@ -1847,12 +1895,12 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
                        break;
                }
        }
-       
+
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        poiData.writeFilesystem(bos);
         return addOlePackage(bos.toByteArray(), label, fileName, command);
     }
-    
+
     public int addOlePackage(byte[] oleData, String label, String fileName, String command)
     throws IOException {
        // check if we were created by POIFS otherwise create a new dummy POIFS for storing the package data
@@ -1860,7 +1908,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
                directory = new NPOIFSFileSystem().getRoot();
                preserveNodes = true;
        }
-       
+
         // get free MBD-Node
         int storageId = 0;
         DirectoryEntry oleDir = null;
@@ -1871,34 +1919,35 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
                 oleDir.setStorageClsid(ClassID.OLE10_PACKAGE);
             }
         } while (oleDir == null);
-       
+
         // the following data was taken from an example libre office document
         // beside this "\u0001Ole" record there were several other records, e.g. CompObj,
         // OlePresXXX, but it seems, that they aren't neccessary
         byte oleBytes[] = { 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
         oleDir.createDocument("\u0001Ole", new ByteArrayInputStream(oleBytes));
-        
+
         Ole10Native oleNative = new Ole10Native(label, fileName, command, oleData);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         oleNative.writeOut(bos);
         oleDir.createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray()));
-        
+
        return storageId;
     }
-    
+
     /**
      * Adds the LinkTable records required to allow formulas referencing
      *  the specified external workbook to be added to this one. Allows
-     *  formulas such as "[MyOtherWorkbook]Sheet3!$A$5" to be added to the 
+     *  formulas such as "[MyOtherWorkbook]Sheet3!$A$5" to be added to the
      *  file, for workbooks not already referenced.
      *
      * @param name The name the workbook will be referenced as in formulas
      * @param workbook The open workbook to fetch the link required information from
      */
+    @Override
     public int linkExternalWorkbook(String name, Workbook workbook) {
         return this.workbook.linkExternalWorkbook(name, workbook);
     }
-    
+
     /**
      * Is the workbook protected with a password (not encrypted)?
      */
@@ -1967,6 +2016,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
             }
         }
     }
+    @Override
     public HSSFCreationHelper getCreationHelper() {
         return new HSSFCreationHelper(this);
     }
@@ -1987,6 +2037,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      *
      * @param toopack the toolpack to register
      */
+    @Override
     public void addToolPack(UDFFinder toopack){
         AggregatingUDFFinder udfs = (AggregatingUDFFinder)_udfFinder;
         udfs.add(toopack);
@@ -2009,6 +2060,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * workbook values when the workbook is opened
      * @since 3.8
      */
+    @Override
     public void setForceFormulaRecalculation(boolean value){
         InternalWorkbook iwb = getWorkbook();
         RecalcIdRecord recalc = iwb.getRecalcId();
@@ -2020,6 +2072,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      *
      * @since 3.8
      */
+    @Override
     public boolean getForceFormulaRecalculation(){
         InternalWorkbook iwb = getWorkbook();
         RecalcIdRecord recalc = (RecalcIdRecord)iwb.findFirstRecordBySid(RecalcIdRecord.sid);
index 9d0566c13f67da659707b440a73af3e2179abd4e..7de84fa88f939d3006438b76e5b09f0ff7c515d3 100644 (file)
@@ -54,7 +54,7 @@ public interface Workbook extends Closeable {
 
     /**
      * Indicates the sheet is visible.
-     * 
+     *
      * @see #setSheetHidden(int, int)
      */
     public static final int SHEET_STATE_VISIBLE = 0;
@@ -286,10 +286,11 @@ public interface Workbook extends Closeable {
      * @param endColumn     0 based end of repeating columns.
      * @param startRow      0 based start of repeating rows.
      * @param endRow        0 based end of repeating rows.
-     * 
+     *
      * @deprecated use {@link Sheet#setRepeatingRows(CellRangeAddress)}
      *        or {@link Sheet#setRepeatingColumns(CellRangeAddress)}
      */
+    @Deprecated
     void setRepeatingRowsAndColumns(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow);
 
     /**
@@ -325,6 +326,7 @@ public interface Workbook extends Closeable {
      * Create a new Cell style and add it to the workbook's style table
      *
      * @return the new Cell Style object
+     * @throws IllegalStateException if the number of cell styles exceeded the limit for this type of Workbook.
      */
     CellStyle createCellStyle();
 
@@ -357,8 +359,9 @@ public interface Workbook extends Closeable {
      *  Workbook should no longer be used.
      * <p>This will have no effect newly created Workbooks.
      */
+    @Override
     void close() throws IOException;
-    
+
     /**
      * @return the total number of defined names in this workbook
      */
@@ -414,7 +417,7 @@ public interface Workbook extends Closeable {
      *  to be added to the file, some linking information must first
      *  be recorded. Once a given external workbook has been linked,
      *  then formulas using it can added. Each workbook needs linking
-     *  only once. 
+     *  only once.
      * <p>This linking only applies for writing formulas. To link things
      *  for evaluation, see {@link FormulaEvaluator#setupReferencedWorkbooks(java.util.Map)}
      *
@@ -422,7 +425,7 @@ public interface Workbook extends Closeable {
      * @param workbook The open workbook to fetch the link required information from
      */
     int linkExternalWorkbook(String name, Workbook workbook);
-    
+
      /**
      * Sets the printarea for the sheet provided
      * <p>
@@ -557,7 +560,7 @@ public interface Workbook extends Closeable {
 
     /**
      * Hide or unhide a sheet.
-     * 
+     *
      * <ul>
      *  <li>0 - visible. </li>
      *  <li>1 - hidden. </li>
index f83facdda4d1cff4b2a6b199659362fe16c90043..b3587fc4a080c4a241ae0592de42f1acf04f6516 100644 (file)
@@ -131,10 +131,11 @@ public class XSSFCellStyle implements CellStyle {
      *  XSSFWorkbook if you like. This allows you to
      *  copy styles from one XSSFWorkbook to another.
      */
+    @Override
     public void cloneStyleFrom(CellStyle source) {
         if(source instanceof XSSFCellStyle) {
             XSSFCellStyle src = (XSSFCellStyle)source;
-            
+
             // Is it on our Workbook?
             if(src._stylesSource == _stylesSource) {
                // Nice and easy
@@ -149,30 +150,30 @@ public class XSSFCellStyle implements CellStyle {
                      _cellXf.unsetAlignment();
                   if(_cellXf.isSetExtLst())
                      _cellXf.unsetExtLst();
-                  
+
                   // Create a new Xf with the same contents
                   _cellXf = CTXf.Factory.parse(
                         src.getCoreXf().toString()
                   );
-                  
+
                   // bug 56295: ensure that the fills is available and set correctly
                   CTFill fill = CTFill.Factory.parse(
                                  src.getCTFill().toString()
                                  );
                   addFill(fill);
-                  
+
                   // Swap it over
                   _stylesSource.replaceCellXfAt(_cellXfId, _cellXf);
                } catch(XmlException e) {
                   throw new POIXMLException(e);
                }
-               
+
                // Copy the format
                String fmt = src.getDataFormatString();
                setDataFormat(
                      (new XSSFDataFormat(_stylesSource)).getFormat(fmt)
                );
-               
+
                // Copy the font
                try {
                   CTFont ctFont = CTFont.Factory.parse(
@@ -185,7 +186,7 @@ public class XSSFCellStyle implements CellStyle {
                   throw new POIXMLException(e);
                }
             }
-            
+
             // Clear out cached details
             _font = null;
             _cellAlignment = null;
@@ -213,6 +214,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_JUSTIFY
      * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION
      */
+    @Override
     public short getAlignment() {
         return (short)(getAlignmentEnum().ordinal());
     }
@@ -250,6 +252,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
      */
+    @Override
     public short getBorderBottom() {
         if(!_cellXf.getApplyBorder()) return BORDER_NONE;
 
@@ -289,6 +292,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
      */
+    @Override
     public short getBorderLeft() {
         if(!_cellXf.getApplyBorder()) return BORDER_NONE;
 
@@ -327,6 +331,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
      */
+    @Override
     public short getBorderRight() {
         if(!_cellXf.getApplyBorder()) return BORDER_NONE;
 
@@ -365,6 +370,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
      */
+    @Override
     public short getBorderTop() {
         if(!_cellXf.getApplyBorder()) return BORDER_NONE;
 
@@ -391,6 +397,7 @@ public class XSSFCellStyle implements CellStyle {
      * @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC}
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public short getBottomBorderColor() {
         XSSFColor clr = getBottomBorderXSSFColor();
         return clr == null ? IndexedColors.BLACK.getIndex() : clr.getIndexed();
@@ -415,6 +422,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @return the index of the number format
      */
+    @Override
     public short getDataFormat() {
         return (short)_cellXf.getNumFmtId();
     }
@@ -425,6 +433,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @return the number format string
      */
+    @Override
     public String getDataFormatString() {
         int idx = getDataFormat();
         return new XSSFDataFormat(_stylesSource).getFormat((short)idx);
@@ -439,11 +448,13 @@ public class XSSFCellStyle implements CellStyle {
      * @return fill color, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC}
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public short getFillBackgroundColor() {
         XSSFColor clr = getFillBackgroundXSSFColor();
         return clr == null ? IndexedColors.AUTOMATIC.getIndex() : clr.getIndexed();
     }
-    
+
+    @Override
     public XSSFColor getFillBackgroundColorColor() {
        return getFillBackgroundXSSFColor();
     }
@@ -480,15 +491,17 @@ public class XSSFCellStyle implements CellStyle {
      * @see IndexedColors
      * @return fill color, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC}
      */
+    @Override
     public short getFillForegroundColor() {
         XSSFColor clr = getFillForegroundXSSFColor();
         return clr == null ? IndexedColors.AUTOMATIC.getIndex() : clr.getIndexed();
     }
 
+    @Override
     public XSSFColor getFillForegroundColorColor() {
        return getFillForegroundXSSFColor();
     }
-    
+
     /**
      * Get the foreground fill color.
      *
@@ -530,6 +543,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#SQUARES
      * @see org.apache.poi.ss.usermodel.CellStyle#DIAMONDS
      */
+    @Override
     public short getFillPattern() {
        // bug 56295: handle missing applyFill attribute as "true" because Excel does as well
         if(_cellXf.isSetApplyFill() && !_cellXf.getApplyFill()) return 0;
@@ -569,6 +583,7 @@ public class XSSFCellStyle implements CellStyle {
      * @return short - font index
      * @see org.apache.poi.xssf.usermodel.XSSFWorkbook#getFontAt(short)
      */
+    @Override
     public short getFontIndex() {
         return (short) getFontId();
     }
@@ -578,6 +593,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @return boolean -  whether the cell using this style is hidden
      */
+    @Override
     public boolean getHidden() {
         if (!_cellXf.isSetProtection() || !_cellXf.getProtection().isSetHidden()) {
             return false;
@@ -590,6 +606,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @return indent - number of spaces
      */
+    @Override
     public short getIndention() {
         CTCellAlignment align = _cellXf.getAlignment();
         return (short)(align == null ? 0 : align.getIndent());
@@ -600,9 +617,18 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @return unique index number of the underlying record this style represents
      */
+    @Override
     public short getIndex() {
         return (short)this._cellXfId;
     }
+
+    /**
+     * Workaround for places where we need to support more than 32767 cell styles, ideally
+     * the main getIndex() and others would return int, not short, but that would affect some
+     * public APIs
+     *
+     * @return
+     */
     protected int getUIndex() {
         return this._cellXfId;
     }
@@ -613,6 +639,7 @@ public class XSSFCellStyle implements CellStyle {
      * @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#BLACK}
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public short getLeftBorderColor() {
         XSSFColor clr = getLeftBorderXSSFColor();
         return clr == null ? IndexedColors.BLACK.getIndex() : clr.getIndexed();
@@ -638,6 +665,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @return whether the cell using this style are locked
      */
+    @Override
     public boolean getLocked() {
         if (!_cellXf.isSetProtection() || !_cellXf.getProtection().isSetLocked()) {
             return true;
@@ -651,6 +679,7 @@ public class XSSFCellStyle implements CellStyle {
      * @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#BLACK}
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public short getRightBorderColor() {
         XSSFColor clr = getRightBorderXSSFColor();
         return clr == null ? IndexedColors.BLACK.getIndex() : clr.getIndexed();
@@ -683,22 +712,25 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @return rotation degrees (between 0 and 180 degrees)
      */
+    @Override
     public short getRotation() {
         CTCellAlignment align = _cellXf.getAlignment();
         return (short)(align == null ? 0 : align.getTextRotation());
     }
 
+    @Override
     public boolean getShrinkToFit() {
         CTCellAlignment align = _cellXf.getAlignment();
         return align != null && align.getShrinkToFit();
     }
-    
+
     /**
      * Get the color to use for the top border
      *
      * @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#BLACK}
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public short getTopBorderColor() {
         XSSFColor clr = getTopBorderXSSFColor();
         return clr == null ? IndexedColors.BLACK.getIndex() : clr.getIndexed();
@@ -727,6 +759,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_BOTTOM
      * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_JUSTIFY
      */
+    @Override
     public short getVerticalAlignment() {
         return (short) (getVerticalAlignmentEnum().ordinal());
     }
@@ -750,6 +783,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @return  a boolean value indicating if the text in a cell should be line-wrapped within the cell.
      */
+    @Override
     public boolean getWrapText() {
         CTCellAlignment align = _cellXf.getAlignment();
         return align != null && align.getWrapText();
@@ -767,6 +801,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_JUSTIFY
      * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION
      */
+    @Override
     public void setAlignment(short align) {
         getCellAlignment().setHorizontal(HorizontalAlignment.values()[align]);
     }
@@ -800,6 +835,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
      */
+    @Override
     public void setBorderBottom(short border) {
         CTBorder ct = getCTBorder();
         CTBorderPr pr = ct.isSetBottom() ? ct.getBottom() : ct.addNewBottom();
@@ -840,6 +876,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
      */
+    @Override
     public void setBorderLeft(short border) {
         CTBorder ct = getCTBorder();
         CTBorderPr pr = ct.isSetLeft() ? ct.getLeft() : ct.addNewLeft();
@@ -880,7 +917,8 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
      */
-   public void setBorderRight(short border) {
+   @Override
+public void setBorderRight(short border) {
         CTBorder ct = getCTBorder();
         CTBorderPr pr = ct.isSetRight() ? ct.getRight() : ct.addNewRight();
         if(border == BORDER_NONE) ct.unsetRight();
@@ -920,7 +958,8 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
      * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
      */
-   public void setBorderTop(short border) {
+   @Override
+public void setBorderTop(short border) {
         CTBorder ct = getCTBorder();
         CTBorderPr pr = ct.isSetTop() ? ct.getTop() : ct.addNewTop();
         if(border == BORDER_NONE) ct.unsetTop();
@@ -946,6 +985,7 @@ public class XSSFCellStyle implements CellStyle {
      * @param color the index of the color definition
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public void setBottomBorderColor(short color) {
         XSSFColor clr = new XSSFColor();
         clr.setIndexed(color);
@@ -976,6 +1016,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @param fmt the index of a data format
      */
+    @Override
     public void setDataFormat(short fmt) {
         // XSSF supports >32,767 formats
         setDataFormat(fmt&0xffff);
@@ -1054,6 +1095,7 @@ public class XSSFCellStyle implements CellStyle {
      * @param bg - the color to use
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public void setFillBackgroundColor(short bg) {
         XSSFColor clr = new XSSFColor();
         clr.setIndexed(bg);
@@ -1088,6 +1130,7 @@ public class XSSFCellStyle implements CellStyle {
      * @param fg the color to use
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public void setFillForegroundColor(short fg) {
         XSSFColor clr = new XSSFColor();
         clr.setIndexed(fg);
@@ -1153,7 +1196,8 @@ public class XSSFCellStyle implements CellStyle {
      * @see #setFillForegroundColor(short)
      * @param fp  fill pattern (set to {@link org.apache.poi.ss.usermodel.CellStyle#SOLID_FOREGROUND} to fill w/foreground color)
      */
-   public void setFillPattern(short fp) {
+   @Override
+public void setFillPattern(short fp) {
         CTFill ct = getCTFill();
         CTPatternFill ptrn = ct.isSetPatternFill() ? ct.getPatternFill() : ct.addNewPatternFill();
         if(fp == NO_FILL && ptrn.isSetPatternType()) ptrn.unsetPatternType();
@@ -1182,6 +1226,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.xssf.usermodel.XSSFWorkbook#createFont()
      * @see org.apache.poi.xssf.usermodel.XSSFWorkbook#getFontAt(short)
      */
+    @Override
     public void setFont(Font font) {
         if(font != null){
             long index = font.getIndex();
@@ -1197,6 +1242,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @param hidden - whether the cell using this style should be hidden
      */
+    @Override
     public void setHidden(boolean hidden) {
         if (!_cellXf.isSetProtection()) {
              _cellXf.addNewProtection();
@@ -1209,6 +1255,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @param indent - number of spaces
      */
+    @Override
     public void setIndention(short indent) {
         getCellAlignment().setIndent(indent);
     }
@@ -1219,6 +1266,7 @@ public class XSSFCellStyle implements CellStyle {
      * @param color the index of the color definition
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public void setLeftBorderColor(short color) {
         XSSFColor clr = new XSSFColor();
         clr.setIndexed(color);
@@ -1249,6 +1297,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @param locked -  whether the cell using this style should be locked
      */
+    @Override
     public void setLocked(boolean locked) {
         if (!_cellXf.isSetProtection()) {
              _cellXf.addNewProtection();
@@ -1262,6 +1311,7 @@ public class XSSFCellStyle implements CellStyle {
      * @param color the index of the color definition
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public void setRightBorderColor(short color) {
         XSSFColor clr = new XSSFColor();
         clr.setIndexed(color);
@@ -1301,6 +1351,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @param rotation - the rotation degrees (between 0 and 180 degrees)
      */
+    @Override
     public void setRotation(short rotation) {
         getCellAlignment().setTextRotation(rotation);
     }
@@ -1312,6 +1363,7 @@ public class XSSFCellStyle implements CellStyle {
      * @param color the index of the color definition
      * @see org.apache.poi.ss.usermodel.IndexedColors
      */
+    @Override
     public void setTopBorderColor(short color) {
         XSSFColor clr = new XSSFColor();
         clr.setIndexed(color);
@@ -1347,6 +1399,7 @@ public class XSSFCellStyle implements CellStyle {
      * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_JUSTIFY
      * @see org.apache.poi.ss.usermodel.VerticalAlignment
      */
+    @Override
     public void setVerticalAlignment(short align) {
         getCellAlignment().setVertical(VerticalAlignment.values()[align]);
     }
@@ -1369,6 +1422,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @param wrapped a boolean value indicating if the text in a cell should be line-wrapped within the cell.
      */
+    @Override
     public void setWrapText(boolean wrapped) {
         getCellAlignment().setWrapText(wrapped);
     }
@@ -1416,7 +1470,8 @@ public class XSSFCellStyle implements CellStyle {
                 break;
         }
     }
-    
+
+    @Override
     public void setShrinkToFit(boolean shrinkToFit) {
         getCellAlignment().setShrinkToFit(shrinkToFit);
     }
@@ -1456,6 +1511,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @return the hash code value for this style
      */
+    @Override
     public int hashCode(){
         return _cellXf.toString().hashCode();
     }
@@ -1466,6 +1522,7 @@ public class XSSFCellStyle implements CellStyle {
      * @param o the style to check
      * @return true if the supplied style is equal to this style
      */
+    @Override
     public boolean equals(Object o){
         if(o == null || !(o instanceof XSSFCellStyle)) return false;
 
@@ -1479,6 +1536,7 @@ public class XSSFCellStyle implements CellStyle {
      *
      * @return a copy of this style
      */
+    @Override
     public Object clone(){
         CTXf xf = (CTXf)_cellXf.copy();
 
index 78e6bee9c14b537f8ade67445c6c534e91448e42..41d1a340f0c93f2f3f8d3f2f16d79d5abe1e6c3c 100644 (file)
 
 package org.apache.poi.poifs.filesystem;
 
-import java.io.*;
-
-import java.util.*;
-
-import junit.framework.*;
+import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Iterator;
 
 import org.apache.poi.poifs.property.DirectoryProperty;
 import org.apache.poi.poifs.property.DocumentProperty;
 
+import junit.framework.TestCase;
+
 /**
  * Class to test DirectoryNode functionality
  *
@@ -51,7 +52,7 @@ public final class TestDirectoryNode extends TestCase {
 
         // verify that getEntries behaves correctly
         int      count = 0;
-        Iterator iter  = node.getEntries();
+        Iterator<Entry> iter  = node.getEntries();
 
         while (iter.hasNext())
         {
@@ -106,7 +107,7 @@ public final class TestDirectoryNode extends TestCase {
 
         // verify that getEntries behaves correctly
         int           count = 0;
-        Iterator      iter  = node.getEntries();
+        Iterator<Entry>      iter  = node.getEntries();
 
         while (iter.hasNext())
         {
@@ -160,7 +161,7 @@ public final class TestDirectoryNode extends TestCase {
         // verify cannot delete the root directory
         assertFalse(root.delete());
         assertTrue(root.isEmpty());
-        
+
         DirectoryEntry dir = fs.createDirectory("myDir");
 
         assertFalse(root.isEmpty());
@@ -169,7 +170,7 @@ public final class TestDirectoryNode extends TestCase {
         // verify can delete empty directory
         assertFalse(root.delete());
         assertTrue(dir.delete());
-        
+
         // Now look at a non-empty one
         dir = fs.createDirectory("NextDir");
         DocumentEntry doc =
@@ -181,14 +182,16 @@ public final class TestDirectoryNode extends TestCase {
 
         // verify cannot delete non-empty directory
         assertFalse(dir.delete());
-        
+
         // but we can delete it if we remove the document
         assertTrue(doc.delete());
         assertTrue(dir.isEmpty());
         assertTrue(dir.delete());
-        
+
         // It's really gone!
         assertTrue(root.isEmpty());
+
+        fs.close();
     }
 
     /**
@@ -211,5 +214,7 @@ public final class TestDirectoryNode extends TestCase {
         assertTrue(dir.renameTo("FirstDir"));
         assertTrue(dir2.renameTo("foo"));
         assertEquals("foo", dir2.getName());
+
+        fs.close();
     }
 }