From: Javen O'Neal Date: Sat, 11 Jun 2016 03:05:31 +0000 (+0000) Subject: methods that return lists should return unmodifiable lists; use foreach sheet iterato... X-Git-Tag: REL_3_15_BETA2~153 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=110c405135035e98983a4416d5b2ae5b1281ef49;p=poi.git methods that return lists should return unmodifiable lists; use foreach sheet iterator when sheet index is not needed git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1747843 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index 9844b98c51..c10e4edae1 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -38,6 +38,7 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.regex.Pattern; +import java.util.Collections; import org.apache.commons.codec.digest.DigestUtils; import org.apache.poi.EncryptedDocumentException; @@ -1475,7 +1476,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss } } - return nameList; + return Collections.unmodifiableList(nameList); } @Override @@ -1721,8 +1722,8 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss void initDrawings(){ DrawingManager2 mgr = workbook.findDrawingGroup(); if(mgr != null) { - for(int i=0; i < getNumberOfSheets(); i++) { - getSheetAt(i).getDrawingPatriarch(); + for(HSSFSheet sh : _sheets) { + sh.getDrawingPatriarch(); } } else { workbook.createDrawingGroup(); @@ -1840,7 +1841,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss searchForPictures(escherRecords, pictures); } } - return pictures; + return Collections.unmodifiableList(pictures); } /** @@ -1976,11 +1977,11 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss public List getAllEmbeddedObjects() { List objects = new ArrayList(); - for (int i = 0; i < getNumberOfSheets(); i++) + for (HSSFSheet sheet : _sheets) { - getAllEmbeddedObjects(getSheetAt(i), objects); + getAllEmbeddedObjects(sheet, objects); } - return objects; + return Collections.unmodifiableList(objects); } /**