Search in sources :

Example 1 with ASTLike

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

the class LikeExpressionHelperTest method testEscape_TwoChars_Mix.

@Test
public void testEscape_TwoChars_Mix() {
    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 2 with ASTLike

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

the class LikeExpressionHelperTest method testEscape_AltEscapeChar2.

@Test
public void testEscape_AltEscapeChar2() {
    PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "a!%c#_");
    LikeExpressionHelper.escape(node);
    assertEquals("a!$%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 3 with ASTLike

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

the class ExpressionFactory method startsWithExp.

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

Example 4 with ASTLike

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

the class ExpressionFactory method startsWithExp.

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

Example 5 with ASTLike

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

the class ExpressionFactory method endsWithExp.

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

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