Ignore:
Timestamp:
2016-06-01T00:55:28+02:00 (9 years ago)
Author:
donvip
Message:

sonar - fix many issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java

    r32060 r32211  
    1414import java.net.MalformedURLException;
    1515import java.net.URL;
     16import java.nio.charset.StandardCharsets;
    1617import java.util.ArrayList;
    1718import java.util.Collection;
     
    4344    private WMSLayer wmsLayer;
    4445    private CadastreInterface wmsInterface;
    45     private String svg = null;
    46     private EastNorthBound viewBox = null;
     46    private String svg;
     47    private EastNorthBound viewBox;
    4748    private static String errorMessage;
    4849
     
    8889    @Override
    8990    protected void finish() {
     91        // Do nothing
    9092    }
    9193
     
    168170    private String grabBoundary(EastNorthBound bbox) throws IOException, OsmTransferException {
    169171        try {
    170             URL url = null;
    171             url = getURLsvg(bbox);
    172             return grabSVG(url);
     172            return grabSVG(getURLsvg(bbox));
    173173        } catch (MalformedURLException e) {
    174174            throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e);
     
    176176    }
    177177
    178     private URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {
    179         String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
     178    private static URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {
     179        String str = CadastreInterface.BASE_URL+"/scpc/wms?version=1.1&request=GetMap";
    180180        str += "&layers=";
    181181        str += "CDIF:COMMUNE";
     
    198198        wmsInterface.setCookie();
    199199        File file = new File(CadastrePlugin.cacheDir + "boundary.svg");
    200         String svg = new String();
     200        String svg = "";
    201201        try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {
    202202            if (file.exists())
     
    205205                 InputStreamReader isr =new InputStreamReader(is);
    206206                 BufferedReader br = new BufferedReader(isr)) {
    207                 String line="";
     207                String line;
    208208                while ( null!=(line=br.readLine())){
    209209                    line += "\n";
    210                     bos.write(line.getBytes());
     210                    bos.write(line.getBytes(StandardCharsets.UTF_8));
    211211                    svg += line;
    212212                }
     
    219219
    220220    public static void download(WMSLayer wmsLayer) {
    221         if (CadastrePlugin.autoSourcing == false) {
     221        if (!CadastrePlugin.autoSourcing) {
    222222            JOptionPane.showMessageDialog(Main.parent,
    223223                    tr("Please, enable auto-sourcing and check cadastre millesime."));
     
    228228            JOptionPane.showMessageDialog(Main.parent, errorMessage);
    229229    }
    230 
    231230}
Note: See TracChangeset for help on using the changeset viewer.