コード例 #1
0
  @Test
  public void testLikeFilter() throws Exception {
    final String wildcard = "%";
    final String single = "?";
    final String escape = "\\";
    PropertyIsLike like =
        ff.like(
            ff.property("/measurement/determinand_description"),
            "%n_1_1",
            wildcard,
            single,
            escape,
            true,
            MatchAction.ONE);

    PropertyIsLike unmapped = (PropertyIsLike) like.accept(visitor, null);
    assertEquals(like.getLiteral(), unmapped.getLiteral());
    assertEquals(like.getWildCard(), unmapped.getWildCard());
    assertEquals(like.getSingleChar(), unmapped.getSingleChar());
    assertEquals(like.getEscape(), unmapped.getEscape());
    assertEquals(like.isMatchingCase(), unmapped.isMatchingCase());
    assertEquals(like.getMatchAction(), unmapped.getMatchAction());

    Expression unmappedExpr = unmapped.getExpression();
    assertTrue(unmappedExpr instanceof PropertyName);
    assertEquals("determinand_description", ((PropertyName) unmappedExpr).getPropertyName());
  }
コード例 #2
0
 @Override
 public Object visit(PropertyIsLike filter, Object extraData) {
   Expression expr = (Expression) filter.getExpression().accept(this, extraData);
   String pattern = filter.getLiteral();
   String wildcard = filter.getWildCard();
   String singleChar = filter.getSingleChar();
   String escape = filter.getEscape();
   return getFactory(extraData).like(expr, pattern, wildcard, singleChar, escape, false);
 }
コード例 #3
0
 @Override
 public Object visit(PropertyIsLike filter, Object extraData) {
   checkExpressionIsProperty(filter.getExpression());
   StringWriter output = asStringWriter(extraData);
   String pattern = escapeSpecialCharacters(filter.getLiteral(), filter.getEscape());
   pattern = pattern.replace(filter.getWildCard(), ".*");
   pattern = pattern.replace(filter.getSingleChar(), ".{1,1}");
   Expression expr = filter.getExpression();
   ExpressionToSolr visitor = new ExpressionToSolr();
   expr.accept(visitor, output);
   output.append(":/");
   output.append(pattern);
   output.append("/ ");
   return output;
 }