Revision: 9665
http://datanucleus.svn.sourceforge.net/datanucleus/?rev=9665&view=rev
Author: andy_jefferson
Date: 2010-04-23 09:04:27 +0000 (Fri, 23 Apr 2010)
Log Message:
-----------
Replace Node types with NodeType enum
Modified Paths:
--------------
platform/core/trunk/src/java/org/datanucleus/query/compiler/JDOQLParser.java
platform/core/trunk/src/java/org/datanucleus/query/compiler/JPQLParser.java
platform/core/trunk/src/java/org/datanucleus/query/compiler/JavaQueryCompiler.java
platform/core/trunk/src/java/org/datanucleus/query/expression/ExpressionCompiler.java
platform/core/trunk/src/java/org/datanucleus/query/node/Node.java
platform/core/trunk/src/java/org/datanucleus/query/node/NodeType.java
platform/core/trunk/src/java/org/datanucleus/query/node/ParameterNode.java
Modified: platform/core/trunk/src/java/org/datanucleus/query/compiler/JDOQLParser.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/query/compiler/JDOQLParser.java 2010-04-23 08:01:11 UTC (rev 9664)
+++ platform/core/trunk/src/java/org/datanucleus/query/compiler/JDOQLParser.java 2010-04-23 09:04:27 UTC (rev 9665)
@@ -33,6 +33,7 @@
import org.datanucleus.exceptions.NucleusUserException;
import org.datanucleus.query.JDOQLQueryHelper;
import org.datanucleus.query.node.Node;
+import org.datanucleus.query.node.NodeType;
import org.datanucleus.query.node.ParameterNode;
import org.datanucleus.store.query.QueryCompilerSyntaxException;
import org.datanucleus.util.Localiser;
@@ -162,8 +163,8 @@
}
// Create candidate class node with alias, and put at top of stack
- Node classNode = new Node(Node.CLASS, className);
- Node aliasNode = new Node(Node.NAME, alias);
+ Node classNode = new Node(NodeType.CLASS, className);
+ Node aliasNode = new Node(NodeType.NAME, alias);
classNode.insertChildNode(aliasNode);
stack.push(classNode);
@@ -219,7 +220,7 @@
}
if (alias != null)
{
- Node aliasNode = new Node(Node.NAME, alias);
+ Node aliasNode = new Node(NodeType.NAME, alias);
expr.appendChildNode(aliasNode);
}
@@ -304,8 +305,8 @@
}
String classDecl = subTokeniser.nextToken();
String parameterName = subTokeniser.nextToken();
- Node declNode = new Node(Node.IDENTIFIER, classDecl);
- Node nameNode = new Node(Node.IDENTIFIER, parameterName);
+ Node declNode = new Node(NodeType.IDENTIFIER, classDecl);
+ Node nameNode = new Node(NodeType.IDENTIFIER, parameterName);
nodes.add(new Node[]{declNode, nameNode});
}
@@ -321,22 +322,22 @@
if (p.parseString("ascending") || p.parseString("asc") ||
p.parseString("ASCENDING") || p.parseString("ASC"))
{
- Node expr = new Node(Node.OPERATOR, "ascending");
+ Node expr = new Node(NodeType.OPERATOR, "ascending");
stack.push(expr);
}
else if (p.parseString("descending") || p.parseString("desc") ||
p.parseString("DESCENDING") || p.parseString("DESC"))
{
- Node expr = new Node(Node.OPERATOR, "descending");
+ Node expr = new Node(NodeType.OPERATOR, "descending");
stack.push(expr);
}
else
{
// Default to ascending
- Node expr = new Node(Node.OPERATOR, "ascending");
+ Node expr = new Node(NodeType.OPERATOR, "ascending");
stack.push(expr);
}
- Node expr = new Node(Node.OPERATOR, "order");
+ Node expr = new Node(NodeType.OPERATOR, "order");
expr.insertChildNode(stack.pop());
if (!stack.empty())
{
@@ -367,7 +368,7 @@
while (p.parseString("||"))
{
processConditionalAndExpression();
- Node expr = new Node(Node.OPERATOR, "||");
+ Node expr = new Node(NodeType.OPERATOR, "||");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -386,7 +387,7 @@
while (p.parseString("&&"))
{
processInclusiveOrExpression();
- Node expr = new Node(Node.OPERATOR, "&&");
+ Node expr = new Node(NodeType.OPERATOR, "&&");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -400,7 +401,7 @@
while (p.parseChar('|', '|'))
{
processExclusiveOrExpression();
- Node expr = new Node(Node.OPERATOR, "|");
+ Node expr = new Node(NodeType.OPERATOR, "|");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -414,7 +415,7 @@
while (p.parseChar('^'))
{
processAndExpression();
- Node expr = new Node(Node.OPERATOR, "^");
+ Node expr = new Node(NodeType.OPERATOR, "^");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -428,7 +429,7 @@
while (p.parseChar('&', '&'))
{
processRelationalExpression();
- Node expr = new Node(Node.OPERATOR, "&");
+ Node expr = new Node(NodeType.OPERATOR, "&");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -447,7 +448,7 @@
if (p.parseString("=="))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, "==");
+ Node expr = new Node(NodeType.OPERATOR, "==");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -455,7 +456,7 @@
else if (p.parseString("!="))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, "!=");
+ Node expr = new Node(NodeType.OPERATOR, "!=");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -468,7 +469,7 @@
else if (p.parseString("<="))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, "<=");
+ Node expr = new Node(NodeType.OPERATOR, "<=");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -476,7 +477,7 @@
else if (p.parseString(">="))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, ">=");
+ Node expr = new Node(NodeType.OPERATOR, ">=");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -484,7 +485,7 @@
else if (p.parseChar('<'))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, "<");
+ Node expr = new Node(NodeType.OPERATOR, "<");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -492,7 +493,7 @@
else if (p.parseChar('>'))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, ">");
+ Node expr = new Node(NodeType.OPERATOR, ">");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -500,7 +501,7 @@
else if (p.parseString("instanceof"))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, "instanceof");
+ Node expr = new Node(NodeType.OPERATOR, "instanceof");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -521,7 +522,7 @@
if (p.parseChar('+'))
{
processMultiplicativeExpression();
- Node expr = new Node(Node.OPERATOR, "+");
+ Node expr = new Node(NodeType.OPERATOR, "+");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -529,7 +530,7 @@
else if (p.parseChar('-'))
{
processMultiplicativeExpression();
- Node expr = new Node(Node.OPERATOR, "-");
+ Node expr = new Node(NodeType.OPERATOR, "-");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -550,7 +551,7 @@
if (p.parseChar('*'))
{
processUnaryExpression();
- Node expr = new Node(Node.OPERATOR, "*");
+ Node expr = new Node(NodeType.OPERATOR, "*");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -558,7 +559,7 @@
else if (p.parseChar('/'))
{
processUnaryExpression();
- Node expr = new Node(Node.OPERATOR, "/");
+ Node expr = new Node(NodeType.OPERATOR, "/");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -566,7 +567,7 @@
else if (p.parseChar('%'))
{
processUnaryExpression();
- Node expr = new Node(Node.OPERATOR, "%");
+ Node expr = new Node(NodeType.OPERATOR, "%");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -597,21 +598,21 @@
else if (p.parseChar('-'))
{
processUnaryExpression();
- Node expr = new Node(Node.OPERATOR, "-");
+ Node expr = new Node(NodeType.OPERATOR, "-");
expr.insertChildNode(stack.pop());
stack.push(expr);
}
else if (p.parseChar('~'))
{
processUnaryExpression();
- Node expr = new Node(Node.OPERATOR, "~");
+ Node expr = new Node(NodeType.OPERATOR, "~");
expr.insertChildNode(stack.pop());
stack.push(expr);
}
else if (p.parseChar('!'))
{
processUnaryExpression();
- Node expr = new Node(Node.OPERATOR, "!");
+ Node expr = new Node(NodeType.OPERATOR, "!");
expr.insertChildNode(stack.pop());
stack.push(expr);
}
@@ -631,7 +632,7 @@
if (p.parseString("DISTINCT ") || p.parseString("distinct"))
{
// Aggregates can have "count(DISTINCT field1)"
- Node distinctNode = new Node(Node.OPERATOR, "DISTINCT");
+ Node distinctNode = new Node(NodeType.OPERATOR, "DISTINCT");
processExpression();
Node identifierNode = stack.pop();
distinctNode.appendChildNode(identifierNode);
@@ -846,7 +847,7 @@
return false;
}
- Node castNode = new Node(Node.CAST, typeName);
+ Node castNode = new Node(NodeType.CAST, typeName);
stack.push(castNode);
return true;
}
@@ -891,7 +892,7 @@
peek.insertChildNode(top);
}
Node expr = stack.pop();
- Node newExpr = new Node(Node.CREATOR);
+ Node newExpr = new Node(NodeType.CREATOR);
newExpr.insertChildNode(expr);
stack.push(newExpr);
return true;
@@ -924,7 +925,7 @@
}
// Found syntax for a method, so invoke the method
- Node expr = new Node(Node.INVOKE, method);
+ Node expr = new Node(NodeType.INVOKE, method);
if (!p.parseChar(')'))
{
int numArgs = 0;
@@ -977,13 +978,13 @@
}
}
- Node arrayNode = new Node(Node.ARRAY, elements);
+ Node arrayNode = new Node(NodeType.ARRAY, elements);
stack.push(arrayNode);
// Check for "length" since won't be picked up by processMethod
if (p.parseString(".length"))
{
- Node lengthMethod = new Node(Node.INVOKE, "length");
+ Node lengthMethod = new Node(NodeType.INVOKE, "length");
arrayNode.appendChildNode(lengthMethod);
}
@@ -1043,7 +1044,7 @@
return false;
}
- stack.push(new Node(Node.LITERAL, litValue));
+ stack.push(new Node(NodeType.LITERAL, litValue));
return true;
}
@@ -1070,14 +1071,14 @@
}
// Named parameter - stored as String
- Node expr = new ParameterNode(Node.PARAMETER, id.substring(1), parameterPosition);
+ Node expr = new ParameterNode(NodeType.PARAMETER, id.substring(1), parameterPosition);
parameterPosition++;
stack.push(expr);
return true;
}
else
{
- Node expr = new Node(Node.IDENTIFIER, id);
+ Node expr = new Node(NodeType.IDENTIFIER, id);
stack.push(expr);
return true;
}
Modified: platform/core/trunk/src/java/org/datanucleus/query/compiler/JPQLParser.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/query/compiler/JPQLParser.java 2010-04-23 08:01:11 UTC (rev 9664)
+++ platform/core/trunk/src/java/org/datanucleus/query/compiler/JPQLParser.java 2010-04-23 09:04:27 UTC (rev 9665)
@@ -28,6 +28,7 @@
import org.datanucleus.exceptions.NucleusException;
import org.datanucleus.exceptions.NucleusUserException;
import org.datanucleus.query.node.Node;
+import org.datanucleus.query.node.NodeType;
import org.datanucleus.query.node.ParameterNode;
import org.datanucleus.store.query.QueryCompilerSyntaxException;
import org.datanucleus.store.query.QueryInvalidParametersException;
@@ -149,7 +150,7 @@
}
if (alias != null)
{
- Node aliasNode = new Node(Node.NAME, alias.toLowerCase()); // Save all aliases in lowercase
+ Node aliasNode = new Node(NodeType.NAME, alias.toLowerCase()); // Save all aliases in lowercase
node.appendChildNode(aliasNode);
}
@@ -266,13 +267,13 @@
// Find what we are joining to
String name = p.parseIdentifier();
- Node joinedNode = new Node(Node.IDENTIFIER, name);
+ Node joinedNode = new Node(NodeType.IDENTIFIER, name);
Node parentNode = joinedNode;
while (p.nextIsDot())
{
p.parseChar('.');
String subName = p.parseIdentifier();
- Node subNode = new Node(Node.IDENTIFIER, subName);
+ Node subNode = new Node(NodeType.IDENTIFIER, subName);
parentNode.appendChildNode(subNode);
parentNode = subNode;
}
@@ -286,15 +287,15 @@
String alias = p.parseIdentifier();
// Create candidate class node with alias, and put at top of stack
- Node classNode = new Node(Node.CLASS, candidateClassName);
- Node classAliasNode = new Node(Node.NAME, candidateAlias);
+ Node classNode = new Node(NodeType.CLASS, candidateClassName);
+ Node classAliasNode = new Node(NodeType.NAME, candidateAlias);
classNode.insertChildNode(classAliasNode);
stack.push(classNode);
// Translate the "IN(...) alias" into the equivalent JOIN syntax nodes
- Node joinNode = new Node(Node.OPERATOR, "JOIN_INNER");
+ Node joinNode = new Node(NodeType.OPERATOR, "JOIN_INNER");
joinNode.appendChildNode(joinedNode);
- Node joinAliasNode = new Node(Node.NAME, alias);
+ Node joinAliasNode = new Node(NodeType.NAME, alias);
joinNode.appendChildNode(joinAliasNode);
classNode.appendChildNode(joinNode);
@@ -329,8 +330,8 @@
}
// Create candidate class node with alias, and put at top of stack
- Node classNode = new Node(Node.CLASS, className);
- Node aliasNode = new Node(Node.NAME, alias);
+ Node classNode = new Node(NodeType.CLASS, className);
+ Node aliasNode = new Node(NodeType.NAME, alias);
classNode.insertChildNode(aliasNode);
stack.push(classNode);
@@ -395,12 +396,12 @@
// Find what we are joining to
String id = p.parseIdentifier();
- Node joinedNode = new Node(Node.IDENTIFIER, id);
+ Node joinedNode = new Node(NodeType.IDENTIFIER, id);
Node parentNode = joinedNode;
while (p.nextIsDot())
{
p.parseChar('.');
- Node subNode = new Node(Node.IDENTIFIER, p.parseName());
+ Node subNode = new Node(NodeType.IDENTIFIER, p.parseName());
parentNode.appendChildNode(subNode);
parentNode = subNode;
}
@@ -418,9 +419,9 @@
{
joinType = (fetch ? "JOIN_OUTER_FETCH" : "JOIN_OUTER");
}
- Node joinNode = new Node(Node.OPERATOR, joinType);
+ Node joinNode = new Node(NodeType.OPERATOR, joinType);
joinNode.appendChildNode(joinedNode);
- Node joinedAliasNode = new Node(Node.NAME, alias);
+ Node joinedAliasNode = new Node(NodeType.NAME, alias);
joinNode.appendChildNode(joinedAliasNode);
candidateNode.appendChildNode(joinNode);
}
@@ -444,22 +445,22 @@
processExpression();
if (p.parseStringIgnoreCase("asc"))
{
- Node expr = new Node(Node.OPERATOR, "ascending");
+ Node expr = new Node(NodeType.OPERATOR, "ascending");
stack.push(expr);
}
else if (p.parseStringIgnoreCase("desc"))
{
- Node expr = new Node(Node.OPERATOR, "descending");
+ Node expr = new Node(NodeType.OPERATOR, "descending");
stack.push(expr);
}
else
{
// Default to ascending
- Node expr = new Node(Node.OPERATOR, "ascending");
+ Node expr = new Node(NodeType.OPERATOR, "ascending");
stack.push(expr);
}
- Node expr = new Node(Node.OPERATOR, "order");
+ Node expr = new Node(NodeType.OPERATOR, "order");
expr.insertChildNode(stack.pop());
if (!stack.empty())
{
@@ -489,7 +490,7 @@
while (p.parseStringIgnoreCase("OR "))
{
processAndExpression();
- Node expr = new Node(Node.OPERATOR, "||");
+ Node expr = new Node(NodeType.OPERATOR, "||");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -508,7 +509,7 @@
while (p.parseStringIgnoreCase("AND "))
{
processRelationalExpression();
- Node expr = new Node(Node.OPERATOR, "&&");
+ Node expr = new Node(NodeType.OPERATOR, "&&");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -529,27 +530,27 @@
processAdditiveExpression();
Node right = stack.pop();
Node left = stack.pop();
- if (right.getNodeType() == Node.TYPE)
+ if (right.getNodeType() == NodeType.TYPE)
{
// Convert TYPE into "instanceof"
Node primNode = right.getFirstChild();
- Node expr = new Node(Node.OPERATOR, "instanceof");
+ Node expr = new Node(NodeType.OPERATOR, "instanceof");
expr.appendChildNode(primNode);
expr.appendChildNode(left);
stack.push(expr);
}
- else if (left.getNodeType() == Node.TYPE)
+ else if (left.getNodeType() == NodeType.TYPE)
{
// Convert TYPE into "instanceof"
Node primNode = left.getFirstChild();
- Node expr = new Node(Node.OPERATOR, "instanceof");
+ Node expr = new Node(NodeType.OPERATOR, "instanceof");
expr.appendChildNode(primNode);
expr.appendChildNode(right);
stack.push(expr);
}
else
{
- Node expr = new Node(Node.OPERATOR, "==");
+ Node expr = new Node(NodeType.OPERATOR, "==");
expr.insertChildNode(right);
expr.insertChildNode(left);
stack.push(expr);
@@ -560,31 +561,31 @@
processAdditiveExpression();
Node right = stack.pop();
Node left = stack.pop();
- if (right.getNodeType() == Node.TYPE)
+ if (right.getNodeType() == NodeType.TYPE)
{
// Convert TYPE into "instanceof"
Node primNode = right.getFirstChild();
- Node expr = new Node(Node.OPERATOR, "instanceof");
+ Node expr = new Node(NodeType.OPERATOR, "instanceof");
expr.appendChildNode(primNode);
expr.appendChildNode(left);
- Node notNode = new Node(Node.OPERATOR, "!");
+ Node notNode = new Node(NodeType.OPERATOR, "!");
notNode.appendChildNode(expr);
stack.push(notNode);
}
- else if (left.getNodeType() == Node.TYPE)
+ else if (left.getNodeType() == NodeType.TYPE)
{
// Convert TYPE into "instanceof"
Node primNode = left.getFirstChild();
- Node expr = new Node(Node.OPERATOR, "instanceof");
+ Node expr = new Node(NodeType.OPERATOR, "instanceof");
expr.appendChildNode(primNode);
expr.appendChildNode(right);
- Node notNode = new Node(Node.OPERATOR, "!");
+ Node notNode = new Node(NodeType.OPERATOR, "!");
notNode.appendChildNode(expr);
stack.push(notNode);
}
else
{
- Node expr = new Node(Node.OPERATOR, "!=");
+ Node expr = new Node(NodeType.OPERATOR, "!=");
expr.insertChildNode(right);
expr.insertChildNode(left);
stack.push(expr);
@@ -603,15 +604,15 @@
processAdditiveExpression();
Node upperNode = stack.pop();
- Node leftNode = new Node(Node.OPERATOR, "<");
+ Node leftNode = new Node(NodeType.OPERATOR, "<");
leftNode.appendChildNode(inputNode);
leftNode.appendChildNode(lowerNode);
- Node rightNode = new Node(Node.OPERATOR, ">");
+ Node rightNode = new Node(NodeType.OPERATOR, ">");
rightNode.appendChildNode(inputNode);
rightNode.appendChildNode(upperNode);
- Node betweenNode = new Node(Node.OPERATOR, "||");
+ Node betweenNode = new Node(NodeType.OPERATOR, "||");
betweenNode.appendChildNode(leftNode);
betweenNode.appendChildNode(rightNode);
stack.push(betweenNode);
@@ -624,7 +625,7 @@
else if (p.parseStringIgnoreCase("LIKE "))
{
processLikeExpression();
- Node notNode = new Node(Node.OPERATOR, "!");
+ Node notNode = new Node(NodeType.OPERATOR, "!");
notNode.insertChildNode(stack.pop());
stack.push(notNode);
}
@@ -652,15 +653,15 @@
{
processAdditiveExpression();
Node upperNode = stack.pop();
- Node leftNode = new Node(Node.OPERATOR, ">=");
+ Node leftNode = new Node(NodeType.OPERATOR, ">=");
leftNode.appendChildNode(inputNode);
leftNode.appendChildNode(lowerNode);
- Node rightNode = new Node(Node.OPERATOR, "<=");
+ Node rightNode = new Node(NodeType.OPERATOR, "<=");
rightNode.appendChildNode(inputNode);
rightNode.appendChildNode(upperNode);
- Node betweenNode = new Node(Node.OPERATOR, "&&");
+ Node betweenNode = new Node(NodeType.OPERATOR, "&&");
betweenNode.appendChildNode(rightNode);
betweenNode.appendChildNode(leftNode);
stack.push(betweenNode);
@@ -689,7 +690,7 @@
// {expression} IS [NOT] [NULL | EMPTY]
Node inputNode = stack.pop();
Node inputRootNode = inputNode;
- if (inputNode.getNodeType() == Node.IDENTIFIER)
+ if (inputNode.getNodeType() == NodeType.IDENTIFIER)
{
// Find the end of the identifier chain
while (inputNode.getFirstChild() != null)
@@ -706,8 +707,8 @@
if (p.parseStringIgnoreCase("NULL"))
{
- Node isNode = new Node(Node.OPERATOR, (not ? "!=" : "=="));
- Node compareNode = new Node(Node.LITERAL, null);
+ Node isNode = new Node(NodeType.OPERATOR, (not ? "!=" : "=="));
+ Node compareNode = new Node(NodeType.LITERAL, null);
isNode.insertChildNode(compareNode);
isNode.insertChildNode(inputRootNode);
stack.push(isNode);
@@ -715,11 +716,11 @@
else if (p.parseStringIgnoreCase("EMPTY"))
{
// Convert IS EMPTY to a method call of "size()==0" on collection/map
- Node sizeNode = new Node(Node.INVOKE, "size");
+ Node sizeNode = new Node(NodeType.INVOKE, "size");
inputNode.insertChildNode(sizeNode);
- Node isEmptyNode = new Node(Node.OPERATOR, not ? "!=" : "==");
+ Node isEmptyNode = new Node(NodeType.OPERATOR, not ? "!=" : "==");
isEmptyNode.appendChildNode(inputNode);
- Node zeroNode = new Node(Node.LITERAL, 0);
+ Node zeroNode = new Node(NodeType.LITERAL, 0);
isEmptyNode.appendChildNode(zeroNode);
stack.push(isEmptyNode);
}
@@ -732,7 +733,7 @@
else if (p.parseString("<="))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, "<=");
+ Node expr = new Node(NodeType.OPERATOR, "<=");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -740,7 +741,7 @@
else if (p.parseString(">="))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, ">=");
+ Node expr = new Node(NodeType.OPERATOR, ">=");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -748,7 +749,7 @@
else if (p.parseChar('<'))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, "<");
+ Node expr = new Node(NodeType.OPERATOR, "<");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -756,7 +757,7 @@
else if (p.parseChar('>'))
{
processAdditiveExpression();
- Node expr = new Node(Node.OPERATOR, ">");
+ Node expr = new Node(NodeType.OPERATOR, ">");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -778,7 +779,7 @@
{
Node primaryNode = stack.pop();
Node primaryRootNode = primaryNode;
- if (primaryNode.getNodeType() == Node.IDENTIFIER)
+ if (primaryNode.getNodeType() == NodeType.IDENTIFIER)
{
// Make sure we put the INVOKE at the end of the identifier chain
while (primaryNode.getFirstChild() != null)
@@ -795,7 +796,7 @@
// Return matchesNode with 2 property nodes - the pattern expression, and the escape char
processAdditiveExpression();
Node escapeNode = stack.pop();
- Node matchesNode = new Node(Node.INVOKE, "matches");
+ Node matchesNode = new Node(NodeType.INVOKE, "matches");
matchesNode.addProperty(likeExprNode);
matchesNode.addProperty(escapeNode);
@@ -805,7 +806,7 @@
else
{
// Return matchesNode with 1 property node - the pattern expression
- Node matchesNode = new Node(Node.INVOKE, "matches");
+ Node matchesNode = new Node(NodeType.INVOKE, "matches");
matchesNode.addProperty(likeExprNode);
primaryNode.appendChildNode(matchesNode);
@@ -828,7 +829,7 @@
if (!p.parseChar('('))
{
// Subquery
- Node inNode = new Node(Node.OPERATOR, "IN");
+ Node inNode = new Node(NodeType.OPERATOR, "IN");
inNode.appendChildNode(inputNode);
processExpression(); // subquery variable
@@ -855,7 +856,7 @@
Node valueNode = stack.pop();
p.skipWS();
- if (numArgs == 1 && !p.peekStringIgnoreCase(",") && valueNode.getNodeType() == Node.PARAMETER &&
+ if (numArgs == 1 && !p.peekStringIgnoreCase(",") && valueNode.getNodeType() == NodeType.PARAMETER &&
parameterValues != null && parameterValues.containsKey(valueNode.getNodeValue()))
{
// Special case of "xxx IN :param" where param is multiple-valued
@@ -865,7 +866,7 @@
// Node (PARAMETER, param)
// ---> Node (INVOKE, "contains")
// ---> Node(IDENTIFIER, inputNode)
- Node containsNode = new Node(Node.INVOKE, "contains");
+ Node containsNode = new Node(NodeType.INVOKE, "contains");
containsNode.addProperty(inputNode);
valueNode.appendChildNode(containsNode);
inNode = valueNode;
@@ -873,7 +874,7 @@
}
}
- Node compareNode = new Node(Node.OPERATOR, (not ? "!=" : "=="));
+ Node compareNode = new Node(NodeType.OPERATOR, (not ? "!=" : "=="));
compareNode.appendChildNode(inputNode);
compareNode.appendChildNode(valueNode);
@@ -883,7 +884,7 @@
}
else
{
- Node newInNode = new Node(Node.OPERATOR, (not ? "&&" : "||"));
+ Node newInNode = new Node(NodeType.OPERATOR, (not ? "&&" : "||"));
newInNode.appendChildNode(inNode);
newInNode.appendChildNode(compareNode);
inNode = newInNode;
@@ -919,7 +920,7 @@
if (not)
{
- Node notNode = new Node(Node.OPERATOR, "!");
+ Node notNode = new Node(NodeType.OPERATOR, "!");
stack.pop();
notNode.insertChildNode(containerNode);
stack.push(notNode);
@@ -928,7 +929,7 @@
// Node (IDENTIFIER, container)
// ---> Node (INVOKE, "contains")
// ---> Node(IDENTIFIER, containsNode)
- Node containsNode = new Node(Node.INVOKE, "contains");
+ Node containsNode = new Node(NodeType.INVOKE, "contains");
containsNode.addProperty(inputNode);
containerNode.appendChildNode(containsNode);
}
@@ -940,7 +941,7 @@
*/
private void processCaseExpression()
{
- Node caseNode = new Node(Node.CASE);
+ Node caseNode = new Node(NodeType.CASE);
while (p.parseStringIgnoreCase("WHEN "))
{
processExpression();
@@ -974,7 +975,7 @@
if (p.parseChar('+'))
{
processMultiplicativeExpression();
- Node expr = new Node(Node.OPERATOR, "+");
+ Node expr = new Node(NodeType.OPERATOR, "+");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -982,7 +983,7 @@
else if (p.parseChar('-'))
{
processMultiplicativeExpression();
- Node expr = new Node(Node.OPERATOR, "-");
+ Node expr = new Node(NodeType.OPERATOR, "-");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -1003,7 +1004,7 @@
if (p.parseChar('*'))
{
processUnaryExpression();
- Node expr = new Node(Node.OPERATOR, "*");
+ Node expr = new Node(NodeType.OPERATOR, "*");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -1011,7 +1012,7 @@
else if (p.parseChar('/'))
{
processUnaryExpression();
- Node expr = new Node(Node.OPERATOR, "/");
+ Node expr = new Node(NodeType.OPERATOR, "/");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -1019,7 +1020,7 @@
else if (p.parseChar('%'))
{
processUnaryExpression();
- Node expr = new Node(Node.OPERATOR, "%");
+ Node expr = new Node(NodeType.OPERATOR, "%");
expr.insertChildNode(stack.pop());
expr.insertChildNode(stack.pop());
stack.push(expr);
@@ -1050,14 +1051,14 @@
else if (p.parseChar('-'))
{
processUnaryExpression();
- Node expr = new Node(Node.OPERATOR, "-");
+ Node expr = new Node(NodeType.OPERATOR, "-");
expr.insertChildNode(stack.pop());
stack.push(expr);
}
else if (p.parseStringIgnoreCase("NOT "))
{
processRelationalExpression();
- Node expr = new Node(Node.OPERATOR, "!");
+ Node expr = new Node(NodeType.OPERATOR, "!");
expr.insertChildNode(stack.pop());
stack.push(expr);
}
@@ -1103,7 +1104,7 @@
}
if (subqueryKeyword != null && subqueryNode != null)
{
- Node subNode = new Node(Node.SUBQUERY, subqueryKeyword);
+ Node subNode = new Node(NodeType.SUBQUERY, subqueryKeyword);
subNode.appendChildNode(subqueryNode);
stack.push(subNode);
return;
@@ -1112,21 +1113,21 @@
if (p.parseStringIgnoreCase("CURRENT_DATE"))
{
// Convert to a method call
- Node node = new Node(Node.INVOKE, "CURRENT_DATE");
+ Node node = new Node(NodeType.INVOKE, "CURRENT_DATE");
stack.push(node);
return;
}
else if (p.parseStringIgnoreCase("CURRENT_TIMESTAMP"))
{
// Convert to a method call
- Node node = new Node(Node.INVOKE, "CURRENT_TIMESTAMP");
+ Node node = new Node(NodeType.INVOKE, "CURRENT_TIMESTAMP");
stack.push(node);
return;
}
else if (p.parseStringIgnoreCase("CURRENT_TIME"))
{
// Convert to a method call
- Node node = new Node(Node.INVOKE, "CURRENT_TIME");
+ Node node = new Node(NodeType.INVOKE, "CURRENT_TIME");
stack.push(node);
return;
}
@@ -1138,7 +1139,7 @@
else if (p.parseStringIgnoreCase("DISTINCT "))
{
// Aggregates can have "count(DISTINCT field1)"
- Node distinctNode = new Node(Node.OPERATOR, "DISTINCT");
+ Node distinctNode = new Node(NodeType.OPERATOR, "DISTINCT");
processExpression();
Node identifierNode = stack.pop();
distinctNode.appendChildNode(identifierNode);
@@ -1243,7 +1244,7 @@
peek.insertChildNode(top);
}
Node node = stack.pop();
- Node newNode = new Node(Node.CREATOR);
+ Node newNode = new Node(NodeType.CREATOR);
newNode.insertChildNode(node);
stack.push(newNode);
return true;
@@ -1299,7 +1300,7 @@
else if (method.equalsIgnoreCase("MOD"))
{
// Convert to be {first} % {second}
- Node modNode = new Node(Node.OPERATOR, "%");
+ Node modNode = new Node(NodeType.OPERATOR, "%");
processExpression(); // argument 1
Node firstNode = stack.pop();
if (!p.parseChar(','))
@@ -1320,7 +1321,7 @@
else if (method.equalsIgnoreCase("TYPE"))
{
// Convert to a TYPE node with the primary as a child node
- Node typeNode = new Node(Node.TYPE);
+ Node typeNode = new Node(NodeType.TYPE);
processExpression(); // argument
Node typePrimaryNode = stack.pop();
typeNode.appendChildNode(typePrimaryNode);
@@ -1335,7 +1336,7 @@
{
// SUBSTRING(string_primary, simple_arithmetic_expression[, simple_arithmetic_expression])
// Convert to be {primary}.INVOKE(substring, {arg1[, arg2]})
- Node invokeNode = new Node(Node.INVOKE, "substring");
+ Node invokeNode = new Node(NodeType.INVOKE, "substring");
processExpression();
Node primaryNode = stack.pop();
if (!p.parseChar(','))
@@ -1346,8 +1347,8 @@
// First arg to substring(...) has origin 0, but JPQL has origin 1!
processExpression();
Node arg1 = stack.pop();
- Node oneNode = new Node(Node.LITERAL, 1);
- Node arg1Node = new Node(Node.OPERATOR, "-");
+ Node oneNode = new Node(NodeType.LITERAL, 1);
+ Node arg1Node = new Node(NodeType.OPERATOR, "-");
arg1Node.insertChildNode(arg1);
arg1Node.appendChildNode(oneNode);
@@ -1357,7 +1358,7 @@
// Second arg to substring(...) has origin 0, but in JPQL is length of result!
processExpression();
Node arg2 = stack.pop();
- Node arg2Node = new Node(Node.OPERATOR, "+");
+ Node arg2Node = new Node(NodeType.OPERATOR, "+");
arg2Node.appendChildNode(arg2);
arg2Node.appendChildNode(arg1Node);
if (!p.parseChar(')'))
@@ -1388,7 +1389,7 @@
{
// UPPER(string_primary)
// Convert to be {primary}.INVOKE(toUpper)
- Node invokeNode = new Node(Node.INVOKE, "toUpperCase");
+ Node invokeNode = new Node(NodeType.INVOKE, "toUpperCase");
processExpression();
if (!p.parseChar(')'))
{
@@ -1409,7 +1410,7 @@
{
// UPPER(string_primary)
// Convert to be {primary}.INVOKE(toLower)
- Node invokeNode = new Node(Node.INVOKE, "toLowerCase");
+ Node invokeNode = new Node(NodeType.INVOKE, "toLowerCase");
processExpression();
if (!p.parseChar(')'))
{
@@ -1430,7 +1431,7 @@
{
// LENGTH(string_primary)
// Convert to be {primary}.INVOKE(length)
- Node invokeNode = new Node(Node.INVOKE, "length");
+ Node invokeNode = new Node(NodeType.INVOKE, "length");
processExpression();
if (!p.parseChar(')'))
{
@@ -1464,7 +1465,7 @@
processExpression();
Node thisNode = stack.pop();
- Node currentNode = new Node(Node.OPERATOR, "+");
+ Node currentNode = new Node(NodeType.OPERATOR, "+");
currentNode.appendChildNode(prevNode);
currentNode.appendChildNode(thisNode);
if (p.parseChar(')'))
@@ -1482,7 +1483,7 @@
// Convert to ({stringExpr}.indexOf(strExpr[, posExpr]) + 1)
processExpression();
Node searchNode = stack.pop();
- Node invokeNode = new Node(Node.INVOKE, "indexOf");
+ Node invokeNode = new Node(NodeType.INVOKE, "indexOf");
invokeNode.addProperty(searchNode);
if (!p.parseChar(','))
{
@@ -1498,12 +1499,12 @@
}
primaryNode.appendChildNode(invokeNode);
- Node oneNode = new Node(Node.LITERAL, 1);
+ Node oneNode = new Node(NodeType.LITERAL, 1);
if (p.parseChar(','))
{
processExpression();
Node fromPosNode = stack.pop();
- Node positionNode = new Node(Node.OPERATOR, "-");
+ Node positionNode = new Node(NodeType.OPERATOR, "-");
positionNode.appendChildNode(fromPosNode);
positionNode.appendChildNode(oneNode);
invokeNode.addProperty(positionNode);
@@ -1513,7 +1514,7 @@
throw new QueryCompilerSyntaxException("')' expected", p.getIndex(), p.getInput());
}
- Node locateNode = new Node(Node.OPERATOR, "+");
+ Node locateNode = new Node(NodeType.OPERATOR, "+");
locateNode.appendChildNode(primaryRootNode);
locateNode.appendChildNode(oneNode);
stack.push(locateNode);
@@ -1536,7 +1537,7 @@
{
// Default
}
- Node invokeNode = new Node(Node.INVOKE, methodName);
+ Node invokeNode = new Node(NodeType.INVOKE, methodName);
Node trimCharNode = null;
processExpression();
@@ -1550,7 +1551,7 @@
}
else
{
- if (next.getNodeType() == Node.LITERAL)
+ if (next.getNodeType() == NodeType.LITERAL)
{
// TRIM(dir trimChar FROM string_primary)
trimCharNode = next;
@@ -1561,7 +1562,7 @@
processExpression();
next = stack.pop();
}
- else if (next.getNodeType() == Node.IDENTIFIER)
+ else if (next.getNodeType() == NodeType.IDENTIFIER)
{
// TRIM(dir FROM string_primary)
Object litValue = next.getNodeValue();
@@ -1599,7 +1600,7 @@
{
// SIZE(collection_valued_path_expression)
// Convert to be {primary}.INVOKE(size)
- Node invokeNode = new Node(Node.INVOKE, "size");
+ Node invokeNode = new Node(NodeType.INVOKE, "size");
processExpression();
if (!p.parseChar(')'))
{
@@ -1620,7 +1621,7 @@
{
// KEY(identification_variable)
// Convert to be {primary}.INVOKE(mapKey)
- Node invokeNode = new Node(Node.INVOKE, "mapKey");
+ Node invokeNode = new Node(NodeType.INVOKE, "mapKey");
processExpression();
if (!p.parseChar(')'))
{
@@ -1641,7 +1642,7 @@
{
// VALUE(identification_variable)
// Convert to be {primary}.INVOKE(mapValue)
- Node invokeNode = new Node(Node.INVOKE, "mapValue");
+ Node invokeNode = new Node(NodeType.INVOKE, "mapValue");
processExpression();
if (!p.parseChar(')'))
{
@@ -1662,7 +1663,7 @@
{
// ENTRY(identification_variable)
// Convert to be {primary}.INVOKE(mapEntry)
- Node invokeNode = new Node(Node.INVOKE, "mapEntry");
+ Node invokeNode = new Node(NodeType.INVOKE, "mapEntry");
processExpression();
if (!p.parseChar(')'))
{
@@ -1683,7 +1684,7 @@
{
// Found syntax for a method, so invoke the method
// TODO What if the method is not supported for JPQL?
- Node node = new Node(Node.INVOKE, method);
+ Node node = new Node(NodeType.INVOKE, method);
if (!p.parseChar(')'))
{
do
@@ -1757,7 +1758,7 @@
return false;
}
- stack.push(new Node(Node.LITERAL, litValue));
+ stack.push(new Node(NodeType.LITERAL, litValue));
return true;
}
@@ -1790,7 +1791,7 @@
String paramName = id.substring(1);
try
{
- Node node = new ParameterNode(Node.PARAMETER, Integer.valueOf(paramName), parameterPosition);
+ Node node = new ParameterNode(NodeType.PARAMETER, Integer.valueOf(paramName), parameterPosition);
parameterPosition++;
stack.push(node);
return true;
@@ -1811,14 +1812,14 @@
{
throw new QueryInvalidParametersException("Query is using numbered parameters yet also has \"" + id + "\"");
}
- Node node = new ParameterNode(Node.PARAMETER, id.substring(1), parameterPosition);
+ Node node = new ParameterNode(NodeType.PARAMETER, id.substring(1), parameterPosition);
parameterPosition++;
stack.push(node);
return true;
}
else
{
- Node node = new Node(Node.IDENTIFIER, id);
+ Node node = new Node(NodeType.IDENTIFIER, id);
stack.push(node);
return true;
}
Modified: platform/core/trunk/src/java/org/datanucleus/query/compiler/JavaQueryCompiler.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/query/compiler/JavaQueryCompiler.java 2010-04-23 08:01:11 UTC (rev 9664)
+++ platform/core/trunk/src/java/org/datanucleus/query/compiler/JavaQueryCompiler.java 2010-04-23 09:04:27 UTC (rev 9665)
@@ -42,6 +42,7 @@
import org.datanucleus.query.expression.PrimaryExpressionIsVariableException;
import org.datanucleus.query.expression.VariableExpression;
import org.datanucleus.query.node.Node;
+import org.datanucleus.query.node.NodeType;
import org.datanucleus.query.symbol.PropertySymbol;
import org.datanucleus.query.symbol.Symbol;
import org.datanucleus.query.symbol.SymbolResolver;
@@ -206,7 +207,7 @@
for (int j=0;j<children.size();j++)
{
Node child = (Node)children.get(j);
- if (child.getNodeType() == Node.NAME) // Alias - maybe should assume it is the first child
+ if (child.getNodeType() == NodeType.NAME) // Alias - maybe should assume it is the first child
{
classAlias = (String)child.getNodeValue();
}
@@ -230,7 +231,7 @@
{
// Add entries in symbol table for any joined aliases
Node childNode = (Node)childIter.next();
- if (childNode.getNodeType() == Node.OPERATOR)
+ if (childNode.getNodeType() == NodeType.OPERATOR)
{
Node joinedNode = childNode.getFirstChild();
String joinedAlias = (String)joinedNode.getNodeValue();
@@ -283,7 +284,7 @@
}
Node aliasNode = childNode.getNextChild();
- if (aliasNode.getNodeType() == Node.NAME)
+ if (aliasNode.getNodeType() == NodeType.NAME)
{
symtbl.addSymbol(new PropertySymbol((String)aliasNode.getNodeValue(), joinedCls));
}
@@ -462,20 +463,20 @@
switch (node.getNodeType())
{
- case Node.IDENTIFIER :
+ case IDENTIFIER :
if (node.getNodeValue().equals(candidateAliasOrig))
{
node.setNodeValue(candidateAlias);
}
break;
- case Node.OPERATOR :
+ case OPERATOR :
while (node.hasNextChild())
{
Node childNode = node.getNextChild();
swapCandidateAliasNodeName(childNode);
}
break;
- case Node.INVOKE :
+ case INVOKE :
if (node.hasProperties())
{
Iterator<Node> propIter = node.getProperties().iterator();
@@ -486,17 +487,17 @@
}
}
break;
- case Node.CAST :
+ case CAST :
Node childNode = node.getChildNode(0);
swapCandidateAliasNodeName(childNode);
break;
- case Node.NAME :
- case Node.CLASS :
- case Node.CASE :
- case Node.PARAMETER :
- case Node.SUBQUERY :
- case Node.LITERAL :
+ case NAME :
+ case CLASS :
+ case CASE :
+ case PARAMETER :
+ case SUBQUERY :
+ case LITERAL :
break;
default :
// TODO Update other node types
@@ -518,7 +519,7 @@
Node swapNode = null;
switch (node.getNodeType())
{
- case Node.PARAMETER :
+ case PARAMETER :
// Swap the parameter for node(s) for the value
Object paramName = node.getNodeValue();
if (parameterSubtitutionMap.containsKey(paramName))
@@ -533,7 +534,7 @@
swapNode = parser.parse(paramValue);
}
return swapNode;
- case Node.OPERATOR :
+ case OPERATOR :
List childNodes = node.getChildNodes();
for (int i=0;i<childNodes.size();i++)
{
@@ -542,7 +543,7 @@
node.insertChildNode(swappedNode, i);
}
break;
- case Node.INVOKE :
+ case INVOKE :
if (node.hasProperties())
{
List<Node> propNodes = node.getProperties();
@@ -584,7 +585,7 @@
while (node[i].hasNextChild())
{
Node childNode = node[i].getNextChild();
- if (childNode.getNodeType() == Node.NAME)
+ if (childNode.getNodeType() == NodeType.NAME)
{
// Alias node
aliasNode = childNode;
Modified: platform/core/trunk/src/java/org/datanucleus/query/expression/ExpressionCompiler.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/query/expression/ExpressionCompiler.java 2010-04-23 08:01:11 UTC (rev 9664)
+++ platform/core/trunk/src/java/org/datanucleus/query/expression/ExpressionCompiler.java 2010-04-23 09:04:27 UTC (rev 9665)
@@ -31,6 +31,7 @@
import org.datanucleus.query.expression.JoinExpression.JoinType;
import org.datanucleus.query.node.Node;
+import org.datanucleus.query.node.NodeType;
import org.datanucleus.query.node.ParameterNode;
import org.datanucleus.query.symbol.Symbol;
import org.datanucleus.query.symbol.SymbolTable;
@@ -78,7 +79,7 @@
*/
public Expression compileFromExpression(Node node, boolean classIsExpression)
{
- if (node.getNodeType() == Node.CLASS)
+ if (node.getNodeType() == NodeType.CLASS)
{
Node aliasNode = node.getFirstChild();
@@ -96,7 +97,7 @@
while (childIter.hasNext())
{
Node childNode = (Node)childIter.next();
- if (childNode.getNodeType() == Node.OPERATOR)
+ if (childNode.getNodeType() == NodeType.OPERATOR)
{
String joinType = (String)childNode.getNodeValue();
JoinType joinTypeId = JoinType.JOIN_INNER;
@@ -318,7 +319,7 @@
private Expression compilePrimaryExpression(Node node)
{
- if (node.getNodeType() == Node.IDENTIFIER)
+ if (node.getNodeType() == NodeType.IDENTIFIER)
{
Node currentNode = node;
List tupple = new ArrayList();
@@ -327,7 +328,7 @@
{
tupple.add(currentNode.getNodeValue());
- if (currentNode.getNodeType() == Node.INVOKE)
+ if (currentNode.getNodeType() == NodeType.INVOKE)
{
if (currentExpr == null && tupple.size() > 1)
{
@@ -382,7 +383,7 @@
currentNode = currentNode.getFirstChild();
tupple = new ArrayList();
}
- else if (currentNode.getNodeType() == Node.CAST)
+ else if (currentNode.getNodeType() == NodeType.CAST)
{
if (currentExpr == null && tupple.size() > 1)
{
@@ -472,7 +473,7 @@
return currentExpr;
}
- else if (node.getNodeType() == Node.PARAMETER)
+ else if (node.getNodeType() == NodeType.PARAMETER)
{
// "{paramExpr}", "{paramExpr}.invoke(...)", "{paramExpr}.invoke(...).invoke(...)"
Object val = node.getNodeValue();
@@ -493,13 +494,13 @@
Node childNode = node.getFirstChild();
while (childNode != null)
{
- if (childNode.getNodeType() == Node.INVOKE)
+ if (childNode.getNodeType() == NodeType.INVOKE)
{
String methodName = (String)childNode.getNodeValue();
List parameterExprs = getExpressionsForPropertiesOfNode(childNode);
currentExpr = new InvokeExpression(currentExpr, methodName, parameterExprs);
}
- else if (childNode.getNodeType() == Node.IDENTIFIER)
+ else if (childNode.getNodeType() == NodeType.IDENTIFIER)
{
String identifier = childNode.getNodeId();
List tuples = new ArrayList();
@@ -515,7 +516,7 @@
}
return currentExpr;
}
- else if (node.getNodeType() == Node.INVOKE)
+ else if (node.getNodeType() == NodeType.INVOKE)
{
Node currentNode = node;
List tupple = new ArrayList();
@@ -524,7 +525,7 @@
{
tupple.add(currentNode.getNodeValue());
- if (currentNode.getNodeType() == Node.INVOKE)
+ if (currentNode.getNodeType() == NodeType.INVOKE)
{
String methodName = (String)tupple.get(tupple.size()-1);
List parameterExprs = getExpressionsForPropertiesOfNode(currentNode);
@@ -546,7 +547,7 @@
}
return currentExpr;
}
- else if (node.getNodeType() == Node.CREATOR)
+ else if (node.getNodeType() == NodeType.CREATOR)
{
Node currentNode = node.getFirstChild();
List tupple = new ArrayList();
@@ -554,7 +555,7 @@
while (currentNode != null)
{
tupple.add(currentNode.getNodeValue());
- if (currentNode.getNodeType() == Node.INVOKE)
+ if (currentNode.getNodeType() == NodeType.INVOKE)
{
method = true;
break;
@@ -573,7 +574,7 @@
}
return new CreatorExpression(tupple, parameterExprs);
}
- else if (node.getNodeType() == Node.LITERAL)
+ else if (node.getNodeType() == NodeType.LITERAL)
{
Node currentNode = node;
List tupple = new ArrayList();
@@ -582,7 +583,7 @@
{
tupple.add(currentNode.getNodeValue());
- if (currentNode.getNodeType() == Node.INVOKE)
+ if (currentNode.getNodeType() == NodeType.INVOKE)
{
if (currentExpr == null && tupple.size() > 1)
{
@@ -609,7 +610,7 @@
}
return currentExpr;
}
- else if (node.getNodeType() == Node.ARRAY)
+ else if (node.getNodeType() == NodeType.ARRAY)
{
Node currentNode = node;
List<Node> arrayElements = (List<Node>)node.getNodeValue();
@@ -625,7 +626,7 @@
{
type = element.getNodeValue().getClass();
}
- if (element.getNodeType() == Node.IDENTIFIER)
+ if (element.getNodeType() == NodeType.IDENTIFIER)
{
literal = false;
break;
@@ -661,7 +662,7 @@
{
tupple.add(currentNode.getNodeValue());
- if (currentNode.getNodeType() == Node.INVOKE)
+ if (currentNode.getNodeType() == NodeType.INVOKE)
{
if (currentExpr == null && tupple.size() > 1)
{
@@ -684,7 +685,7 @@
return currentExpr;
}
- else if (node.getNodeType() == Node.SUBQUERY)
+ else if (node.getNodeType() == NodeType.SUBQUERY)
{
List children = node.getChildNodes();
if (children.size() != 1)
@@ -696,7 +697,7 @@
Expression currentExpr = new SubqueryExpression((String)node.getNodeValue(), subqueryExpr);
return currentExpr;
}
- else if (node.getNodeType() == Node.CASE)
+ else if (node.getNodeType() == NodeType.CASE)
{
// Node with children in the order "when", "action"[, "when", "action"], "else"
List<Node> children = node.getChildNodes();
@@ -750,6 +751,6 @@
private boolean isOperator(Node node, String operator)
{
- return node.getNodeType() == Node.OPERATOR && node.getNodeValue().equals(operator);
+ return node.getNodeType() == NodeType.OPERATOR && node.getNodeValue().equals(operator);
}
}
\ No newline at end of file
Modified: platform/core/trunk/src/java/org/datanucleus/query/node/Node.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/query/node/Node.java 2010-04-23 08:01:11 UTC (rev 9664)
+++ platform/core/trunk/src/java/org/datanucleus/query/node/Node.java 2010-04-23 09:04:27 UTC (rev 9665)
@@ -30,47 +30,8 @@
*/
public class Node
{
- /** literal node type **/
- public final static int LITERAL = 0;
-
- /** invoke node type. Such as method/function invocation. **/
- public final static int INVOKE = 1;
-
- /** type name node type. Not defined what this was for so now being used for aliases in from clause. **/
- public final static int NAME = 2;
-
- /** identifier node type **/
- public final static int IDENTIFIER = 3;
-
- /** operator node type. **/
- public final static int OPERATOR = 4;
-
- /** creator node type. Such as new X(). **/
- public final static int CREATOR = 5;
-
- /** class node type (e.g use in a "from" clause for a candidate). **/
- public final static int CLASS = 6;
-
- /** parameter node type **/
- public final static int PARAMETER = 7;
-
- /** cast node type **/
- public final static int CAST = 8;
-
- /** array node type **/
- public final static int ARRAY = 9;
-
- /** subquery node type (EXISTS, ANY, SOME, ALL, etc) **/
- public final static int SUBQUERY = 10;
-
- /** "type" node type **/
- public final static int TYPE = 11;
-
- /** "CASE" node type **/
- public final static int CASE = 12;
-
/** Type of node. */
- protected int nodeType;
+ protected NodeType nodeType;
/** Value of the node. */
protected Object nodeValue;
@@ -89,18 +50,18 @@
/** List of properties for the node. Used for invocation of methods, representing the arguments. */
protected List<Node> properties = null;
- public Node(int nodeType)
+ public Node(NodeType nodeType)
{
this.nodeType = nodeType;
}
- public Node(int nodeType, Object nodeValue)
+ public Node(NodeType nodeType, Object nodeValue)
{
this.nodeType = nodeType;
this.nodeValue = nodeValue;
}
- public int getNodeType()
+ public NodeType getNodeType()
{
return nodeType;
}
@@ -241,7 +202,7 @@
{
Node node = this;
StringBuffer sb = new StringBuffer();
- while (node != null && node.getNodeType() == Node.IDENTIFIER)
+ while (node != null && node.getNodeType() == NodeType.IDENTIFIER)
{
if (sb.length() > 0)
{
@@ -257,7 +218,7 @@
{
Node node = this;
StringBuffer sb = new StringBuffer();
- while (node != null && node.getNodeType() == Node.IDENTIFIER)
+ while (node != null && node.getNodeType() == NodeType.IDENTIFIER)
{
if (sb.length() > 0)
{
@@ -289,59 +250,7 @@
{
StringBuffer sb = new StringBuffer();
sb.append(indent(indentation));
- String nodeTypeStr = null;
- if (this.nodeType == LITERAL)
- {
- nodeTypeStr = "LITERAL";
- }
- else if (this.nodeType == INVOKE)
- {
- nodeTypeStr = "INVOKE";
- }
- else if (this.nodeType == NAME)
- {
- nodeTypeStr = "NAME";
- }
- else if (this.nodeType == IDENTIFIER)
- {
- nodeTypeStr = "IDENTIFIER";
- }
- else if (this.nodeType == OPERATOR)
- {
- nodeTypeStr = "OPERATOR";
- }
- else if (this.nodeType == CREATOR)
- {
- nodeTypeStr = "CREATOR";
- }
- else if (this.nodeType == CLASS)
- {
- nodeTypeStr = "CLASS";
- }
- else if (this.nodeType == PARAMETER)
- {
- nodeTypeStr = "PARAMETER";
- }
- else if (this.nodeType == CAST)
- {
- nodeTypeStr = "CAST";
- }
- else if (this.nodeType == ARRAY)
- {
- nodeTypeStr = "ARRAY";
- }
- else if (this.nodeType == SUBQUERY)
- {
- nodeTypeStr = "SUBQUERY";
- }
- else if (this.nodeType == TYPE)
- {
- nodeTypeStr = "TYPE";
- }
- else if (this.nodeType == CASE)
- {
- nodeTypeStr = "CASE";
- }
+ String nodeTypeStr = nodeType.toString();
sb.append("[" + nodeTypeStr + " : " + nodeValue);
if (properties != null)
@@ -360,7 +269,7 @@
if (childNodes.size() > 0)
{
- if (nodeType == Node.LITERAL || nodeType == Node.IDENTIFIER)
+ if (nodeType == NodeType.LITERAL || nodeType == NodeType.IDENTIFIER)
{
sb.append(".");
}
@@ -379,7 +288,7 @@
}
}
- if (nodeType != Node.LITERAL && nodeType != Node.IDENTIFIER)
+ if (nodeType != NodeType.LITERAL && nodeType != NodeType.IDENTIFIER)
{
sb.append(indent(indentation));
sb.append("}");
Modified: platform/core/trunk/src/java/org/datanucleus/query/node/NodeType.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/query/node/NodeType.java 2010-04-23 08:01:11 UTC (rev 9664)
+++ platform/core/trunk/src/java/org/datanucleus/query/node/NodeType.java 2010-04-23 09:04:27 UTC (rev 9665)
@@ -18,7 +18,7 @@
package org.datanucleus.query.node;
/**
- *
+ * Enum of node types.
*/
public enum NodeType
{
@@ -33,5 +33,6 @@
CAST, /** cast node type **/
ARRAY, /** array node type **/
SUBQUERY, /** subquery node type (EXISTS, ANY, SOME, ALL, etc) **/
- TYPE; /** "type" node type (JPQL, like "instanceof" **/
+ TYPE, /** "type" node type (JPQL, like "instanceof" **/
+ CASE; /** Case node type (JPQL) **/
}
\ No newline at end of file
Modified: platform/core/trunk/src/java/org/datanucleus/query/node/ParameterNode.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/query/node/ParameterNode.java 2010-04-23 08:01:11 UTC (rev 9664)
+++ platform/core/trunk/src/java/org/datanucleus/query/node/ParameterNode.java 2010-04-23 09:04:27 UTC (rev 9665)
@@ -30,7 +30,7 @@
* @param nodeType
* @param position Position
*/
- public ParameterNode(int nodeType, int position)
+ public ParameterNode(NodeType nodeType, int position)
{
super(nodeType);
this.position = position;
@@ -41,7 +41,7 @@
* @param nodeValue
* @param position
*/
- public ParameterNode(int nodeType, Object nodeValue, int position)
+ public ParameterNode(NodeType nodeType, Object nodeValue, int position)
{
super(nodeType, nodeValue);
this.position = position;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|