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   {
9       private List<String> annotations;
10  
11      public JAnnotations()
12      {
13          this.annotations = new ArrayList<String>();
14      }
15  
16      public void appendAnnotation( String annotation )
17      {
18          annotations.add( annotation );
19      }
20  
21      /**
22       * Returns the String representation of this JAnnotations
23       * @return the String representation of this JAnnotations
24       **/
25      public String toString()
26      {
27          StringBuilder sb = new StringBuilder();
28          for ( Iterator<String> iterator = annotations.iterator(); iterator.hasNext(); )
29          {
30              sb.append( iterator.next() );
31              if ( iterator.hasNext() )
32              {
33                  sb.append( ' ' );
34              }
35          }
36          return sb.toString();
37      } //-- toString
38  
39      /**
40       * prints this Annotations using the given JSourceWriter
41       *
42       * @param jsw the JSourceWriter to print to
43       */
44      public void print( JSourceWriter jsw )
45      {
46          for ( String annotation : annotations )
47          {
48              jsw.writeln( annotation.toString() );
49          }
50      } // -- print
51  }