Eric--

I'm not sure how well our needs will fit together... however you might take
a look at the PropertyTagsHandler I added and let me know what's missing or
inconsistent with what you need.  I didn't put argument validation in: for
jmx attributes (here called properties) can't be indexed, and my needs are
for looking only at explicitly tagged methods, so that's what I wrote it
with.  It's possible that I can get the same result by nesting the tag
tests, however I didn't feel like proving that one way or another to
myself.  It also simplifies the templates considerably. 

Thanks
david jencks

On 2002.02.27 10:14:10 -0500 Erik Hatcher wrote:
> Also, on this note I suggest tightening up the definition of what a
> "setter"
> and "getter" is to be as close to the Java Bean spec as possible.
> 
> i.e. a setter is only a single parameter void method or two parameters
> with
> one being an int for indexed setters.  getters take no parameters or a
> single int parameter.
> 
> I'm going to add this kind of logic into my AntTagsHandler class, and
> that
> code is now in Ant's CVS under proposal/xdocs.
> 
>     Erik
> 
> 
> ----- Original Message -----
> From: "Ara Abrahamian" <[EMAIL PROTECTED]>
> To: "'David Jencks'" <[EMAIL PROTECTED]>; "'xdoclet-devel'"
> <[EMAIL PROTECTED]>
> Sent: Wednesday, February 27, 2002 5:09 AM
> Subject: RE: [Xdoclet-devel] Comments requested
> 
> 
> > So you're iterating over methods and check if there's a getter for
> > current property extracted from current method. I prefer the name
> > ifPropertyHasGetterMethod. Btw, we should also add
> > forAllProperties/ifIsGetter/Setter and so on. So I think instead of
> > putting these new methods in MethodTagsHandler it's better to define
> > them in a new PropertyTagsHandler class along with the other
> > property-oriented methods.
> >
> > Ara.
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> [mailto:xdoclet-devel-
> > > [EMAIL PROTECTED]] On Behalf Of David Jencks
> > > Sent: Wednesday, February 27, 2002 3:00 AM
> > > To: xdoclet-devel
> > > Subject: [Xdoclet-devel] Comments requested
> > >
> > > For the mbean stuff I am working on I need to find out if there are
> > > getter/setter methods based on the current method name.  I've written
> > the
> > > following additions to MethodTagsHandler and want to check that I'm
> > not
> > > breaking any conventions, rules, etc by adding these.  Also if there
> > is an
> > > easier way to do this I'd like to know.
> > >
> > > thanks
> > > david jencks
> > >
> > > Index: xdoclet/tags/MethodTagsHandler.java
> > > ===================================================================
> > > RCS file:
> > >
> > /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/MethodTagsHandler.java,v
> > > retrieving revision 1.23
> > > diff -u -r1.23 MethodTagsHandler.java
> > > --- xdoclet/tags/MethodTagsHandler.java 26 Feb 2002 06:04:29
> > > -0000 1.23
> > > +++ xdoclet/tags/MethodTagsHandler.java 26 Feb 2002 23:22:58
> > -0000
> > > @@ -935,6 +935,72 @@
> > >  }
> > >
> > >  /**
> > > + * The block tag <code>ifHasGetMethod</code> looks for a get
> > > method based on
> > > + * the attribute name from the current method, sets the current
> > > method to that
> > > + * get method, and applies the template if found. This is used
> > to
> > > look for
> > > + * getters for mbean managed attributes. The get method found
> > may
> > > be the
> > > + * current method.
> > > + *
> > > + * @param template              a <code>String</code> value
> > > + * @param attributes            a <code>Properties</code> value
> > > + * @exception XDocletException  if an error occurs
> > > + * @doc:tag                     type="block"
> > > + */
> > > + public void ifHasGetMethod( String template, Properties
> > attributes
> > > ) throws XDocletException
> > > + {
> > > + MethodDoc get_method = getGetMethod();
> > > +
> > > + if( get_method != null )
> > > + {
> > > + MethodDoc old_method = getCurrentMethod();
> > > +
> > > + setCurrentMethod( get_method );
> > > + try
> > > + {
> > > + generate( template );
> > > + }
> > > + finally
> > > + {
> > > + setCurrentMethod( old_method );
> > > + }
> > > + // end of try-catch
> > > + }
> > > + }
> > > +
> > > + /**
> > > + * The block tag <code>ifHasSetMethod</code> looks for a set
> > > method based on
> > > + * the attribute name from the current method, sets the current
> > > method to that
> > > + * set method, and applies the template if found. This is used
> > to
> > > look for
> > > + * setters for mbean managed attributes. The set method found
> > may
> > > be the
> > > + * current method.
> > > + *
> > > + * @param template              a <code>String</code> value
> > > + * @param attributes            a <code>Properties</code> value
> > > + * @exception XDocletException  if an error occurs
> > > + * @doc:tag                     type="block"
> > > + */
> > > + public void ifHasSetMethod( String template, Properties
> > attributes
> > > ) throws XDocletException
> > > + {
> > > + MethodDoc set_method = getSetMethod();
> > > +
> > > + if( set_method != null )
> > > + {
> > > + MethodDoc old_method = getCurrentMethod();
> > > +
> > > + setCurrentMethod( set_method );
> > > + try
> > > + {
> > > + generate( template );
> > > + }
> > > + finally
> > > + {
> > > + setCurrentMethod( old_method );
> > > + }
> > > + // end of try-catch
> > > + }
> > > + }
> > > +
> > > + /**
> > >  * Searches for the MethodDoc of the method with name methodName
> > > and returns
> > >  * it.
> > >  *
> > > @@ -1037,6 +1103,47 @@
> > >  cat.debug( "Method not found" );
> > >
> > >  return false;
> > > + }
> > > +
> > > + private MethodDoc getGetMethod() throws XDocletException
> > > + {
> > > + MethodDoc current_method = getCurrentMethod();
> > > +
> > > + if( current_method.name().startsWith( "get" ) ||
> > > current_method.name().startsWith( "is" ) )
> > > + {
> > > + return current_method;
> > > + }
> > > +
> > > + // end of if ()
> > > +
> > > + String attributeName = getMethodNameWithoutPrefixFor(
> > > current_method );
> > > + MethodDoc getter = getMethodDocForMethodName( "get" +
> > > attributeName );
> > > +
> > > + if( getter != null )
> > > + {
> > > + return getter;
> > > + }
> > > + // end of if ()
> > > + getter = getMethodDocForMethodName( "is" + attributeName
> > > );
> > > + //not too safe.. should check it's boolean.
> > > + return getter;
> > > + }
> > > +
> > > + private MethodDoc getSetMethod() throws XDocletException
> > > + {
> > > + MethodDoc current_method = getCurrentMethod();
> > > +
> > > + if( current_method.name().startsWith( "set" ) )
> > > + {
> > > + return current_method;
> > > + }
> > > +
> > > + // end of if ()
> > > +
> > > + String attributeName = getMethodNameWithoutPrefixFor(
> > > current_method );
> > > + MethodDoc setter = getMethodDocForMethodName( "set" +
> > > attributeName );
> > > +
> > > + return setter;
> > >  }
> > >
> > >  private boolean isInAppendExceptionsList( String
> > > append_exceptions, String type )
> > >
> > > _______________________________________________
> > > Xdoclet-devel mailing list
> > > [EMAIL PROTECTED]
> > > https://lists.sourceforge.net/lists/listinfo/xdoclet-devel
> >
> >
> >
> > _______________________________________________
> > Xdoclet-devel mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/xdoclet-devel
> >
> 
> 
> 

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to