JcrSqlQueryParser extends BasicSqlQueryParser { @Override protected String removeBracketsAndQuotes( String text, Position position ) { if (text.length() > 0) { char firstChar = text.charAt(0); switch (firstChar) { case '\'': assert text.charAt(text.length() - 1) == firstChar; return removeBracketsAndQuotes(text.substring(1, text.length() - 1), position); } } return text; } JcrSqlQueryParser(); @Override String getLanguage(); @SuppressWarnings( "deprecation" )
    static final String LANGUAGE; }
@Test public void shouldRemoveBracketsAndQuotes() { assertThat(parser.removeBracketsAndQuotes("string", null), is("string")); assertThat(parser.removeBracketsAndQuotes("'string'", null), is("string")); assertThat(parser.removeBracketsAndQuotes("word one and two", null), is("word one and two")); assertThat(parser.removeBracketsAndQuotes("'word one and two'", null), is("word one and two")); }
@Test public void shouldFailToRemoveDoubleQuotesAroundOneWord() { assertThat(parser.removeBracketsAndQuotes("\"string\"", null), is("\"string\"")); assertThat(parser.removeBracketsAndQuotes("\"string\"", null), is("\"string\"")); assertThat(parser.removeBracketsAndQuotes("\"word one and two\"", null), is("\"word one and two\"")); assertThat(parser.removeBracketsAndQuotes("[word one and two]", null), is("[word one and two]")); }