Class OpeningHourTest
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.Test
-
- org.openstreetmap.josm.data.validation.Test.TagTest
-
- org.openstreetmap.josm.data.validation.tests.OpeningHourTest
-
- All Implemented Interfaces:
OsmPrimitiveVisitor
public class OpeningHourTest extends Test.TagTest
Tests the correct usage of the opening hour syntax of the tagsopening_hours
,collection_times
,service_times
according to OpeningHoursParser.- Since:
- 6370 (using opening_hours.js), 15978 (using OpeningHoursParser)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.data.validation.Test
Test.TagTest
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.JCheckBox
checkboxStrictMode
private static java.util.Collection<java.lang.String>
KEYS_TO_CHECK
private static BooleanProperty
PREF_STRICT_MODE
-
Fields inherited from class org.openstreetmap.josm.data.validation.Test
checkBeforeUpload, checkEnabled, description, enabled, errors, IN_DOWNLOADED_AREA, IN_DOWNLOADED_AREA_STRICT, isBeforeUpload, name, partialSelection, progressMonitor, stopwatch, testBeforeUpload
-
-
Constructor Summary
Constructors Constructor Description OpeningHourTest()
Constructs a newOpeningHourTest
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addErrorsForPrimitive(OsmPrimitive p, java.util.Collection<TestError> errors)
Checks the tags of the given primitive and adds validation errors to the given list.void
addGui(javax.swing.JPanel testPanel)
Allow the tester to manage its own preferencesvoid
check(OsmPrimitive p)
Checks the tags of the given primitive.java.util.List<TestError>
checkOpeningHourSyntax(java.lang.String key, java.lang.String value)
Checks for a correct usage of the opening hour syntax of thevalue
given, and returns a list containing validation errors or an empty list.(package private) java.util.List<TestError>
checkOpeningHourSyntax(java.lang.String key, java.lang.String value, OsmPrimitive p, java.util.Locale locale)
Checks for a correct usage of the opening hour syntax of thevalue
given, and returns a list containing validation errors or an empty list.private TestError
createTestError(Severity severity, java.lang.String message, java.lang.String key, java.lang.String value, java.lang.String prettifiedValue, OsmPrimitive p)
Returns the real test error given to JOSM validator.boolean
ok()
Called when the used submits the preferences-
Methods inherited from class org.openstreetmap.josm.data.validation.Test.TagTest
includeOtherSeverityChecks, visit, visit, visit
-
Methods inherited from class org.openstreetmap.josm.data.validation.Test
clear, deletePrimitivesIfNeeded, endTest, fixError, getErrors, getName, getSource, initialize, isBuilding, isCanceled, isFixable, isPrimitiveUsable, isResidentialArea, removeIrrelevantErrors, setBeforeUpload, setPartialSelection, setShowElements, startTest, testBeforeUpload, visit
-
-
-
-
Field Detail
-
KEYS_TO_CHECK
private static final java.util.Collection<java.lang.String> KEYS_TO_CHECK
-
PREF_STRICT_MODE
private static final BooleanProperty PREF_STRICT_MODE
-
checkboxStrictMode
private final javax.swing.JCheckBox checkboxStrictMode
-
-
Constructor Detail
-
OpeningHourTest
public OpeningHourTest()
Constructs a newOpeningHourTest
.
-
-
Method Detail
-
createTestError
private TestError createTestError(Severity severity, java.lang.String message, java.lang.String key, java.lang.String value, java.lang.String prettifiedValue, OsmPrimitive p)
Returns the real test error given to JOSM validator.- Parameters:
severity
- The error severitymessage
- The error messagekey
- The incriminated key, used for display.value
- The incriminated value, used for comparison with prettified value.prettifiedValue
- The prettified valuep
- The incriminated OSM primitive.- Returns:
- The real test error given to JOSM validator. Can be fixable or not if a prettified values has been determined.
-
checkOpeningHourSyntax
public java.util.List<TestError> checkOpeningHourSyntax(java.lang.String key, java.lang.String value)
Checks for a correct usage of the opening hour syntax of thevalue
given, and returns a list containing validation errors or an empty list. Null values result in an empty list.- Parameters:
key
- the OSM key (should be "opening_hours", "collection_times" or "service_times"). Used in error messagevalue
- the opening hour value to be checked.- Returns:
- a list of
TestError
or an empty list
-
checkOpeningHourSyntax
java.util.List<TestError> checkOpeningHourSyntax(java.lang.String key, java.lang.String value, OsmPrimitive p, java.util.Locale locale)
Checks for a correct usage of the opening hour syntax of thevalue
given, and returns a list containing validation errors or an empty list. Null values result in an empty list.- Parameters:
key
- the OSM key (should be "opening_hours", "collection_times" or "service_times").value
- the opening hour value to be checked.p
- the primitive to check/fix.locale
- the locale code used for localizing messages- Returns:
- a list of
TestError
or an empty list
-
check
public void check(OsmPrimitive p)
Description copied from class:Test.TagTest
Checks the tags of the given primitive.- Specified by:
check
in classTest.TagTest
- Parameters:
p
- The primitive to test
-
addErrorsForPrimitive
public void addErrorsForPrimitive(OsmPrimitive p, java.util.Collection<TestError> errors)
Checks the tags of the given primitive and adds validation errors to the given list.- Parameters:
p
- The primitive to testerrors
- The list to add validation errors to- Since:
- 17643
-
addGui
public void addGui(javax.swing.JPanel testPanel)
Description copied from class:Test
Allow the tester to manage its own preferences
-
-