User: vharcq Date: 02/03/07 14:35:18 Modified: core/src/xdoclet/ejb/tags EjbTagsHandler.java PersistentTagsHandler.java PkTagsHandler.java Log: Thanks to Marcus Brito ! Value Objects : - Support added for entity bean with a PK field instead of a PK class - Support for JBoss dependant value object (CMP2) - Some more stuffs I don't remember. Marcus is ahead now. Let's trust him. Revision Changes Path 1.31 +23 -1 xdoclet/core/src/xdoclet/ejb/tags/EjbTagsHandler.java Index: EjbTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ejb/tags/EjbTagsHandler.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -r1.30 -r1.31 --- EjbTagsHandler.java 4 Mar 2002 21:32:41 -0000 1.30 +++ EjbTagsHandler.java 7 Mar 2002 22:35:18 -0000 1.31 @@ -26,7 +26,7 @@ /** * @author Ara Abrahamian ([EMAIL PROTECTED]) * @created Oct 15, 2001 - * @version $Revision: 1.30 $ + * @version $Revision: 1.31 $ */ public class EjbTagsHandler extends XDocletTagSupport { @@ -593,6 +593,28 @@ public void ifRemoteEjb( String template ) throws XDocletException { if( isRemoteEjb( getCurrentClass() ) ) + generate( template ); + } + + /** + * @param template + * @exception XDocletException + * @doc: tag type="body" + */ + public void ifNotLocalEjb( String template ) throws XDocletException + { + if( !isLocalEjb( getCurrentClass() ) ) + generate( template ); + } + + /** + * @param template + * @exception XDocletException + * @doc:tag type="body" + */ + public void ifNotRemoteEjb( String template ) throws XDocletException + { + if( !isRemoteEjb( getCurrentClass() ) ) generate( template ); } 1.20 +2 -2 xdoclet/core/src/xdoclet/ejb/tags/PersistentTagsHandler.java Index: PersistentTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ejb/tags/PersistentTagsHandler.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -w -r1.19 -r1.20 --- PersistentTagsHandler.java 17 Feb 2002 08:51:02 -0000 1.19 +++ PersistentTagsHandler.java 7 Mar 2002 22:35:18 -0000 1.20 @@ -19,7 +19,7 @@ /** * @author Ara Abrahamian ([EMAIL PROTECTED]) * @created Oct 16, 2001 - * @version $Revision: 1.19 $ + * @version $Revision: 1.20 $ */ public class PersistentTagsHandler extends CmpTagsHandler { @@ -176,7 +176,7 @@ String value = MethodTagsHandler.getPropertyNameFor( methods[j] ); if( foundFields.size() > 1 ) - st.append( " + " ); + st.append( " + " + "\" \"" + " + " ); st.append( "\"" ).append( name ).append( "=\" + " ).append( value ); break; 1.17 +197 -1 xdoclet/core/src/xdoclet/ejb/tags/PkTagsHandler.java Index: PkTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ejb/tags/PkTagsHandler.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -r1.16 -r1.17 --- PkTagsHandler.java 21 Feb 2002 23:07:58 -0000 1.16 +++ PkTagsHandler.java 7 Mar 2002 22:35:18 -0000 1.17 @@ -24,10 +24,78 @@ /** * @author Ara Abrahamian ([EMAIL PROTECTED]) * @created Oct 16, 2001 - * @version $Revision: 1.16 $ + * @version $Revision: 1.17 $ */ public class PkTagsHandler extends EjbTagsHandler { + + /** + * @param clazz The class to look into + * @return The value of the + * @ejb:bean primkey-field parameter + * @throws XDocletException if the class doesn't have a primkey-field + */ + public static String getPrimkeyFieldFor( ClassDoc clazz ) throws XDocletException + { + String pkField = getParameterValue( clazz, DocletUtil.getText( clazz, "ejb:bean" ), "primkey-field", -1 ); + + return pkField; + } + + /** + * @param clazz The class to look into + * @param method The method to check for primkey-field + * @return true if the method is a getter or setter for the + * primkey-field + * @throws XDocletException + */ + public static boolean isMethodPrimkeyField( ClassDoc clazz, MethodDoc method ) + throws XDocletException + { + String pkField = getPrimkeyFieldFor( clazz ); + String propertyName = MethodTagsHandler.getPropertyNameFor( method ); + + return propertyName.equals( pkField ); + } + + public static String getPrimkeyGetterFor( ClassDoc clazz ) throws XDocletException + { + if( !classHasPrimkeyField( clazz ) ) + return null; + + StringBuffer buffer = new StringBuffer(); + + buffer.append( "get" ); + buffer.append( Character.toUpperCase( getPrimkeyFieldFor( clazz ).charAt( 0 ) ) ); + buffer.append( getPrimkeyFieldFor( clazz ).substring( 1 ) ); + + String getterName = buffer.toString(); + + if( MethodTagsHandler.hasMethod( clazz, getterName, null, false ) ) + return getterName; + else + return null; + } + + public static String getPrimkeySetterFor( ClassDoc clazz ) throws XDocletException + { + if( !classHasPrimkeyField( clazz ) ) + return null; + + StringBuffer buffer = new StringBuffer(); + + buffer.append( "set" ); + buffer.append( Character.toUpperCase( getPrimkeyFieldFor( clazz ).charAt( 0 ) ) ); + buffer.append( getPrimkeyFieldFor( clazz ).substring( 1 ) ); + + String setterName = buffer.toString(); + + if( MethodTagsHandler.hasMethod( clazz, setterName, null, false ) ) + return setterName; + else + return null; + } + public static String getPkClassFor( ClassDoc clazz ) throws XDocletException { String fileName = clazz.containingPackage().name(); @@ -79,6 +147,20 @@ else return create_method_return_type; } + /** + * Returns true if the clazz has a primkey-field defined on the + * + * @param clazz The class to look into. + * @return true if the class has a defined primkey-field + * @ejb:bean tag (opposed to having a separete PK class) + * @throws XDocletException + */ + public static boolean classHasPrimkeyField( ClassDoc clazz ) throws XDocletException + { + String pkField = getPrimkeyFieldFor( clazz ); + + return ( pkField != null ); + } protected static String getEntityPkClassPattern() { @@ -99,6 +181,120 @@ return false; else return true; + } + + /** + * Process the tag body if the current class has a defined primkey-field + * + * @param template + * @param attributes + * @exception XDocletException + * @doc:tag type="block" + */ + public void ifHasPrimkeyField( String template, Properties attributes ) + throws XDocletException + { + if( classHasPrimkeyField( getCurrentClass() ) ) + generate( template ); + } + + /** + * Process the tag body if the current method is a getter or setter for the + * primkey-field + * + * @param template + * @param attributes + * @exception XDocletException + * @doc:tag type="block" + */ + public void ifIsPrimkeyField( String template, Properties attributes ) + throws XDocletException + { + if( isMethodPrimkeyField( getCurrentClass(), getCurrentMethod() ) ) + generate( template ); + } + + /** + * @param template + * @param attributes + * @doc:tag type="block" + * @throws XDocletException + */ + public void ifIsNotPrimkeyField( String template, Properties attributes ) + throws XDocletException + { + if( !isMethodPrimkeyField( getCurrentClass(), getCurrentMethod() ) ) + generate( template ); + } + + /** + * @param template + * @param attributes + * @exception XDocletException + * @doc:tag type="body" + */ + public void ifDoesntHavePrimkeyField( String template, Properties attributes ) + throws XDocletException + { + if( !classHasPrimkeyField( getCurrentClass() ) ) + generate( template ); + } + + /** + * Returns the primkey-field defined for the current class + * + * @param attributes + * @return + * @exception XDocletException + * @doc:tag type="content" + */ + public String primkeyField( Properties attributes ) + throws XDocletException + { + return getPrimkeyFieldFor( getCurrentClass() ); + } + + /** + * Returns the getter name for the primkey-field + * + * @param attributes + * @return + * @exception XDocletException + * @doc:tag type="content" + */ + public String primkeyGetter( Properties attributes ) + throws XDocletException + { + return getPrimkeyGetterFor( getCurrentClass() ); + } + + /** + * Returns the setter name for the primkey-field + * + * @param attributes + * @return + * @exception XDocletException + * @doc:tag type="content" + */ + public String primkeySetter( Properties attributes ) + throws XDocletException + { + return getPrimkeySetterFor( getCurrentClass() ); + } + + /** + * Process the tag body if the current class has defined a setter for the + * primkey-field. + * + * @param template + * @param attributes + * @exception XDocletException + */ + public void ifHasPrimkeySetter( String template, Properties attributes ) + throws XDocletException + { + if( getPrimkeySetterFor( getCurrentClass() ) != null ) + generate( template ); } /**
_______________________________________________ Xdoclet-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-devel