From a3e5e4104ff31c9f06d90bd0f6876bef305831dc Mon Sep 17 00:00:00 2001
From: Andy Clement
Date: Thu, 28 Nov 2019 15:56:46 -0800
Subject: Move to 1.9.6.BUILD-SNAPSHOT version
---
.../main/java/$installer$/org/aspectj/Main.java | 52 +++----
.../internal/tools/ant/taskdefs/AJInstaller.java | 37 ++---
.../internal/tools/ant/taskdefs/AJPush.java | 19 +--
.../internal/tools/ant/taskdefs/AntBuilder.java | 55 +++----
.../internal/tools/ant/taskdefs/Checklics.java | 27 ++--
.../tools/ant/taskdefs/ConditionalTask.java | 21 +--
.../org/aspectj/internal/tools/build/Builder.java | 64 ++++----
.../org/aspectj/internal/tools/build/Module.java | 50 +++---
.../internal/tools/build/SampleGatherer.java | 173 +++++++++++----------
.../org/aspectj/internal/tools/build/Util.java | 105 +++++++------
10 files changed, 314 insertions(+), 289 deletions(-)
(limited to 'build/src/main')
diff --git a/build/src/main/java/$installer$/org/aspectj/Main.java b/build/src/main/java/$installer$/org/aspectj/Main.java
index 536c86293..9e7518038 100644
--- a/build/src/main/java/$installer$/org/aspectj/Main.java
+++ b/build/src/main/java/$installer$/org/aspectj/Main.java
@@ -1,14 +1,14 @@
/* *******************************************************************
- * Copyright (c) 2000-2001 Xerox Corporation,
+ * Copyright (c) 2000-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package $installer$.org.aspectj;
@@ -75,12 +75,12 @@ import javax.swing.border.EmptyBorder;
* "-text".equals(arg[0])
* arg[1] is the path to a properties file which defines name="output.dir" value="{path to output dir}" name="context.javaPath"
* value="{path to JDKDIR}", i.e,.
- *
+ *
*
* output.dir=c:/latest
* "context.javaPath=c:/apps/jdk1.3.1
*
- *
+ *
*
* outputDir must be created and empty (i.e., no overwriting
* the VM being invoked should be the target vm
@@ -106,7 +106,7 @@ public class Main {
Main.exit(-1);
}
properties.load(istream);
- // when running outside GUI, load values into properties
+ // when running outside GUI, load values into properties
// so that property-value resolution works
// (otherwise, could just set values below).
// XXX not sure if this indirection is actually needed.
@@ -626,7 +626,7 @@ abstract class Installer {
* (files == null) return; for (int i=0; i properties;
public boolean hasGui() {
return hasGui;
@@ -762,7 +762,7 @@ class InstallContext {
return overwriteState == OVERWRITE_YES || overwriteState == OVERWRITE_ALL;
}
- public Map getProperties() {
+ public Map getProperties() {
return properties;
}
}
@@ -1081,11 +1081,11 @@ class ConfigureLauncherPane extends WizardPane {
/*
* //XXX check that the returned file is valid public String getDefaultJavaLocation() { String name = "java"; if
* (context.onWindows()) name += ".exe";
- *
+ *
* if (Options.verbose) { System.out.println("java.home: " + System.getProperty("java.home")); System.out.println(" java: " +
* new File(new File(System.getProperty("java.home"), "bin"), name)); System.out.println(" java: " + new File(new
* File(System.getProperty("java.home"), "bin"), name).getPath()); }
- *
+ *
* return new File(new File(System.getProperty("java.home"), "bin"), name).getPath(); }
*/
@@ -1492,7 +1492,7 @@ class CurrentJarUnpacker {
public void unpack(String contentsName, File outputDir) throws IOException {
URL url = getClass().getResource(contentsName);
-
+
// Process everything under 'files/**' copying to the target
// install directory with 'files/' removed
JarURLConnection juc = (JarURLConnection) url.openConnection();
@@ -1504,7 +1504,7 @@ class CurrentJarUnpacker {
writeResource(jf, je, outputDir);
}
}
-
+
// InputStream stream = url.openStream();
// BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "US-ASCII"));
// String line = reader.readLine();
@@ -1528,7 +1528,7 @@ class LaunchScriptMaker {
}
/**
- *
+ *
*/
public void writeAJLaunchScript(String name, boolean isJava5) throws IOException {
if (!context.onUnix()) {
@@ -1764,22 +1764,22 @@ class LaunchScriptMaker {
/*
* final static String OVERWRITE_MESSAGE = "Overwrite launch script "; final static String OVERWRITE_TITLE = "Overwrite?";
- *
+ *
* final static String[] OVERWRITE_OPTIONS = { "Yes", "No", "Yes to all", "No to all" };
- *
+ *
* final static int OVERWRITE_YES = 0; final static int OVERWRITE_NO = 1; final static int OVERWRITE_ALL = 2; final static int
* OVERWRITE_NONE = 3;
- *
+ *
* int overwriteState = OVERWRITE_NO; boolean shouldOverwrite(final File file) { if (overwriteState == OVERWRITE_ALL) return
* true; if (overwriteState == OVERWRITE_NONE) return false;
- *
+ *
* try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { int ret =
* JOptionPane.showOptionDialog(context.installer.frame, OVERWRITE_MESSAGE+file.getPath(), OVERWRITE_TITLE,
* JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, OVERWRITE_OPTIONS, OVERWRITE_OPTIONS[OVERWRITE_YES]);
- *
+ *
* overwriteState = ret; } }); } catch (InvocationTargetException ite) { context.handleException(ite.getTargetException()); }
* catch (InterruptedException ie) { }
- *
+ *
* return overwriteState == OVERWRITE_YES || overwriteState == OVERWRITE_ALL; }
*/
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java
index 6bc2fc09b..2428e66d9 100644
--- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java
+++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java
@@ -1,14 +1,14 @@
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
//XXX INCLUDES CODE FROM ANT -- UNDER APACHE LICENSE
@@ -39,12 +39,13 @@ import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet;
+@SuppressWarnings("deprecation")
public class AJInstaller extends MatchingTask {
static final String INCLUDE_CLASSES = "$installer$/org/aspectj/*.class";
static final String MAIN_CLASS = "$installer$.org.aspectj.Main";
static final String CONTENTS_FILE = "$installer$/org/aspectj/resources/contents.txt";
private String htmlSrc;
-
+
public void setHtmlSrc(String v) { htmlSrc = v; }
private String resourcesSrc;
@@ -57,11 +58,11 @@ public class AJInstaller extends MatchingTask {
private File installerClassJar;
- public void setInstallerclassjar(String v) {
+ public void setInstallerclassjar(String v) {
installerClassJar = project.resolveFile(v);
}
- protected List contentsNames = new ArrayList();
+ protected List contentsNames = new ArrayList<>();
protected long contentsBytes = 0;
@@ -102,7 +103,7 @@ public class AJInstaller extends MatchingTask {
PatternSet patterns = new PatternSet();
patterns.setIncludes(INCLUDE_CLASSES);
expand.addPatternset(patterns);
- expand.execute();
+ expand.execute();
// move the correct resource files into the jar
Copy cd = getCopyTask();
@@ -151,8 +152,8 @@ public class AJInstaller extends MatchingTask {
StringBuffer buf = new StringBuffer();
buf.append(contentsBytes);
buf.append(NEWLINE);
- for (Iterator i = contentsNames.iterator(); i.hasNext(); ) {
- String name = (String)i.next();
+ for (Iterator i = contentsNames.iterator(); i.hasNext(); ) {
+ String name = i.next();
buf.append(name);
buf.append(NEWLINE);
}
@@ -179,7 +180,7 @@ public class AJInstaller extends MatchingTask {
* This is the name/location of where to
* create the .zip file.
*/
- public void setZipfile(String zipFilename) {
+ public void setZipfile(String zipFilename) {
zipFile = project.resolveFile(zipFilename);
}
@@ -294,12 +295,12 @@ public class AJInstaller extends MatchingTask {
}
return tmpDir;
}
-
+
public void execute() throws BuildException {
if (installerClassJar == null) {
throw new BuildException("installerClassJar attribute must be set!");
}
- if (!installerClassJar.canRead()
+ if (!installerClassJar.canRead()
|| !installerClassJar.getPath().endsWith(".jar")) {
throw new BuildException("not readable jar:" + installerClassJar);
}
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJPush.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJPush.java
index 26ab7ce5f..81e592553 100644
--- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJPush.java
+++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJPush.java
@@ -1,14 +1,14 @@
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.ant.taskdefs;
@@ -22,6 +22,7 @@ import java.util.Properties;
import org.apache.tools.ant.taskdefs.Mkdir;
+@SuppressWarnings("deprecation")
public class AJPush extends ConditionalTask {
private File src;
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java
index d65c50501..c4f8848d8 100644
--- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java
+++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java
@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.ant.taskdefs;
@@ -51,7 +51,7 @@ public class AntBuilder extends Builder {
/**
* Factory for a Builder.
- *
+ *
* @param config the String configuration, where only substrings "verbose" and "useEclipseCompiles" are significant
* @param project the owning Project for all tasks (not null)
* @param tempDir the File path to a temporary dir for side effects (may be null)
@@ -128,7 +128,7 @@ public class AntBuilder extends Builder {
/**
* Initialize task with project and "ajbuild-" + name as name. (Using bm- prefix distinguishes these tasks from tasks found in
* the build script.)
- *
+ *
* @param task the Task to initialize - not null
* @param name the String name suffix for the task
* @return true unless some error
@@ -141,7 +141,7 @@ public class AntBuilder extends Builder {
/**
* Copy file, optionally filtering. (Filters set in project.)
- *
+ *
* @param fromFile the readable File source to copy
* @param toFile the writable File destination file
* @param boolean filter if true, enable filtering
@@ -158,7 +158,7 @@ public class AntBuilder extends Builder {
/**
* (Filters set in project.)
- *
+ *
* @see org.aspectj.internal.tools.ant.taskdefs.Builder#copyFiles(File, File, String, String, boolean)
*/
@Override
@@ -230,7 +230,7 @@ public class AntBuilder extends Builder {
for (File file: result.getSrcDirs()) {
path.createPathElement().setLocation(file);
if (!isJava5Compile
- && (Util.Constants.JAVA5_SRC.equals(file.getName()) ||
+ && (Util.Constants.JAVA5_SRC.equals(file.getName()) ||
Util.Constants.JAVA5_TESTSRC.equals(file.getName()) ||
new File(file.getParent(), ".isJava5").exists())) {
isJava5Compile = true;
@@ -272,11 +272,11 @@ public class AntBuilder extends Builder {
javac.setDebug(true);
if (isJava8Compile) {
javac.setSource("1.8");
- javac.setTarget("1.8");
+ javac.setTarget("1.8");
} else if (isJava5Compile) {
// *cough*
javac.setSource("1.6");
- javac.setTarget("1.6");
+ javac.setTarget("1.6");
} else {
javac.setTarget("1.1"); // 1.1 class files - Javac in 1.4 uses 1.4
javac.setSource("1.3");
@@ -311,8 +311,8 @@ public class AntBuilder extends Builder {
public boolean setupClasspath(Result result, Path classpath) { // XXX fix test access
boolean hasLibraries = false;
// required libraries
- for (Iterator iter = result.getLibJars().iterator(); iter.hasNext();) {
- File file = (File) iter.next();
+ for (Iterator iter = result.getLibJars().iterator(); iter.hasNext();) {
+ File file = iter.next();
classpath.createPathElement().setLocation(file);
if (!hasLibraries) {
hasLibraries = true;
@@ -329,8 +329,8 @@ public class AntBuilder extends Builder {
}
// also put on classpath libraries exported from required module
// XXX exported modules not supported
- for (Iterator iterator = requiredResult.getExportedLibJars().iterator(); iterator.hasNext();) {
- classpath.createPathElement().setLocation((File) iterator.next());
+ for (Iterator iterator = requiredResult.getExportedLibJars().iterator(); iterator.hasNext();) {
+ classpath.createPathElement().setLocation(iterator.next());
}
}
return hasLibraries;
@@ -356,8 +356,9 @@ public class AntBuilder extends Builder {
ZipFileSet zipfileset = null;
// -- merge any resources in any of the src directories
- for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) {
- File srcDir = (File) iter.next();
+ //for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) {
+ // File srcDir = (File) iter.next();
+ for (File srcDir: result.getSrcDirs()) {
zipfileset = new ZipFileSet();
zipfileset.setProject(project);
zipfileset.setDir(srcDir);
@@ -528,7 +529,7 @@ public class AntBuilder extends Builder {
/**
* If this module should be compiled with AspectJ, return a task to do so.
- *
+ *
* @param module the Module to compile
* @param javac the Javac compile commands
* @return javac or a Task to compile with AspectJ if needed
@@ -588,7 +589,7 @@ public class AntBuilder extends Builder {
/**
* Wrap AspectJ compiler as Task. Only works for javac-like source compilation of everything under srcDir. Written
* reflectively to compile in the build module, which can't depend on the whole tree.
- *
+ *
* @param javac the Javac specification
* @param toolsJar the Path to the aspectjtools.jar
* @param runtimeJar the Path to the aspectjrt.jar
@@ -659,7 +660,7 @@ public class AntBuilder extends Builder {
// loadAntProperties(ant, buildSpec);
// ant.execute();
// }
-//
+//
// /** override definitions */
// private void loadAntProperties(Ant ant, BuildSpec buildSpec) {
// Property property = ant.createProperty();
@@ -682,7 +683,7 @@ public class AntBuilder extends Builder {
/**
* Segregate product-building API's from module-building APIs for clarity. These are called by the superclass if the BuildSpec
* warrants. XXX extremely brittle/arbitrary assumptions.
- *
+ *
* @see BuildModule for assumptions
*/
class ProductBuilder extends AntBuilder {
@@ -708,7 +709,7 @@ class ProductBuilder extends AntBuilder {
/**
* Calculate name of main, typically InitialCap, and hence installer class.
- *
+ *
* @return $$installer$$.org.aspectj." + ProductName + "Installer"
*/
@@ -801,7 +802,7 @@ class ProductBuilder extends AntBuilder {
// String name = (!assembleAll ? jarName : jarName.substring(0, jarName.length()-4));
// return modules.getModule(name);
// }
- //
+ //
}
class ProjectMessager extends Messager {
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java
index 904ba4656..e7de69284 100644
--- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java
+++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java
@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.ant.taskdefs;
@@ -36,6 +36,7 @@ import org.apache.tools.ant.types.Reference;
* Check that included .java files contain license and copyright strings for MPL 1.0 (default), Apache, or CPL. Use list="true" to
* get a list of known license variants {license}-{copyrightHolder} todo reimplement with regexp and jdiff FileLine utilities
*/
+@SuppressWarnings("deprecation")
public class Checklics extends MatchingTask {
/*
* This does not enforce that copyrights are correct/current, only that they exist. E.g., the default behavior requires MPL but
@@ -114,7 +115,7 @@ public class Checklics extends MatchingTask {
/**
* Run the license check directly
- *
+ *
* @param sourcepaths String[] of paths to source directories
* @param license the String tag for the license, if any
* @param failonerror boolean flag to pass to Checklics
@@ -171,7 +172,7 @@ public class Checklics extends MatchingTask {
/**
* When failOnError is true, if any file failed, throw BuildException listing number of files that file failed to pass license
* check
- *
+ *
* @param fail if true, report errors by throwing BuildException
*/
public void setFailOnError(boolean fail) {
@@ -342,7 +343,7 @@ public class Checklics extends MatchingTask {
public static class License {
/** acceptable years for copyright prefix to company - append " " */
static final String[] YEARS = // remove older after license xfer?
- new String[] { "2002 ", "2003 ", "2004 ", "2005", "2006", "2007", "2008",
+ new String[] { "2002 ", "2003 ", "2004 ", "2005", "2006", "2007", "2008",
"2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2001 ", "2000 ",
"1999 " };
public final String tag;
@@ -556,7 +557,7 @@ class HeaderInfo {
* Alto Research Center, Incorporated (PARC). All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which accompanies this distribution and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors: Xerox/PARC initial implementation ******************************************************************
*/
}
@@ -651,7 +652,7 @@ class Header {
/**
* Add any years found (as String) to years, and return true at the first end-of-comment
- *
+ *
* @return true if this line has end-of-comment
*/
private static boolean checkLine(String line, ArrayList years) {
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java
index fdff0d7c1..ccb9c2149 100644
--- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java
+++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java
@@ -1,14 +1,14 @@
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.ant.taskdefs;
@@ -21,6 +21,7 @@ import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
+@SuppressWarnings("deprecation")
public abstract class ConditionalTask extends Task {
public final static String TRUE = "true";
@@ -170,7 +171,7 @@ public abstract class ConditionalTask extends Task {
Iterator iter = ifs().iterator();
List result = new Vector();
while (iter.hasNext()) {
- If next = (If) iter.next();
+ If next = iter.next();
String name = next.getName();
String prop = project.getProperty(name);
if (prop == null) {
diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java
index 72f53e901..8efea662a 100644
--- a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java
+++ b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java
@@ -1,14 +1,14 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC),
* 2003 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.build;
@@ -80,10 +80,10 @@ public abstract class Builder {
/**
* This has only weak forms for build instructions needed: - resource
* pattern - compiler selection and control
- *
+ *
* Both assumed and generated paths are scattered; see XXXNameLiteral and
* XXXFileLiteral.
- *
+ *
* Builder is supposed to be thread-safe, but currently caches build
* properties to tunnel for filters. hmm.
*/
@@ -140,12 +140,12 @@ public abstract class Builder {
/**
* Splits strings into an unmodifable List
of String using
* comma as the delimiter and trimming whitespace from the result.
- *
+ *
* @param text
* String
to split.
* @return unmodifiable List (String) of String delimited by comma in text
*/
- public static List commaStrings(String text) {
+ public static List commaStrings(String text) {
if ((null == text) || (0 == text.length())) {
return Collections.EMPTY_LIST;
}
@@ -162,7 +162,7 @@ public abstract class Builder {
/**
* Map delivered-jar name to created-module name
- *
+ *
* @param jarName
* the String (lowercased) of the jar/zip to map
*/
@@ -305,9 +305,9 @@ public abstract class Builder {
}
return noErr;
}
-
+
protected final boolean isLogging() {
- return (verbose && (null != this.handler));
+ return (verbose && (null != this.handler));
}
protected Result[] skipUptodate(Result[] results) {
@@ -331,14 +331,14 @@ public abstract class Builder {
/**
* Build a result with all antecedants.
- *
+ *
* @param result
* the Result to build
* @param errors
* the List sink for errors, if any
* @return false after successful build, when module jar should exist
*/
- protected final boolean buildAll(Result result, List errors) {
+ protected final boolean buildAll(Result result, List errors) {
Result[] buildList = skipUptodate(getAntecedantResults(result));
ArrayList doneList = new ArrayList();
if ((null != buildList) && (0 < buildList.length)) {
@@ -364,7 +364,7 @@ public abstract class Builder {
/**
* Build a module but no antecedants.
- *
+ *
* @param module
* the Module to build
* @param errors
@@ -419,7 +419,7 @@ public abstract class Builder {
* Build product by discovering any modules to build, building those,
* assembling the product distribution, and optionally creating an installer
* for it.
- *
+ *
* @return true on success
*/
protected final boolean buildProduct(BuildSpec buildSpec)
@@ -527,13 +527,13 @@ public abstract class Builder {
}
protected final boolean buildProductModule(ProductModule module) {
- ArrayList errors = new ArrayList();
+ ArrayList errors = new ArrayList<>();
try {
Kind productKind = Result.kind(Result.NORMAL, Result.ASSEMBLE);
Result result = module.module.getResult(productKind);
return buildAll(result, errors);
} finally {
- for (Iterator iter = errors.iterator(); iter.hasNext();) {
+ for (Iterator iter = errors.iterator(); iter.hasNext();) {
handler.error("error building " + module + ": " + iter.next());
}
}
@@ -578,25 +578,25 @@ public abstract class Builder {
assembleAll));
}
}
- return (ProductModule[]) results.toArray(new ProductModule[0]);
+ return results.toArray(new ProductModule[0]);
}
/**
* Subclasses should query whether to include library files in the assembly.
- *
+ *
* @param module
* the Module being built
* @param libraries
* the List of File path to the jar to consider assembling
* @return true if the jar should be included, false otherwise.
*/
- protected void removeLibraryFilesToSkip(Module module, List libraries) {
- for (ListIterator liter = libraries.listIterator(); liter.hasNext();) {
- File library = (File) liter.next();
+ protected void removeLibraryFilesToSkip(Module module, List libraries) {
+ for (ListIterator liter = libraries.listIterator(); liter.hasNext();) {
+ File library = liter.next();
final String fname = library.getName();
if (null != fname) {
- for (Iterator iter = SKIP_LIBRARIES.iterator(); iter.hasNext();) {
- String name = (String) iter.next();
+ for (Iterator iter = SKIP_LIBRARIES.iterator(); iter.hasNext();) {
+ String name = iter.next();
if (fname.equals(name)) {
liter.remove();
break;
@@ -613,7 +613,7 @@ public abstract class Builder {
/**
* Compile module classes to classesDir, saving String errors.
- *
+ *
* @param module
* the Module to compile
* @param classesDir
@@ -629,7 +629,7 @@ public abstract class Builder {
/**
* Assemble the module distribution from the classesDir, saving String
* errors.
- *
+ *
* @see #removeLibraryFilesToSkip(Module, File)
*/
abstract protected boolean assemble(Result result, File classesDir,
@@ -638,7 +638,7 @@ public abstract class Builder {
/**
* Assemble the module distribution from the classesDir and all
* antecendants, saving String errors.
- *
+ *
* @see #removeLibraryFilesToSkip(Module, File)
*/
abstract protected boolean assembleAll(Result result, Messager handler);
@@ -658,7 +658,7 @@ public abstract class Builder {
/**
* Copy toDir any fromDir included files without any exluded files,
* optionally filtering contents.
- *
+ *
* @param fromDir
* File dir to read from - error if not readable
* @param toDir
diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Module.java b/build/src/main/java/org/aspectj/internal/tools/build/Module.java
index 3f0afbfd9..cbbbc308b 100644
--- a/build/src/main/java/org/aspectj/internal/tools/build/Module.java
+++ b/build/src/main/java/org/aspectj/internal/tools/build/Module.java
@@ -1,14 +1,14 @@
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.build;
@@ -43,7 +43,7 @@ import org.aspectj.internal.tools.build.Util.OSGIBundle.RequiredBundle;
* a file {moduleName}.mf.txt
is taken as the manifest of
* any .jar file produced, after filtering.
*
- *
+ *
* @see Builder
* @see Modules#getModule(String)
*/
@@ -98,7 +98,7 @@ public class Module {
/**
* Recursively find antecedant jars.
- *
+ *
* @see findKnownJarAntecedants()
*/
static void doFindJarRequirements(Result result, List known) {
@@ -147,7 +147,7 @@ public class Module {
// }
// return result;
// }
-
+
public final boolean valid;
public final File moduleDir;
@@ -266,7 +266,7 @@ public class Module {
return false;
}
-
+
public String toString() {
return name;
@@ -282,32 +282,32 @@ public class Module {
return kind.assemble ? (kind.normal ? releaseAll : testAll)
: (kind.normal ? release : test);
}
-
+
List srcDirs(Result result) {
myResult(result);
return srcDirs;
}
-
+
List libJars(Result result) {
myResult(result);
return libJars;
}
-
+
List classpathVariables(Result result) {
myResult(result);
return classpathVariables;
}
-
+
List exportedLibJars(Result result) {
myResult(result);
return exportedLibJars;
}
-
+
List requiredModules(Result result) {
myResult(result);
return requiredModules;
}
-
+
private void myResult(Result result) {
if ((null == result) || this != result.getModule()) {
throw new IllegalArgumentException("not my result: " + result + ": " + this);
@@ -325,7 +325,7 @@ public class Module {
/** read OSGI manifest.mf file XXX hacked */
private boolean initManifest() {
- File metaInf = new File(moduleDir, "META-INF");
+ File metaInf = new File(moduleDir, "META-INF");
if (!metaInf.canRead() || !metaInf.isDirectory()) {
return false;
}
@@ -354,9 +354,9 @@ public class Module {
update("lib", libs[i], libs[i], false);
}
- return true;
+ return true;
}
-
+
/** read eclipse .classpath file XXX line-oriented hack */
private boolean initClasspath() {
// meaning testsrc directory, junit library, etc.
@@ -517,8 +517,8 @@ public class Module {
*/
protected boolean reviewInit() {
try {
- for (ListIterator iter = srcDirs.listIterator(); iter.hasNext();) {
- File srcDir = (File) iter.next();
+ for (ListIterator iter = srcDirs.listIterator(); iter.hasNext();) {
+ File srcDir = iter.next();
String lcname = srcDir.getName().toLowerCase();
if (!Util.JAVA5_VM
&& (Util.Constants.JAVA5_SRC.equals(lcname) || Util.Constants.JAVA5_TESTSRC
@@ -640,7 +640,7 @@ public class Module {
}
}
}
- return (String[]) result.toArray(new String[0]);
+ return result.toArray(new String[0]);
}
public void acceptLine(String line) {
diff --git a/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java b/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java
index 0b023e6c5..bb1ed8555 100644
--- a/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java
+++ b/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java
@@ -1,27 +1,40 @@
/* *******************************************************************
* Copyright (c) 2003 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wes Isberg initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
* ******************************************************************/
/*
* A quickie hack to extract sample code from testable sources.
- * This could reuse a lot of code from elsewhere,
- * but currently doesn't,
+ * This could reuse a lot of code from elsewhere,
+ * but currently doesn't,
* to keep it in the build module which avoids dependencies.
* (Too bad we can't use scripting languages...)
*/
package org.aspectj.internal.tools.build;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.io.Reader;
import java.text.DateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
/**
* This gathers sample code delimited with [START..END]-SAMPLE
@@ -31,14 +44,14 @@ import java.util.*;
* ... sample code ...
* // END-SAMPLE {anchorName}
*
- * where {anchorName} need not be unique and might be
+ * where {anchorName} need not be unique and might be
* hierarchical wrt "-", e.g., "genus-species-individual".
*/
public class SampleGatherer {
-
+
/** EOL String for gathered lines */
public static final String EOL = "\n"; // XXX
-
+
static final String START = "START-SAMPLE";
static final String END = "END-SAMPLE";
static final String AUTHOR = "@author";
@@ -62,7 +75,7 @@ public class SampleGatherer {
// source = "in this day and
age";
// System.err.println("from " + source);
// System.err.println(" to " + SampleUtil.replace(source, from, to));
-//
+//
// }
/**
* Emit samples gathered from any input args.
@@ -88,7 +101,7 @@ public class SampleGatherer {
fos.close();
System.out.println("see file:///" + out);
}
-
+
/**
* Gather samples from a source file or directory
* @param source the File file or directory to start with
@@ -96,7 +109,7 @@ public class SampleGatherer {
* @return sink or a new Samples collection with any samples found
* @throws IOException if unable to read a source file
*/
- public static Samples gather(File source, Samples sink)
+ public static Samples gather(File source, Samples sink)
throws IOException {
if (null == sink) {
sink = new Samples();
@@ -122,8 +135,8 @@ public class SampleGatherer {
}
return line;
}
-
- private static void doGather(File source, Samples sink)
+
+ private static void doGather(File source, Samples sink)
throws IOException {
if (source.isFile()) {
if (isSource(source)) {
@@ -150,8 +163,8 @@ public class SampleGatherer {
}
return false;
}
-
- private static void gatherFromFile(final File source, final Samples sink)
+
+ private static void gatherFromFile(final File source, final Samples sink)
throws IOException {
Reader reader = null;
try {
@@ -185,7 +198,7 @@ public class SampleGatherer {
anchorName = anchorName.substring(0, loc);
}
continue;
- }
+ }
// found end?
loc = line.indexOf(END);
@@ -203,10 +216,10 @@ public class SampleGatherer {
endLine = lineNumber;
Sample sample = new Sample(anchorName,
anchorTitle,
- author,
- sampleCode.toString(),
- source,
- startLine,
+ author,
+ sampleCode.toString(),
+ source,
+ startLine,
endLine,
(String[]) flags.toArray(new String[flags.size()]));
sink.addSample(sample);
@@ -216,7 +229,7 @@ public class SampleGatherer {
startLine = -1;
endLine = Integer.MAX_VALUE;
continue;
- }
+ }
// found author?
loc = line.indexOf(AUTHOR);
@@ -228,7 +241,7 @@ public class SampleGatherer {
if (-1 != loc) {
flags.add(trimCommentEnd(line, loc + FLAG.length()));
}
-
+
// reading?
if ((-1 != startLine) && (-1 == endLine)) {
sampleCode.append(line);
@@ -272,21 +285,21 @@ class Sample {
public int compare(Sample left, Sample right) {
if (null == left) {
return (null == right ? 0 : -1);
- }
+ }
if (null == right) {
return 1;
- }
+ }
int result = left.anchorName.compareTo(right.anchorName);
if (0 != result) {
- return result;
+ return result;
}
result = left.sourcePath.compareTo(right.sourcePath);
if (0 != result) {
- return result;
+ return result;
}
result = right.startLine - left.startLine;
if (0 != result) {
- return result;
+ return result;
}
return right.endLine - left.endLine;
}
@@ -297,18 +310,18 @@ class Sample {
public int compare(Sample left, Sample right) {
if (null == left) {
return (null == right ? 0 : -1);
- }
+ }
if (null == right) {
return 1;
- }
+ }
int result = left.author.compareTo(right.author);
if (0 != result) {
- return result;
+ return result;
}
return NAME_SOURCE_COMPARER.compare(left,right);
}
};
-
+
final String anchorName;
final String anchorTitle;
final String author;
@@ -349,10 +362,10 @@ class Sample {
}
public static class Kind {
-
+
/** lowercase source suffixes identify files to gather samples from */
public static final String[] SOURCE_SUFFIXES = new String[]
- { ".java", ".aj", ".sh", ".ksh",
+ { ".java", ".aj", ".sh", ".ksh",
".txt", ".text", ".html", ".htm", ".xml" };
static final Kind XML = new Kind();
static final Kind HTML = new Kind();
@@ -404,7 +417,7 @@ class Samples {
List getSortedSamples() {
return getSortedSamples(Sample.NAME_SOURCE_COMPARER);
}
-
+
List getSortedSamples(Comparator comparer) {
ArrayList result = new ArrayList();
result.addAll(samples);
@@ -419,10 +432,10 @@ class Samples {
*/
class SamplesRenderer {
public static SamplesRenderer ME = new SamplesRenderer();
- protected SamplesRenderer() {
+ protected SamplesRenderer() {
}
public static final String EOL = "\n"; // XXX
- public static final String INFO =
+ public static final String INFO =
"This contains contributions from the AspectJ community of "
+ "
- sample code for AspectJ programs,
"
+ "- sample code for extensions to AspectJ tools using the public API's,
"
@@ -436,7 +449,7 @@ class SamplesRenderer {
+ "see the FAQ entry "
+ "\"buildingsource\".
";
- public static final String COPYRIGHT =
+ public static final String COPYRIGHT =
"Copyright 2003 Contributors. All Rights Reserved. "
+ "This sample code is made available under the Common Public "
+ "License version 1.0 available at "
+ ""
@@ -448,7 +461,7 @@ class SamplesRenderer {
+ "the source by reference to the AspectJ project home page "
+ " at http://eclipse.org/aspectj.
"
+ EOL;
-
+
/** template algorithm to render */
public final StringBuffer render(Samples samples, StringBuffer sink) {
if (null == sink) {
@@ -458,15 +471,15 @@ class SamplesRenderer {
return sink;
}
startList(samples, sink);
- List list = samples.getSortedSamples();
+ List list = samples.getSortedSamples();
String anchorName = null;
- for (ListIterator iter = list.listIterator();
+ for (ListIterator iter = list.listIterator();
iter.hasNext();) {
- Sample sample = (Sample) iter.next();
+ Sample sample = iter.next();
String newAnchorName = sample.anchorName;
- if ((null == anchorName)
+ if ((null == anchorName)
|| (!anchorName.equals(newAnchorName))) {
- endAnchorName(anchorName, sink);
+ endAnchorName(anchorName, sink);
startAnchorName(newAnchorName, sample.anchorTitle, sink);
anchorName = newAnchorName;
}
@@ -518,25 +531,25 @@ class SamplesRenderer {
class HTMLSamplesRenderer extends SamplesRenderer {
public static SamplesRenderer ME = new HTMLSamplesRenderer();
// XXX move these
- public static boolean doHierarchical = true;
- public static boolean doFlags = false;
+ public static boolean doHierarchical = true;
+ public static boolean doFlags = false;
+
-
final StringBuffer tableOfContents;
final StringBuffer sampleSection;
String[] lastAnchor = new String[0];
String currentAnchor;
String currentAuthor;
- protected HTMLSamplesRenderer() {
+ protected HTMLSamplesRenderer() {
sampleSection = new StringBuffer();
tableOfContents = new StringBuffer();
}
-
+
protected void startAnchorName(String name, String title, StringBuffer sink) {
if (doHierarchical) {
doContentTree(name);
- }
+ }
// ---- now do anchor
tableOfContents.append(" | " + currentAuthor);
sampleSection.append(EOL);
}
- sampleSection.append(" | ");
+ sampleSection.append(" | ");
sampleSection.append(SampleUtil.renderCodePath(sample.sourcePath));
sampleSection.append(":" + sample.startLine);
- sampleSection.append(" |");
+ sampleSection.append(" |");
sampleSection.append(EOL);
- sampleSection.append("");
+ sampleSection.append("
");
sampleSection.append(EOL);
if (doFlags) {
boolean flagHeaderDone = false;
@@ -609,7 +622,7 @@ class HTMLSamplesRenderer extends SamplesRenderer {
}
}
}
-
+
protected void renderXML(Sample sample) {
renderStandardHeader(sample);
sampleSection.append("
");
@@ -756,10 +769,10 @@ class HTMLSamplesRenderer extends SamplesRenderer {
tableOfContents.append(EOL);
tableOfContents.append("
");
tableOfContents.append(EOL);
-
+
renderHeading(prefixName, prefixName, sampleSection);
}
- lastAnchor = parts;
+ lastAnchor = parts;
}
protected void renderAuthorIndex(Samples samples, StringBuffer sink) {
@@ -803,22 +816,22 @@ class SampleUtil {
iter.hasNext();) {
Sample sample = (Sample) iter.next();
sink.append(i++ + ": " + sample);
- }
+ }
}
-
+
/** result struct for getPackagePath */
static class JavaFile {
/** input File possibly signifying a java file */
final File path;
-
- /** String java path suffix in form "com/company/Bar.java"
+
+ /** String java path suffix in form "com/company/Bar.java"
* null if this is not a java file
*/
final String javaPath;
-
+
/** any prefix before java path suffix in the original path */
final String prefix;
-
+
/** error handling */
final Throwable thrown;
JavaFile(File path, String javaPath, String prefix, Throwable thrown) {
@@ -874,7 +887,7 @@ class SampleUtil {
if (null != reader) {
try {
reader.close();
- } catch (IOException e1) {
+ } catch (IOException e1) {
// ignore
}
}
@@ -891,7 +904,7 @@ class SampleUtil {
}
return new JavaFile(path, javaPath, prefix, thrown);
}
-
+
/**
* Extract file path relative to base of package directory
* and directory in SAMPLE_BASE_DIR_NAME for this file.
@@ -901,10 +914,10 @@ class SampleUtil {
public static String renderCodePath(File path) {
JavaFile javaFile = getJavaFile(path);
if (javaFile.thrown != null) {
- throw new Error(javaFile.thrown.getClass()
+ throw new Error(javaFile.thrown.getClass()
+ ": " + javaFile.thrown.getMessage());
}
-
+
String file = javaFile.javaPath; // can be null...
String prefix = javaFile.prefix;
if (prefix == null) {
@@ -916,7 +929,7 @@ class SampleUtil {
throw new IllegalArgumentException(m + "?: " + path);
}
prefix = prefix.substring(loc + 1 + SAMPLE_BASE_DIR_NAME.length());
-
+
if (file == null) {
int slash = prefix.lastIndexOf('/');
if (-1 == slash) {
@@ -951,11 +964,11 @@ class SampleUtil {
}
return (one.length > two.length ? two.length : one.length);
}
-
+
public static String[] splitAnchorName(Sample sample) {
return splitAnchorName(sample.anchorName);
}
-
+
public static String[] splitAnchorName(String anchorName) {
ArrayList result = new ArrayList();
int start = 0;
@@ -969,7 +982,7 @@ class SampleUtil {
}
next = anchorName.substring(start);
result.add(next);
- return (String[]) result.toArray(new String[result.size()]);
+ return result.toArray(new String[result.size()]);
}
/**
* Replace literals with literals in source string
@@ -1008,8 +1021,8 @@ class SampleUtil {
public static void render(
Sample sample,
- String fieldDelim,
- String valueDelim,
+ String fieldDelim,
+ String valueDelim,
StringBuffer sink) {
if ((null == sink) || (null == sample)) {
return;
diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Util.java b/build/src/main/java/org/aspectj/internal/tools/build/Util.java
index 2fc2dcb72..9a1eb9abc 100644
--- a/build/src/main/java/org/aspectj/internal/tools/build/Util.java
+++ b/build/src/main/java/org/aspectj/internal/tools/build/Util.java
@@ -1,29 +1,36 @@
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
-
+
package org.aspectj.internal.tools.build;
-import java.io.*;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import java.util.jar.Attributes;
-import java.util.jar.Manifest;
import java.util.jar.Attributes.Name;
+import java.util.jar.Manifest;
-/**
+/**
* Build-only utilities.
* Many mirror utils module APIs.
*/
@@ -45,8 +52,8 @@ public class Util {
JAVA5_VM = java5VM;
}
- /**
- * Map version in long form to short,
+ /**
+ * Map version in long form to short,
* e.g., replacing "alpha" with "a"
*/
public static String shortVersion(String version) {
@@ -57,7 +64,7 @@ public class Util {
version = Util.replace(version, "dev", "d");
return version;
}
-
+
/**
* Replace any instances of {replace} in {input} with {with}.
* @param input the String to search/replace
@@ -92,35 +99,35 @@ public class Util {
}
return passed;
}
-
+
/** @throws IllegalArgumentException if cannot read dir */
public static void iaxIfNotCanReadDir(File dir, String name) {
if (!canReadDir(dir)) {
throw new IllegalArgumentException(name + " dir not readable: " + dir);
}
}
-
+
/** @throws IllegalArgumentException if cannot read file */
public static void iaxIfNotCanReadFile(File file, String name) {
if (!canReadFile(file)) {
throw new IllegalArgumentException(name + " file not readable: " + file);
}
}
-
+
/** @throws IllegalArgumentException if cannot write dir */
public static void iaxIfNotCanWriteDir(File dir, String name) {
if (!canWriteDir(dir)) {
throw new IllegalArgumentException(name + " dir not writeable: " + dir);
}
}
-
+
/** @throws IllegalArgumentException if input is null */
public static void iaxIfNull(Object input, String name) {
if (null == input) {
throw new IllegalArgumentException("null " + name);
}
}
-
+
/** render exception to String */
public static String renderException(Throwable thrown) {
if (null == thrown) {
@@ -129,16 +136,16 @@ public class Util {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
pw.println(thrown.getMessage());
- thrown.printStackTrace(pw);
+ thrown.printStackTrace(pw);
pw.flush();
- return sw.getBuffer().toString();
+ return sw.getBuffer().toString();
}
-
+
/** @return true if dir is a writable directory */
public static boolean canWriteDir(File dir) {
return (null != dir) && dir.canWrite() && dir.isDirectory();
}
-
+
public static String path(String first, String second) {
return first + File.separator + second;
}
@@ -155,31 +162,31 @@ public class Util {
}
return sb.toString();
}
-
+
/** @return true if dir is a readable directory */
public static boolean canReadDir(File dir) {
return (null != dir) && dir.canRead() && dir.isDirectory();
}
-
+
/** @return true if dir is a readable file */
public static boolean canReadFile(File file) {
return (null != file) && file.canRead() && file.isFile();
}
-
- /**
+
+ /**
* Delete file or directory.
* @param dir the File file or directory to delete.
- * @return true if all contents of dir were deleted
+ * @return true if all contents of dir were deleted
*/
public static boolean delete(File dir) {
return deleteContents(dir) && dir.delete();
}
-
- /**
+
+ /**
* Delete contents of directory.
* The directory itself is not deleted.
* @param dir the File directory whose contents should be deleted.
- * @return true if all contents of dir were deleted
+ * @return true if all contents of dir were deleted
*/
public static boolean deleteContents(File dir) {
if ((null == dir) || !dir.canWrite()) {
@@ -194,7 +201,7 @@ public class Util {
}
return true;
}
-
+
/** @return File temporary directory with the given prefix */
public static File makeTempDir(String prefix) {
if (null == prefix) {
@@ -203,7 +210,7 @@ public class Util {
File tempFile = null;
for (int i = 0; i < 10; i++) {
try {
- tempFile = File.createTempFile(prefix,"tmp");
+ tempFile = File.createTempFile(prefix,"tmp");
tempFile.delete();
if (tempFile.mkdirs()) {
break;
@@ -212,12 +219,12 @@ public class Util {
} catch (IOException e) {
}
}
- return tempFile;
+ return tempFile;
}
/**
* Close stream with the usual checks.
- * @param stream the InputStream to close - ignored if null
- * @return null if closed without IOException, message otherwise
+ * @param stream the InputStream to close - ignored if null
+ * @return null if closed without IOException, message otherwise
*/
public static String close(Writer stream) {
String result = null;
@@ -323,12 +330,12 @@ public class Util {
/**
* Support for OSGI bundles read from manifest files.
- * Currently very limited, and will only support the subset of
+ * Currently very limited, and will only support the subset of
* features that we use.
* sources:
* http://www-128.ibm.com/developerworks/library/os-ecl-osgi/index.html
* http://help.eclipse.org/help30/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/osgi/org/osgi/framework/Constants.html
- */
+ */
public static class OSGIBundle {
public static final Name BUNDLE_NAME = new Name("Bundle-Name");
@@ -348,9 +355,9 @@ public class Util {
public static final Name BUNDLE_CLASSPATH = new Name("Bundle-ClassPath");
/** unmodifiable list of all valid OSGIBundle Name's */
- public static final List NAMES;
+ public static final List NAMES;
static {
- ArrayList names = new ArrayList();
+ ArrayList names = new ArrayList<>();
names.add(BUNDLE_NAME);
names.add(BUNDLE_SYMBOLIC_NAME);
names.add(BUNDLE_VERSION);
@@ -367,7 +374,7 @@ public class Util {
private final Attributes attributes;
/**
- *
+ *
* @param manifestInputStream
* the InputStream of the manifest.mf - will be closed.
* @throws IOException
@@ -414,7 +421,7 @@ public class Util {
int skips = 0;
while (st.hasMoreTokens()) {
String token = st.nextToken();
- int first = token.indexOf("\"");
+ int first = token.indexOf("\"");
if (-1 != first) {
if (!st.hasMoreTokens()) {
throw new IllegalArgumentException(token);
@@ -434,18 +441,18 @@ public class Util {
}
/**
- * Wrap each dependency on another bundle
+ * Wrap each dependency on another bundle
*/
public static class RequiredBundle {
-
+
/** unparsed entry text, for debugging */
final String text;
-
+
/** Symbolic name of the required bundle */
final String name;
/** if not null, then start/end versions of required bundle
- * in the format of the corresponding manifest entry
+ * in the format of the corresponding manifest entry
*/
final String versions;
@@ -472,7 +479,7 @@ public class Util {
int start = RESOLUTION.length();
int end = token.length();
opt = token.substring(start, end);
- }
+ }
}
versions = vers;
optional = "optional".equals(opt);
--
cgit v1.2.3