ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/src/org/apache/axis/wsdl/toJava JavaBeanWriter.java
Date Wed, 24 Mar 2004 17:36:37 GMT
dims        2004/03/24 09:36:37

  Modified:    java/src/org/apache/axis/wsdl/symbolTable SchemaUtils.java
               java/src/org/apache/axis/wsdl/toJava JavaBeanWriter.java
  Log:
  Fix for AXIS-1262 - Pulling Javadoc from
  from Danno Ferrin
  
  Revision  Changes    Path
  1.38      +50 -5     ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SchemaUtils.java
  
  Index: SchemaUtils.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SchemaUtils.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- SchemaUtils.java	16 Mar 2004 15:14:29 -0000	1.37
  +++ SchemaUtils.java	24 Mar 2004 17:36:37 -0000	1.38
  @@ -430,6 +430,55 @@
       }
   
       /**
  +     * Returns the complete text of the child xsd:annotation/xsd:documentation 
  +     * element from the provided node.  Only the first annotation element and 
  +     * the first documentation element in the annotation element will be used.
  +     * 
  +     * @param root Parent node.
  +     * @param path Path of element names to text of interest, delimited by "/". 
  +     */
  +    public static String getAnnotationDocumentation(Node typeNode) {
  +        Node annotationNode = typeNode.getFirstChild();
  +        while (annotationNode != null) {
  +            if (isXSDNode(annotationNode, "annotation")) {
  +                break;
  +            }
  +            annotationNode = annotationNode.getNextSibling();
  +        }
  +        Node documentationNode;
  +        if (annotationNode != null) {
  +            documentationNode = annotationNode.getFirstChild();
  +            while (documentationNode != null) {
  +                if (isXSDNode(documentationNode, "documentation")) {
  +                    break;
  +                }
  +                documentationNode = documentationNode.getNextSibling();
  +            }
  +        } else {
  +            documentationNode = null;
  +        }
  +        
  +        // should have found the node if it exists
  +        String text = "";
  +        if (documentationNode != null) {
  +            NodeList children = documentationNode.getChildNodes();
  +            if (children != null) {
  +                for (int i = 0; i < children.getLength(); i++) {
  +                    Node child = children.item(i);
  +                    if (child != null) {
  +                        if (child.getNodeName() != null
  +                                && (child.getNodeName().equals("#text")
  +                                || child.getNodeName().equals("#cdata-section"))) {
  +                            text += child.getNodeValue();
  +                        }
  +                    }
  +                }
  +            }
  +        }
  +        return text;
  +    }
  +
  +    /**
        * Invoked by getContainedElementDeclarations to get the child element types
        * and child element names underneath a Sequence Node
        * 
  @@ -571,11 +620,7 @@
           QName nodeName = Utils.getNodeNameQName(elementNode);
           BooleanHolder forElement = new BooleanHolder();
           String comments = null;
  -        try {
  -            comments = getTextByPath(elementNode, "annotation/documentation");
  -        } catch (DOMException e) {
  -            // no comments
  -        }
  +        comments = getAnnotationDocumentation(elementNode);
           
           // The type qname is used to locate the TypeEntry, which is then
           // used to retrieve the proper java name of the type.
  
  
  
  1.58      +13 -9     ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java
  
  Index: JavaBeanWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- JavaBeanWriter.java	16 Mar 2004 15:14:29 -0000	1.57
  +++ JavaBeanWriter.java	24 Mar 2004 17:36:37 -0000	1.58
  @@ -154,13 +154,13 @@
       
           try
           {
  -            String comments = SchemaUtils.getTextByPath(type.getNode(), "annotation/documentation");
  +            String comments = SchemaUtils.getAnnotationDocumentation(type.getNode());
               comments = getJavadocDescriptionPart(comments, false);
               if (comments != null && comments.trim().length() > 0)
               {
                   pw.println();
                   pw.println("/**");
  -                pw.println(" * " + comments);
  +                pw.println(comments);
                   pw.println(" */");
               }
           }
  @@ -440,7 +440,8 @@
               // Declare the bean element
               if (comments != null && comments.trim().length() > 0)
               {
  -                String flatComments = getJavadocDescriptionPart(comments, true);
  +                String flatComments = getJavadocDescriptionPart(comments, false).substring(3);
  +                // it will be flat if it fits on one line
                   pw.println("    /** " + flatComments.trim() + " */");
               }
               pw.print("    private " + typeName + " " + variable + ";");
  @@ -804,14 +805,18 @@
                   get = "is";
               }
   
  +            String comment = getJavadocDescriptionPart(documentation, false);
  +            if (comment.length() > 3) {
  +                // remove the " *" at the front of the first line
  +                comment = comment.substring(2);
  +            }
               if (enableGetters) {
                   try {
  -                    String comments = "Gets the " + name + " value for this " + getClassName()
+ ".";
                       pw.println();
                       pw.println("    /**");
  -                    pw.println("     * " + comments);
  +                    pw.println("     * Gets the " + name + " value for this " + getClassName()
+ ".");
                       pw.println("     * ");
  -                    pw.println("     * @return " + name + " " + getJavadocDescriptionPart(documentation,
true));
  +                    pw.println("     * @return " + name + comment);
                       pw.println("     */");
                   } catch (DOMException e) {
                       // no comment
  @@ -832,12 +837,11 @@
               if (enableSetters) {
                   try
                   {
  -                    String comments = "Sets the " + name + " value for this " + getClassName()
+ ".";
                       pw.println();
                       pw.println("    /**");
  -                    pw.println("     * " + comments);
  +                    pw.println("     * Sets the " + name + " value for this " + getClassName()
+ ".");
                       pw.println("     * ");
  -                    pw.println("     * @param " + name + " " + getJavadocDescriptionPart(documentation,
true));
  +                    pw.println("     * @param " + name + comment);
                       pw.println("     */");
                   }
                   catch (DOMException e)
  
  
  

Mime
View raw message