Class OsmValidator
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.OsmValidator
-
public final class OsmValidator extends Object
A OSM data validator.
-
-
Field Summary
Fields Modifier and Type Field Description private static Collection<Class<? extends Test>>
allTests
All registered testsprivate static Map<String,Test>
allTestsMap
private static Class<Test>[]
CORE_TEST_CLASSES
All available tests in coreprivate static ValidatorLayer
errorLayer
private static double
griddetail
Grid detail, multiplier of east,north values for valuable cell sizingprivate static SortedMap<String,String>
ignoredErrors
private static boolean
testsInitialized
-
Constructor Summary
Constructors Modifier Constructor Description private
OsmValidator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addIgnoredError(String s)
Adds an ignored errorstatic void
addIgnoredError(String s, String description)
Adds an ignored errorstatic void
addTest(Class<? extends Test> testClass)
Adds a test to the list of available testsprivate static void
applyPrefs(Map<String,Test> tests, boolean beforeUpload)
static Map<String,String>
buildIgnore(JTree tree)
Build aHashMap
from a tree of ignored errorsprivate static Map<String,String>
buildIgnore(TreeModel model, DefaultMutableTreeNode node)
static JTree
buildJTreeList()
Build a JTree with a list(package private) static void
cleanupIgnoredErrors()
Make sure that we don't keep single entries for a "group ignore".(package private) static void
clearIgnoredErrors()
For unit testsprivate static String
extractCodeFromIgnoreKey(String key)
Extract the leading digits building the code for the error key.static Collection<Class<? extends Test>>
getAllAvailableTestClasses()
Gets the list of all available test classesstatic SortedMap<String,Test>
getAllTestsMap()
Gets a map from simple names to all tests.static Collection<Test>
getEnabledTests(boolean beforeUpload)
Gets all tests that are runstatic Map<Severity,Map<String,Map<String,List<TestError>>>>
getErrorsBySeverityMessageDescription(Collection<TestError> errors, Predicate<? super TestError> filterToUse)
Groups the given collection of errors by severity, then message, then description.static double
getGridDetail()
Returns grid detail, multiplier of east,north values for valuable cell sizingstatic SortedMap<String,String>
getIgnoredErrors()
Get the list of all ignored errorsstatic <T extends Test>
TgetTest(Class<T> testClass)
Returns the instance of the given test class.static Collection<Test>
getTests()
Gets all tests that are possiblestatic String
getValidatorDir()
Returns the validator directory.static boolean
hasIgnoredError(String s)
Check if a error should be ignoredstatic void
initialize()
InitializesOsmValidator
.static void
initializeErrorLayer()
Initializes error layer.static void
initializeGridDetail()
Initialize grid details based on current projection system.static void
initializeTests()
Initializes all tests if this operations hasn't been performed already.static void
initializeTests(Collection<? extends Test> allTests)
Initializes all testsprivate static DefaultMutableTreeNode
inTree(DefaultMutableTreeNode root, String name)
private static void
loadIgnoredErrors()
private static void
removeLegacyEntries(boolean force)
static boolean
removeTest(Class<? extends Test> testClass)
Removes a test from the list of available tests.static void
resetErrorLayer()
Resets error layer.static void
resetErrorList()
Reset the error list by deletingvalidator.ignorelist
private static boolean
sameCode(String key1, String key2)
static void
saveIgnoredErrors()
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 SortedMap<String,String> ignoredErrors
-
allTests
private static final Collection<Class<? extends Test>> allTests
All registered tests
-
allTestsMap
private static final Map<String,Test> allTestsMap
-
CORE_TEST_CLASSES
private static final 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(Class<? extends Test> testClass)
Adds a test to the list of available tests- Parameters:
testClass
- The test class
-
removeTest
public static boolean removeTest(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:
true
if the test was removed (seeCollection.remove(java.lang.Object)
)- Since:
- 15603
-
initialize
public static void initialize()
InitializesOsmValidator
.
-
getValidatorDir
public static String getValidatorDir()
Returns the validator directory.- Returns:
- The validator directory
-
loadIgnoredErrors
private static void loadIgnoredErrors()
-
removeLegacyEntries
private static void removeLegacyEntries(boolean force)
-
addIgnoredError
public static void addIgnoredError(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(String s, 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".
-
extractCodeFromIgnoreKey
private static String extractCodeFromIgnoreKey(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(String s)
Check if a error should be ignored- Parameters:
s
- The ignore group / sub group name- Returns:
true
to ignore that error
-
getIgnoredErrors
public static SortedMap<String,String> getIgnoredErrors()
Get the list of all ignored errors- Returns:
- The
Collection<String>
of errors that are ignored
-
buildJTreeList
public static JTree buildJTreeList()
Build a JTree with a list- Returns:
- <type>list as a
JTree
-
inTree
private static DefaultMutableTreeNode inTree(DefaultMutableTreeNode root, String name)
-
buildIgnore
public static Map<String,String> buildIgnore(JTree tree)
Build aHashMap
from a tree of ignored errors- Parameters:
tree
- The JTree of ignored errors- Returns:
- A
HashMap
of the ignored errors for comparison
-
buildIgnore
private static Map<String,String> buildIgnore(TreeModel model, 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 SortedMap<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(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(Map<String,Test> tests, boolean beforeUpload)
-
getTests
public static Collection<Test> getTests()
Gets all tests that are possible- Returns:
- The tests
-
getEnabledTests
public static 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 Collection<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 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 operations hasn't been performed already.
-
initializeTests
public static void initializeTests(Collection<? extends Test> allTests)
Initializes all tests- Parameters:
allTests
- The tests to initialize
-
getErrorsBySeverityMessageDescription
public static Map<Severity,Map<String,Map<String,List<TestError>>>> getErrorsBySeverityMessageDescription(Collection<TestError> errors, 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
-
-