jmcnally 2002/09/24 22:46:51
Modified: src/java/org/apache/torque/om SimpleKey.java
Log:
patch by J. Russell Smyth
added static keyFor(value) methods to create appropriate SimpleKey instances for
specified values.
Revision Changes Path
1.4 +92 -3
jakarta-turbine-torque/src/java/org/apache/torque/om/SimpleKey.java
Index: SimpleKey.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/om/SimpleKey.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SimpleKey.java 26 Jul 2002 22:30:35 -0000 1.3
+++ SimpleKey.java 25 Sep 2002 05:46:51 -0000 1.4
@@ -56,12 +56,101 @@
/**
* This empty class marks an ObjectKey as being capable of being
- * represented as a single column in a database. It does not
- * implement any methods.
+ * represented as a single column in a database.
*
* @author <a href="mailto:[EMAIL PROTECTED]">John McNally</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">J. Russell Smyth</a>
* @version $Id$
*/
public abstract class SimpleKey extends ObjectKey
{
+ /**
+ * Creates a SimpleKey equivalent to key
+ * @param key the key value
+ * @return a SimpleKey
+ */
+ public static SimpleKey keyFor(java.math.BigDecimal key)
+ {
+ return new NumberKey(key);
+ }
+
+ /**
+ * Creates a SimpleKey equivalent to key
+ * @param key the key value
+ * @return a SimpleKey
+ */
+ public static SimpleKey keyFor(int key)
+ {
+ return new NumberKey(key);
+ }
+
+ /**
+ * Creates a SimpleKey equivalent to key
+ * @param key the key value
+ * @return a SimpleKey
+ */
+ public static SimpleKey keyFor(long key)
+ {
+ return new NumberKey(key);
+ }
+
+ /**
+ * Creates a SimpleKey equivalent to key
+ * @param key the key value
+ * @return a SimpleKey
+ */
+ public static SimpleKey keyFor(Number key)
+ {
+ return new NumberKey(key);
+ }
+
+ /**
+ * Creates a SimpleKey equivalent to key
+ * @param key the key value
+ * @return a SimpleKey
+ */
+ public static SimpleKey keyFor(NumberKey key)
+ {
+ return new NumberKey(key);
+ }
+
+ /**
+ * Creates a SimpleKey equivalent to key
+ * @param key the key value
+ * @return a SimpleKey
+ */
+ public static SimpleKey keyFor(String key)
+ {
+ return new StringKey(key);
+ }
+
+ /**
+ * Creates a SimpleKey equivalent to key
+ * @param key the key value
+ * @return a SimpleKey
+ */
+ public static SimpleKey keyFor(StringKey key)
+ {
+ return new StringKey(key);
+ }
+
+ /**
+ * Creates a SimpleKey equivalent to key
+ * @param key the key value
+ * @return a SimpleKey
+ */
+ public static SimpleKey keyFor(java.util.Date key)
+ {
+ return new DateKey(key);
+ }
+
+ /**
+ * Creates a SimpleKey equivalent to key
+ * @param key the key value
+ * @return a SimpleKey
+ */
+ public static SimpleKey keyFor(DateKey key)
+ {
+ return new DateKey(key);
+ }
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>