Class MapCSSTagCheckerRule
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.tests.MapCSSTagCheckerRule
-
- All Implemented Interfaces:
Predicate<OsmPrimitive>
final class MapCSSTagCheckerRule extends Object implements Predicate<OsmPrimitive>
Tag check.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) List<String>
alternatives
Tags (or arbitrary strings) of alternatives to be presented to the user(package private) boolean
deletion
Denotes whether the object should be deleted for fixing it(package private) Map<Instruction.AssignmentInstruction,Severity>
errors
(package private) List<MapCSSTagCheckerFixCommand>
fixCommands
Commands to apply in order to fix a matching primitive(package private) String
group
A string used to group similar testsprivate static String
POSSIBLE_THROWS
(package private) MapCSSRule
rule
The selector of thisTagCheck
(package private) Collection<String>
setClassExpressions
MapCSS Classes to set on matching primitives
-
Constructor Summary
Constructors Constructor Description MapCSSTagCheckerRule(MapCSSTagCheckerRule check)
MapCSSTagCheckerRule(MapCSSRule rule)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static String
determineArgument(Selector.GeneralSelector matchingSelector, int index, String type, OsmPrimitive p)
(package private) Command
fixPrimitive(OsmPrimitive p)
Constructs a fix in terms of aCommand
for theOsmPrimitive
if the error is fixable, ornull
otherwise.(package private) String
getDescription(OsmPrimitive p)
Constructs a (localized) description for this deprecation check.(package private) String
getDescriptionForMatchingSelector(OsmPrimitive p, Selector matchingSelector)
Constructs a (localized) description for this deprecation check where any placeholders are replaced by values of the matched selector.(package private) List<TestError>
getErrorsForPrimitive(OsmPrimitive p, Selector matchingSelector, Environment env, Test tester)
Constructs aTestError
for the given primitive, or returns null if the primitive does not give rise to an error.(package private) String
getMessage(OsmPrimitive p)
Constructs a (localized) message for this deprecation check.(package private) Severity
getSeverity()
(package private) static String
insertArguments(Selector matchingSelector, String s, OsmPrimitive p)
Replaces occurrences of{i.key}
,{i.value}
,{i.tag}
ins
by the corresponding key/value/tag of theindex
-thCondition
ofmatchingSelector
.(package private) static MapCSSTagCheckerRule
ofMapCSSRule(MapCSSRule rule, MapCSSTagChecker.AssertionConsumer assertionConsumer)
(package private) static MapCSSTagChecker.ParseResult
readMapCSS(Reader css)
(package private) static MapCSSTagChecker.ParseResult
readMapCSS(Reader css, MapCSSTagChecker.AssertionConsumer assertionConsumer)
boolean
test(OsmPrimitive primitive)
(package private) MapCSSTagCheckerRule
toImmutable()
String
toString()
(package private) Selector
whichSelectorMatchesEnvironment(Environment env)
(package private) Selector
whichSelectorMatchesPrimitive(OsmPrimitive primitive)
-
-
-
Field Detail
-
rule
final MapCSSRule rule
The selector of thisTagCheck
-
fixCommands
final List<MapCSSTagCheckerFixCommand> fixCommands
Commands to apply in order to fix a matching primitive
-
alternatives
final List<String> alternatives
Tags (or arbitrary strings) of alternatives to be presented to the user
-
errors
final Map<Instruction.AssignmentInstruction,Severity> errors
AnInstruction.AssignmentInstruction
-Severity
pair. Is evaluated on the matching primitive to give the error message. Map is checked to contain exactly one element.
-
setClassExpressions
final Collection<String> setClassExpressions
MapCSS Classes to set on matching primitives
-
deletion
boolean deletion
Denotes whether the object should be deleted for fixing it
-
POSSIBLE_THROWS
private static final String POSSIBLE_THROWS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MapCSSTagCheckerRule
MapCSSTagCheckerRule(MapCSSRule rule)
-
MapCSSTagCheckerRule
MapCSSTagCheckerRule(MapCSSTagCheckerRule check)
-
-
Method Detail
-
toImmutable
MapCSSTagCheckerRule toImmutable()
-
ofMapCSSRule
static MapCSSTagCheckerRule ofMapCSSRule(MapCSSRule rule, MapCSSTagChecker.AssertionConsumer assertionConsumer) throws IllegalDataException
- Throws:
IllegalDataException
-
readMapCSS
static MapCSSTagChecker.ParseResult readMapCSS(Reader css) throws org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException
- Throws:
org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException
-
readMapCSS
static MapCSSTagChecker.ParseResult readMapCSS(Reader css, MapCSSTagChecker.AssertionConsumer assertionConsumer) throws org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException
- Throws:
org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException
-
test
public boolean test(OsmPrimitive primitive)
- Specified by:
test
in interfacePredicate<OsmPrimitive>
-
whichSelectorMatchesPrimitive
Selector whichSelectorMatchesPrimitive(OsmPrimitive primitive)
-
whichSelectorMatchesEnvironment
Selector whichSelectorMatchesEnvironment(Environment env)
-
determineArgument
static String determineArgument(Selector.GeneralSelector matchingSelector, int index, String type, OsmPrimitive p)
- Parameters:
matchingSelector
- matching selectorindex
- indextype
- selector type ("key", "value" or "tag")p
- OSM primitive- Returns:
- argument value, can be
null
-
insertArguments
static String insertArguments(Selector matchingSelector, String s, OsmPrimitive p)
Replaces occurrences of{i.key}
,{i.value}
,{i.tag}
ins
by the corresponding key/value/tag of theindex
-thCondition
ofmatchingSelector
.- Parameters:
matchingSelector
- matching selectors
- any stringp
- OSM primitive- Returns:
- string with arguments inserted
-
fixPrimitive
Command fixPrimitive(OsmPrimitive p)
Constructs a fix in terms of aCommand
for theOsmPrimitive
if the error is fixable, ornull
otherwise.- Parameters:
p
- the primitive to construct the fix for- Returns:
- the fix or
null
-
getMessage
String getMessage(OsmPrimitive p)
Constructs a (localized) message for this deprecation check.- Parameters:
p
- OSM primitive- Returns:
- a message
-
getDescription
String getDescription(OsmPrimitive p)
Constructs a (localized) description for this deprecation check.- Parameters:
p
- OSM primitive- Returns:
- a description (possibly with alternative suggestions)
- See Also:
getDescriptionForMatchingSelector(org.openstreetmap.josm.data.osm.OsmPrimitive, org.openstreetmap.josm.gui.mappaint.mapcss.Selector)
-
getDescriptionForMatchingSelector
String getDescriptionForMatchingSelector(OsmPrimitive p, Selector matchingSelector)
Constructs a (localized) description for this deprecation check where any placeholders are replaced by values of the matched selector.- Parameters:
matchingSelector
- matching selectorp
- OSM primitive- Returns:
- a description (possibly with alternative suggestions)
-
getSeverity
Severity getSeverity()
-
getErrorsForPrimitive
List<TestError> getErrorsForPrimitive(OsmPrimitive p, Selector matchingSelector, Environment env, Test tester)
Constructs aTestError
for the given primitive, or returns null if the primitive does not give rise to an error.- Parameters:
p
- the primitive to construct the error formatchingSelector
- the matching selector (e.g., obtained viawhichSelectorMatchesPrimitive(org.openstreetmap.josm.data.osm.OsmPrimitive)
)env
- the environmenttester
- the tester- Returns:
- an instance of
TestError
, or returns null if the primitive does not give rise to an error.
-
-