db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r332635 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile: ColumnReference.java CreateTriggerNode.java QueryTreeNode.java TableName.java
Date Fri, 11 Nov 2005 19:43:29 GMT
Author: djd
Date: Fri Nov 11 11:43:10 2005
New Revision: 332635

URL: http://svn.apache.org/viewcvs?rev=332635&view=rev
Log:
Methods tracking the begin and end offset of the Node in the SQL statement are duplicated
in TableName.java and ColumnReference.java. The parent class QueryTreeNode has implementations
of these methods, should use those consistently.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java?rev=332635&r1=332634&r2=332635&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
Fri Nov 11 11:43:10 2005
@@ -80,13 +80,6 @@
 	private int			nestingLevel = -1;
 	private int			sourceLevel = -1;
 
-	/*
-	** These fields are used to track the being and end
-	** offset of the token from which the column name came.
-	*/
-	private int		tokBeginOffset = -1;
-	private int		tokEndOffset = -1;
-
 	/**
 	 * Initializer.
 	 * This one is called by the parser where we could
@@ -108,8 +101,8 @@
 	{
 		this.columnName = (String) columnName;
 		this.tableName = (TableName) tableName;
-		this.tokBeginOffset = ((Integer) tokBeginOffset).intValue();
-		this.tokEndOffset = ((Integer) tokEndOffset).intValue();
+		this.setBeginOffset(((Integer) tokBeginOffset).intValue());
+		this.setEndOffset(((Integer) tokEndOffset).intValue());
 		tableNumber = -1;
 	}
 
@@ -174,54 +167,6 @@
 				source.treePrint(depth + 1);
 			}
 		}
-	}
-
-	/**
-	 * Get the begin offset of the parser token for the column name
-	 * Will only be set when the CR was generated by the
-	 * parser.
-	 *
-	 * @return the begin offset of the token.  -1 means unknown
-	 */
-	public int getTokenBeginOffset()
-	{
-		/* We should never get called if not initialized, as
-		 * begin/end offset has no meaning unless this CR was
-		 * created in the parser.
-		 */
-		if (SanityManager.DEBUG)
-		{
-			if (tokBeginOffset == -1)
-			{
-				SanityManager.THROWASSERT(
-					"tokBeginOffset not expected to be -1");
-			}
-		}
-		return tokBeginOffset;
-	}
-
-	/**
-	 * Get the end offset of the parser token for the column name.
-	 * Will only be set when the CR was generated by the
-	 * parser.
-	 *
-	 * @return the end offset of the token.  -1 means unknown
-	 */
-	public int getTokenEndOffset()
-	{
-		/* We should never get called if not initialized, as
-		 * begin/end offset has no meaning unless this CR was
-		 * created in the parser.
-		 */
-		if (SanityManager.DEBUG)
-		{
-			if (tokEndOffset == -1)
-			{
-				SanityManager.THROWASSERT(
-					"tokEndOffset not expected to be -1");
-			}
-		}
-		return tokEndOffset;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java?rev=332635&r1=332634&r2=332635&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
Fri Nov 11 11:43:10 2005
@@ -405,8 +405,8 @@
 					continue;
 				}
 					
