Package org.datanucleus.util

Examples of org.datanucleus.util.RegularExpressionConverter


                {
                    caseSensitive = true;
                    pattern = pattern.substring(4);
                }
                DatabaseAdapter dba = stmt.getDatabaseAdapter();
                RegularExpressionConverter converter = new RegularExpressionConverter(
                    dba.getPatternExpressionZeroMoreCharacters().charAt(0),
                    dba.getPatternExpressionAnyCharacter().charAt(0),
                    dba.getEscapeCharacter().charAt(0));
                if (caseSensitive)
                {
                    SQLExpression patternExpr = exprFactory.newLiteral(stmt,
                        likeExpr.getJavaTypeMapping(), converter.convert(pattern).toLowerCase());
                    return getBooleanLikeExpression(expr.invoke("toLowerCase", null), patternExpr, escapeExpr);
                }
                else
                {
                    SQLExpression patternExpr = exprFactory.newLiteral(stmt,
                        likeExpr.getJavaTypeMapping(), converter.convert(pattern));
                    return getBooleanLikeExpression(expr, patternExpr, escapeExpr);
                }
            }
            else
            {
View Full Code Here


{
    public void testParsePattern()
    {
        //testZZteteAAyyy.dede\--
        String str = "test.*tete.yyy\\.dede\\\\--";
        RegularExpressionConverter parser = new RegularExpressionConverter('Z', 'A', '\\');
        String parsed = parser.convert(str);
        String str_correct = "testZteteAyyy.dede\\\\\\\\--";
        assertTrue("Parsing mised expression gave erroneous string : " + parsed + " but should have been " + str_correct,parsed.equals(str_correct));

        // Empty string
        RegularExpressionConverter parser2 = new RegularExpressionConverter('Z', 'A', '\\');
        assertEquals("",parser2.convert(""));

        // Any character
        str = ".output.";
        RegularExpressionConverter parser3 = new RegularExpressionConverter('Z', 'A', '\\');
        parsed = parser3.convert(str);
        str_correct = "AoutputA";
        assertEquals(str_correct, parsed);

        // "slash\city"
        str = "\"slash\\city\"";
        RegularExpressionConverter parser4 = new RegularExpressionConverter('Z', 'A', '\\');
        parsed = parser4.convert(str);
        str_correct = "\"slash\\\\city\"";
        assertEquals(str_correct, parsed);
    }
View Full Code Here

                caseSensitive = true;
                pattern = pattern.substring(4);
            }

            DatastoreAdapter dba = qs.getStoreManager().getDatastoreAdapter();
            RegularExpressionConverter converter = new RegularExpressionConverter(
                dba.getPatternExpressionZeroMoreCharacters().charAt(0),
                dba.getPatternExpressionAnyCharacter().charAt(0),
                dba.getEscapeCharacter().charAt(0));
            if (caseSensitive)
            {
                StringLiteral patternExpr = new StringLiteral(qs, mapping, converter.convert(pattern).toLowerCase());
                //StringExpression escapedExpr = (StringExpression) qs.getStoreManager().getDatastoreAdapter().getEscapedPatternExpression(patternExpr);
                return new LikeExpression(this.toLowerCaseMethod(), ScalarExpression.OP_LIKE, patternExpr);
            }
            else
            {
                StringLiteral patternExpr = new StringLiteral(qs, mapping, converter.convert(pattern));
                //StringExpression escapedExpr = (StringExpression) qs.getStoreManager().getDatastoreAdapter().getEscapedPatternExpression(patternExpr);
                return new LikeExpression(this, ScalarExpression.OP_LIKE, patternExpr);
            }
        }
        else if (expr instanceof StringExpression)
View Full Code Here

TOP

Related Classes of org.datanucleus.util.RegularExpressionConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.