langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndexCache.java
changeset 22163 3651128c74eb
parent 22159 682da512ec17
equal deleted inserted replaced
22162:3b3e23e67329 22163:3651128c74eb
    37 
    37 
    38 
    38 
    39 /** A cache for ZipFileIndex objects. */
    39 /** A cache for ZipFileIndex objects. */
    40 public class ZipFileIndexCache {
    40 public class ZipFileIndexCache {
    41 
    41 
    42     private final Map<File, ZipFileIndex> map =
    42     private final Map<File, ZipFileIndex> map = new HashMap<>();
    43             new HashMap<File, ZipFileIndex>();
       
    44 
    43 
    45     /** Get a shared instance of the cache. */
    44     /** Get a shared instance of the cache. */
    46     private static ZipFileIndexCache sharedInstance;
    45     private static ZipFileIndexCache sharedInstance;
    47     public synchronized static ZipFileIndexCache getSharedInstance() {
    46     public synchronized static ZipFileIndexCache getSharedInstance() {
    48         if (sharedInstance == null)
    47         if (sharedInstance == null)
    73      * @param openedOnly If true it returns a list of only opened ZipFileIndex entries, otherwise
    72      * @param openedOnly If true it returns a list of only opened ZipFileIndex entries, otherwise
    74      *                   all ZipFileEntry(s) are included into the list.
    73      *                   all ZipFileEntry(s) are included into the list.
    75      * @return A list of ZipFileIndex entries, or an empty list
    74      * @return A list of ZipFileIndex entries, or an empty list
    76      */
    75      */
    77     public synchronized List<ZipFileIndex> getZipFileIndexes(boolean openedOnly) {
    76     public synchronized List<ZipFileIndex> getZipFileIndexes(boolean openedOnly) {
    78         List<ZipFileIndex> zipFileIndexes = new ArrayList<ZipFileIndex>();
    77         List<ZipFileIndex> zipFileIndexes = new ArrayList<>();
    79 
    78 
    80         zipFileIndexes.addAll(map.values());
    79         zipFileIndexes.addAll(map.values());
    81 
    80 
    82         if (openedOnly) {
    81         if (openedOnly) {
    83             for(ZipFileIndex elem : zipFileIndexes) {
    82             for(ZipFileIndex elem : zipFileIndexes) {