@Test public void testEscapeAllButWildcardCharacters() { ProjectionSearchRequestBuilder sut = new ProjectionSearchRequestBuilder(); assertEquals("foo bar", sut.escapeAllButWildcardCharacters("foo bar")); assertEquals("\\(foo bar\\)", sut.escapeAllButWildcardCharacters("(foo bar)")); assertEquals("\\\\foo bar", sut.escapeAllButWildcardCharacters("\\foo bar")); assertEquals("foo\\:bar", sut.escapeAllButWildcardCharacters("foo:bar")); assertEquals("foo\\^bar", sut.escapeAllButWildcardCharacters("foo^bar")); assertEquals("foo\\|bar", sut.escapeAllButWildcardCharacters("foo|bar")); assertEquals("foo\\&bar", sut.escapeAllButWildcardCharacters("foo&bar")); assertEquals("\\\"foo bar\\\"", sut.escapeAllButWildcardCharacters("\"foo bar\"")); assertEquals("foo\\+bar", sut.escapeAllButWildcardCharacters("foo+bar")); assertEquals("foo\\-bar", sut.escapeAllButWildcardCharacters("foo-bar")); assertEquals("\\!foo bar", sut.escapeAllButWildcardCharacters("!foo bar")); assertEquals("he?lo there", sut.escapeAllButWildcardCharacters("he?lo there")); assertEquals("hello* there*", sut.escapeAllButWildcardCharacters("hello* there*")); assertEquals("he**o th??e", sut.escapeAllButWildcardCharacters("he**o th??e")); assertEquals("hi* hi", sut.escapeAllButWildcardCharacters("hi* * hi")); assertEquals("hi?* hi", sut.escapeAllButWildcardCharacters("hi?* ? hi")); assertEquals(" asd hi", sut.escapeAllButWildcardCharacters("* asd hi")); assertEquals(" hi hi", sut.escapeAllButWildcardCharacters("*** hi *** hi")); assertEquals("", sut.escapeAllButWildcardCharacters("*")); assertEquals("", sut.escapeAllButWildcardCharacters("*?*?*?*")); assertEquals("hello there", sut.escapeAllButWildcardCharacters("*hello there")); assertEquals("hello there", sut.escapeAllButWildcardCharacters("****hello there")); assertEquals("hello there", sut.escapeAllButWildcardCharacters("?hello there")); assertEquals(" hello there", sut.escapeAllButWildcardCharacters(" ?hello there")); }
public String escapeAllButWildcardCharacters(final String s) { final int negTwo = -2; StringBuffer sb = new StringBuffer(); int stringLength = s.length(); int lastGoodCharIndex = negTwo; for (int i = 0; i < stringLength; i++) { char c = s.charAt(i); if ((c == '*' || c == '?') && (lastGoodCharIndex < (i - 1) || isWhitespaceChar(s.charAt(i - 1)))) { continue; } if (c == '\\' || c == ':' || c == '^' || c == '|' || c == '&' || c == '"' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')') { sb.append('\\'); } sb.append(c); lastGoodCharIndex = i; } if (log.isDebugEnabled()) { log.debug("Escaping '" + s + "' as '" + sb.toString() + "'"); } return sb.toString(); }
ProjectionSearchRequestBuilder { public String escapeAllButWildcardCharacters(final String s) { final int negTwo = -2; StringBuffer sb = new StringBuffer(); int stringLength = s.length(); int lastGoodCharIndex = negTwo; for (int i = 0; i < stringLength; i++) { char c = s.charAt(i); if ((c == '*' || c == '?') && (lastGoodCharIndex < (i - 1) || isWhitespaceChar(s.charAt(i - 1)))) { continue; } if (c == '\\' || c == ':' || c == '^' || c == '|' || c == '&' || c == '"' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')') { sb.append('\\'); } sb.append(c); lastGoodCharIndex = i; } if (log.isDebugEnabled()) { log.debug("Escaping '" + s + "' as '" + sb.toString() + "'"); } return sb.toString(); } }
ProjectionSearchRequestBuilder { public String escapeAllButWildcardCharacters(final String s) { final int negTwo = -2; StringBuffer sb = new StringBuffer(); int stringLength = s.length(); int lastGoodCharIndex = negTwo; for (int i = 0; i < stringLength; i++) { char c = s.charAt(i); if ((c == '*' || c == '?') && (lastGoodCharIndex < (i - 1) || isWhitespaceChar(s.charAt(i - 1)))) { continue; } if (c == '\\' || c == ':' || c == '^' || c == '|' || c == '&' || c == '"' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')') { sb.append('\\'); } sb.append(c); lastGoodCharIndex = i; } if (log.isDebugEnabled()) { log.debug("Escaping '" + s + "' as '" + sb.toString() + "'"); } return sb.toString(); } ProjectionSearchRequestBuilder(); }
ProjectionSearchRequestBuilder { public String escapeAllButWildcardCharacters(final String s) { final int negTwo = -2; StringBuffer sb = new StringBuffer(); int stringLength = s.length(); int lastGoodCharIndex = negTwo; for (int i = 0; i < stringLength; i++) { char c = s.charAt(i); if ((c == '*' || c == '?') && (lastGoodCharIndex < (i - 1) || isWhitespaceChar(s.charAt(i - 1)))) { continue; } if (c == '\\' || c == ':' || c == '^' || c == '|' || c == '&' || c == '"' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')') { sb.append('\\'); } sb.append(c); lastGoodCharIndex = i; } if (log.isDebugEnabled()) { log.debug("Escaping '" + s + "' as '" + sb.toString() + "'"); } return sb.toString(); } ProjectionSearchRequestBuilder(); @PersistenceContext void setEntityManager(final EntityManager newEntityManager); org.hibernate.search.jpa.FullTextQuery buildQueryFromNativeSearchString(final String nativeSearchString); org.hibernate.search.jpa.FullTextQuery buildQueryFromSearchText(final String searchText); org.hibernate.search.jpa.FullTextQuery buildQueryFromSearchText(final String searchText,
            final String constraints); org.hibernate.search.jpa.FullTextQuery setPaging(final org.hibernate.search.jpa.FullTextQuery query,
            final int from, final int to); String escapeAllButWildcardCharacters(final String s); String escape(final String s); void setResultTypes(final Class< ? >[] theResultTypes); void setSearchStringFormat(final String theSearchStringFormat); void setResultTransformer(final ResultTransformer theResultTransformer); void setQueryParserBuilder(final QueryParserBuilder inQueryParserBuilder); void setResultFields(final List<String> theResultFields); void setAdvancedQueryParserBuilder(final QueryParserBuilder inAdvancedQueryParserBuilder); String getEntityNames(); }
