src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java

changeset 589
4177f5bdd189
parent 554
9d9f26857129
child 766
90af8d87741f
     1.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java	Fri Jun 18 16:45:13 2010 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java	Fri Jun 18 21:13:56 2010 -0700
     1.3 @@ -92,44 +92,42 @@
     1.4      public abstract void build() throws IOException;
     1.5  
     1.6      /**
     1.7 -     * Build the documentation, as specified by the given XML elements.
     1.8 +     * Build the documentation, as specified by the given XML element.
     1.9       *
    1.10 -     * @param elements the XML elements that specify which components to
    1.11 -     *                 document.
    1.12 +     * @param node the XML element that specifies which component to document.
    1.13       */
    1.14 -    protected void build(List<?> elements) {
    1.15 -        for (int i = 0; i < elements.size(); i++ ) {
    1.16 -            Object element = elements.get(i);
    1.17 -            String component = (String)
    1.18 -                ((element instanceof String) ?
    1.19 -                     element :
    1.20 -                    ((List<?>) element).get(0));
    1.21 -            try {
    1.22 -                invokeMethod("build" + component,
    1.23 -                    element instanceof String ?
    1.24 -                        new Class<?>[] {} :
    1.25 -                        new Class<?>[] {List.class},
    1.26 -                    element instanceof String ?
    1.27 -                        new Object[] {} :
    1.28 -                        new Object[] {((List<?>) element).subList(1,
    1.29 -                            ((List<?>) element).size())});
    1.30 -            } catch (NoSuchMethodException e) {
    1.31 -                e.printStackTrace();
    1.32 -                configuration.root.printError("Unknown element: " + component);
    1.33 -                throw new DocletAbortException();
    1.34 -            } catch (InvocationTargetException e) {
    1.35 -                e.getCause().printStackTrace();
    1.36 -            } catch (Exception e) {
    1.37 -                e.printStackTrace();
    1.38 -                configuration.root.printError("Exception " +
    1.39 -                    e.getClass().getName() +
    1.40 -                    " thrown while processing element: " + component);
    1.41 -                throw new DocletAbortException();
    1.42 -            }
    1.43 +    protected void build(XMLNode node) {
    1.44 +        String component = node.name;
    1.45 +        try {
    1.46 +            invokeMethod("build" + component,
    1.47 +                    new Class<?>[] { XMLNode.class },
    1.48 +                    new Object[] { node });
    1.49 +        } catch (NoSuchMethodException e) {
    1.50 +            e.printStackTrace();
    1.51 +            configuration.root.printError("Unknown element: " + component);
    1.52 +            throw new DocletAbortException();
    1.53 +        } catch (InvocationTargetException e) {
    1.54 +            e.getCause().printStackTrace();
    1.55 +        } catch (Exception e) {
    1.56 +            e.printStackTrace();
    1.57 +            configuration.root.printError("Exception " +
    1.58 +                e.getClass().getName() +
    1.59 +                " thrown while processing element: " + component);
    1.60 +            throw new DocletAbortException();
    1.61          }
    1.62      }
    1.63  
    1.64      /**
    1.65 +     * Build the documentation, as specified by the children of the given XML element.
    1.66 +     *
    1.67 +     * @param node the XML element that specifies which components to document.
    1.68 +     */
    1.69 +    protected void buildChildren(XMLNode node) {
    1.70 +        for (XMLNode child: node.children)
    1.71 +            build(child);
    1.72 +    }
    1.73 +
    1.74 +    /**
    1.75       * Given the name and parameters, invoke the method in the builder.  This
    1.76       * method is required to invoke the appropriate build method as instructed
    1.77       * by the builder XML file.
    1.78 @@ -138,7 +136,14 @@
    1.79       * @param paramClasses the types for each parameter.
    1.80       * @param params       the parameters of the method.
    1.81       */
    1.82 -    protected abstract void invokeMethod(String methodName, Class<?>[] paramClasses,
    1.83 +    protected void invokeMethod(String methodName, Class<?>[] paramClasses,
    1.84              Object[] params)
    1.85 -    throws Exception;
    1.86 +    throws Exception {
    1.87 +        if (DEBUG) {
    1.88 +            configuration.root.printError("DEBUG: " + this.getClass().getName()
    1.89 +                + "." + methodName);
    1.90 +        }
    1.91 +        Method method = this.getClass().getMethod(methodName, paramClasses);
    1.92 +        method.invoke(this, params);
    1.93 +    }
    1.94  }

mercurial