ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject cvs commit: jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet TaskTagsHandler.java
Date Tue, 28 May 2002 20:16:49 GMT
ehatcher    02/05/28 13:16:49

  Modified:    proposal/xdocs/src/org/apache/tools/ant/xdoclet Tag:
                        ANT_15_BRANCH TaskTagsHandler.java
  Log:
  some fixes to the generator to not duplicate setters (we have some overloaded setters for
better type handling - which caused duplication here).
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +37 -7     jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/TaskTagsHandler.java
  
  Index: TaskTagsHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/TaskTagsHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- TaskTagsHandler.java	5 Mar 2002 03:26:40 -0000	1.1
  +++ TaskTagsHandler.java	28 May 2002 20:16:49 -0000	1.1.2.1
  @@ -307,31 +307,51 @@
           return false;
       }
   
  -    /**
  -     * @todo need to add checks for number of parameters and non-supported parameters
  -     */
       private MethodDoc[] getAttributeMethods(ClassDoc cur_class) throws XDocletException
{
           MethodDoc[] methods = getMethods(cur_class);
           List attributeMethods = new ArrayList();
  +        Map nameTypeMap = new HashMap();
   
           for (int i = 0; i < methods.length; i++) {
  -            if (!methods[i].name().startsWith("set")) {
  +            MethodDoc method = methods[i];
  +
  +            if (!method.isPublic()) {
  +                continue;
  +            }
  +
  +            if (!method.name().startsWith("set")) {
                   continue;
               }
   
               // if superclass is org.apache.tools.ant.Task then
               // remove some known unallowed properties
  -            if (isAntAttribute(methods[i])) {
  +            if (isAntAttribute(method)) {
                   continue;
               }
   
               // ensure method only has one parameter
  -            Parameter[] params = methods[i].parameters();
  +            Parameter[] params = method.parameters();
               if (params.length != 1) {
                   continue;
               }
   
  -            attributeMethods.add(methods[i]);
  +            Parameter param = params[0];
  +
  +            // Screen out attribute setters if there are duplicates,
  +            // and only return the first non-String one
  +            // (this may or may not jive with IntrospectionHelper)
  +            MethodDoc oldMethod = (MethodDoc) nameTypeMap.get(method.name());
  +            if (oldMethod == null) {
  +                nameTypeMap.put(method.name(), method);
  +            }
  +            else {
  +                if ("java.lang.String".equals(oldMethod.parameters()[0].typeName())) {
  +                    attributeMethods.remove(oldMethod);
  +                    nameTypeMap.put(method.name(), method);
  +                }
  +            }
  +
  +            attributeMethods.add(method);
           }
   
           return (MethodDoc[]) attributeMethods.toArray(new MethodDoc[0]);
  @@ -347,6 +367,10 @@
           List attributeMethods = new ArrayList();
   
           for (int i = 0; i < methods.length; i++) {
  +            if (! methods[i].isPublic()) {
  +                continue;
  +            }
  +
               String name = methods[i].name();
   
               // ensure if there are no parameters, there is a return type,
  @@ -354,6 +378,12 @@
               Parameter[] params = methods[i].parameters();
               if (params.length == 0) {
                   if (methods[i].returnType().asClassDoc() == null) {
  +                    continue;
  +                }
  +
  +                // only the "createXXX" method has zero params
  +                // the "addXXX" and "addConfiguredXXX" have 1 param
  +                if (!name.startsWith("create")) {
                       continue;
                   }
               }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message