Return-Path: Delivered-To: apmail-cayenne-commits-archive@www.apache.org Received: (qmail 88869 invoked from network); 29 Jan 2011 11:53:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Jan 2011 11:53:25 -0000 Received: (qmail 25182 invoked by uid 500); 29 Jan 2011 11:53:25 -0000 Delivered-To: apmail-cayenne-commits-archive@cayenne.apache.org Received: (qmail 25150 invoked by uid 500); 29 Jan 2011 11:53:24 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 25142 invoked by uid 99); 29 Jan 2011 11:53:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Jan 2011 11:53:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Jan 2011 11:53:20 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A790F23889B3; Sat, 29 Jan 2011 11:53:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1065007 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished: ./ src/main/java/org/apache/cayenne/exp/parser/ src/main/jjtree/org/apache/cayenne/exp/parser/ src/test/java/org/apache/cayenne/exp/ Date: Sat, 29 Jan 2011 11:53:00 -0000 To: commits@cayenne.apache.org From: aadamchik@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110129115300.A790F23889B3@eris.apache.org> Author: aadamchik Date: Sat Jan 29 11:52:59 2011 New Revision: 1065007 URL: http://svn.apache.org/viewvc?rev=1065007&view=rev Log: CAY-1529 Cayenne should support enum types in qualifier statements/expression handling Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ParserUtil.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpEnum1.java Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/pom.xml cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParser.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserConstants.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserTokenManager.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserTreeConstants.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/JJTExpressionParserState.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/jjtree/org/apache/cayenne/exp/parser/ExpressionParser.jjt cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionTest.java Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/pom.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/pom.xml?rev=1065007&r1=1065006&r2=1065007&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/pom.xml (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/pom.xml Sat Jan 29 11:52:59 2011 @@ -155,24 +155,42 @@ Commented out expression executions, as exp/parser package is not properly setup - it stores generated parser in SVN in src/main/java. So the executions below are used for manual - generation - --> - + @@ -213,17 +231,17 @@ true - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + org.apache.cayenne.build-tools maven-cayenne-build-plugin Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParser.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParser.java?rev=1065007&r1=1065006&r2=1065007&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParser.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParser.java Sat Jan 29 11:52:59 2011 @@ -179,6 +179,7 @@ public class ExpressionParser/*@bgen(jjt case 24: case 25: case 26: + case 27: case NULL: case TRUE: case FALSE: @@ -228,6 +229,7 @@ public class ExpressionParser/*@bgen(jjt case 24: case 25: case 26: + case 27: case NULL: case PROPERTY_PATH: case SINGLE_QUOTED_STRING: @@ -774,6 +776,7 @@ public class ExpressionParser/*@bgen(jjt case 24: case 25: case 26: + case 27: case PROPERTY_PATH: case INT_LITERAL: case FLOAT_LITERAL: @@ -836,6 +839,7 @@ public class ExpressionParser/*@bgen(jjt case 24: case 25: case 26: + case 27: case NULL: case PROPERTY_PATH: case SINGLE_QUOTED_STRING: @@ -1142,6 +1146,7 @@ public class ExpressionParser/*@bgen(jjt case 24: case 25: case 26: + case 27: case PROPERTY_PATH: case INT_LITERAL: case FLOAT_LITERAL: @@ -1198,6 +1203,7 @@ public class ExpressionParser/*@bgen(jjt break; case 25: case 26: + case 27: case PROPERTY_PATH: pathExpression(); break; @@ -1309,6 +1315,22 @@ public class ExpressionParser/*@bgen(jjt } } break; + case 27: + jj_consume_token(27); + t = jj_consume_token(PROPERTY_PATH); + ASTScalar jjtn004 = new ASTScalar(JJTSCALAR); + boolean jjtc004 = true; + jjtree.openNodeScope(jjtn004); + try { + jjtree.closeNodeScope(jjtn004, 0); + jjtc004 = false; + jjtn004.setValue(ParserUtil.makeEnum(t.image)); + } finally { + if (jjtc004) { + jjtree.closeNodeScope(jjtn004, 0); + } + } + break; default: jj_la1[24] = jj_gen; jj_consume_token(-1); @@ -1333,10 +1355,10 @@ public class ExpressionParser/*@bgen(jjt jj_la1_init_1(); } private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x2,0x4,0x18,0x87310018,0x60,0x180,0x1010000,0x4fff8,0x4fff8,0x87310000,0x18,0x1010000,0x4e000,0x80000,0x87310000,0x87310000,0x1000000,0x300000,0x300000,0xc00000,0xc00000,0x100000,0x7310000,0x7010000,0x6000000,}; + jj_la1_0 = new int[] {0x2,0x4,0x18,0xf310018,0x60,0x180,0x1010000,0x4fff8,0x4fff8,0xf310000,0x18,0x1010000,0x4e000,0x80000,0xf310000,0xf310000,0x1000000,0x300000,0x300000,0xc00000,0xc00000,0x100000,0xf310000,0xf010000,0xe000000,}; } private static void jj_la1_init_1() { - jj_la1_1 = new int[] {0x0,0x0,0x0,0xe407,0x0,0x0,0x0,0x0,0x0,0xe407,0x0,0x0,0x0,0x0,0xe404,0xe407,0xe403,0x0,0x0,0x0,0x0,0x0,0xc004,0xc004,0x4,}; + jj_la1_1 = new int[] {0x0,0x0,0x0,0x1c80f,0x0,0x0,0x0,0x0,0x0,0x1c80f,0x0,0x0,0x0,0x0,0x1c809,0x1c80f,0x1c806,0x0,0x0,0x0,0x0,0x0,0x18008,0x18008,0x8,}; } /** Constructor with InputStream. */ @@ -1449,14 +1471,14 @@ public class ExpressionParser/*@bgen(jjt return (jj_ntk = jj_nt.kind); } - private java.util.List jj_expentries = new java.util.ArrayList(); + private java.util.List jj_expentries = new java.util.ArrayList(); private int[] jj_expentry; private int jj_kind = -1; /** Generate ParseException. */ public ParseException generateParseException() { jj_expentries.clear(); - boolean[] la1tokens = new boolean[52]; + boolean[] la1tokens = new boolean[53]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; @@ -1473,7 +1495,7 @@ public class ExpressionParser/*@bgen(jjt } } } - for (int i = 0; i < 52; i++) { + for (int i = 0; i < 53; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; @@ -1482,7 +1504,7 @@ public class ExpressionParser/*@bgen(jjt } int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { - exptokseq[i] = (int[])jj_expentries.get(i); + exptokseq[i] = jj_expentries.get(i); } return new ParseException(token, exptokseq, tokenImage); } Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserConstants.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserConstants.java?rev=1065007&r1=1065006&r2=1065007&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserConstants.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserConstants.java Sat Jan 29 11:52:59 2011 @@ -31,39 +31,39 @@ public interface ExpressionParserConstan /** End of File. */ int EOF = 0; /** RegularExpression Id. */ - int NULL = 31; + int NULL = 32; /** RegularExpression Id. */ - int TRUE = 32; + int TRUE = 33; /** RegularExpression Id. */ - int FALSE = 33; + int FALSE = 34; /** RegularExpression Id. */ - int PROPERTY_PATH = 34; + int PROPERTY_PATH = 35; /** RegularExpression Id. */ - int IDENTIFIER = 35; + int IDENTIFIER = 36; /** RegularExpression Id. */ - int LETTER = 36; + int LETTER = 37; /** RegularExpression Id. */ - int DIGIT = 37; + int DIGIT = 38; /** RegularExpression Id. */ - int ESC = 40; + int ESC = 41; /** RegularExpression Id. */ - int SINGLE_QUOTED_STRING = 42; + int SINGLE_QUOTED_STRING = 43; /** RegularExpression Id. */ - int STRING_ESC = 43; + int STRING_ESC = 44; /** RegularExpression Id. */ - int DOUBLE_QUOTED_STRING = 45; + int DOUBLE_QUOTED_STRING = 46; /** RegularExpression Id. */ - int INT_LITERAL = 46; + int INT_LITERAL = 47; /** RegularExpression Id. */ - int FLOAT_LITERAL = 47; + int FLOAT_LITERAL = 48; /** RegularExpression Id. */ - int DEC_FLT = 48; + int DEC_FLT = 49; /** RegularExpression Id. */ - int DEC_DIGITS = 49; + int DEC_DIGITS = 50; /** RegularExpression Id. */ - int EXPONENT = 50; + int EXPONENT = 51; /** RegularExpression Id. */ - int FLT_SUFF = 51; + int FLT_SUFF = 52; /** Lexical state. */ int DEFAULT = 0; @@ -101,6 +101,7 @@ public interface ExpressionParserConstan "\"$\"", "\"obj:\"", "\"db:\"", + "\"enum:\"", "\" \"", "\"\\t\"", "\"\\n\"", @@ -115,10 +116,10 @@ public interface ExpressionParserConstan "\"\\\'\"", "\"\\\"\"", "", - "", + "", "\"\\\'\"", "", - "", + "", "\"\\\"\"", "", "", Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserTokenManager.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserTokenManager.java?rev=1065007&r1=1065006&r2=1065007&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserTokenManager.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserTokenManager.java Sat Jan 29 11:52:59 2011 @@ -39,18 +39,18 @@ public class ExpressionParserTokenManage { int ofs = image.length() - 1; switch ( image.charAt(ofs) ) { - case 'n': return '\n'; - case 'r': return '\r'; - case 't': return '\t'; - case 'b': return '\b'; - case 'f': return '\f'; - case '\\': return '\\'; - case '\'': return '\''; - case '\"': return '\"'; + case 'n': return '\u005cn'; + case 'r': return '\u005cr'; + case 't': return '\u005ct'; + case 'b': return '\u005cb'; + case 'f': return '\u005cf'; + case '\u005c\u005c': return '\u005c\u005c'; + case '\u005c'': return '\u005c''; + case '\u005c"': return '\u005c"'; } // Otherwise, it's an octal number. Find the backslash and convert. - while ( image.charAt(--ofs) != '\\' ) + while ( image.charAt(--ofs) != '\u005c\u005c' ) {} int value = 0; while ( ++ofs < image.length() ) @@ -109,21 +109,21 @@ private final int jjStopStringLiteralDfa switch (pos) { case 0: - if ((active0 & 0x604e006L) != 0L) + if ((active0 & 0xe04e006L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; return 56; } if ((active0 & 0x8L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; return 2; } return -1; case 1: - if ((active0 & 0x604600cL) != 0L) + if ((active0 & 0xe04600cL) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 1; return 56; } @@ -131,9 +131,9 @@ private final int jjStopStringLiteralDfa return 56; return -1; case 2: - if ((active0 & 0x2046000L) != 0L) + if ((active0 & 0xa046000L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 2; return 56; } @@ -141,22 +141,22 @@ private final int jjStopStringLiteralDfa return 56; return -1; case 3: - if ((active0 & 0x6000L) != 0L) - return 56; - if ((active0 & 0x40000L) != 0L) + if ((active0 & 0x8040000L) != 0L) { if (jjmatchedPos != 3) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 3; } return 56; } + if ((active0 & 0x6000L) != 0L) + return 56; return -1; case 4: if ((active0 & 0x44000L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 4; return 56; } @@ -164,7 +164,7 @@ private final int jjStopStringLiteralDfa case 5: if ((active0 & 0x44000L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 5; return 56; } @@ -172,7 +172,7 @@ private final int jjStopStringLiteralDfa case 6: if ((active0 & 0x4000L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 6; return 56; } @@ -182,7 +182,7 @@ private final int jjStopStringLiteralDfa case 7: if ((active0 & 0x4000L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 7; return 56; } @@ -190,7 +190,7 @@ private final int jjStopStringLiteralDfa case 8: if ((active0 & 0x4000L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 8; return 56; } @@ -198,7 +198,7 @@ private final int jjStopStringLiteralDfa case 9: if ((active0 & 0x4000L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 9; return 56; } @@ -206,7 +206,7 @@ private final int jjStopStringLiteralDfa case 10: if ((active0 & 0x4000L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 10; return 56; } @@ -214,7 +214,7 @@ private final int jjStopStringLiteralDfa case 11: if ((active0 & 0x4000L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 11; return 56; } @@ -222,7 +222,7 @@ private final int jjStopStringLiteralDfa case 12: if ((active0 & 0x4000L) != 0L) { - jjmatchedKind = 34; + jjmatchedKind = 35; jjmatchedPos = 12; return 56; } @@ -249,11 +249,11 @@ private int jjMoveStringLiteralDfa0_0() jjmatchedKind = 4; return jjMoveStringLiteralDfa1_0(0x80L); case 34: - return jjStopAtPos(0, 39); + return jjStopAtPos(0, 40); case 36: return jjStopAtPos(0, 24); case 39: - return jjStopAtPos(0, 38); + return jjStopAtPos(0, 39); case 40: return jjStopAtPos(0, 16); case 41: @@ -283,6 +283,8 @@ private int jjMoveStringLiteralDfa0_0() return jjMoveStringLiteralDfa1_0(0x40000L); case 100: return jjMoveStringLiteralDfa1_0(0x4000000L); + case 101: + return jjMoveStringLiteralDfa1_0(0x8000000L); case 105: return jjMoveStringLiteralDfa1_0(0x8000L); case 108: @@ -327,7 +329,7 @@ private int jjMoveStringLiteralDfa1_0(lo case 110: if ((active0 & 0x8000L) != 0L) return jjStartNfaWithStates_0(1, 15, 56); - return jjMoveStringLiteralDfa2_0(active0, 0x4L); + return jjMoveStringLiteralDfa2_0(active0, 0x8000004L); case 111: return jjMoveStringLiteralDfa2_0(active0, 0x8L); case 114: @@ -366,6 +368,8 @@ private int jjMoveStringLiteralDfa2_0(lo if ((active0 & 0x8L) != 0L) return jjStartNfaWithStates_0(2, 3, 56); return jjMoveStringLiteralDfa3_0(active0, 0x40000L); + case 117: + return jjMoveStringLiteralDfa3_0(active0, 0x8000000L); default : break; } @@ -393,6 +397,8 @@ private int jjMoveStringLiteralDfa3_0(lo jjmatchedPos = 3; } return jjMoveStringLiteralDfa4_0(active0, 0x4000L); + case 109: + return jjMoveStringLiteralDfa4_0(active0, 0x8000000L); case 119: return jjMoveStringLiteralDfa4_0(active0, 0x40000L); default : @@ -411,6 +417,10 @@ private int jjMoveStringLiteralDfa4_0(lo } switch(curChar) { + case 58: + if ((active0 & 0x8000000L) != 0L) + return jjStopAtPos(4, 27); + break; case 73: return jjMoveStringLiteralDfa5_0(active0, 0x4000L); case 101: @@ -617,27 +627,27 @@ private int jjMoveNfa_0(int startState, case 56: if ((0x3ff000000000000L & l) != 0L) { - if (kind > 35) - kind = 35; + if (kind > 36) + kind = 36; jjCheckNAddTwoStates(54, 55); } else if (curChar == 43) { - if (kind > 35) - kind = 35; + if (kind > 36) + kind = 36; } else if (curChar == 46) jjstateSet[jjnewStateCnt++] = 52; if ((0x3ff000000000000L & l) != 0L) { - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAddStates(0, 2); } else if (curChar == 43) { - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAdd(51); } break; @@ -648,56 +658,56 @@ private int jjMoveNfa_0(int startState, jjCheckNAdd(30); if ((0x3fe000000000000L & l) != 0L) { - if (kind > 46) - kind = 46; + if (kind > 47) + kind = 47; jjCheckNAddTwoStates(27, 28); } else if (curChar == 48) { - if (kind > 46) - kind = 46; + if (kind > 47) + kind = 47; jjCheckNAddStates(9, 11); } break; case 2: if ((0x3ff000000000000L & l) != 0L) { - if (kind > 35) - kind = 35; + if (kind > 36) + kind = 36; jjCheckNAddTwoStates(54, 55); } else if (curChar == 43) { - if (kind > 35) - kind = 35; + if (kind > 36) + kind = 36; } else if (curChar == 46) jjstateSet[jjnewStateCnt++] = 52; if ((0x3ff000000000000L & l) != 0L) { - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAddStates(0, 2); } else if (curChar == 43) { - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAdd(51); } break; case 26: if ((0x3fe000000000000L & l) == 0L) break; - if (kind > 46) - kind = 46; + if (kind > 47) + kind = 47; jjCheckNAddTwoStates(27, 28); break; case 27: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 46) - kind = 46; + if (kind > 47) + kind = 47; jjCheckNAddTwoStates(27, 28); break; case 29: @@ -707,8 +717,8 @@ private int jjMoveNfa_0(int startState, case 30: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 47) - kind = 47; + if (kind > 48) + kind = 48; jjCheckNAddStates(12, 14); break; case 32: @@ -718,8 +728,8 @@ private int jjMoveNfa_0(int startState, case 33: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 47) - kind = 47; + if (kind > 48) + kind = 48; jjCheckNAddTwoStates(33, 34); break; case 35: @@ -733,15 +743,15 @@ private int jjMoveNfa_0(int startState, case 37: if (curChar != 46) break; - if (kind > 47) - kind = 47; + if (kind > 48) + kind = 48; jjCheckNAddStates(15, 17); break; case 38: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 47) - kind = 47; + if (kind > 48) + kind = 48; jjCheckNAddStates(15, 17); break; case 39: @@ -755,8 +765,8 @@ private int jjMoveNfa_0(int startState, case 42: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 47) - kind = 47; + if (kind > 48) + kind = 48; jjCheckNAddTwoStates(42, 34); break; case 43: @@ -766,36 +776,36 @@ private int jjMoveNfa_0(int startState, case 44: if (curChar != 48) break; - if (kind > 46) - kind = 46; + if (kind > 47) + kind = 47; jjCheckNAddStates(9, 11); break; case 45: if ((0xff000000000000L & l) == 0L) break; - if (kind > 46) - kind = 46; + if (kind > 47) + kind = 47; jjCheckNAddTwoStates(45, 28); break; case 47: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 46) - kind = 46; + if (kind > 47) + kind = 47; jjCheckNAddTwoStates(47, 28); break; case 49: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAddStates(0, 2); break; case 50: if (curChar != 43) break; - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAdd(51); break; case 51: @@ -805,20 +815,20 @@ private int jjMoveNfa_0(int startState, case 53: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAddStates(18, 20); break; case 54: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 35) - kind = 35; + if (kind > 36) + kind = 36; jjCheckNAddTwoStates(54, 55); break; case 55: - if (curChar == 43 && kind > 35) - kind = 35; + if (curChar == 43 && kind > 36) + kind = 36; break; default : break; } @@ -834,22 +844,22 @@ private int jjMoveNfa_0(int startState, case 56: if ((0x7fffffe87fffffeL & l) != 0L) { - if (kind > 35) - kind = 35; + if (kind > 36) + kind = 36; jjCheckNAddTwoStates(54, 55); } if ((0x7fffffe87fffffeL & l) != 0L) { - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAddStates(0, 2); } break; case 3: if ((0x7fffffe87fffffeL & l) != 0L) { - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAddStates(21, 25); } if (curChar == 70) @@ -868,30 +878,30 @@ private int jjMoveNfa_0(int startState, case 2: if ((0x7fffffe87fffffeL & l) != 0L) { - if (kind > 35) - kind = 35; + if (kind > 36) + kind = 36; jjCheckNAddTwoStates(54, 55); } if ((0x7fffffe87fffffeL & l) != 0L) { - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAddStates(0, 2); } if (curChar == 117) jjstateSet[jjnewStateCnt++] = 1; break; case 0: - if (curChar == 108 && kind > 31) - kind = 31; + if (curChar == 108 && kind > 32) + kind = 32; break; case 1: if (curChar == 108) jjstateSet[jjnewStateCnt++] = 0; break; case 4: - if (curChar == 76 && kind > 31) - kind = 31; + if (curChar == 76 && kind > 32) + kind = 32; break; case 5: if (curChar == 76) @@ -906,8 +916,8 @@ private int jjMoveNfa_0(int startState, jjstateSet[jjnewStateCnt++] = 6; break; case 8: - if (curChar == 101 && kind > 32) - kind = 32; + if (curChar == 101 && kind > 33) + kind = 33; break; case 9: if (curChar == 117) @@ -922,8 +932,8 @@ private int jjMoveNfa_0(int startState, jjstateSet[jjnewStateCnt++] = 10; break; case 12: - if (curChar == 69 && kind > 32) - kind = 32; + if (curChar == 69 && kind > 33) + kind = 33; break; case 13: if (curChar == 85) @@ -938,8 +948,8 @@ private int jjMoveNfa_0(int startState, jjstateSet[jjnewStateCnt++] = 14; break; case 16: - if (curChar == 101 && kind > 33) - kind = 33; + if (curChar == 101 && kind > 34) + kind = 34; break; case 17: if (curChar == 115) @@ -958,8 +968,8 @@ private int jjMoveNfa_0(int startState, jjstateSet[jjnewStateCnt++] = 19; break; case 21: - if (curChar == 69 && kind > 33) - kind = 33; + if (curChar == 69 && kind > 34) + kind = 34; break; case 22: if (curChar == 83) @@ -978,16 +988,16 @@ private int jjMoveNfa_0(int startState, jjstateSet[jjnewStateCnt++] = 24; break; case 28: - if ((0x110000001100L & l) != 0L && kind > 46) - kind = 46; + if ((0x110000001100L & l) != 0L && kind > 47) + kind = 47; break; case 31: if ((0x2000000020L & l) != 0L) jjAddStates(26, 27); break; case 34: - if ((0x5400000054L & l) != 0L && kind > 47) - kind = 47; + if ((0x5400000054L & l) != 0L && kind > 48) + kind = 48; break; case 40: if ((0x2000000020L & l) != 0L) @@ -1000,37 +1010,37 @@ private int jjMoveNfa_0(int startState, case 47: if ((0x7e0000007eL & l) == 0L) break; - if (kind > 46) - kind = 46; + if (kind > 47) + kind = 47; jjCheckNAddTwoStates(47, 28); break; case 48: if ((0x7fffffe87fffffeL & l) == 0L) break; - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAddStates(21, 25); break; case 49: if ((0x7fffffe87fffffeL & l) == 0L) break; - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAddStates(0, 2); break; case 52: case 53: if ((0x7fffffe87fffffeL & l) == 0L) break; - if (kind > 34) - kind = 34; + if (kind > 35) + kind = 35; jjCheckNAddStates(18, 20); break; case 54: if ((0x7fffffe87fffffeL & l) == 0L) break; - if (kind > 35) - kind = 35; + if (kind > 36) + kind = 36; jjCheckNAddTwoStates(54, 55); break; default : break; @@ -1082,7 +1092,7 @@ private int jjMoveStringLiteralDfa0_1() switch(curChar) { case 39: - return jjStopAtPos(0, 42); + return jjStopAtPos(0, 43); default : return jjMoveNfa_1(0, 0); } @@ -1112,12 +1122,12 @@ private int jjMoveNfa_1(int startState, switch(jjstateSet[--i]) { case 0: - if ((0xffffff7fffffffffL & l) != 0L && kind > 41) - kind = 41; + if ((0xffffff7fffffffffL & l) != 0L && kind > 42) + kind = 42; break; case 1: - if ((0x8400000000L & l) != 0L && kind > 40) - kind = 40; + if ((0x8400000000L & l) != 0L && kind > 41) + kind = 41; break; case 2: if ((0xf000000000000L & l) != 0L) @@ -1126,13 +1136,13 @@ private int jjMoveNfa_1(int startState, case 3: if ((0xff000000000000L & l) == 0L) break; - if (kind > 40) - kind = 40; + if (kind > 41) + kind = 41; jjstateSet[jjnewStateCnt++] = 4; break; case 4: - if ((0xff000000000000L & l) != 0L && kind > 40) - kind = 40; + if ((0xff000000000000L & l) != 0L && kind > 41) + kind = 41; break; default : break; } @@ -1148,19 +1158,19 @@ private int jjMoveNfa_1(int startState, case 0: if ((0xffffffffefffffffL & l) != 0L) { - if (kind > 41) - kind = 41; + if (kind > 42) + kind = 42; } else if (curChar == 92) jjAddStates(30, 32); break; case 1: - if ((0x14404510000000L & l) != 0L && kind > 40) - kind = 40; + if ((0x14404510000000L & l) != 0L && kind > 41) + kind = 41; break; case 5: - if ((0xffffffffefffffffL & l) != 0L && kind > 41) - kind = 41; + if ((0xffffffffefffffffL & l) != 0L && kind > 42) + kind = 42; break; default : break; } @@ -1178,8 +1188,8 @@ private int jjMoveNfa_1(int startState, switch(jjstateSet[--i]) { case 0: - if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 41) - kind = 41; + if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 42) + kind = 42; break; default : break; } @@ -1215,7 +1225,7 @@ private int jjMoveStringLiteralDfa0_2() switch(curChar) { case 34: - return jjStopAtPos(0, 45); + return jjStopAtPos(0, 46); default : return jjMoveNfa_2(0, 0); } @@ -1239,12 +1249,12 @@ private int jjMoveNfa_2(int startState, switch(jjstateSet[--i]) { case 0: - if ((0xfffffffbffffffffL & l) != 0L && kind > 44) - kind = 44; + if ((0xfffffffbffffffffL & l) != 0L && kind > 45) + kind = 45; break; case 1: - if ((0x8400000000L & l) != 0L && kind > 43) - kind = 43; + if ((0x8400000000L & l) != 0L && kind > 44) + kind = 44; break; case 2: if ((0xf000000000000L & l) != 0L) @@ -1253,13 +1263,13 @@ private int jjMoveNfa_2(int startState, case 3: if ((0xff000000000000L & l) == 0L) break; - if (kind > 43) - kind = 43; + if (kind > 44) + kind = 44; jjstateSet[jjnewStateCnt++] = 4; break; case 4: - if ((0xff000000000000L & l) != 0L && kind > 43) - kind = 43; + if ((0xff000000000000L & l) != 0L && kind > 44) + kind = 44; break; default : break; } @@ -1275,19 +1285,19 @@ private int jjMoveNfa_2(int startState, case 0: if ((0xffffffffefffffffL & l) != 0L) { - if (kind > 44) - kind = 44; + if (kind > 45) + kind = 45; } else if (curChar == 92) jjAddStates(30, 32); break; case 1: - if ((0x14404510000000L & l) != 0L && kind > 43) - kind = 43; + if ((0x14404510000000L & l) != 0L && kind > 44) + kind = 44; break; case 5: - if ((0xffffffffefffffffL & l) != 0L && kind > 44) - kind = 44; + if ((0xffffffffefffffffL & l) != 0L && kind > 45) + kind = 45; break; default : break; } @@ -1305,8 +1315,8 @@ private int jjMoveNfa_2(int startState, switch(jjstateSet[--i]) { case 0: - if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 44) - kind = 44; + if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 45) + kind = 45; break; default : break; } @@ -1348,9 +1358,9 @@ public static final String[] jjstrLitera "", "\157\162", "\141\156\144", "\156\157\164", "\41", "\75", "\75\75", "\41\75", "\74\76", "\74\75", "\74", "\76", "\76\75", "\154\151\153\145", "\154\151\153\145\111\147\156\157\162\145\103\141\163\145", "\151\156", "\50", "\51", "\142\145\164\167\145\145\156", "\54", "\53", "\55", -"\52", "\57", "\44", "\157\142\152\72", "\144\142\72", null, null, null, null, null, +"\52", "\57", "\44", "\157\142\152\72", "\144\142\72", "\145\156\165\155\72", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, }; +null, null, null, null, null, null, null, null, null, null, }; /** Lexer state names. */ public static final String[] lexStateNames = { @@ -1362,23 +1372,23 @@ public static final String[] lexStateNam /** Lex State array. */ public static final int[] jjnewLexState = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, -1, -1, 0, -1, -1, 0, -1, -1, -1, -1, - -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, -1, -1, 0, -1, -1, 0, -1, -1, -1, + -1, -1, -1, }; static final long[] jjtoToken = { - 0xe40f87ffffffL, + 0x1c81f0fffffffL, }; static final long[] jjtoSkip = { - 0x78000000L, + 0xf0000000L, }; static final long[] jjtoMore = { - 0x1bc000000000L, + 0x378000000000L, }; protected JavaCharStream input_stream; private final int[] jjrounds = new int[56]; private final int[] jjstateSet = new int[112]; -private final StringBuffer jjimage = new StringBuffer(); -private StringBuffer image = jjimage; +private final StringBuilder jjimage = new StringBuilder(); +private StringBuilder image = jjimage; private int jjimageLen; private int lengthOfMatch; protected char curChar; @@ -1564,32 +1574,32 @@ void MoreLexicalActions() jjimageLen += (lengthOfMatch = jjmatchedPos + 1); switch(jjmatchedKind) { - case 38 : + case 39 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; stringBuffer = new StringBuffer(); break; - case 39 : + case 40 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; stringBuffer = new StringBuffer(); break; - case 40 : + case 41 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; stringBuffer.append( escapeChar() ); break; - case 41 : + case 42 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; stringBuffer.append( image.charAt(image.length()-1) ); break; - case 43 : + case 44 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; stringBuffer.append( escapeChar() ); break; - case 44 : + case 45 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; stringBuffer.append( image.charAt(image.length()-1) ); @@ -1602,19 +1612,19 @@ void TokenLexicalActions(Token matchedTo { switch(jjmatchedKind) { - case 42 : + case 43 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); literalValue = stringBuffer.toString(); break; - case 45 : + case 46 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); literalValue = stringBuffer.toString(); break; - case 46 : + case 47 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); literalValue = makeInt(); break; - case 47 : + case 48 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); literalValue = makeFloat(); break; Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserTreeConstants.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserTreeConstants.java?rev=1065007&r1=1065006&r2=1065007&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserTreeConstants.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ExpressionParserTreeConstants.java Sat Jan 29 11:52:59 2011 @@ -1,5 +1,4 @@ -/* Generated By:JJTree: Do not edit this line. ./ExpressionParserTreeConstants.java */ - +/* Generated By:JavaCC: Do not edit this line. ExpressionParserTreeConstants.java Version 5.0 */ package org.apache.cayenne.exp.parser; public interface ExpressionParserTreeConstants @@ -69,3 +68,4 @@ public interface ExpressionParserTreeCon "DbPath", }; } +/* JavaCC - OriginalChecksum=238d7dc8bb4d7ce029d1935e3afc53f0 (do not edit this line) */ Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/JJTExpressionParserState.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/JJTExpressionParserState.java?rev=1065007&r1=1065006&r2=1065007&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/JJTExpressionParserState.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/JJTExpressionParserState.java Sat Jan 29 11:52:59 2011 @@ -1,38 +1,17 @@ -/* Generated By:JJTree: Do not edit this line. src/cayenne/java/org.apache.cayenne/exp/parser/JJTExpressionParserState.java */ - -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - - +/* Generated By:JavaCC: Do not edit this line. JJTExpressionParserState.java Version 5.0 */ package org.apache.cayenne.exp.parser; -class JJTExpressionParserState { - private java.util.Stack nodes; - private java.util.Stack marks; +public class JJTExpressionParserState { + private java.util.List nodes; + private java.util.List marks; - private int sp; // number of nodes on stack - private int mk; // current mark + private int sp; // number of nodes on stack + private int mk; // current mark private boolean node_created; - JJTExpressionParserState() { - nodes = new java.util.Stack(); - marks = new java.util.Stack(); + public JJTExpressionParserState() { + nodes = new java.util.ArrayList(); + marks = new java.util.ArrayList(); sp = 0; mk = 0; } @@ -40,62 +19,62 @@ class JJTExpressionParserState { /* Determines whether the current node was actually closed and pushed. This should only be called in the final user action of a node scope. */ - boolean nodeCreated() { + public boolean nodeCreated() { return node_created; } /* Call this to reinitialize the node stack. It is called automatically by the parser's ReInit() method. */ - void reset() { - nodes.removeAllElements(); - marks.removeAllElements(); + public void reset() { + nodes.clear(); + marks.clear(); sp = 0; mk = 0; } /* Returns the root node of the AST. It only makes sense to call this after a successful parse. */ - Node rootNode() { - return (Node)nodes.elementAt(0); + public Node rootNode() { + return nodes.get(0); } /* Pushes a node on to the stack. */ - void pushNode(Node n) { - nodes.push(n); + public void pushNode(Node n) { + nodes.add(n); ++sp; } /* Returns the node on the top of the stack, and remove it from the stack. */ - Node popNode() { + public Node popNode() { if (--sp < mk) { - mk = ((Integer)marks.pop()).intValue(); + mk = marks.remove(marks.size()-1); } - return (Node)nodes.pop(); + return nodes.remove(nodes.size()-1); } /* Returns the node currently on the top of the stack. */ - Node peekNode() { - return (Node)nodes.peek(); + public Node peekNode() { + return nodes.get(nodes.size()-1); } /* Returns the number of children on the stack in the current node scope. */ - int nodeArity() { + public int nodeArity() { return sp - mk; } - void clearNodeScope(Node n) { + public void clearNodeScope(Node n) { while (sp > mk) { popNode(); } - mk = ((Integer)marks.pop()).intValue(); + mk = marks.remove(marks.size()-1); } - void openNodeScope(Node n) { - marks.push(Integer.valueOf(mk)); + public void openNodeScope(Node n) { + marks.add(mk); mk = sp; n.jjtOpen(); } @@ -105,8 +84,8 @@ class JJTExpressionParserState { children. That number of nodes are popped from the stack and made the children of the definite node. Then the definite node is pushed on to the stack. */ - void closeNodeScope(Node n, int num) { - mk = ((Integer)marks.pop()).intValue(); + public void closeNodeScope(Node n, int num) { + mk = marks.remove(marks.size()-1); while (num-- > 0) { Node c = popNode(); c.jjtSetParent(n); @@ -120,24 +99,25 @@ class JJTExpressionParserState { /* A conditional node is constructed if its condition is true. All the nodes that have been pushed since the node was opened are - made children of the the conditional node, which is then pushed + made children of the conditional node, which is then pushed on to the stack. If the condition is false the node is not constructed and they are left on the stack. */ - void closeNodeScope(Node n, boolean condition) { + public void closeNodeScope(Node n, boolean condition) { if (condition) { int a = nodeArity(); - mk = ((Integer)marks.pop()).intValue(); + mk = marks.remove(marks.size()-1); while (a-- > 0) { - Node c = popNode(); - c.jjtSetParent(n); - n.jjtAddChild(c, a); + Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, a); } n.jjtClose(); pushNode(n); node_created = true; } else { - mk = ((Integer)marks.pop()).intValue(); + mk = marks.remove(marks.size()-1); node_created = false; } } } +/* JavaCC - OriginalChecksum=b1c8a6064ef7a507929d26284938a24b (do not edit this line) */ Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ParserUtil.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ParserUtil.java?rev=1065007&view=auto ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ParserUtil.java (added) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ParserUtil.java Sat Jan 29 11:52:59 2011 @@ -0,0 +1,58 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + ****************************************************************/ +package org.apache.cayenne.exp.parser; + +import org.apache.cayenne.util.Util; + +class ParserUtil { + + static Object makeEnum(String enumPath) throws ParseException { + + if (enumPath == null) { + throw new ParseException("Null 'enumPath'"); + } + + int dot = enumPath.lastIndexOf('.'); + if (dot <= 0 || dot == enumPath.length() - 1) { + throw new ParseException("Invalid enum path: " + enumPath); + } + + String className = enumPath.substring(0, dot); + String enumName = enumPath.substring(dot + 1); + + Class enumClass; + try { + enumClass = Util.getJavaClass(className); + } + catch (ClassNotFoundException e) { + throw new ParseException("Enum class not found: " + className); + } + + if (!enumClass.isEnum()) { + throw new ParseException("Specified class is not an enum: " + className); + } + + try { + return Enum.valueOf(enumClass, enumName); + } + catch (IllegalArgumentException e) { + throw new ParseException("Invalid enum path: " + enumPath); + } + } +} Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/jjtree/org/apache/cayenne/exp/parser/ExpressionParser.jjt URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/jjtree/org/apache/cayenne/exp/parser/ExpressionParser.jjt?rev=1065007&r1=1065006&r2=1065007&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/jjtree/org/apache/cayenne/exp/parser/ExpressionParser.jjt (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/jjtree/org/apache/cayenne/exp/parser/ExpressionParser.jjt Sat Jan 29 11:52:59 2011 @@ -252,6 +252,9 @@ void pathExpression() : { | "db:" t = { jjtThis.setPath(t.image); } #DbPath(0) + | + "enum:" + t = { jjtThis.setValue(ParserUtil.makeEnum(t.image)); } #Scalar(0) ) } Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpEnum1.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpEnum1.java?rev=1065007&view=auto ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpEnum1.java (added) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpEnum1.java Sat Jan 29 11:52:59 2011 @@ -0,0 +1,24 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + ****************************************************************/ +package org.apache.cayenne.exp; + +public enum ExpEnum1 { + + ONE, TWO, THREE +} Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionTest.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionTest.java?rev=1065007&r1=1065006&r2=1065007&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionTest.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionTest.java Sat Jan 29 11:52:59 2011 @@ -28,8 +28,6 @@ import junit.framework.TestCase; import org.apache.cayenne.ObjectId; import org.apache.cayenne.testdo.testmap.Artist; -/** - */ public class ExpressionTest extends TestCase { public void testFromStringLong() { @@ -51,6 +49,41 @@ public class ExpressionTest extends Test assertEquals(Expression.DB_PATH, e4.getType()); } + public void testFromStringScalar() { + Expression e1 = Expression.fromString("a = 'abc'"); + assertEquals("abc", e1.getOperand(1)); + } + + public void testFromStringEnum() { + Expression e1 = Expression + .fromString("a = enum:org.apache.cayenne.exp.ExpEnum1.ONE"); + assertEquals(ExpEnum1.ONE, e1.getOperand(1)); + + Expression e2 = Expression + .fromString("a = enum:org.apache.cayenne.exp.ExpEnum1.TWO"); + assertEquals(ExpEnum1.TWO, e2.getOperand(1)); + + Expression e3 = Expression + .fromString("a = enum:org.apache.cayenne.exp.ExpEnum1.THREE"); + assertEquals(ExpEnum1.THREE, e3.getOperand(1)); + + try { + Expression.fromString("a = enum:org.apache.cayenne.exp.ExpEnum1.BOGUS"); + fail("Didn't throw on bad enum"); + } + catch (ExpressionException e) { + // expected + } + + try { + Expression.fromString("a = enum:BOGUS"); + fail("Didn't throw on bad enum"); + } + catch (ExpressionException e) { + // expected + } + } + public void testExpWithParametersNullHandling_CAY847() { Expression e = Expression.fromString("X = $x"); @@ -107,9 +140,9 @@ public class ExpressionTest extends Test assertEquals("x.artistName in ('a', 'b', 'c')", ejbql); } - + public void testEncodeAsEJBQL_PersistentParamater() { - + Artist a = new Artist(); ObjectId aId = new ObjectId("Artist", Artist.ARTIST_ID_PK_COLUMN, 1); a.setObjectId(aId); @@ -125,7 +158,7 @@ public class ExpressionTest extends Test assertEquals("x.artist = 1", ejbql); } - + public void testEncodeAsEJBQLNotEquals() { Expression e = Expression.fromString("artistName != 'bla'");