View Javadoc
1   package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.codehaus.mojo.jaxb2.AbstractJaxbMojo;
23  
24  import java.util.Map;
25  
26  /**
27   * <p>Default JavaDocRenderer implementation which provides a plain JavaDocData rendering, on the form:</p>
28   * <pre>
29   *     [JavaDoc comment]
30   *     (tag1): [tag1 value]
31   *     (tag2): [tag2 value]
32   * </pre>
33   *
34   * @author <a href="mailto:lj@jguru.se">Lennart J&ouml;relid</a>, jGuru Europe AB
35   * @since 2.0
36   */
37  public class DefaultJavaDocRenderer implements JavaDocRenderer {
38  
39      /**
40       * {@inheritDoc}
41       */
42      @Override
43      public String render(final JavaDocData nonNullData, final SortableLocation location) {
44  
45          // Compile the XSD documentation string for this Node.
46          final StringBuilder builder = new StringBuilder();
47          builder.append(nonNullData.getComment()).append("\n\n");
48          for (Map.Entry<String, String> current : nonNullData.getTag2ValueMap().entrySet()) {
49  
50              final String tagDocumentation = "(" + current.getKey() + "): " + current.getValue() + "\n";
51              builder.append(tagDocumentation);
52          }
53  
54          // All done.
55          return builder.toString().replace("\n", AbstractJaxbMojo.NEWLINE);
56      }
57  }