|
|||||||||||||||||||
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 | |||||||||||||||
XJavadocFilter.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 java.io.File;
|
|
8 |
import java.util.Iterator;
|
|
9 |
|
|
10 |
import org.apache.tools.ant.BuildException;
|
|
11 |
import org.apache.tools.ant.types.Parameter;
|
|
12 |
import org.apache.tools.ant.types.selectors.BaseExtendSelector;
|
|
13 |
|
|
14 |
import xjavadoc.XClass;
|
|
15 |
import xjavadoc.XJavaDoc;
|
|
16 |
import xjavadoc.filesystem.FileSourceSet;
|
|
17 |
|
|
18 |
/**
|
|
19 |
* Custom file filter for Ant based on XJavadoc. Filters java sources according
|
|
20 |
* to some Java specific features. <br/>
|
|
21 |
* Usage:<br/>
|
|
22 |
* <pre>
|
|
23 |
*<copy todir="filtered-src">
|
|
24 |
* <fileset dir="src">
|
|
25 |
* <or>
|
|
26 |
* <custom classname="xjavadoc.XJavadocFilter" classpathref="lib.jars">
|
|
27 |
* <parameter name="implements" value="javax.ejb.EntityBean" />
|
|
28 |
* </custom>
|
|
29 |
* <custom classname="xjavadoc.XJavadocFilter" classpathref="lib.jars">
|
|
30 |
* <parameter name="implements" value="javax.ejb.SessionBean" />
|
|
31 |
* </custom>
|
|
32 |
* </or>
|
|
33 |
* </fileset>
|
|
34 |
*</copy>
|
|
35 |
*</pre> Valid parameters are:<br/>
|
|
36 |
*
|
|
37 |
* <dl>
|
|
38 |
* <dt> <strong>implements</strong> </dt>
|
|
39 |
* <dd> full qualified name of the class or interface to implement</dd>
|
|
40 |
* <dt> <strong>contains-tag</strong> </dt>
|
|
41 |
* <dd> javadoc tag to contain</dd>
|
|
42 |
* </dl>
|
|
43 |
*
|
|
44 |
*
|
|
45 |
* @author Ludovic Claude
|
|
46 |
* @created 02 November 2002
|
|
47 |
* @version $Revision: 1.6 $
|
|
48 |
*/
|
|
49 |
public class XJavadocFilter extends BaseExtendSelector |
|
50 |
{ |
|
51 |
XJavaDoc _xJavaDoc = new XJavaDoc();
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Constructor for XJavadocFilter.
|
|
55 |
*/
|
|
56 | 0 |
public XJavadocFilter()
|
57 |
{ |
|
58 | 0 |
super();
|
59 |
} |
|
60 |
|
|
61 |
/**
|
|
62 |
* @param basedir
|
|
63 |
* @param filename
|
|
64 |
* @param file
|
|
65 |
* @return
|
|
66 |
* @exception BuildException
|
|
67 |
* @see org.apache.tools.ant.types.selectors.FileSelector#isSelected(File,
|
|
68 |
* String, File)
|
|
69 |
*/
|
|
70 | 0 |
public boolean isSelected( File basedir, String filename, File file ) |
71 |
throws BuildException
|
|
72 |
{ |
|
73 |
|
|
74 | 0 |
if( !filename.endsWith( ".java" ) ) |
75 | 0 |
return false; |
76 |
|
|
77 | 0 |
_xJavaDoc.reset( true );
|
78 | 0 |
try
|
79 |
{ |
|
80 |
//validateOptions();
|
|
81 |
|
|
82 | 0 |
_xJavaDoc.addSourceSet( new FileSourceSet( basedir, new String[]{filename} ) ); |
83 |
|
|
84 | 0 |
for( Iterator i = _xJavaDoc.getSourceClasses().iterator() ; i.hasNext(); )
|
85 |
{ |
|
86 | 0 |
XClass clazz = (XClass) i.next(); |
87 | 0 |
Parameter[] params = getParameters(); |
88 |
|
|
89 | 0 |
for( int j = 0; j < params.length; j++ ) |
90 |
{ |
|
91 | 0 |
Parameter param = params[j]; |
92 |
|
|
93 | 0 |
if( param.getName().equals( "implements" ) ) |
94 |
{ |
|
95 | 0 |
String mandatoryClass = param.getValue(); |
96 |
|
|
97 | 0 |
if( !clazz.isA( mandatoryClass ) )
|
98 | 0 |
return false; |
99 |
} |
|
100 | 0 |
else if( param.getName().equals( "contains-tag" ) ) |
101 |
{ |
|
102 | 0 |
String mandatoryTag = param.getValue(); |
103 |
|
|
104 | 0 |
if( !clazz.getDoc().hasTag( mandatoryTag ) )
|
105 | 0 |
return false; |
106 |
} |
|
107 |
} |
|
108 |
} |
|
109 |
} |
|
110 |
catch( OutOfMemoryError e )
|
|
111 |
{ |
|
112 | 0 |
System.err.println( e.getMessage() ); |
113 | 0 |
XJavaDoc.printMemoryStatus(); |
114 | 0 |
System.err.println( "Try to increase heap size. Can be done by defining ANT_OPTS=-Xmx640m" );
|
115 | 0 |
System.err.println( "See the JDK tooldocs." );
|
116 | 0 |
throw new BuildException( e.getMessage(), e ); |
117 |
} |
|
118 |
catch( Throwable t )
|
|
119 |
{ |
|
120 | 0 |
t.printStackTrace(); |
121 | 0 |
throw new BuildException( "Unexpected error", t ); |
122 |
} |
|
123 |
finally
|
|
124 |
{ |
|
125 |
//XJavaDoc.printMemoryStatus();
|
|
126 |
|
|
127 | 0 |
_xJavaDoc.printLogMessages( System.out, XJavaDoc.NO_IMPORTED_PACKAGES ); |
128 | 0 |
_xJavaDoc.printLogMessages( System.out, XJavaDoc.ONE_OR_MORE_IMPORTED_PACKAGES ); |
129 | 0 |
_xJavaDoc.reset( true );
|
130 | 0 |
System.gc(); |
131 |
} |
|
132 | 0 |
return true; |
133 |
} |
|
134 |
|
|
135 |
} |
|
136 |
|
|