Update of
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-interfaceextractor/src/main/java/org/xdoclet/plugin/interfaceextractor
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28461/plugin-interfaceextractor/src/main/java/org/xdoclet/plugin/interfaceextractor
Added Files:
InterfaceExtractorPlugin.java InterfaceExtractorPlugin.vm
Log Message:
XDP-137 : added simple interface extractor plugin
--- NEW FILE: InterfaceExtractorPlugin.vm ---
#set( $pakkage = $plugin.getDestinationPackage($metadata) )
#if($pakkage != "")
package ${pakkage};
#end
/**
* @author Generated by xdoclet-plugin-interfaceextractor.
*/
public interface ${plugin.getDestinationClassname(null)}
#if (${plugin.extends}) extends ${plugin.extends} #end {
#foreach($method in $plugin.commonMethods)
$method
#end
}
--- NEW FILE: InterfaceExtractorPlugin.java ---
package org.xdoclet.plugin.interfaceextractor;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaMethod;
import org.generama.QDoxCapableMetadataProvider;
import org.generama.VelocityTemplateEngine;
import org.generama.WriterMapper;
import org.generama.defaults.JavaGeneratingPlugin;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
/**
* todo : add possibility to include javadoc or not (for now is javadoc of 1st
class with method)
* todo : from this javadoc, add possibility to include doclet tags or not
*
* @author <a href="mailto:[EMAIL PROTECTED]">Grégory Joseph</a>
* @author $Author: moinsmoins $ (last edit)
* @version $Revision: 1.1 $
*/
public class InterfaceExtractorPlugin extends JavaGeneratingPlugin {
private String ignoreMethodsRegex;
private String extendsInterface;
public InterfaceExtractorPlugin(VelocityTemplateEngine
velocityTemplateEngine, QDoxCapableMetadataProvider metadataProvider,
WriterMapper writerMapper) {
super(velocityTemplateEngine, metadataProvider, writerMapper);
setMultioutput(false);
//setFilereplace("AllTests.java");
}
public void setIgnoremethodsregex(String ignoreMethodsRegex) {
this.ignoreMethodsRegex = ignoreMethodsRegex;
}
public String getExtends() {
return extendsInterface;
}
public void setExtends(String extendsInterface) {
this.extendsInterface = extendsInterface;
}
public Set getCommonMethods() {
Set extractedMethods = new HashSet();
Collection classes = getMetadata();
Iterator it = classes.iterator();
boolean firstIteration = true;
while (it.hasNext()) {
JavaClass clas = (JavaClass) it.next();
JavaMethod[] methods = clas.getMethods();
List validMethods = new LinkedList();
for (int i = 0; i < methods.length; i++) {
JavaMethod method = methods[i];
// strip methods to be ignored
if (ignoreMethodsRegex == null ||
!(method.getName().matches(ignoreMethodsRegex))) {
validMethods.add(method);
}
}
if (firstIteration) {
extractedMethods.addAll(validMethods);
firstIteration = false;
}
extractedMethods.retainAll(validMethods); // todo could use the
signatureMatches() method instead of equals used by retainAll
}
return extractedMethods;
}
}
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
xdoclet-plugins-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-commits