public class OpeningHourTest extends Test.TagTest
opening_hours, collection_times, service_times according to
opening_hours.js.| Modifier and Type | Class and Description |
|---|---|
static class |
OpeningHourTest.CheckMode
In OSM, the syntax originally designed to describe opening hours, is now used to describe a few other things as well.
|
class |
OpeningHourTest.OpeningHoursTestError
An error concerning invalid syntax for an "opening_hours"-like tag.
|
Test.TagTest| Modifier and Type | Field and Description |
|---|---|
static javax.script.ScriptEngine |
ENGINE
Javascript engine
|
checkBeforeUpload, checkEnabled, description, enabled, errors, IN_DOWNLOADED_AREA, IN_DOWNLOADED_AREA_STRICT, isBeforeUpload, name, partialSelection, progressMonitor, startTime, testBeforeUpload| Constructor and Description |
|---|
OpeningHourTest()
Constructs a new
OpeningHourTest. |
| Modifier and Type | Method and Description |
|---|---|
void |
check(OsmPrimitive p)
Checks the tags of the given primitive.
|
protected void |
check(OsmPrimitive p,
java.lang.String key) |
java.util.List<OpeningHourTest.OpeningHoursTestError> |
checkOpeningHourSyntax(java.lang.String key,
java.lang.String value)
Checks for a correct usage of the opening hour syntax of the
value given according to
opening_hours.js and returns a list containing
validation errors or an empty list. |
java.util.List<OpeningHourTest.OpeningHoursTestError> |
checkOpeningHourSyntax(java.lang.String key,
java.lang.String value,
OpeningHourTest.CheckMode mode,
boolean ignoreOtherSeverity,
java.lang.String locale)
Checks for a correct usage of the opening hour syntax of the
value given according to
opening_hours.js and returns a list containing
validation errors or an empty list. |
static java.lang.String |
getErrorMessage(java.lang.Object o)
Translates and shortens the error/warning message.
|
(package private) static java.lang.String |
getErrorMessage(java.lang.String key,
java.lang.Object o)
Translates and shortens the error/warning message.
|
protected java.util.List<java.lang.Object> |
getList(java.lang.Object obj) |
java.util.List<java.lang.Object> |
getOpeningHoursErrors(java.lang.Object r)
Returns the list of errors returned by the opening hours parser.
|
java.lang.String |
getOpeningHoursPrettifiedValues(java.lang.Object r)
Returns the prettified value returned by the opening hours parser.
|
java.util.List<java.lang.Object> |
getOpeningHoursWarnings(java.lang.Object r)
Returns the list of warnings returned by the opening hours parser.
|
void |
initialize()
Initializes any global data used this tester.
|
java.lang.Object |
parse(java.lang.String value,
java.lang.String tagKey,
OpeningHourTest.CheckMode mode,
java.lang.String locale)
Parses the opening hour syntax of the
value given according to
opening_hours.js and returns an object on which
methods can be called to extract information. |
visit, visit, visitaddGui, clear, compareTo, deletePrimitivesIfNeeded, endTest, equals, fixError, getErrors, getName, hashCode, isBuilding, isCanceled, isFixable, isPrimitiveUsable, isResidentialArea, ok, setBeforeUpload, setPartialSelection, setShowElements, startTest, testBeforeUpload, visitpublic static final javax.script.ScriptEngine ENGINE
public OpeningHourTest()
OpeningHourTest.public void initialize() throws java.lang.Exception
Testinitialize in class Testjava.lang.Exception - When cannot initialize the testpublic java.lang.Object parse(java.lang.String value, java.lang.String tagKey, OpeningHourTest.CheckMode mode, java.lang.String locale) throws javax.script.ScriptException, java.lang.NoSuchMethodException
value given according to
opening_hours.js and returns an object on which
methods can be called to extract information.value - the opening hour value to be checkedtagKey - the OSM key (should be "opening_hours", "collection_times" or "service_times")mode - whether to validate value as a time range, or points in time, or both. Can be nulllocale - the locale code used for localizing messagesjdk.nashorn.api.scripting.ScriptObjectMirrorjavax.script.ScriptException - if an error occurs during invocation of the underlying methodjava.lang.NoSuchMethodException - if underlying method with given name or matching argument types cannot be foundprotected java.util.List<java.lang.Object> getList(java.lang.Object obj) throws javax.script.ScriptException, java.lang.NoSuchMethodException
javax.script.ScriptExceptionjava.lang.NoSuchMethodExceptionpublic java.util.List<OpeningHourTest.OpeningHoursTestError> checkOpeningHourSyntax(java.lang.String key, java.lang.String value)
value given according to
opening_hours.js and returns a list containing
validation errors or an empty list. Null values result in an empty list.key - the OSM key (should be "opening_hours", "collection_times" or "service_times"). Used in error messagevalue - the opening hour value to be checked.TestError or an empty listpublic java.util.List<OpeningHourTest.OpeningHoursTestError> checkOpeningHourSyntax(java.lang.String key, java.lang.String value, OpeningHourTest.CheckMode mode, boolean ignoreOtherSeverity, java.lang.String locale)
value given according to
opening_hours.js and returns a list containing
validation errors or an empty list. Null values result in an empty list.key - the OSM key (should be "opening_hours", "collection_times" or "service_times").value - the opening hour value to be checked.mode - whether to validate value as a time range, or points in time, or both. Can be nullignoreOtherSeverity - whether to ignore errors with Severity.OTHER.locale - the locale code used for localizing messagesTestError or an empty listpublic final java.lang.String getOpeningHoursPrettifiedValues(java.lang.Object r) throws java.lang.NoSuchMethodException, javax.script.ScriptException
r - result of parse(java.lang.String, java.lang.String, org.openstreetmap.josm.data.validation.tests.OpeningHourTest.CheckMode, java.lang.String)java.lang.NoSuchMethodException - if method "prettifyValue" or matching argument types cannot be foundjavax.script.ScriptException - if an error occurs during invocation of the JavaScript methodpublic final java.util.List<java.lang.Object> getOpeningHoursErrors(java.lang.Object r) throws java.lang.NoSuchMethodException, javax.script.ScriptException
r - result of parse(java.lang.String, java.lang.String, org.openstreetmap.josm.data.validation.tests.OpeningHourTest.CheckMode, java.lang.String)java.lang.NoSuchMethodException - if method "getErrors" or matching argument types cannot be foundjavax.script.ScriptException - if an error occurs during invocation of the JavaScript methodpublic final java.util.List<java.lang.Object> getOpeningHoursWarnings(java.lang.Object r) throws java.lang.NoSuchMethodException, javax.script.ScriptException
r - result of parse(java.lang.String, java.lang.String, org.openstreetmap.josm.data.validation.tests.OpeningHourTest.CheckMode, java.lang.String)java.lang.NoSuchMethodException - if method "getWarnings" or matching argument types cannot be foundjavax.script.ScriptException - if an error occurs during invocation of the JavaScript methodpublic static java.lang.String getErrorMessage(java.lang.Object o)
o - error/warning message returned by getOpeningHoursErrors(java.lang.Object) or getOpeningHoursWarnings(java.lang.Object)static java.lang.String getErrorMessage(java.lang.String key, java.lang.Object o)
key - OSM keyo - error/warning message returned by getOpeningHoursErrors(java.lang.Object) or getOpeningHoursWarnings(java.lang.Object)protected void check(OsmPrimitive p, java.lang.String key)
public void check(OsmPrimitive p)
Test.TagTestcheck in class Test.TagTestp - The primitive to test