- Timestamp:
- 2020-11-23T19:59:45+01:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/OverpassQueryWizardDialog.java
r16359 r17336 91 91 private Optional<String> tryParseSearchTerm(String searchTerm) { 92 92 try { 93 return Optional.of(SearchCompilerQueryWizard. getInstance().constructQuery(searchTerm));93 return Optional.of(SearchCompilerQueryWizard.constructQuery(searchTerm)); 94 94 } catch (UncheckedParseException | IllegalStateException ex) { 95 95 Logging.error(ex); -
trunk/src/org/openstreetmap/josm/tools/SearchCompilerQueryWizard.java
r16358 r17336 26 26 public final class SearchCompilerQueryWizard { 27 27 28 private static final SearchCompilerQueryWizard instance = new SearchCompilerQueryWizard();29 30 /**31 * Replies the unique instance of this class.32 *33 * @return the unique instance of this class34 */35 public static SearchCompilerQueryWizard getInstance() {36 return instance;37 }38 39 28 private SearchCompilerQueryWizard() { 40 29 // private constructor for utility class … … 47 36 * @throws UncheckedParseException when the parsing fails 48 37 */ 49 public String constructQuery(final String search) { 38 public static String constructQuery(final String search) { 50 39 try { 51 40 Matcher matcher = Pattern.compile("\\s+GLOBAL\\s*$", Pattern.CASE_INSENSITIVE).matcher(search); … … 74 63 } 75 64 } 76 65 77 66 final Match match = SearchCompiler.compile(search); 78 67 return constructQuery(match, "[bbox:{{bbox}}];", ""); … … 82 71 } 83 72 84 private String constructQuery(final Match match, final String bounds, final String queryLineSuffix) { 73 private static String constructQuery(final Match match, final String bounds, final String queryLineSuffix) { 85 74 final List<Match> normalized = normalizeToDNF(match); 86 75 final List<String> queryLines = new ArrayList<>(); … … 136 125 case EXACT: 137 126 return "[" + quote(key) + (negated ? "!=" : "=") + quote(value) + "]"; 127 case ANY_KEY: // *=value 128 // fall through 138 129 case EXACT_REGEXP: 139 130 final Matcher matcher = Pattern.compile("/(?<regex>.*)/(?<flags>i)?").matcher(value); … … 141 132 ? quote(matcher.group("regex")) + Optional.ofNullable(matcher.group("flags")).map(f -> "," + f).orElse("") 142 133 : quote(value); 134 if (mode == SearchCompiler.ExactKeyValue.Mode.ANY_KEY) 135 return "[~\"^.*$\"" + (negated ? "!~" : "~") + valueQuery + "]"; 143 136 return "[" + quote(key) + (negated ? "!~" : "~") + valueQuery + "]"; 144 137 case MISSING_KEY:
Note:
See TracChangeset
for help on using the changeset viewer.