You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by da...@apache.org on 2013/06/21 09:47:52 UTC

svn commit: r1495305 [17/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/sq...

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,22 +21,19 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
+import java.util.Properties;
 import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.CostEstimate;
 import org.apache.derby.iapi.sql.compile.Optimizable;
-import org.apache.derby.iapi.sql.compile.Visitor;
 import org.apache.derby.iapi.sql.compile.Optimizer;
-import org.apache.derby.iapi.sql.compile.CostEstimate;
 import org.apache.derby.iapi.sql.compile.OptimizerFactory;
 import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
+import org.apache.derby.iapi.sql.compile.Visitor;
+import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-
 import org.apache.derby.iapi.util.JBitSet;
 
 /**
@@ -59,24 +56,26 @@ abstract class TableOperatorNode extends
 	private boolean 	leftModifyAccessPathsDone;
 	private boolean 	rightModifyAccessPathsDone;
 
-	/**
-	 * Initializer for a TableOperatorNode.
+    /**
+     * Constructor for a TableOperatorNode.
 	 *
 	 * @param leftResultSet		The ResultSetNode on the left side of this node
 	 * @param rightResultSet	The ResultSetNode on the right side of this node
 	 * @param tableProperties	Properties list associated with the table
+     * @param cm                The context manager
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public void init(Object leftResultSet,
-							 Object rightResultSet,
-							 Object tableProperties)
+    TableOperatorNode(ResultSetNode  leftResultSet,
+                      ResultSetNode  rightResultSet,
+                      Properties     tableProperties,
+                      ContextManager cm)
 				throws StandardException
 	{
 		/* correlationName is always null */
-		init(null, tableProperties);
-		this.leftResultSet = (ResultSetNode) leftResultSet;
-		this.rightResultSet = (ResultSetNode) rightResultSet;
+        super(null, tableProperties, cm);
+        this.leftResultSet = leftResultSet;
+        this.rightResultSet = rightResultSet;
 	}
 
 	/**
@@ -89,7 +88,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public void bindUntypedNullsToResultColumns(ResultColumnList rcl)
+    @Override
+    void bindUntypedNullsToResultColumns(ResultColumnList rcl)
 	throws StandardException
 	{
 		leftResultSet.bindUntypedNullsToResultColumns(rcl);
@@ -101,6 +101,7 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	public Optimizable modifyAccessPath(JBitSet outerTables) throws StandardException
 	{
 		boolean callModifyAccessPaths = false;
@@ -177,6 +178,7 @@ abstract class TableOperatorNode extends
 	/** @see Optimizable#verifyProperties 
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	public void verifyProperties(DataDictionary dDictionary)
 		throws StandardException
 	{
@@ -200,6 +202,7 @@ abstract class TableOperatorNode extends
 	 * left and right child, in order to ensure that we've handled
 	 * the full plan all the way down this node's subtree. 
 	 */
