Update of /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util
In directory sc8-pr-cvs1:/tmp/cvs-serv5707/src/java/xdoclet/util
Modified Files:
ClasspathManager.java
Log Message:
Added icon support for BeanInfo and added some ugly icons for jelly and velocity.
Index: ClasspathManager.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/ClasspathManager.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** ClasspathManager.java 8 Mar 2003 14:21:10 -0000 1.5
--- ClasspathManager.java 16 Mar 2003 20:38:54 -0000 1.6
***************
*** 17,22 ****
import java.util.*;
- import java.util.jar.JarEntry;
- import java.util.jar.JarFile;
/**
--- 17,20 ----
***************
*** 30,39 ****
public static final JarFilter JAR_FILTER = new JarFilter();
public static final DirFilter DIR_FILTER = new DirFilter();
- public static final ClassFilter CLASS_FILE_FILTER = new ClassFilter();
public static final String PATH_DELIM = System.getProperty("path.separator");
- // TODO: We should probably add some more intelligence to
- // getClassesFromClasspath and friends, so it only introspects jars and dirs
with META-INF/xdoclet-plugin.xml.
- // This is to avoid scanning all the other support jars which might be a bit big
-> slow.
private final String _classpath;
private XDocletClassLoader _classpathClassLoader;
--- 28,33 ----
***************
*** 180,308 ****
}
- /**
- * Returns a Collection of all classes on the classpath that are
- * in both directories and jars.
- *
- * @see #getClassesFromJars
- * @see #getClassesFromDirectories
- * @return Collection of [EMAIL PROTECTED] Class}.
- */
- public Collection getClassesFromClasspath() {
- Collection classes = new ArrayList(getClassesFromJars());
-
- classes.addAll(getClassesFromDirectories());
-
- return classes;
- }
-
- /**
- * Returns a Collection of all classes on the classpath that are in
- * jars. Useful for introspection of metadata, such as knowing
- * what [EMAIL PROTECTED] xdoclet.XDoclet} and [EMAIL PROTECTED] xdoclet.Plugin}
classes
- * are available.
- *
- * @return Collection of [EMAIL PROTECTED] Class}.
- */
- public Collection getClassesFromJars() {
- List classes = new ArrayList();
-
- for (Iterator jars = getJars().iterator(); jars.hasNext();) {
- File file = (File) jars.next();
-
- try {
- JarFile jar = new JarFile(file);
-
- addClassesFromJar(jar, classes);
- } catch (IOException e) {
-
LogFactory.getLog(ClasspathManager.class).error(file.getAbsolutePath() + " is not a
valid jar file.", e);
- }
- }
-
- return classes;
- }
-
- /**
- * Adds classes in a jar.
- * @param jar the jar to add classes from.
- * @param classes the List where classes should be added.
- */
- private void addClassesFromJar(JarFile jar, List classes) {
- for (Enumeration entries = jar.entries(); entries.hasMoreElements();) {
- JarEntry entry = (JarEntry) entries.nextElement();
- String entryName = entry.getName();
-
- if (entryName.endsWith(".class")) {
- // Strip away ".class"
- entryName = entryName.substring(0, entryName.length() - 6);
-
- String className = entryName.replace('/', '.');
-
- try {
- Class clazz = _classpathClassLoader.loadClass(className);
-
- classes.add(clazz);
- } catch (ClassNotFoundException e) {
- LogFactory.getLog(ClasspathManager.class).error("Couldn't load
class " + className, e);
- } catch (Throwable e) {
- LogFactory.getLog(ClasspathManager.class).error("Couldn't load
class " + className, e);
- }
- }
- }
- }
-
- /**
- * Returns a Collection of all classes on the classpath that are in
- * directories. Useful for introspection of metadata, such as knowing
- * what [EMAIL PROTECTED] xdoclet.XDoclet} and [EMAIL PROTECTED] xdoclet.Plugin}
classes
- * are available.
- *
- * @return Collection of [EMAIL PROTECTED] Class}.
- */
- public Collection getClassesFromDirectories() {
- List classes = new ArrayList();
-
- for (Iterator dirs = getFiles().iterator(); dirs.hasNext();) {
- File dir = (File) dirs.next();
-
- addClassesFromDirectory(dir, classes, "");
- }
-
- return classes;
- }
-
- /**
- * Recursively descends a directory and adds classes.
- * @param dir current directory.
- * @param classes the List where classes should be added.
- * @param packageName current package name.
- */
- private void addClassesFromDirectory(File dir, List classes, String packageName)
{
- // Recursively descend.
- File[] subdirs = dir.listFiles(ClasspathManager.DIR_FILTER);
-
- if (subdirs != null) {
- for (int i = 0; i < subdirs.length; i++) {
- addClassesFromDirectory(subdirs[i], classes, subdirs[i].getName() +
".");
- }
- }
-
- // Add classes in this directory.
- File[] classFiles = dir.listFiles(ClasspathManager.CLASS_FILE_FILTER);
-
- if (classFiles != null) {
- for (int i = 0; i < subdirs.length; i++) {
- String className = packageName
- + classFiles[i].getName().substring(0,
classFiles[i].getName().length() - 5);
-
- try {
- Class clazz = _classpathClassLoader.loadClass(className);
-
- classes.add(clazz);
- } catch (ClassNotFoundException e) {
- LogFactory.getLog(ClasspathManager.class).error("Couldn't load
class " + className, e);
- }
- }
- }
- }
/**
--- 174,177 ----
***************
*** 327,350 ****
public boolean accept(File file) {
return file.isDirectory();
- }
- }
-
- public static class ClassFilter extends FileFilterPredicate {
- public boolean accept(File file) {
- return file.getName().endsWith(".class");
- }
- }
-
- public static class AssignableFromPredicate implements Predicate {
- private final Class _class;
-
- public AssignableFromPredicate(Class clazz) {
- _class = clazz;
- }
-
- public boolean evaluate(Object o) {
- Class clazz = (Class) o;
-
- return _class.isAssignableFrom(clazz);
}
}
--- 196,199 ----
-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open!
Get cracking and register here for some mind boggling fun and
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
_______________________________________________
xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel