Clover coverage report - XJavaDoc - 1.1 Coverage timestamp: Sun Oct 3 2004 19:56:54 BST FRAMES NO FRAMES |
file stats: | LOC: | 188 |  | Methods: | 11
| NCLOC: | 103 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
XJavadocTask.java | 0% | 0% | 0% | 0% |

1 |  |
     /*
2 |  |
      * Copyright (c) 2001-2003 The XDoclet team
3 |  |
      * All rights reserved.
4 |  |
      */
5 |  |
     package xjavadoc.ant;
6 |  |
7 |  |
     import org.apache.tools.ant.Task;
8 |  |
     import org.apache.tools.ant.BuildException;
9 |  |
     import org.apache.tools.ant.DirectoryScanner;
10 |  |
     import org.apache.tools.ant.AntClassLoader;
11 |  |
     import org.apache.tools.ant.types.Path;
12 |  |
     import org.apache.tools.ant.types.FileSet;
13 |  |
14 |  |
     import java.util.LinkedList;
15 |  |
     import java.io.File;
16 |  |
17 |  |
     import xjavadoc.XJavaDoc;
18 |  |
     import xjavadoc.DefaultXTag;
19 |  |
     import xjavadoc.filesystem.FileSourceSet;
20 |  |
21 |  |
     /**
22 |  |
      * This class should be subclassed to be used for XDocletImpl, revXDoclet etc.
23 |  |
      *
24 |  |
      * @author    Aslak Hellesøy
25 |  |
      * @author    Ara Abrahamian
26 |  |
      * @created   26. februar 2003
27 |  |
      */
28 |  |
     public abstract class XJavadocTask extends Task
