Converted to Java regexp code; renamed to avoid enum keyword collision.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@1470 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -25,7 +25,7 @@ import java.awt.print.*;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.samskivert.swing.util.SwingUtil;
|
import com.samskivert.swing.util.SwingUtil;
|
||||||
import com.samskivert.viztool.enum.*;
|
import com.samskivert.viztool.clenum.*;
|
||||||
|
|
||||||
import com.samskivert.viztool.hierarchy.HierarchyVisualizer;
|
import com.samskivert.viztool.hierarchy.HierarchyVisualizer;
|
||||||
import com.samskivert.viztool.summary.SummaryVisualizer;
|
import com.samskivert.viztool.summary.SummaryVisualizer;
|
||||||
@@ -59,10 +59,10 @@ public class Driver
|
|||||||
// run ourselves on the classpath
|
// run ourselves on the classpath
|
||||||
String classpath = System.getProperty("java.class.path");
|
String classpath = System.getProperty("java.class.path");
|
||||||
// System.err.println("Scanning " + classpath + ".");
|
// System.err.println("Scanning " + classpath + ".");
|
||||||
ClassEnumerator enum = new ClassEnumerator(classpath);
|
ClassEnumerator clenum = new ClassEnumerator(classpath);
|
||||||
|
|
||||||
// print out the warnings
|
// print out the warnings
|
||||||
ClassEnumerator.Warning[] warnings = enum.getWarnings();
|
ClassEnumerator.Warning[] warnings = clenum.getWarnings();
|
||||||
for (int i = 0; i < warnings.length; i++) {
|
for (int i = 0; i < warnings.length; i++) {
|
||||||
System.err.println("Warning: " + warnings[i].reason);
|
System.err.println("Warning: " + warnings[i].reason);
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ public class Driver
|
|||||||
// and finally generate the visualization
|
// and finally generate the visualization
|
||||||
FilterEnumerator fenum = null;
|
FilterEnumerator fenum = null;
|
||||||
try {
|
try {
|
||||||
fenum = new RegexpEnumerator(regexp, enum);
|
fenum = new RegexpEnumerator(regexp, null, clenum);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Invalid package regular expression " +
|
Log.warning("Invalid package regular expression " +
|
||||||
"[regexp=" + regexp + ", error=" + e + "].");
|
"[regexp=" + regexp + ", error=" + e + "].");
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ import org.apache.tools.ant.types.Path;
|
|||||||
|
|
||||||
import com.samskivert.swing.util.SwingUtil;
|
import com.samskivert.swing.util.SwingUtil;
|
||||||
|
|
||||||
import com.samskivert.viztool.enum.ClassEnumerator;
|
import com.samskivert.viztool.clenum.ClassEnumerator;
|
||||||
import com.samskivert.viztool.enum.FilterEnumerator;
|
import com.samskivert.viztool.clenum.FilterEnumerator;
|
||||||
import com.samskivert.viztool.enum.RegexpEnumerator;
|
import com.samskivert.viztool.clenum.RegexpEnumerator;
|
||||||
import com.samskivert.viztool.util.FontPicker;
|
import com.samskivert.viztool.util.FontPicker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,10 +118,10 @@ public class DriverTask extends Task
|
|||||||
|
|
||||||
// scan the classpath and determine which classes will be
|
// scan the classpath and determine which classes will be
|
||||||
// visualized
|
// visualized
|
||||||
ClassEnumerator enum = new ClassEnumerator(classpath.toString());
|
ClassEnumerator clenum = new ClassEnumerator(classpath.toString());
|
||||||
FilterEnumerator fenum = null;
|
FilterEnumerator fenum = null;
|
||||||
try {
|
try {
|
||||||
fenum = new RegexpEnumerator(_classes, _exclude, enum);
|
fenum = new RegexpEnumerator(_classes, _exclude, clenum);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BuildException("Invalid package regular expression " +
|
throw new BuildException("Invalid package regular expression " +
|
||||||
"[classes=" + _classes +
|
"[classes=" + _classes +
|
||||||
|
|||||||
+15
-15
@@ -18,7 +18,7 @@
|
|||||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.samskivert.viztool.enum;
|
package com.samskivert.viztool.clenum;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@@ -53,19 +53,19 @@ public class ClassEnumerator implements Iterator
|
|||||||
while (tok.hasMoreTokens()) {
|
while (tok.hasMoreTokens()) {
|
||||||
String component = tok.nextToken();
|
String component = tok.nextToken();
|
||||||
// locate an enumerator for this token
|
// locate an enumerator for this token
|
||||||
ComponentEnumerator enum = matchEnumerator(component);
|
ComponentEnumerator cenum = matchEnumerator(component);
|
||||||
if (enum == null) {
|
if (cenum == null) {
|
||||||
String wmsg = "Unable to match enumerator for " +
|
String wmsg = "Unable to match enumerator for " +
|
||||||
"component '" + component + "'.";
|
"component '" + component + "'.";
|
||||||
warnings.add(new Warning(wmsg));
|
warnings.add(new Warning(wmsg));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// System.out.println("Adding [enum=" + enum +
|
// System.out.println("Adding [enum=" + cenum +
|
||||||
// ", component=" + component + "].");
|
// ", component=" + component + "].");
|
||||||
// construct an enumerator to enumerate this component
|
// construct an enumerator to enumerate this component
|
||||||
// and put it on our list
|
// and put it on our list
|
||||||
enums.add(enum.enumerate(component));
|
enums.add(cenum.enumerate(component));
|
||||||
|
|
||||||
} catch (EnumerationException ee) {
|
} catch (EnumerationException ee) {
|
||||||
// if there was a problem creating an enumerator for
|
// if there was a problem creating an enumerator for
|
||||||
@@ -95,10 +95,10 @@ public class ClassEnumerator implements Iterator
|
|||||||
protected ComponentEnumerator matchEnumerator (String component)
|
protected ComponentEnumerator matchEnumerator (String component)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _enumerators.size(); i++) {
|
for (int i = 0; i < _enumerators.size(); i++) {
|
||||||
ComponentEnumerator enum =
|
ComponentEnumerator cenum =
|
||||||
(ComponentEnumerator)_enumerators.get(i);
|
(ComponentEnumerator)_enumerators.get(i);
|
||||||
if (enum.matchesComponent(component)) {
|
if (cenum.matchesComponent(component)) {
|
||||||
return enum;
|
return cenum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,12 +143,12 @@ public class ClassEnumerator implements Iterator
|
|||||||
{
|
{
|
||||||
if (_enumidx < _enums.length) {
|
if (_enumidx < _enums.length) {
|
||||||
// grab the current enumerator
|
// grab the current enumerator
|
||||||
ComponentEnumerator enum = _enums[_enumidx];
|
ComponentEnumerator cenum = _enums[_enumidx];
|
||||||
|
|
||||||
// if it has more classes
|
// if it has more classes
|
||||||
if (enum.hasMoreClasses()) {
|
if (cenum.hasMoreClasses()) {
|
||||||
// get the next one
|
// get the next one
|
||||||
_nextClass = enum.nextClass();
|
_nextClass = cenum.nextClass();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -182,17 +182,17 @@ public class ClassEnumerator implements Iterator
|
|||||||
{
|
{
|
||||||
// run ourselves on the classpath
|
// run ourselves on the classpath
|
||||||
String classpath = System.getProperty("java.class.path");
|
String classpath = System.getProperty("java.class.path");
|
||||||
ClassEnumerator enum = new ClassEnumerator(classpath);
|
ClassEnumerator cenum = new ClassEnumerator(classpath);
|
||||||
|
|
||||||
// print out the warnings
|
// print out the warnings
|
||||||
Warning[] warnings = enum.getWarnings();
|
Warning[] warnings = cenum.getWarnings();
|
||||||
for (int i = 0; i < warnings.length; i++) {
|
for (int i = 0; i < warnings.length; i++) {
|
||||||
System.out.println("Warning: " + warnings[i].reason);
|
System.out.println("Warning: " + warnings[i].reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
// enumerate over whatever classes we can
|
// enumerate over whatever classes we can
|
||||||
while (enum.hasNext()) {
|
while (cenum.hasNext()) {
|
||||||
System.out.println("Class: " + enum.next());
|
System.out.println("Class: " + cenum.next());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.samskivert.viztool.enum;
|
package com.samskivert.viztool.clenum;
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.samskivert.viztool.enum;
|
package com.samskivert.viztool.clenum;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.samskivert.viztool.enum;
|
package com.samskivert.viztool.clenum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration exception is thrown when some problem occurs while
|
* An enumeration exception is thrown when some problem occurs while
|
||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.samskivert.viztool.enum;
|
package com.samskivert.viztool.clenum;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.samskivert.viztool.enum;
|
package com.samskivert.viztool.clenum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The jar file enumerator enumerates all of the classes in a .jar class
|
* The jar file enumerator enumerates all of the classes in a .jar class
|
||||||
+5
-5
@@ -18,7 +18,7 @@
|
|||||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.samskivert.viztool.enum;
|
package com.samskivert.viztool.clenum;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@@ -49,12 +49,12 @@ public class PackageEnumerator extends FilterEnumerator
|
|||||||
{
|
{
|
||||||
// run ourselves on the classpath
|
// run ourselves on the classpath
|
||||||
String classpath = System.getProperty("java.class.path");
|
String classpath = System.getProperty("java.class.path");
|
||||||
ClassEnumerator enum = new ClassEnumerator(classpath);
|
ClassEnumerator clenum = new ClassEnumerator(classpath);
|
||||||
String pkg = "com.samskivert.viztool.enum";
|
String pkg = "com.samskivert.viztool.clenum";
|
||||||
PackageEnumerator penum = new PackageEnumerator(pkg, enum, true);
|
PackageEnumerator penum = new PackageEnumerator(pkg, clenum, true);
|
||||||
|
|
||||||
// print out the warnings
|
// print out the warnings
|
||||||
ClassEnumerator.Warning[] warnings = enum.getWarnings();
|
ClassEnumerator.Warning[] warnings = clenum.getWarnings();
|
||||||
for (int i = 0; i < warnings.length; i++) {
|
for (int i = 0; i < warnings.length; i++) {
|
||||||
System.out.println("Warning: " + warnings[i].reason);
|
System.out.println("Warning: " + warnings[i].reason);
|
||||||
}
|
}
|
||||||
+10
-11
@@ -18,12 +18,11 @@
|
|||||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.samskivert.viztool.enum;
|
package com.samskivert.viztool.clenum;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import org.apache.regexp.RE;
|
import java.util.regex.PatternSyntaxException;
|
||||||
import org.apache.regexp.RESyntaxException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The regex enumerator filters classes based on a regular expression.
|
* The regex enumerator filters classes based on a regular expression.
|
||||||
@@ -31,21 +30,21 @@ import org.apache.regexp.RESyntaxException;
|
|||||||
public class RegexpEnumerator extends FilterEnumerator
|
public class RegexpEnumerator extends FilterEnumerator
|
||||||
{
|
{
|
||||||
public RegexpEnumerator (String regexp, String exregex, Iterator source)
|
public RegexpEnumerator (String regexp, String exregex, Iterator source)
|
||||||
throws RESyntaxException
|
throws PatternSyntaxException
|
||||||
{
|
{
|
||||||
super(source);
|
super(source);
|
||||||
_regexp = new RE(regexp);
|
_regexp = Pattern.compile(regexp);
|
||||||
if (exregex != null) {
|
if (exregex != null) {
|
||||||
_exreg = new RE(exregex);
|
_exreg = Pattern.compile(exregex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean filterClass (String clazz)
|
protected boolean filterClass (String clazz)
|
||||||
{
|
{
|
||||||
return !(_regexp.match(clazz) &&
|
return !(_regexp.matcher(clazz).matches() &&
|
||||||
(_exreg == null || !_exreg.match(clazz)));
|
(_exreg == null || !_exreg.matcher(clazz).matches()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RE _regexp;
|
protected Pattern _regexp;
|
||||||
protected RE _exreg;
|
protected Pattern _exreg;
|
||||||
}
|
}
|
||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.samskivert.viztool.enum;
|
package com.samskivert.viztool.clenum;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@@ -30,7 +30,7 @@ import com.samskivert.util.CollectionUtil;
|
|||||||
|
|
||||||
import com.samskivert.viztool.Log;
|
import com.samskivert.viztool.Log;
|
||||||
import com.samskivert.viztool.Visualizer;
|
import com.samskivert.viztool.Visualizer;
|
||||||
import com.samskivert.viztool.enum.PackageEnumerator;
|
import com.samskivert.viztool.clenum.PackageEnumerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The hierarchy visualizer displays inheritance hierarchies in a compact
|
* The hierarchy visualizer displays inheritance hierarchies in a compact
|
||||||
|
|||||||
Reference in New Issue
Block a user