Changeset 8851 in josm for trunk


Ignore:
Timestamp:
2015-10-10T15:47:41+02:00 (9 years ago)
Author:
Don-vip
Message:

sonar - squid:S1149 - Synchronized classes Vector, Hashtable, Stack and StringBuffer should not be used

Location:
trunk/src/org/openstreetmap/josm
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r8846 r8851  
    88import java.awt.event.ActionEvent;
    99import java.awt.event.KeyEvent;
     10import java.util.ArrayDeque;
    1011import java.util.ArrayList;
    1112import java.util.Collection;
    1213import java.util.Collections;
     14import java.util.Deque;
    1315import java.util.LinkedHashMap;
    1416import java.util.LinkedHashSet;
     
    1719import java.util.Map;
    1820import java.util.Set;
    19 import java.util.Stack;
    2021
    2122import javax.swing.JOptionPane;
     
    557558        }
    558559
    559         protected Set<Node> getNodes(Stack<NodePair> pairs) {
    560             Set<Node> nodes = new LinkedHashSet<>(2*pairs.size());
    561             for (NodePair pair: pairs) {
    562                 nodes.add(pair.getA());
    563                 nodes.add(pair.getB());
    564             }
    565             return nodes;
    566         }
    567 
    568560        protected List<NodePair> getOutboundPairs(NodePair pair) {
    569561            return getOutboundPairs(pair.getB());
     
    586578        }
    587579
    588         protected boolean isSpanningWay(Stack<NodePair> way) {
     580        protected boolean isSpanningWay(Deque<NodePair> way) {
    589581            return numUndirectedEges == way.size();
    590582        }
    591583
    592         protected List<Node> buildPathFromNodePairs(Stack<NodePair> path) {
     584        protected List<Node> buildPathFromNodePairs(Deque<NodePair> path) {
    593585            List<Node> ret = new LinkedList<>();
    594586            for (NodePair pair: path) {
     
    610602            if (startNode == null)
    611603                return null;
    612             Stack<NodePair> path = new Stack<>();
    613             Stack<NodePair> nextPairs  = new Stack<>();
     604            Deque<NodePair> path = new ArrayDeque<>();
     605            Deque<NodePair> nextPairs  = new ArrayDeque<>();
    614606            nextPairs.addAll(getOutboundPairs(startNode));
    615607            while (!nextPairs.isEmpty()) {
  • trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java

    r8836 r8851  
    88import java.awt.event.KeyEvent;
    99import java.io.IOException;
     10import java.util.ArrayDeque;
    1011import java.util.Collection;
     12import java.util.Deque;
    1113import java.util.HashSet;
    1214import java.util.Set;
    13 import java.util.Stack;
    1415
    1516import javax.swing.JOptionPane;
     
    321322        protected void realRun() throws SAXException, IOException, OsmTransferException {
    322323            try {
    323                 Stack<OsmPrimitive> toCheck = new Stack<>();
     324                Deque<OsmPrimitive> toCheck = new ArrayDeque<>();
    324325                toCheck.addAll(getPrimitivesToCheckForParents());
    325326                Set<OsmPrimitive> checked = new HashSet<>();
  • trunk/src/org/openstreetmap/josm/actions/upload/CyclicUploadDependencyException.java

    r8510 r8851  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.util.ArrayList;
    7 import java.util.List;
    8 import java.util.Stack;
     6import java.util.ArrayDeque;
     7import java.util.Deque;
    98
    109import org.openstreetmap.josm.data.osm.Relation;
    1110
    1211public class CyclicUploadDependencyException extends Exception {
    13     private final Stack<Relation> cycle;
     12    private final Deque<Relation> cycle;
    1413
    15     public CyclicUploadDependencyException(Stack<Relation> cycle) {
     14    public CyclicUploadDependencyException(Deque<Relation> cycle) {
    1615        this.cycle = cycle;
    1716    }
     
    3433        sb.append(tr("Cyclic dependency between relations:"))
    3534          .append('[');
    36         for (int i = 0; i < cycle.size(); i++) {
    37             if (i > 0) {
     35        for (Relation r : cycle) {
     36            if (sb.length() > 0) {
    3837                sb.append(',');
    3938            }
    40             sb.append(formatRelation(cycle.get(i)));
     39            sb.append(formatRelation(r));
    4140        }
    4241        sb.append(']');
     
    4443    }
    4544
    46     public List<Relation> getCyclicUploadDependency() {
    47         return new ArrayList<>(cycle);
     45    public Deque<Relation> getCyclicUploadDependency() {
     46        return new ArrayDeque<>(cycle);
    4847    }
    4948}
  • trunk/src/org/openstreetmap/josm/actions/upload/RelationUploadOrderHook.java

    r8510 r8851  
    66import java.awt.BorderLayout;
    77import java.awt.Dimension;
     8import java.util.ArrayList;
     9import java.util.Deque;
    810import java.util.Iterator;
    911import java.util.List;
     
    6769     */
    6870    protected void warnCyclicUploadDependency(CyclicUploadDependencyException e) {
    69         List<Relation> dep = e.getCyclicUploadDependency();
    70         Relation last = dep.get(dep.size() -1);
     71        Deque<Relation> dep = e.getCyclicUploadDependency();
     72        Relation last = dep.getLast();
    7173        Iterator<Relation> it = dep.iterator();
    7274        while (it.hasNext()) {
     
    7779            }
    7880        }
    79         JPanel pnl = buildWarningPanel(dep);
     81        JPanel pnl = buildWarningPanel(new ArrayList<>(dep));
    8082        ExtendedDialog dialog = new ExtendedDialog(
    8183                Main.parent,
  • trunk/src/org/openstreetmap/josm/data/APIDataSet.java

    r8836 r8851  
    22package org.openstreetmap.josm.data;
    33
     4import java.util.ArrayDeque;
    45import java.util.ArrayList;
    56import java.util.Collection;
    67import java.util.Collections;
    78import java.util.Comparator;
     9import java.util.Deque;
    810import java.util.HashMap;
    911import java.util.HashSet;
     
    1214import java.util.Map;
    1315import java.util.Set;
    14 import java.util.Stack;
    1516
    1617import org.openstreetmap.josm.actions.upload.CyclicUploadDependencyException;
     
    309310        }
    310311
    311         protected void visit(Stack<Relation> path, Relation current) throws CyclicUploadDependencyException {
     312        protected void visit(Deque<Relation> path, Relation current) throws CyclicUploadDependencyException {
    312313            if (path.contains(current)) {
    313314                path.push(current);
     
    328329            visited = new HashSet<>();
    329330            uploadOrder = new LinkedList<>();
    330             Stack<Relation> path = new Stack<>();
     331            Deque<Relation> path = new ArrayDeque<>();
    331332            for (Relation relation: relations) {
    332333                visit(path, relation);
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r8846 r8851  
    1111import java.nio.charset.StandardCharsets;
    1212import java.text.NumberFormat;
     13import java.util.ArrayDeque;
    1314import java.util.ArrayList;
    1415import java.util.Collection;
    1516import java.util.Collections;
    1617import java.util.Date;
     18import java.util.Deque;
    1719import java.util.HashSet;
    1820import java.util.LinkedList;
     
    2123import java.util.Map.Entry;
    2224import java.util.Set;
    23 import java.util.Stack;
    2425import java.util.TreeMap;
    2526import java.util.concurrent.CopyOnWriteArrayList;
     
    649650    }
    650651
    651     private Stack<ZoomData> zoomUndoBuffer = new Stack<>();
    652     private Stack<ZoomData> zoomRedoBuffer = new Stack<>();
     652    private Deque<ZoomData> zoomUndoBuffer = new ArrayDeque<>();
     653    private Deque<ZoomData> zoomRedoBuffer = new ArrayDeque<>();
    653654    private Date zoomTimestamp = new Date();
    654655
  • trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java

    r8836 r8851  
    99import java.awt.event.KeyEvent;
    1010import java.awt.event.MouseEvent;
     11import java.util.ArrayDeque;
    1112import java.util.ArrayList;
    1213import java.util.Arrays;
    1314import java.util.Collection;
     15import java.util.Deque;
    1416import java.util.HashSet;
    1517import java.util.List;
    1618import java.util.Set;
    17 import java.util.Stack;
    1819
    1920import javax.swing.AbstractAction;
     
    291292        // Filters can use nested parent/child expression so complete tree is necessary
    292293        Set<OsmPrimitive> result = new HashSet<>();
    293         Stack<OsmPrimitive> stack = new Stack<>();
     294        Deque<OsmPrimitive> stack = new ArrayDeque<>();
    294295        stack.addAll(primitives);
    295296
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java

    r8836 r8851  
    1212import java.io.IOException;
    1313import java.net.HttpURLConnection;
     14import java.util.ArrayDeque;
     15import java.util.Deque;
    1416import java.util.HashSet;
    1517import java.util.Iterator;
    1618import java.util.List;
    1719import java.util.Set;
    18 import java.util.Stack;
    1920
    2021import javax.swing.AbstractAction;
     
    329330    class DownloadAllChildrenTask extends DownloadTask {
    330331        private final Relation relation;
    331         private final Stack<Relation> relationsToDownload;
     332        private final Deque<Relation> relationsToDownload;
    332333        private final Set<Long> downloadedRelationIds;
    333334
     
    335336            super(tr("Download relation members"), parent);
    336337            this.relation = r;
    337             relationsToDownload = new Stack<>();
     338            relationsToDownload = new ArrayDeque<>();
    338339            downloadedRelationIds = new HashSet<>();
    339340            relationsToDownload.push(this.relation);
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r8840 r8851  
    199199    private static class NameFinderResultParser extends DefaultHandler {
    200200        private SearchResult currentResult;
    201         private StringBuffer description;
     201        private StringBuilder description;
    202202        private int depth;
    203203        private List<SearchResult> data = new LinkedList<>();
     
    226226                    data.add(currentResult);
    227227                } else if ("description".equals(qName) && (depth == 3)) {
    228                     description = new StringBuffer();
     228                    description = new StringBuilder();
    229229                } else if ("named".equals(qName) && (depth == 4)) {
    230230                    // this is a "named" place in the nearest places list.
  • trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java

    r8846 r8851  
    2626import java.text.AttributedString;
    2727import java.util.ArrayList;
    28 import java.util.Hashtable;
     28import java.util.HashMap;
    2929import java.util.List;
    3030import java.util.Map;
     
    405405            } else {
    406406                // Draw message on several lines
    407                 Map<TextAttribute, Object> map = new Hashtable<TextAttribute, Object>();
     407                Map<TextAttribute, Object> map = new HashMap<TextAttribute, Object>();
    408408                map.put(TextAttribute.FAMILY, "Serif");
    409409                map.put(TextAttribute.SIZE, new Float(18.0));
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r8602 r8851  
    118118    @Override
    119119    public String nameSupportedProjections() {
    120         StringBuffer ret = new StringBuffer();
     120        StringBuilder ret = new StringBuilder();
    121121        for (String e: supportedProjections) {
    122122            ret.append(e).append(", ");
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r8846 r8851  
    77import java.io.InputStream;
    88import java.io.Reader;
     9import java.util.ArrayDeque;
    910import java.util.ArrayList;
    1011import java.util.Collection;
     12import java.util.Deque;
    1113import java.util.HashMap;
    1214import java.util.LinkedList;
    1315import java.util.List;
    1416import java.util.Map;
    15 import java.util.Stack;
    1617
    1718import javax.xml.parsers.ParserConfigurationException;
     
    6465        private GpxLink currentLink;
    6566        private Extensions currentExtensions;
    66         private Stack<State> states;
    67         private final Stack<String> elements = new Stack<>();
    68 
    69         private StringBuffer accumulator = new StringBuffer();
     67        private Deque<State> states;
     68        private final Deque<String> elements = new ArrayDeque<>();
     69
     70        private StringBuilder accumulator = new StringBuilder();
    7071
    7172        private boolean nokiaSportsTrackerBug;
     
    7374        @Override
    7475        public void startDocument() {
    75             accumulator = new StringBuffer();
    76             states = new Stack<>();
     76            accumulator = new StringBuilder();
     77            states = new ArrayDeque<>();
    7778            data = new GpxData();
    7879        }
     
    476477        @Override
    477478        public void endDocument() throws SAXException  {
    478             if (!states.empty())
     479            if (!states.isEmpty())
    479480                throw new SAXException(tr("Parse error: invalid document structure for GPX document."));
    480481            Extensions metaExt = (Extensions) data.get(META_EXTENSIONS);
  • trunk/src/org/openstreetmap/josm/io/NoteReader.java

    r8510 r8851  
    4949
    5050        private NoteParseMode parseMode;
    51         private StringBuffer buffer = new StringBuffer();
     51        private StringBuilder buffer = new StringBuilder();
    5252        private Note thisNote;
    5353        private long commentUid;
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r8846 r8851  
    44import java.io.IOException;
    55import java.io.InputStream;
     6import java.util.ArrayDeque;
    67import java.util.ArrayList;
    78import java.util.Arrays;
     9import java.util.Deque;
    810import java.util.HashMap;
    911import java.util.List;
    1012import java.util.Map;
    1113import java.util.Objects;
    12 import java.util.Stack;
    1314
    1415import javax.xml.parsers.ParserConfigurationException;
     
    7071
    7172    private static class Parser extends DefaultHandler {
    72         private StringBuffer accumulator = new StringBuffer();
    73 
    74         private Stack<State> states;
     73        private StringBuilder accumulator = new StringBuilder();
     74
     75        private Deque<State> states;
    7576
    7677        private List<ImageryInfo> entries;
     
    9394        @Override
    9495        public void startDocument() {
    95             accumulator = new StringBuffer();
     96            accumulator = new StringBuilder();
    9697            skipEntry = false;
    97             states = new Stack<>();
     98            states = new ArrayDeque<>();
    9899            states.push(State.INIT);
    99100            entries = new ArrayList<>();
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r8846 r8851  
    1010import java.lang.reflect.Method;
    1111import java.lang.reflect.Modifier;
     12import java.util.ArrayDeque;
     13import java.util.Deque;
    1214import java.util.HashMap;
    1315import java.util.Iterator;
     
    1618import java.util.Locale;
    1719import java.util.Map;
    18 import java.util.Stack;
    1920
    2021import javax.xml.XMLConstants;
     
    6465
    6566    private class Parser extends DefaultHandler {
    66         private Stack<Object> current = new Stack<>();
     67        private Deque<Object> current = new ArrayDeque<>();
    6768        private StringBuilder characters = new StringBuilder(64);
    6869
Note: See TracChangeset for help on using the changeset viewer.