Thanks - I've managed to workaround the problem.
However, I think a more general solution would be better,
perhaps by adding an optional "match" attribute to the
forAll* template methods.

I haven't looked at all of the sources, but it looks like a
change to
   xdoclet.tagshandler.AbstractProgramElementTagsHandler.forAllMembers()
would do the trick.

As for supporting regexps on a non-1.4 platform, there is
ORO (http://jakarta.apache.org/oro/index.html) and Regexp
(http://jakarta.apache.org/regexp/index.html)
ORO supports Perl regular expressions.

Regards,

Tim

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of David
> Sciamma
> Sent: Wednesday, 28 May 2003 7:00 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [Xdoclet-user] Can the template language match method names
> on a regexp?
>
>
> Hi,
>
>     I realize something like this, it check if a class has test method :
> you can modify this to iterate over all methods.
> I hope it will help you.
>
> David
>
>
> package com.myclass.xdoclet;
>
> import java.util.*;
>
> import xjavadoc.*;
> import xdoclet.DocletContext;
>
> import xdoclet.tagshandler.*;
> import xdoclet.XDocletException;
> import xdoclet.XDocletMessages;
> import xdoclet.XmlSubTask;
> import xdoclet.util.DocletUtil;
> import xdoclet.util.LogUtil;
> import xdoclet.util.Translator;
> import xdoclet.util.TypeConversionUtil;
>
> /**
>  * This class offers new tags to XDoclet.
>  * Those tags returns function results to deal easily with the tests
>  *
>  * @author                      <a
> href="mailto:[EMAIL PROTECTED]">David Sciamma</a>
>  * @created                     Feb 21, 2003
>  * @xdoclet.taghandler    namespace="Test"
>  * @version                     $Revision: 1.1.1.1 $
>  */
> public class TestTagsHandler extends MethodTagsHandler
> {
>
>     /**
>      * Evaluates if the class contains a test method.
>      * Use :
> &lt;XDtTest:ifHasTestMethod&gt;&lt;/XDtTest:ifHasTestMethod&gt;
>      *
>      * @param template                  The body of the block tag
>      * @param attributes                 The attributes of the
> template tag
>      * @exception XDocletException
>      */
>     public void ifHasTestMethod(String template, Properties attributes)
> throws XDocletException
>     {
>         boolean superclasses =
> TypeConversionUtil.stringToBoolean(attributes.getProperty("supercl
> asses"),
> true);
>         XClass currentClass = getCurrentClass();
>         boolean hasTest = false;
>
>         if (currentClass == null) {
>             throw new XDocletException("currentClass == null!!!");
>         }
>
>         Collection members = null;
>
>         members = currentClass.getMethods(superclasses);
>
>         for (Iterator j = members.iterator(); j.hasNext(); ) {
>             XMember member = (XMember) j.next();
>
>             if (_isTestMethod((XMethod) member)) {
>                 hasTest = true;
>             }
>             setCurrentClass(member.getContainingClass());
>
>         }
>         setCurrentClass(currentClass);
>
>         if (hasTest) {
>             generate(template);
>         }
>     }
>
>     /**
>      * Evaluates if the method is a test method.
>      * Use : &lt;XDtTest:ifIsTestMethod&gt;&lt;/XDtTest:ifIsTestMethod&gt;
>      *
>      * @param template                  The body of the block tag
>      * @param attributes                 The attributes of the
> template tag
>      * @exception XDocletException
>      */
>     public void ifIsTestMethod(String template, Properties attributes)
> throws XDocletException
>     {
>         String method_name = attributes.getProperty("method");
>
>         if (method_name != null) {
>             if (_isTest(method_name)) {
>                 generate(template);
>             }
>         }
>         else {
>             if (_isTestMethod(getCurrentMethod())) {
>                 generate(template);
>             }
>         }
>     }
>
>     /**
>      * Returns true if the str string starts with the "test", "load",
> "timed", "mixed" or "memory" prefix.
>      *
>      * @param str
>      */
>     private static boolean _isTest(String str)
>     {
>         return str.startsWith("test");
>     }
>
>     /**
>      * Returns true if the method is a test method.
>      *
>      * @param method
>      */
>     private static boolean _isTestMethod(XMethod method)
>     {
>         String str = method.getName();
>
>         return _isTest(str);
>     }
> }
>
>
> Rupp,Heiko wrote:
>
> >Hi,
> >
> >
> >
> >>    I'm trying to write a template which
> >>matches all public methods which start with 'test'.
> >>
> >>
> >
> >Regular Expressions are not yet supported. Can't say
> >about the simple test* case though.
> >Afaik, there are currently investigations underway on
> >how to support regexp in JDK 1.3, which does not have
> >this capability.
> >Xdoclet2 will probably require JDK1.4, so regexps are
> >provided by the JDK and will probably be used.
> >
> >Doesn't really help? :-/
> >
> >  Heiko
> >
> >
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ObjectStore.
> If flattening out C++ or Java code to make your application fit in a
> relational database is painful, don't do it! Check out ObjectStore.
> Now part of Progress Software. http://www.objectstore.net/sourceforge
> _______________________________________________
> xdoclet-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/xdoclet-user
>




-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to