Class OsmValidator
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.OsmValidator
-
public final class OsmValidator extends java.lang.Object
A OSM data validator.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Collection<java.lang.Class<? extends Test>>allTestsAll registered testsprivate static java.util.Map<java.lang.String,Test>allTestsMapprivate static java.lang.Class<Test>[]CORE_TEST_CLASSESAll available tests in coreprivate static ValidatorLayererrorLayerprivate static doublegriddetailGrid detail, multiplier of east,north values for valuable cell sizingprivate static java.util.SortedMap<java.lang.String,java.lang.String>ignoredErrorsprivate static booleantestsInitialized
-
Constructor Summary
Constructors Modifier Constructor Description privateOsmValidator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddIgnoredError(java.lang.String s)Adds an ignored errorstatic voidaddIgnoredError(java.lang.String s, java.lang.String description)Adds an ignored errorstatic voidaddTest(java.lang.Class<? extends Test> testClass)Adds a test to the list of available testsprivate static voidapplyPrefs(java.util.Map<java.lang.String,Test> tests, boolean beforeUpload)static java.util.Map<java.lang.String,java.lang.String>buildIgnore(javax.swing.JTree tree)Build aHashMapfrom a tree of ignored errorsprivate static java.util.Map<java.lang.String,java.lang.String>buildIgnore(javax.swing.tree.TreeModel model, javax.swing.tree.DefaultMutableTreeNode node)static javax.swing.JTreebuildJTreeList()Build a JTree with a list(package private) static voidcleanupIgnoredErrors()Make sure that we don't keep single entries for a "group ignore".(package private) static voidclearIgnoredErrors()For unit testsprivate static java.lang.StringextractCodeFromIgnoreKey(java.lang.String key)Extract the leading digits building the code for the error key.static java.util.Collection<java.lang.Class<? extends Test>>getAllAvailableTestClasses()Gets the list of all available test classesstatic java.util.SortedMap<java.lang.String,Test>getAllTestsMap()Gets a map from simple names to all tests.static java.util.Collection<Test>getEnabledTests(boolean beforeUpload)Gets all tests that are runstatic java.util.Map<Severity,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<TestError>>>>getErrorsBySeverityMessageDescription(java.util.Collection<TestError> errors, java.util.function.Predicate<? super TestError> filterToUse)Groups the given collection of errors by severity, then message, then description.static doublegetGridDetail()Returns grid detail, multiplier of east,north values for valuable cell sizingstatic java.util.SortedMap<java.lang.String,java.lang.String>getIgnoredErrors()Get the list of all ignored errorsstatic <T extends Test>
TgetTest(java.lang.Class<T> testClass)Returns the instance of the given test class.static java.util.Collection<Test>getTests()Gets all tests that are possiblestatic java.lang.StringgetValidatorDir()Returns the validator directory.static booleanhasIgnoredError(java.lang.String s)Check if a error should be ignoredstatic voidinitialize()InitializesOsmValidator.static voidinitializeErrorLayer()Initializes error layer.static voidinitializeGridDetail()Initialize grid details based on the current projection system.static voidinitializeTests()Initializes all tests if this operation hasn't been performed already.static voidinitializeTests(java.util.Collection<? extends Test> allTests)Initializes all testsprivate static javax.swing.tree.DefaultMutableTreeNodeinTree(javax.swing.tree.DefaultMutableTreeNode root, java.lang.String name)private static voidloadIgnoredErrors()private static voidremoveLegacyEntries(boolean force)private static booleanremoveLegacyEntry(boolean force, boolean keep, java.lang.String prefix)static booleanremoveTest(java.lang.Class<? extends Test> testClass)Removes a test from the list of available tests.static voidresetErrorLayer()Resets error layer.static voidresetErrorList()Reset the error list by deletingvalidator.ignorelistprivate static booleansameCode(java.lang.String key1, java.lang.String key2)static voidsaveIgnoredErrors()Saves the names of the ignored errors to a preference
-
-
-
Field Detail
-
errorLayer
private static volatile ValidatorLayer errorLayer
-
griddetail
private static double griddetail
Grid detail, multiplier of east,north values for valuable cell sizing
-
ignoredErrors
private static final java.util.SortedMap<java.lang.String,java.lang.String> ignoredErrors
-
allTests
private static final java.util.Collection<java.lang.Class<? extends Test>> allTests
All registered tests
-
allTestsMap
private static final java.util.Map<java.lang.String,Test> allTestsMap
-
CORE_TEST_CLASSES
private static final java.lang.Class<Test>[] CORE_TEST_CLASSES
All available tests in core
-
testsInitialized
private static boolean testsInitialized
-
-
Constructor Detail
-
OsmValidator
private OsmValidator()
-
-
Method Detail
-
addTest
public static void addTest(java.lang.Class<? extends Test> testClass)
Adds a test to the list of available tests- Parameters:
testClass- The test class
-
removeTest
public static boolean removeTest(java.lang.Class<? extends Test> testClass)
Removes a test from the list of available tests. This will not remove core tests.- Parameters:
testClass- The test class- Returns:
trueif the test was removed (seeCollection.remove(java.lang.Object))- Since:
- 15603
-
initialize
public static void initialize()
InitializesOsmValidator.
-
getValidatorDir
public static java.lang.String getValidatorDir()
Returns the validator directory.- Returns:
- The validator directory
-
loadIgnoredErrors
private static void loadIgnoredErrors()
-
removeLegacyEntries
private static void removeLegacyEntries(boolean force)
-
removeLegacyEntry
private static boolean removeLegacyEntry(boolean force, boolean keep, java.lang.String prefix)
-
addIgnoredError
public static void addIgnoredError(java.lang.String s)
Adds an ignored error- Parameters:
s- The ignore group / sub group name- See Also:
TestError.getIgnoreGroup(),TestError.getIgnoreSubGroup()
-
addIgnoredError
public static void addIgnoredError(java.lang.String s, java.lang.String description)
Adds an ignored error- Parameters:
s- The ignore group / sub group namedescription- What the error actually is- See Also:
TestError.getIgnoreGroup(),TestError.getIgnoreSubGroup()
-
cleanupIgnoredErrors
static void cleanupIgnoredErrors()
Make sure that we don't keep single entries for a "group ignore".
-
sameCode
private static boolean sameCode(java.lang.String key1, java.lang.String key2)
-
extractCodeFromIgnoreKey
private static java.lang.String extractCodeFromIgnoreKey(java.lang.String key)
Extract the leading digits building the code for the error key.- Parameters:
key- the error key- Returns:
- the leading digits
-
hasIgnoredError
public static boolean hasIgnoredError(java.lang.String s)
Check if a error should be ignored- Parameters:
s- The ignore group / sub group name- Returns:
trueto ignore that error
-
getIgnoredErrors
public static java.util.SortedMap<java.lang.String,java.lang.String> getIgnoredErrors()
Get the list of all ignored errors- Returns:
- The
Collection<String>of errors that are ignored
-
buildJTreeList
public static javax.swing.JTree buildJTreeList()
Build a JTree with a list- Returns:
- <type>list as a
JTree
-
inTree
private static javax.swing.tree.DefaultMutableTreeNode inTree(javax.swing.tree.DefaultMutableTreeNode root, java.lang.String name)
-
buildIgnore
public static java.util.Map<java.lang.String,java.lang.String> buildIgnore(javax.swing.JTree tree)
Build aHashMapfrom a tree of ignored errors- Parameters:
tree- The JTree of ignored errors- Returns:
- A
HashMapof the ignored errors for comparison
-
buildIgnore
private static java.util.Map<java.lang.String,java.lang.String> buildIgnore(javax.swing.tree.TreeModel model, javax.swing.tree.DefaultMutableTreeNode node)
-
resetErrorList
public static void resetErrorList()
Reset the error list by deletingvalidator.ignorelist
-
saveIgnoredErrors
public static void saveIgnoredErrors()
Saves the names of the ignored errors to a preference
-
initializeErrorLayer
public static void initializeErrorLayer()
Initializes error layer.
-
resetErrorLayer
public static void resetErrorLayer()
Resets error layer.- Since:
- 11852
-
getAllTestsMap
public static java.util.SortedMap<java.lang.String,Test> getAllTestsMap()
Gets a map from simple names to all tests.- Returns:
- A map of all tests, indexed and sorted by the name of their Java class
-
getTest
public static <T extends Test> T getTest(java.lang.Class<T> testClass)
Returns the instance of the given test class.- Type Parameters:
T- testClass type- Parameters:
testClass- The class of test to retrieve- Returns:
- the instance of the given test class, if any, or
null - Since:
- 6670
-
applyPrefs
private static void applyPrefs(java.util.Map<java.lang.String,Test> tests, boolean beforeUpload)
-
getTests
public static java.util.Collection<Test> getTests()
Gets all tests that are possible- Returns:
- The tests
-
getEnabledTests
public static java.util.Collection<Test> getEnabledTests(boolean beforeUpload)
Gets all tests that are run- Parameters:
beforeUpload- To get the ones that are run before upload- Returns:
- The tests
-
getAllAvailableTestClasses
public static java.util.Collection<java.lang.Class<? extends Test>> getAllAvailableTestClasses()
Gets the list of all available test classes- Returns:
- A collection of the test classes
-
initializeGridDetail
public static void initializeGridDetail()
Initialize grid details based on the current projection system. Values based on the original value fixed for EPSG:4326 (10000) using heuristics (that is, test&error until most bugs were discovered while keeping the processing time reasonable)
-
getGridDetail
public static double getGridDetail()
Returns grid detail, multiplier of east,north values for valuable cell sizing- Returns:
- grid detail
- Since:
- 11852
-
initializeTests
public static void initializeTests()
Initializes all tests if this operation hasn't been performed already.
-
initializeTests
public static void initializeTests(java.util.Collection<? extends Test> allTests)
Initializes all tests- Parameters:
allTests- The tests to initialize
-
getErrorsBySeverityMessageDescription
public static java.util.Map<Severity,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<TestError>>>> getErrorsBySeverityMessageDescription(java.util.Collection<TestError> errors, java.util.function.Predicate<? super TestError> filterToUse)
Groups the given collection of errors by severity, then message, then description.- Parameters:
errors- list of errors to groupfilterToUse- optional filter- Returns:
- collection of errors grouped by severity, then message, then description
- Since:
- 12667
-
clearIgnoredErrors
static void clearIgnoredErrors()
For unit tests
-
-