Update of /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31211/app/src/net/sourceforge/squirrel_sql/client/session
Modified Files:
CaseInsensitiveString.java IObjectTreeAPI.java
SQLExecuterTask.java SchemaInfo.java Session.java
Removed Files:
ExtendedTableInfo.java
Log Message:
First step of making SchemaInfo the central cache.
Index: CaseInsensitiveString.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/CaseInsensitiveString.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CaseInsensitiveString.java 5 Nov 2005 19:36:51 -0000 1.1
--- CaseInsensitiveString.java 19 Apr 2006 07:55:32 -0000 1.2
***************
*** 10,14 ****
* memory finger print.
*/
! public class CaseInsensitiveString
{
private char[] value = new char[0];
--- 10,14 ----
* memory finger print.
*/
! public class CaseInsensitiveString implements Comparable
{
private char[] value = new char[0];
***************
*** 154,156 ****
--- 154,200 ----
return new String(value, offset, count);
}
+
+ public int compareTo(Object o)
+ {
+ // return this.toString().toLowerCase().compareTo(o.toString().toLowerCase());
+
+ CaseInsensitiveString anotherString = (CaseInsensitiveString) o;
+
+ int len1 = count;
+ int len2 = anotherString.count;
+ int n = Math.min(len1, len2);
+ char v1[] = value;
+ char v2[] = anotherString.value;
+ int i = offset;
+ int j = anotherString.offset;
+
+ if (i == j)
+ {
+ int k = i;
+ int lim = n + i;
+ while (k < lim)
+ {
+ char c1 = v1[k];
+ char c2 = v2[k];
+ if (Character.toLowerCase(c1) != Character.toLowerCase(c2))
+ {
+ return Character.toLowerCase(c1) - Character.toLowerCase(c2);
+ }
+ k++;
+ }
+ }
+ else
+ {
+ while (n-- != 0)
+ {
+ char c1 = v1[i++];
+ char c2 = v2[j++];
+ if (Character.toLowerCase(c1) != Character.toLowerCase(c2))
+ {
+ return Character.toLowerCase(c1) - Character.toLowerCase(c2);
+ }
+ }
+ }
+ return len1 - len2;
+ }
}
Index: Session.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/Session.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** Session.java 23 Mar 2006 13:03:59 -0000 1.43
--- Session.java 19 Apr 2006 07:55:32 -0000 1.44
***************
*** 48,52 ****
import net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand;
import net.sourceforge.squirrel_sql.client.plugin.IPlugin;
- import net.sourceforge.squirrel_sql.client.plugin.PluginManager;
import net.sourceforge.squirrel_sql.client.session.mainpanel.IMainPanelTab;
import net.sourceforge.squirrel_sql.client.session.parser.IParserEventsProcessor;
--- 48,51 ----
***************
*** 205,219 ****
// Start loading table/column info about the current database.
! _app.getThreadPool().addTask(new Runnable()
! {
! public void run()
! {
! loadTableInfo();
! _finishedLoading = true;
! }
! });
! _sessionCreated = true;
! }
/**
--- 204,218 ----
// Start loading table/column info about the current database.
! _app.getThreadPool().addTask(new Runnable()
! {
! public void run()
! {
! _schemaInfo.load(Session.this);
! _finishedLoading = true;
! }
! });
! _sessionCreated = true;
! }
/**
***************
*** 658,709 ****
}
! /**
! * Load table information about the current database.
! */
! private void loadTableInfo()
! {
! _schemaInfo.load(this);
! }
!
! private void setupTitle()
! {
! String catalog = null;
! try
! {
! catalog = getSQLConnection().getCatalog();
! }
! catch (SQLException ex)
! {
! s_log.error("Error occured retrieving current catalog from Connection", ex);
! }
! if (catalog == null)
! {
! catalog = "";
! }
! else
! {
! catalog = "(" + catalog + ")";
! }
! String title = null;
! String user = _user != null ? _user : "";
! if (user.length() > 0)
! {
! String[] args = new String[3];
! args[0] = getAlias().getName();
! args[1] = catalog;
! args[2] = user;
! title = s_stringMgr.getString("Session.title1", args);
! }
! else
! {
! String[] args = new String[2];
! args[0] = getAlias().getName();
! args[1] = catalog;
! title = s_stringMgr.getString("Session.title0", args);
! }
! _title = _id + " - " + title;
! }
private void cacheDatabaseProductName(SQLConnection con) {
--- 657,700 ----
}
! private void setupTitle()
! {
! String catalog = null;
! try
! {
! catalog = getSQLConnection().getCatalog();
! }
! catch (SQLException ex)
! {
! s_log.error("Error occured retrieving current catalog from Connection", ex);
! }
! if (catalog == null)
! {
! catalog = "";
! }
! else
! {
! catalog = "(" + catalog + ")";
! }
! String title = null;
! String user = _user != null ? _user : "";
! if (user.length() > 0)
! {
! String[] args = new String[3];
! args[0] = getAlias().getName();
! args[1] = catalog;
! args[2] = user;
! title = s_stringMgr.getString("Session.title1", args);
! }
! else
! {
! String[] args = new String[2];
! args[0] = getAlias().getName();
! args[1] = catalog;
! title = s_stringMgr.getString("Session.title0", args);
! }
! _title = _id + " - " + title;
! }
private void cacheDatabaseProductName(SQLConnection con) {
Index: IObjectTreeAPI.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/IObjectTreeAPI.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** IObjectTreeAPI.java 18 Dec 2005 00:43:51 -0000 1.9
--- IObjectTreeAPI.java 19 Apr 2006 07:55:32 -0000 1.10
***************
*** 43,76 ****
public interface IObjectTreeAPI extends IHasIdentifier
{
! /**
! * Database object type for a "Table Type" node in the object tree. Some examples
! * are "TABLE", "SYSTEM TABLE", "VIEW" etc.
! */
! DatabaseObjectType TABLE_TYPE_DBO = DatabaseObjectType.createNewDatabaseObjectType("Table Type");
!
! /**
! * Database object type for a "Procedure Type" node in the object tree. There is
! * only one node of this type in the object tree and it says "PROCEDURE".
! */
! DatabaseObjectType PROC_TYPE_DBO = DatabaseObjectType.createNewDatabaseObjectType("Stored Procedure Type");
!
! /**
! * Database object type for a "UDT Type" node in the object tree. There is only one
! * node of this type in the object tree and it says "UDT".
! */
! DatabaseObjectType UDT_TYPE_DBO = DatabaseObjectType.createNewDatabaseObjectType("UDT Type");
!
! /**
! * Datbase object type for a "Database" node in the object tree. There is onle one
! * node of this type in the object tree and it indicates the alias of the database.
! */
! DatabaseObjectType DATABASE_TYPE_DBO = DatabaseObjectType.createNewDatabaseObjectType("Database Type");
!
! /**
! * Retrieves the session of associated with the tree.
! *
! * @return Session associated with the tree.
! */
! ISession getSession();
/**
--- 43,52 ----
public interface IObjectTreeAPI extends IHasIdentifier
{
! /**
! * Retrieves the session of associated with the tree.
! *
! * @return Session associated with the tree.
! */
! ISession getSession();
/**
***************
*** 227,231 ****
void refreshTree();
! /**
* Refresh the nodes currently selected in the object tree.
*/
--- 203,213 ----
void refreshTree();
! /**
! * Refresh the object tree.
! */
! void refreshTree(boolean reloadSchemaInfo);
!
!
! /**
* Refresh the nodes currently selected in the object tree.
*/
***************
*** 242,259 ****
void removeNodes(ObjectTreeNode[] nodes);
! /**
! * Create a new <TT>DatabaseObjectType</TT>
! *
! * @return a new <TT>DatabaseObjectType</TT>
! */
! DatabaseObjectType createNewDatabaseObjectType(String name);
!
! /**
! * Retrieve details about all object types that can be in this
! * tree.
! *
! * @return DatabaseObjectType[] Array of object type info objects.
! */
! DatabaseObjectType[] getDatabaseObjectTypes();
/**
--- 224,234 ----
void removeNodes(ObjectTreeNode[] nodes);
! /**
! * Retrieve details about all object types that can be in this
! * tree.
! *
! * @return DatabaseObjectType[] Array of object type info objects.
! */
! DatabaseObjectType[] getDatabaseObjectTypes();
/**
Index: SchemaInfo.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/SchemaInfo.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** SchemaInfo.java 6 Mar 2006 19:34:03 -0000 1.27
--- SchemaInfo.java 19 Apr 2006 07:55:32 -0000 1.28
***************
*** 22,35 ****
*/
import java.sql.SQLException;
! import java.util.ArrayList;
! import java.util.Arrays;
! import java.util.HashMap;
! import java.util.Hashtable;
! import java.util.List;
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.session.event.SessionAdapter;
[...1573 lines suppressed...]
+ System.out.println("");
+ }
+
+ final List catalogs = new ArrayList();
+ final List schemas = new ArrayList();
+
+ final TreeMap keywords = new TreeMap();
+ final TreeMap dataTypes = new TreeMap();
+ final TreeMap functions = new TreeMap();
+ final TreeMap tableNames = new TreeMap();
+ final TreeMap columnNames = new TreeMap();
+ final TreeMap _procedureNames = new TreeMap();
+
+ final TreeMap extendedColumnInfosByTableName = new TreeMap();
+ final TreeMap iTableInfos = new TreeMap();
+ final TreeMap iProcedureInfos = new TreeMap();
+ }
+
+
}
Index: SQLExecuterTask.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/SQLExecuterTask.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** SQLExecuterTask.java 15 Apr 2006 14:47:21 -0000 1.26
--- SQLExecuterTask.java 19 Apr 2006 07:55:32 -0000 1.27
***************
*** 589,647 ****
{
! try
! {
! final SQLConnection conn = _session.getSQLConnection();
! final SQLDatabaseMetaData md = conn.getSQLMetaData();
! //final ITableInfo[] tables = md.getTables(null, null, "%", null);
! ITableInfo[] tables = md.getAllTables();
! // filter the list of all DB objects looking for things with the given name
! for (int i = 0; i < tables.length; ++i)
! {
! String simpleName = tables[i].getSimpleName().toUpperCase();
! String nameWithSchema = simpleName;
! String nameWithSchemaAndCatalog = simpleName;
! if (null != tables[i].getSchemaName() && 0 < tables[i].getSchemaName().length())
! {
! nameWithSchema = tables[i].getSchemaName().toUpperCase() + "." + nameWithSchema;
! nameWithSchemaAndCatalog = nameWithSchema;
! }
! if (null != tables[i].getCatalogName() && 0 < tables[i].getCatalogName().length())
! {
! nameWithSchemaAndCatalog = tables[i].getCatalogName().toUpperCase() + "." + nameWithSchema;
! }
! if (simpleName.equals(tableNameFromSQL)
! || nameWithSchema.equals(tableNameFromSQL)
! || nameWithSchemaAndCatalog.equals(tableNameFromSQL))
! {
! return (TableInfo) tables[i];
! }
}
- // ok, that didn't work - let's see if the table looks fully qualified.
- // if so, we'll split the name from the schema/catalog and try that.
- String[] parts = tableNameFromSQL.split("\\.");
- if (parts.length == 2) {
- String catalog = parts[0];
- String simpleName = parts[1];
- tables = md.getTables(catalog, null, simpleName, null);
- if (tables != null && tables.length > 0) {
- return (TableInfo) tables[0];
- }
- // Ok, maybe catalog was really a schema instead.
- tables = md.getTables(null, catalog, simpleName, null);
- if (tables != null && tables.length > 0) {
- return (TableInfo) tables[0];
- }
- }
- return null;
}
! catch (SQLException e)
{
! throw new RuntimeException(e);
}
}
--- 589,643 ----
{
! final SQLConnection conn = _session.getSQLConnection();
! //final SQLDatabaseMetaData md = conn.getSQLMetaData();
! //final ITableInfo[] tables = md.getTables(null, null, "%", null);
! ITableInfo[] tables = _session.getSchemaInfo().getITableInfos();
! // filter the list of all DB objects looking for things with the given name
! for (int i = 0; i < tables.length; ++i)
! {
! String simpleName = tables[i].getSimpleName().toUpperCase();
! String nameWithSchema = simpleName;
! String nameWithSchemaAndCatalog = simpleName;
! if (null != tables[i].getSchemaName() && 0 < tables[i].getSchemaName().length())
! {
! nameWithSchema = tables[i].getSchemaName().toUpperCase() + "." + nameWithSchema;
! nameWithSchemaAndCatalog = nameWithSchema;
! }
! if (null != tables[i].getCatalogName() && 0 < tables[i].getCatalogName().length())
! {
! nameWithSchemaAndCatalog = tables[i].getCatalogName().toUpperCase() + "." + nameWithSchema;
! }
! if (simpleName.equals(tableNameFromSQL)
! || nameWithSchema.equals(tableNameFromSQL)
! || nameWithSchemaAndCatalog.equals(tableNameFromSQL))
! {
! return (TableInfo) tables[i];
}
}
! // ok, that didn't work - let's see if the table looks fully qualified.
! // if so, we'll split the name from the schema/catalog and try that.
! String[] parts = tableNameFromSQL.split("\\.");
! if (parts.length == 2)
{
! String catalog = parts[0];
! String simpleName = parts[1];
! tables = _session.getSchemaInfo().getITableInfos(catalog, null, simpleName, null);
! if (tables != null && tables.length > 0)
! {
! return (TableInfo) tables[0];
! }
! // Ok, maybe catalog was really a schema instead.
! tables = _session.getSchemaInfo().getITableInfos(null, catalog, simpleName, null);
! if (tables != null && tables.length > 0)
! {
! return (TableInfo) tables[0];
! }
}
+ return null;
}
--- ExtendedTableInfo.java DELETED ---
|