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/xml/XmlStyleSource.java

    r7083 r7248  
    2929import org.openstreetmap.josm.gui.mappaint.StyleSource;
    3030import org.openstreetmap.josm.gui.preferences.SourceEntry;
    31 import org.openstreetmap.josm.io.MirroredInputStream;
     31import org.openstreetmap.josm.io.CachedFile;
    3232import org.openstreetmap.josm.tools.Utils;
    3333import org.openstreetmap.josm.tools.XmlObjectParser;
     
    104104    @Override
    105105    public InputStream getSourceInputStream() throws IOException {
    106         MirroredInputStream in = getMirroredInputStream();
    107         InputStream zip = in.findZipEntryInputStream("xml", "style");
     106        CachedFile cf = getCachedFile();
     107        InputStream zip = cf.findZipEntryInputStream("xml", "style");
    108108        if (zip != null) {
    109             zipIcons = in.getFile();
     109            zipIcons = cf.getFile();
    110110            return zip;
    111111        } else {
    112112            zipIcons = null;
    113             return in;
    114         }
    115     }
    116 
    117     @Override
    118     public MirroredInputStream getMirroredInputStream() throws IOException {
    119         return new MirroredInputStream(url, null, XML_STYLE_MIME_TYPES);
     113            return cf.getInputStream();
     114        }
     115    }
     116
     117    @Override
     118    public CachedFile getCachedFile() throws IOException {
     119        return new CachedFile(url).setHttpAccept(XML_STYLE_MIME_TYPES);
    120120    }
    121121
Note: See TracChangeset for help on using the changeset viewer.