- Timestamp:
- 2017-06-11T13:39:33+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r12282 r12390 134 134 }; 135 135 136 /** 137 * Adds a test to the list of available tests 138 * @param testClass The test class 139 */ 136 140 public static void addTest(Class<? extends Test> testClass) { 137 141 allTests.add(testClass); … … 193 197 } 194 198 199 /** 200 * Adds an ignored error 201 * @param s The ignore group / sub group name 202 * @see TestError#getIgnoreGroup() 203 * @see TestError#getIgnoreSubGroup() 204 */ 195 205 public static void addIgnoredError(String s) { 196 206 ignoredErrors.add(s); 197 207 } 198 208 209 /** 210 * Check if a error should be ignored 211 * @param s The ignore group / sub group name 212 * @return <code>true</code> to ignore that error 213 */ 199 214 public static boolean hasIgnoredError(String s) { 200 215 return ignoredErrors.contains(s); 201 216 } 202 217 218 /** 219 * Saves the names of the ignored errors to a file 220 */ 203 221 public static void saveIgnoredErrors() { 204 222 try (PrintWriter out = new PrintWriter(new File(getValidatorDir(), "ignorederrors"), StandardCharsets.UTF_8.name())) { … … 270 288 } 271 289 290 /** 291 * Gets all tests that are possible 292 * @return The tests 293 */ 272 294 public static Collection<Test> getTests() { 273 295 return getAllTestsMap().values(); 274 296 } 275 297 298 /** 299 * Gets all tests that are run 300 * @param beforeUpload To get the ones that are run before upload 301 * @return The tests 302 */ 276 303 public static Collection<Test> getEnabledTests(boolean beforeUpload) { 277 304 Collection<Test> enabledTests = getTests(); -
trunk/src/org/openstreetmap/josm/data/validation/Severity.java
r10853 r12390 43 43 } 44 44 45 /** 46 * Retrieves all colors once from the preferences to register them 47 */ 45 48 public static void getColors() { 46 49 for (Severity c : values()) { -
trunk/src/org/openstreetmap/josm/data/validation/TestError.java
r11336 r12390 299 299 } 300 300 301 /** 302 * Gets the ignores subgroup that is more specialized than {@link #getIgnoreGroup()} 303 * @return The ignore sub group 304 */ 301 305 public String getIgnoreSubGroup() { 302 306 String ignorestring = getIgnoreGroup(); … … 307 311 } 308 312 313 /** 314 * Gets the ignore group ID that is used to allow the user to ignore all same errors 315 * @return The group id 316 * @see TestError#getIgnoreSubGroup() 317 */ 309 318 public String getIgnoreGroup() { 310 319 return Integer.toString(code); 311 320 } 312 321 322 /** 323 * Flags this error as ignored 324 * @param state The ignore flag 325 */ 313 326 public void setIgnored(boolean state) { 314 327 ignored = state; 315 328 } 316 329 330 /** 331 * Checks if this error is ignored 332 * @return <code>true</code> if it is ignored 333 */ 317 334 public boolean isIgnored() { 318 335 return ignored; … … 371 388 } 372 389 390 /** 391 * Visits all highlighted validation elements 392 * @param v The visitor that should receive a visit-notification on all highlighted elements 393 */ 373 394 @SuppressWarnings("unchecked") 374 395 public void visitHighlighted(ValidatorVisitor v) { -
trunk/src/org/openstreetmap/josm/data/validation/ValidatorVisitor.java
r8510 r12390 8 8 import org.openstreetmap.josm.data.osm.WaySegment; 9 9 10 /** 11 * A visitor that is used during validation. 12 * <p> 13 * The most basic use is to visit all {@link TestError}s of the validator 14 */ 10 15 public interface ValidatorVisitor { 16 /** 17 * Visit a test error 18 * @param error The test error to visit 19 */ 11 20 void visit(TestError error); 12 21 13 void visit(OsmPrimitive p); 22 /** 23 * Visit a OSM primitive, e.g. to highlight it 24 * @param primitive The primitive 25 */ 26 void visit(OsmPrimitive primitive); 14 27 15 void visit(WaySegment ws); 28 /** 29 * Visit a way segment that was part of the error 30 * @param waySegment The way segment 31 */ 32 void visit(WaySegment waySegment); 16 33 34 /** 35 * Visit a list of nodes that are part of the error 36 * @param nodes The nodes 37 */ 17 38 void visit(List<Node> nodes); 18 39 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/ConditionalKeys.java
r11747 r12390 51 51 } 52 52 53 /** 54 * Check if the key is a key for an access restriction 55 * @param part The key (or the restriction part of it, e.g. for lanes) 56 * @return <code>true</code> if it is a restriction 57 */ 53 58 public static boolean isRestrictionType(String part) { 54 59 return RESTRICTION_TYPES.contains(part); 55 60 } 56 61 62 /** 63 * Check if the value is a valid restriction value 64 * @param part The value 65 * @return <code>true</code> for allowed restriction values 66 */ 57 67 public static boolean isRestrictionValue(String part) { 58 68 return RESTRICTION_VALUES.contains(part); 59 69 } 60 70 71 /** 72 * Checks if the key denotes a <a href="http://wiki.openstreetmap.org/wiki/Key:access#Transport_mode_restrictions">transport access mode restriction</a> 73 * @param part The key (or the restriction part of it, e.g. for lanes) 74 * @return <code>true</code> if it is a restriction 75 */ 61 76 public static boolean isTransportationMode(String part) { 62 // http://wiki.openstreetmap.org/wiki/Key:access#Transport_mode_restrictions63 77 return TRANSPORT_MODES.contains(part); 64 78 } 65 79 80 /** 81 * Check if a key part is a valid direction 82 * @param part The part of the key 83 * @return <code>true</code> if it is a direction 84 */ 66 85 public static boolean isDirection(String part) { 67 86 return "forward".equals(part) || "backward".equals(part); 68 87 } 69 88 89 /** 90 * Checks if a given key is a valid access key 91 * @param key The conditional key 92 * @return <code>true</code> if the key is valid 93 */ 70 94 public boolean isKeyValid(String key) { 71 95 // <restriction-type>[:<transportation mode>][:<direction>]:conditional … … 91 115 } 92 116 117 /** 118 * Check if a value is valid 119 * @param key The key the value is for 120 * @param value The value 121 * @return <code>true</code> if it is valid 122 */ 93 123 public boolean isValueValid(String key, String value) { 94 124 return validateValue(key, value) == null; … … 101 131 } 102 132 133 /** 134 * A conditional value is a value for the access restriction tag that depends on conditions (time, ...) 135 */ 103 136 public static class ConditionalValue { 137 /** 138 * The value the tag should have if the condition matches 139 */ 104 140 public final String restrictionValue; 141 /** 142 * The conditions for {@link #restrictionValue} 143 */ 105 144 public final Collection<String> conditions; 106 145 146 /** 147 * Create a new {@link ConditionalValue} 148 * @param restrictionValue The value the tag should have if the condition matches 149 * @param conditions The conditions for that value 150 */ 107 151 public ConditionalValue(String restrictionValue, Collection<String> conditions) { 108 152 this.restrictionValue = restrictionValue; … … 137 181 } 138 182 183 /** 184 * Validate a key/value pair 185 * @param key The key 186 * @param value The value 187 * @return The error message for that value or <code>null</code> to indicate valid 188 */ 139 189 public String validateValue(String key, String value) { 140 190 try { … … 162 212 } 163 213 214 /** 215 * Validate a primitive 216 * @param p The primitive 217 * @return The errors for that primitive or an empty list if there are no errors. 218 */ 164 219 public List<TestError> validatePrimitive(OsmPrimitive p) { 165 220 final List<TestError> errors = new ArrayList<>(); -
trunk/src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java
r12283 r12390 235 235 } 236 236 237 /** 238 * A normalization that is applied to names before testing them 239 */ 237 240 @FunctionalInterface 238 241 public interface NormalizeRule { … … 246 249 } 247 250 251 /** 252 * A rule to replace by regular expression, 253 * so that all strings matching the regular expression are handled as if they were {@link RegExprRule#replacement} 254 */ 248 255 public static class RegExprRule implements NormalizeRule { 249 256 private final Pattern regExpr; 250 257 private final String replacement; 251 258 259 /** 260 * Create a new rule to replace by regular expression 261 * @param expression The regular expression 262 * @param replacement The replacement 263 */ 252 264 public RegExprRule(String expression, String replacement) { 253 265 this.regExpr = Pattern.compile(expression); … … 266 278 } 267 279 280 /** 281 * A rule that registers synonyms to a given word 282 */ 268 283 public static class SynonymRule implements NormalizeRule { 269 284 … … 272 287 private final String replacement; 273 288 289 /** 290 * Create a new {@link SynonymRule} 291 * @param replacement The word to use instead 292 * @param words The synonyms for that word 293 */ 274 294 public SynonymRule(String replacement, String... words) { 275 295 this.replacement = replacement.toLowerCase(Locale.ENGLISH); -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r12279 r12390 81 81 protected static final String PREFIX = ValidatorPreference.PREFIX + "." + TagChecker.class.getSimpleName(); 82 82 83 /** 84 * The preference key to check values 85 */ 83 86 public static final String PREF_CHECK_VALUES = PREFIX + ".checkValues"; 87 /** 88 * The preference key to check keys 89 */ 84 90 public static final String PREF_CHECK_KEYS = PREFIX + ".checkKeys"; 91 /** 92 * The preference key to enable complex checks 93 */ 85 94 public static final String PREF_CHECK_COMPLEX = PREFIX + ".checkComplex"; 95 /** 96 * The preference key to search for fixme tags 97 */ 86 98 public static final String PREF_CHECK_FIXMES = PREFIX + ".checkFixmes"; 87 99 100 /** 101 * The preference key for source files 102 * @see #DEFAULT_SOURCES 103 */ 88 104 public static final String PREF_SOURCES = PREFIX + ".source"; 89 105 106 /** 107 * The preference key to check keys - used before upload 108 */ 90 109 public static final String PREF_CHECK_KEYS_BEFORE_UPLOAD = PREF_CHECK_KEYS + "BeforeUpload"; 110 /** 111 * The preference key to check values - used before upload 112 */ 91 113 public static final String PREF_CHECK_VALUES_BEFORE_UPLOAD = PREF_CHECK_VALUES + "BeforeUpload"; 114 /** 115 * The preference key to run complex tests - used before upload 116 */ 92 117 public static final String PREF_CHECK_COMPLEX_BEFORE_UPLOAD = PREF_CHECK_COMPLEX + "BeforeUpload"; 118 /** 119 * The preference key to search for fixmes - used before upload 120 */ 93 121 public static final String PREF_CHECK_FIXMES_BEFORE_UPLOAD = PREF_CHECK_FIXMES + "BeforeUpload"; 94 122 … … 638 666 } 639 667 668 /** 669 * Enables/disables the source list field 670 */ 640 671 public void handlePrefEnable() { 641 672 boolean selected = prefCheckKeys.isSelected() || prefCheckKeysBeforeUpload.isSelected()
Note:
See TracChangeset
for help on using the changeset viewer.