Here is the other part to the criteria.containsObjectColumn() patch.
Let me know if it looks ok and i will commit it.
************** begin patch ******************
Index: turbine/src/java/org/apache/turbine/util/db/Criteria.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/db/Criteria.java,v
retrieving revision 1.8
diff -u -r1.8 Criteria.java
--- turbine/src/java/org/apache/turbine/util/db/Criteria.java 2000/07/11
12:08:36 1.8
+++ turbine/src/java/org/apache/turbine/util/db/Criteria.java 2000/07/12
16:27:27
@@ -56,7 +56,7 @@
*
*/
-// Java Core Classes
+// Java Core Classes
import java.util.*;
import java.io.*;
@@ -79,7 +79,7 @@
*/
public class Criteria extends Hashtable // extends Vector
{
-
+
public static final String EQUAL = "=";
public static final String NOT_EQUAL = "<>";
public static final String ALT_NOT_EQUAL = "!=";
@@ -95,7 +95,7 @@
public static final String IN = " IN ";
public static final String NOT_IN = " NOT IN ";
public static final String ALL = "ALL ";
-
+
private boolean ignoreCase = false;
private boolean singleRecord = false;
private boolean cascade = false;
@@ -108,7 +108,7 @@
private String dbMap = DBBroker.DEFAULT;
// public static final String CUSTOM = "true";
-
+
public Criteria()
{
super(10);
@@ -127,7 +127,7 @@
super(initialCapacity);
this.dbName = dbName;
}
-
+
/**
* Does this Criteria Object contain the specified key?
* @param table the name of the table
@@ -137,7 +137,7 @@
{
return containsKey(table + "." + column);
}
-
+
/**
* Convenience method to return value as a boolean
*
@@ -164,11 +164,20 @@
/**
* Returns true if any of the tables in the criteria contain an
Object
- * ciolumn.
+ * ciolumn.
*/
public boolean containsObjectColumn() throws Exception
{
- DatabaseMap map = DBBroker.getInstance().getDatabaseMap(dbMap);
+ return containsObjectColumn(dbMap);
+ }
+
+ /**
+ * Returns true if any of the tables in the criteria contain an
Object
+ * ciolumn.
+ */
+ public boolean containsObjectColumn(String databaseMapName) throws
Exception
+ {
+ DatabaseMap map =
DBBroker.getInstance().getDatabaseMap(databaseMapName);
StringStackBuffer tables = new StringStackBuffer();
for (Enumeration e = super.elements(); e.hasMoreElements(); )
{
@@ -183,7 +192,7 @@
}
return false;
}
-
+
/**
* Method to return criteria related to columns in a table
*
@@ -195,7 +204,7 @@
{
return (CriteriaObject)super.get(name);
}
-
+
/**
* Method to return criteria related to column in a table
*
@@ -209,17 +218,17 @@
.toString() );
}
/**
- * method to return a String table name
+ * method to return a String table name
*
* @param name - String name of key
* @return String - value of object at key
- */
+ */
public String getColumnName(String name)
{
return getCObject(name).column;
- }
-
+ }
+
/**
* Method to return a comparison String
*
@@ -250,7 +259,7 @@
public java.util.Date getDate(String name)
{
return (java.util.Date)getCObject(name).getValue();
- }
+ }
/**
* Convenience method to return a Date
*
@@ -262,7 +271,7 @@
return getDate( new
StringBuffer(table).append('.').append(column)
.toString() );
}
-
+
/**
* Get the database name for this criteria object
* By default, this is DBBroker.DEFAULT
@@ -270,7 +279,7 @@
public String getDbName()
{
if ( this.dbName == null )
- return DBBroker.DEFAULT;
+ return DBBroker.DEFAULT;
return dbName;
}
/**
@@ -287,7 +296,7 @@
public String getMapName()
{
if ( this.dbMap == null )
- return DBBroker.DEFAULT;
+ return DBBroker.DEFAULT;
return dbMap;
}
/**
@@ -303,7 +312,7 @@
* @param name - String name of key
* @return double - value of object at key
*/
- public double getDouble(String name)
+ public double getDouble(String name)
{
Object obj = getCObject(name).getValue();
if (obj instanceof String)
@@ -316,7 +325,7 @@
* @param name - String name of key
* @return double - value of object at key
*/
- public double getDouble(String table, String column)
+ public double getDouble(String table, String column)
{
return getDouble( new
StringBuffer(table).append('.').append(column)
.toString() );
@@ -327,7 +336,7 @@
* @param name - String name of key
* @return float - value of object at key
*/
- public float getFloat(String name)
+ public float getFloat(String name)
{
Object obj = getCObject(name).getValue();
if (obj instanceof String)
@@ -340,7 +349,7 @@
* @param name - String name of key
* @return float - value of object at key
*/
- public float getFloat(String table, String column)
+ public float getFloat(String table, String column)
{
return getFloat( new
StringBuffer(table).append('.').append(column)
.toString() );
@@ -351,7 +360,7 @@
* @param name - String name of key
* @return Integer - value of object at key
*/
- public Integer getInteger(String name)
+ public Integer getInteger(String name)
{
Object obj = getCObject(name).getValue();
if (obj instanceof String)
@@ -364,7 +373,7 @@
* @param name - String name of key
* @return Integer - value of object at key
*/
- public Integer getInteger(String table, String column)
+ public Integer getInteger(String table, String column)
{
return getInteger( new
StringBuffer(table).append('.').append(column)
.toString() );
@@ -399,7 +408,7 @@
* @param name - String name of key
* @return long - value of object at key
*/
- public long getLong(String name)
+ public long getLong(String name)
{
Object obj = getCObject(name).getValue();
if (obj instanceof String)
@@ -412,7 +421,7 @@
* @param name - String name of key
* @return long - value of object at key
*/
- public long getLong(String table, String column)
+ public long getLong(String table, String column)
{
return getLong( new
StringBuffer(table).append('.').append(column)
.toString() );
@@ -422,7 +431,7 @@
*
* @param name - String name of key
* @return String - value of object at key
- */
+ */
public String getString(String name)
{
return (String) getCObject(name).getValue();
@@ -432,30 +441,30 @@
*
* @param name - String name of key
* @return String - value of object at key
- */
+ */
public String getString(String table, String column)
{
return getString( new
StringBuffer(table).append('.').append(column)
.toString() );
}
/**
- * method to return a String table name
+ * method to return a String table name
*
* @param name - String name of key
* @return String - value of object at key
- */
+ */
public String getTableName(String name)
{
return getCObject(name).getTable();
- }
-
+ }
+
/**
* Convenience method to return a vector
*
* @param name - String name of key
* @return Vector - value of object at key
*/
- public Vector getVector(String name)
+ public Vector getVector(String name)
{
return (Vector) getCObject(name).getValue();
}
@@ -465,7 +474,7 @@
* @param name - String name of key
* @return Vector - value of object at key
*/
- public Vector getVector(String table, String column)
+ public Vector getVector(String table, String column)
{
return getVector( new
StringBuffer(table).append('.').append(column)
.toString() );
@@ -492,7 +501,7 @@
return getValue( new
StringBuffer(table).append('.').append(column)
.toString() );
}
-
+
/**
* Overrides Hashtable get, so that the value placed in the
CriteriaObject is
* returned instead of the CriteriaObject
@@ -501,18 +510,18 @@
{
return getValue( (String)key );
}
-
+
public Object put( Object key, Object value )
{
if ( value instanceof CriteriaObject )
{
return super.put(key, value);
}
- return super.put( key, new CriteriaObject((String)key, value,
EQUAL) );
+ return super.put( key, new CriteriaObject((String)key, value,
EQUAL) );
}
/**
- This method is a slightly faster alternative to using the
method put().
+ This method is a slightly faster alternative to using the
method put().
It also allows code that looks like this:
<p>
<code>
@@ -525,7 +534,7 @@
return this;
}
/**
- This method is a slightly faster alternative to using the
method put().
+ This method is a slightly faster alternative to using the
method put().
It also allows code that looks like this:
<p>
<code>
@@ -538,7 +547,7 @@
return this;
}
/**
- This method is a slightly faster alternative to using the
method put().
+ This method is a slightly faster alternative to using the
method put().
It also allows code that looks like this:
<p>
<code>
@@ -551,7 +560,7 @@
return this;
}
/**
- This method is a slightly faster alternative to using the
method put().
+ This method is a slightly faster alternative to using the
method put().
It also allows code that looks like this:
<p>
<code>
@@ -560,7 +569,7 @@
*/
public Criteria add ( String table, String column, Object value,
String comparison )
{
- super.put( new
StringBuffer(table).append('.').append(column).toString(),
+ super.put( new
StringBuffer(table).append('.').append(column).toString(),
new CriteriaObject(table, column, value, comparison) );
return this;
}
@@ -603,7 +612,7 @@
* @param value - long to add
* @return Criteria - modified Criteria object
*/
- public Criteria add(String key, long value)
+ public Criteria add(String key, long value)
{
add(key, new Long(value));
return this;
@@ -615,7 +624,7 @@
* @param value - long to add
* @return Criteria - modified Criteria object
*/
- public Criteria add(String key, long value, String comparison)
+ public Criteria add(String key, long value, String comparison)
{
add(key, new Long(value), comparison);
return this;
@@ -627,7 +636,7 @@
* @param value - float to add
* @return Criteria - modified Criteria object
*/
- public Criteria add(String key, float value)
+ public Criteria add(String key, float value)
{
add(key, new Float(value));
return this;
@@ -639,7 +648,7 @@
* @param value - float to add
* @return Criteria - modified Criteria object
*/
- public Criteria add(String key, float value, String comparison)
+ public Criteria add(String key, float value, String comparison)
{
add(key, new Float(value), comparison);
return this;
@@ -651,7 +660,7 @@
* @param value - double to add
* @return Criteria - modified Criteria object
*/
- public Criteria add(String key, double value)
+ public Criteria add(String key, double value)
{
add(key, new Double(value));
return this;
@@ -663,7 +672,7 @@
* @param value - double to add
* @return Criteria - modified Criteria object
*/
- public Criteria add(String key, double value, String comparison)
+ public Criteria add(String key, double value, String comparison)
{
add(key, new Double(value), comparison);
return this;
@@ -709,7 +718,7 @@
<p>
where 'values' contains three objects that evaluate to the
respective
strings above when .toString() is called
- */
+ */
public Criteria addIn(String key, Object[] values)
{
add(key, (Object)values, Criteria.IN);
@@ -722,13 +731,13 @@
FOO.ID IN ('2', '3', '7')
<p>
where 'values' contains those three integers.
- */
+ */
public Criteria addIn(String key, int[] values)
{
add(key, (Object)values, Criteria.IN);
return this;
}
- /**
+ /**
Adds an 'IN' clause with the criteria supplied as a Vector.
For example:
<p>
@@ -750,7 +759,7 @@
<p>
where 'values' contains three objects that evaluate to the
respective
strings above when .toString() is called
- */
+ */
public Criteria addNotIn(String key, Object[] values)
{
add(key, (Object)values, Criteria.NOT_IN);
@@ -763,13 +772,13 @@
FOO.ID NOT IN ('2', '3', '7')
<p>
where 'values' contains those three integers.
- */
+ */
public Criteria addNotIn(String key, int[] values)
{
add(key, (Object)values, Criteria.NOT_IN);
return this;
}
- /**
+ /**
Adds an 'IN' clause with the criteria supplied as a Vector.
For example:
<p>
@@ -848,7 +857,7 @@
public Criteria addSelectColumn( String name )
{
selectColumns.add( name );
- return this;
+ return this;
}
/**
get select columns
@@ -870,7 +879,7 @@
public Criteria addOrderByColumn( String name )
{
orderByColumns.add( name );
- return this;
+ return this;
}
/**
get order by columns
@@ -887,7 +896,7 @@
Object foo = super.remove(key);
if (foo instanceof CriteriaObject)
return ((CriteriaObject)foo).getValue();
- return foo;
+ return foo;
}
/**
build a string representation of the Criteria
@@ -916,7 +925,7 @@
private String table = "";
/** column name */
private String column = "";
-
+
/**
Constructor
*/
@@ -926,7 +935,7 @@
this.column = column;
value = val;
comparison = comp;
- }
+ }
/**
Constructor
*/
@@ -944,7 +953,7 @@
}
value = val;
comparison = comp;
- }
+ }
/**
Constructor
*/
@@ -954,7 +963,7 @@
this.column = column;
value = val;
comparison = EQUAL;
- }
+ }
/**
Constructor
*/
*************** end patch *****************
John
--
********************************
** John Thorhauer
** [EMAIL PROTECTED]
********************************
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]