db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1478295 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql: compile/ execute/
Date Thu, 02 May 2013 07:46:59 GMT
Author: kahatlen
Date: Thu May  2 07:46:59 2013
New Revision: 1478295

URL: http://svn.apache.org/r1478295
Log:
DERBY-6169: Reduce visibility of classes and methods under impl/sql

- Reduce visibility of fields in ColumnInfo, FKInfo,
  InsertConstantAction and TablePrivilegeInfo to private or package.

- Reduce visibility of TablePrivilegesNode.makePrivilegeInfo() and
  InsertConstantAction.getAutoincRowLocation() to package.

- Clone arrays passed in to public constructors of the above mentioned
  classes as well as ConstraintInfo.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TablePrivilegesNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintInfo.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertConstantAction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TablePrivilegeInfo.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java?rev=1478295&r1=1478294&r2=1478295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
Thu May  2 07:46:59 2013
@@ -518,7 +518,7 @@ public class CreateTableNode extends DDL
 
         for (int i = 0; i < colInfos.length; i++)
         {
-			DataTypeDescriptor dts = colInfos[i].dataType;
+            DataTypeDescriptor dts = colInfos[i].getDataType();
             if (dts.getTypeId().isLongConcatableTypeId())
             {
                 table_has_long_column = 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=1478295&r1=1478294&r2=1478295&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
Thu May  2 07:46:59 2013
@@ -32,13 +32,9 @@ import org.apache.derby.iapi.sql.diction
 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.depend.ProviderList;
-import org.apache.derby.iapi.sql.conn.ConnectionUtil;
 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.SchemaDescriptor;
-import org.apache.derby.iapi.sql.dictionary.TupleDescriptor;
 import org.apache.derby.iapi.sql.dictionary.ViewDescriptor;
 
 import java.util.ArrayList;
@@ -117,7 +113,7 @@ public class TablePrivilegesNode extends
 	/**
 	 * @return PrivilegeInfo for this node
 	 */
-	public PrivilegeInfo makePrivilegeInfo()
+    PrivilegeInfo makePrivilegeInfo()
 	{
 		return new TablePrivilegeInfo( td, actionAllowed, columnBitSets, 
 				descriptorList);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java?rev=1478295&r1=1478294&r2=1478295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java Thu
May  2 07:46:59 2013
@@ -21,11 +21,9 @@
 
 package org.apache.derby.impl.sql.execute;
 
+import org.apache.derby.iapi.services.io.ArrayUtil;
 import org.apache.derby.iapi.services.io.Formatable;
 import org.apache.derby.iapi.services.io.StoredFormatIds;
-import org.apache.derby.iapi.services.io.FormatIdUtil;
-
-import org.apache.derby.iapi.error.StandardException;
 
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.DataValueDescriptor;
@@ -37,7 +35,6 @@ import org.apache.derby.catalog.UUID;
 
 import org.apache.derby.iapi.services.io.FormatableArrayHolder;
 import org.apache.derby.iapi.services.io.FormatableHashtable;
-import org.apache.derby.iapi.services.io.FormatableIntHolder;
 import org.apache.derby.iapi.services.io.FormatableLongHolder;
 
 import java.io.ObjectOutput;
@@ -67,21 +64,21 @@ public class ColumnInfo implements Forma
 	**
 	********************************************************/
 
-	public  int							action;
-	public	String						name;
-	public	DataTypeDescriptor			dataType;
-	public	DefaultInfo					defaultInfo;
-    public    ProviderInfo[]            providers;
-	public	DataValueDescriptor			defaultValue;
-	public	UUID						newDefaultUUID;
-	public	UUID						oldDefaultUUID;
+    int                         action;
+    String                      name;
+    DataTypeDescriptor          dataType;
+    DefaultInfo                 defaultInfo;
+    ProviderInfo[]              providers;
+    DataValueDescriptor         defaultValue;
+    UUID                        newDefaultUUID;
+    UUID                        oldDefaultUUID;
 	// autoinc columns.
-	public long 						autoincStart;
-	public long 						autoincInc;
+    long                        autoincStart;
+    long                        autoincInc;
 	//if this is an autoincrement column, then following variable will have CREATE or
 	//MODIFY_COLUMN_DEFAULT_RESTART or MODIFY_COLUMN_DEFAULT_INCREMENT. Otherwise,
 	//this variable will be set to -1.
-	public long 						autoinc_create_or_modify_Start_Increment = -1;
+    long                        autoinc_create_or_modify_Start_Increment = -1;
 
 	//This indicates column is for CREATE TABLE
 	public static final int CREATE					= 0;
@@ -135,7 +132,7 @@ public class ColumnInfo implements Forma
 		this.dataType = dataType;
 		this.defaultValue = defaultValue;
 		this.defaultInfo = defaultInfo;
-        this.providers = providers;
+        this.providers = (ProviderInfo[]) ArrayUtil.copy(providers);
 		this.newDefaultUUID = newDefaultUUID;
 		this.oldDefaultUUID = oldDefaultUUID;
 		this.action = action;
@@ -228,6 +225,12 @@ public class ColumnInfo implements Forma
 	 */
 	public	int	getTypeFormatId()	{ return StoredFormatIds.COLUMN_INFO_V02_ID; }
 
+    // Accessors
+
+    public DataTypeDescriptor getDataType() {
+        return dataType;
+    }
+
 	/*
 	  Object methods.
 	  */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintInfo.java?rev=1478295&r1=1478294&r2=1478295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintInfo.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintInfo.java
Thu May  2 07:46:59 2013
@@ -30,9 +30,7 @@ import org.apache.derby.catalog.UUID;
 import org.apache.derby.iapi.error.StandardException;
 
 import org.apache.derby.iapi.services.io.StoredFormatIds;
-import org.apache.derby.iapi.services.io.FormatIdUtil;
 import org.apache.derby.iapi.services.io.ArrayUtil;
-import org.apache.derby.iapi.services.io.Formatable;
 
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
@@ -93,7 +91,7 @@ public class ConstraintInfo implements C
 	{
 		this.tableName = tableName;
 		this.tableSd = tableSd;
-		this.columnNames = columnNames;
+        this.columnNames = ArrayUtil.copy(columnNames);
 		this.raDeleteRule  = raDeleteRule;
 		this.raUpdateRule  = raUpdateRule;
 	}
@@ -238,8 +236,9 @@ public class ConstraintInfo implements C
 	  *
 	  *	@return	array of referenced column names
 	  */
-	public String[] getReferencedColumnNames()
-	{ return columnNames; }
+    public String[] getReferencedColumnNames() {
+        return ArrayUtil.copy(columnNames);
+    }
 
 	/**
 	  *	Get the name of the table that these column live in.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java?rev=1478295&r1=1478294&r2=1478295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java Thu May
 2 07:46:59 2013
@@ -75,18 +75,18 @@ public class FKInfo implements Formatabl
 	/*
 	** See the constructor for the meaning of these fields
 	*/
-	public String				fkConstraintNames[];
-	public String				tableName;
-	public int					type;
-	public UUID					refUUID;
-	public long					refConglomNumber;
-	public UUID[]				fkUUIDs;
-	public long[]				fkConglomNumbers;
-	public boolean[]			fkIsSelfReferencing;
-	public int[]				colArray;
-	public int					stmtType;
-	public RowLocation			rowLocation;
-	public int[] 	            raRules;
+    String[]            fkConstraintNames;
+    String              tableName;
+    int                 type;
+    UUID                refUUID;
+    long                refConglomNumber;
+    private UUID[]      fkUUIDs;
+    long[]              fkConglomNumbers;
+    boolean[]           fkIsSelfReferencing;
+    int[]               colArray;
+    int                 stmtType;
+    RowLocation         rowLocation;
+    int[]               raRules;
 
 	/**
 	 * Niladic constructor for Formattable
@@ -132,18 +132,18 @@ public class FKInfo implements Formatabl
 					int[]               raRules
 					)
 	{
-		this.fkConstraintNames = fkConstraintNames;
+        this.fkConstraintNames = ArrayUtil.copy(fkConstraintNames);
 		this.tableName = tableName;
 		this.stmtType = stmtType;
 		this.type = type;
 		this.refUUID = refUUID;
 		this.refConglomNumber = refConglomNumber;
-		this.fkUUIDs = fkUUIDs;
-		this.fkConglomNumbers = fkConglomNumbers;
-		this.fkIsSelfReferencing = fkIsSelfReferencing;
-		this.colArray = colArray;
+        this.fkUUIDs = (UUID[]) ArrayUtil.copy(fkUUIDs);
+        this.fkConglomNumbers = ArrayUtil.copy(fkConglomNumbers);
+        this.fkIsSelfReferencing = ArrayUtil.copy(fkIsSelfReferencing);
+        this.colArray = ArrayUtil.copy(colArray);
 		this.rowLocation = rowLocation;
-		this.raRules = raRules;
+        this.raRules = ArrayUtil.copy(raRules);
 
 		if (SanityManager.DEBUG)
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertConstantAction.java?rev=1478295&r1=1478294&r2=1478295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertConstantAction.java
Thu May  2 07:46:59 2013
@@ -86,7 +86,7 @@ public class InsertConstantAction extend
 	 * the row location of the column in SYSCOLUMNS.
 	 * if not, then it contains null.
 	 */
-	protected RowLocation[] autoincRowLocation;
+    RowLocation[] autoincRowLocation;
 	private long[] autoincIncrement;
 	
 	// CONSTRUCTORS
@@ -262,7 +262,7 @@ public class InsertConstantAction extend
 	/**
 	 * gets the row location 
 	 */
-	public RowLocation[] getAutoincRowLocation()
+    RowLocation[] getAutoincRowLocation()
 	{
 		return autoincRowLocation;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TablePrivilegeInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TablePrivilegeInfo.java?rev=1478295&r1=1478294&r2=1478295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TablePrivilegeInfo.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TablePrivilegeInfo.java
Thu May  2 07:46:59 2013
@@ -21,6 +21,7 @@
 
 package org.apache.derby.impl.sql.execute;
 
+import org.apache.derby.iapi.services.io.ArrayUtil;
 import org.apache.derby.iapi.services.io.FormatableBitSet;
 import org.apache.derby.iapi.sql.Activation;
 import org.apache.derby.iapi.error.StandardException;
@@ -59,10 +60,10 @@ public class TablePrivilegeInfo extends 
 	private static final String[][] actionString =
 	{{"s", "S"}, {"d", "D"}, {"i", "I"}, {"u", "U"}, {"r", "R"}, {"t", "T"}};
 
-	private TableDescriptor td;
-	private boolean[] actionAllowed;
-	private FormatableBitSet[] columnBitSets;
-	private List descriptorList;
+    private final TableDescriptor td;
+    private final boolean[] actionAllowed;
+    private final FormatableBitSet[] columnBitSets;
+    private final List descriptorList;
 	
 	/**
 	 * @param actionAllowed actionAllowed[action] is true if action is in the privilege set.
@@ -72,8 +73,16 @@ public class TablePrivilegeInfo extends 
 							   FormatableBitSet[] columnBitSets,
 							   List descriptorList)
 	{
-		this.actionAllowed = actionAllowed;
-		this.columnBitSets = columnBitSets;
+        // Copy the arrays so that modification outside doesn't change
+        // the internal state.
+        this.actionAllowed = ArrayUtil.copy(actionAllowed);
+        this.columnBitSets = new FormatableBitSet[columnBitSets.length];
+        for (int i = 0; i < columnBitSets.length; i++) {
+            if (columnBitSets[i] != null) {
+                this.columnBitSets[i] = new FormatableBitSet(columnBitSets[i]);
+            }
+        }
+
 		this.td = td;
 		this.descriptorList = descriptorList;
 	}



Mime
View raw message