@Test public void escapeSupportsCommonSearches() { assertThat(searchContributionSupport.escape("library/alpine-dev"), is("library\\/alpine\\-dev")); String mavenGroup = "org.sonatype.nexus"; assertThat(searchContributionSupport.escape(mavenGroup), is(mavenGroup)); assertThat( searchContributionSupport.escape("org.apache.maven maven-plugin-registry"), is("org.apache.maven maven\\-plugin\\-registry") ); }
public String escape(String value) { if (null == value) { return null; } String escaped = QueryParserBase.escape(value); boolean shouldLeaveDoubleQuotesEscaped = StringUtils.countMatches(value, "\"") % 2 != 0; String escapedCharactersRegex = shouldLeaveDoubleQuotesEscaped ? "\\\\([?*])" : "\\\\([?*\"])"; return escaped.replaceAll(escapedCharactersRegex, "$1"); }
SearchContributionSupport implements SearchContribution { public String escape(String value) { if (null == value) { return null; } String escaped = QueryParserBase.escape(value); boolean shouldLeaveDoubleQuotesEscaped = StringUtils.countMatches(value, "\"") % 2 != 0; String escapedCharactersRegex = shouldLeaveDoubleQuotesEscaped ? "\\\\([?*])" : "\\\\([?*\"])"; return escaped.replaceAll(escapedCharactersRegex, "$1"); } }
SearchContributionSupport implements SearchContribution { public String escape(String value) { if (null == value) { return null; } String escaped = QueryParserBase.escape(value); boolean shouldLeaveDoubleQuotesEscaped = StringUtils.countMatches(value, "\"") % 2 != 0; String escapedCharactersRegex = shouldLeaveDoubleQuotesEscaped ? "\\\\([?*])" : "\\\\([?*\"])"; return escaped.replaceAll(escapedCharactersRegex, "$1"); }  }
SearchContributionSupport implements SearchContribution { public String escape(String value) { if (null == value) { return null; } String escaped = QueryParserBase.escape(value); boolean shouldLeaveDoubleQuotesEscaped = StringUtils.countMatches(value, "\"") % 2 != 0; String escapedCharactersRegex = shouldLeaveDoubleQuotesEscaped ? "\\\\([?*])" : "\\\\([?*\"])"; return escaped.replaceAll(escapedCharactersRegex, "$1"); }  @Override void contribute(final BoolQueryBuilder query, final String type, final String value); String escape(String value); }
SearchContributionSupport implements SearchContribution { public String escape(String value) { if (null == value) { return null; } String escaped = QueryParserBase.escape(value); boolean shouldLeaveDoubleQuotesEscaped = StringUtils.countMatches(value, "\"") % 2 != 0; String escapedCharactersRegex = shouldLeaveDoubleQuotesEscaped ? "\\\\([?*])" : "\\\\([?*\"])"; return escaped.replaceAll(escapedCharactersRegex, "$1"); }  @Override void contribute(final BoolQueryBuilder query, final String type, final String value); String escape(String value);  }