org.openstreetmap.josm.actions.search
Class SearchCompiler

java.lang.Object
  extended by org.openstreetmap.josm.actions.search.SearchCompiler

public class SearchCompiler
extends java.lang.Object

Implements a google-like search.
Grammar:

expression =
  fact | expression
  fact expression
  fact

fact =
 ( expression )
 -fact
 term?
 term=term
 term:term
 term
 


Nested Class Summary
static class SearchCompiler.Always
          Matches every OsmPrimitive.
static class SearchCompiler.And
          Matches if both left and right expressions match.
private static class SearchCompiler.Any
          Match a string in any tags (key or value), with optional regex and case insensitivity.
private static class SearchCompiler.AreaSize
          Matches if the size of the area is within the given range
static class SearchCompiler.BinaryMatch
          A binary search operator which may take data parameters.
static interface SearchCompiler.BinaryMatchFactory
           
private static class SearchCompiler.BooleanMatch
          Matches if the value of the corresponding key is ''yes'', ''true'', ''1'' or ''on''.
private static class SearchCompiler.ChangesetId
          Matches objects with the given changeset ID.
static class SearchCompiler.Child
          Matches objects if they are children of the expression
private static class SearchCompiler.Closed
          Matches ways which are closed (i.e.
 class SearchCompiler.CoreSimpleMatchFactory
           
static class SearchCompiler.CoreUnaryMatchFactory
           
private static class SearchCompiler.CountRange
          Matches objects with properties in a certain range.
static class SearchCompiler.ExactKeyValue
          Matches objects with the exact given key-value pair.
private static class SearchCompiler.ExactType
           
private static class SearchCompiler.Id
          Matches objects with the given object ID.
private static class SearchCompiler.InArea
          Matches objects within the given bounds.
private static class SearchCompiler.Incomplete
          Match objects that are incomplete, where only id and type are known.
private static class SearchCompiler.InDataSourceArea
          Matches objects within source area ("downloaded area").
private static class SearchCompiler.InView
          Matches objects within current map view.
private static class SearchCompiler.KeyValue
          Matches objects with the given key-value pair.
static class SearchCompiler.Match
          Base class for all search operators.
private static interface SearchCompiler.MatchFactory
          Classes implementing this interface can provide Match operators.
private static class SearchCompiler.Modified
          Matches all objects that have been modified, created, or undeleted
static class SearchCompiler.Never
          Never matches any OsmPrimitive.
private static class SearchCompiler.New
          Matches objects that are new (i.e.
private static class SearchCompiler.NodeCountRange
          Matches ways with a number of nodes in given range
static class SearchCompiler.Not
          Inverts the match.
static class SearchCompiler.Or
          Matches if the left OR the right expression match.
static class SearchCompiler.Parent
          Matches objects if they are parents of the expression
static class SearchCompiler.ParseError
           
private static class SearchCompiler.RoleMatch
          Matches objects with the given relation role (i.e.
private static class SearchCompiler.Selected
          Matches all objects currently selected
static interface SearchCompiler.SimpleMatchFactory
           
private static class SearchCompiler.TagCountRange
          Matches objects with a number of tags in given range
private static class SearchCompiler.TimestampRange
          Matches objects with a timestamp in given range
static class SearchCompiler.UnaryMatch
          A unary search operator which may take data parameters.
static interface SearchCompiler.UnaryMatchFactory
           
private static class SearchCompiler.Untagged
          Matches objects that don't have any interesting tags (i.e.
private static class SearchCompiler.UserMatch
          Matches objects last changed by the given username.
private static class SearchCompiler.Version
          Matches objects with the given version number.
static class SearchCompiler.Xor
          Matches if the left OR the right expression match, but not both.
 
Field Summary
private static java.util.Map<java.lang.String,SearchCompiler.BinaryMatchFactory> binaryMatchFactoryMap
           
private  boolean caseSensitive
           
private  boolean regexSearch
           
private static java.lang.String rxErrorMsg
           
private static java.lang.String rxErrorMsgNoPos
           
private static java.util.Map<java.lang.String,SearchCompiler.SimpleMatchFactory> simpleMatchFactoryMap
           
private  PushbackTokenizer tokenizer
           
private static java.util.Map<java.lang.String,SearchCompiler.UnaryMatchFactory> unaryMatchFactoryMap
           
 
Constructor Summary
SearchCompiler(boolean caseSensitive, boolean regexSearch, PushbackTokenizer tokenizer)
           
 
Method Summary
static void addMatchFactory(SearchCompiler.MatchFactory factory)
          Add (register) MatchFactory with SearchCompiler
static SearchCompiler.Match compile(java.lang.String searchStr, boolean caseSensitive, boolean regexSearch)
           
 SearchCompiler.Match parse()
          Parse search string.
private  SearchCompiler.Match parseExpression()
          Parse expression.
private  SearchCompiler.Match parseExpression(java.lang.String errorMessage)
          Parse expression, showing the specified error message if parsing fails.
private  SearchCompiler.Match parseFactor()
          Parse next factor (a search operator or search term).
private  SearchCompiler.Match parseFactor(java.lang.String errorMessage)
           
private  SearchCompiler.Match parseKV(java.lang.String key, java.lang.String value)
           
private static int regexFlags(boolean caseSensitive)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

caseSensitive

private boolean caseSensitive

regexSearch

private boolean regexSearch

rxErrorMsg

private static java.lang.String rxErrorMsg

rxErrorMsgNoPos

private static java.lang.String rxErrorMsgNoPos

tokenizer

private PushbackTokenizer tokenizer

simpleMatchFactoryMap

private static java.util.Map<java.lang.String,SearchCompiler.SimpleMatchFactory> simpleMatchFactoryMap

unaryMatchFactoryMap

private static java.util.Map<java.lang.String,SearchCompiler.UnaryMatchFactory> unaryMatchFactoryMap

binaryMatchFactoryMap

private static java.util.Map<java.lang.String,SearchCompiler.BinaryMatchFactory> binaryMatchFactoryMap
Constructor Detail

SearchCompiler

public SearchCompiler(boolean caseSensitive,
                      boolean regexSearch,
                      PushbackTokenizer tokenizer)
Method Detail

addMatchFactory

public static void addMatchFactory(SearchCompiler.MatchFactory factory)
Add (register) MatchFactory with SearchCompiler

Parameters:
factory -

compile

public static SearchCompiler.Match compile(java.lang.String searchStr,
                                           boolean caseSensitive,
                                           boolean regexSearch)
                                    throws SearchCompiler.ParseError
Throws:
SearchCompiler.ParseError

parse

public SearchCompiler.Match parse()
                           throws SearchCompiler.ParseError
Parse search string.

Returns:
match determined by search string
Throws:
SearchCompiler.ParseError

parseExpression

private SearchCompiler.Match parseExpression()
                                      throws SearchCompiler.ParseError
Parse expression. This is a recursive method.

Returns:
match determined by parsing expression
Throws:
SearchCompiler.ParseError

parseExpression

private SearchCompiler.Match parseExpression(java.lang.String errorMessage)
                                      throws SearchCompiler.ParseError
Parse expression, showing the specified error message if parsing fails.

Parameters:
errorMessage - to display if parsing error occurs
Returns:
Throws:
SearchCompiler.ParseError

parseFactor

private SearchCompiler.Match parseFactor()
                                  throws SearchCompiler.ParseError
Parse next factor (a search operator or search term).

Returns:
match determined by parsing factor string
Throws:
SearchCompiler.ParseError

parseFactor

private SearchCompiler.Match parseFactor(java.lang.String errorMessage)
                                  throws SearchCompiler.ParseError
Throws:
SearchCompiler.ParseError

parseKV

private SearchCompiler.Match parseKV(java.lang.String key,
                                     java.lang.String value)
                              throws SearchCompiler.ParseError
Throws:
SearchCompiler.ParseError

regexFlags

private static int regexFlags(boolean caseSensitive)


JOSM