-				int tokBeginOffset = tableName.getTokenBeginOffset();
-				int tokEndOffset = tableName.getTokenEndOffset();
+				int tokBeginOffset = tableName.getBeginOffset();
+				int tokEndOffset = tableName.getEndOffset();
 				if (tokBeginOffset == -1)
 				{
 					continue;
@@ -415,7 +415,7 @@
 				regenNode = true;
 				checkInvalidTriggerReference(tableName.getTableName());
 				String colName = ref.getColumnName();
-				int columnLength = ref.getTokenEndOffset() - ref.getTokenBeginOffset() + 1;
+				int columnLength = ref.getEndOffset() - ref.getBeginOffset() + 1;
 
 				newText.append(originalActionText.substring(start, tokBeginOffset-actionOffset));
 				newText.append(genColumnReferenceSQL(dd, colName, tableName.getTableName(), tableName.getTableName().equals(oldTableName)));
@@ -444,8 +444,8 @@
 				{
 					continue;
 				}
-				int tokBeginOffset = fromTable.getTableNameField().getTokenBeginOffset();
-				int tokEndOffset = fromTable.getTableNameField().getTokenEndOffset();
+				int tokBeginOffset = fromTable.getTableNameField().getBeginOffset();
+				int tokEndOffset = fromTable.getTableNameField().getEndOffset();
 				if (tokBeginOffset == -1)
 				{
 					continue;
@@ -514,12 +514,12 @@
 			for (int j = 0; j < size - i - 1; j++)
 			{
 				if ((isRow && 
-					 ((ColumnReference) sorted[j]).getTokenBeginOffset() > 
-					 ((ColumnReference) sorted[j+1]).getTokenBeginOffset()
+					 sorted[j].getBeginOffset() > 
+					 sorted[j+1].getBeginOffset()
 					) ||
 					(!isRow &&
-					 ((FromBaseTable) sorted[j]).getTableNameField().getTokenBeginOffset() > 
-					 ((FromBaseTable) sorted[j+1]).getTableNameField().getTokenBeginOffset()
+					 ((FromBaseTable) sorted[j]).getTableNameField().getBeginOffset() > 
+					 ((FromBaseTable) sorted[j+1]).getTableNameField().getBeginOffset()
 					))
 				{
 					temp = sorted[j];

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java?rev=332635&r1=332634&r2=332635&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java Fri
Nov 11 11:43:10 2005
@@ -82,9 +82,9 @@
 	public static final int AUTOINCREMENT_INC_INDEX   = 1;
 	public static final int AUTOINCREMENT_IS_AUTOINCREMENT_INDEX   = 2;
 
-	int				beginOffset;		// offset into SQL input of the substring
+	private int		beginOffset = -1;		// offset into SQL input of the substring
 	                                // which this query node encodes.
-	int				endOffset;
+	private int		endOffset = -1;
 
 	private int nodeType;
 	private ContextManager cm;
@@ -199,7 +199,7 @@
 	 * Gets the beginning offset of the SQL substring which this
 	 * query node represents.
 	 *
-	 * @return	The beginning offset of the SQL substring.
+	 * @return	The beginning offset of the SQL substring. -1 means unknown.
 	 *
 	 */
     public	int	getBeginOffset() { return beginOffset; }
@@ -220,7 +220,7 @@
 	 * Gets the ending offset of the SQL substring which this
 	 * query node represents.
 	 *
-	 * @return	The ending offset of the SQL substring.
+	 * @return	The ending offset of the SQL substring. -1 means unknown.
 	 *
 	 */
 	public	int	getEndOffset()  { return endOffset; }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java?rev=332635&r1=332634&r2=332635&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java Fri Nov
11 11:43:10 2005
@@ -48,16 +48,6 @@
 	String	schemaName;
 	private boolean hasSchema;
 
-	/*
-	** These fields are used to track the being and end
-	** offset of the token from which the TableName came.
-	** These are always set to legitimate values in the
-	** parser.  If a tableName has been generated elsewhere,
-	** they may not be set.  -1 means unset.
-	*/
-	private int		tokBeginOffset = -1;
-	private int		tokEndOffset = -1;
-
 	/**
 	 * Initializer for when you have both the table and schema names.
 	 *
@@ -91,8 +81,8 @@
 	)
 	{
 		init(schemaName, tableName);
-		this.tokBeginOffset = ((Integer) tokBeginOffset).intValue();
-		this.tokEndOffset = ((Integer) tokEndOffset).intValue();
+		this.setBeginOffset(((Integer) tokBeginOffset).intValue());
+		this.setEndOffset(((Integer) tokEndOffset).intValue());
 	}
 
 	/**
@@ -125,30 +115,6 @@
 	public String getSchemaName()
 	{
 		return schemaName;
-	}
-
-	/**
-	 * Get the begin offset of the parser token for the table name
-	 * Will only be set when the TableName was generated by the
-	 * parser.
-	 *
-	 * @return the begin offset of the token.  -1 means unknown
-	 */
-	public int getTokenBeginOffset()
-	{
-		return tokBeginOffset;
-	}
-
-	/**
-	 * Get the end offset of the parser token for the table name.
-	 * Will only be set when the TableName was generated by the
-	 * parser.
-	 *
-	 * @return the end offset of the token.  -1 means unknown
-	 */
-	public int getTokenEndOffset()
-	{
-		return tokEndOffset;
 	}
 
 	/**



Mime
View raw message