Changeset 6494 in josm


Ignore:
Timestamp:
2013-12-18T19:13:16+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #9430, fix #9445 - fix validator tests lifecycle

Location:
trunk/src/org/openstreetmap/josm/data/validation/tests
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/BuildingInBuilding.java

    r6240 r6494  
    188188            }
    189189        }
     190       
     191        primitivesToCheck.clear();
     192        index.clear();
    190193
    191194        super.endTest();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DeprecatedTags.java

    r6466 r6494  
    3030public class DeprecatedTags extends Test {
    3131
    32     private List<DeprecationCheck> checks = new LinkedList<DeprecationCheck>();
     32    private final List<DeprecationCheck> checks = new LinkedList<DeprecationCheck>();
    3333
    3434    /**
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java

    r6240 r6494  
    172172
    173173    /** List of keys without useful information */
    174     private Collection<String> ignoreKeys = new HashSet<String>(OsmPrimitive.getUninterestingKeys());
     174    private final Set<String> ignoreKeys = new HashSet<String>(OsmPrimitive.getUninterestingKeys());
    175175
    176176    /**
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java

    r6240 r6494  
    122122        }
    123123
    124         for(Set<OsmPrimitive> sameway : waysNoTags.values()) {
    125             if( sameway.size() > 1) {
     124        for (Set<OsmPrimitive> sameway : waysNoTags.values()) {
     125            if (sameway.size() > 1) {
    126126                //Report error only if at least some tags are different, as otherwise the error was already reported as duplicated ways
    127127                Map<String, String> tags0=null;
    128128                boolean skip=true;
    129129
    130                 for(OsmPrimitive o : sameway) {
     130                for (OsmPrimitive o : sameway) {
    131131                    if (tags0==null) {
    132132                        tags0=o.getKeys();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r6390 r6494  
    8080        }
    8181    }
     82   
     83    @Override
     84    public void endTest() {
     85        keysCheckedByAnotherTest.clear();
     86        super.endTest();
     87    }
    8288
    8389    private List<List<Node>> joinWays(Collection<Way> ways) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/NameMismatch.java

    r6240 r6494  
    106106     * @param selection The primitives to be tested
    107107     */
    108     @Override public void visit(Collection<OsmPrimitive> selection) {
    109         for (OsmPrimitive p : selection)
     108    @Override
     109    public void visit(Collection<OsmPrimitive> selection) {
     110        for (OsmPrimitive p : selection) {
    110111            if (!p.isDeleted() && !p.isIncomplete()) {
    111112                check(p);
    112113            }
     114        }
    113115    }
    114116}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/NodesWithSameName.java

    r6241 r6494  
    3333    }
    3434
    35     @Override public void startTest(ProgressMonitor monitor) {
     35    @Override
     36    public void startTest(ProgressMonitor monitor) {
    3637        super.startTest(monitor);
    3738        namesToNodes = new HashMap<String, List<Node>>();
    3839    }
    3940
    40     @Override public void visit(Node n) {
     41    @Override
     42    public void visit(Node n) {
    4143        if (!n.isUsable()) return;
    4244
     
    5557    }
    5658
    57     @Override public void endTest() {
     59    @Override
     60    public void endTest() {
    5861        for (List<Node> nodes : namesToNodes.values()) {
    5962            if (nodes.size() > 1) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java

    r6488 r6494  
    102102    }
    103103
     104    /**
     105     * An error concerning invalid syntax for an "opening_hours"-like tag.
     106     */
    104107    public class OpeningHoursTestError {
    105108        final Severity severity;
    106109        final String message, prettifiedValue;
    107110
     111        /**
     112         * Constructs a new {@code OpeningHoursTestError} with a known pretiffied value.
     113         * @param message The error message
     114         * @param severity The error severity
     115         * @param prettifiedValue The prettified value
     116         */
    108117        public OpeningHoursTestError(String message, Severity severity, String prettifiedValue) {
    109118            this.message = message;
     
    112121        }
    113122
     123        /**
     124         * Constructs a new {@code OpeningHoursTestError}.
     125         * @param message The error message
     126         * @param severity The error severity
     127         */
    114128        public OpeningHoursTestError(String message, Severity severity) {
    115129            this(message, severity, null);
    116130        }
    117131
     132        /**
     133         * Returns the real test error given to JOSM validator.
     134         * @param p The incriminated OSM primitive.
     135         * @param key The incriminated key, used for display.
     136         * @return The real test error given to JOSM validator. Can be fixable or not if a prettified values has been determined.
     137         */
    118138        public TestError getTestError(final OsmPrimitive p, final String key) {
    119139            if (prettifiedValue == null) {
     
    125145        }
    126146
     147        /**
     148         * Returns the error message.
     149         * @return The error message.
     150         */
    127151        public String getMessage() {
    128152            return message;
    129153        }
    130154
     155        /**
     156         * Returns the prettified value.
     157         * @return The prettified value.
     158         */
    131159        public String getPrettifiedValue() {
    132160            return prettifiedValue;
    133161        }
    134162
     163        /**
     164         * Returns the error severity.
     165         * @return The error severity.
     166         */
    135167        public Severity getSeverity() {
    136168            return severity;
     
    172204    }
    173205
     206    /**
     207     * Checks for a correct usage of the opening hour syntax of the {@code value} given, in time range mode, according to
     208     * <a href="https://github.com/ypid/opening_hours.js">opening_hours.js</a> and returns a list containing
     209     * validation errors or an empty list. Null values result in an empty list.
     210     * @param key the OSM key (should be "opening_hours", "collection_times" or "service_times"). Used in error message
     211     * @param value the opening hour value to be checked.
     212     * @return a list of {@link TestError} or an empty list
     213     */
    174214    public List<OpeningHoursTestError> checkOpeningHourSyntax(final String key, final String value) {
    175215        return checkOpeningHourSyntax(key, value, CheckMode.TIME_RANGE);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingAreas.java

    r6241 r6494  
    2525
    2626    protected static final int OVERLAPPING_AREAS = 2201;
    27     protected QuadBuckets<Way> index = new QuadBuckets<Way>();
     27    protected final QuadBuckets<Way> index = new QuadBuckets<Way>();
    2828
    2929    /**
     
    9393            }
    9494        }
     95       
     96        index.clear();
    9597
    9698        super.endTest();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java

    r6491 r6494  
    6464    }
    6565
    66     @SuppressWarnings("null")
    6766    @Override
    6867    public void endTest() {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java

    r6475 r6494  
    2525import org.openstreetmap.josm.data.validation.Test;
    2626import org.openstreetmap.josm.data.validation.TestError;
     27import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2728import org.openstreetmap.josm.tools.Geometry;
    2829
     
    9697
    9798    @Override
     99    public void startTest(ProgressMonitor progressMonitor) {
     100        super.startTest(progressMonitor);
     101        towerPoleTagMap.clear();
     102        powerStations.clear();
     103        potentialErrors.clear();
     104    }
     105
     106    @Override
    98107    public void endTest() {
    99108        for (PowerLineError e : potentialErrors) {
     
    103112            }
    104113        }
     114        potentialErrors.clear();
    105115        super.endTest();
    106116    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r6482 r6494  
    7272public class TagChecker extends Test {
    7373   
    74     /** The default data files */
     74    /** The default data file of tagchecker rules */
    7575    public static final String DATA_FILE = "resource://data/validator/tagchecker.cfg";
     76    /** The config file of ignored tags */
    7677    public static final String IGNORE_FILE = "resource://data/validator/ignoretags.cfg";
     78    /** The config file of dictionary words */
    7779    public static final String SPELL_FILE = "resource://data/validator/words.cfg";
    7880
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r6491 r6494  
    6969        mindist = Main.pref.getDouble(PREFIX + ".node_way_distance", 10.0);
    7070        minmiddledist = Main.pref.getDouble(PREFIX + ".way_way_distance", 0.0);
    71         this.dsArea = Main.main.getCurrentDataSet().getDataSourceArea();
     71        dsArea = Main.main.getCurrentDataSet().getDataSourceArea();
    7272    }
    7373
     
    167167        ways = null;
    168168        endnodes = null;
     169        endnodes_highway = null;
     170        middlenodes = null;
     171        othernodes = null;
     172        dsArea = null;
    169173        super.endTest();
    170174    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java

    r6400 r6494  
    2424 * @author frsantos
    2525 */
    26 public class UntaggedWay extends Test
    27 {
     26public class UntaggedWay extends Test {
     27   
    2828    /** Empty way error */
    2929    protected static final int EMPTY_WAY    = 301;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/WayConnectedToArea.java

    r6241 r6494  
    4343            }
    4444        }
    45         if(!hasway)
    46         {
     45        if (!hasway) {
    4746            for (OsmPrimitive p : r) {
    4847                testForError(w, w.firstNode(), p);
     
    5756            }
    5857        }
    59         if(!hasway) {
     58        if (!hasway) {
    6059            for (OsmPrimitive p : r) {
    6160                testForError(w, w.lastNode(), p);
Note: See TracChangeset for help on using the changeset viewer.