db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1495305 [3/21] - in /db/derby/code/trunk: java/engine/org/apache/derby/ java/engine/org/apache/derby/catalog/types/ java/engine/org/apache/derby/iapi/services/io/ java/engine/org/apache/derby/iapi/sql/ java/engine/org/apache/derby/iapi/sql...
Date Fri, 21 Jun 2013 07:47:52 GMT
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,25 +21,21 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.sql.compile.Visitor;
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.compiler.LocalField;
-
 import java.lang.reflect.Modifier;
 import java.sql.Types;
 import java.util.List;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
+import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.reference.SQLState;
-
-import org.apache.derby.iapi.util.JBitSet;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
-
+import org.apache.derby.iapi.services.compiler.LocalField;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.Visitor;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
+import org.apache.derby.iapi.util.JBitSet;
 
 /**
  * A BinaryOperatorNode represents a built-in binary operator as defined by
@@ -49,7 +45,7 @@ import org.apache.derby.iapi.services.cl
  *
  */
 
-public class BinaryOperatorNode extends OperatorNode
+class BinaryOperatorNode extends OperatorNode
 {
 	String	operator;
 	String	methodName;
@@ -58,20 +54,20 @@ public class BinaryOperatorNode extends 
 	/*
 	** These identifiers are used in the grammar.
 	*/
-	public final static int PLUS	= 1;
-	public final static int MINUS	= 2;
-	public final static int TIMES	= 3;
-	public final static int DIVIDE	= 4;
-	public final static int CONCATENATE	= 5;
-	public final static int EQ	= 6;
-	public final static int NE	= 7;
-	public final static int GT	= 8;
-	public final static int GE	= 9;
-	public final static int LT	= 10;
-	public final static int LE	= 11;
-	public final static int AND	= 12;
-	public final static int OR	= 13;
-	public final static int LIKE	= 14;
+    final static int PLUS   = 1;
+    final static int MINUS  = 2;
+    final static int TIMES  = 3;
+    final static int DIVIDE = 4;
+    final static int CONCATENATE    = 5;
+    final static int EQ = 6;
+    final static int NE = 7;
+    final static int GT = 8;
+    final static int GE = 9;
+    final static int LT = 10;
+    final static int LE = 11;
+    final static int AND    = 12;
+    final static int OR = 13;
+    final static int LIKE   = 14;
 
 	ValueNode	leftOperand;
 	ValueNode	rightOperand;
@@ -89,8 +85,8 @@ public class BinaryOperatorNode extends 
 	// XML-related or not) should follow this example when
 	// possible.
 
-	public final static int XMLEXISTS_OP = 0;
-	public final static int XMLQUERY_OP = 1;
+    final static int XMLEXISTS_OP = 0;
+    final static int XMLQUERY_OP = 1;
 
 	// NOTE: in the following 4 arrays, order
 	// IS important.
@@ -118,64 +114,63 @@ public class BinaryOperatorNode extends 
     /** The query expression if the operator is XMLEXISTS or XMLQUERY. */
     private String xmlQuery;
 
-	/**
-	 * Initializer for a BinaryOperatorNode
-	 *
-	 * @param leftOperand	The left operand of the node
-	 * @param rightOperand	The right operand of the node
-	 * @param operator		The name of the operator
-	 * @param methodName	The name of the method to call for this operator
-	 * @param leftInterfaceType	The name of the interface for the left operand
-	 * @param rightInterfaceType	The name of the interface for the right
-	 *								operand
-	 */
-
-	public void init(
-			Object leftOperand,
-			Object rightOperand,
-			Object operator,
-			Object methodName,
-			Object leftInterfaceType,
-			Object rightInterfaceType)
-	{
-		this.leftOperand = (ValueNode) leftOperand;
-		this.rightOperand = (ValueNode) rightOperand;
-		this.operator = (String) operator;
-		this.methodName = (String) methodName;
-		this.leftInterfaceType = (String) leftInterfaceType;
-		this.rightInterfaceType = (String) rightInterfaceType;
-		this.operatorType = -1;
-	}
+    BinaryOperatorNode(ContextManager cm) {
+        super(cm);
+    }
+
+    BinaryOperatorNode(
+            ValueNode leftOperand,
+            ValueNode rightOperand,
+            String operator,
+            String methodName,
+            String leftInterfaceType,
+            String rightInterfaceType,
+            ContextManager cm) {
+        super(cm);
+        this.leftOperand = leftOperand;
+        this.rightOperand = rightOperand;
+        this.operator = operator;
+        this.methodName = methodName;
+        this.leftInterfaceType = leftInterfaceType;
+        this.rightInterfaceType = rightInterfaceType;
+        this.operatorType = -1;
+    }
 
-	public void init(
-			Object leftOperand,
-			Object rightOperand,
-			Object leftInterfaceType,
-			Object rightInterfaceType)
-	{
-		this.leftOperand = (ValueNode) leftOperand;
-		this.rightOperand = (ValueNode) rightOperand;
-		this.leftInterfaceType = (String) leftInterfaceType;
-		this.rightInterfaceType = (String) rightInterfaceType;
+    BinaryOperatorNode(
+            ValueNode leftOperand,
+            ValueNode rightOperand,
+            String leftInterfaceType,
+            String rightInterfaceType,
+            ContextManager cm)
+	{
+        super(cm);
+        this.leftOperand = leftOperand;
+        this.rightOperand = rightOperand;
+        this.leftInterfaceType = leftInterfaceType;
+        this.rightInterfaceType = rightInterfaceType;
 		this.operatorType = -1;
 	}
 
 	/**
-	 * Initializer for a BinaryOperatorNode
+     * Constructor for a BinaryOperatorNode
 	 *
 	 * @param leftOperand	The left operand of the node
 	 * @param rightOperand	The right operand of the node
 	 * @param opType  An Integer holding the operatorType
 	 *  for this operator.
 	 */
-	public void init(
-			Object leftOperand,
-			Object rightOperand,
-			Object opType)
-	{
-		this.leftOperand = (ValueNode)leftOperand;
-		this.rightOperand = (ValueNode)rightOperand;
-		this.operatorType = ((Integer)opType).intValue();
+    BinaryOperatorNode(
+            int nodeType,
+            ValueNode leftOperand,
+            ValueNode rightOperand,
+            int opType,
+            ContextManager cm)
+	{
+        super(cm);
+        setNodeType(nodeType);
+        this.leftOperand = leftOperand;
+        this.rightOperand = rightOperand;
+        this.operatorType = opType;
 		this.operator = BinaryOperators[this.operatorType];
 		this.methodName = BinaryMethodNames[this.operatorType];
 		this.leftInterfaceType = BinaryArgTypes[this.operatorType][0];
@@ -189,7 +184,7 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @return	This object as a String
 	 */
-
+    @Override
 	public String toString()
 	{
 		if (SanityManager.DEBUG)
@@ -231,7 +226,7 @@ public class BinaryOperatorNode extends 
 	 * Used when we don't know the interface type until
 	 * later in binding.
 	 */
-	public void setLeftRightInterfaceType(String iType)
+    void setLeftRightInterfaceType(String iType)
 	{
 		leftInterfaceType = iType;
 		rightInterfaceType = iType;
@@ -244,8 +239,8 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
-	public void printSubNodes(int depth)
+    @Override
+    void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
 		{
@@ -278,7 +273,7 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     ValueNode bindExpression(
         FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 			throws StandardException
@@ -328,7 +323,6 @@ public class BinaryOperatorNode extends 
         throws StandardException
     {
         // Check operand types.
-        TypeId leftOperandType = leftOperand.getTypeId();
         TypeId rightOperandType = rightOperand.getTypeId();
 
         // Left operand is query expression and must be a string
@@ -389,7 +383,8 @@ public class BinaryOperatorNode extends 
 	 * operand of this Binary Operator Node if needed. Subclasses can override
 	 * the default behavior.
 	 */
-	public ValueNode genSQLJavaSQLTree() throws StandardException
+    @Override
+    ValueNode genSQLJavaSQLTree() throws StandardException
 	{
 		TypeId leftTypeId = leftOperand.getTypeId();
 		
@@ -418,7 +413,8 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ValueNode preprocess(int numTables,
+    @Override
+    ValueNode preprocess(int numTables,
 								FromList outerFromList,
 								SubqueryList outerSubqueryList,
 								PredicateList outerPredicateList) 
@@ -442,7 +438,7 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
 		throws StandardException
 	{
@@ -651,7 +647,7 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @param newLeftOperand	The new leftOperand
 	 */
-	public void setLeftOperand(ValueNode newLeftOperand)
+    void setLeftOperand(ValueNode newLeftOperand)
 	{
 		leftOperand = newLeftOperand;
 	}
@@ -661,7 +657,7 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @return The current leftOperand.
 	 */
-	public ValueNode getLeftOperand()
+    ValueNode getLeftOperand()
 	{
 		return leftOperand;
 	}
@@ -671,7 +667,7 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @param newRightOperand	The new rightOperand
 	 */
-	public void setRightOperand(ValueNode newRightOperand)
+    void setRightOperand(ValueNode newRightOperand)
 	{
 		rightOperand = newRightOperand;
 	}
@@ -681,7 +677,7 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @return The current rightOperand.
 	 */
-	public ValueNode getRightOperand()
+    ValueNode getRightOperand()
 	{
 		return rightOperand;
 	}
@@ -711,7 +707,8 @@ public class BinaryOperatorNode extends 
 	 *						or a VirtualColumnNode.
 	 * @exception StandardException			Thrown on error
 	 */
-	public boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
+    @Override
+    boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
 		throws StandardException
 	{
 		boolean pushable;
@@ -728,7 +725,8 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @exception StandardException			Thrown on error
 	 */
-	public ValueNode remapColumnReferencesToExpressions()
+    @Override
+    ValueNode remapColumnReferencesToExpressions()
 		throws StandardException
 	{
 		leftOperand = leftOperand.remapColumnReferencesToExpressions();
@@ -741,14 +739,16 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @return	Whether or not this expression tree represents a constant expression.
 	 */
-	public boolean isConstantExpression()
+    @Override
+    boolean isConstantExpression()
 	{
 		return (leftOperand.isConstantExpression() &&
 				rightOperand.isConstantExpression());
 	}
 
 	/** @see ValueNode#constantExpression */
-	public boolean constantExpression(PredicateList whereClause)
+    @Override
+    boolean constantExpression(PredicateList whereClause)
 	{
 		return (leftOperand.constantExpression(whereClause) &&
 				rightOperand.constantExpression(whereClause));
@@ -763,7 +763,7 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public String getReceiverInterfaceName() throws StandardException {
+    String getReceiverInterfaceName() throws StandardException {
 		if (SanityManager.DEBUG)
 		{
 			SanityManager.ASSERT(receiver!=null,"can't get receiver interface name until receiver is set");
@@ -785,6 +785,7 @@ public class BinaryOperatorNode extends 
 	 * @return	The variant type for the underlying expression.
 	 * @exception StandardException	thrown on error
 	 */
+    @Override
 	protected int getOrderableVariantType() throws StandardException
 	{
 		int leftType = leftOperand.getOrderableVariantType();
@@ -800,6 +801,7 @@ public class BinaryOperatorNode extends 
 	 *
 	 * @exception StandardException on error
 	 */
+    @Override
 	void acceptChildren(Visitor v)
 		throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,30 +21,21 @@
 
 package	org.apache.derby.impl.sql.compile;
 
+import java.sql.Types;
+import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.reference.ClassName;
-
-import org.apache.derby.iapi.util.JBitSet;
-
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
+import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.error.StandardException;
-
 import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.ExpressionClassBuilderInterface;
 import org.apache.derby.iapi.sql.compile.Optimizable;
-
 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-
 import org.apache.derby.iapi.store.access.ScanController;
-
-import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.types.DataValueDescriptor;
-
 import org.apache.derby.iapi.types.Orderable;
-
-import java.sql.Types;
+import org.apache.derby.iapi.types.TypeId;
+import org.apache.derby.iapi.util.JBitSet;
 
 /**
  * This class represents the 6 binary operators: LessThan, LessThanEquals,
@@ -52,7 +43,7 @@ import java.sql.Types;
  *
  */
 
-public class BinaryRelationalOperatorNode
+class BinaryRelationalOperatorNode
 	extends BinaryComparisonOperatorNode
 	implements RelationalOperator
 {
@@ -81,92 +72,178 @@ public class BinaryRelationalOperatorNod
 	 */
 	private InListOperatorNode inListProbeSource = null;
 
-	//DERBY-6185 (Query against view  with "where name LIKE 
-	// 'Col1' ESCAPE '\' " failed)
-	//4th argument forQueryRewrite can be true only if this node has been 
-	//  added by an internal rewrite of the query. This allows binding to 
-	//  be more liberal when checking it against allowed syntax.
-	//  This parameter will be passed FALSE when a new instance of the node
-	//  is being created(which is the majority of the cases). But when an 
-	//  existing node is getting cloned, the value of this parameter should 
-	//  be passed as the originalNode.getForQueryRewrite(). Examples of this
-	//  can be found in Predicate.Java and PredicateList.java
-	public void init(Object leftOperand, Object rightOperand,
-        Object forQueryRewrite)
-	{
-		String methodName = "";
-		String operatorName = "";
+    /**
+     *  Constructor.
+     *  DERBY-6185 Query against view  with {@code "where name LIKE
+     *  'Col1' ESCAPE '\' "} failed.
+     *  Argument {@code forQueryRewrite} can be true only if this node has been
+     *  added by an internal rewrite of the query. This allows binding to
+     *  be more liberal when checking it against allowed syntax.
+     *  This parameter will be passed FALSE when a new instance of the node
+     *  is being created(which is the majority of the cases). But when an
+     *  existing node is getting cloned, the value of this parameter should
+     *  be passed as the originalNode.getForQueryRewrite(). Examples of this
+     *  can be found in Predicate.Java and PredicateList.java
+     *
+     * @param leftOperand
+     * @param rightOperand
+     * @param forQueryRewrite
+     */
+    BinaryRelationalOperatorNode(
+            int nodeType,
+            ValueNode leftOperand,
+            ValueNode rightOperand,
+            boolean forQueryRewrite,
+            ContextManager cm) throws StandardException
+	{
+        super(leftOperand,
+              rightOperand,
+              getOperatorName(nodeType),
+              getMethodName(nodeType),
+              forQueryRewrite,
+              cm);
+        constructorMinion(nodeType);
+    }
 
-		switch (getNodeType())
-		{
+    /**
+     * Same as constructor above except takes a third argument that is
+     * an InListOperatorNode.  This version is used during IN-list
+     * preprocessing to create a "probe predicate" for the IN-list.
+     * See InListOperatorNode.preprocess() for more.
+     * DERBY-6185 (Query against view  with "where name LIKE
+     *  'Col1' ESCAPE '\' " failed)
+     * 4th argument forQueryRewrite can be true only if this node has been
+     *  added by an internal rewrite of the query. This allows binding to
+     *  be more liberal when checking it against allowed syntax.
+     *  This parameter will be passed FALSE when a new instance of the node
+     *  is being created(which is the majority of the cases). But when an
+     *  existing node is getting cloned, the value of this parameter should
+     *  be passed as the originalNode.getForQueryRewrite(). Examples of this
+     *  can be found in Predicate.Java and PredicateList.java
+     */
+    BinaryRelationalOperatorNode(
+            int nodeType,
+            ValueNode leftOperand,
+            ValueNode rightOperand,
+            InListOperatorNode inListOp,
+            boolean forQueryRewrite,
+            ContextManager cm) throws StandardException
+    {
+        super(leftOperand,
+              rightOperand,
+              getOperatorName(nodeType),
+              getMethodName(nodeType),
+              forQueryRewrite,
+              cm);
+        constructorMinion(nodeType);
+        this.inListProbeSource = inListOp;
+    }
+
+    private void constructorMinion(int nodeType) {
+        this.operatorType = getOperatorType(nodeType);
+        setNodeType(nodeType);
+        btnVis = null;
+    }
+
+    private static String getMethodName(int nodeType) {
+        String methodName = "";
+        switch (nodeType) {
 			case C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE:
 				methodName = "equals";
-				operatorName = "=";
-				operatorType = RelationalOperator.EQUALS_RELOP;
 				break;
 
 			case C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE:
 				methodName = "greaterOrEquals";
-				operatorName = ">=";
-				operatorType = RelationalOperator.GREATER_EQUALS_RELOP;
 				break;
 
 			case C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE:
 				methodName = "greaterThan";
-				operatorName = ">";
-				operatorType = RelationalOperator.GREATER_THAN_RELOP;
 				break;
 
 			case C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE:
 				methodName = "lessOrEquals";
-				operatorName = "<=";
-				operatorType =  RelationalOperator.LESS_EQUALS_RELOP;
 				break;
 
 			case C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE:
 				methodName = "lessThan";
-				operatorName = "<";
-				operatorType = RelationalOperator.LESS_THAN_RELOP;
 				break;
 			case C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE:
 				methodName = "notEquals";
+                break;
+
+            default:
+                if (SanityManager.DEBUG) {
+                    SanityManager.THROWASSERT(
+                            "Constructor for BinaryRelationalOperatorNode" +
+                            " called with wrong nodeType = " + nodeType);
+                }
+                break;
+        }
+        return methodName;
+    }
+
+    private static String getOperatorName(int nodeType) {
+        String operatorName = "";
+
+        switch (nodeType) {
+            case C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE:
+                operatorName = "=";
+                break;
+
+            case C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE:
+                operatorName = ">=";
+                break;
+
+            case C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE:
+                operatorName = ">";
+                break;
+
+            case C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE:
+                operatorName = "<=";
+                break;
+
+            case C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE:
+                operatorName = "<";
+                break;
+            case C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE:
 				operatorName = "<>";
-				operatorType = RelationalOperator.NOT_EQUALS_RELOP;
 				break;
 
 			default:
-				if (SanityManager.DEBUG)
-				{
-					SanityManager.THROWASSERT("init for BinaryRelationalOperator called with wrong nodeType = " + getNodeType());
+                if (SanityManager.DEBUG) {
+                    SanityManager.THROWASSERT(
+                            "Constructor for BinaryRelationalOperatorNode " +
+                            "called with wrong nodeType = " + nodeType);
 				}
 			    break;
 		}
-		super.init(leftOperand, rightOperand, operatorName, methodName, forQueryRewrite);
-		btnVis = null;
-	}
 
-	/**
-	 * Same as init() above except takes a third argument that is
-	 * an InListOperatorNode.  This version is used during IN-list
-	 * preprocessing to create a "probe predicate" for the IN-list.
-	 * See InListOperatorNode.preprocess() for more.
-	 * DERBY-6185 (Query against view  with "where name LIKE 
-	 *  'Col1' ESCAPE '\' " failed)
-	 * 4th argument forQueryRewrite can be true only if this node has been
-	 *  added by an internal rewrite of the query. This allows binding to
-	 *  be more liberal when checking it against allowed syntax.
-	 *  This parameter will be passed FALSE when a new instance of the node
-	 *  is being created(which is the majority of the cases). But when an 
-	 *  existing node is getting cloned, the value of this parameter should
-	 *  be passed as the originalNode.getForQueryRewrite(). Examples of this
-	 *  can be found in Predicate.Java and PredicateList.java
-	 */
-	public void init(Object leftOperand, Object rightOperand,
-			 Object inListOp, Object forQueryRewrite)
-	{
-		init(leftOperand, rightOperand, forQueryRewrite);
-		this.inListProbeSource = (InListOperatorNode)inListOp;
-	}
+        return operatorName;
+    }
+
+    private int getOperatorType(int nodeType) {
+        switch (nodeType) {
+            case C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE:
+                return RelationalOperator.EQUALS_RELOP;
+            case C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE:
+                return RelationalOperator.GREATER_EQUALS_RELOP;
+            case C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE:
+                return RelationalOperator.GREATER_THAN_RELOP;
+            case C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE:
+                return RelationalOperator.LESS_EQUALS_RELOP;
+            case C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE:
+                return RelationalOperator.LESS_THAN_RELOP;
+            case C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE:
+                return RelationalOperator.NOT_EQUALS_RELOP;
+            default:
+                if (SanityManager.DEBUG) {
+                    SanityManager.THROWASSERT(
+                            "Constructor for BinaryRelationalOperatorNode " +
+                            "called with wrong nodeType = " + getNodeType());
+                }
+                return 0;
+        }
+    }
 
 	/**
 	 * If this rel op was created for an IN-list probe predicate then return
@@ -840,7 +917,7 @@ public class BinaryRelationalOperatorNod
 		FromTable	ft;
 		ValueNode	otherSide = null;
 		JBitSet		tablesReferenced;
-		ColumnReference	cr = null;
+        ColumnReference cr;
 		boolean	found = false;
 		boolean walkSubtree = true;
 
@@ -917,8 +994,7 @@ public class BinaryRelationalOperatorNod
 	/** @see RelationalOperator#compareWithKnownConstant */
 	public boolean compareWithKnownConstant(Optimizable optTable, boolean considerParameters)
 	{
-		ValueNode	node = null;
-		node = keyColumnOnLeft(optTable) ? rightOperand : leftOperand;
+        ValueNode node = keyColumnOnLeft(optTable) ? rightOperand : leftOperand;
 
 		if (considerParameters)
 		{
@@ -940,12 +1016,10 @@ public class BinaryRelationalOperatorNod
 	public DataValueDescriptor getCompareValue(Optimizable optTable) 
         throws StandardException
 	{
-		ValueNode	node = null;
-
 		/* The value being compared to is on the opposite side from
 		** the key column.
 		*/
-		node = keyColumnOnLeft(optTable) ? rightOperand : leftOperand;
+        ValueNode node = keyColumnOnLeft(optTable) ? rightOperand : leftOperand;
 
 		if (node instanceof ConstantNode) 
 		{
@@ -997,7 +1071,8 @@ public class BinaryRelationalOperatorNod
 	 * Overrides this method
 	 * in BooleanOperatorNode for code generation purposes.
 	 */
-	public String getReceiverInterfaceName() {
+    @Override
+    String getReceiverInterfaceName() {
 	    return ClassName.DataValueDescriptor;
 	}
 
@@ -1008,6 +1083,7 @@ public class BinaryRelationalOperatorNod
      * @return a node representing a Boolean constant if the result of the
      * operator is known; otherwise, this operator node
      */
+    @Override
     ValueNode evaluateConstantExpressions() throws StandardException {
         if (leftOperand instanceof ConstantNode &&
                 rightOperand instanceof ConstantNode) {
@@ -1045,10 +1121,7 @@ public class BinaryRelationalOperatorNod
      * @return a node representing a Boolean constant
      */
     private ValueNode newBool(boolean b) throws StandardException {
-        return (ValueNode) getNodeFactory().getNode(
-                C_NodeTypes.BOOLEAN_CONSTANT_NODE,
-                Boolean.valueOf(b),
-                getContextManager());
+        return new BooleanConstantNode(b, getContextManager());
     }
 	
 	/**
@@ -1063,10 +1136,9 @@ public class BinaryRelationalOperatorNod
 			SanityManager.ASSERT(getTypeServices() != null,
 								 "dataTypeServices is expected to be non-null");
 		/* xxxRESOLVE: look into doing this in place instead of allocating a new node */
-		negation = (BinaryOperatorNode)
-			getNodeFactory().getNode(getNegationNode(),
+        negation = new BinaryRelationalOperatorNode(getNegationNode(),
 									 leftOperand, rightOperand,
-									 Boolean.FALSE,
+                                     false,
 									 getContextManager());
 		negation.setType(getTypeServices());
 		return negation;
@@ -1110,10 +1182,12 @@ public class BinaryRelationalOperatorNod
      * expression.
      */
     BinaryOperatorNode getSwappedEquivalent() throws StandardException {
-        BinaryOperatorNode newNode = (BinaryOperatorNode) getNodeFactory().getNode(getNodeTypeForSwap(),
-                rightOperand, leftOperand,
-                Boolean.FALSE,
-                getContextManager());
+        BinaryOperatorNode newNode = new BinaryRelationalOperatorNode(
+            getNodeTypeForSwap(),
+            rightOperand,
+            leftOperand,
+            false,
+            getContextManager());
         newNode.setType(getTypeServices());
         return newNode;
     }
@@ -1295,8 +1369,6 @@ public class BinaryRelationalOperatorNod
 				mb.push(keyColumnOnLeft(optTable));
 				break;
 		}
-		
-		return;
 	}
 		
 	/** @see RelationalOperator#getOperator */
@@ -1307,6 +1379,7 @@ public class BinaryRelationalOperatorNod
 
 	/** return the selectivity of this predicate.
 	 */
+    @Override
 	public double selectivity(Optimizable optTable)
 	throws StandardException
 	{
@@ -1334,14 +1407,15 @@ public class BinaryRelationalOperatorNod
 	}
 
 	/** @see RelationalOperator#getTransitiveSearchClause */
+    @Override
 	public RelationalOperator getTransitiveSearchClause(ColumnReference otherCR)
 		throws StandardException
 	{
-		return (RelationalOperator)getNodeFactory().getNode(getNodeType(),
-														  otherCR,
-														  rightOperand,
-														  Boolean.FALSE,
-														  getContextManager());
+        return new BinaryRelationalOperatorNode(getNodeType(),
+                                                otherCR,
+                                                rightOperand,
+                                                false,
+                                                getContextManager());
 	}
 	
 	public boolean equalsComparisonWithConstantExpression(Optimizable optTable)
@@ -1366,7 +1440,8 @@ public class BinaryRelationalOperatorNod
 	}
 	
 	/** @see ValueNode#isRelationalOperator */
-	public boolean isRelationalOperator()
+    @Override
+    boolean isRelationalOperator()
 	{
 		/* If this rel op is for a probe predicate then we do not call
 		 * it a "relational operator"; it's actually a disguised IN-list
@@ -1376,7 +1451,8 @@ public class BinaryRelationalOperatorNod
 	}
 	
 	/** @see ValueNode#isBinaryEqualsOperatorNode */
-	public boolean isBinaryEqualsOperatorNode()
+    @Override
+    boolean isBinaryEqualsOperatorNode()
 	{
 		/* If this rel op is for a probe predicate then we do not treat
 		 * it as an "equals operator"; it's actually a disguised IN-list
@@ -1394,13 +1470,15 @@ public class BinaryRelationalOperatorNod
 	 * leftOperand, and a caller of this method cannot gain access to
 	 * inListProbeSource's leftOperand through this method.
 	 */
-	public boolean isInListProbeNode()
+    @Override
+    boolean isInListProbeNode()
 	{
 		return (inListProbeSource != null);
 	}
 
 	/** @see ValueNode#optimizableEqualityNode */
-	public boolean optimizableEqualityNode(Optimizable optTable, 
+    @Override
+    boolean optimizableEqualityNode(Optimizable optTable,
 										   int columnNumber, 
 										   boolean isNullOkay)
 		throws StandardException
@@ -1458,7 +1536,8 @@ public class BinaryRelationalOperatorNod
 	/* @see BinaryOperatorNode#genSQLJavaSQLTree
 	 * @see BinaryComparisonOperatorNode#genSQLJavaSQLTree
 	 */
-	public ValueNode genSQLJavaSQLTree() throws StandardException
+    @Override
+    ValueNode genSQLJavaSQLTree() throws StandardException
 	{
 		if (operatorType == EQUALS_RELOP)
 			return this;
@@ -1517,11 +1596,11 @@ public class BinaryRelationalOperatorNod
 	 *  instance of the column reference, they'll interfere with each other
 	 *  during optimization.
 	 */
-	public ValueNode getScopedOperand(int whichSide,
+    ValueNode getScopedOperand(int whichSide,
 		JBitSet parentRSNsTables, ResultSetNode childRSN,
 		int [] whichRC) throws StandardException
 	{
-		ResultColumn rc = null;
+        ResultColumn rc;
 		ColumnReference cr = 
 			whichSide == LEFT
 				? (ColumnReference)leftOperand
@@ -1546,9 +1625,9 @@ public class BinaryRelationalOperatorNod
 		 * is included in the list of table numbers from the parentRSN.
 		 */
 		JBitSet crTables = new JBitSet(parentRSNsTables.size());
-		BaseTableNumbersVisitor btnVis =
+        BaseTableNumbersVisitor btnVisitor =
 			new BaseTableNumbersVisitor(crTables);
-		cr.accept(btnVis);
+        cr.accept(btnVisitor);
 
 		/* If the column reference in question is not intended for
 		 * the received result set node, just leave the operand as
@@ -1846,7 +1925,6 @@ public class BinaryRelationalOperatorNod
 		// table numbers beneath the target node.
 		btnVis.setTableMap(optBaseTables);
 		ft.accept(btnVis);
-		return;
 	}
 
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java Fri Jun 21 07:47:47 2013
@@ -21,70 +21,47 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.types.BitDataValue;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataValueFactory;
-
+import java.sql.Types;
 import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
-
-import org.apache.derby.iapi.services.io.FormatableBitSet;
-import org.apache.derby.iapi.util.ReuseFactory;
-import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.types.BitDataValue;
+import org.apache.derby.iapi.types.TypeId;
+import org.apache.derby.iapi.util.StringUtil;
 
-import java.sql.Types;
 
-public class BitConstantNode extends ConstantNode
+class BitConstantNode extends ConstantNode
 {
-
-	private int bitLength;
-
-
-	/**
-	 * Initializer for a BitConstantNode.
-	 *
-	 * @param arg1	A Bit containing the value of the constant OR The TypeId for the type of the node
-	 *
-	 * @exception StandardException
-	 */
-
-	public void init(
-					Object arg1)
-		throws StandardException
-	{
-		super.init(
-					arg1,
-					Boolean.TRUE,
-					ReuseFactory.getInteger(0));
-	}
-
-	public void init(
-					Object arg1, Object arg2)
-		throws StandardException
-	{
-		String a1 = (String) arg1;
-
-		byte[] nv = org.apache.derby.iapi.util.StringUtil.fromHexString(a1, 0, a1.length()); 
-
-		Integer bitLengthO = (Integer) arg2;
-		bitLength = bitLengthO.intValue();
-
-		init(
-			TypeId.getBuiltInTypeId(Types.BINARY),
-			Boolean.FALSE,
-			bitLengthO);
-
-		org.apache.derby.iapi.types.BitDataValue dvd = getDataValueFactory().getBitDataValue(nv);
-
+    /**
+     * @param t The TypeId for the type of the node
+     * @param cm context manager
+     * @throws StandardException
+     */
+    BitConstantNode(TypeId t, ContextManager cm)
+            throws StandardException {
+        super(t, true, 0, cm);
+        setNodeType(C_NodeTypes.BIT_CONSTANT_NODE);
+    }
+
+
+    /**
+     * @param hexString hexadecimally coded bit string
+     * @param bitLength desired length of the bit string
+     * @param cm context manager
+     * @throws StandardException
+     */
+    BitConstantNode(String hexString, int bitLength, ContextManager cm)
+            throws StandardException {
+        super(TypeId.getBuiltInTypeId(Types.BINARY), false, bitLength, cm);
+        setNodeType(C_NodeTypes.BIT_CONSTANT_NODE);
+        byte[] nv = StringUtil.fromHexString(hexString, 0, hexString.length());
+        BitDataValue dvd = getDataValueFactory().getBitDataValue(nv);
 		dvd.setWidth(bitLength, 0, false);
 
-		setValue(dvd);
-	}
-
+        setValue(dvd);
+    }
 
 	/**
 	 * Return an Object representing the bind time value of this
@@ -98,6 +75,7 @@ public class BitConstantNode extends Con
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	Object getConstantValueAsObject()
 		throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java Fri Jun 21 07:47:47 2013
@@ -21,26 +21,20 @@
 
 package org.apache.derby.impl.sql.compile;
 
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.services.loader.ClassFactory;
-
 import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.services.io.StoredFormatIds;
-
-import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
 import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
-import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
 
 /**
  * This class implements TypeCompiler for the SQL BIT datatype.
  *
  */
 
-public class BitTypeCompiler extends BaseTypeCompiler
+class BitTypeCompiler extends BaseTypeCompiler
 {
         /**
          * Tell whether this type (bit) can be converted to the given type.
@@ -145,6 +139,7 @@ public class BitTypeCompiler extends Bas
                 }
         }
 
+        @Override
         String dataValueMethodName()
         {
                 int formatId = getStoredFormatIdFromTypeId();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanConstantNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanConstantNode.java Fri Jun 21 07:47:47 2013
@@ -22,20 +22,13 @@
 package	org.apache.derby.impl.sql.compile;
 
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
 import org.apache.derby.iapi.error.StandardException;
-
 import org.apache.derby.iapi.sql.compile.Optimizable;
-
 import org.apache.derby.iapi.types.SQLBoolean;
-import org.apache.derby.iapi.types.BooleanDataValue;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
-
-import org.apache.derby.iapi.util.ReuseFactory;
-import java.sql.Types;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 
 public final class BooleanConstantNode extends ConstantNode
 {
@@ -45,50 +38,35 @@ public final class BooleanConstantNode e
 	boolean booleanValue;
 	boolean unknownValue;
 
-	/**
-	 * Initializer for a BooleanConstantNode.
-	 *
-	 * @param arg1	A boolean containing the value of the constant OR The TypeId for the type of the node
-	 *
-	 * @exception StandardException
-	 */
-	public void init(
-					Object arg1)
-		throws StandardException
-	{
+    /**
+     * @param cm context manager
+     * @throws StandardException
+     */
+    BooleanConstantNode(ContextManager cm) throws StandardException {
 		/*
 		** RESOLVE: The length is fixed at 1, even for nulls.
 		** Is that OK?
 		*/
-
-		if ( arg1 == null )
-		{
-			/* Fill in the type information in the parent ValueNode */
-			super.init(TypeId.BOOLEAN_ID,
-			 Boolean.TRUE,
-			 ReuseFactory.getInteger(1));
-
-            setValue( null );
-		}
-		else if ( arg1 instanceof Boolean )
-		{
-			/* Fill in the type information in the parent ValueNode */
-			super.init(TypeId.BOOLEAN_ID,
-			 Boolean.FALSE,
-			 ReuseFactory.getInteger(1));
-
-			booleanValue = ((Boolean) arg1).booleanValue();
-			super.setValue(new SQLBoolean(booleanValue));
-		}
-		else
-		{
-			super.init(
-				arg1,
-				Boolean.TRUE,
-				ReuseFactory.getInteger(0));
-			unknownValue = true;
-		}
-	}
+        // Fill in the type information in the parent ValueNode
+        super(TypeId.BOOLEAN_ID, true, 1, cm);
+        setNodeType(C_NodeTypes.BOOLEAN_CONSTANT_NODE);
+        setValue( null );
+    }
+
+    BooleanConstantNode(boolean value, ContextManager cm)
+            throws StandardException {
+        super(TypeId.BOOLEAN_ID, false, 1, cm);
+        setNodeType(C_NodeTypes.BOOLEAN_CONSTANT_NODE);
+        super.setValue(new SQLBoolean(value));
+        this.booleanValue = value;
+    }
+
+    BooleanConstantNode(TypeId t, ContextManager cm)
+            throws StandardException {
+        super(t, true, 0, cm);
+        setNodeType(C_NodeTypes.BOOLEAN_CONSTANT_NODE);
+        this.unknownValue = true;
+    }
 
 	/**
 	 * Return the value from this BooleanConstantNode
@@ -126,6 +104,7 @@ public final class BooleanConstantNode e
 	 *			(null if not a bind time constant.)
 	 *
 	 */
+    @Override
 	Object getConstantValueAsObject()
 	{
 		return booleanValue ? Boolean.TRUE : Boolean.FALSE;
@@ -154,6 +133,7 @@ public final class BooleanConstantNode e
 	 *
 	 * @return Whether or not this node represents a true constant.
 	 */
+    @Override
 	boolean isBooleanTrue()
 	{
 		return (booleanValue && !unknownValue);
@@ -164,6 +144,7 @@ public final class BooleanConstantNode e
 	 *
 	 * @return Whether or not this node represents a false constant.
 	 */
+    @Override
 	boolean isBooleanFalse()
 	{
 		return (!booleanValue && !unknownValue);
@@ -173,6 +154,7 @@ public final class BooleanConstantNode e
 	 * The default selectivity for value nodes is 50%.  This is overridden
 	 * in specific cases, such as the RelationalOperators.
 	 */
+    @Override
 	public double selectivity(Optimizable optTable)
 	{
 		if (isBooleanTrue())
@@ -200,6 +182,7 @@ public final class BooleanConstantNode e
 	 * @return		The modified expression
 	 *
 	 */
+    @Override
 	ValueNode eliminateNots(boolean underNotNode) 
 	{
 		if (! underNotNode)
@@ -229,7 +212,8 @@ public final class BooleanConstantNode e
 	/**
 	 * Set the value in this ConstantNode.
 	 */
-	public void setValue(DataValueDescriptor value)
+    @Override
+    void setValue(DataValueDescriptor value)
 	{
 		super.setValue( value);
         unknownValue = true;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java Fri Jun 21 07:47:47 2013
@@ -21,29 +21,18 @@
 
 package org.apache.derby.impl.sql.compile;
 
+import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.services.loader.ClassFactory;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.reference.SQLState;
-
+import org.apache.derby.iapi.sql.compile.TypeCompiler;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.BooleanDataValue;
 import org.apache.derby.iapi.types.TypeId;
 
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
-import org.apache.derby.catalog.types.BaseTypeIdImpl;
-import org.apache.derby.iapi.reference.ClassName;
-
-import java.sql.Types;
-
 /**
  * This class implements TypeCompiler for the SQL BOOLEAN datatype.
  *
  */
 
-public class BooleanTypeCompiler extends BaseTypeCompiler
+class BooleanTypeCompiler extends BaseTypeCompiler
 {
 	/**
 	 * Tell whether this type (boolean) can be converted to the given type.
@@ -104,6 +93,7 @@ public class BooleanTypeCompiler extends
 	 * @return String		The method call name for getting the
 	 *						corresponding primitive Java type.
 	 */
+    @Override
 	public String getPrimitiveMethodName()
 	{
 		return "getBoolean";

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java Fri Jun 21 07:47:47 2013
@@ -21,27 +21,21 @@
 
 package org.apache.derby.impl.sql.compile;
 
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.services.loader.ClassFactory;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.services.compiler.LocalField;
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.io.StoredFormatIds;
-
+import org.apache.derby.iapi.sql.compile.TypeCompiler;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.types.TypeId;
 
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
-import org.apache.derby.iapi.reference.ClassName;
-
 /**
  * This class implements TypeCompiler for the SQL LOB types.
  *
  */
 
-public class CLOBTypeCompiler extends BaseTypeCompiler
+class CLOBTypeCompiler extends BaseTypeCompiler
 {
         /**
          * Tell whether this type (LOB) can be converted to the given type.
@@ -121,6 +115,7 @@ public class CLOBTypeCompiler extends Ba
             }
         }
 
+        @Override
         String dataValueMethodName()
         {
             int formatId = getStoredFormatIdFromTypeId();
@@ -139,6 +134,7 @@ public class CLOBTypeCompiler extends Ba
          * @param collationType Collation type of character values.
          * @return true collationType will be pushed, false collationType will be ignored.
          */
+        @Override
         boolean pushCollationForDataValue(int collationType)
         {
             return collationType != StringDataValue.COLLATION_TYPE_UCS_BASIC;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java Fri Jun 21 07:47:47 2013
@@ -22,18 +22,17 @@
 package	org.apache.derby.impl.sql.compile;
 
 import java.lang.reflect.Modifier;
-
 import org.apache.derby.catalog.types.RoutineAliasInfo;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.ResultDescription;
 import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.CompilerContext;
-import org.apache.derby.iapi.sql.compile.Visitable;
 import org.apache.derby.iapi.sql.compile.Visitor;
 import org.apache.derby.iapi.sql.conn.Authorizer;
 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
@@ -52,7 +51,7 @@ import org.apache.derby.iapi.sql.diction
  * A procedure is always represented by a MethodCallNode.
  *
  */
-public class CallStatementNode extends DMLStatementNode
+class CallStatementNode extends DMLStatementNode
 {	
 	/**
 	 * The method call for the Java procedure. Guaranteed to be
@@ -63,20 +62,22 @@ public class CallStatementNode extends D
 
 
 	/**
-	 * Initializer for a CallStatementNode.
+     * Constructor for a CallStatementNode.
 	 *
 	 * @param methodCall		The expression to "call"
+     * @param cm                The context manager
 	 */
 
-	public void init(Object methodCall)
+    CallStatementNode(JavaToSQLValueNode methodCall, ContextManager cm)
 	{
-		super.init(null);
-		this.methodCall = (JavaToSQLValueNode) methodCall;
+        super(null, cm);
+        setNodeType(C_NodeTypes.CALL_STATEMENT_NODE);
+        this.methodCall = methodCall;
 		this.methodCall.getJavaValueNode().markForCallStatement();
 	}
 
 
-	public String statementToString()
+    String statementToString()
 	{
 		return "CALL";
 	}
@@ -87,8 +88,8 @@ public class CallStatementNode extends D
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
-	public void printSubNodes(int depth)
+    @Override
+    void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
 		{
@@ -114,7 +115,7 @@ public class CallStatementNode extends D
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
 	public void bindStatement() throws StandardException
 	{
 		DataDictionary dd = getDataDictionary();
@@ -122,14 +123,12 @@ public class CallStatementNode extends D
 		if (SanityManager.DEBUG)
 			SanityManager.ASSERT((dd != null), "Failed to get data dictionary");
 
-        SubqueryList subqueries = (SubqueryList) getNodeFactory().getNode(
-                C_NodeTypes.SUBQUERY_LIST, getContextManager());
+        SubqueryList subqueries = new SubqueryList(getContextManager());
 
 		getCompilerContext().pushCurrentPrivType(getPrivType());
 		methodCall = (JavaToSQLValueNode) methodCall.bindExpression(
-							(FromList) getNodeFactory().getNode(
-								C_NodeTypes.FROM_LIST,
-								getNodeFactory().doJoinOrderOptimization(),
+                            new FromList(
+                                getOptimizerFactory().doJoinOrderOptimization(),
 								getContextManager()), 
                             subqueries,
 							null);
@@ -162,7 +161,7 @@ public class CallStatementNode extends D
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
 	public void optimizeStatement() throws StandardException
 	{
 		DataDictionary dd = getDataDictionary();
@@ -171,14 +170,14 @@ public class CallStatementNode extends D
 		SanityManager.ASSERT((dd != null), "Failed to get data dictionary");
 
 		/* Preprocess the method call tree */
-		methodCall = (JavaToSQLValueNode) methodCall.preprocess(
-								getCompilerContext().getNumTables(),
-								(FromList) getNodeFactory().getNode(
-									C_NodeTypes.FROM_LIST,
-									getNodeFactory().doJoinOrderOptimization(),
-									getContextManager()),
-								(SubqueryList) null,
-								(PredicateList) null);
+        methodCall =
+            (JavaToSQLValueNode) methodCall.preprocess(
+                getCompilerContext().getNumTables(),
+                new FromList(
+                    getOptimizerFactory().doJoinOrderOptimization(),
+                    getContextManager()),
+                (SubqueryList) null,
+                (PredicateList) null);
 
 	}
 
@@ -192,6 +191,7 @@ public class CallStatementNode extends D
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
     void generate(ActivationClassBuilder acb, MethodBuilder mb)
 							throws StandardException
 	{
@@ -241,6 +241,7 @@ public class CallStatementNode extends D
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getCallStatementResultSet", ClassName.ResultSet, 2);
 	}
 
+    @Override
 	public ResultDescription makeResultDescription()
 	{
 		return null;
@@ -253,6 +254,7 @@ public class CallStatementNode extends D
 	 *
 	 * @exception StandardException on error
 	 */
+    @Override
 	void acceptChildren(Visitor v)
 		throws StandardException
 	{
@@ -267,6 +269,7 @@ public class CallStatementNode extends D
 	/**
 	 * Set default privilege of EXECUTE for this node. 
 	 */
+    @Override
 	int getPrivType()
 	{
 		return Authorizer.EXECUTE_PRIV;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Fri Jun 21 07:47:47 2013
@@ -21,59 +21,45 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.compiler.LocalField;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
+import java.lang.reflect.Modifier;
+import java.sql.Types;
+import java.util.List;
 import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
-import org.apache.derby.iapi.types.DataTypeUtilities;
-import org.apache.derby.iapi.types.TypeId;
+import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.reference.Limits;
-
 import org.apache.derby.iapi.reference.SQLState;
-
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.DataValueDescriptor;
-
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
-import org.apache.derby.iapi.util.StringUtil;
-
-import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
-
+import org.apache.derby.iapi.services.compiler.LocalField;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.TypeCompiler;
 import org.apache.derby.iapi.sql.compile.Visitor;
-
-import java.lang.reflect.Modifier;
-
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.DataTypeUtilities;
+import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.NumberDataType;
-
+import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.util.JBitSet;
 import org.apache.derby.iapi.util.ReuseFactory;
-
-import java.sql.Types;
-
-import java.util.List;
+import org.apache.derby.iapi.util.StringUtil;
 
 /**
- * An CastNode represents a cast expressionr.
+ * An CastNode represents a cast expression.
  *
  */
 
-public class CastNode extends ValueNode
+class CastNode extends ValueNode
 {
 	ValueNode			castOperand;
 	private int					targetCharType;
 	TypeId	sourceCTI = null;
 	private boolean forDataTypeFunction = false;
     
-	/** This variable gets set by the parser to indiciate that this CAST node 
+    /** This variable gets set by the parser to indicate that this CAST node
 	 * has been generated by the parser. This means that we should use the 
-	 * collation info of the current compilation schmea for this node's 
+     * collation info of the current compilation schema for this node's
 	 * collation setting. If this variable does not get set to true, then it 
 	 * means that this CAST node has been an internally generated node and we 
 	 * should not touch the collation info set for this CAST node because it 
@@ -100,37 +86,44 @@ public class CastNode extends ValueNode
     private boolean assignmentSemantics = false;
 
 	/**
-	 * Initializer for a CastNode
+     * Constructor for a CastNode
 	 *
 	 * @param castOperand	The operand of the node
 	 * @param castTarget	DataTypeServices (target type of cast)
+     * @param cm            The context manager
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
 
-	public void init(Object castOperand, Object castTarget)
-		throws StandardException
-	{
-		this.castOperand = (ValueNode) castOperand;
-		setType((DataTypeDescriptor) castTarget);
+    CastNode(ValueNode castOperand,
+             DataTypeDescriptor castTarget,
+             ContextManager cm) throws StandardException {
+        super(cm);
+        setNodeType(C_NodeTypes.CAST_NODE);
+        this.castOperand = castOperand;
+        setType(castTarget);
 	}
 
 	/**
-	 * Initializer for a CastNode
+     * Constructor for a CastNode
 	 *
 	 * @param castOperand	The operand of the node
 	 * @param charType		CHAR or VARCHAR JDBC type as target
 	 * @param charLength	target type length
+     * @param cm            The context manager
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
 
-	public void init(Object castOperand, Object charType, Object charLength)
-		throws StandardException
-	{
-		this.castOperand = (ValueNode) castOperand;
-		int charLen = ((Integer) charLength).intValue();
-		targetCharType = ((Integer) charType).intValue();
+    CastNode(ValueNode castOperand,
+             int charType,
+             int charLength,
+             ContextManager cm) throws StandardException {
+        super(cm);
+        setNodeType(C_NodeTypes.CAST_NODE);
+        this.castOperand = castOperand;
+        int charLen = charLength;
+        targetCharType = charType;
 		if (charLen < 0)	// unknown, figure out later
 			return;
 		setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(targetCharType, charLen));
@@ -142,7 +135,7 @@ public class CastNode extends ValueNode
 	 *
 	 * @return		This object as a String
 	 */
-
+    @Override
 	public String toString()
 	{
 	    if (SanityManager.DEBUG)
@@ -162,8 +155,8 @@ public class CastNode extends ValueNode
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
-	public void printSubNodes(int depth)
+    @Override
+    void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
 		{
@@ -194,7 +187,7 @@ public class CastNode extends ValueNode
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 				throws StandardException
 	{
@@ -207,42 +200,43 @@ public class CastNode extends ValueNode
 			DataTypeDescriptor opndType = castOperand.getTypeServices();
 			int length = -1;
 			TypeId srcTypeId = opndType.getTypeId();
-			if (opndType != null)
-			{
-				if (srcTypeId.isNumericTypeId())
-				{
-					length = opndType.getPrecision() + 1; // 1 for the sign
-					if (opndType.getScale() > 0)
-						length += 1;               // 1 for the decimal .
-				 
-				}
-				/*
-				 * Derby-1132 : The length for the target type was calculated
-				 * incorrectly while Char & Varchar functions were used. Thus
-				 * adding the check for Char & Varchar and calculating the
-				 * length based on the operand type.
-				 */
-				else if(srcTypeId.isStringTypeId())
-				{
-					length = opndType.getMaximumWidth();
-			
-					// Truncate the target type width to the max width of the
-					// data type
-					if (this.targetCharType == Types.CHAR)
-						length = Math.min(length, Limits.DB2_CHAR_MAXWIDTH);
-					else if (this.targetCharType == Types.VARCHAR)
-						length = Math.min(length, Limits.DB2_VARCHAR_MAXWIDTH);
-				}
-				else 
-				{
-					TypeId typeid = opndType.getTypeId();
-					if (length < 0)
-						length = DataTypeUtilities.getColumnDisplaySize(typeid.getJDBCTypeId(),-1);
 
-				}
-			}
-			if (length < 0)
-				length = 1;  // same default as in parser
+            if (srcTypeId.isNumericTypeId())
+            {
+                length = opndType.getPrecision() + 1; // 1 for the sign
+                if (opndType.getScale() > 0)
+                    length += 1;               // 1 for the decimal .
+
+            }
+            /*
+             * Derby-1132 : The length for the target type was calculated
+             * incorrectly while Char & Varchar functions were used. Thus
+             * adding the check for Char & Varchar and calculating the
+             * length based on the operand type.
+             */
+            else if(srcTypeId.isStringTypeId())
+            {
+                length = opndType.getMaximumWidth();
+
+                // Truncate the target type width to the max width of the
+                // data type
+                if (this.targetCharType == Types.CHAR)
+                    length = Math.min(length, Limits.DB2_CHAR_MAXWIDTH);
+                else if (this.targetCharType == Types.VARCHAR)
+                    length = Math.min(length, Limits.DB2_VARCHAR_MAXWIDTH);
+            }
+            else
+            {
+                TypeId typeid = opndType.getTypeId();
+
+                if (length < 0) {
+                    length = DataTypeUtilities.getColumnDisplaySize(
+                        typeid.getJDBCTypeId(), -1);
+                }
+            }
+
+            if (length < 0)
+                length = 1;  // same default as in parser
 			setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(targetCharType, length));
 			
 		}
@@ -300,12 +294,10 @@ public class CastNode extends ValueNode
 					{
 						BooleanConstantNode bcn = (BooleanConstantNode) castOperand;
 						String booleanString = bcn.getValueAsString();
-						retNode = (ValueNode) getNodeFactory().getNode(
-											C_NodeTypes.CHAR_CONSTANT_NODE,
-											booleanString,
-											ReuseFactory.getInteger(
-                                                    getTypeServices().getMaximumWidth()),
-											getContextManager());
+                       retNode = new CharConstantNode(
+                                booleanString,
+                                getTypeServices().getMaximumWidth(),
+                                getContextManager());
 					}
 					break;
 
@@ -322,12 +314,10 @@ public class CastNode extends ValueNode
 								((UserTypeConstantNode) castOperand).
 											getObjectValue().
 												toString();
-							retNode = (ValueNode) getNodeFactory().getNode(
-												C_NodeTypes.CHAR_CONSTANT_NODE,
-												castValue, 
-												ReuseFactory.getInteger(
-                                                        getTypeServices().getMaximumWidth()),
-												getContextManager());
+                           retNode = new CharConstantNode(
+                               castValue,
+                               getTypeServices().getMaximumWidth(),
+                               getContextManager());
 						}
 						break;
 
@@ -365,7 +355,7 @@ public class CastNode extends ValueNode
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public void bindCastNodeOnly()
+    void bindCastNodeOnly()
 		throws StandardException
 	{
 
@@ -465,24 +455,15 @@ public class CastNode extends ValueNode
 			case Types.BOOLEAN:
 				if (cleanCharValue.equals("TRUE"))
 				{
-					return (ValueNode) getNodeFactory().getNode(
-											C_NodeTypes.BOOLEAN_CONSTANT_NODE,
-											Boolean.TRUE,
-											getContextManager());
+                   return new BooleanConstantNode(true, getContextManager());
 				}
 				else if (cleanCharValue.equals("FALSE"))
 				{
-					return (ValueNode) getNodeFactory().getNode(
-											C_NodeTypes.BOOLEAN_CONSTANT_NODE,
-											Boolean.FALSE,
-											getContextManager());
+                   return new BooleanConstantNode(false, getContextManager());
 				}
 				else if (cleanCharValue.equals("UNKNOWN"))
 				{
-					return (ValueNode) getNodeFactory().getNode(
-											C_NodeTypes.BOOLEAN_CONSTANT_NODE,
-											null,
-											getContextManager());
+                   return new BooleanConstantNode(getContextManager());
 				}
 				else
 				{
@@ -490,20 +471,17 @@ public class CastNode extends ValueNode
 				}
 
 			case Types.DATE:
-				return (ValueNode) getNodeFactory().getNode(
-										C_NodeTypes.USERTYPE_CONSTANT_NODE,
+               return new UserTypeConstantNode(
 										getDataValueFactory().getDateValue(cleanCharValue, false),
 										getContextManager());
 
 			case Types.TIMESTAMP:
-				return (ValueNode) getNodeFactory().getNode(
-									C_NodeTypes.USERTYPE_CONSTANT_NODE,
+               return new UserTypeConstantNode(
 									getDataValueFactory().getTimestampValue(cleanCharValue, false),
 									getContextManager());
 
 			case Types.TIME:
-				return (ValueNode) getNodeFactory().getNode(
-										C_NodeTypes.USERTYPE_CONSTANT_NODE,
+               return new UserTypeConstantNode(
 										getDataValueFactory().getTimeValue(cleanCharValue, false),
 										getContextManager());
 
@@ -532,10 +510,10 @@ public class CastNode extends ValueNode
 				{
 					throw StandardException.newException(SQLState.LANG_FORMAT_EXCEPTION, "float");
 				}
-				return (ValueNode) getNodeFactory().getNode(
-											C_NodeTypes.FLOAT_CONSTANT_NODE,
-											floatValue,
-											getContextManager());
+               return new NumericConstantNode(
+                       TypeId.getBuiltInTypeId(Types.REAL),
+                       floatValue,
+                       getContextManager());
 			case Types.DOUBLE:
 				Double doubleValue;
 				try
@@ -546,10 +524,10 @@ public class CastNode extends ValueNode
 				{
 					throw StandardException.newException(SQLState.LANG_FORMAT_EXCEPTION, "double");
 				}
-				return (ValueNode) getNodeFactory().getNode(
-											C_NodeTypes.DOUBLE_CONSTANT_NODE,
-											doubleValue,
-											getContextManager());
+               return new NumericConstantNode(
+                       TypeId.getBuiltInTypeId(Types.DOUBLE),
+                       doubleValue,
+                       getContextManager());
 		}
 
 		return retNode;
@@ -583,22 +561,20 @@ public class CastNode extends ValueNode
 		switch (destJDBCTypeId)
 		{
 			case Types.CHAR:
-				return (ValueNode) getNodeFactory().getNode(
-										C_NodeTypes.CHAR_CONSTANT_NODE,
-										Long.toString(longValue), 
-										ReuseFactory.getInteger(
-                                                getTypeServices().getMaximumWidth()),
-										getContextManager());
+               return new CharConstantNode(
+                        Long.toString(longValue),
+                        getTypeServices().getMaximumWidth(),
+                        getContextManager());
 			case Types.TINYINT:
 				if (longValue < Byte.MIN_VALUE ||
 					longValue > Byte.MAX_VALUE)
 				{
 					throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "TINYINT");
 				}
-				return (ValueNode) getNodeFactory().getNode(
-										C_NodeTypes.TINYINT_CONSTANT_NODE,
-										ReuseFactory.getByte((byte) longValue),
-										getContextManager());
+               return new NumericConstantNode(
+                       TypeId.getBuiltInTypeId(Types.TINYINT),
+                       ReuseFactory.getByte((byte) longValue),
+                       getContextManager());
 
 			case Types.SMALLINT:
 				if (longValue < Short.MIN_VALUE ||
@@ -606,11 +582,11 @@ public class CastNode extends ValueNode
 				{
 					throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "SHORT");
 				}
-				return (ValueNode) getNodeFactory().getNode(
-											C_NodeTypes.SMALLINT_CONSTANT_NODE,
-											ReuseFactory.getShort(
-															(short) longValue),
-											getContextManager());
+               return new NumericConstantNode(
+                   TypeId.getBuiltInTypeId(destJDBCTypeId),
+                   ReuseFactory.getShort(
+                       (short) longValue),
+                   getContextManager());
 
 			case Types.INTEGER:
 				if (longValue < Integer.MIN_VALUE ||
@@ -618,33 +594,33 @@ public class CastNode extends ValueNode
 				{
 					throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "INTEGER");
 				}
-				return (ValueNode) getNodeFactory().getNode(
-												C_NodeTypes.INT_CONSTANT_NODE,
-												ReuseFactory.getInteger(
-															(int) longValue),
-												getContextManager());
+               return new NumericConstantNode(
+                   TypeId.getBuiltInTypeId(destJDBCTypeId),
+                   ReuseFactory.getInteger(
+                       (int) longValue),
+                   getContextManager());
 
 			case Types.BIGINT:
-				return (ValueNode) getNodeFactory().getNode(
-								C_NodeTypes.LONGINT_CONSTANT_NODE,
-								ReuseFactory.getLong(longValue),
-								getContextManager());
+               return new NumericConstantNode(
+                   TypeId.getBuiltInTypeId(destJDBCTypeId),
+                   ReuseFactory.getLong(longValue),
+                   getContextManager());
 
 			case Types.REAL:
 				if (Math.abs(longValue) > Float.MAX_VALUE)
 				{
 					throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "REAL");
 				}
-				return (ValueNode) getNodeFactory().getNode(
-											C_NodeTypes.FLOAT_CONSTANT_NODE,
-											new Float((float) longValue),
-											getContextManager());
+               return new NumericConstantNode(
+                   TypeId.getBuiltInTypeId(destJDBCTypeId),
+                   new Float((float) longValue),
+                   getContextManager());
 
 			case Types.DOUBLE:
-				return (ValueNode) getNodeFactory().getNode(
-									C_NodeTypes.DOUBLE_CONSTANT_NODE,
-									new Double((double) longValue),
-									getContextManager());
+               return new NumericConstantNode(
+                   TypeId.getBuiltInTypeId(destJDBCTypeId),
+                   new Double((double) longValue),
+                   getContextManager());
 		}
 
 		return retNode;
@@ -672,62 +648,54 @@ public class CastNode extends ValueNode
 									  int destJDBCTypeId)
 		throws StandardException
 	{
-		int nodeType = -1;
-		Object constantObject = null;
-
 		switch (destJDBCTypeId)
 		{
 			case Types.CHAR:
-				nodeType = C_NodeTypes.CHAR_CONSTANT_NODE;
-				constantObject = constantValue.getString();
-				return (ValueNode) getNodeFactory().getNode(
-										nodeType,
-										constantObject, 
-										ReuseFactory.getInteger(
-                                                getTypeServices().getMaximumWidth()),
-										getContextManager());
+               return new CharConstantNode(
+                        constantValue.getString(),
+                        getTypeServices().getMaximumWidth(),
+                        getContextManager());
 
 			case Types.TINYINT:
-				nodeType = C_NodeTypes.TINYINT_CONSTANT_NODE;
-				constantObject = new Byte(constantValue.getByte());
-				break;
+                return new NumericConstantNode(
+                        TypeId.getBuiltInTypeId(destJDBCTypeId),
+                        Byte.valueOf(constantValue.getByte()),
+                        getContextManager());
 
 			case Types.SMALLINT:
-				nodeType = C_NodeTypes.SMALLINT_CONSTANT_NODE;
-				constantObject = ReuseFactory.getShort(constantValue.getShort());
-				break;
+                return new NumericConstantNode(
+                        TypeId.getBuiltInTypeId(destJDBCTypeId),
+                        Short.valueOf(constantValue.getShort()),
+                        getContextManager());
 
 			case Types.INTEGER:
-				nodeType = C_NodeTypes.INT_CONSTANT_NODE;
-				constantObject = ReuseFactory.getInteger(constantValue.getInt());
-				break;
+                return new NumericConstantNode(
+                        TypeId.getBuiltInTypeId(destJDBCTypeId),
+                        Integer.valueOf(constantValue.getInt()),
+                        getContextManager());
 
 			case Types.BIGINT:
-				nodeType = C_NodeTypes.LONGINT_CONSTANT_NODE;
-				constantObject = ReuseFactory.getLong(constantValue.getLong());
-				break;
+                return new NumericConstantNode(
+                        TypeId.getBuiltInTypeId(destJDBCTypeId),
+                        Long.valueOf(constantValue.getLong()),
+                        getContextManager());
 
 			case Types.REAL:
-				nodeType = C_NodeTypes.FLOAT_CONSTANT_NODE;
-				constantObject = new Float(NumberDataType.normalizeREAL(constantValue.getDouble()));
-				break;
+                return new NumericConstantNode(
+                        TypeId.getBuiltInTypeId(destJDBCTypeId),
+                        Float.valueOf(NumberDataType.normalizeREAL(
+                                      constantValue.getDouble())),
+                        getContextManager());
 
 			case Types.DOUBLE:
 				// no need to normalize here because no constant could be out of range for a double
-				nodeType = C_NodeTypes.DOUBLE_CONSTANT_NODE;
-				constantObject = new Double(constantValue.getDouble());
-				break;
+                return new NumericConstantNode(
+                        TypeId.getBuiltInTypeId(destJDBCTypeId),
+                       Double.valueOf(constantValue.getDouble()),
+                        getContextManager());
 		}
 
-		if (nodeType == -1)
-			return this;
-
-
-		return (ValueNode) getNodeFactory().getNode(
-										nodeType,
-										constantObject, 
-										getContextManager());
-
+        return this;
 	}
 
 	/**
@@ -745,7 +713,8 @@ public class CastNode extends ValueNode
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ValueNode preprocess(int numTables,
+    @Override
+    ValueNode preprocess(int numTables,
 								FromList outerFromList,
 								SubqueryList outerSubqueryList,
 								PredicateList outerPredicateList) 
@@ -783,7 +752,8 @@ public class CastNode extends ValueNode
 	 *
 	 * @exception StandardException			Thrown on error
 	 */
-	public boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
+    @Override
+    boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
 		throws StandardException
 	{
 		return castOperand.categorize(referencedTabs, simplePredsOnly);
@@ -797,7 +767,8 @@ public class CastNode extends ValueNode
 	 *
 	 * @exception StandardException			Thrown on error
 	 */
-	public ValueNode remapColumnReferencesToExpressions()
+    @Override
+    ValueNode remapColumnReferencesToExpressions()
 		throws StandardException
 	{
 		castOperand = castOperand.remapColumnReferencesToExpressions();
@@ -809,13 +780,15 @@ public class CastNode extends ValueNode
 	 *
 	 * @return	Whether or not this expression tree represents a constant expression.
 	 */
-	public boolean isConstantExpression()
+    @Override
+    boolean isConstantExpression()
 	{
 		return castOperand.isConstantExpression();
 	}
 
 	/** @see ValueNode#constantExpression */
-	public boolean constantExpression(PredicateList whereClause)
+    @Override
+    boolean constantExpression(PredicateList whereClause)
 	{
 		return castOperand.constantExpression(whereClause);
 	}
@@ -832,6 +805,7 @@ public class CastNode extends ValueNode
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	Object getConstantValueAsObject()
 		throws StandardException
 	{
@@ -863,7 +837,7 @@ public class CastNode extends ValueNode
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
 									throws StandardException
 	{
@@ -1002,6 +976,7 @@ public class CastNode extends ValueNode
 	 *
 	 * @exception StandardException on error
 	 */
+    @Override
 	void acceptChildren(Visitor v)
 		throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java Fri Jun 21 07:47:47 2013
@@ -22,86 +22,77 @@
 package	org.apache.derby.impl.sql.compile;
 
 import java.util.List;
-import org.apache.derby.iapi.types.StringDataValue;
-import org.apache.derby.iapi.types.TypeId;
-
 import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
 import org.apache.derby.iapi.reference.SQLState;
-
-import org.apache.derby.iapi.util.ReuseFactory;
-
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.types.StringDataValue;
+import org.apache.derby.iapi.types.TypeId;
 
 public final class CharConstantNode extends ConstantNode
 {
-	/**
-	 * Initializer for a CharConstantNode.
-	 *
-	 * @param arg1	A String containing the value of the constant OR The TypeId for the type of the node
-	 *
-	 * @exception StandardException
-	 */
-	public void init(
-					Object arg1)
-		throws StandardException
-	{
-		if (arg1 instanceof TypeId)
-		{
-			super.init(
-						arg1,
-						Boolean.TRUE,
-						ReuseFactory.getInteger(0));
-		}
-		else
-		{
-			String val = (String) arg1;
-
-			super.init(
-				TypeId.CHAR_ID,
-				(val == null) ? Boolean.TRUE : Boolean.FALSE,
-				(val != null) ?
-					ReuseFactory.getInteger(val.length()) :
-					ReuseFactory.getInteger(0));
-
-			setValue(getDataValueFactory().getCharDataValue(val));
-		}
-	}
-
-	/**
-	 * Initializer for a CharConstantNode of a specific length.
-	 *
-	 * @param newValue	A String containing the value of the constant
-	 * @param newLength The length of the new value of the constant
-	 *
-	 * @exception StandardException
-	 */
-	public void init(
-					Object newValue, 
-					Object newLength)
-		throws StandardException
-	{
-		String val = (String) newValue;
-		int newLen = ((Integer) newLength).intValue();
-
-		super.init(
-			 TypeId.CHAR_ID,
-			 (val == null) ? Boolean.TRUE : Boolean.FALSE,
-			 newLength);
-
-		if (val.length() > newLen)
-		{
-			throw StandardException.newException(SQLState.LANG_STRING_TRUNCATION, "CHAR", val, String.valueOf(newLen));
+    CharConstantNode(String value, ContextManager cm)
+            throws StandardException {
+        super(TypeId.CHAR_ID,
+              value == null, // nullable?
+              (value != null) ? value.length() : 0,
+              cm);
+
+        setValue(getDataValueFactory().getCharDataValue(value));
+        setNodeType(C_NodeTypes.CHAR_CONSTANT_NODE);
+    }
+
+    CharConstantNode(TypeId t, ContextManager cm)
+            throws StandardException {
+        super(t, true, 0, cm);
+        setNodeType(C_NodeTypes.CHAR_CONSTANT_NODE);
+    }
+
+    /**
+     * @param type VARCHAR_CONSTANT_NODE or LONGVARCHAR_CONSTANT_NODE
+     * @param t typeId
+     * @param cm context manager
+     * @throws StandardException
+     */
+    CharConstantNode(int type, TypeId t, ContextManager cm)
+            throws StandardException {
+        super(t, true, 0, cm);
+        setNodeType(type);
+    }
+
+    /**
+     * Constructor for a CharConstantNode of a specific length.
+     *
+     * @param newValue A String containing the value of the constant
+     * @param newLength The length of the new value of the constant
+     * @param cm
+     * @throws StandardException
+     */
+    CharConstantNode(String newValue, int newLength, ContextManager cm)
+            throws StandardException {
+
+        super(TypeId.CHAR_ID,
+              newValue == null,
+              newLength,
+              cm);
+
+        setNodeType(C_NodeTypes.CHAR_CONSTANT_NODE);
+
+        if (newValue.length() > newLength) {
+           throw StandardException.newException(
+                    SQLState.LANG_STRING_TRUNCATION,
+                    "CHAR",
+                    newValue,
+                    String.valueOf(newLength));
 		}
 
-		// Blank pad the string if necessesary
-		while (val.length() < newLen)
-		{
-			val = val + ' ';
+        // Blank pad the string if necessesary
+       while (newValue.length() < newLength) {
+           newValue = newValue + ' ';
 		}
 
-		setValue(getDataValueFactory().getCharDataValue(val));
+       setValue(getDataValueFactory().getCharDataValue(newValue));
 	}
 
 	/**
@@ -112,7 +103,7 @@ public final class CharConstantNode exte
 	 * @exception StandardException		Thrown on error
 	 */
 
-	public String	getString() throws StandardException
+    String  getString() throws StandardException
 	{
 		return value.getString();
 	}
@@ -142,14 +133,17 @@ public final class CharConstantNode exte
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	Object getConstantValueAsObject() throws StandardException 
 	{
 		return value.getString();
 	}
 	
+    @Override
     ValueNode bindExpression(
-        FromList fromList, SubqueryList subqueryList, List aggregates)
-	throws StandardException
+        FromList fromList,
+        SubqueryList subqueryList,
+        List<AggregateNode> aggregates) throws StandardException
 	{
 		//The DTD for this character constant should get its collation type
 		//from the schema it is getting compiled in.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharStream.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharStream.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharStream.java Fri Jun 21 07:47:47 2013
@@ -50,6 +50,7 @@ interface CharStream {
    * @deprecated
    * @see #getEndColumn
    */
+  @Deprecated
   int getColumn();
 
   /**
@@ -57,6 +58,7 @@ interface CharStream {
    * @deprecated
    * @see #getEndLine
    */
+  @Deprecated
   int getLine();
 
   /**



Mime
View raw message