View Javadoc
1   package org.codehaus.modello.plugin.java.javasource;
2   
3   import java.util.ArrayList;
4   import java.util.Iterator;
5   import java.util.List;
6   
7   public class JAnnotations {
8       private List<String> annotations;
9   
10      public JAnnotations() {
11          this.annotations = new ArrayList<String>();
12      }
13  
14      public void appendAnnotation(String annotation) {
15          annotations.add(annotation);
16      }
17  
18      /**
19       * Returns the String representation of this JAnnotations
20       * @return the String representation of this JAnnotations
21       **/
22      public String toString() {
23          StringBuilder sb = new StringBuilder();
24          for (Iterator<String> iterator = annotations.iterator(); iterator.hasNext(); ) {
25              sb.append(iterator.next());
26              if (iterator.hasNext()) {
27                  sb.append(' ');
28              }
29          }
30          return sb.toString();
31      } // -- toString
32  
33      /**
34       * prints this Annotations using the given JSourceWriter
35       *
36       * @param jsw the JSourceWriter to print to
37       */
38      public void print(JSourceWriter jsw) {
39          for (String annotation : annotations) {
40              jsw.writeln(annotation.toString());
41          }
42      } // -- print
43  }