Class SearchCompiler
java.lang.Object
org.openstreetmap.josm.data.osm.search.SearchCompiler
Implements a google-like search.
Grammar:
Grammar:
expression = fact | expression fact expression fact fact = ( expression ) -fact term? term=term term:term term
- Since:
- 12656 (moved from actions.search package)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA binary search operator which may take data parameters.static classMatches every OsmPrimitive.static classMatches if both left and right expressions match.private static classMatch a string in any tags (key or value), with optional regex and case insensitivity.private static classMatches if the size of the area is within the given rangestatic interfaceA factor for gettingSearchCompiler.AbstractBinaryMatchobjectsstatic classMatches if the value of the corresponding key is ''yes'', ''true'', ''1'' or ''on''.private static classMatches objects with a changeset ID in the given range.static classMatches objects if they are children of the expressionprivate static final classMatches ways which are closed (i.e.static classThe core factory for "simple"SearchCompiler.Matchobjectsstatic classThe coreSearchCompiler.UnaryMatchfactoryprivate static final classMatches all objects that have been deletedstatic classMatches objects with the exact given key-value pair.static classFilter OsmPrimitives based off of the base primitive typeprivate static classMatches relations with a member of the given roleprivate static classMatches objects with ID in the given range.static classMatches objects within the given bounds.private static final classMatch objects that are incomplete, where only id and type are known.static classMatches objects within source area ("downloaded area").static classMatches objects with the given key-value pair.private static classstatic classBase class for all search criteria.private static interfaceClasses implementing this interface can provide Match operators.static interfaceClasses implementing this interface can provide Match instances themselves and do not rely oncompile(String).private static classprivate static final classMatches all objects that have been modified, created, or undeletedstatic classNever matches any OsmPrimitive.private static final classMatches objects that are new (i.e.private static classMatches ways with a number of nodes in given rangestatic classInverts the match.static classMatches objects which are not outside the source area ("downloaded area").private static classMatches the n-th object of a relation and/or the n-th node of a way.static classMatches if the left OR the right expression match.static classMatches objects if they are parents of the expressionprivate static classMatches presets.private static classMatches objects with properties in a certain range.private static classMatches objects with the given relation role (i.e.private static final classMatches all objects currently selectedstatic interfaceA factory for gettingSearchCompiler.Matchobjectsprivate static classMatches objects with a number of tags in given rangestatic classA common subclass ofSearchCompiler.Matchfor matching against tagsprivate static classMatches objects with a timestamp in given rangestatic classA unary search operator which may take data parameters.static interfaceA factory for gettingSearchCompiler.UnaryMatchobjectsprivate static final classMatches objects that don't have any interesting tags (i.e.static classMatches objects last changed by the given username.static classMatch a primitive based off of a value comparison.private static classMatches objects with a version number in the given range.private static classMatches objects with the number of referring/contained ways in the given rangeprivate static classMatches if the length of a way is within the given rangestatic classMatches if the left OR the right expression match, but not both. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final Map<String,SearchCompiler.BinaryMatchFactory> private final booleanprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate final booleanprivate static final Stringprivate static final Map<String,SearchCompiler.SimpleMatchFactory> private static final Stringprivate final PushbackTokenizerprivate static final Map<String,SearchCompiler.UnaryMatchFactory> private static final Stringprivate static final Stringprivate static final Stringprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionSearchCompiler(boolean caseSensitive, boolean regexSearch, PushbackTokenizer tokenizer) Constructs a newSearchCompiler. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdd (register) MatchFactory with SearchCompilerstatic StringbuildSearchStringForTag(String key, String value) Builds a search string for the given tag.static SearchCompiler.MatchCompiles the search expression.static SearchCompiler.Matchcompile(SearchSetting setting) Compiles the search expression.(package private) static SearchCompiler.MatchcompileMapCSS(String mapCSS) (package private) static Stringprivate SearchCompiler.MatchgetValidate(SearchCompiler.UnaryMatchFactory unaryFactory, String key, PushbackTokenizer tokenizer) parse()Parse search string.private SearchCompiler.MatchParse expression.private static SearchCompiler.MatchparseExpressionStep2(List<Object> list) private SearchCompiler.MatchParse next factor (a search operator or search term).private SearchCompiler.MatchparseFactor(String errorMessage) private static intregexFlags(boolean caseSensitive)
-
Field Details
-
caseSensitive
-
regexSearch
-
REGEX_ERROR_MESSAGE
-
REGEX_ERROR_MESSAGE_NO_POSITION
-
RANGE_OF_NUMBERS_EXPECTED
-
tokenizer
-
simpleMatchFactoryMap
-
unaryMatchFactoryMap
-
binaryMatchFactoryMap
-
AREA_SIZE
- See Also:
-
CHANGESET
- See Also:
-
CLOSED
- See Also:
-
DELETED
- See Also:
-
INCOMPLETE
- See Also:
-
IN_DOWNLOADED_AREA
- See Also:
-
ALL_IN_DOWNLOADED_AREA
- See Also:
-
MEMBERS
- See Also:
-
MODIFIED
- See Also:
-
NODES
- See Also:
-
SELECTED
- See Also:
-
TIMESTAMP
- See Also:
-
UNTAGGED
- See Also:
-
VERSION
- See Also:
-
WAYS
- See Also:
-
WAY_LENGTH
- See Also:
-
-
Constructor Details
-
SearchCompiler
Constructs a newSearchCompiler.- Parameters:
caseSensitive-trueto perform a case-sensitive searchregexSearch-trueto perform a regex-based searchtokenizer- to split the search string into tokens
-
-
Method Details
-
addMatchFactory
Add (register) MatchFactory with SearchCompiler- Parameters:
factory- match factory
-
compile
Compiles the search expression.- Parameters:
searchStr- the search expression- Returns:
- a
SearchCompiler.Matchobject for the expression - Throws:
SearchParseError- if an error has been encountered while compiling- See Also:
-
compile
Compiles the search expression.- Parameters:
setting- the settings to use- Returns:
- a
SearchCompiler.Matchobject for the expression - Throws:
SearchParseError- if an error has been encountered while compiling- See Also:
-
compileMapCSS
- Throws:
SearchParseError
-
parse
Parse search string.- Returns:
- match determined by search string
- Throws:
SearchParseError- if search expression cannot be parsed
-
parseExpression
Parse expression.- Returns:
- match determined by parsing expression
- Throws:
SearchParseError- if search expression cannot be parsed
-
parseExpressionStep1
- Throws:
SearchParseError
-
parseExpressionStep2
-
parseFactor
Parse next factor (a search operator or search term).- Returns:
- match determined by parsing factor string
- Throws:
SearchParseError- if search expression cannot be parsed
-
parseFactor
- Throws:
SearchParseError
-
getValidate
private SearchCompiler.Match getValidate(SearchCompiler.UnaryMatchFactory unaryFactory, String key, PushbackTokenizer tokenizer) throws SearchParseError - Throws:
SearchParseError
-
regexFlags
-
escapeStringForSearch
-
buildSearchStringForTag
Builds a search string for the given tag. If value is empty, the existence of the key is checked.- Parameters:
key- the tag keyvalue- the tag value- Returns:
- a search string for the given tag
-