From 16073c05777c7fbd11575f216df6b3fadc21995f Mon Sep 17 00:00:00 2001 From: evenisse Date: Thu, 4 Dec 2003 15:05:50 +0000 Subject: [PATCH] Apply patch from Nicolas De Loof for reduce open files during jxr process. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114442 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/jxr/pacman/JavaFileImpl.java | 108 ++++++++++-------- jxr/xdocs/changes.xml | 3 + 2 files changed, 62 insertions(+), 49 deletions(-) diff --git a/jxr/src/main/org/apache/maven/jxr/pacman/JavaFileImpl.java b/jxr/src/main/org/apache/maven/jxr/pacman/JavaFileImpl.java index b0fd0112..d72b9957 100644 --- a/jxr/src/main/org/apache/maven/jxr/pacman/JavaFileImpl.java +++ b/jxr/src/main/org/apache/maven/jxr/pacman/JavaFileImpl.java @@ -58,10 +58,11 @@ import java.io.*; * determine package, class, and imports * * @author Kevin A. Burton - * @version $Id: JavaFileImpl.java,v 1.2 2003/10/02 00:18:52 dion Exp $ + * @version $Id: JavaFileImpl.java,v 1.3 2003/12/04 15:05:50 evenisse Exp $ */ public class JavaFileImpl extends JavaFile { + private Reader reader; /** * Create a new JavaFileImpl that points to a given file... @@ -92,59 +93,68 @@ public class JavaFileImpl extends JavaFile private void parse() throws IOException { - - StreamTokenizer stok = this.getTokenizer(); - - while (stok.nextToken() != StreamTokenizer.TT_EOF) + StreamTokenizer stok = null; + try { - - if (stok.sval == null) + stok = this.getTokenizer(); + + while (stok.nextToken() != StreamTokenizer.TT_EOF) { - continue; - } - - //set the package - if (stok.sval.equals("package")) - { - stok.nextToken(); - this.setPackageType(new PackageType(stok.sval)); - } - - //set the imports - if (stok.sval.equals("import")) - { - stok.nextToken(); - - String name = stok.sval; - - /* - WARNING: this is a bug/non-feature in the current - StreamTokenizer. We needed to set the comment char as "*" - and packages that are imported with this (ex "test.*") will be - stripped( and become "test." ). Here we need to test for this - and if necessary re-add the char. - */ - if (name.charAt(name.length() - 1) == '.') + + if (stok.sval == null) { - name = name + "*"; + continue; } - - this.addImportType(new ImportType(name)); + + //set the package + if (stok.sval.equals("package")) + { + stok.nextToken(); + this.setPackageType(new PackageType(stok.sval)); + } + + //set the imports + if (stok.sval.equals("import")) + { + stok.nextToken(); + + String name = stok.sval; + + /* + WARNING: this is a bug/non-feature in the current + StreamTokenizer. We needed to set the comment char as "*" + and packages that are imported with this (ex "test.*") will be + stripped( and become "test." ). Here we need to test for this + and if necessary re-add the char. + */ + if (name.charAt(name.length() - 1) == '.') + { + name = name + "*"; + } + + this.addImportType(new ImportType(name)); + } + + //set the Class... if the class is found no more information is + //valid so just break out of the while loop at this point. + //set the imports + if (stok.sval.equals("class") || + stok.sval.equals("interface")) + { + stok.nextToken(); + this.setClassType(new ClassType(stok.sval)); + break; + } + + } + } + finally + { + stok = null; + if (this.reader != null) { + this.reader.close(); } - - //set the Class... if the class is found no more information is - //valid so just break out of the while loop at this point. - //set the imports - if (stok.sval.equals("class") || - stok.sval.equals("interface")) - { - stok.nextToken(); - this.setClassType(new ClassType(stok.sval)); - break; - } - } - } /** Get a StreamTokenizer for this file. */ @@ -157,7 +167,7 @@ public class JavaFileImpl extends JavaFile throw new IOException(this.getFilename() + " does not exist!"); } - FileReader reader = new FileReader(this.getFilename()); + this.reader = new FileReader(this.getFilename()); StreamTokenizer stok = new StreamTokenizer(reader); //int tok; diff --git a/jxr/xdocs/changes.xml b/jxr/xdocs/changes.xml index 89f5a904..669e98c2 100644 --- a/jxr/xdocs/changes.xml +++ b/jxr/xdocs/changes.xml @@ -9,6 +9,9 @@ + + Apply patch from Nicolas De Loof for reduce open files during jxr process. + MAVEN-822 MAVEN-797