ProjectionSearchRequestBuilder { public String escapeAllButWildcardCharacters(final String s) { final int negTwo = -2; StringBuffer sb = new StringBuffer(); int stringLength = s.length(); int lastGoodCharIndex = negTwo; for (int i = 0; i < stringLength; i++) { char c = s.charAt(i); if ((c == '*' || c == '?') && (lastGoodCharIndex < (i - 1) || isWhitespaceChar(s.charAt(i - 1)))) { continue; } if (c == '\\' || c == ':' || c == '^' || c == '|' || c == '&' || c == '"' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')') { sb.append('\\'); } sb.append(c); lastGoodCharIndex = i; } if (log.isDebugEnabled()) { log.debug("Escaping '" + s + "' as '" + sb.toString() + "'"); } return sb.toString(); } ProjectionSearchRequestBuilder(); @PersistenceContext void setEntityManager(final EntityManager newEntityManager); org.hibernate.search.jpa.FullTextQuery buildQueryFromNativeSearchString(final String nativeSearchString); org.hibernate.search.jpa.FullTextQuery buildQueryFromSearchText(final String searchText); org.hibernate.search.jpa.FullTextQuery buildQueryFromSearchText(final String searchText,
            final String constraints); org.hibernate.search.jpa.FullTextQuery setPaging(final org.hibernate.search.jpa.FullTextQuery query,
            final int from, final int to); String escapeAllButWildcardCharacters(final String s); String escape(final String s); void setResultTypes(final Class< ? >[] theResultTypes); void setSearchStringFormat(final String theSearchStringFormat); void setResultTransformer(final ResultTransformer theResultTransformer); void setQueryParserBuilder(final QueryParserBuilder inQueryParserBuilder); void setResultFields(final List<String> theResultFields); void setAdvancedQueryParserBuilder(final QueryParserBuilder inAdvancedQueryParserBuilder); String getEntityNames();  }