Save This Page
Home » tapestry-src-5.0.19 » org.apache.tapestry.mojo » [javadoc | source]
    1   // Copyright 2007, 2008 The Apache Software Foundation
    2   //
    3   // Licensed under the Apache License, Version 2.0 (the "License");
    4   // you may not use this file except in compliance with the License.
    5   // You may obtain a copy of the License at
    6   //
    7   //     http://www.apache.org/licenses/LICENSE-2.0
    8   //
    9   // Unless required by applicable law or agreed to in writing, software
   10   // distributed under the License is distributed on an "AS IS" BASIS,
   11   // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12   // See the License for the specific language governing permissions and
   13   // limitations under the License.
   14   
   15   package org.apache.tapestry.mojo;
   16   
   17   import nu.xom;
   18   import org.apache.commons.lang.StringUtils;
   19   import org.apache.commons.lang.SystemUtils;
   20   import org.apache.maven.artifact.Artifact;
   21   import org.apache.maven.artifact.repository.ArtifactRepository;
   22   import org.apache.maven.model.Resource;
   23   import org.apache.maven.project.MavenProject;
   24   import org.apache.maven.reporting.AbstractMavenReport;
   25   import org.apache.maven.reporting.MavenReportException;
   26   import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
   27   import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newList;
   28   import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newMap;
   29   import org.apache.tapestry5.ioc.internal.util.InternalUtils;
   30   import org.codehaus.doxia.sink.Sink;
   31   import org.codehaus.doxia.site.renderer.SiteRenderer;
   32   import org.codehaus.plexus.util.cli.CommandLineException;
   33   import org.codehaus.plexus.util.cli.CommandLineUtils;
   34   import org.codehaus.plexus.util.cli.Commandline;
   35   import org.codehaus.plexus.util.cli.DefaultConsumer;
   36   
   37   import java.io;
   38   import java.util;
   39   
   40   /**
   41    * The component report generates documentation about components and parameters within the current project.
   42    *
   43    * @goal component-report
   44    * @requiresDependencyResolution compile
   45    * @execute phase="generate-sources"
   46    */
   47   @SuppressWarnings({"unchecked"})
   48   public class ComponentReport extends AbstractMavenReport
   49   {
   50       /**
   51        * Subdirectory containing the component reference pages and index.
   52        */
   53       private static final String REFERENCE_DIR = "ref";
   54   
   55       private final static String[] PARAMETER_HEADERS = {"Name", "Type", "Flags", "Default", "Default Prefix",
   56               "Description"};
   57   
   58   
   59       /**
   60        * Identifies the application root package.
   61        *
   62        * @parameter
   63        * @required
   64        */
   65       private String rootPackage;
   66   
   67       /**
   68        * The Maven Project Object
   69        *
   70        * @parameter expression="${project}"
   71        * @required
   72        * @readonly
   73        */
   74       private MavenProject project;
   75   
   76       /**
   77        * Generates the site report
   78        *
   79        * @component
   80        */
   81       private SiteRenderer siteRenderer;
   82   
   83       /**
   84        * Location of the generated site.
   85        *
   86        * @parameter default-value="${project.reporting.outputDirectory}"
   87        * @required
   88        */
   89       private String outputDirectory;
   90   
   91       /**
   92        * @parameter expression="${project.build.directory}/generated-site/xdoc"
   93        * @required
   94        */
   95       private File generatedDocsDirectory;
   96   
   97       /**
   98        * @parameter expression="${project.build.directory}/generated-site/resources"
   99        * @required
  100        */
  101       private File generatedResourcesDirectory;
  102   
  103       /**
  104        * Working directory for temporary files.
  105        *
  106        * @parameter default-value="target"
  107        * @required
  108        */
  109       private String workDirectory;
  110   
  111       /**
  112        * Relative path from the generated report to the API documentation (Javadoc). Defaults to "apidocs" but will often
  113        * be changed to "../apidocs" when documentation is created at the project level.
  114        *
  115        * @parameter default-value="apidocs"
  116        * @required
  117        */
  118       private String apidocs;
  119   
  120       @Override
  121       protected String getOutputDirectory()
  122       {
  123           return outputDirectory;
  124       }
  125   
  126       @Override
  127       protected MavenProject getProject()
  128       {
  129           return project;
  130       }
  131   
  132       @Override
  133       protected SiteRenderer getSiteRenderer()
  134       {
  135           return siteRenderer;
  136       }
  137   
  138       public String getDescription(Locale locale)
  139       {
  140           return "Tapestry component parameter reference documentation";
  141       }
  142   
  143       public String getName(Locale locale)
  144       {
  145           return "Component Reference";
  146       }
  147   
  148   
  149       public String getOutputName()
  150       {
  151           return REFERENCE_DIR + "/index";
  152       }
  153   
  154   
  155       private final static Set<String> SUPPORTED_SUBPACKAGES = CollectionFactory.newSet("base", "components", "mixins",
  156                                                                                         "pages");
  157   
  158       /**
  159        * Generates the report; this consist of the index page
  160        *
  161        * @param locale
  162        * @throws MavenReportException
  163        */
  164       @Override
  165       protected void executeReport(Locale locale) throws MavenReportException
  166       {
  167           Map<String, ClassDescription> descriptions = runJavadoc();
  168   
  169           getLog().info("Generating reference pages ...");
  170   
  171           try
  172           {
  173               File refDir = new File(generatedDocsDirectory, REFERENCE_DIR);
  174   
  175               refDir.mkdirs();
  176   
  177   
  178               List<File> docSearchPath = createDocSearchPath();
  179   
  180               Sink sink = getSink();
  181   
  182               sink.head();
  183               sink.title();
  184               sink.text("Component Reference");
  185               sink.title_();
  186               sink.head_();
  187   
  188               sink.section1();
  189               sink.sectionTitle1();
  190               sink.text("Component Reference");
  191               sink.sectionTitle1_();
  192               sink.list();
  193   
  194               String currentSubpackage = null;
  195   
  196               for (String className : InternalUtils.sortedKeys(descriptions))
  197               {
  198                   String subpackage = extractSubpackage(className);
  199   
  200                   if (!SUPPORTED_SUBPACKAGES.contains(subpackage)) continue;
  201   
  202                   if (!subpackage.equals(currentSubpackage))
  203                   {
  204                       if (currentSubpackage != null)
  205                       {
  206                           sink.list_();
  207                           sink.section2_();
  208                       }
  209   
  210                       sink.section2();
  211                       sink.sectionTitle2();
  212                       sink.text(StringUtils.capitalize(subpackage));
  213                       sink.sectionTitle2_();
  214   
  215   
  216                       sink.list();
  217   
  218                       currentSubpackage = subpackage;
  219                   }
  220   
  221   
  222                   sink.listItem();
  223   
  224                   sink.link(toPath(className) + ".html");
  225   
  226                   sink.text(className);
  227                   sink.link_();
  228   
  229                   writeClassDescription(descriptions, refDir, docSearchPath, className);
  230   
  231   
  232                   sink.listItem_();
  233               }
  234   
  235               if (currentSubpackage != null)
  236               {
  237                   sink.list_();
  238                   sink.section2_();
  239               }
  240           }
  241           catch (Exception ex)
  242           {
  243               throw new MavenReportException(ex.getMessage(), ex);
  244           }
  245       }
  246   
  247       private String toPath(String className)
  248       {
  249           return className.replace('.', '/');
  250       }
  251   
  252       private String extractSubpackage(String className)
  253       {
  254           int dotx = className.indexOf(".", rootPackage.length() + 1);
  255   
  256           // For classes directly in the root package.
  257   
  258           if (dotx < 1) return "";
  259   
  260           return className.substring(rootPackage.length() + 1, dotx);
  261       }
  262   
  263       private List<File> createDocSearchPath()
  264       {
  265           List<File> result = CollectionFactory.newList();
  266   
  267           for (String sourceRoot : (List<String>) project.getCompileSourceRoots())
  268           {
  269               result.add(new File(sourceRoot));
  270           }
  271   
  272   
  273           for (Resource r : (List<Resource>) project.getResources())
  274           {
  275               String dir = r.getDirectory();
  276   
  277               result.add(new File(dir));
  278           }
  279   
  280           return result;
  281       }
  282   
  283       private void writeClassDescription(Map<String, ClassDescription> descriptions, File refDir,
  284                                          List<File> docSearchPath, String className) throws Exception
  285       {
  286   
  287           int dotx = className.lastIndexOf('.');
  288           String packageName = className.substring(0, dotx);
  289           File outputDir = new File(refDir, toPath(packageName));
  290           outputDir.mkdirs();
  291   
  292           File outputFile = new File(refDir, toPath(className) + ".xml");
  293   
  294   
  295           Element root = new Element("document");
  296   
  297           ClassDescription cd = descriptions.get(className);
  298   
  299           Map<String, ParameterDescription> parameters = newMap(cd.getParameters());
  300           List<String> parents = newList();
  301   
  302           String current = cd.getSuperClassName();
  303   
  304           while (true)
  305           {
  306               ClassDescription superDescription = descriptions.get(current);
  307   
  308               if (superDescription == null) break;
  309   
  310               parents.add(current);
  311               parameters.putAll(superDescription.getParameters());
  312   
  313               current = superDescription.getSuperClassName();
  314           }
  315   
  316           Collections.reverse(parents);
  317   
  318           // XOM is pretty verbose; it really needs a builder/fluent interface.
  319   
  320           Element properties = addChild(root, "properties");
  321           addChild(properties, "title", String.format("Component Reference: %s", className));
  322   
  323           Element body = new Element("body");
  324           root.appendChild(body);
  325   
  326           Element section = addSection(body, className);
  327   
  328           addChild(section, "p", cd.getDescription());
  329   
  330   
  331           StringBuilder javadocURL = new StringBuilder(200);
  332   
  333           int depth = packageName.split("\\.").length;
  334   
  335   
  336           for (int i = 0; i < depth; i++)
  337           {
  338               javadocURL.append("../");
  339           }
  340   
  341           String pathToRefRoot = javadocURL.toString();
  342   
  343           javadocURL.append("../").append(apidocs).append("/").append(toPath(className)).append(".html");
  344   
  345           addLink(addChild(section, "p"), javadocURL.toString(), "[JavaDoc]");
  346   
  347           if (!parents.isEmpty())
  348           {
  349               section = addSection(body, "Component Inheritance");
  350               Element container = section;
  351   
  352               for (String name : parents)
  353               {
  354   
  355                   Element ul = addChild(container, "ul");
  356   
  357                   Element li = addChild(ul, "li");
  358   
  359                   addLink(li, name + ".html", name);
  360   
  361                   container = li;
  362               }
  363   
  364               addChild(addChild(container, "ul"), "li", className);
  365           }
  366   
  367   
  368           if (!parameters.isEmpty())
  369           {
  370               section = addSection(body, "Component Parameters");
  371   
  372               Element table = new Element("table");
  373   
  374               section.appendChild(table);
  375   
  376               Element headerRow = new Element("tr");
  377               table.appendChild(headerRow);
  378   
  379               for (String header : PARAMETER_HEADERS)
  380                   addChild(headerRow, "th", header);
  381   
  382               List<String> flags = newList();
  383   
  384               for (String name : InternalUtils.sortedKeys(parameters))
  385               {
  386                   ParameterDescription pd = parameters.get(name);
  387   
  388                   flags.clear();
  389   
  390                   if (pd.getRequired()) flags.add("Required");
  391   
  392                   if (!pd.getCache()) flags.add("NOT Cached");
  393   
  394                   if (!pd.getAllowNull()) flags.add("NOT Allow Null");
  395   
  396                   Element row = new Element("tr");
  397                   table.appendChild(row);
  398   
  399                   addChild(row, "td", pd.getName());
  400                   addChild(row, "td", pd.getType());
  401                   addChild(row, "td", InternalUtils.join(flags));
  402                   addChild(row, "td", pd.getDefaultValue());
  403                   addChild(row, "td", pd.getDefaultPrefix());
  404                   addChild(row, "td", pd.getDescription());
  405               }
  406           }
  407   
  408           if (cd.isSupportsInformalParameters())
  409               addChild(section, "p", "Informal parameters: supported");
  410   
  411           addExternalDocumentation(body, docSearchPath, className);
  412   
  413           addChild(body, "hr");
  414   
  415           addLink(addChild(body, "p"), pathToRefRoot + "index.html", "Back to index");
  416   
  417           Document document = new Document(root);
  418   
  419   
  420           getLog().info(String.format("Writing %s", outputFile));
  421   
  422           FileOutputStream fos = new FileOutputStream(outputFile);
  423   
  424           BufferedOutputStream bos = new BufferedOutputStream(fos);
  425   
  426           PrintWriter writer = new PrintWriter(bos);
  427   
  428           writer.print(document.toXML());
  429   
  430           writer.close();
  431       }
  432   
  433       private void addExternalDocumentation(Element body, List<File> docSearchPath, String className)
  434               throws ParsingException, IOException
  435       {
  436           String classNamePath = toPath(className);
  437   
  438           String pathExtension = classNamePath + ".xdoc";
  439   
  440           for (File path : docSearchPath)
  441           {
  442               File file = new File(path, pathExtension);
  443   
  444               getLog().debug(String.format("Checking for %s", file));
  445   
  446               if (!file.exists()) continue;
  447   
  448               getLog().info(String.format("Reading extra documentation from %s", file));
  449   
  450               Builder builder = new Builder();
  451   
  452               Document doc = builder.build(file);
  453   
  454               // Transfer the nodes inside document/body into our body
  455   
  456               Element incomingBody = doc.getRootElement().getFirstChildElement("body");
  457   
  458               for (int i = 0; i < incomingBody.getChildCount(); i++)
  459               {
  460                   Node incoming = incomingBody.getChild(i).copy();
  461   
  462                   body.appendChild(incoming);
  463               }
  464   
  465               Nodes nodes = doc.query("//img/@src");
  466   
  467               int lastslashx = classNamePath.lastIndexOf('/');
  468               String packagePath = classNamePath.substring(0, lastslashx);
  469   
  470               File generatedRefRoot = new File(generatedResourcesDirectory, REFERENCE_DIR);
  471               File generatedPackageRoot = new File(generatedRefRoot, packagePath);
  472   
  473               for (int i = 0; i < nodes.size(); i++)
  474               {
  475                   Node src = nodes.get(i);
  476   
  477                   String srcPath = src.getValue();
  478   
  479                   File imgFile = new File(path, packagePath + "/" + srcPath);
  480                   File imgTargetFile = new File(generatedPackageRoot, srcPath);
  481   
  482                   copy(imgFile, imgTargetFile);
  483               }
  484   
  485   
  486               return;
  487           }
  488       }
  489   
  490       private void copy(File sourceFile, File targetFile) throws IOException
  491       {
  492           getLog().info(String.format("Copying image file %s to %s", sourceFile, targetFile));
  493   
  494           targetFile.getParentFile().mkdirs();
  495   
  496           byte[] buffer = new byte[20000];
  497   
  498           InputStream in = new BufferedInputStream(new FileInputStream(sourceFile));
  499           OutputStream out = new BufferedOutputStream(new FileOutputStream(targetFile));
  500   
  501           while (true)
  502           {
  503               int length = in.read(buffer);
  504   
  505               if (length < 0) break;
  506   
  507               out.write(buffer, 0, length);
  508           }
  509   
  510           in.close();
  511           out.close();
  512       }
  513   
  514   
  515       private Map<String, ClassDescription> runJavadoc() throws MavenReportException
  516       {
  517           getLog().info("Running JavaDoc to collect component parameter data ...");
  518   
  519           Commandline command = new Commandline();
  520   
  521           try
  522           {
  523               command.setExecutable(pathToJavadoc());
  524           }
  525           catch (IOException ex)
  526           {
  527               throw new MavenReportException("Unable to locate javadoc command: " + ex.getMessage(), ex);
  528           }
  529   
  530           String parametersPath = workDirectory + File.separator + "component-parameters.xml";
  531   
  532           String[] arguments = {"-private", "-o", parametersPath,
  533   
  534                   "-subpackages", rootPackage,
  535   
  536                   "-doclet", ParametersDoclet.class.getName(),
  537   
  538                   "-docletpath", docletPath(),
  539   
  540                   "-sourcepath", sourcePath(),
  541   
  542                   "-classpath", classPath()};
  543   
  544           String argumentsFile = writeArgumentsFile(arguments);
  545   
  546           command.addArguments(new String[] {"@" + argumentsFile});
  547   
  548           executeCommand(command);
  549   
  550           return readXML(parametersPath);
  551       }
  552   
  553       private String writeArgumentsFile(String[] arguments) throws MavenReportException
  554       {
  555           String fileName = workDirectory + "/component-report-javadoc-arguments.txt";
  556   
  557           try
  558           {
  559               PrintWriter pw = new PrintWriter(fileName);
  560   
  561               for (String arg : arguments)
  562               {
  563                   pw.println(arg);
  564               }
  565   
  566               pw.close();
  567           }
  568           catch (IOException ex)
  569           {
  570               throw new MavenReportException(ex.getMessage());
  571           }
  572   
  573           return fileName;
  574       }
  575   
  576       @SuppressWarnings("unchecked")
  577       private String sourcePath()
  578       {
  579           List<String> roots = project.getCompileSourceRoots();
  580   
  581           return toArgumentPath(roots);
  582       }
  583   
  584       /**
  585        * Needed to help locate this plugin's local JAR file for the -doclet argument.
  586        *
  587        * @parameter default-value="${localRepository}"
  588        * @read-only
  589        */
  590       private ArtifactRepository localRepository;
  591   
  592       /**
  593        * Needed to help locate this plugin's local JAR file for the -doclet argument.
  594        *
  595        * @parameter default-value="${plugin.groupId}"
  596        * @read-only
  597        */
  598       private String pluginGroupId;
  599   
  600       /**
  601        * Needed to help locate this plugin's local JAR file for the -doclet argument.
  602        *
  603        * @parameter default-value="${plugin.artifactId}"
  604        * @read-only
  605        */
  606       private String pluginArtifactId;
  607   
  608       /**
  609        * Needed to help locate this plugin's local JAR file for the -doclet argument.
  610        *
  611        * @parameter default-value="${plugin.version}"
  612        * @read-only
  613        */
  614       private String pluginVersion;
  615   
  616       @SuppressWarnings("unchecked")
  617       private String docletPath() throws MavenReportException
  618       {
  619           File file = new File(localRepository.getBasedir());
  620   
  621           for (String term : pluginGroupId.split("\\."))
  622               file = new File(file, term);
  623   
  624           file = new File(file, pluginArtifactId);
  625           file = new File(file, pluginVersion);
  626   
  627           file = new File(file, String.format("%s-%s.jar", pluginArtifactId, pluginVersion));
  628   
  629           return file.getAbsolutePath();
  630       }
  631   
  632       @SuppressWarnings("unchecked")
  633       private String classPath() throws MavenReportException
  634       {
  635           List<Artifact> artifacts = project.getCompileArtifacts();
  636   
  637           return artifactsToArgumentPath(artifacts);
  638       }
  639   
  640       private String artifactsToArgumentPath(List<Artifact> artifacts) throws MavenReportException
  641       {
  642           List<String> paths = newList();
  643   
  644           for (Artifact artifact : artifacts)
  645           {
  646               if (artifact.getScope().equals("test")) continue;
  647   
  648               File file = artifact.getFile();
  649   
  650               if (file == null) throw new MavenReportException(
  651                       "Unable to execute Javadoc: compile dependencies are not fully resolved.");
  652   
  653               paths.add(file.getAbsolutePath());
  654           }
  655   
  656           return toArgumentPath(paths);
  657       }
  658   
  659       private void executeCommand(Commandline command) throws MavenReportException
  660       {
  661           getLog().debug(command.toString());
  662   
  663           CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
  664   
  665           try
  666           {
  667               int exitCode = CommandLineUtils.executeCommandLine(command, new DefaultConsumer(), err);
  668   
  669               if (exitCode != 0)
  670               {
  671                   String message = String.format("Javadoc exit code: %d - %s\nCommand line was: %s", exitCode,
  672                                                  err.getOutput(), command);
  673   
  674                   throw new MavenReportException(message);
  675               }
  676           }
  677           catch (CommandLineException ex)
  678           {
  679               throw new MavenReportException("Unable to execute javadoc command: " + ex.getMessage(), ex);
  680           }
  681   
  682           // ----------------------------------------------------------------------
  683           // Handle Javadoc warnings
  684           // ----------------------------------------------------------------------
  685   
  686           if (StringUtils.isNotEmpty(err.getOutput()))
  687           {
  688               getLog().info("Javadoc Warnings");
  689   
  690               StringTokenizer token = new StringTokenizer(err.getOutput(), "\n");
  691               while (token.hasMoreTokens())
  692               {
  693                   String current = token.nextToken().trim();
  694   
  695                   getLog().warn(current);
  696               }
  697           }
  698       }
  699   
  700       private String pathToJavadoc() throws IOException, MavenReportException
  701       {
  702           String executableName = SystemUtils.IS_OS_WINDOWS ? "javadoc.exe" : "javadoc";
  703   
  704           File executable = initialGuessAtJavadocFile(executableName);
  705   
  706           if (!executable.exists() || !executable.isFile())
  707               throw new MavenReportException(String.format("Path %s does not exist or is not a file.", executable));
  708   
  709           return executable.getAbsolutePath();
  710       }
  711   
  712       private File initialGuessAtJavadocFile(String executableName)
  713       {
  714           if (SystemUtils.IS_OS_MAC_OSX)
  715               return new File(SystemUtils.getJavaHome() + File.separator + "bin", executableName);
  716   
  717           return new File(SystemUtils.getJavaHome() + File.separator + ".." + File.separator + "bin", executableName);
  718       }
  719   
  720       private String toArgumentPath(List<String> paths)
  721       {
  722           StringBuilder builder = new StringBuilder();
  723   
  724           String sep = "";
  725   
  726           for (String path : paths)
  727           {
  728               builder.append(sep);
  729               builder.append(path);
  730   
  731               sep = SystemUtils.PATH_SEPARATOR;
  732           }
  733   
  734           return builder.toString();
  735       }
  736   
  737       public Map<String, ClassDescription> readXML(String path) throws MavenReportException
  738       {
  739           try
  740           {
  741               Builder builder = new Builder(false);
  742   
  743               File input = new File(path);
  744   
  745               Document doc = builder.build(input);
  746   
  747               return buildMapFromDocument(doc);
  748           }
  749           catch (Exception ex)
  750           {
  751               throw new MavenReportException(String.format("Failure reading from %s: %s", path, ex
  752                       .getMessage()), ex);
  753           }
  754       }
  755   
  756       private Map<String, ClassDescription> buildMapFromDocument(Document doc)
  757       {
  758           Map<String, ClassDescription> result = newMap();
  759   
  760           Elements elements = doc.getRootElement().getChildElements("class");
  761   
  762           for (int i = 0; i < elements.size(); i++)
  763           {
  764               Element element = elements.get(i);
  765   
  766               String description = element.getFirstChildElement("description").getValue();
  767   
  768               String className = element.getAttributeValue("name");
  769               String superClassName = element.getAttributeValue("super-class");
  770               String supportsInformalParameters = element.getAttributeValue("supports-informal-parameters");
  771   
  772               ClassDescription cd = new ClassDescription(className, superClassName, description,
  773                                                          Boolean.valueOf(supportsInformalParameters));
  774   
  775               result.put(className, cd);
  776   
  777               readParameters(cd, element);
  778           }
  779   
  780           return result;
  781       }
  782   
  783       private void readParameters(ClassDescription cd, Element classElement)
  784       {
  785           Elements elements = classElement.getChildElements("parameter");
  786   
  787           for (int i = 0; i < elements.size(); i++)
  788           {
  789               Element node = elements.get(i);
  790   
  791               String name = node.getAttributeValue("name");
  792               String type = node.getAttributeValue("type");
  793   
  794               int dotx = type.lastIndexOf('.');
  795               if (dotx > 0 && type.substring(0, dotx).equals("java.lang")) type = type.substring(dotx + 1);
  796   
  797               String defaultValue = node.getAttributeValue("default");
  798               boolean required = Boolean.parseBoolean(node.getAttributeValue("required"));
  799               boolean cache = Boolean.parseBoolean(node.getAttributeValue("cache"));
  800               boolean allowNull = Boolean.parseBoolean(node.getAttributeValue("allowNull"));
  801               String defaultPrefix = node.getAttributeValue("default-prefix");
  802               String description = node.getValue();
  803   
  804               ParameterDescription pd = new ParameterDescription(name, type, defaultValue, defaultPrefix, required,
  805                                                                  allowNull, cache, description);
  806   
  807               cd.getParameters().put(name, pd);
  808           }
  809       }
  810   
  811       private Element addSection(Element container, String name)
  812       {
  813           Element section = new Element("section");
  814           container.appendChild(section);
  815   
  816           section.addAttribute(new Attribute("name", name));
  817   
  818           return section;
  819       }
  820   
  821       private Element addLink(Element container, String URL, String text)
  822       {
  823           Element link = addChild(container, "a", text);
  824   
  825           link.addAttribute(new Attribute("href", URL));
  826   
  827           return link;
  828       }
  829   
  830       private Element addChild(Element container, String elementName)
  831       {
  832           Element child = new Element(elementName);
  833           container.appendChild(child);
  834   
  835           return child;
  836       }
  837   
  838       private Element addChild(Element container, String elementName, String text)
  839       {
  840           Element child = new Element(elementName);
  841           container.appendChild(child);
  842   
  843           child.appendChild(text);
  844   
  845           return child;
  846       }
  847   }

Save This Page
Home » tapestry-src-5.0.19 » org.apache.tapestry.mojo » [javadoc | source]