User: stevensa Date: 02/03/03 17:28:33 Added: core/src/xdoclet/ejb/tags DaoTagsHandler.java Log: Added DAO and Bluestone subtasks Revision Changes Path 1.1 xdoclet/core/src/xdoclet/ejb/tags/DaoTagsHandler.java Index: DaoTagsHandler.java =================================================================== package xdoclet.ejb.tags; import com.sun.javadoc.ClassDoc; import org.apache.log4j.Category; import xdoclet.DocletContext; import xdoclet.XDocletException; import xdoclet.XDocletTagSupport; import xdoclet.ejb.DaoSubTask; import xdoclet.util.DocletUtil; import xdoclet.util.Log; import java.text.MessageFormat; import java.util.Properties; /** * @author <a href="mailto:[EMAIL PROTECTED]">Andrew Stevens</a> * @created February 8, 2002 * @version $Revision: 1.1 $ */ public class DaoTagsHandler extends EjbTagsHandler { /** * Similar to {@link InterfaceTagsHandler#getComponentInterface}. Relies on the * ejb:dao tag, which has the following relevant properties: * <ul> * <li> class: The fully qualified name of the DAO class - overrides all set * patterns * <li> pattern: The pattern to be used to determine the unqualified name of * the DAO class * <li> package: The package the DAO is to be placed in * </ul> * * * @param clazz Description of Parameter * @return The DAO value * @exception XDocletException Description of Exception */ public static String getDaoClassFor( ClassDoc clazz ) throws XDocletException { Category cat = Log.getCategory( DaoTagsHandler.class, "daoClassName" ); String fileName = clazz.containingPackage().name(); String dao_pattern = null; if( cat.isDebugEnabled() ) cat.debug( "dao for " + clazz.name() ); dao_pattern = getDaoClassPattern(); String daoClass = getParameterValue( clazz, DocletUtil.getText( clazz, "ejb:dao" ), "class", -1 ); if( daoClass != null ) return daoClass; String ejb_name = null; String package_pattern = null; if( dao_pattern.indexOf( "{0}" ) != -1 ) ejb_name = MessageFormat.format( dao_pattern, new Object[]{getShortEjbNameFor( clazz )} ); else ejb_name = dao_pattern; // Fix package name fileName = choosePackage( fileName, package_pattern, DaoSubTask.SUBTASK_NAME ); fileName += "." + ejb_name; return fileName; } protected static String getDaoClassPattern() { DaoSubTask dao_subtask = ( ( DaoSubTask ) DocletContext.getInstance().getSubTaskBy( DaoSubTask.SUBTASK_NAME ) ); if( dao_subtask != null ) return dao_subtask.getDaoClassPattern(); else return DaoSubTask.DEFAULT_DAO_CLASS_PATTERN; } private static boolean isDaoSubTaskActive() { return DocletContext.getInstance().isSubTaskDefined( DaoSubTask.SUBTASK_NAME ); } /** * Returns the full qualified dao class name for the bean * * @param attributes The attributes of the template tag * @return DAO class name * @exception XDocletException Description of Exception * @doc:tag type="content" */ public String daoClass( Properties attributes ) throws XDocletException { return getDaoClassFor( getCurrentClass() ); } /** * Evaluate the body block if ejb:dao tag present and DAO subtask being used. * * @param template * @exception XDocletException Description of Exception * @doc:tag type="block" */ public void ifUsingDao( String template ) throws XDocletException { if( isDaoSubTaskActive() && DocletUtil.hasTag( getCurrentClass(), "ejb:dao", false ) ) generate( template ); } }
_______________________________________________ Xdoclet-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-devel
