Ignore:
Timestamp:
2014-06-14T12:40:50+02:00 (10 years ago)
Author:
bastiK
Message:

reworked MirroredInputStream (renamed to CachedFile):

  • no more awkwardly open and close InputStream if you just want the underlying file (e.g. to get file inside zip file)
  • make it easier to add configuration parameters, without having endless list of parameters for the constructor (Factory style, similar to ImageProvider)

breaks plugins; see #10139

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r7200 r7248  
    4242import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.TokenMgrError;
    4343import org.openstreetmap.josm.gui.preferences.SourceEntry;
    44 import org.openstreetmap.josm.io.MirroredInputStream;
     44import org.openstreetmap.josm.io.CachedFile;
    4545import org.openstreetmap.josm.tools.CheckParameterUtil;
    4646import org.openstreetmap.josm.tools.LanguageInfo;
     
    275275            return new ByteArrayInputStream(css.getBytes(StandardCharsets.UTF_8));
    276276        }
    277         MirroredInputStream in = getMirroredInputStream();
     277        CachedFile cf = getCachedFile();
    278278        if (isZip) {
    279             File file = in.getFile();
    280             Utils.close(in);
     279            File file = cf.getFile();
    281280            zipFile = new ZipFile(file, StandardCharsets.UTF_8);
    282281            zipIcons = file;
     
    286285            zipFile = null;
    287286            zipIcons = null;
    288             return in;
    289         }
    290     }
    291 
    292     @Override
    293     public MirroredInputStream getMirroredInputStream() throws IOException {
    294         return new MirroredInputStream(url, null, MAPCSS_STYLE_MIME_TYPES);
     287            return cf.getInputStream();
     288        }
     289    }
     290
     291    @Override
     292    public CachedFile getCachedFile() throws IOException {
     293        return new CachedFile(url).setHttpAccept(MAPCSS_STYLE_MIME_TYPES);
    295294    }
    296295
Note: See TracChangeset for help on using the changeset viewer.