Update of /cvsroot/xdoclet/xdoclet2/src/main/java/org/xdoclet
In directory sc8-pr-cvs1:/tmp/cvs-serv10249/src/main/java/org/xdoclet
Modified Files:
ConfigurableDocletTagFactory.java QDoxMetadataProvider.java
Log Message:
Making it easier to test
Index: ConfigurableDocletTagFactory.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet2/src/main/java/org/xdoclet/ConfigurableDocletTagFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ConfigurableDocletTagFactory.java 20 Sep 2003 12:25:48 -0000 1.2
--- ConfigurableDocletTagFactory.java 2 Oct 2003 10:28:47 -0000 1.3
***************
*** 4,7 ****
--- 4,8 ----
import com.thoughtworks.qdox.model.DocletTag;
import com.thoughtworks.qdox.model.DefaultDocletTag;
+ import com.thoughtworks.qdox.model.JavaSource;
import java.util.*;
***************
*** 43,46 ****
--- 44,51 ----
public DocletTag createDocletTag(String tag, String text) {
+ throw new UnsupportedOperationException();
+ }
+
+ public DocletTag createDocletTag(String tag, String text, int lineNumber,
JavaSource javaSource) {
Class tagClass = (Class) registeredTags.get(tag);
***************
*** 51,56 ****
}
try {
! Constructor newTag = tagClass.getConstructor(new Class[] {String.class,
String.class});
! DocletTag result = (DocletTag) newTag.newInstance(new Object[]{tag,
text});
if (!isKnown) {
--- 56,61 ----
}
try {
! Constructor newTag = tagClass.getConstructor(new Class[] {String.class,
String.class, Integer.TYPE, JavaSource.class});
! DocletTag result = (DocletTag) newTag.newInstance(new Object[]{tag,
text, new Integer(lineNumber), javaSource});
if (!isKnown) {
***************
*** 59,73 ****
return result;
} catch (ClassCastException e) {
! throw new RuntimeException();
} catch (NoSuchMethodException e) {
throw new RuntimeException("No (String, String) constructor in " +
tagClass.getName());
} catch (SecurityException e) {
! throw new RuntimeException();
} catch (InstantiationException e) {
! throw new RuntimeException();
} catch (IllegalAccessException e) {
! throw new RuntimeException();
} catch (IllegalArgumentException e) {
! throw new RuntimeException();
} catch (InvocationTargetException e) {
throw new RuntimeException(e.getTargetException());
--- 64,78 ----
return result;
} catch (ClassCastException e) {
! throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException("No (String, String) constructor in " +
tagClass.getName());
} catch (SecurityException e) {
! throw new RuntimeException(e);
} catch (InstantiationException e) {
! throw new RuntimeException(e);
} catch (IllegalAccessException e) {
! throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
! throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e.getTargetException());
***************
*** 76,80 ****
public void registerTag(String tagName, Class tagClass) {
- System.out.println("Registering tag " + tagName);
registeredTags.put(tagName, tagClass != null ? tagClass :
DefaultDocletTag.class);
}
--- 81,84 ----
Index: QDoxMetadataProvider.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet2/src/main/java/org/xdoclet/QDoxMetadataProvider.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** QDoxMetadataProvider.java 28 Sep 2003 19:13:24 -0000 1.6
--- QDoxMetadataProvider.java 2 Oct 2003 10:28:47 -0000 1.7
***************
*** 19,38 ****
public class QDoxMetadataProvider implements MetadataProvider {
private final ConfigurableDocletTagFactory docletTagFactory = new
ConfigurableDocletTagFactory();
- private final JavaSourceProvider fileProvider;
public QDoxMetadataProvider(JavaSourceProvider fileProvider) {
this.fileProvider = fileProvider;
}
! public QDoxMetadataProvider(final Reader reader) {
this(new JavaSourceProvider() {
public Collection getFiles() throws IOException {
! return Collections.singleton(reader);
}
});
}
! public QDoxMetadataProvider(final File reader) throws IOException {
! this(new FileReader(reader));
}
--- 19,50 ----
public class QDoxMetadataProvider implements MetadataProvider {
private final ConfigurableDocletTagFactory docletTagFactory = new
ConfigurableDocletTagFactory();
+ private JavaSourceProvider fileProvider;
+ private File singleSourceOrDirectory;
+
+ /**
+ * Main constructor. Gives fine control over what sources to parse.
+ */
public QDoxMetadataProvider(JavaSourceProvider fileProvider) {
this.fileProvider = fileProvider;
}
! /**
! * Convenience constructor for testing.
! */
! public QDoxMetadataProvider(final Reader singleSource) {
this(new JavaSourceProvider() {
public Collection getFiles() throws IOException {
! return Collections.singleton(singleSource);
}
});
}
! /**
! * Convenience constructor for testing. If singleSourceOrDirectory
! * is a directory, all sources in it will be parsed.
! */
! public QDoxMetadataProvider(final File singleSourceOrDirectory) {
! this.singleSourceOrDirectory = singleSourceOrDirectory;
}
***************
*** 46,49 ****
--- 58,74 ----
public Collection getMetadata() throws IOException {
JavaDocBuilder builder = new JavaDocBuilder(docletTagFactory);
+ if(fileProvider != null) {
+ addSourcesFromJavaSourceProvider(builder);
+ } else {
+ if(singleSourceOrDirectory.isDirectory()) {
+ builder.addSourceTree(singleSourceOrDirectory);
+ } else {
+ builder.addSource(singleSourceOrDirectory);
+ }
+ }
+ return Arrays.asList(builder.getClasses());
+ }
+
+ private void addSourcesFromJavaSourceProvider(JavaDocBuilder builder) throws
IOException {
Collection files = fileProvider.getFiles();
for (Iterator iterator = files.iterator(); iterator.hasNext();) {
***************
*** 57,61 ****
}
}
- return Arrays.asList(builder.getClasses());
}
--- 82,85 ----
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel