Index: ./src/java/org/apache/torque/om/BaseObject.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-torque/src/java/org/apache/torque/om/BaseObject.java,v
retrieving revision 1.11
diff -u -r1.11 BaseObject.java
--- ./src/java/org/apache/torque/om/BaseObject.java 30 Apr 2002 09:22:38 -0000
1.11
+++ ./src/java/org/apache/torque/om/BaseObject.java 2 May 2002 03:54:20 -0000
@@ -337,6 +337,21 @@
}
/**
+ * Sets the field specified by name to
+ * the value passed in.
+ * Must be overridden if called.
+ * BaseObject's implementation will throw an Error.
+ *
+ * @param field The name of the field to set.
+ * @param value The new value for the field.
+ *
+ */
+ public void setByName(String field, Object value)
+ {
+ throw new Error("BaseObject.setByName: " + NOT_IMPLEMENTED);
+ }
+
+ /**
* Retrieves a field from the object by name passed in
* as a String. Must be overridden if called.
* BaseObject's implementation will throw an Error.
@@ -344,6 +359,21 @@
public Object getByPeerName(String name)
{
throw new Error("BaseObject.getByPeerName: " + NOT_IMPLEMENTED);
+ }
+
+ /**
+ * Sets the field specified by the Peer name to
+ * the value passed in.
+ * Must be overridden if called.
+ * BaseObject's implementation will throw an Error.
+ *
+ * @param field The name of the field to set.
+ * @param value The new value for the field.
+ *
+ */
+ public void setByPeerName(String field, Object value)
+ {
+ throw new Error("BaseObject.setByPeerName: " + NOT_IMPLEMENTED);
}
/**
Index: ./src/templates/om/Object.vm
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/src/templates/om/Object.vm,v
retrieving revision 1.28
diff -u -r1.28 Object.vm
--- ./src/templates/om/Object.vm 30 Apr 2002 23:49:48 -0000 1.28
+++ ./src/templates/om/Object.vm 2 May 2002 03:54:21 -0000
@@ -689,6 +689,46 @@
#end
return null;
}
+
+ /**
+ * Sets a field by name passed in
+ * as a String.
+ * throws a TorqueException
+ */
+ public void setByName(String name, Object obj)
+ throws TorqueException
+ {
+ #foreach ($col in $table.Columns)
+ #set ( $cfc = $col.JavaName )
+ #set ( $cup=$col.Name.toUpperCase() )
+ #set ( $cjtype = $col.JavaNative )
+ if (name.equals("${col.JavaName}"))
+ {
+ #if (!$col.isPrimitive())
+ #if ( ($cjtype == "NumberKey")
+ || ($cjtype == "StringKey")
+ || ($cjtype == "DateKey") )
+ // For ObjectKeys we need to check Object
+ // to see if it's a String or an ObjectKey
+ // so we can use the correct method
+ if (obj instanceof $cjtype)
+ {
+ set${cfc}(($cjtype)obj);
+ }
+ else if (obj instanceof String)
+ {
+ set${cfc}((String)obj);
+ }
+ #else
+ set${cfc}(($cjtype)obj);
+ #end
+ #else
+ set${cfc}(((Number)obj).${cjtype}Value());
+ #end
+ }
+ #end
+ }
+
/**
* Retrieves a field from the object by name passed in
* as a String. The String must be one of the static
@@ -724,6 +764,42 @@
}
#end
return null;
+ }
+
+ /**
+ * Sets a field by name passed in
+ * as a String. The String must be one of the static
+ * Strings defined in this Class' Peer.
+ */
+ public void setByPeerName(String name, Object obj)
+ throws TorqueException
+ {
+ #foreach ($col in $table.Columns)
+ #set ( $cfc = $col.JavaName )
+ #set ( $cup=$col.Name.toUpperCase() )
+ #set ( $cjtype = $col.JavaNative )
+ if (name.equals(${table.JavaName}Peer.$cup ))
+ {
+ #if (!$col.isPrimitive())
+ #if ( ($cjtype == "NumberKey")
+ || ($cjtype == "StringKey")
+ || ($cjtype == "DateKey") )
+ // For ObjectKeys we need to check Object
+ // to see if it's a String or an ObjectKey
+ // so we can use the correct method
+ if (obj instanceof $cjtype) {
+ set${cfc}(($cjtype)obj);
+ } else if (obj instanceof String) {
+ set${cfc}((String)obj);
+ }
+ #else
+ set${cfc}(($cjtype)obj);
+ #end
+ #else
+ set${cfc}(((Number)obj).${cjtype}Value());
+ #end
+ }
+ #end
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>