+    @Override
 	public void updateBestPlanMap(short action,
 		Object planKey) throws StandardException
 	{
@@ -240,7 +243,7 @@ abstract class TableOperatorNode extends
 	 *
 	 * @return	This object as a String
 	 */
-
+    @Override
 	public String toString()
 	{
 		if (SanityManager.DEBUG)
@@ -260,8 +263,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
-	public void printSubNodes(int depth)
+    @Override
+    void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
 		{
@@ -286,7 +289,7 @@ abstract class TableOperatorNode extends
 	 *
 	 * @return ResultSetNode	The leftResultSet from this node.
 	 */
-	public ResultSetNode getLeftResultSet()
+    ResultSetNode getLeftResultSet()
 	{
 		return leftResultSet;
 	}
@@ -296,12 +299,12 @@ abstract class TableOperatorNode extends
 	 *
 	 * @return ResultSetNode	The rightResultSet from this node.
 	 */
-	public ResultSetNode getRightResultSet()
+    ResultSetNode getRightResultSet()
 	{
 		return rightResultSet;
 	}
 
-	public ResultSetNode getLeftmostResultSet()
+    ResultSetNode getLeftmostResultSet()
 	{
 		if (leftResultSet instanceof TableOperatorNode)
 		{
@@ -313,7 +316,7 @@ abstract class TableOperatorNode extends
 		}
 	}
 
-	public void setLeftmostResultSet(ResultSetNode newLeftResultSet)
+    void setLeftmostResultSet(ResultSetNode newLeftResultSet)
 	{
 		if (leftResultSet instanceof TableOperatorNode)
 		{
@@ -330,7 +333,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @param level		The query block level for this FromTable.
 	 */
-	public void setLevel(int level)
+    @Override
+    void setLevel(int level)
 	{
 		super.setLevel(level);
 		if (leftResultSet instanceof FromTable)
@@ -349,8 +353,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @return	The exposed name for this table.
 	 */
-
-	public String getExposedName()
+    @Override
+    String getExposedName()
 	{
 		return null;
 	}
@@ -365,7 +369,7 @@ abstract class TableOperatorNode extends
 	 *
 	 * @param nestedInParens	Whether or not this node is nested in parens.
 	 */
-	public void setNestedInParens(boolean nestedInParens)
+    void setNestedInParens(boolean nestedInParens)
 	{
 	}
 
@@ -384,8 +388,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
-	public ResultSetNode bindNonVTITables(DataDictionary dataDictionary, 
+    @Override
+    ResultSetNode bindNonVTITables(DataDictionary dataDictionary,
 						  FromList fromListParam) 
 							throws StandardException
 	{
@@ -411,8 +415,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
-	public ResultSetNode bindVTITables(FromList fromListParam) 
+    @Override
+    ResultSetNode bindVTITables(FromList fromListParam)
 							throws StandardException
 	{
 		leftResultSet = leftResultSet.bindVTITables(fromListParam);
@@ -428,8 +432,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
-	public void bindExpressions(FromList fromListParam)
+    @Override
+    void bindExpressions(FromList fromListParam)
 				throws StandardException
 	{
 		/*
@@ -455,8 +459,8 @@ abstract class TableOperatorNode extends
 	 * @exception StandardException		Thrown if a ? parameter found
 	 *									directly under a ResultColumn
 	 */
-
-	public void rejectParameters() throws StandardException
+    @Override
+    void rejectParameters() throws StandardException
 	{
 		leftResultSet.rejectParameters();
 		rightResultSet.rejectParameters();
@@ -471,7 +475,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public void bindExpressionsWithTables(FromList fromListParam)
+    @Override
+    void bindExpressionsWithTables(FromList fromListParam)
 					throws StandardException
 	{
 		/*
@@ -499,7 +504,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public void bindResultColumns(FromList fromListParam)
+    @Override
+    void bindResultColumns(FromList fromListParam)
 					throws StandardException
 	{
 		leftResultSet.bindResultColumns(fromListParam);
@@ -532,7 +538,7 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     void bindResultColumns(TableDescriptor targetTableDescriptor,
             FromVTI targetVTI, ResultColumnList targetColumnList,
             DMLStatementNode statement, FromList fromListParam)
@@ -561,6 +567,7 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
     FromTable getFromTableByName(String name, String schemaName, boolean exactMatch)
 		throws StandardException
 	{
@@ -600,8 +607,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
-	public ResultSetNode preprocess(int numTables,
+    @Override
+    ResultSetNode preprocess(int numTables,
 									GroupByList gbl,
 									FromList fromList)
 								throws StandardException
@@ -627,7 +634,7 @@ abstract class TableOperatorNode extends
 
 		/* Build the referenced table map (left || right) */
 		referencedTableMap = (JBitSet) leftResultSet.getReferencedTableMap().clone();
-		referencedTableMap.or((JBitSet) rightResultSet.getReferencedTableMap());
+        referencedTableMap.or(rightResultSet.getReferencedTableMap());
 		referencedTableMap.set(tableNumber);
 
 		/* Only generate a PRN if this node is not a flattenable join node. */
@@ -652,6 +659,7 @@ abstract class TableOperatorNode extends
      * Find the unreferenced result columns and project them out. This is used in pre-processing joins
      * that are not flattened into the where clause.
      */
+    @Override
     void projectResultColumns() throws StandardException
     {
         resultColumns.doProjection();
@@ -673,24 +681,22 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ResultSetNode optimize(DataDictionary dataDictionary,
+    @Override
+    ResultSetNode optimize(DataDictionary dataDictionary,
 								  PredicateList predicateList,
 								  double outerRows)
 				throws StandardException
 	{
 		/* Get an optimizer, so we can get a cost structure */
-		Optimizer optimizer =
-							getOptimizer(
-								(FromList) getNodeFactory().getNode(
-									C_NodeTypes.FROM_LIST,
-									getNodeFactory().doJoinOrderOptimization(),
-									this,
-									getContextManager()),
-									predicateList,
-									dataDictionary,
-									(RequiredRowOrdering) null);
+        Optimizer opt = getOptimizer(
+                new FromList(getOptimizerFactory().doJoinOrderOptimization(),
+                             this,
+                             getContextManager()),
+                predicateList,
+                dataDictionary,
+                (RequiredRowOrdering) null);
 
-		costEstimate = optimizer.newCostEstimate();
+        costEstimate = opt.newCostEstimate();
 
 		/* RESOLVE: This is just a stub for now */
 		leftResultSet = leftResultSet.optimize(
@@ -718,7 +724,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ResultSetNode modifyAccessPaths() throws StandardException
+    @Override
+    ResultSetNode modifyAccessPaths() throws StandardException
 	{
 		/* Beetle 4454 - union all with another union all would modify access
 		 * paths twice causing NullPointerException, make sure we don't
@@ -801,7 +808,8 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public boolean referencesTarget(String name, boolean baseTable)
+    @Override
+    boolean referencesTarget(String name, boolean baseTable)
 		throws StandardException
 	{
 		return leftResultSet.referencesTarget(name, baseTable) ||
@@ -815,6 +823,7 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	public boolean referencesSessionSchema()
 		throws StandardException
 	{
@@ -838,17 +847,14 @@ abstract class TableOperatorNode extends
 
 		if (sourceResultSet instanceof FromTable)
 		{
-			FromList optList = (FromList) getNodeFactory().getNode(
-									C_NodeTypes.FROM_LIST,
-									getNodeFactory().doJoinOrderOptimization(),
-									sourceResultSet,
-									getContextManager());
+            FromList optList = new FromList(
+                    getOptimizerFactory().doJoinOrderOptimization(),
+                    (FromTable)sourceResultSet,
+                    getContextManager());
 
 			/* If there is no predicate list, create an empty one */
 			if (predList == null)
-				predList = (PredicateList) getNodeFactory().getNode(
-												C_NodeTypes.PREDICATE_LIST,
-												getContextManager());
+                predList = new PredicateList(getContextManager());
 
 			LanguageConnectionContext lcc = getLanguageConnectionContext();
 			OptimizerFactory optimizerFactory = lcc.getOptimizerFactory();
@@ -909,6 +915,7 @@ abstract class TableOperatorNode extends
 	 *
 	 * @param decrement	The amount to decrement by.
 	 */
+    @Override
 	void decrementLevel(int decrement)
 	{
 		leftResultSet.decrementLevel(decrement);
@@ -918,6 +925,7 @@ abstract class TableOperatorNode extends
 	/**
 	 * @see ResultSetNode#adjustForSortElimination
 	 */
+    @Override
 	void adjustForSortElimination()
 	{
 		leftResultSet.adjustForSortElimination();
@@ -927,6 +935,7 @@ abstract class TableOperatorNode extends
 	/**
 	 * @see ResultSetNode#adjustForSortElimination
 	 */
+    @Override
 	void adjustForSortElimination(RequiredRowOrdering rowOrdering)
 		throws StandardException
 	{
@@ -941,6 +950,7 @@ abstract class TableOperatorNode extends
 	 *
 	 * @exception StandardException on error
 	 */
+    @Override
 	void acceptChildren(Visitor v)
 		throws StandardException
 	{
@@ -959,7 +969,8 @@ abstract class TableOperatorNode extends
 	/** 
 	 * apparently something special needs to be done for me....
 	 */
-	public boolean needsSpecialRCLBinding()
+    @Override
+    boolean needsSpecialRCLBinding()
 	{
 		return true;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TablePrivilegesNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TablePrivilegesNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TablePrivilegesNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TablePrivilegesNode.java Fri Jun 21 07:47:47 2013
@@ -21,40 +21,44 @@
 
 package	org.apache.derby.impl.sql.compile;
 
+import java.util.ArrayList;
+import java.util.List;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.reference.SQLState;
-
-import org.apache.derby.impl.sql.execute.PrivilegeInfo;
-import org.apache.derby.impl.sql.execute.TablePrivilegeInfo;
+import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.io.FormatableBitSet;
-import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
 import org.apache.derby.iapi.sql.depend.DependencyManager;
 import org.apache.derby.iapi.sql.depend.Provider;
 import org.apache.derby.iapi.sql.depend.ProviderInfo;
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
 import org.apache.derby.iapi.sql.dictionary.AliasDescriptor;
 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
 import org.apache.derby.iapi.sql.dictionary.ViewDescriptor;
-
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.derby.impl.sql.execute.PrivilegeInfo;
+import org.apache.derby.impl.sql.execute.TablePrivilegeInfo;
 
 /**
  * This class represents a set of privileges on one table.
  */
-public class TablePrivilegesNode extends QueryTreeNode
+class TablePrivilegesNode extends QueryTreeNode
 {
 	private boolean[] actionAllowed = new boolean[ TablePrivilegeInfo.ACTION_COUNT];
 	private ResultColumnList[] columnLists = new ResultColumnList[ TablePrivilegeInfo.ACTION_COUNT];
 	private FormatableBitSet[] columnBitSets = new FormatableBitSet[ TablePrivilegeInfo.ACTION_COUNT];
 	private TableDescriptor td;  
 	private List<Provider> descriptorList; 
-	
+
+    TablePrivilegesNode(ContextManager cm) {
+        super(cm);
+        setNodeType(C_NodeTypes.TABLE_PRIVILEGES_NODE);
+    }
+
 	/**
 	 * Add all actions
 	 */
-	public void addAll()
+    void addAll()
 	{
 		for( int i = 0; i < TablePrivilegeInfo.ACTION_COUNT; i++)
 		{
@@ -71,7 +75,7 @@ public class TablePrivilegesNode extends
 	 *
 	 * @exception StandardException standard error policy.
 	 */
-	public void addAction( int action, ResultColumnList privilegeColumnList)
+    void addAction( int action, ResultColumnList privilegeColumnList)
 	{
 		actionAllowed[ action] = true;
 		if( privilegeColumnList == null)
@@ -88,7 +92,7 @@ public class TablePrivilegesNode extends
 	 * @param td The table descriptor
 	 * @param isGrant grant if true; revoke if false
 	 */
-	public void bind( TableDescriptor td, boolean isGrant) throws StandardException
+    void bind( TableDescriptor td, boolean isGrant) throws StandardException
 	{
 		this.td = td;
 			

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,38 +21,34 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
+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.reference.ClassName;
+import org.apache.derby.iapi.reference.SQLState;
+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.io.StoredFormatIds;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-import org.apache.derby.iapi.sql.compile.Visitor;
-import org.apache.derby.iapi.error.StandardException;
-
 import org.apache.derby.iapi.sql.compile.TypeCompiler;
-import org.apache.derby.iapi.types.TypeId;
+import org.apache.derby.iapi.sql.compile.Visitor;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
-
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.ClassName;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
+import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.util.JBitSet;
 import org.apache.derby.iapi.util.ReuseFactory;
 
-import java.lang.reflect.Modifier;
-
-import java.sql.Types;
-import java.util.List;
 /**
  * A TernaryOperatorNode represents a built-in ternary operators.
- * This covers  built-in functions like substr().
+ * This covers  built-in functions like {@code substr()}.
  * Java operators are not represented here: the JSQL language allows Java
  * methods to be called from expressions, but not Java operators.
  *
  */
 
-public class TernaryOperatorNode extends OperatorNode
+class TernaryOperatorNode extends OperatorNode
 {
 	String		operator;
 	String		methodName;
@@ -68,12 +64,12 @@ public class TernaryOperatorNode extends
 	String		rightInterfaceType;
 	int			trimType;
 
-	public static final int TRIM = 0;
-	public static final int LOCATE = 1;
-	public static final int SUBSTRING = 2;
-	public static final int LIKE = 3;
-	public static final int TIMESTAMPADD = 4;
-	public static final int TIMESTAMPDIFF = 5;
+    static final int TRIM = 0;
+    static final int LOCATE = 1;
+    static final int SUBSTRING = 2;
+    static final int LIKE = 3;
+    static final int TIMESTAMPADD = 4;
+    static final int TIMESTAMPDIFF = 5;
 	static final String[] TernaryOperators = {"trim", "LOCATE", "substring", "like", "TIMESTAMPADD", "TIMESTAMPDIFF"};
 	static final String[] TernaryMethodNames = {"ansiTrim", "locate", "substring", "like", "timestampAdd", "timestampDiff"};
 	static final String[] TernaryResultType = {ClassName.StringDataValue, 
@@ -92,34 +88,73 @@ public class TernaryOperatorNode extends
 	};
 
 	/**
-	 * Initializer for a TernaryOperatorNode
+     * Constructor for a TernaryOperatorNode
 	 *
-	 * @param receiver		The receiver (eg, string being operated on in substr())
+     * @param receiver      The receiver (e.g., string being operated on in
+     *                      {@code substr()})
 	 * @param leftOperand	The left operand of the node
 	 * @param rightOperand	The right operand of the node
 	 * @param operatorType	The type of the operand
-	 */
+     * @param cm            The context manager
+     */
+    TernaryOperatorNode(
+                    ValueNode receiver,
+                    ValueNode leftOperand,
+                    ValueNode rightOperand,
+                    int operatorType,
+                    int trimType,
+                    ContextManager cm)
+    {
+        super(cm);
+        constructorMinion(
+                receiver, leftOperand, rightOperand, operatorType, trimType);
+    }
 
-	public void init(
-					Object receiver,
-					Object leftOperand,
-					Object rightOperand,
-					Object operatorType,
-					Object trimType)
-	{
-		this.receiver = (ValueNode) receiver;
-		this.leftOperand = (ValueNode) leftOperand;
-		this.rightOperand = (ValueNode) rightOperand;
-		this.operatorType = ((Integer) operatorType).intValue();
-		this.operator = (String) TernaryOperators[this.operatorType];
-		this.methodName = (String) TernaryMethodNames[this.operatorType];
-		this.resultInterfaceType = (String) TernaryResultType[this.operatorType];
-		this.receiverInterfaceType = (String) TernaryArgType[this.operatorType][0];
-		this.leftInterfaceType = (String) TernaryArgType[this.operatorType][1];
-		this.rightInterfaceType = (String) TernaryArgType[this.operatorType][2];
-		if (trimType != null)
-				this.trimType = ((Integer) trimType).intValue();
-	}
+    /**
+     * Constructor for a TernaryOperatorNode
+     *
+     * @param nodeType      The node type
+     * @param receiver      The receiver (e.g., string being operated on in
+     *                      {@code substr()})
+     * @param leftOperand   The left operand of the node
+     * @param rightOperand  The right operand of the node
+     * @param operatorType  The type of the operand
+     * @param cm            The context manager
+     */
+    TernaryOperatorNode(int nodeType,
+                        ValueNode receiver,
+                        ValueNode leftOperand,
+                        ValueNode rightOperand,
+                        int operatorType,
+                        int trimType,
+                        ContextManager cm)
+    {
+        super(cm);
+        setNodeType(nodeType);
+        constructorMinion(
+                receiver, leftOperand, rightOperand, operatorType, trimType);
+    }
+
+    private void constructorMinion(ValueNode receiver,
+                                   ValueNode leftOperand,
+                                   ValueNode rightOperand,
+                                   int operatorType,
+                                   int trimType) {
+        this.receiver = receiver;
+        this.leftOperand = leftOperand;
+        this.rightOperand = rightOperand;
+        this.operatorType = operatorType;
+        this.operator = TernaryOperators[this.operatorType];
+        this.methodName = TernaryMethodNames[this.operatorType];
+        this.resultInterfaceType = TernaryResultType[this.operatorType];
+        this.receiverInterfaceType = TernaryArgType[this.operatorType][0];
+        this.leftInterfaceType = TernaryArgType[this.operatorType][1];
+        this.rightInterfaceType = TernaryArgType[this.operatorType][2];
+
+        if (trimType != -1) {
+            this.trimType = trimType;
+        }
+    }
 
 	/**
 	 * Convert this object to a String.  See comments in QueryTreeNode.java
@@ -128,6 +163,7 @@ public class TernaryOperatorNode extends
 	 * @return	This object as a String
 	 */
 
+    @Override
 	public String toString()
 	{
 		if (SanityManager.DEBUG)
@@ -152,8 +188,8 @@ public class TernaryOperatorNode extends
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
-	public void printSubNodes(int depth)
+    @Override
+    void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
 		{
@@ -192,7 +228,7 @@ public class TernaryOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 			throws StandardException
 	{
@@ -236,7 +272,8 @@ public class TernaryOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ValueNode preprocess(int numTables,
+    @Override
+    ValueNode preprocess(int numTables,
 								FromList outerFromList,
 								SubqueryList outerSubqueryList,
 								PredicateList outerPredicateList) 
@@ -266,7 +303,7 @@ public class TernaryOperatorNode extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
 		throws StandardException
 	{
@@ -345,7 +382,7 @@ public class TernaryOperatorNode extends
 	 *
 	 * @param newLeftOperand	The new leftOperand
 	 */
-	public void setLeftOperand(ValueNode newLeftOperand)
+    void setLeftOperand(ValueNode newLeftOperand)
 	{
 		leftOperand = newLeftOperand;
 	}
@@ -355,7 +392,7 @@ public class TernaryOperatorNode extends
 	 *
 	 * @return The current leftOperand.
 	 */
-	public ValueNode getLeftOperand()
+    ValueNode getLeftOperand()
 	{
 		return leftOperand;
 	}
@@ -365,7 +402,7 @@ public class TernaryOperatorNode extends
 	 *
 	 * @param newRightOperand	The new rightOperand
 	 */
-	public void setRightOperand(ValueNode newRightOperand)
+    void setRightOperand(ValueNode newRightOperand)
 	{
 		rightOperand = newRightOperand;
 	}
@@ -375,7 +412,7 @@ public class TernaryOperatorNode extends
 	 *
 	 * @return The current rightOperand.
 	 */
-	public ValueNode getRightOperand()
+    ValueNode getRightOperand()
 	{
 		return rightOperand;
 	}
@@ -405,7 +442,8 @@ public class TernaryOperatorNode 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;
@@ -426,7 +464,8 @@ public class TernaryOperatorNode extends
 	 *
 	 * @exception StandardException			Thrown on error
 	 */
-	public ValueNode remapColumnReferencesToExpressions()
+    @Override
+    ValueNode remapColumnReferencesToExpressions()
 		throws StandardException
 	{
 		receiver = receiver.remapColumnReferencesToExpressions();
@@ -443,7 +482,8 @@ public class TernaryOperatorNode extends
 	 *
 	 * @return	Whether or not this expression tree represents a constant expression.
 	 */
-	public boolean isConstantExpression()
+    @Override
+    boolean isConstantExpression()
 	{
 		return (receiver.isConstantExpression() &&
 				leftOperand.isConstantExpression() &&
@@ -451,7 +491,8 @@ public class TernaryOperatorNode extends
 	}
 
 	/** @see ValueNode#constantExpression */
-	public boolean constantExpression(PredicateList whereClause)
+    @Override
+    boolean constantExpression(PredicateList whereClause)
 	{
 		return (receiver.constantExpression(whereClause) &&
 				leftOperand.constantExpression(whereClause) &&
@@ -466,6 +507,7 @@ public class TernaryOperatorNode extends
 	 *
 	 * @exception StandardException on error
 	 */
+    @Override
 	void acceptChildren(Visitor v)
 		throws StandardException
 	{
@@ -604,7 +646,7 @@ public class TernaryOperatorNode extends
 	 * @exception StandardException		Thrown on error
 	 */
 
-	public ValueNode locateBind() throws StandardException
+    ValueNode locateBind() throws StandardException
 	{
 		TypeId	firstOperandType, secondOperandType, offsetType;
 
@@ -706,12 +748,7 @@ public class TernaryOperatorNode extends
 	                vnTC.getCastToCharWidth(
 		                    vn.getTypeServices()));
 
-			ValueNode newNode = (ValueNode)
-						getNodeFactory().getNode(
-							C_NodeTypes.CAST_NODE,
-							vn,
-							dtd,
-							getContextManager());
+            ValueNode newNode = new CastNode(vn, dtd, getContextManager());
             
             // DERBY-2910 - Match current schema collation for implicit cast as we do for
             // explicit casts per SQL Spec 6.12 (10)                                                
@@ -731,7 +768,7 @@ public class TernaryOperatorNode extends
 	 * @exception StandardException		Thrown on error
 	 */
 
- 	public ValueNode substrBind() 
+    ValueNode substrBind()
 			throws StandardException
 	{
 		TypeId	receiverType;
@@ -908,7 +945,7 @@ public class TernaryOperatorNode extends
         return false;
     } // end of bindParameter
 
-	public ValueNode getReceiver()
+    ValueNode getReceiver()
 	{
 		return receiver;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TestConstraintNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TestConstraintNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TestConstraintNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TestConstraintNode.java Fri Jun 21 07:47:47 2013
@@ -22,18 +22,14 @@
 package	org.apache.derby.impl.sql.compile;
 
 import java.util.List;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.reference.ClassName;
-
 import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
+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.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
 
 /**
  * A TestConstraintNode is used to determine when a constraint
@@ -41,34 +37,35 @@ import org.apache.derby.iapi.services.cl
  *
  */
 
-public class TestConstraintNode extends UnaryLogicalOperatorNode
+class TestConstraintNode extends UnaryLogicalOperatorNode
 {
 	private String sqlState;
 	private String tableName;
 	private String constraintName;
 
-	/**
-	 * Initializer for a TestConstraintNode
-	 *
-	 * @param booleanValue	The operand of the constraint test
-	 * @param sqlState	The SQLState of the exception to throw if the
-	 *					constraint has failed
-	 * @param tableName	The name of the table that the constraint is on
-	 * @param constraintName	The name of the constraint being checked
-	 */
-
-	public void init(Object booleanValue,
-					 Object sqlState,
-					 Object tableName,
-					 Object constraintName)
-	{
-		super.init(booleanValue, "throwExceptionIfFalse");
-		this.sqlState = (String) sqlState;
-		this.tableName = (String) tableName;
-		this.constraintName = (String) constraintName;
-	}
+    /**
+     * @param booleanValue The operand of the constraint test
+     * @param sqlState The SQLState of the exception to throw if the
+    *              constraint has failed
+     * @param tableName The name of the table that the constraint is on
+     * @param constraintName The name of the constraint being checked
+     * @param cm context manager
+     * @throws StandardException
+     */
+    TestConstraintNode(
+            ValueNode booleanValue,
+            String sqlState,
+            String tableName,
+            String constraintName,
+            ContextManager cm) throws StandardException {
+        super(booleanValue, "throwExceptionIfFalse", cm);
+        setNodeType(C_NodeTypes.TEST_CONSTRAINT_NODE);
+        this.sqlState = sqlState;
+       this.tableName = tableName;
+       this.constraintName = constraintName;
+    }
 
-	/**
+    /**
 	 * Bind this logical operator.  All that has to be done for binding
 	 * a logical operator is to bind the operand, check that the operand
 	 * is SQLBoolean, and set the result type to SQLBoolean.
@@ -81,7 +78,6 @@ public class TestConstraintNode extends 
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
     ValueNode bindExpression(
         FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 			throws StandardException
@@ -94,9 +90,7 @@ public class TestConstraintNode extends 
 
 		if (!operand.getTypeServices().getTypeId().isBooleanTypeId())
 		{
-			operand = (ValueNode)
-				getNodeFactory().getNode(
-					C_NodeTypes.CAST_NODE,
+            operand = new CastNode(
 					operand,
 					new DataTypeDescriptor(TypeId.BOOLEAN_ID, true),
 					getContextManager());
@@ -118,7 +112,7 @@ public class TestConstraintNode extends 
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
 									throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java Fri Jun 21 07:47:47 2013
@@ -21,24 +21,14 @@
 
 package org.apache.derby.impl.sql.compile;
 
+import java.sql.Types;
+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.types.DataTypeDescriptor;
+import org.apache.derby.iapi.sql.compile.TypeCompiler;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.DateTimeDataValue;
-import org.apache.derby.iapi.types.DataValueFactory;
 import org.apache.derby.iapi.types.TypeId;
 
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import java.sql.Types;
-import org.apache.derby.iapi.reference.ClassName;
-
-public class TimeTypeCompiler extends BaseTypeCompiler
+class TimeTypeCompiler extends BaseTypeCompiler
 {
 	/* TypeCompiler methods */
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,40 +21,41 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import java.sql.Types;
+import java.util.List;
 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 java.sql.Types;
-
-import java.util.List;
+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.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
 
 /**
  * The TimestampOperatorNode class implements the timestamp( date, time) function.
  */
 
-public class TimestampOperatorNode extends BinaryOperatorNode
+class TimestampOperatorNode extends BinaryOperatorNode
 {
 
     /**
-     * Initailizer for a TimestampOperatorNode.
+     * Constructor for a TimestampOperatorNode.
      *
      * @param date The date
      * @param time The time
+     * @param cm   The context manager
      */
 
-    public void init( Object date,
-                      Object time)
+    TimestampOperatorNode(ValueNode date,
+                          ValueNode time,
+                          ContextManager cm)
     {
-        leftOperand = (ValueNode) date;
-        rightOperand = (ValueNode) time;
+        super(cm);
+        setNodeType(C_NodeTypes.TIMESTAMP_OPERATOR_NODE);
+        leftOperand = date;
+        rightOperand = time;
         operator = "timestamp";
         methodName = "getTimestamp";
     }
@@ -73,7 +74,7 @@ public class TimestampOperatorNode exten
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     ValueNode bindExpression(
         FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 			throws StandardException
@@ -113,7 +114,7 @@ public class TimestampOperatorNode exten
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
 		throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java Fri Jun 21 07:47:47 2013
@@ -21,23 +21,14 @@
 
 package org.apache.derby.impl.sql.compile;
 
+import java.sql.Types;
+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.sql.compile.TypeCompiler;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.DateTimeDataValue;
-import org.apache.derby.iapi.types.DataValueFactory;
 import org.apache.derby.iapi.types.TypeId;
 
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import java.sql.Types;
-import org.apache.derby.iapi.reference.ClassName;
-
-public class TimestampTypeCompiler extends BaseTypeCompiler
+class TimestampTypeCompiler extends BaseTypeCompiler
 {
 	/* TypeCompiler methods */	
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Token.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Token.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Token.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Token.java Fri Jun 21 07:47:47 2013
@@ -81,6 +81,7 @@ class Token {
   /**
    * Returns the image.
    */
+  @Override
   public String toString()
   {
      return image;
@@ -98,7 +99,7 @@ class Token {
    * to the following switch statement. Then you can cast matchedToken
    * variable to the appropriate type and use it in your lexical actions.
    */
-  public static final Token newToken(int ofKind)
+  public static Token newToken(int ofKind)
   {
      switch(ofKind)
      {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TransactionStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TransactionStatementNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TransactionStatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TransactionStatementNode.java Fri Jun 21 07:47:47 2013
@@ -24,8 +24,6 @@ package	org.apache.derby.impl.sql.compil
 
 import org.apache.derby.iapi.services.context.ContextManager;
 
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
 /**
  * A TransactionStatementNode represents any type of Transaction statement: 
  * SET TRANSACTION, COMMIT, and ROLLBACK.
@@ -34,6 +32,11 @@ import org.apache.derby.iapi.services.sa
 
 abstract class TransactionStatementNode extends StatementNode
 {
+
+    TransactionStatementNode(ContextManager cm) {
+        super(cm);
+    }
+
 	int activationKind()
 	{
 		   return StatementNode.NEED_NOTHING_ACTIVATION;
@@ -44,6 +47,7 @@ abstract class TransactionStatementNode 
 	 *
 	 * @return false 
 	 */	
+    @Override
 	public boolean isAtomic() 
 	{
 		return false;
@@ -57,6 +61,7 @@ abstract class TransactionStatementNode 
 	 *
 	 * @return boolean	Whether or not this Statement requires a set/clear savepoint
 	 */
+    @Override
 	public boolean needsSavepoint()
 	{
 		return false;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TriggerReferencingStruct.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TriggerReferencingStruct.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TriggerReferencingStruct.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TriggerReferencingStruct.java Fri Jun 21 07:47:47 2013
@@ -26,13 +26,13 @@ package org.apache.derby.impl.sql.compil
  * a REFERENCING clause for a trigger.
  *
  */
-public class TriggerReferencingStruct 
+class TriggerReferencingStruct
 {
-	public String identifier;
-	public boolean isRow;
-	public boolean isNew;
+    String identifier;
+    boolean isRow;
+    boolean isNew;
 
-	public TriggerReferencingStruct
+    TriggerReferencingStruct
 	(
 		boolean	isRow, 
 		boolean	isNew,
@@ -44,6 +44,7 @@ public class TriggerReferencingStruct 
 		this.identifier = identifier;
 	}
 
+    @Override
 	public String toString()
 	{
 		return (isRow ? "ROW " : "TABLE ")+(isNew ? "new: " : "old: ") + identifier;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java Fri Jun 21 07:47:47 2013
@@ -21,14 +21,12 @@
 
 package org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.sql.compile.TypeCompilerFactory;
+import java.sql.Types;
+import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.compile.TypeCompiler;
+import org.apache.derby.iapi.sql.compile.TypeCompilerFactory;
 import org.apache.derby.iapi.types.TypeId;
 
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import java.sql.Types;
-
 public class TypeCompilerFactoryImpl implements TypeCompilerFactory
 {
         private static final String PACKAGE_NAME =

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UCode_CharStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UCode_CharStream.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UCode_CharStream.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UCode_CharStream.java Fri Jun 21 07:47:47 2013
@@ -58,7 +58,7 @@ public final class UCode_CharStream impl
   private int maxNextCharInd = 0;
   private int nextCharInd = -1;
 
-  private final void ExpandBuff(boolean wrapAround)
+  private void ExpandBuff(boolean wrapAround)
   {
      char[] newbuffer = new char[bufsize + 2048];
      int newbufline[] = new int[bufsize + 2048];
@@ -121,7 +121,7 @@ public final class UCode_CharStream impl
      tokenBegin = 0;
   }
 
-  private final void FillBuff() throws java.io.IOException
+  private void FillBuff() throws java.io.IOException
   {
      if (maxNextCharInd == nextCharBuf.length)
         maxNextCharInd = nextCharInd = 0;
@@ -136,7 +136,6 @@ public final class UCode_CharStream impl
         }
         else
            maxNextCharInd += i;
-        return;
      }
      catch(java.io.IOException e) {
         if (bufpos != 0)
@@ -155,7 +154,7 @@ public final class UCode_CharStream impl
      }
   }
 
-  private final char ReadChar() throws java.io.IOException
+  private char ReadChar() throws java.io.IOException
   {
      if (++nextCharInd >= maxNextCharInd)
         FillBuff();
@@ -179,7 +178,7 @@ public final class UCode_CharStream impl
      return c;
   }     
 
-  private final void UpdateLineColumn(char c)
+  private void UpdateLineColumn(char c)
   {
      column++;
 
@@ -225,7 +224,7 @@ public final class UCode_CharStream impl
      if (inBuf > 0)
      {
         --inBuf;
-        return (char)buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos];
+        return buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos];
      }
 
      if (++bufpos == available)
@@ -265,7 +264,7 @@ public final class UCode_CharStream impl
    * @deprecated 
    * @see #getEndColumn
    */
-
+  @Deprecated
   public final int getColumn() {
      return bufcolumn[bufpos];
   }
@@ -274,7 +273,7 @@ public final class UCode_CharStream impl
    * @deprecated 
    * @see #getEndLine
    */
-
+  @Deprecated
   public final int getLine() {
      return bufline[bufpos];
   }
@@ -443,13 +442,13 @@ public final class UCode_CharStream impl
      }
 
      int i = 0, j = 0, k = 0;
-     int nextColDiff = 0, columnDiff = 0;
+     int columnDiff = 0;
 
      while (i < len &&
             bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
      {
         bufline[j] = newLine;
-        nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+        int nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
         bufcolumn[j] = newCol + columnDiff;
         columnDiff = nextColDiff;
         i++;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,86 +21,80 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
 import java.sql.Types;
 import java.util.List;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
 
 /**
  * This node represents a unary arithmetic operator
  *
  */
 
-public class UnaryArithmeticOperatorNode extends UnaryOperatorNode
+class UnaryArithmeticOperatorNode extends UnaryOperatorNode
 {
-	private final static int UNARY_PLUS	= 0;
-	private final static int UNARY_MINUS	= 1;
-	private final static int SQRT = 2;
-	private final static int ABSOLUTE = 3;
 	private final static String[] UNARY_OPERATORS = {"+","-","SQRT", "ABS/ABSVAL"};
 	private final static String[] UNARY_METHODS = {"plus","minus","sqrt", "absolute"};
 
-	private int operatorType;
-  
-	/**
-	 * Initializer for a UnaryArithmeticOperatorNode
-	 *
-	 * @param operand		The operand of the node
-	 */
-	public void init(Object operand)
-	{
-		switch(getNodeType())
-		{
-			case C_NodeTypes.UNARY_PLUS_OPERATOR_NODE:
-				operatorType = UNARY_PLUS;
-				break;
-			case C_NodeTypes.UNARY_MINUS_OPERATOR_NODE:
-				operatorType = UNARY_MINUS;
-				break;
-			case C_NodeTypes.SQRT_OPERATOR_NODE:
-				operatorType = SQRT;
-				break;
-			case C_NodeTypes.ABSOLUTE_OPERATOR_NODE:
-				operatorType = ABSOLUTE;
-				break;
-			default:
-				if (SanityManager.DEBUG)
-				{
-					SanityManager.THROWASSERT("init for UnaryArithmeticOperator called with wrong nodeType = " + getNodeType());
-				}
-			    break;
-		}
-		init(operand, UNARY_OPERATORS[this.operatorType], 
-				UNARY_METHODS[this.operatorType]);
-	}
+   private final OperatorType operatorType;
+
+    public enum OperatorType {PLUS(0), MINUS(1), SQRT(2), ABS(3);
+
+        private int representation;
+
+        private OperatorType(int repr) {
+            this.representation = repr;
+        }
+
+        public int getVal() { return representation; }
+    }
     
     /**
+     * @param operand The operand of the node
+     * @param type unary operator identity
+     * @param cm context manager
+     * @throws StandardException
+     */
+    UnaryArithmeticOperatorNode(
+            ValueNode operand,
+            OperatorType type,
+            ContextManager cm) throws StandardException {
+        super(operand,
+              UNARY_OPERATORS[type.getVal()],
+              UNARY_METHODS[type.getVal()],
+              cm);
+        this.operatorType = type;
+    }
+    /**
      * Unary + and - require their type to be set if
      * they wrap another node (e.g. a parameter) that
      * requires type from its context.
      * @see ValueNode#requiresTypeFromContext
      */
+    @Override
     public boolean requiresTypeFromContext()
     {
-        if (operatorType == UNARY_PLUS || operatorType == UNARY_MINUS)
+        if (operatorType == OperatorType.PLUS ||
+            operatorType == OperatorType.MINUS) {
             return operand.requiresTypeFromContext(); 
+        }
         return false;
     }
     
     /**
      * A +? or a -? is considered a parameter.
      */
+    @Override
     public boolean isParameterNode()
     {
-        if (operatorType == UNARY_PLUS || operatorType == UNARY_MINUS)
+        if (operatorType == OperatorType.PLUS ||
+            operatorType == OperatorType.MINUS) {
             return operand.isParameterNode(); 
+        }
         return false;
     }
 
@@ -115,10 +109,11 @@ public class UnaryArithmeticOperatorNode
 	 *									have a type bound to it yet.
 	 *									? parameter where it isn't allowed.
 	 */
-
+    @Override
 	void bindParameter() throws StandardException
 	{
-		if (operatorType == SQRT || operatorType == ABSOLUTE)
+       if (operatorType == OperatorType.SQRT ||
+            operatorType == OperatorType.ABS)
 		{
 			operand.setType(
 				new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.DOUBLE), true));
@@ -126,7 +121,8 @@ public class UnaryArithmeticOperatorNode
 		}
         
 		//Derby-582 add support for dynamic parameter for unary plus and minus
-		if (operatorType == UNARY_MINUS || operatorType == UNARY_PLUS) 
+       if (operatorType == OperatorType.MINUS ||
+            operatorType == OperatorType.PLUS)
 			return;
         
         // Not expected to get here since only the above types are supported
@@ -146,23 +142,27 @@ public class UnaryArithmeticOperatorNode
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     ValueNode bindExpression(
         FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 			throws StandardException
 	{
 		//Return with no binding, if the type of unary minus/plus parameter is not set yet.
-		if (operand.requiresTypeFromContext() && ((operatorType == UNARY_PLUS || operatorType == UNARY_MINUS))
+       if (operand.requiresTypeFromContext() &&
+                ((operatorType == OperatorType.PLUS ||
+                  operatorType == OperatorType.MINUS))
 				&& operand.getTypeServices() == null)
 				return this;
 
         bindOperand(fromList, subqueryList, aggregates);
 
-		if (operatorType == SQRT || operatorType == ABSOLUTE)
+       if (operatorType == OperatorType.SQRT ||
+            operatorType == OperatorType.ABS)
 		{
 			bindSQRTABS();
 		}
-		else if (operatorType == UNARY_PLUS || operatorType == UNARY_MINUS)
+       else if (operatorType == OperatorType.PLUS ||
+                 operatorType == OperatorType.MINUS)
 		{
             checkOperandIsNumeric(operand.getTypeId());
 		}
@@ -183,7 +183,7 @@ public class UnaryArithmeticOperatorNode
 	    {
 	        throw StandardException.newException(
                     SQLState.LANG_UNARY_ARITHMETIC_BAD_TYPE, 
-	                (operatorType == UNARY_PLUS) ? "+" : "-", 
+                   (operatorType == OperatorType.PLUS) ? "+" : "-",
 	                        operandType.getSQLTypeName());
 	    }
 	    
@@ -197,12 +197,12 @@ public class UnaryArithmeticOperatorNode
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
 									throws StandardException
 	{
 		/* Unary + doesn't do anything.  Just return the operand */
-		if (operatorType == UNARY_PLUS)
+       if (operatorType == OperatorType.PLUS)
 			operand.generateExpression(acb, mb);
 		else
 			super.generateExpression(acb, mb);
@@ -242,10 +242,10 @@ public class UnaryArithmeticOperatorNode
 						getOperatorString(), operandType.getSQLTypeName());
 
 		/* For SQRT, if operand is not a DOUBLE, convert it to DOUBLE */
-		if (operatorType == SQRT && jdbcType != Types.DOUBLE)
+       if (operatorType == OperatorType.SQRT &&
+            jdbcType != Types.DOUBLE)
 		{
-			operand = (ValueNode) getNodeFactory().getNode(
-					C_NodeTypes.CAST_NODE,
+            operand = new CastNode(
 					operand,
 					new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.DOUBLE), true),
 					getContextManager());
@@ -257,7 +257,8 @@ public class UnaryArithmeticOperatorNode
 	the type of these dynamic parameters and hence we can do the parameter
 	binding. The setType method will call the binding code after setting
 	the type of the parameter*/
-	public void setType(DataTypeDescriptor descriptor) throws StandardException
+    @Override
+    void setType(DataTypeDescriptor descriptor) throws StandardException
 	{
         if (operand.requiresTypeFromContext() && operand.getTypeServices() == null)
         {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryComparisonOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryComparisonOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryComparisonOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryComparisonOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -22,27 +22,18 @@
 package	org.apache.derby.impl.sql.compile;
 
 import java.util.List;
+import org.apache.derby.iapi.error.StandardException;
+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.ExpressionClassBuilderInterface;
 import org.apache.derby.iapi.sql.compile.Optimizable;
-
 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
 import org.apache.derby.iapi.store.access.ScanController;
-
-import org.apache.derby.iapi.error.StandardException;
-
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.util.JBitSet;
 
-
 /**
  * This node is the superclass  for all unary comparison operators, such as is null
  * and is not null.
@@ -51,6 +42,11 @@ import org.apache.derby.iapi.util.JBitSe
 
 public abstract class UnaryComparisonOperatorNode extends UnaryOperatorNode
 {
+    UnaryComparisonOperatorNode(ValueNode operator, ContextManager cm)
+            throws StandardException {
+        super(operator, cm);
+    }
+
 	/**
 	 * Bind this comparison operator.  All that has to be done for binding
 	 * a comparison operator is to bind the operand and set the result type 
@@ -64,7 +60,7 @@ public abstract class UnaryComparisonOpe
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     ValueNode bindExpression(
         FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 			throws StandardException
@@ -84,7 +80,7 @@ public abstract class UnaryComparisonOpe
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public void bindComparisonOperator()
+    void bindComparisonOperator()
 			throws StandardException
 	{
 		/*
@@ -111,6 +107,7 @@ public abstract class UnaryComparisonOpe
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	ValueNode eliminateNots(boolean underNotNode) 
 					throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryDateTimestampOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryDateTimestampOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryDateTimestampOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryDateTimestampOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,25 +21,19 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.types.DataValueFactory;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.DataValueDescriptor;
-import org.apache.derby.iapi.types.DateTimeDataValue;
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
+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.reference.ClassName;
 import org.apache.derby.iapi.reference.SQLState;
-
 import org.apache.derby.iapi.services.classfile.VMOpcode;
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import java.sql.Types;
-
-import java.util.List;
+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.DataTypeDescriptor;
+import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.iapi.types.DataValueFactory;
+import org.apache.derby.iapi.types.DateTimeDataValue;
 
 /**
  * This class implements the timestamp( x) and date(x) functions.
@@ -47,39 +41,33 @@ import java.util.List;
  * These two functions implement a few special cases of string conversions beyond the normal string to
  * date/timestamp casts.
  */
-public class UnaryDateTimestampOperatorNode extends UnaryOperatorNode
+class UnaryDateTimestampOperatorNode extends UnaryOperatorNode
 {
     private static final String TIMESTAMP_METHOD_NAME = "getTimestamp";
     private static final String DATE_METHOD_NAME = "getDate";
     
+    enum OperatorType {DATE, TIMESTAMP};
+
     /**
      * @param operand The operand of the function
-     * @param targetType The type of the result. Timestamp or Date.
-     *
-	 * @exception StandardException		Thrown on error
-	 */
-
-	public void init( Object operand, Object targetType)
-		throws StandardException
-	{
-		setType( (DataTypeDescriptor) targetType);
-        switch( getTypeServices().getJDBCTypeId())
-        {
-        case Types.DATE:
-            super.init( operand, "date", DATE_METHOD_NAME);
-            break;
-
-        case Types.TIMESTAMP:
-            super.init( operand, "timestamp", TIMESTAMP_METHOD_NAME);
-            break;
-
-        default:
-            if( SanityManager.DEBUG)
-                SanityManager.NOTREACHED();
-            super.init( operand);
-        }
+     * @param type The type of the result, Date or Timestamp.
+     * @param cm context manager
+     * @throws StandardException
+     */
+    UnaryDateTimestampOperatorNode(
+            ValueNode operand,
+            OperatorType type,
+            ContextManager cm) throws StandardException {
+        super(operand,
+                type == OperatorType.DATE ? "date" : "timestamp",
+                type == OperatorType.DATE ?
+                    DATE_METHOD_NAME : TIMESTAMP_METHOD_NAME,
+                cm);
+        setNodeType(C_NodeTypes.UNARY_DATE_TIMESTAMP_OPERATOR_NODE);
+        setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(
+                type == OperatorType.DATE ? Types.DATE : Types.TIMESTAMP));
     }
-    
+
     /**
      * Called by UnaryOperatorNode.bindExpression.
      *
@@ -96,6 +84,7 @@ public class UnaryDateTimestampOperatorN
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
     ValueNode bindExpression (
                     FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 				throws StandardException
@@ -146,7 +135,7 @@ public class UnaryDateTimestampOperatorN
         {
             DataValueFactory dvf = getLanguageConnectionContext().getDataValueFactory();
             DataValueDescriptor sourceValue = ((ConstantNode) operand).getValue();
-            DataValueDescriptor destValue = null;
+            DataValueDescriptor destValue;
             if( sourceValue.isNull())
             {
                 destValue = (TIMESTAMP_METHOD_NAME.equals( methodName))
@@ -158,8 +147,8 @@ public class UnaryDateTimestampOperatorN
                 destValue = (TIMESTAMP_METHOD_NAME.equals( methodName))
                   ? dvf.getTimestamp( sourceValue) : dvf.getDate( sourceValue);
             }
-            return (ValueNode) getNodeFactory().getNode( C_NodeTypes.USERTYPE_CONSTANT_NODE,
-                                                         destValue, getContextManager());
+
+            return new UserTypeConstantNode(destValue, getContextManager());
         }
 
         if( isIdentity)
@@ -182,7 +171,7 @@ public class UnaryDateTimestampOperatorN
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     void generateExpression( ExpressionClassBuilder acb, MethodBuilder mb)
         throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryLogicalOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryLogicalOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryLogicalOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryLogicalOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -22,34 +22,21 @@
 package	org.apache.derby.impl.sql.compile;
 
 import java.util.List;
-
-import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
-
+import org.apache.derby.iapi.types.TypeId;
 
 public abstract class UnaryLogicalOperatorNode extends UnaryOperatorNode
 {
-	/**
-	 * Initializer for a UnaryLogicalOperatorNode
-	 *
-	 * @param operand	The operand of the operator
-	 * @param methodName	The name of the method to call in the generated
-	 *						class.  In this case, it's actually an operator
-	 *						name.
-	 */
+    UnaryLogicalOperatorNode(ValueNode operand,
+            String methodName,
+            ContextManager cm) throws StandardException {
+        super(operand, methodName, methodName, cm);
+    }
 
-	public void init(
-				Object	operand,
-				Object		methodName)
-	{
-		/* For logical operators, the operator and method names are the same */
-		super.init(operand, methodName, methodName);
-	}
-
-	/**
+    /**
 	 * Bind this logical operator.  All that has to be done for binding
 	 * a logical operator is to bind the operand, check that the operand
 	 * is SQLBoolean, and set the result type to SQLBoolean.
@@ -62,7 +49,7 @@ public abstract class UnaryLogicalOperat
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     ValueNode bindExpression(
         FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 			throws StandardException

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,27 +21,22 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.store.access.Qualifier;
-
-import org.apache.derby.iapi.sql.compile.Visitor;
-
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.ClassName;
+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.services.sanity.SanityManager;
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
+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.LocalField;
-
-import org.apache.derby.iapi.types.TypeId;
+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.store.access.Qualifier;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
-
-import java.lang.reflect.Modifier;
-
+import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
-import java.sql.Types;
-import java.util.List;
 
 /**
  * A UnaryOperatorNode represents a built-in unary operator as defined by
@@ -51,7 +46,7 @@ import java.util.List;
  *
  */
 
-public class UnaryOperatorNode extends OperatorNode
+class UnaryOperatorNode extends OperatorNode
 {
 	String	operator;
 	String	methodName;
@@ -83,8 +78,8 @@ public class UnaryOperatorNode extends O
     // node implementations, in its other mode it is a concrete
     // class for XMLPARSE and XMLSERIALIZE.
 
-	public final static int XMLPARSE_OP = 0;
-	public final static int XMLSERIALIZE_OP = 1;
+    final static int XMLPARSE_OP = 0;
+    final static int XMLSERIALIZE_OP = 1;
 
 	// NOTE: in the following 4 arrays, order
 	// IS important.
@@ -115,69 +110,61 @@ public class UnaryOperatorNode extends O
     /** Whether or not an XMLParse operator should preserve whitespace. */
     private boolean preserveWhitespace;
 
-	/**
-	 * Initializer for a UnaryOperatorNode.
-	 *
-	 * <ul>
-	 * @param operand	The operand of the node
-	 * @param operatorOrOpType	Either 1) the name of the operator,
-	 *  OR 2) an Integer holding the operatorType for this operator.
-	 * @param methodNameOrAddedArgs	Either 1) name of the method
-	 *  to call for this operator, or 2) an array of Objects
-	 *  from which primitive method parameters can be
-	 *  retrieved.
-	 */
-
-	public void init(
-					Object	operand,
-					Object		operatorOrOpType,
-					Object		methodNameOrAddedArgs)
-	{
-		this.operand = (ValueNode) operand;
-		if (operatorOrOpType instanceof String) {
-		// then 2nd and 3rd params are operator and methodName,
-		// respectively.
-			this.operator = (String) operatorOrOpType;
-			this.methodName = (String) methodNameOrAddedArgs;
-			this.operatorType = -1;
-		}
-		else {
-		// 2nd and 3rd params are operatorType and additional args,
-		// respectively.
-			if (SanityManager.DEBUG) {
-				SanityManager.ASSERT(
-					((operatorOrOpType instanceof Integer) &&
-                      ((methodNameOrAddedArgs instanceof DataTypeDescriptor) ||
-                       (methodNameOrAddedArgs instanceof Boolean))),
-					"Init params in UnaryOperator node have the " +
-					"wrong type.");
-			}
-			this.operatorType = ((Integer) operatorOrOpType).intValue();
-			this.operator = UnaryOperators[this.operatorType];
-			this.methodName = UnaryMethodNames[this.operatorType];
-			this.resultInterfaceType = UnaryResultTypes[this.operatorType];
-			this.receiverInterfaceType = UnaryArgTypes[this.operatorType];
-            if (operatorType == XMLSERIALIZE_OP) {
-                targetType = (DataTypeDescriptor) methodNameOrAddedArgs;
-            } else if (operatorType == XMLPARSE_OP) {
-                preserveWhitespace =
-                    ((Boolean) methodNameOrAddedArgs).booleanValue();
-            } else if (SanityManager.DEBUG) {
-                SanityManager.THROWASSERT(
-                    "Don't know how to handle operator type " + operatorType);
-            }
-		}
-	}
+    UnaryOperatorNode(ValueNode operand,
+            String operator,
+            String methodNameOrAddedArgs,
+            ContextManager cm) throws StandardException {
+        super(cm);
+        this.operand = operand;
+        this.operator = operator;
+        this.methodName = methodNameOrAddedArgs;
+        this.operatorType = -1;
+    }
+
+    UnaryOperatorNode(ValueNode operand, ContextManager cm) {
+        super(cm);
+        this.operand = operand;
+        this.operatorType = -1;
+    }
 
 	/**
-	 * Initializer for a UnaryOperatorNode
+     * Constructor for a UnaryOperatorNode.
 	 *
-	 * @param operand	The operand of the node
-	 */
-	public void init(Object	operand)
-	{
-		this.operand = (ValueNode) operand;
-		this.operatorType = -1;
+     * @param operand       The operand of the node
+     * @param operatorType  Either 1) the name of the operator,
+     *                      OR 2) an Integer holding the operatorType
+     *                      for this operator.
+     * @param methodNameOrAddedArgs
+     *                      Either 1) name of the method to call for
+     *                      this operator, or 2) an array of Objects
+     *                      from which primitive method parameters can
+     *                      be retrieved.
+     * @param cm            The context manager
+	 */
+    UnaryOperatorNode(int                nodeType,
+                      ValueNode          operand,
+                      int                operatorType,
+                      DataTypeDescriptor targetType,
+                      boolean            preserveWhiteSpace,
+                      ContextManager     cm)
+	{
+        super(cm);
+        setNodeType(nodeType);
+        this.operand = operand;
+        this.operatorType = operatorType;
+        this.operator = UnaryOperators[this.operatorType];
+        this.methodName = UnaryMethodNames[this.operatorType];
+        this.resultInterfaceType = UnaryResultTypes[this.operatorType];
+        this.receiverInterfaceType = UnaryArgTypes[this.operatorType];
+
+        if (operatorType == XMLSERIALIZE_OP) {
+            this.targetType = targetType;
+        } else if (operatorType == XMLPARSE_OP) {
+            this.preserveWhitespace = preserveWhiteSpace;
+        } else if (SanityManager.DEBUG) {
+            SanityManager.THROWASSERT(
+                    "Don't know how to handle operator type " + operatorType);
+        }
 	}
 
 	/**
@@ -218,7 +205,7 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @return		This object as a String
 	 */
-
+    @Override
 	public String toString()
 	{
 		if (SanityManager.DEBUG)
@@ -239,8 +226,8 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
-	public void printSubNodes(int depth)
+    @Override
+    void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
 		{
@@ -259,7 +246,7 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @return	The operand of this unary operator.
 	 */
-	public ValueNode getOperand()
+    ValueNode getOperand()
 	{
 		return operand;
 	}
@@ -274,7 +261,7 @@ public class UnaryOperatorNode extends O
 	 * 
 	 * @return	The parameter operand of this unary operator else null.
 	 */
-	public ParameterNode getParameterOperand() throws StandardException
+    ParameterNode getParameterOperand() throws StandardException
 	{
 		if (requiresTypeFromContext() == false)
 			return null;
@@ -303,7 +290,7 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     ValueNode bindExpression(
             FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 				throws StandardException
@@ -453,7 +440,8 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ValueNode preprocess(int numTables,
+    @Override
+    ValueNode preprocess(int numTables,
 								FromList outerFromList,
 								SubqueryList outerSubqueryList,
 								PredicateList outerPredicateList) 
@@ -494,7 +482,8 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @exception StandardException			Thrown on error
 	 */
-	public boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
+    @Override
+    boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
 		throws StandardException
 	{
 		return (operand == null) ? 
@@ -510,7 +499,8 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @exception StandardException			Thrown on error
 	 */
-	public ValueNode remapColumnReferencesToExpressions()
+    @Override
+    ValueNode remapColumnReferencesToExpressions()
 		throws StandardException
 	{
 		if (operand != null)
@@ -525,13 +515,15 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @return	Whether or not this expression tree represents a constant expression.
 	 */
-	public boolean isConstantExpression()
+    @Override
+    boolean isConstantExpression()
 	{
 		return (operand == null) ? true: operand.isConstantExpression();
 	}
 
 	/** @see ValueNode#constantExpression */
-	public boolean constantExpression(PredicateList whereClause)
+    @Override
+    boolean constantExpression(PredicateList whereClause)
 	{
 		return (operand == null) ?
 					true :
@@ -605,7 +597,7 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
 									throws StandardException
 	{
@@ -657,7 +649,7 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public String getReceiverInterfaceName() throws StandardException {
+    String getReceiverInterfaceName() throws StandardException {
 		if (SanityManager.DEBUG)
 		{
 			SanityManager.ASSERT(operand!=null,
@@ -684,6 +676,7 @@ public class UnaryOperatorNode extends O
 	 * @return	The variant type for the underlying expression.
 	 * @exception StandardException	thrown on error
 	 */
+    @Override
 	protected int getOrderableVariantType() throws StandardException
 	{
 		/*
@@ -702,6 +695,7 @@ public class UnaryOperatorNode extends O
 	 *
 	 * @exception StandardException on error
 	 */
+    @Override
 	void acceptChildren(Visitor v)
 		throws StandardException
 	{