29 |  |
     {
30 |  |
         private final XJavaDoc _xJavaDoc = new XJavaDoc();
31 |  |
         private final LinkedList _fileSets = new LinkedList();
32 |  |
33 | 0 |
         protected XJavaDoc getXJavaDoc() {
34 | 0 |
             return _xJavaDoc;
35 |  |
         }
36 |  |
37 |  |
         /**
38 |  |
          * Sets the tags to ignore if validation is true. The value should be a
39 |  |
          * comma-separated list of tag names (without the tag name)
40 |  |
          *
41 |  |
          * @param tags  tags that should be ignored when doing validation.
42 |  |
          */
43 | 0 |
         public void setIgnoredtags( String tags )
44 |  |
         {
45 | 0 |
             _xJavaDoc.getTagFactory().setIgnoredTags( tags );
46 |  |
         }
47 |  |
48 |  |
         /**
49 |  |
          * Sets whether or not tags will be validated.
50 |  |
          *
51 |  |
          * @param flag validate?
52 |  |
          */
53 | 0 |
         public void setValidating( boolean flag )
54 |  |
         {
55 | 0 |
             _xJavaDoc.getTagFactory().setValidating( flag );
56 |  |
         }
57 |  |
58 |  |
         /**
59 |  |
          * set source file charset
60 |  |
              *
61 |  |
          * @param enc the encoding
62 |  |
          */
63 | 0 |
         public void setEncoding(String enc)
64 |  |
         {
65 | 0 |
             _xJavaDoc.setEncoding(enc);
66 |  |
         }
67 |  |
68 |  |
         /**
69 |  |
          * set generated file charset
70 |  |
              *
71 |  |
          * @param enc the encoding
72 |  |
           */
73 | 0 |
         public void setDocencoding(String enc)
74 |  |
         {
75 | 0 |
             _xJavaDoc.setDocEncoding(enc);
76 |  |
         }
77 |  |
78 |  |
         /**
79 |  |
          * Implementation of Ant's {@link Task#execute()}.
80 |  |
          *
81 |  |
          * @exception BuildException  Ant's way of reporting build exception
82 |  |
          */
83 | 0 |
         public final void execute() throws BuildException
84 |  |
         {
85 | 0 |
             _xJavaDoc.reset( true );
86 | 0 |
             _xJavaDoc.setPropertyMap( project.getProperties() );
87 | 0 |
             try
88 |  |
             {
89 | 0 |
                 validateOptions();
90 |  |
91 | 0 |
                 FileSourceSet[] sourceSets = new FileSourceSet[_fileSets.size()];
92 |  |
93 | 0 |
                 for( int i = 0; i < _fileSets.size(); i++ )
94 |  |
                 {
95 | 0 |
                     FileSet fs = ( FileSet ) _fileSets.get( i );
96 | 0 |
                     File dir = fs.getDir( project );
97 |  |
98 | 0 |
                     DirectoryScanner ds = fs.getDirectoryScanner( project );
99 | 0 |
                     String[] files = ds.getIncludedFiles();
100 |  |
101 | 0 |
                     sourceSets[i] = new FileSourceSet( dir, files );
102 | 0 |
                     _xJavaDoc.addSourceSet( sourceSets[i] );
103 |  |
                 }
104 |  |
105 | 0 |
                 start();
106 |  |
             }
107 |  |
             catch( OutOfMemoryError e )
108 |  |
             {
109 | 0 |
                 System.err.println( e.getMessage() );
110 | 0 |
                 XJavaDoc.printMemoryStatus();
111 | 0 |
                 System.err.println( "Try to increase heap size. Can be done by defining ANT_OPTS=-Xmx640m" );
112 | 0 |
                 System.err.println( "See the JDK tooldocs." );
113 | 0 |
                 throw new BuildException( e.getMessage(), e, location );
114 |  |
             }
115 |  |
             catch( Throwable t )
116 |  |
             {
117 | 0 |
                 t.printStackTrace();
118 | 0 |
                 throw new BuildException( "Unexpected error", t, location );
119 |  |
             }
120 |  |
             finally
121 |  |
             {
122 |  |
                 //XJavaDoc.printMemoryStatus();
123 |  |
124 | 0 |
                 _xJavaDoc.printLogMessages( System.out, XJavaDoc.NO_IMPORTED_PACKAGES );
125 | 0 |
                 _xJavaDoc.printLogMessages( System.out, XJavaDoc.ONE_OR_MORE_IMPORTED_PACKAGES );
126 | 0 |
                 _xJavaDoc.reset(true);
127 | 0 |
                 System.gc();
128 |  |
             }
129 |  |
         }
130 |  |
131 |  |
         /**
132 |  |
          * Ignores one tag
133 |  |
          *
134 |  |
          * @return
135 |  |
          */
136 | 0 |
         public Object createIgnoredtag()
137 |  |
         {
138 | 0 |
             return
139 |  |
                 new Object()
140 |  |
                 {
141 | 0 |
                     public void addText( String text )
142 |  |
                     {
143 | 0 |
                         _xJavaDoc.getTagFactory().registerTagClass( text, DefaultXTag.class );
144 |  |
                     }
145 |  |
                 };
146 |  |
         }
147 |  |
148 |  |
         /**
149 |  |
          * Ant's &lt;fileset&gt; definition. To define the files to parse.
150 |  |
          *
151 |  |
          * @param set  a fileset to add
152 |  |
          */
153 | 0 |
         public void addFileset( FileSet set )
154 |  |
         {
155 | 0 |
             _fileSets.add( set );
156 |  |
         }
157 |  |
158 |  |
         /**
159 |  |
          * Returns the classpath
160 |  |
          *
161 |  |
          * @return   the classpath
162 |  |
          */
163 | 0 |
         protected String getClasspath()
164 |  |
         {
165 | 0 |
             return ( ( AntClassLoader ) getClass().getClassLoader() ).getClasspath();
166 |  |
         }
167 |  |
168 |  |
         /**
169 |  |
          * Implement this method and play with _xJavaDoc
170 |  |
          *
171 |  |
          * @exception BuildException  Ant's way of reporting exception
172 |  |
          */
173 |  |
         protected abstract void start() throws BuildException;
174 |  |
175 |  |
         /**
176 |  |
          * Validate a Xdoclet task before running it.
177 |  |
          *
178 |  |
          * @exception BuildException  in case the validation fails.
179 |  |
          */
180 | 0 |
         protected void validateOptions() throws BuildException
181 |  |
         {
182 | 0 |
             if( _fileSets.size() == 0 )
183 |  |
             {
184 | 0 |
                 throw new BuildException( "At least one fileset must be specified", location );
185 |  |
             }
186 |  |
         }
187 |  |
     }
188 |  |