View Javadoc

1   package no.sesat.mojo.modes;
2   
3   import com.sun.javadoc.MethodDoc;
4   
5   /**
6    * Data representing an attribute.
7    *
8    */
9   public class ConfigAttribute extends ConfigAbstract {
10  
11      protected String type = "CDATA";
12      protected boolean required = false;
13  
14      /**
15       * @param method Construct this attribute from a Javadoc element.
16       */
17      public ConfigAttribute(final MethodDoc method) {
18          doc = parseDoc(method);
19  
20          name = Builder.toXmlName(method.name()).substring(4);
21          type = "CDATA"; // method.parameters()[0].toString();
22      }
23  
24      /**
25       * @param name
26       *            Name of this attribute.
27       */
28      protected ConfigAttribute(final String name) {
29          this.name = name;
30      }
31  
32      /**
33       * @param name
34       *            Name of this attribute.
35       * @param doc
36       *            Doc for this attribute.
37       */
38      protected ConfigAttribute(final String name, final String doc) {
39          this.name = name;
40          this.doc = doc;
41      }
42  
43      /**
44       * @param name
45       *            Name of this attribute.
46       * @param doc
47       *            Doc for this attribute.
48       * @param required
49       *            if this is required attribute or not
50       */
51      protected ConfigAttribute(final String name, final String doc, final boolean required) {
52          this.name = name;
53          this.doc = doc;
54          this.required = required;
55      }
56  
57      private String parseDoc(final MethodDoc method) {
58          if (method == null) {
59              return null;
60          }
61          if (method.commentText().contains("{@inheritDoc}")) {
62              return parseDoc(method.overriddenMethod());
63          } else {
64              return method.commentText();
65          }
66      }
67  }