tfischer 2005/06/27 14:34:10
Modified: src/generator/src/templates/om Object.vm
ObjectWithManager.vm
src/generator/src/dtd database.dtd
. project-base.xml
xdocs changes.xml
src/generator/src/java/org/apache/torque/engine/database/model
Column.java
src/rttest test-schema.xml
Log:
Added a "protected" attribute to the column which van be used to make getters
and setters for the column protected.
This can be helpful if Torque manages inheritance.
Thanks to Jonthan Purvis for the Patch.
See TRQS306 in scarab
Revision Changes Path
1.25 +8 -3 db-torque/src/generator/src/templates/om/Object.vm
Index: Object.vm
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/templates/om/Object.vm,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- Object.vm 28 Mar 2005 18:25:28 -0000 1.24
+++ Object.vm 27 Jun 2005 21:34:09 -0000 1.25
@@ -119,13 +119,18 @@
#set ( $cfc=$col.JavaName )
#set ( $clo=$col.UncapitalisedJavaName )
#set ( $cjtype = $col.JavaNative )
-
+ #if ( $col.isProtected() )
+ #set ( $accessLevel = "protected" )
+ #else
+ #set ( $accessLevel = "public" )
+ #end
+
/**
* Get the $cfc
*
* @return $cjtype
*/
- public $cjtype ${col.GetterName} ()
+ $accessLevel $cjtype ${col.GetterName} ()
{
return $clo;
}
@@ -147,7 +152,7 @@
*
* @param v new value
*/
- public void ${col.SetterName}($cjtype v) $throwsClause
+ $accessLevel void ${col.SetterName}($cjtype v) $throwsClause
{
#if (($cjtype == "NumberKey") || ($cjtype == "StringKey") || ($cjtype ==
"DateKey"))
if (v != null && v.getValue() == null)
1.20 +7 -2
db-torque/src/generator/src/templates/om/ObjectWithManager.vm
Index: ObjectWithManager.vm
===================================================================
RCS file:
/home/cvs/db-torque/src/generator/src/templates/om/ObjectWithManager.vm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ObjectWithManager.vm 28 Mar 2005 18:25:28 -0000 1.19
+++ ObjectWithManager.vm 27 Jun 2005 21:34:09 -0000 1.20
@@ -120,13 +120,18 @@
#set ( $cfc=$col.JavaName )
#set ( $clo=$col.UncapitalisedJavaName )
#set ( $cjtype = $col.JavaNative )
+ #if ( $col.isProtected() )
+ #set ( $accessLevel = "protected" )
+ #else
+ #set ( $accessLevel = "public" )
+ #end
/**
* Get the $cfc
*
* @return $cjtype
*/
- public $cjtype ${col.GetterName}()
+ $accessLevel $cjtype ${col.GetterName}()
{
return $clo;
}
@@ -148,7 +153,7 @@
*
* @param v new value
*/
- public void ${col.SetterName}($cjtype v) $throwsClause
+ $accessLevel void ${col.SetterName}($cjtype v) $throwsClause
{
#if (($cjtype == "NumberKey") || ($cjtype == "StringKey") || ($cjtype ==
"DateKey"))
if (v != null && v.getValue() == null)
1.8 +2 -1 db-torque/src/generator/src/dtd/database.dtd
Index: database.dtd
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/dtd/database.dtd,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- database.dtd 17 Apr 2005 10:45:43 -0000 1.7
+++ database.dtd 27 Jun 2005 21:34:10 -0000 1.8
@@ -104,6 +104,7 @@
javaName CDATA #IMPLIED
primaryKey (true|false) "false"
required (true|false) "false"
+ protected (true|false) "false"
domain CDATA #IMPLIED
type
(
1.15 +4 -0 db-torque/project-base.xml
Index: project-base.xml
===================================================================
RCS file: /home/cvs/db-torque/project-base.xml,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- project-base.xml 9 Mar 2005 15:43:05 -0000 1.14
+++ project-base.xml 27 Jun 2005 21:34:10 -0000 1.15
@@ -271,6 +271,10 @@
<email>[EMAIL PROTECTED]</email>
</contributor>
<contributor>
+ <name>Jonathan Purvis</name>
+ <email>[EMAIL PROTECTED]</email>
+ </contributor>
+ <contributor>
<name>J. Russell Smyth</name>
<email>[EMAIL PROTECTED]</email>
</contributor>
1.167 +4 -0 db-torque/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/db-torque/xdocs/changes.xml,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -r1.166 -r1.167
--- changes.xml 27 Jun 2005 20:34:41 -0000 1.166
+++ changes.xml 27 Jun 2005 21:34:10 -0000 1.167
@@ -28,6 +28,10 @@
<body>
<release version="3.2-dev" date="in CVS">
+ <action type="add" dev="tfischer" issue="TRQS306">
+ Added a "protected" attribute to the column. If set to true, the
getters
+ and setters of a column are protected rather than public.
+ </action>
<action type="fix" dev="tfischer" issue="TRQS304">
If a Peer class cannot instantiate its Map Builder, a Runtime
Exception is now
thrown (instead of just logging the error).
1.29 +20 -1
db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java
Index: Column.java
===================================================================
RCS file:
/home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Column.java 17 Apr 2005 10:45:43 -0000 1.28
+++ Column.java 27 Jun 2005 21:34:10 -0000 1.29
@@ -50,6 +50,7 @@
private String javaName = null;
private String javaNamingMethod;
private boolean isNotNull = false;
+ private boolean isProtected = false;
private String javaType;
private Table parentTable;
private int position;
@@ -193,6 +194,8 @@
this.inputValidator = attrib.getValue("inputValidator");
description = attrib.getValue("description");
+
+ isProtected = ("true".equals(attrib.getValue("protected")));
}
/**
@@ -440,6 +443,22 @@
}
/**
+ * Return the isProtected property of the column
+ */
+ public boolean isProtected()
+ {
+ return isProtected;
+ }
+
+ /**
+ * Set the isProtected property of the Column
+ */
+ public void setProtected(boolean prot)
+ {
+ isProtected = prot;
+ }
+
+ /**
* Set if the column is a primary key or not
*/
public void setPrimaryKey(boolean pk)
1.26 +5 -3 db-torque/src/rttest/test-schema.xml
Index: test-schema.xml
===================================================================
RCS file: /home/cvs/db-torque/src/rttest/test-schema.xml,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- test-schema.xml 15 Jun 2005 06:51:57 -0000 1.25
+++ test-schema.xml 27 Jun 2005 21:34:10 -0000 1.26
@@ -258,12 +258,14 @@
name="PAYLOAD_PARENT"
required="true"
type="VARCHAR"
- size="100"
- />
+ size="100"
+ protected="false"
+ />
<column
name="PAYLOAD_B"
type="VARCHAR"
- size="100"
+ size="100"
+ protected="true"
/>
<column
name="PAYLOAD_C"
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]