Changeset 30566 in osm for applications


Ignore:
Timestamp:
2014-08-06T09:53:24+02:00 (10 years ago)
Author:
donvip
Message:

[josm_opendata] fix warnings, robustness

Location:
applications/editors/josm/plugins/opendata/src/org
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/src/org/geotools/data/shapefile/files/TabFiles.java

    r30310 r30566  
    5757     * key is the type of file
    5858     */
    59     private final Map<ShpFileType, URL> urls = new ConcurrentHashMap<ShpFileType, URL>();
     59    private final Map<ShpFileType, URL> urls = new ConcurrentHashMap<>();
    6060
    6161    /**
     
    6868     * the locks
    6969     */
    70     private final Map<Thread, Collection<ShpFilesLocker>> lockers = new ConcurrentHashMap<Thread, Collection<ShpFilesLocker>>();
     70    private final Map<Thread, Collection<ShpFilesLocker>> lockers = new ConcurrentHashMap<>();
    7171
    7272    /**
     
    144144        if (isLocalTab()) {
    145145            Set<Entry<ShpFileType, URL>> entries = urls.entrySet();
    146             Map<ShpFileType, URL> toUpdate = new HashMap<ShpFileType, URL>();
     146            Map<ShpFileType, URL> toUpdate = new HashMap<>();
    147147            for (Entry<ShpFileType, URL> entry : entries) {
    148148                if( !existsTab(entry.getKey()) ){
     
    222222     */
    223223    public Map<ShpFileType, String> getFileNames() {
    224         Map<ShpFileType, String> result = new HashMap<ShpFileType, String>();
     224        Map<ShpFileType, String> result = new HashMap<>();
    225225        Set<Entry<ShpFileType, URL>> entries = urls.entrySet();
    226226
     
    342342        URL url = urls.get(type);
    343343        if (url == null) {
    344             return new Result<URL, State>(null, State.NOT_EXIST);
     344            return new Result<>(null, State.NOT_EXIST);
    345345        }
    346346       
    347347        boolean locked = readWriteLock.readLock().tryLock();
    348348        if (!locked) {
    349             return new Result<URL, State>(null, State.LOCKED);
     349            return new Result<>(null, State.LOCKED);
    350350        }
    351351       
    352352        getCurrentThreadLockers().add(new ShpFilesLocker(url, requestor));
    353353
    354         return new Result<URL, State>(url, State.GOOD);
     354        return new Result<>(url, State.GOOD);
    355355    }
    356356
     
    390390        }
    391391
    392         Collection threadLockers = getCurrentThreadLockers();
     392        Collection<ShpFilesLocker> threadLockers = getCurrentThreadLockers();
    393393        boolean removed = threadLockers.remove(new ShpFilesLocker(url, requestor));
    394394        if (!removed) {
     
    489489        URL url = urls.get(type);
    490490        if (url == null) {
    491             return new Result<URL, State>(null, State.NOT_EXIST);
     491            return new Result<>(null, State.NOT_EXIST);
    492492        }
    493493
     
    500500            if(locked == false) {
    501501                regainReadLocks(threadLockers);
    502                 return new Result<URL, State>(null, State.LOCKED);
     502                return new Result<>(null, State.LOCKED);
    503503            }
    504504        }
    505505
    506506        threadLockers.add(new ShpFilesLocker(url, requestor));
    507         return new Result<URL, State>(url, State.GOOD);
     507        return new Result<>(url, State.GOOD);
    508508    }
    509509
     
    568568        Collection<ShpFilesLocker> threadLockers = lockers.get(Thread.currentThread());
    569569        if(threadLockers == null) {
    570             threadLockers = new ArrayList<ShpFilesLocker>();
     570            threadLockers = new ArrayList<>();
    571571            lockers.put(Thread.currentThread(), threadLockers);
    572572        }
     
    771771                File file = DataUtilities.urlToFile(url);
    772772               
     773                @SuppressWarnings("resource")
    773774                RandomAccessFile raf = new RandomAccessFile(file, "r");
    774775                channel = new FileChannelDecorator(raf.getChannel(), this, url,
     
    828829                File file = DataUtilities.urlToFile(url);
    829830
     831                @SuppressWarnings("resource")
    830832                RandomAccessFile raf = new RandomAccessFile(file, "rw");
    831833                channel = new FileChannelDecorator(raf.getChannel(), this, url,
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReader.java

    r30532 r30566  
    55
    66import java.awt.Component;
     7import java.awt.GraphicsEnvironment;
    78import java.io.BufferedReader;
    89import java.io.File;
     
    8990                        if (desc != null && desc.getCoordinateReferenceSystem() != null) {
    9091                                crs = desc.getCoordinateReferenceSystem();
    91                         } else {
     92                        } else if (!GraphicsEnvironment.isHeadless()) {
    9293                            GuiHelper.runInEDTAndWait(new Runnable() {
    9394                        @Override
Note: See TracChangeset for help on using the changeset viewer.