Search in sources :

Example 6 with ASTLike

use of org.apache.cayenne.exp.parser.ASTLike in project cayenne by apache.

the class ExpressionFactory method containsExp.

/**
 * @since 4.0
 * @see ExpressionFactory#containsExp(String, String)
 */
static Expression containsExp(Expression exp, String value) {
    ASTLike like = likeExpInternal(exp, value, (char) 0);
    LikeExpressionHelper.toContains(like);
    return like;
}
Also used : ASTLike(org.apache.cayenne.exp.parser.ASTLike)

Example 7 with ASTLike

use of org.apache.cayenne.exp.parser.ASTLike in project cayenne by apache.

the class ExpressionFactory method endsWithExp.

/**
 * @since 4.0
 * @see ExpressionFactory#endsWithExp(String, String)
 */
static Expression endsWithExp(Expression exp, String value) {
    ASTLike like = likeExpInternal(exp, value, (char) 0);
    LikeExpressionHelper.toEndsWith(like);
    return like;
}
Also used : ASTLike(org.apache.cayenne.exp.parser.ASTLike)

Example 8 with ASTLike

use of org.apache.cayenne.exp.parser.ASTLike in project cayenne by apache.

the class ExpressionFactory method containsExp.

/**
 * @return An expression for a database "LIKE" query with the value
 *         converted to a pattern matching anywhere in the String.
 * @since 4.0
 */
public static Expression containsExp(String pathSpec, String value) {
    ASTLike like = likeExpInternal(pathSpec, value, (char) 0);
    LikeExpressionHelper.toContains(like);
    return like;
}
Also used : ASTLike(org.apache.cayenne.exp.parser.ASTLike)

Example 9 with ASTLike

use of org.apache.cayenne.exp.parser.ASTLike in project cayenne by apache.

the class LikeExpressionHelperTest method testEscape_OneChar.

@Test
public void testEscape_OneChar() {
    PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "ab_c");
    LikeExpressionHelper.escape(node);
    assertEquals("ab!_c", node.getOperand(1));
    assertEquals('!', node.getEscapeChar());
}
Also used : ASTObjPath(org.apache.cayenne.exp.parser.ASTObjPath) ASTLike(org.apache.cayenne.exp.parser.ASTLike) PatternMatchNode(org.apache.cayenne.exp.parser.PatternMatchNode) Test(org.junit.Test)

Example 10 with ASTLike

use of org.apache.cayenne.exp.parser.ASTLike in project cayenne by apache.

the class LikeExpressionHelperTest method testEscape_NoEscapeChars.

@Test
public void testEscape_NoEscapeChars() {
    PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "abc");
    LikeExpressionHelper.escape(node);
    assertEquals("abc", node.getOperand(1));
    assertEquals(0, node.getEscapeChar());
}
Also used : ASTObjPath(org.apache.cayenne.exp.parser.ASTObjPath) ASTLike(org.apache.cayenne.exp.parser.ASTLike) PatternMatchNode(org.apache.cayenne.exp.parser.PatternMatchNode) Test(org.junit.Test)

Aggregations

ASTLike (org.apache.cayenne.exp.parser.ASTLike)12 ASTObjPath (org.apache.cayenne.exp.parser.ASTObjPath)6 PatternMatchNode (org.apache.cayenne.exp.parser.PatternMatchNode)6 Test (org.junit.Test)6