Update of /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/properties
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6548
Modified Files:
EditWhereCols.java
Log Message:
limit cols in edit functional
Index: EditWhereCols.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/properties/EditWhereCols.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** EditWhereCols.java 20 Apr 2004 19:45:46 -0000 1.1
--- EditWhereCols.java 23 Apr 2004 18:33:37 -0000 1.2
***************
*** 30,37 ****
public class EditWhereCols {
! /**
! * The singleton instance of this object
! */
! private static EditWhereCols singleton = null;
/**
--- 30,34 ----
public class EditWhereCols {
!
/**
***************
*** 42,46 ****
* that those classes can handle, i.e. an array of strings.
* Each string consists of the name of the table, a space, then a comma-separated list of
! * all of the columns that SHOULD be used in the WHERE clause when doing editing operations.
*/
private String[] dataArray = new String[0];
--- 39,45 ----
* that those classes can handle, i.e. an array of strings.
* Each string consists of the name of the table, a space, then a comma-separated list of
! * all of the columns that SHOULD be used in the WHERE clause when doing editing
! * operations.
! * This is used in an instance of this class created during load/unload.
*/
private String[] dataArray = new String[0];
***************
*** 49,84 ****
* The mapping from table name to object (also a HashMap)
* containing the list of names of columns to use in WHERE clause.
*/
! private HashMap tables = new HashMap();
!
! /**
! * Singleton - do not allow external objects to create instances of this
! */
! private EditWhereCols() {}
!
! /**
! * let external objects get a copy of this singleton,
! * creating the instance the first time it is accessed.
! */
! static public EditWhereCols getInstance() {
! if (singleton == null)
! singleton = new EditWhereCols();
! return singleton;
! }
/**
! * get the data from the instance
*/
! public HashMap getTables() {
! return tables;
! }
/**
! * get data in form that can be used to output to file
*/
public String[] getDataArray() {
// first convert internal data into the string array
! dataArray = new String[tables.size()];
! Iterator keys = tables.keySet().iterator();
int index = 0;
--- 48,69 ----
* The mapping from table name to object (also a HashMap)
* containing the list of names of columns to use in WHERE clause.
+ * There is only one copy of this table for all instances of this class.
*/
! private static HashMap _tables = new HashMap();
/**
! * ctor
*/
! public EditWhereCols() {}
+
/**
! * get data in form that can be used to output to file.
! * This is called from an instance of this class.
*/
public String[] getDataArray() {
// first convert internal data into the string array
! dataArray = new String[_tables.size()];
! Iterator keys = _tables.keySet().iterator();
int index = 0;
***************
*** 86,90 ****
while (keys.hasNext()) {
String tableName = (String)keys.next();
! HashMap h = (HashMap)tables.get(tableName);
Iterator columnNames = h.keySet().iterator();
String outData = tableName + " ";
--- 71,75 ----
while (keys.hasNext()) {
String tableName = (String)keys.next();
! HashMap h = (HashMap)_tables.get(tableName);
Iterator columnNames = h.keySet().iterator();
String outData = tableName + " ";
***************
*** 106,113 ****
* Data in the external form (array of strings) is passed in and must be converted
* to the internal form.
* @param inData array of strings in form "tableName col,col,col..."
*/
public void setDataArray(String[] inData) {
! tables = new HashMap(); // make sure we are starting clean
// convert each string into key+HashMap and fill it into the data
--- 91,99 ----
* Data in the external form (array of strings) is passed in and must be converted
* to the internal form.
+ * This is called on an instance of this class.
* @param inData array of strings in form "tableName col,col,col..."
*/
public void setDataArray(String[] inData) {
! _tables = new HashMap(); // make sure we are starting clean
// convert each string into key+HashMap and fill it into the data
***************
*** 128,131 ****
--- 114,126 ----
colList.add(inData[i].substring(startIndex, endIndex));
}
+
+ // create a hashmap containing the column names.
+ // by convention, the value and key is the same for each column name
+ HashMap h = new HashMap(colList.size());
+ for (int j=0; j<colList.size(); j++)
+ h.put(colList.get(j), colList.get(j));
+
+ // put the map into the tables db with the table name as the key
+ _tables.put(tableName, h);
}
}
***************
*** 135,143 ****
* If map is null, remove the entry from the tables.
*/
! public void put(String tableName, HashMap colNames) {
if (colNames == null)
! tables.remove(tableName);
else
! tables.put(tableName, colNames);
return;
}
--- 130,138 ----
* If map is null, remove the entry from the tables.
*/
! public static void put(String tableName, HashMap colNames) {
if (colNames == null)
! _tables.remove(tableName);
else
! _tables.put(tableName, colNames);
return;
}
***************
*** 147,152 ****
* it will be null if the table does not have any limitation on the columns to use.
*/
! public HashMap get(String tableName) {
! return (HashMap)tables.get(tableName);
}
}
--- 142,147 ----
* it will be null if the table does not have any limitation on the columns to use.
*/
! public static HashMap get(String tableName) {
! return (HashMap)_tables.get(tableName);
}
}
|