@@ -86,7 +86,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
/** | |||
* The name of the resource being searched for. | |||
*/ | |||
private String resourceName; | |||
private final String resourceName; | |||
/** | |||
* The index of the next classpath element to search. | |||
@@ -106,7 +106,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param name the name of the resource to search for. | |||
*/ | |||
ResourceEnumeration(String name) { | |||
ResourceEnumeration(final String name) { | |||
this.resourceName = name; | |||
this.pathElementsIndex = 0; | |||
findNextResource(); | |||
@@ -119,7 +119,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @return <code>true</code> if there are more elements in the | |||
* enumeration; <code>false</code> otherwise. | |||
*/ | |||
public boolean hasMoreElements() { | |||
@Override | |||
public boolean hasMoreElements() { | |||
return (this.nextResource != null); | |||
} | |||
@@ -128,8 +129,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @return the next resource in the enumeration | |||
*/ | |||
public URL nextElement() { | |||
URL ret = this.nextResource; | |||
@Override | |||
public URL nextElement() { | |||
final URL ret = this.nextResource; | |||
if (ret == null) { | |||
throw new NoSuchElementException(); | |||
} | |||
@@ -147,10 +149,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
URL url = null; | |||
while ((pathElementsIndex < pathComponents.size()) && (url == null)) { | |||
try { | |||
File pathComponent = (File) pathComponents.elementAt(pathElementsIndex); | |||
final File pathComponent = pathComponents.elementAt(pathElementsIndex); | |||
url = getResourceURL(pathComponent, this.resourceName); | |||
pathElementsIndex++; | |||
} catch (BuildException e) { | |||
} catch (final BuildException e) { | |||
// ignore path elements which are not valid relative to the | |||
// project | |||
} | |||
@@ -173,7 +175,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* The components of the classpath that the classloader searches | |||
* for classes. | |||
*/ | |||
private Vector<File> pathComponents = new VectorSet<File>(); | |||
private final Vector<File> pathComponents = new VectorSet<File>(); | |||
/** | |||
* The project to which this class loader belongs. | |||
@@ -191,14 +193,14 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* loader regardless of whether the parent class loader is being searched | |||
* first or not. | |||
*/ | |||
private Vector<String> systemPackages = new Vector<String>(); | |||
private final Vector<String> systemPackages = new Vector<String>(); | |||
/** | |||
* These are the package roots that are to be loaded by this class loader | |||
* regardless of whether the parent class loader is being searched first | |||
* or not. | |||
*/ | |||
private Vector<String> loaderPackages = new Vector<String>(); | |||
private final Vector<String> loaderPackages = new Vector<String>(); | |||
/** | |||
* Whether or not this classloader will ignore the base | |||
@@ -219,7 +221,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
private Hashtable<File, JarFile> jarFiles = new Hashtable<File, JarFile>(); | |||
/** Static map of jar file/time to manifest class-path entries */ | |||
private static Map<String,String> pathMap = Collections.synchronizedMap(new HashMap<String, String>()); | |||
private static Map<String, String> pathMap = | |||
Collections.synchronizedMap(new HashMap<String, String>()); | |||
/** | |||
* The context loader saved when setting the thread's current | |||
@@ -241,7 +244,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* belong. | |||
* @param classpath The classpath to use to load classes. | |||
*/ | |||
public AntClassLoader(ClassLoader parent, Project project, Path classpath) { | |||
public AntClassLoader(final ClassLoader parent, final Project project, final Path classpath) { | |||
setParent(parent); | |||
setClassPath(classpath); | |||
setProject(project); | |||
@@ -265,7 +268,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* May be <code>null</code>, in which case no path | |||
* elements are set up to start with. | |||
*/ | |||
public AntClassLoader(Project project, Path classpath) { | |||
public AntClassLoader(final Project project, final Path classpath) { | |||
setParent(null); | |||
setProject(project); | |||
setClassPath(classpath); | |||
@@ -288,7 +291,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* load the a class through this loader. | |||
*/ | |||
public AntClassLoader( | |||
ClassLoader parent, Project project, Path classpath, boolean parentFirst) { | |||
final ClassLoader parent, final Project project, final Path classpath, final boolean parentFirst) { | |||
this(project, classpath); | |||
if (parent != null) { | |||
setParent(parent); | |||
@@ -309,7 +312,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* classloader should be consulted before trying to | |||
* load the a class through this loader. | |||
*/ | |||
public AntClassLoader(Project project, Path classpath, boolean parentFirst) { | |||
public AntClassLoader(final Project project, final Path classpath, final boolean parentFirst) { | |||
this(null, project, classpath, parentFirst); | |||
} | |||
@@ -326,7 +329,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* classloader should be consulted before trying to | |||
* load the a class through this loader. | |||
*/ | |||
public AntClassLoader(ClassLoader parent, boolean parentFirst) { | |||
public AntClassLoader(final ClassLoader parent, final boolean parentFirst) { | |||
setParent(parent); | |||
project = null; | |||
this.parentFirst = parentFirst; | |||
@@ -337,7 +340,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param project the project instance | |||
*/ | |||
public void setProject(Project project) { | |||
public void setProject(final Project project) { | |||
this.project = project; | |||
if (project != null) { | |||
project.addBuildListener(this); | |||
@@ -351,15 +354,15 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @param classpath the search classpath consisting of directories and | |||
* jar/zip files. | |||
*/ | |||
public void setClassPath(Path classpath) { | |||
public void setClassPath(final Path classpath) { | |||
pathComponents.removeAllElements(); | |||
if (classpath != null) { | |||
Path actualClasspath = classpath.concatSystemClasspath("ignore"); | |||
String[] pathElements = actualClasspath.list(); | |||
final Path actualClasspath = classpath.concatSystemClasspath("ignore"); | |||
final String[] pathElements = actualClasspath.list(); | |||
for (int i = 0; i < pathElements.length; ++i) { | |||
try { | |||
addPathElement(pathElements[i]); | |||
} catch (BuildException e) { | |||
} catch (final BuildException e) { | |||
// ignore path elements which are invalid | |||
// relative to the project | |||
} | |||
@@ -373,7 +376,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param parent the parent class loader. | |||
*/ | |||
public void setParent(ClassLoader parent) { | |||
public void setParent(final ClassLoader parent) { | |||
this.parent = parent == null ? AntClassLoader.class.getClassLoader() : parent; | |||
} | |||
@@ -385,7 +388,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @param parentFirst if true, delegate initial class search to the parent | |||
* classloader. | |||
*/ | |||
public void setParentFirst(boolean parentFirst) { | |||
public void setParentFirst(final boolean parentFirst) { | |||
this.parentFirst = parentFirst; | |||
} | |||
@@ -397,7 +400,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param priority The logging priority of the message. | |||
*/ | |||
protected void log(String message, int priority) { | |||
protected void log(final String message, final int priority) { | |||
if (project != null) { | |||
project.log(message, priority); | |||
} | |||
@@ -443,12 +446,12 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @exception BuildException if the given path element cannot be resolved | |||
* against the project. | |||
*/ | |||
public void addPathElement(String pathElement) throws BuildException { | |||
File pathComponent = project != null ? project.resolveFile(pathElement) : new File( | |||
public void addPathElement(final String pathElement) throws BuildException { | |||
final File pathComponent = project != null ? project.resolveFile(pathElement) : new File( | |||
pathElement); | |||
try { | |||
addPathFile(pathComponent); | |||
} catch (IOException e) { | |||
} catch (final IOException e) { | |||
throw new BuildException(e); | |||
} | |||
} | |||
@@ -460,7 +463,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* their CLASSPATH entry in the manifest file. | |||
* @param file the jar file or directory to add. | |||
*/ | |||
public void addPathComponent(File file) { | |||
public void addPathComponent(final File file) { | |||
if (pathComponents.contains(file)) { | |||
return; | |||
} | |||
@@ -477,7 +480,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @throws IOException if data needed from the file cannot be read. | |||
*/ | |||
protected void addPathFile(File pathComponent) throws IOException { | |||
protected void addPathFile(final File pathComponent) throws IOException { | |||
if (!pathComponents.contains(pathComponent)) { | |||
pathComponents.addElement(pathComponent); | |||
} | |||
@@ -485,14 +488,14 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
return; | |||
} | |||
String absPathPlusTimeAndLength = pathComponent.getAbsolutePath() | |||
final String absPathPlusTimeAndLength = pathComponent.getAbsolutePath() | |||
+ pathComponent.lastModified() + "-" + pathComponent.length(); | |||
String classpath = (String) pathMap.get(absPathPlusTimeAndLength); | |||
String classpath = pathMap.get(absPathPlusTimeAndLength); | |||
if (classpath == null) { | |||
JarFile jarFile = null; | |||
try { | |||
jarFile = new JarFile(pathComponent); | |||
Manifest manifest = jarFile.getManifest(); | |||
final Manifest manifest = jarFile.getManifest(); | |||
if (manifest == null) { | |||
return; | |||
} | |||
@@ -510,19 +513,19 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
} | |||
if (!"".equals(classpath)) { | |||
URL baseURL = FILE_UTILS.getFileURL(pathComponent); | |||
StringTokenizer st = new StringTokenizer(classpath); | |||
final URL baseURL = FILE_UTILS.getFileURL(pathComponent); | |||
final StringTokenizer st = new StringTokenizer(classpath); | |||
while (st.hasMoreTokens()) { | |||
String classpathElement = st.nextToken(); | |||
URL libraryURL = new URL(baseURL, classpathElement); | |||
final String classpathElement = st.nextToken(); | |||
final URL libraryURL = new URL(baseURL, classpathElement); | |||
if (!libraryURL.getProtocol().equals("file")) { | |||
log("Skipping jar library " + classpathElement | |||
+ " since only relative URLs are supported by this" + " loader", | |||
Project.MSG_VERBOSE); | |||
continue; | |||
} | |||
String decodedPath = Locator.decodeUri(libraryURL.getFile()); | |||
File libraryFile = new File(decodedPath); | |||
final String decodedPath = Locator.decodeUri(libraryURL.getFile()); | |||
final File libraryFile = new File(decodedPath); | |||
if (libraryFile.exists() && !isInPath(libraryFile)) { | |||
addPathFile(libraryFile); | |||
} | |||
@@ -539,7 +542,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
public String getClasspath() { | |||
final StringBuilder sb = new StringBuilder(); | |||
boolean firstPass = true; | |||
Enumeration<File> componentEnum = pathComponents.elements(); | |||
final Enumeration<File> componentEnum = pathComponents.elements(); | |||
while (componentEnum.hasMoreElements()) { | |||
if (!firstPass) { | |||
sb.append(System.getProperty("path.separator")); | |||
@@ -560,7 +563,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @param isolated Whether or not this classloader should run in | |||
* isolated mode. | |||
*/ | |||
public synchronized void setIsolated(boolean isolated) { | |||
public synchronized void setIsolated(final boolean isolated) { | |||
ignoreBase = isolated; | |||
} | |||
@@ -574,7 +577,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @deprecated since 1.6.x. | |||
* Use Class.forName with initialize=true instead. | |||
*/ | |||
public static void initializeClass(Class<?> theClass) { | |||
@Deprecated | |||
public static void initializeClass(final Class<?> theClass) { | |||
// ***HACK*** We ask the VM to create an instance | |||
// by voluntarily providing illegal arguments to force | |||
// the VM to run the class' static initializer, while | |||
@@ -589,7 +593,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
cons[0].newInstance((Object[]) strs); | |||
// Expecting an exception to be thrown by this call: | |||
// IllegalArgumentException: wrong number of Arguments | |||
} catch (Exception e) { | |||
} catch (final Exception e) { | |||
// Ignore - we are interested only in the side | |||
// effect - that of getting the static initializers | |||
// invoked. As we do not want to call a valid | |||
@@ -616,7 +620,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @param packageRoot The root of all packages to be included. | |||
* Should not be <code>null</code>. | |||
*/ | |||
public void addSystemPackageRoot(String packageRoot) { | |||
public void addSystemPackageRoot(final String packageRoot) { | |||
systemPackages.addElement(packageRoot + (packageRoot.endsWith(".") ? "" : ".")); | |||
} | |||
@@ -629,7 +633,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @param packageRoot The root of all packages to be included. | |||
* Should not be <code>null</code>. | |||
*/ | |||
public void addLoaderPackageRoot(String packageRoot) { | |||
public void addLoaderPackageRoot(final String packageRoot) { | |||
loaderPackages.addElement(packageRoot + (packageRoot.endsWith(".") ? "" : ".")); | |||
} | |||
@@ -648,7 +652,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @exception ClassNotFoundException if the requested class does not exist | |||
* on this loader's classpath. | |||
*/ | |||
public Class<?> forceLoadClass(String classname) throws ClassNotFoundException { | |||
public Class<?> forceLoadClass(final String classname) throws ClassNotFoundException { | |||
log("force loading " + classname, Project.MSG_DEBUG); | |||
Class<?> theClass = findLoadedClass(classname); | |||
@@ -675,7 +679,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @exception ClassNotFoundException if the requested class does not exist | |||
* on this loader's classpath. | |||
*/ | |||
public Class<?> forceLoadSystemClass(String classname) throws ClassNotFoundException { | |||
public Class<?> forceLoadSystemClass(final String classname) throws ClassNotFoundException { | |||
log("force system loading " + classname, Project.MSG_DEBUG); | |||
Class<?> theClass = findLoadedClass(classname); | |||
@@ -695,7 +699,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @return a stream to the required resource or <code>null</code> if the | |||
* resource cannot be found on the loader's classpath. | |||
*/ | |||
public InputStream getResourceAsStream(String name) { | |||
@Override | |||
public InputStream getResourceAsStream(final String name) { | |||
InputStream resourceStream = null; | |||
if (isParentFirst(name)) { | |||
resourceStream = loadBaseResource(name); | |||
@@ -712,7 +717,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
} | |||
if (resourceStream == null && !isParentFirst(name)) { | |||
if (ignoreBase) { | |||
resourceStream = getRootLoader() == null ? null : getRootLoader().getResourceAsStream(name); | |||
resourceStream = getRootLoader() == null | |||
? null | |||
: getRootLoader().getResourceAsStream(name); | |||
} else { | |||
resourceStream = loadBaseResource(name); | |||
} | |||
@@ -736,14 +743,14 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @return a stream to the required resource or <code>null</code> if | |||
* the resource cannot be found on the loader's classpath. | |||
*/ | |||
private InputStream loadResource(String name) { | |||
private InputStream loadResource(final String name) { | |||
// we need to search the components of the path to see if we can | |||
// find the class we want. | |||
InputStream stream = null; | |||
Enumeration<File> e = pathComponents.elements(); | |||
final Enumeration<File> e = pathComponents.elements(); | |||
while (e.hasMoreElements() && stream == null) { | |||
File pathComponent = e.nextElement(); | |||
final File pathComponent = e.nextElement(); | |||
stream = getResourceStream(pathComponent, name); | |||
} | |||
return stream; | |||
@@ -759,7 +766,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @return a stream to the named resource, or <code>null</code> if | |||
* the resource cannot be found. | |||
*/ | |||
private InputStream loadBaseResource(String name) { | |||
private InputStream loadBaseResource(final String name) { | |||
return parent == null ? super.getResourceAsStream(name) : parent.getResourceAsStream(name); | |||
} | |||
@@ -775,11 +782,11 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @return a stream to the required resource or <code>null</code> if | |||
* the resource cannot be found in the given file. | |||
*/ | |||
private InputStream getResourceStream(File file, String resourceName) { | |||
private InputStream getResourceStream(final File file, final String resourceName) { | |||
try { | |||
JarFile jarFile = (JarFile) jarFiles.get(file); | |||
JarFile jarFile = jarFiles.get(file); | |||
if (jarFile == null && file.isDirectory()) { | |||
File resource = new File(file, resourceName); | |||
final File resource = new File(file, resourceName); | |||
if (resource.exists()) { | |||
return new FileInputStream(resource); | |||
} | |||
@@ -793,14 +800,14 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
} | |||
//to eliminate a race condition, retrieve the entry | |||
//that is in the hash table under that filename | |||
jarFile = (JarFile) jarFiles.get(file); | |||
jarFile = jarFiles.get(file); | |||
} | |||
JarEntry entry = jarFile.getJarEntry(resourceName); | |||
final JarEntry entry = jarFile.getJarEntry(resourceName); | |||
if (entry != null) { | |||
return jarFile.getInputStream(entry); | |||
} | |||
} | |||
} catch (Exception e) { | |||
} catch (final Exception e) { | |||
log("Ignoring Exception " + e.getClass().getName() + ": " + e.getMessage() | |||
+ " reading resource " + resourceName + " from " + file, Project.MSG_VERBOSE); | |||
} | |||
@@ -820,7 +827,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @return whether or not the parent classloader should be checked for a | |||
* resource before this one is. | |||
*/ | |||
private boolean isParentFirst(String resourceName) { | |||
private boolean isParentFirst(final String resourceName) { | |||
// default to the global setting and then see | |||
// if this class belongs to a package which has been | |||
// designated to use a specific loader first | |||
@@ -830,15 +837,15 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
boolean useParentFirst = parentFirst; | |||
for (Enumeration<String> e = systemPackages.elements(); e.hasMoreElements();) { | |||
String packageName = e.nextElement(); | |||
for (final Enumeration<String> e = systemPackages.elements(); e.hasMoreElements();) { | |||
final String packageName = e.nextElement(); | |||
if (resourceName.startsWith(packageName)) { | |||
useParentFirst = true; | |||
break; | |||
} | |||
} | |||
for (Enumeration<String> e = loaderPackages.elements(); e.hasMoreElements();) { | |||
String packageName = e.nextElement(); | |||
for (final Enumeration<String> e = loaderPackages.elements(); e.hasMoreElements();) { | |||
final String packageName = e.nextElement(); | |||
if (resourceName.startsWith(packageName)) { | |||
useParentFirst = false; | |||
break; | |||
@@ -871,7 +878,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* resource could not be found or the caller doesn't have | |||
* adequate privileges to get the resource. | |||
*/ | |||
public URL getResource(String name) { | |||
@Override | |||
public URL getResource(final String name) { | |||
// we need to search the components of the path to see if | |||
// we can find the class we want. | |||
URL url = null; | |||
@@ -883,9 +891,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
} else { | |||
// try and load from this loader if the parent either didn't find | |||
// it or wasn't consulted. | |||
Enumeration<File> e = pathComponents.elements(); | |||
final Enumeration<File> e = pathComponents.elements(); | |||
while (e.hasMoreElements() && url == null) { | |||
File pathComponent = e.nextElement(); | |||
final File pathComponent = e.nextElement(); | |||
url = getResourceURL(pathComponent, name); | |||
if (url != null) { | |||
log("Resource " + name + " loaded from ant loader", Project.MSG_DEBUG); | |||
@@ -917,9 +925,13 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* <p>Would override getResources if that wasn't final in Java | |||
* 1.4.</p> | |||
* | |||
* @param name name of the resource | |||
* @return possible URLs as enumeration | |||
* @throws IOException | |||
* @see {@link #findResources(String, boolean)} | |||
* @since Ant 1.8.0 | |||
*/ | |||
public Enumeration<URL> getNamedResources(String name) | |||
public Enumeration<URL> getNamedResources(final String name) | |||
throws IOException { | |||
return findResources(name, false); | |||
} | |||
@@ -933,7 +945,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @return an enumeration of URLs for the resources | |||
* @exception IOException if I/O errors occurs (can't happen) | |||
*/ | |||
protected Enumeration<URL> findResources(String name) throws IOException { | |||
@Override | |||
protected Enumeration<URL> findResources(final String name) throws IOException { | |||
return findResources(name, true); | |||
} | |||
@@ -949,10 +962,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @return an enumeration of URLs for the resources | |||
* @exception IOException if I/O errors occurs (can't happen) | |||
*/ | |||
protected Enumeration<URL> findResources(String name, | |||
boolean parentHasBeenSearched) | |||
protected Enumeration<URL> findResources(final String name, | |||
final boolean parentHasBeenSearched) | |||
throws IOException { | |||
Enumeration<URL> mine = new ResourceEnumeration(name); | |||
final Enumeration<URL> mine = new ResourceEnumeration(name); | |||
Enumeration<URL> base; | |||
if (parent != null && (!parentHasBeenSearched || parent != getParent())) { | |||
// Delegate to the parent: | |||
@@ -989,16 +1002,16 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @return a stream to the required resource or <code>null</code> if the | |||
* resource cannot be found in the given file object. | |||
*/ | |||
protected URL getResourceURL(File file, String resourceName) { | |||
protected URL getResourceURL(final File file, final String resourceName) { | |||
try { | |||
JarFile jarFile = (JarFile) jarFiles.get(file); | |||
JarFile jarFile = jarFiles.get(file); | |||
if (jarFile == null && file.isDirectory()) { | |||
File resource = new File(file, resourceName); | |||
final File resource = new File(file, resourceName); | |||
if (resource.exists()) { | |||
try { | |||
return FILE_UTILS.getFileURL(resource); | |||
} catch (MalformedURLException ex) { | |||
} catch (final MalformedURLException ex) { | |||
return null; | |||
} | |||
} | |||
@@ -1006,7 +1019,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
if (jarFile == null) { | |||
if (file.exists()) { | |||
if (!isZip(file)) { | |||
String msg = "CLASSPATH element " + file | |||
final String msg = "CLASSPATH element " + file | |||
+ " is not a JAR."; | |||
log(msg, Project.MSG_WARN); | |||
System.err.println(msg); | |||
@@ -1018,19 +1031,19 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
return null; | |||
} | |||
// potential race-condition | |||
jarFile = (JarFile) jarFiles.get(file); | |||
jarFile = jarFiles.get(file); | |||
} | |||
JarEntry entry = jarFile.getJarEntry(resourceName); | |||
final JarEntry entry = jarFile.getJarEntry(resourceName); | |||
if (entry != null) { | |||
try { | |||
return new URL("jar:" + FILE_UTILS.getFileURL(file) + "!/" + entry); | |||
} catch (MalformedURLException ex) { | |||
} catch (final MalformedURLException ex) { | |||
return null; | |||
} | |||
} | |||
} | |||
} catch (Exception e) { | |||
String msg = "Unable to obtain resource from " + file + ": "; | |||
} catch (final Exception e) { | |||
final String msg = "Unable to obtain resource from " + file + ": "; | |||
log(msg + e, Project.MSG_WARN); | |||
System.err.println(msg); | |||
e.printStackTrace(); | |||
@@ -1058,7 +1071,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* on the system classpath (when not in isolated mode) or this loader's | |||
* classpath. | |||
*/ | |||
protected synchronized Class<?> loadClass(String classname, boolean resolve) | |||
@Override | |||
protected synchronized Class<?> loadClass(final String classname, final boolean resolve) | |||
throws ClassNotFoundException { | |||
// 'sync' is needed - otherwise 2 threads can load the same class | |||
// twice, resulting in LinkageError: duplicated class definition. | |||
@@ -1073,7 +1087,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
theClass = findBaseClass(classname); | |||
log("Class " + classname + " loaded from parent loader " + "(parentFirst)", | |||
Project.MSG_DEBUG); | |||
} catch (ClassNotFoundException cnfe) { | |||
} catch (final ClassNotFoundException cnfe) { | |||
theClass = findClass(classname); | |||
log("Class " + classname + " loaded from ant loader " + "(parentFirst)", | |||
Project.MSG_DEBUG); | |||
@@ -1082,7 +1096,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
try { | |||
theClass = findClass(classname); | |||
log("Class " + classname + " loaded from ant loader", Project.MSG_DEBUG); | |||
} catch (ClassNotFoundException cnfe) { | |||
} catch (final ClassNotFoundException cnfe) { | |||
if (ignoreBase) { | |||
throw cnfe; | |||
} | |||
@@ -1105,7 +1119,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @return the classname in filesystem format (eg java/lang/Integer.class) | |||
*/ | |||
private String getClassFilename(String classname) { | |||
private String getClassFilename(final String classname) { | |||
return classname.replace('.', '/') + ".class"; | |||
} | |||
@@ -1122,15 +1136,15 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @throws IOException if the class data cannot be read. | |||
*/ | |||
protected Class<?> defineClassFromData(File container, byte[] classData, String classname) | |||
protected Class<?> defineClassFromData(final File container, final byte[] classData, final String classname) | |||
throws IOException { | |||
definePackage(container, classname); | |||
ProtectionDomain currentPd = Project.class.getProtectionDomain(); | |||
String classResource = getClassFilename(classname); | |||
CodeSource src = new CodeSource(FILE_UTILS.getFileURL(container), | |||
final ProtectionDomain currentPd = Project.class.getProtectionDomain(); | |||
final String classResource = getClassFilename(classname); | |||
final CodeSource src = new CodeSource(FILE_UTILS.getFileURL(container), | |||
getCertificates(container, | |||
classResource)); | |||
ProtectionDomain classesPd = | |||
final ProtectionDomain classesPd = | |||
new ProtectionDomain(src, currentPd.getPermissions(), | |||
this, | |||
currentPd.getPrincipals()); | |||
@@ -1148,18 +1162,18 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @exception IOException if the package information cannot be read from the | |||
* container. | |||
*/ | |||
protected void definePackage(File container, String className) throws IOException { | |||
int classIndex = className.lastIndexOf('.'); | |||
protected void definePackage(final File container, final String className) throws IOException { | |||
final int classIndex = className.lastIndexOf('.'); | |||
if (classIndex == -1) { | |||
return; | |||
} | |||
String packageName = className.substring(0, classIndex); | |||
final String packageName = className.substring(0, classIndex); | |||
if (getPackage(packageName) != null) { | |||
// already defined | |||
return; | |||
} | |||
// define the package now | |||
Manifest manifest = getJarManifest(container); | |||
final Manifest manifest = getJarManifest(container); | |||
if (manifest == null) { | |||
definePackage(packageName, null, null, null, null, null, null, null); | |||
@@ -1179,11 +1193,11 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @exception IOException if the manifest cannot be read. | |||
*/ | |||
private Manifest getJarManifest(File container) throws IOException { | |||
private Manifest getJarManifest(final File container) throws IOException { | |||
if (container.isDirectory()) { | |||
return null; | |||
} | |||
JarFile jarFile = (JarFile) jarFiles.get(container); | |||
final JarFile jarFile = jarFiles.get(container); | |||
if (jarFile == null) { | |||
return null; | |||
} | |||
@@ -1201,16 +1215,16 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @exception IOException if the manifest cannot be read. | |||
*/ | |||
private Certificate[] getCertificates(File container, String entry) | |||
private Certificate[] getCertificates(final File container, final String entry) | |||
throws IOException { | |||
if (container.isDirectory()) { | |||
return null; | |||
} | |||
JarFile jarFile = (JarFile) jarFiles.get(container); | |||
final JarFile jarFile = jarFiles.get(container); | |||
if (jarFile == null) { | |||
return null; | |||
} | |||
JarEntry ent = jarFile.getJarEntry(entry); | |||
final JarEntry ent = jarFile.getJarEntry(entry); | |||
return ent == null ? null : ent.getCertificates(); | |||
} | |||
@@ -1222,8 +1236,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @param packageName the name of the package being defined. | |||
* @param manifest the jar's manifest | |||
*/ | |||
protected void definePackage(File container, String packageName, Manifest manifest) { | |||
String sectionName = packageName.replace('.', '/') + "/"; | |||
protected void definePackage(final File container, final String packageName, final Manifest manifest) { | |||
final String sectionName = packageName.replace('.', '/') + "/"; | |||
String specificationTitle = null; | |||
String specificationVendor = null; | |||
@@ -1234,7 +1248,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
String sealedString = null; | |||
URL sealBase = null; | |||
Attributes sectionAttributes = manifest.getAttributes(sectionName); | |||
final Attributes sectionAttributes = manifest.getAttributes(sectionName); | |||
if (sectionAttributes != null) { | |||
specificationTitle = sectionAttributes.getValue(Name.SPECIFICATION_TITLE); | |||
specificationVendor = sectionAttributes.getValue(Name.SPECIFICATION_VENDOR); | |||
@@ -1244,7 +1258,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
implementationVersion = sectionAttributes.getValue(Name.IMPLEMENTATION_VERSION); | |||
sealedString = sectionAttributes.getValue(Name.SEALED); | |||
} | |||
Attributes mainAttributes = manifest.getMainAttributes(); | |||
final Attributes mainAttributes = manifest.getMainAttributes(); | |||
if (mainAttributes != null) { | |||
if (specificationTitle == null) { | |||
specificationTitle = mainAttributes.getValue(Name.SPECIFICATION_TITLE); | |||
@@ -1271,7 +1285,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
if (sealedString != null && sealedString.equalsIgnoreCase("true")) { | |||
try { | |||
sealBase = new URL(FileUtils.getFileUtils().toURI(container.getAbsolutePath())); | |||
} catch (MalformedURLException e) { | |||
} catch (final MalformedURLException e) { | |||
// ignore | |||
} | |||
} | |||
@@ -1295,16 +1309,16 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @exception SecurityException if there is a security problem while | |||
* reading the class from the stream. | |||
*/ | |||
private Class<?> getClassFromStream(InputStream stream, String classname, File container) | |||
private Class<?> getClassFromStream(final InputStream stream, final String classname, final File container) | |||
throws IOException, SecurityException { | |||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||
int bytesRead = -1; | |||
byte[] buffer = new byte[BUFFER_SIZE]; | |||
final byte[] buffer = new byte[BUFFER_SIZE]; | |||
while ((bytesRead = stream.read(buffer, 0, BUFFER_SIZE)) != -1) { | |||
baos.write(buffer, 0, bytesRead); | |||
} | |||
byte[] classData = baos.toByteArray(); | |||
final byte[] classData = baos.toByteArray(); | |||
return defineClassFromData(container, classData, classname); | |||
} | |||
@@ -1319,7 +1333,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @exception ClassNotFoundException if the requested class does not exist | |||
* on this loader's classpath. | |||
*/ | |||
public Class<?> findClass(String name) throws ClassNotFoundException { | |||
@Override | |||
public Class<?> findClass(final String name) throws ClassNotFoundException { | |||
log("Finding class " + name, Project.MSG_DEBUG); | |||
return findClassInComponents(name); | |||
} | |||
@@ -1331,7 +1346,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @return true if the file is in the class path | |||
*/ | |||
protected boolean isInPath(File component) { | |||
protected boolean isInPath(final File component) { | |||
return pathComponents.contains(component); | |||
} | |||
@@ -1346,14 +1361,14 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @exception ClassNotFoundException if the requested class does not exist | |||
* on this loader's classpath. | |||
*/ | |||
private Class<?> findClassInComponents(String name) | |||
private Class<?> findClassInComponents(final String name) | |||
throws ClassNotFoundException { | |||
// we need to search the components of the path to see if | |||
// we can find the class we want. | |||
String classFilename = getClassFilename(name); | |||
Enumeration<File> e = pathComponents.elements(); | |||
final String classFilename = getClassFilename(name); | |||
final Enumeration<File> e = pathComponents.elements(); | |||
while (e.hasMoreElements()) { | |||
File pathComponent = (File) e.nextElement(); | |||
final File pathComponent = e.nextElement(); | |||
InputStream stream = null; | |||
try { | |||
stream = getResourceStream(pathComponent, classFilename); | |||
@@ -1362,9 +1377,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
+ classFilename, Project.MSG_DEBUG); | |||
return getClassFromStream(stream, name, pathComponent); | |||
} | |||
} catch (SecurityException se) { | |||
} catch (final SecurityException se) { | |||
throw se; | |||
} catch (IOException ioe) { | |||
} catch (final IOException ioe) { | |||
// ioe.printStackTrace(); | |||
log("Exception reading component " + pathComponent + " (reason: " | |||
+ ioe.getMessage() + ")", Project.MSG_VERBOSE); | |||
@@ -1390,7 +1405,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* @exception ClassNotFoundException if the requested class does not exist | |||
* on this loader's classpath. | |||
*/ | |||
private Class<?> findBaseClass(String name) throws ClassNotFoundException { | |||
private Class<?> findBaseClass(final String name) throws ClassNotFoundException { | |||
return parent == null ? findSystemClass(name) : parent.loadClass(name); | |||
} | |||
@@ -1399,11 +1414,11 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* files are closed. | |||
*/ | |||
public synchronized void cleanup() { | |||
for (Enumeration<JarFile> e = jarFiles.elements(); e.hasMoreElements();) { | |||
JarFile jarFile = e.nextElement(); | |||
for (final Enumeration<JarFile> e = jarFiles.elements(); e.hasMoreElements();) { | |||
final JarFile jarFile = e.nextElement(); | |||
try { | |||
jarFile.close(); | |||
} catch (IOException ioe) { | |||
} catch (final IOException ioe) { | |||
// ignore | |||
} | |||
} | |||
@@ -1418,6 +1433,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* Gets the parent as has been specified in the constructor or via | |||
* setParent. | |||
* | |||
* @return classloader | |||
* @since Ant 1.8.0 | |||
*/ | |||
public ClassLoader getConfiguredParent() { | |||
@@ -1429,7 +1445,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param event the buildStarted event | |||
*/ | |||
public void buildStarted(BuildEvent event) { | |||
@Override | |||
public void buildStarted(final BuildEvent event) { | |||
// Not significant for the class loader. | |||
} | |||
@@ -1439,7 +1456,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param event the buildFinished event | |||
*/ | |||
public void buildFinished(BuildEvent event) { | |||
@Override | |||
public void buildFinished(final BuildEvent event) { | |||
cleanup(); | |||
} | |||
@@ -1452,7 +1470,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @since Ant 1.6.2 | |||
*/ | |||
public void subBuildFinished(BuildEvent event) { | |||
@Override | |||
public void subBuildFinished(final BuildEvent event) { | |||
if (event.getProject() == project) { | |||
cleanup(); | |||
} | |||
@@ -1465,7 +1484,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @since Ant 1.6.2 | |||
*/ | |||
public void subBuildStarted(BuildEvent event) { | |||
@Override | |||
public void subBuildStarted(final BuildEvent event) { | |||
// Not significant for the class loader. | |||
} | |||
@@ -1474,7 +1494,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param event the targetStarted event | |||
*/ | |||
public void targetStarted(BuildEvent event) { | |||
@Override | |||
public void targetStarted(final BuildEvent event) { | |||
// Not significant for the class loader. | |||
} | |||
@@ -1483,7 +1504,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param event the targetFinished event | |||
*/ | |||
public void targetFinished(BuildEvent event) { | |||
@Override | |||
public void targetFinished(final BuildEvent event) { | |||
// Not significant for the class loader. | |||
} | |||
@@ -1492,7 +1514,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param event the taskStarted event | |||
*/ | |||
public void taskStarted(BuildEvent event) { | |||
@Override | |||
public void taskStarted(final BuildEvent event) { | |||
// Not significant for the class loader. | |||
} | |||
@@ -1501,7 +1524,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param event the taskFinished event | |||
*/ | |||
public void taskFinished(BuildEvent event) { | |||
@Override | |||
public void taskFinished(final BuildEvent event) { | |||
// Not significant for the class loader. | |||
} | |||
@@ -1510,7 +1534,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* | |||
* @param event the messageLogged event | |||
*/ | |||
public void messageLogged(BuildEvent event) { | |||
@Override | |||
public void messageLogged(final BuildEvent event) { | |||
// Not significant for the class loader. | |||
} | |||
@@ -1519,10 +1544,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* here | |||
*/ | |||
public void addJavaLibraries() { | |||
Vector<String> packages = JavaEnvUtils.getJrePackages(); | |||
Enumeration<String> e = packages.elements(); | |||
final Vector<String> packages = JavaEnvUtils.getJrePackages(); | |||
final Enumeration<String> e = packages.elements(); | |||
while (e.hasMoreElements()) { | |||
String packageName = e.nextElement(); | |||
final String packageName = e.nextElement(); | |||
addSystemPackageRoot(packageName); | |||
} | |||
} | |||
@@ -1531,7 +1556,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
* Returns a <code>String</code> representing this loader. | |||
* @return the path that this classloader has. | |||
*/ | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
return "AntClassLoader[" + getClasspath() + "]"; | |||
} | |||
@@ -1545,7 +1571,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
try { | |||
subClassToLoad = | |||
Class.forName("org.apache.tools.ant.loader.AntClassLoader5"); | |||
} catch (ClassNotFoundException e) { | |||
} catch (final ClassNotFoundException e) { | |||
// this is Java5 but the installation is lacking our subclass | |||
} | |||
} | |||
@@ -1554,10 +1580,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
/** | |||
* Factory method | |||
*/ | |||
public static AntClassLoader newAntClassLoader(ClassLoader parent, | |||
Project project, | |||
Path path, | |||
boolean parentFirst) { | |||
public static AntClassLoader newAntClassLoader(final ClassLoader parent, | |||
final Project project, | |||
final Path path, | |||
final boolean parentFirst) { | |||
if (subClassToLoad != null) { | |||
return (AntClassLoader) | |||
ReflectUtil.newInstance(subClassToLoad, | |||
@@ -1574,10 +1600,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
private static final ZipLong SINGLE_SEGMENT_SPLIT_MARKER = | |||
new ZipLong(0X30304B50L); | |||
private static boolean isZip(File file) throws IOException { | |||
byte[] sig = new byte[4]; | |||
private static boolean isZip(final File file) throws IOException { | |||
final byte[] sig = new byte[4]; | |||
if (readFully(file, sig)) { | |||
ZipLong start = new ZipLong(sig); | |||
final ZipLong start = new ZipLong(sig); | |||
return ZipLong.LFH_SIG.equals(start) // normal file | |||
|| EOCD_SIG.equals(start) // empty zip | |||
|| ZipLong.DD_SIG.equals(start) // split zip | |||
@@ -1586,8 +1612,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||
return false; | |||
} | |||
private static boolean readFully(File f, byte[] b) throws IOException { | |||
FileInputStream fis = new FileInputStream(f); | |||
private static boolean readFully(final File f, final byte[] b) throws IOException { | |||
final FileInputStream fis = new FileInputStream(f); | |||
try { | |||
final int len = b.length; | |||
int count = 0, x = 0; | |||
@@ -27,7 +27,7 @@ import java.util.List; | |||
* ones. It is then recommended to chose specific 'enough' argument name, | |||
* avoiding for instance one letter arguments. By the way, if there any | |||
* conflict, Ant will take precedence. | |||
* | |||
* | |||
* @since 1.9 | |||
*/ | |||
public interface ArgumentProcessor { | |||
@@ -64,7 +64,7 @@ public interface ArgumentProcessor { | |||
/** | |||
* Print the usage of the supported arguments | |||
* | |||
* | |||
* @see org.apache.tools.ant.Main#printUsage() | |||
*/ | |||
void printUsage(PrintStream writer); | |||
@@ -39,7 +39,7 @@ import org.apache.tools.ant.util.LoaderUtils; | |||
* <p> | |||
* Use the system property <code>ant.argument-processor.debug</code> to enable | |||
* the print of debug log. | |||
* | |||
* | |||
* @since 1.9 | |||
*/ | |||
public class ArgumentProcessorRegistry { | |||
@@ -37,7 +37,7 @@ public interface BuildListener extends EventListener { | |||
* <p>This event is fired before the project instance is fully | |||
* configured. In particular no properties have been set and the | |||
* project may not know its name or default target, yet.</p> | |||
* | |||
* | |||
* @param event An event with any relevant extra information. | |||
* Must not be <code>null</code>. | |||
*/ | |||
@@ -145,7 +145,8 @@ public class DirectoryScanner | |||
* Use the {@link #getDefaultExcludes getDefaultExcludes} | |||
* method instead. | |||
*/ | |||
protected static final String[] DEFAULTEXCLUDES = { | |||
@Deprecated | |||
protected static final String[] DEFAULTEXCLUDES = { | |||
// Miscellaneous typical temporary files | |||
SelectorUtils.DEEP_TREE_MATCH + "/*~", | |||
SelectorUtils.DEEP_TREE_MATCH + "/#*#", | |||
@@ -558,7 +559,7 @@ public class DirectoryScanner | |||
*/ | |||
public static String[] getDefaultExcludes() { | |||
synchronized (defaultExcludes) { | |||
return (String[]) defaultExcludes.toArray(new String[defaultExcludes | |||
return defaultExcludes.toArray(new String[defaultExcludes | |||
.size()]); | |||
} | |||
} | |||
@@ -618,7 +619,8 @@ public class DirectoryScanner | |||
* | |||
* @param basedir The base directory to scan. | |||
*/ | |||
public void setBasedir(String basedir) { | |||
@Override | |||
public void setBasedir(String basedir) { | |||
setBasedir(basedir == null ? (File) null | |||
: new File(basedir.replace('/', File.separatorChar).replace( | |||
'\\', File.separatorChar))); | |||
@@ -630,7 +632,8 @@ public class DirectoryScanner | |||
* | |||
* @param basedir The base directory for scanning. | |||
*/ | |||
public synchronized void setBasedir(File basedir) { | |||
@Override | |||
public synchronized void setBasedir(File basedir) { | |||
this.basedir = basedir; | |||
} | |||
@@ -640,7 +643,8 @@ public class DirectoryScanner | |||
* | |||
* @return the base directory to be scanned. | |||
*/ | |||
public synchronized File getBasedir() { | |||
@Override | |||
public synchronized File getBasedir() { | |||
return basedir; | |||
} | |||
@@ -661,7 +665,8 @@ public class DirectoryScanner | |||
* @param isCaseSensitive whether or not the file system should be | |||
* regarded as a case sensitive one. | |||
*/ | |||
public synchronized void setCaseSensitive(boolean isCaseSensitive) { | |||
@Override | |||
public synchronized void setCaseSensitive(boolean isCaseSensitive) { | |||
this.isCaseSensitive = isCaseSensitive; | |||
} | |||
@@ -719,7 +724,8 @@ public class DirectoryScanner | |||
* list is given, all elements must be | |||
* non-<code>null</code>. | |||
*/ | |||
public synchronized void setIncludes(String[] includes) { | |||
@Override | |||
public synchronized void setIncludes(String[] includes) { | |||
if (includes == null) { | |||
this.includes = null; | |||
} else { | |||
@@ -742,7 +748,8 @@ public class DirectoryScanner | |||
* should be excluded. If a non-<code>null</code> list is | |||
* given, all elements must be non-<code>null</code>. | |||
*/ | |||
public synchronized void setExcludes(String[] excludes) { | |||
@Override | |||
public synchronized void setExcludes(String[] excludes) { | |||
if (excludes == null) { | |||
this.excludes = null; | |||
} else { | |||
@@ -807,7 +814,8 @@ public class DirectoryScanner | |||
* | |||
* @param selectors specifies the selectors to be invoked on a scan. | |||
*/ | |||
public synchronized void setSelectors(FileSelector[] selectors) { | |||
@Override | |||
public synchronized void setSelectors(FileSelector[] selectors) { | |||
this.selectors = selectors; | |||
} | |||
@@ -832,7 +840,8 @@ public class DirectoryScanner | |||
* @exception IllegalStateException if the base directory was set | |||
* incorrectly (i.e. if it doesn't exist or isn't a directory). | |||
*/ | |||
public void scan() throws IllegalStateException { | |||
@Override | |||
public void scan() throws IllegalStateException { | |||
synchronized (scanLock) { | |||
if (scanning) { | |||
while (scanning) { | |||
@@ -1023,7 +1032,7 @@ public class DirectoryScanner | |||
scandir(myfile, currentPath, true); | |||
} | |||
} else if (myfile.isFile()) { | |||
String originalpattern = (String) entry.getValue(); | |||
String originalpattern = entry.getValue(); | |||
boolean included = isCaseSensitive() | |||
? originalpattern.equals(currentelement) | |||
: originalpattern.equalsIgnoreCase(currentelement); | |||
@@ -1239,7 +1248,7 @@ public class DirectoryScanner | |||
noLinks.add(newfiles[i]); | |||
} | |||
} | |||
newfiles = (String[]) (noLinks.toArray(new String[noLinks.size()])); | |||
newfiles = (noLinks.toArray(new String[noLinks.size()])); | |||
} else { | |||
directoryNamesFollowed.addFirst(dir.getName()); | |||
} | |||
@@ -1424,7 +1433,7 @@ public class DirectoryScanner | |||
} | |||
} | |||
for (Iterator<TokenizedPath> iter = includeNonPatterns.values().iterator(); | |||
iter.hasNext(); ) { | |||
iter.hasNext();) { | |||
if (couldHoldIncluded(tokenizedName, | |||
iter.next().toPattern())) { | |||
return true; | |||
@@ -1567,7 +1576,8 @@ public class DirectoryScanner | |||
* @return the names of the files which matched at least one of the | |||
* include patterns and none of the exclude patterns. | |||
*/ | |||
public String[] getIncludedFiles() { | |||
@Override | |||
public String[] getIncludedFiles() { | |||
String[] files; | |||
synchronized (this) { | |||
if (filesIncluded == null) { | |||
@@ -1602,7 +1612,8 @@ public class DirectoryScanner | |||
* | |||
* @see #slowScan | |||
*/ | |||
public synchronized String[] getNotIncludedFiles() { | |||
@Override | |||
public synchronized String[] getNotIncludedFiles() { | |||
slowScan(); | |||
String[] files = new String[filesNotIncluded.size()]; | |||
filesNotIncluded.copyInto(files); | |||
@@ -1620,7 +1631,8 @@ public class DirectoryScanner | |||
* | |||
* @see #slowScan | |||
*/ | |||
public synchronized String[] getExcludedFiles() { | |||
@Override | |||
public synchronized String[] getExcludedFiles() { | |||
slowScan(); | |||
String[] files = new String[filesExcluded.size()]; | |||
filesExcluded.copyInto(files); | |||
@@ -1638,7 +1650,8 @@ public class DirectoryScanner | |||
* | |||
* @see #slowScan | |||
*/ | |||
public synchronized String[] getDeselectedFiles() { | |||
@Override | |||
public synchronized String[] getDeselectedFiles() { | |||
slowScan(); | |||
String[] files = new String[filesDeselected.size()]; | |||
filesDeselected.copyInto(files); | |||
@@ -1653,7 +1666,8 @@ public class DirectoryScanner | |||
* @return the names of the directories which matched at least one of the | |||
* include patterns and none of the exclude patterns. | |||
*/ | |||
public String[] getIncludedDirectories() { | |||
@Override | |||
public String[] getIncludedDirectories() { | |||
String[] directories; | |||
synchronized (this) { | |||
if (dirsIncluded == null) { | |||
@@ -1688,7 +1702,8 @@ public class DirectoryScanner | |||
* | |||
* @see #slowScan | |||
*/ | |||
public synchronized String[] getNotIncludedDirectories() { | |||
@Override | |||
public synchronized String[] getNotIncludedDirectories() { | |||
slowScan(); | |||
String[] directories = new String[dirsNotIncluded.size()]; | |||
dirsNotIncluded.copyInto(directories); | |||
@@ -1706,7 +1721,8 @@ public class DirectoryScanner | |||
* | |||
* @see #slowScan | |||
*/ | |||
public synchronized String[] getExcludedDirectories() { | |||
@Override | |||
public synchronized String[] getExcludedDirectories() { | |||
slowScan(); | |||
String[] directories = new String[dirsExcluded.size()]; | |||
dirsExcluded.copyInto(directories); | |||
@@ -1724,7 +1740,8 @@ public class DirectoryScanner | |||
* | |||
* @see #slowScan | |||
*/ | |||
public synchronized String[] getDeselectedDirectories() { | |||
@Override | |||
public synchronized String[] getDeselectedDirectories() { | |||
slowScan(); | |||
String[] directories = new String[dirsDeselected.size()]; | |||
dirsDeselected.copyInto(directories); | |||
@@ -1743,7 +1760,7 @@ public class DirectoryScanner | |||
public synchronized String[] getNotFollowedSymlinks() { | |||
String[] links; | |||
synchronized (this) { | |||
links = (String[]) notFollowedSymlinks | |||
links = notFollowedSymlinks | |||
.toArray(new String[notFollowedSymlinks.size()]); | |||
} | |||
Arrays.sort(links); | |||
@@ -1753,7 +1770,8 @@ public class DirectoryScanner | |||
/** | |||
* Add default exclusions to the current exclusions set. | |||
*/ | |||
public synchronized void addDefaultExcludes() { | |||
@Override | |||
public synchronized void addDefaultExcludes() { | |||
int excludesLength = excludes == null ? 0 : excludes.length; | |||
String[] newExcludes; | |||
String[] defaultExcludesTemp = getDefaultExcludes(); | |||
@@ -1776,7 +1794,8 @@ public class DirectoryScanner | |||
* @return the resource with the given name. | |||
* @since Ant 1.5.2 | |||
*/ | |||
public synchronized Resource getResource(String name) { | |||
@Override | |||
public synchronized Resource getResource(String name) { | |||
return new FileResource(basedir, name); | |||
} | |||
@@ -1847,7 +1866,7 @@ public class DirectoryScanner | |||
al.add(new TokenizedPattern(patterns[i])); | |||
} | |||
} | |||
return (TokenizedPattern[]) al.toArray(new TokenizedPattern[al.size()]); | |||
return al.toArray(new TokenizedPattern[al.size()]); | |||
} | |||
/** | |||
@@ -19,7 +19,7 @@ package org.apache.tools.ant; | |||
/** | |||
* Kind of task attribute that can be evaluated before being assigned | |||
* | |||
* | |||
* @see RuntimeConfigurable | |||
*/ | |||
public interface Evaluable { | |||
@@ -26,7 +26,6 @@ package org.apache.tools.ant; | |||
public class ExtensionPoint extends Target { | |||
public ExtensionPoint() { | |||
} | |||
/** | |||
@@ -45,15 +44,17 @@ public class ExtensionPoint extends Target { | |||
/** | |||
* Throws an exception. | |||
*/ | |||
public final void addTask(Task task) { | |||
@Override | |||
public final void addTask(Task task) { | |||
throw new BuildException(NO_CHILDREN_ALLOWED); | |||
} | |||
/** | |||
* Throws an exception. | |||
*/ | |||
public final void addDataType(RuntimeConfigurable r) { | |||
@Override | |||
public final void addDataType(RuntimeConfigurable r) { | |||
throw new BuildException(NO_CHILDREN_ALLOWED); | |||
} | |||
} |
@@ -86,16 +86,16 @@ public class Main implements AntMain { | |||
private static PrintStream err = System.err; | |||
/** The build targets. */ | |||
private Vector<String> targets = new Vector<String>(); | |||
private final Vector<String> targets = new Vector<String>(); | |||
/** Set of properties that can be used by tasks. */ | |||
private Properties definedProps = new Properties(); | |||
private final Properties definedProps = new Properties(); | |||
/** Names of classes to add as listeners to project. */ | |||
private Vector<String> listeners = new Vector<String>(1); | |||
private final Vector<String> listeners = new Vector<String>(1); | |||
/** File names of property files to load on startup. */ | |||
private Vector<String> propertyFiles = new Vector<String>(1); | |||
private final Vector<String> propertyFiles = new Vector<String>(1); | |||
/** Indicates whether this build is to support interactive input */ | |||
private boolean allowInput = true; | |||
@@ -154,13 +154,15 @@ public class Main implements AntMain { | |||
*/ | |||
private boolean proxy = false; | |||
private Map<Class<?>, List<String>> extraArguments = new HashMap<Class<?>, List<String>>(); | |||
private final Map<Class<?>, List<String>> extraArguments = new HashMap<Class<?>, List<String>>(); | |||
private static final GetProperty NOPROPERTIES = new GetProperty(){ | |||
public Object getProperty(String aName) { | |||
private static final GetProperty NOPROPERTIES = new GetProperty() { | |||
@Override | |||
public Object getProperty(final String aName) { | |||
// No existing property takes precedence | |||
return null; | |||
}}; | |||
} | |||
}; | |||
@@ -172,8 +174,8 @@ public class Main implements AntMain { | |||
* @param t Throwable to print the message of. | |||
* Must not be <code>null</code>. | |||
*/ | |||
private static void printMessage(Throwable t) { | |||
String message = t.getMessage(); | |||
private static void printMessage(final Throwable t) { | |||
final String message = t.getMessage(); | |||
if (message != null) { | |||
System.err.println(message); | |||
} | |||
@@ -191,9 +193,9 @@ public class Main implements AntMain { | |||
* @param coreLoader Classloader used for core classes. May be | |||
* <code>null</code> in which case the system classloader is used. | |||
*/ | |||
public static void start(String[] args, Properties additionalUserProperties, | |||
ClassLoader coreLoader) { | |||
Main m = new Main(); | |||
public static void start(final String[] args, final Properties additionalUserProperties, | |||
final ClassLoader coreLoader) { | |||
final Main m = new Main(); | |||
m.startAnt(args, additionalUserProperties, coreLoader); | |||
} | |||
@@ -206,12 +208,13 @@ public class Main implements AntMain { | |||
* | |||
* @since Ant 1.6 | |||
*/ | |||
public void startAnt(String[] args, Properties additionalUserProperties, | |||
ClassLoader coreLoader) { | |||
@Override | |||
public void startAnt(final String[] args, final Properties additionalUserProperties, | |||
final ClassLoader coreLoader) { | |||
try { | |||
processArgs(args); | |||
} catch (Throwable exc) { | |||
} catch (final Throwable exc) { | |||
handleLogfile(); | |||
printMessage(exc); | |||
exit(1); | |||
@@ -219,10 +222,10 @@ public class Main implements AntMain { | |||
} | |||
if (additionalUserProperties != null) { | |||
for (Enumeration<?> e = additionalUserProperties.keys(); | |||
for (final Enumeration<?> e = additionalUserProperties.keys(); | |||
e.hasMoreElements();) { | |||
String key = (String) e.nextElement(); | |||
String property = additionalUserProperties.getProperty(key); | |||
final String key = (String) e.nextElement(); | |||
final String property = additionalUserProperties.getProperty(key); | |||
definedProps.put(key, property); | |||
} | |||
} | |||
@@ -233,17 +236,17 @@ public class Main implements AntMain { | |||
try { | |||
runBuild(coreLoader); | |||
exitCode = 0; | |||
} catch (ExitStatusException ese) { | |||
} catch (final ExitStatusException ese) { | |||
exitCode = ese.getStatus(); | |||
if (exitCode != 0) { | |||
throw ese; | |||
} | |||
} | |||
} catch (BuildException be) { | |||
} catch (final BuildException be) { | |||
if (err != System.err) { | |||
printMessage(be); | |||
} | |||
} catch (Throwable exc) { | |||
} catch (final Throwable exc) { | |||
exc.printStackTrace(); | |||
printMessage(exc); | |||
} finally { | |||
@@ -258,7 +261,7 @@ public class Main implements AntMain { | |||
* However, it is possible to do something else. | |||
* @param exitCode code to exit with | |||
*/ | |||
protected void exit(int exitCode) { | |||
protected void exit(final int exitCode) { | |||
System.exit(exitCode); | |||
} | |||
@@ -281,7 +284,7 @@ public class Main implements AntMain { | |||
* | |||
* @param args Command line arguments. Must not be <code>null</code>. | |||
*/ | |||
public static void main(String[] args) { | |||
public static void main(final String[] args) { | |||
start(args, null, null); | |||
} | |||
@@ -303,7 +306,8 @@ public class Main implements AntMain { | |||
* | |||
* @deprecated since 1.6.x | |||
*/ | |||
protected Main(String[] args) throws BuildException { | |||
@Deprecated | |||
protected Main(final String[] args) throws BuildException { | |||
processArgs(args); | |||
} | |||
@@ -316,7 +320,7 @@ public class Main implements AntMain { | |||
* | |||
* @since Ant 1.6 | |||
*/ | |||
private void processArgs(String[] args) { | |||
private void processArgs(final String[] args) { | |||
String searchForThis = null; | |||
boolean searchForFile = false; | |||
PrintStream logTo = null; | |||
@@ -327,10 +331,10 @@ public class Main implements AntMain { | |||
boolean justPrintVersion = false; | |||
boolean justPrintDiagnostics = false; | |||
ArgumentProcessorRegistry processorRegistry = ArgumentProcessorRegistry.getInstance(); | |||
final ArgumentProcessorRegistry processorRegistry = ArgumentProcessorRegistry.getInstance(); | |||
for (int i = 0; i < args.length; i++) { | |||
String arg = args[i]; | |||
final String arg = args[i]; | |||
if (arg.equals("-help") || arg.equals("-h")) { | |||
justPrintUsage = true; | |||
@@ -350,17 +354,17 @@ public class Main implements AntMain { | |||
allowInput = false; | |||
} else if (arg.equals("-logfile") || arg.equals("-l")) { | |||
try { | |||
File logFile = new File(args[i + 1]); | |||
final File logFile = new File(args[i + 1]); | |||
i++; | |||
logTo = new PrintStream(new FileOutputStream(logFile)); | |||
isLogFileUsed = true; | |||
} catch (IOException ioe) { | |||
String msg = "Cannot write on the specified log file. " | |||
} catch (final IOException ioe) { | |||
final String msg = "Cannot write on the specified log file. " | |||
+ "Make sure the path exists and you have write " | |||
+ "permissions."; | |||
throw new BuildException(msg); | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
String msg = "You must specify a log file when " | |||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||
final String msg = "You must specify a log file when " | |||
+ "using the -log argument"; | |||
throw new BuildException(msg); | |||
} | |||
@@ -396,7 +400,7 @@ public class Main implements AntMain { | |||
//catch script/ant mismatch with a meaningful message | |||
//we could ignore it, but there are likely to be other | |||
//version problems, so we stamp down on the configuration now | |||
String msg = "Ant's Main method is being handed " | |||
final String msg = "Ant's Main method is being handed " | |||
+ "an option " + arg + " that is only for the launcher class." | |||
+ "\nThis can be caused by a version mismatch between " | |||
+ "the ant script/.bat file and Ant itself."; | |||
@@ -405,8 +409,8 @@ public class Main implements AntMain { | |||
proxy = true; | |||
} else if (arg.startsWith("-")) { | |||
boolean processed = false; | |||
for (ArgumentProcessor processor : processorRegistry.getProcessors()) { | |||
int newI = processor.readArguments(args, i); | |||
for (final ArgumentProcessor processor : processorRegistry.getProcessors()) { | |||
final int newI = processor.readArguments(args, i); | |||
if (newI != -1) { | |||
List<String> extraArgs = extraArguments.get(processor.getClass()); | |||
if (extraArgs == null) { | |||
@@ -422,7 +426,7 @@ public class Main implements AntMain { | |||
} | |||
if (!processed) { | |||
// we don't have any more args to recognize! | |||
String msg = "Unknown argument: " + arg; | |||
final String msg = "Unknown argument: " + arg; | |||
System.err.println(msg); | |||
printUsage(); | |||
throw new BuildException(""); | |||
@@ -458,9 +462,9 @@ public class Main implements AntMain { | |||
} | |||
} else { | |||
// no search file specified: so search an existing default file | |||
Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers(); | |||
final Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers(); | |||
do { | |||
ProjectHelper helper = it.next(); | |||
final ProjectHelper helper = it.next(); | |||
searchForThis = helper.getDefaultBuildFile(); | |||
if (msgOutputLevel >= Project.MSG_VERBOSE) { | |||
System.out.println("Searching the default build file: " + searchForThis); | |||
@@ -473,9 +477,9 @@ public class Main implements AntMain { | |||
} | |||
} else { | |||
// no build file specified: so search an existing default file | |||
Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers(); | |||
final Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers(); | |||
do { | |||
ProjectHelper helper = it.next(); | |||
final ProjectHelper helper = it.next(); | |||
buildFile = new File(helper.getDefaultBuildFile()); | |||
if (msgOutputLevel >= Project.MSG_VERBOSE) { | |||
System.out.println("Trying the default build file: " + buildFile); | |||
@@ -491,7 +495,7 @@ public class Main implements AntMain { | |||
} | |||
if (buildFile.isDirectory()) { | |||
File whatYouMeant = new File(buildFile, "build.xml"); | |||
final File whatYouMeant = new File(buildFile, "build.xml"); | |||
if (whatYouMeant.isFile()) { | |||
buildFile = whatYouMeant; | |||
} else { | |||
@@ -525,11 +529,11 @@ public class Main implements AntMain { | |||
// -------------------------------------------------------- | |||
/** Handle the -buildfile, -file, -f argument */ | |||
private int handleArgBuildFile(String[] args, int pos) { | |||
private int handleArgBuildFile(final String[] args, int pos) { | |||
try { | |||
buildFile = new File( | |||
args[++pos].replace('/', File.separatorChar)); | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||
throw new BuildException( | |||
"You must specify a buildfile when using the -buildfile argument"); | |||
} | |||
@@ -537,12 +541,12 @@ public class Main implements AntMain { | |||
} | |||
/** Handle -listener argument */ | |||
private int handleArgListener(String[] args, int pos) { | |||
private int handleArgListener(final String[] args, int pos) { | |||
try { | |||
listeners.addElement(args[pos + 1]); | |||
pos++; | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
String msg = "You must specify a classname when " | |||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||
final String msg = "You must specify a classname when " | |||
+ "using the -listener argument"; | |||
throw new BuildException(msg); | |||
} | |||
@@ -550,7 +554,7 @@ public class Main implements AntMain { | |||
} | |||
/** Handler -D argument */ | |||
private int handleArgDefine(String[] args, int argPos) { | |||
private int handleArgDefine(final String[] args, int argPos) { | |||
/* Interestingly enough, we get to here when a user | |||
* uses -Dname=value. However, in some cases, the OS | |||
* goes ahead and parses this out to args | |||
@@ -561,10 +565,10 @@ public class Main implements AntMain { | |||
* I don't know how to predict when the JDK is going | |||
* to help or not, so we simply look for the equals sign. | |||
*/ | |||
String arg = args[argPos]; | |||
final String arg = args[argPos]; | |||
String name = arg.substring(2, arg.length()); | |||
String value = null; | |||
int posEq = name.indexOf("="); | |||
final int posEq = name.indexOf("="); | |||
if (posEq > 0) { | |||
value = name.substring(posEq + 1); | |||
name = name.substring(0, posEq); | |||
@@ -579,14 +583,14 @@ public class Main implements AntMain { | |||
} | |||
/** Handle the -logger argument. */ | |||
private int handleArgLogger(String[] args, int pos) { | |||
private int handleArgLogger(final String[] args, int pos) { | |||
if (loggerClassname != null) { | |||
throw new BuildException( | |||
"Only one logger class may be specified."); | |||
} | |||
try { | |||
loggerClassname = args[++pos]; | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||
throw new BuildException( | |||
"You must specify a classname when using the -logger argument"); | |||
} | |||
@@ -594,14 +598,14 @@ public class Main implements AntMain { | |||
} | |||
/** Handle the -inputhandler argument. */ | |||
private int handleArgInputHandler(String[] args, int pos) { | |||
private int handleArgInputHandler(final String[] args, int pos) { | |||
if (inputHandlerClassname != null) { | |||
throw new BuildException("Only one input handler class may " | |||
+ "be specified."); | |||
} | |||
try { | |||
inputHandlerClassname = args[++pos]; | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||
throw new BuildException("You must specify a classname when" | |||
+ " using the -inputhandler" | |||
+ " argument"); | |||
@@ -610,11 +614,11 @@ public class Main implements AntMain { | |||
} | |||
/** Handle the -propertyfile argument. */ | |||
private int handleArgPropertyFile(String[] args, int pos) { | |||
private int handleArgPropertyFile(final String[] args, int pos) { | |||
try { | |||
propertyFiles.addElement(args[++pos]); | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
String msg = "You must specify a property filename when " | |||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||
final String msg = "You must specify a property filename when " | |||
+ "using the -propertyfile argument"; | |||
throw new BuildException(msg); | |||
} | |||
@@ -622,14 +626,14 @@ public class Main implements AntMain { | |||
} | |||
/** Handle the -nice argument. */ | |||
private int handleArgNice(String[] args, int pos) { | |||
private int handleArgNice(final String[] args, int pos) { | |||
try { | |||
threadPriority = Integer.decode(args[++pos]); | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||
throw new BuildException( | |||
"You must supply a niceness value (1-10)" | |||
+ " after the -nice option"); | |||
} catch (NumberFormatException e) { | |||
} catch (final NumberFormatException e) { | |||
throw new BuildException("Unrecognized niceness value: " | |||
+ args[pos]); | |||
} | |||
@@ -648,13 +652,13 @@ public class Main implements AntMain { | |||
/** Load the property files specified by -propertyfile */ | |||
private void loadPropertyFiles() { | |||
for (String filename : propertyFiles) { | |||
Properties props = new Properties(); | |||
for (final String filename : propertyFiles) { | |||
final Properties props = new Properties(); | |||
FileInputStream fis = null; | |||
try { | |||
fis = new FileInputStream(filename); | |||
props.load(fis); | |||
} catch (IOException e) { | |||
} catch (final IOException e) { | |||
System.out.println("Could not load property file " | |||
+ filename + ": " + e.getMessage()); | |||
} finally { | |||
@@ -662,9 +666,9 @@ public class Main implements AntMain { | |||
} | |||
// ensure that -D properties take precedence | |||
Enumeration<?> propertyNames = props.propertyNames(); | |||
final Enumeration<?> propertyNames = props.propertyNames(); | |||
while (propertyNames.hasMoreElements()) { | |||
String name = (String) propertyNames.nextElement(); | |||
final String name = (String) propertyNames.nextElement(); | |||
if (definedProps.getProperty(name) == null) { | |||
definedProps.put(name, props.getProperty(name)); | |||
} | |||
@@ -681,8 +685,9 @@ public class Main implements AntMain { | |||
* @param file File to find parent of. Must not be <code>null</code>. | |||
* @return Parent file or null if none | |||
*/ | |||
private File getParentFile(File file) { | |||
File parent = file.getParentFile(); | |||
@Deprecated | |||
private File getParentFile(final File file) { | |||
final File parent = file.getParentFile(); | |||
if (parent != null && msgOutputLevel >= Project.MSG_VERBOSE) { | |||
System.out.println("Searching in " + parent.getAbsolutePath()); | |||
@@ -706,7 +711,7 @@ public class Main implements AntMain { | |||
* | |||
* @return A handle to the build file if one is found, <code>null</code> if not | |||
*/ | |||
private File findBuildFile(String start, String suffix) { | |||
private File findBuildFile(final String start, final String suffix) { | |||
if (msgOutputLevel >= Project.MSG_INFO) { | |||
System.out.println("Searching for " + suffix + " ..."); | |||
} | |||
@@ -743,16 +748,16 @@ public class Main implements AntMain { | |||
* | |||
* @exception BuildException if the build fails | |||
*/ | |||
private void runBuild(ClassLoader coreLoader) throws BuildException { | |||
private void runBuild(final ClassLoader coreLoader) throws BuildException { | |||
if (!readyToRun) { | |||
return; | |||
} | |||
ArgumentProcessorRegistry processorRegistry = ArgumentProcessorRegistry.getInstance(); | |||
final ArgumentProcessorRegistry processorRegistry = ArgumentProcessorRegistry.getInstance(); | |||
for (ArgumentProcessor processor : processorRegistry.getProcessors()) { | |||
List<String> extraArgs = extraArguments.get(processor.getClass()); | |||
for (final ArgumentProcessor processor : processorRegistry.getProcessors()) { | |||
final List<String> extraArgs = extraArguments.get(processor.getClass()); | |||
if (extraArgs != null) { | |||
if (processor.handleArg(extraArgs)) { | |||
return; | |||
@@ -769,9 +774,9 @@ public class Main implements AntMain { | |||
addBuildListeners(project); | |||
addInputHandler(project); | |||
PrintStream savedErr = System.err; | |||
PrintStream savedOut = System.out; | |||
InputStream savedIn = System.in; | |||
final PrintStream savedErr = System.err; | |||
final PrintStream savedOut = System.out; | |||
final InputStream savedIn = System.in; | |||
// use a system manager that prevents from System.exit() | |||
SecurityManager oldsm = null; | |||
@@ -800,7 +805,7 @@ public class Main implements AntMain { | |||
project.log("Setting Ant's thread priority to " | |||
+ threadPriority, Project.MSG_VERBOSE); | |||
Thread.currentThread().setPriority(threadPriority.intValue()); | |||
} catch (SecurityException swallowed) { | |||
} catch (final SecurityException swallowed) { | |||
//we cannot set the priority here. | |||
project.log("A security manager refused to set the -nice value"); | |||
} | |||
@@ -811,12 +816,12 @@ public class Main implements AntMain { | |||
project.setKeepGoingMode(keepGoingMode); | |||
if (proxy) { | |||
//proxy setup if enabled | |||
ProxySetup proxySetup = new ProxySetup(project); | |||
final ProxySetup proxySetup = new ProxySetup(project); | |||
proxySetup.enableProxies(); | |||
} | |||
for (ArgumentProcessor processor : processorRegistry.getProcessors()) { | |||
List<String> extraArgs = extraArguments.get(processor.getClass()); | |||
for (final ArgumentProcessor processor : processorRegistry.getProcessors()) { | |||
final List<String> extraArgs = extraArguments.get(processor.getClass()); | |||
if (extraArgs != null) { | |||
processor.prepareConfigure(project, extraArgs); | |||
} | |||
@@ -824,8 +829,8 @@ public class Main implements AntMain { | |||
ProjectHelper.configureProject(project, buildFile); | |||
for (ArgumentProcessor processor : processorRegistry.getProcessors()) { | |||
List<String> extraArgs = extraArguments.get(processor.getClass()); | |||
for (final ArgumentProcessor processor : processorRegistry.getProcessors()) { | |||
final List<String> extraArgs = extraArguments.get(processor.getClass()); | |||
if (extraArgs != null) { | |||
if (processor.handleArg(project, extraArgs)) { | |||
return; | |||
@@ -859,17 +864,17 @@ public class Main implements AntMain { | |||
System.setErr(savedErr); | |||
System.setIn(savedIn); | |||
} | |||
} catch (RuntimeException exc) { | |||
} catch (final RuntimeException exc) { | |||
error = exc; | |||
throw exc; | |||
} catch (Error e) { | |||
} catch (final Error e) { | |||
error = e; | |||
throw e; | |||
} finally { | |||
if (!projectHelp) { | |||
try { | |||
project.fireBuildFinished(error); | |||
} catch (Throwable t) { | |||
} catch (final Throwable t) { | |||
// yes, I know it is bad style to catch Throwable, | |||
// but if we don't, we lose valuable information | |||
System.err.println("Caught an exception while logging the" | |||
@@ -893,20 +898,22 @@ public class Main implements AntMain { | |||
project.init(); | |||
// resolve properties | |||
PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(project); | |||
final PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(project); | |||
@SuppressWarnings({ "rawtypes", "unchecked" }) | |||
final | |||
Map raw = new HashMap(definedProps); | |||
@SuppressWarnings("unchecked") | |||
final | |||
Map<String, Object> props = raw; | |||
ResolvePropertyMap resolver = new ResolvePropertyMap(project, | |||
final ResolvePropertyMap resolver = new ResolvePropertyMap(project, | |||
NOPROPERTIES, propertyHelper.getExpanders()); | |||
resolver.resolveAllProperties(props, null, false); | |||
// set user-define properties | |||
for (Entry<String, Object> ent : props.entrySet()) { | |||
String arg = ent.getKey(); | |||
Object value = ent.getValue(); | |||
for (final Entry<String, Object> ent : props.entrySet()) { | |||
final String arg = ent.getKey(); | |||
final Object value = ent.getValue(); | |||
project.setUserProperty(arg, String.valueOf(value)); | |||
} | |||
@@ -923,15 +930,15 @@ public class Main implements AntMain { | |||
* @param project The project to add listeners to. | |||
* Must not be <code>null</code>. | |||
*/ | |||
protected void addBuildListeners(Project project) { | |||
protected void addBuildListeners(final Project project) { | |||
// Add the default listener | |||
project.addBuildListener(createLogger()); | |||
final int count = listeners.size(); | |||
for (int i = 0; i < count; i++) { | |||
String className = (String) listeners.elementAt(i); | |||
BuildListener listener = | |||
final String className = listeners.elementAt(i); | |||
final BuildListener listener = | |||
(BuildListener) ClasspathUtils.newInstance(className, | |||
Main.class.getClassLoader(), BuildListener.class); | |||
project.setProjectReference(listener); | |||
@@ -948,7 +955,7 @@ public class Main implements AntMain { | |||
* @exception BuildException if a specified InputHandler | |||
* implementation could not be loaded. | |||
*/ | |||
private void addInputHandler(Project project) throws BuildException { | |||
private void addInputHandler(final Project project) throws BuildException { | |||
InputHandler handler = null; | |||
if (inputHandlerClassname == null) { | |||
handler = new DefaultInputHandler(); | |||
@@ -982,7 +989,7 @@ public class Main implements AntMain { | |||
logger = (BuildLogger) ClasspathUtils.newInstance( | |||
loggerClassname, Main.class.getClassLoader(), | |||
BuildLogger.class); | |||
} catch (BuildException e) { | |||
} catch (final BuildException e) { | |||
System.err.println("The specified logger class " | |||
+ loggerClassname | |||
+ " could not be used because " + e.getMessage()); | |||
@@ -1040,7 +1047,7 @@ public class Main implements AntMain { | |||
System.out.println(" -noclasspath Run ant without using CLASSPATH"); | |||
System.out.println(" -autoproxy Java1.5+: use the OS proxy settings"); | |||
System.out.println(" -main <class> override Ant's normal entry point"); | |||
for (ArgumentProcessor processor : ArgumentProcessorRegistry.getInstance().getProcessors()) { | |||
for (final ArgumentProcessor processor : ArgumentProcessorRegistry.getInstance().getProcessors()) { | |||
processor.printUsage(System.out); | |||
} | |||
} | |||
@@ -1050,7 +1057,7 @@ public class Main implements AntMain { | |||
* | |||
* @exception BuildException if the version information is unavailable | |||
*/ | |||
private static void printVersion(int logLevel) throws BuildException { | |||
private static void printVersion(final int logLevel) throws BuildException { | |||
System.out.println(getAntVersion()); | |||
} | |||
@@ -1063,7 +1070,7 @@ public class Main implements AntMain { | |||
* Cache of the short Ant version information when it has been loaded. | |||
*/ | |||
private static String shortAntVersion = null; | |||
/** | |||
* Returns the Ant version information, if available. Once the information | |||
* has been loaded once, it's cached and returned from the cache on future | |||
@@ -1077,37 +1084,37 @@ public class Main implements AntMain { | |||
public static synchronized String getAntVersion() throws BuildException { | |||
if (antVersion == null) { | |||
try { | |||
Properties props = new Properties(); | |||
InputStream in = | |||
final Properties props = new Properties(); | |||
final InputStream in = | |||
Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt"); | |||
props.load(in); | |||
in.close(); | |||
shortAntVersion = props.getProperty("VERSION"); | |||
StringBuffer msg = new StringBuffer(); | |||
final StringBuffer msg = new StringBuffer(); | |||
msg.append("Apache Ant(TM) version "); | |||
msg.append(shortAntVersion); | |||
msg.append(" compiled on "); | |||
msg.append(props.getProperty("DATE")); | |||
antVersion = msg.toString(); | |||
} catch (IOException ioe) { | |||
} catch (final IOException ioe) { | |||
throw new BuildException("Could not load the version information:" | |||
+ ioe.getMessage()); | |||
} catch (NullPointerException npe) { | |||
} catch (final NullPointerException npe) { | |||
throw new BuildException("Could not load the version information."); | |||
} | |||
} | |||
return antVersion; | |||
} | |||
/** | |||
* Returns the short Ant version information, if available. Once the information | |||
* has been loaded once, it's cached and returned from the cache on future | |||
* calls. | |||
* | |||
* | |||
* @return the short Ant version information as a String | |||
* (always non-<code>null</code>) | |||
* | |||
* | |||
* @throws BuildException BuildException if the version information is unavailable | |||
* @since Ant 1.9.3 | |||
*/ | |||
@@ -1125,7 +1132,7 @@ public class Main implements AntMain { | |||
* @param project The project to display a description of. | |||
* Must not be <code>null</code>. | |||
*/ | |||
private static void printDescription(Project project) { | |||
private static void printDescription(final Project project) { | |||
if (project.getDescription() != null) { | |||
project.log(project.getDescription()); | |||
} | |||
@@ -1139,12 +1146,12 @@ public class Main implements AntMain { | |||
* @param targets the targets to filter. | |||
* @return the filtered targets. | |||
*/ | |||
private static Map<String, Target> removeDuplicateTargets(Map<String, Target> targets) { | |||
Map<Location, Target> locationMap = new HashMap<Location, Target>(); | |||
for (Entry<String, Target> entry : targets.entrySet()) { | |||
String name = entry.getKey(); | |||
Target target = entry.getValue(); | |||
Target otherTarget = locationMap.get(target.getLocation()); | |||
private static Map<String, Target> removeDuplicateTargets(final Map<String, Target> targets) { | |||
final Map<Location, Target> locationMap = new HashMap<Location, Target>(); | |||
for (final Entry<String, Target> entry : targets.entrySet()) { | |||
final String name = entry.getKey(); | |||
final Target target = entry.getValue(); | |||
final Target otherTarget = locationMap.get(target.getLocation()); | |||
// Place this entry in the location map if | |||
// a) location is not in the map | |||
// b) location is in map, but its name is longer | |||
@@ -1155,8 +1162,8 @@ public class Main implements AntMain { | |||
target.getLocation(), target); // Smallest name wins | |||
} | |||
} | |||
Map<String, Target> ret = new HashMap<String, Target>(); | |||
for (Target target : locationMap.values()) { | |||
final Map<String, Target> ret = new HashMap<String, Target>(); | |||
for (final Target target : locationMap.values()) { | |||
ret.put(target.getName(), target); | |||
} | |||
return ret; | |||
@@ -1171,34 +1178,34 @@ public class Main implements AntMain { | |||
* @param printSubTargets Whether or not subtarget names should also be | |||
* printed. | |||
*/ | |||
private static void printTargets(Project project, boolean printSubTargets, | |||
boolean printDependencies) { | |||
private static void printTargets(final Project project, boolean printSubTargets, | |||
final boolean printDependencies) { | |||
// find the target with the longest name | |||
int maxLength = 0; | |||
Map<String, Target> ptargets = removeDuplicateTargets(project.getTargets()); | |||
final Map<String, Target> ptargets = removeDuplicateTargets(project.getTargets()); | |||
// split the targets in top-level and sub-targets depending | |||
// on the presence of a description | |||
Vector<String> topNames = new Vector<String>(); | |||
Vector<String> topDescriptions = new Vector<String>(); | |||
Vector<Enumeration<String>> topDependencies = new Vector<Enumeration<String>>(); | |||
Vector<String> subNames = new Vector<String>(); | |||
Vector<Enumeration<String>> subDependencies = new Vector<Enumeration<String>>(); | |||
for (Target currentTarget : ptargets.values()) { | |||
String targetName = currentTarget.getName(); | |||
final Vector<String> topNames = new Vector<String>(); | |||
final Vector<String> topDescriptions = new Vector<String>(); | |||
final Vector<Enumeration<String>> topDependencies = new Vector<Enumeration<String>>(); | |||
final Vector<String> subNames = new Vector<String>(); | |||
final Vector<Enumeration<String>> subDependencies = new Vector<Enumeration<String>>(); | |||
for (final Target currentTarget : ptargets.values()) { | |||
final String targetName = currentTarget.getName(); | |||
if (targetName.equals("")) { | |||
continue; | |||
} | |||
String targetDescription = currentTarget.getDescription(); | |||
final String targetDescription = currentTarget.getDescription(); | |||
// maintain a sorted list of targets | |||
if (targetDescription == null) { | |||
int pos = findTargetPosition(subNames, targetName); | |||
final int pos = findTargetPosition(subNames, targetName); | |||
subNames.insertElementAt(targetName, pos); | |||
if (printDependencies) { | |||
subDependencies.insertElementAt(currentTarget.getDependencies(), pos); | |||
} | |||
} else { | |||
int pos = findTargetPosition(topNames, targetName); | |||
final int pos = findTargetPosition(topNames, targetName); | |||
topNames.insertElementAt(targetName, pos); | |||
topDescriptions.insertElementAt(targetDescription, pos); | |||
if (targetName.length() > maxLength) { | |||
@@ -1221,7 +1228,7 @@ public class Main implements AntMain { | |||
printTargets(project, subNames, null, subDependencies, "Other targets:", 0); | |||
} | |||
String defaultTarget = project.getDefaultTarget(); | |||
final String defaultTarget = project.getDefaultTarget(); | |||
if (defaultTarget != null && !"".equals(defaultTarget)) { | |||
// shouldn't need to check but... | |||
project.log("Default target: " + defaultTarget); | |||
@@ -1238,7 +1245,7 @@ public class Main implements AntMain { | |||
* | |||
* @return the correct place in the list for the given name | |||
*/ | |||
private static int findTargetPosition(Vector<String> names, String name) { | |||
private static int findTargetPosition(final Vector<String> names, final String name) { | |||
final int size = names.size(); | |||
int res = size; | |||
for (int i = 0; i < size && res == size; i++) { | |||
@@ -1272,18 +1279,18 @@ public class Main implements AntMain { | |||
* position so they line up (so long as the names really | |||
* <i>are</i> shorter than this). | |||
*/ | |||
private static void printTargets(Project project, Vector<String> names, | |||
Vector<String> descriptions, Vector<Enumeration<String>> dependencies, | |||
String heading, | |||
int maxlen) { | |||
private static void printTargets(final Project project, final Vector<String> names, | |||
final Vector<String> descriptions, final Vector<Enumeration<String>> dependencies, | |||
final String heading, | |||
final int maxlen) { | |||
// now, start printing the targets and their descriptions | |||
String lSep = System.getProperty("line.separator"); | |||
final String lSep = System.getProperty("line.separator"); | |||
// got a bit annoyed that I couldn't find a pad function | |||
String spaces = " "; | |||
while (spaces.length() <= maxlen) { | |||
spaces += spaces; | |||
} | |||
StringBuilder msg = new StringBuilder(); | |||
final StringBuilder msg = new StringBuilder(); | |||
msg.append(heading + lSep + lSep); | |||
final int size = names.size(); | |||
for (int i = 0; i < size; i++) { | |||
@@ -1296,7 +1303,7 @@ public class Main implements AntMain { | |||
} | |||
msg.append(lSep); | |||
if (!dependencies.isEmpty()) { | |||
Enumeration<String> deps = dependencies.elementAt(i); | |||
final Enumeration<String> deps = dependencies.elementAt(i); | |||
if (deps.hasMoreElements()) { | |||
msg.append(" depends on: "); | |||
while (deps.hasMoreElements()) { | |||
@@ -101,7 +101,7 @@ public class ProjectHelper { | |||
* | |||
* @since 1.8.2 | |||
*/ | |||
public final static class OnMissingExtensionPoint { | |||
public static final class OnMissingExtensionPoint { | |||
/** fail if the extension-point is not defined */ | |||
public static final OnMissingExtensionPoint FAIL = new OnMissingExtensionPoint( | |||
@@ -181,7 +181,7 @@ public class ProjectHelper { | |||
return extensionStack; | |||
} | |||
private final static ThreadLocal<String> targetPrefix = new ThreadLocal<String>(); | |||
private static final ThreadLocal<String> targetPrefix = new ThreadLocal<String>(); | |||
/** | |||
* The prefix to prepend to imported target names. | |||
@@ -205,7 +205,7 @@ public class ProjectHelper { | |||
targetPrefix.set(prefix); | |||
} | |||
private final static ThreadLocal<String> prefixSeparator = new ThreadLocal<String>() { | |||
private static final ThreadLocal<String> prefixSeparator = new ThreadLocal<String>() { | |||
protected String initialValue() { | |||
return "."; | |||
} | |||
@@ -231,7 +231,7 @@ public class ProjectHelper { | |||
prefixSeparator.set(sep); | |||
} | |||
private final static ThreadLocal<Boolean> inIncludeMode = new ThreadLocal<Boolean>() { | |||
private static final ThreadLocal<Boolean> inIncludeMode = new ThreadLocal<Boolean>() { | |||
protected Boolean initialValue() { | |||
return Boolean.FALSE; | |||
} | |||
@@ -36,7 +36,7 @@ import org.apache.tools.ant.types.Parameter; | |||
* </filterchain> | |||
* </copy> | |||
* </pre> | |||
* | |||
* | |||
* <p>Copies all java sources from <i>src</i> to <i>build</i> and adds the | |||
* content of <i>apache-license-java.txt</i> add the beginning of each | |||
* file.</p> | |||
@@ -90,7 +90,8 @@ public final class ConcatFilter extends BaseParamFilterReader | |||
* @exception IOException if the underlying stream throws an IOException | |||
* during reading | |||
*/ | |||
public int read() throws IOException { | |||
@Override | |||
public int read() throws IOException { | |||
// do the "singleton" initialization | |||
if (!getInitialized()) { | |||
initialize(); | |||
@@ -170,7 +171,8 @@ public final class ConcatFilter extends BaseParamFilterReader | |||
* @return a new filter based on this configuration, but filtering | |||
* the specified reader | |||
*/ | |||
public Reader chain(final Reader rdr) { | |||
@Override | |||
public Reader chain(final Reader rdr) { | |||
ConcatFilter newFilter = new ConcatFilter(rdr); | |||
newFilter.setPrepend(getPrepend()); | |||
newFilter.setAppend(getAppend()); | |||
@@ -105,15 +105,15 @@ public class Launcher { | |||
* | |||
* @param args commandline arguments | |||
*/ | |||
public static void main(String[] args) { | |||
public static void main(final String[] args) { | |||
int exitCode; | |||
try { | |||
Launcher launcher = new Launcher(); | |||
final Launcher launcher = new Launcher(); | |||
exitCode = launcher.run(args); | |||
} catch (LaunchException e) { | |||
} catch (final LaunchException e) { | |||
exitCode = EXIT_CODE_ERROR; | |||
System.err.println(e.getMessage()); | |||
} catch (Throwable t) { | |||
} catch (final Throwable t) { | |||
exitCode = EXIT_CODE_ERROR; | |||
t.printStackTrace(System.err); | |||
} | |||
@@ -136,26 +136,28 @@ public class Launcher { | |||
* @param libPathURLs the list of paths to add to | |||
* @throws MalformedURLException if we can't create a URL | |||
*/ | |||
private void addPath(String path, boolean getJars, List<URL> libPathURLs) | |||
private void addPath(final String path, final boolean getJars, final List<URL> libPathURLs) | |||
throws MalformedURLException { | |||
StringTokenizer tokenizer = new StringTokenizer(path, File.pathSeparator); | |||
final StringTokenizer tokenizer = new StringTokenizer(path, File.pathSeparator); | |||
while (tokenizer.hasMoreElements()) { | |||
String elementName = tokenizer.nextToken(); | |||
File element = new File(elementName); | |||
final String elementName = tokenizer.nextToken(); | |||
final File element = new File(elementName); | |||
if (elementName.indexOf('%') != -1 && !element.exists()) { | |||
continue; | |||
} | |||
if (getJars && element.isDirectory()) { | |||
// add any jars in the directory | |||
URL[] dirURLs = Locator.getLocationURLs(element); | |||
final URL[] dirURLs = Locator.getLocationURLs(element); | |||
for (int j = 0; j < dirURLs.length; ++j) { | |||
if (launchDiag) { System.out.println("adding library JAR: " + dirURLs[j]);} | |||
libPathURLs.add(dirURLs[j]); | |||
} | |||
} | |||
URL url = Locator.fileToURL(element); | |||
if (launchDiag) { System.out.println("adding library URL: " + url) ;} | |||
final URL url = Locator.fileToURL(element); | |||
if (launchDiag) { | |||
System.out.println("adding library URL: " + url); | |||
} | |||
libPathURLs.add(url); | |||
} | |||
} | |||
@@ -170,13 +172,13 @@ public class Launcher { | |||
* cannot be created. | |||
* @throws LaunchException for launching problems | |||
*/ | |||
private int run(String[] args) | |||
private int run(final String[] args) | |||
throws LaunchException, MalformedURLException { | |||
String antHomeProperty = System.getProperty(ANTHOME_PROPERTY); | |||
final String antHomeProperty = System.getProperty(ANTHOME_PROPERTY); | |||
File antHome = null; | |||
File sourceJar = Locator.getClassSource(getClass()); | |||
File jarDir = sourceJar.getParentFile(); | |||
final File sourceJar = Locator.getClassSource(getClass()); | |||
final File jarDir = sourceJar.getParentFile(); | |||
String mainClassname = MAIN_CLASS; | |||
if (antHomeProperty != null) { | |||
@@ -193,9 +195,9 @@ public class Launcher { | |||
+ "ant could not be located (estimated value="+antHome.getAbsolutePath()+")"); | |||
} | |||
List<String> libPaths = new ArrayList<String>(); | |||
final List<String> libPaths = new ArrayList<String>(); | |||
String cpString = null; | |||
List<String> argList = new ArrayList<String>(); | |||
final List<String> argList = new ArrayList<String>(); | |||
String[] newArgs; | |||
boolean noUserLib = false; | |||
boolean noClassPath = false; | |||
@@ -244,21 +246,21 @@ public class Launcher { | |||
if (argList.size() == args.length) { | |||
newArgs = args; | |||
} else { | |||
newArgs = (String[]) argList.toArray(new String[argList.size()]); | |||
newArgs = argList.toArray(new String[argList.size()]); | |||
} | |||
URL[] libURLs = getLibPathURLs( | |||
final URL[] libURLs = getLibPathURLs( | |||
noClassPath ? null : cpString, libPaths); | |||
URL[] systemURLs = getSystemURLs(jarDir); | |||
URL[] userURLs = noUserLib ? new URL[0] : getUserURLs(); | |||
final URL[] systemURLs = getSystemURLs(jarDir); | |||
final URL[] userURLs = noUserLib ? new URL[0] : getUserURLs(); | |||
File toolsJAR = Locator.getToolsJar(); | |||
final File toolsJAR = Locator.getToolsJar(); | |||
logPath("tools.jar",toolsJAR); | |||
URL[] jars = getJarArray( | |||
final URL[] jars = getJarArray( | |||
libURLs, userURLs, systemURLs, toolsJAR); | |||
// now update the class.path property | |||
StringBuffer baseClassPath | |||
final StringBuffer baseClassPath | |||
= new StringBuffer(System.getProperty(JAVA_CLASS_PATH)); | |||
if (baseClassPath.charAt(baseClassPath.length() - 1) | |||
== File.pathSeparatorChar) { | |||
@@ -272,27 +274,27 @@ public class Launcher { | |||
setProperty(JAVA_CLASS_PATH, baseClassPath.toString()); | |||
URLClassLoader loader = new URLClassLoader(jars, Launcher.class.getClassLoader()); | |||
final URLClassLoader loader = new URLClassLoader(jars, Launcher.class.getClassLoader()); | |||
Thread.currentThread().setContextClassLoader(loader); | |||
Class<?> mainClass = null; | |||
int exitCode = 0; | |||
Throwable thrown=null; | |||
try { | |||
mainClass = loader.loadClass(mainClassname); | |||
AntMain main = (AntMain) mainClass.newInstance(); | |||
final AntMain main = (AntMain) mainClass.newInstance(); | |||
main.startAnt(newArgs, null, null); | |||
} catch (InstantiationException ex) { | |||
} catch (final InstantiationException ex) { | |||
System.err.println( | |||
"Incompatible version of " + mainClassname + " detected"); | |||
File mainJar = Locator.getClassSource(mainClass); | |||
final File mainJar = Locator.getClassSource(mainClass); | |||
System.err.println( | |||
"Location of this class " + mainJar); | |||
thrown = ex; | |||
} catch (ClassNotFoundException cnfe) { | |||
} catch (final ClassNotFoundException cnfe) { | |||
System.err.println( | |||
"Failed to locate" + mainClassname); | |||
thrown = cnfe; | |||
} catch (Throwable t) { | |||
} catch (final Throwable t) { | |||
t.printStackTrace(System.err); | |||
thrown=t; | |||
} | |||
@@ -314,15 +316,15 @@ public class Launcher { | |||
* @return an array of URLs. | |||
* @throws MalformedURLException if the URLs cannot be created. | |||
*/ | |||
private URL[] getLibPathURLs(String cpString, List<String> libPaths) | |||
private URL[] getLibPathURLs(final String cpString, final List<String> libPaths) | |||
throws MalformedURLException { | |||
List<URL> libPathURLs = new ArrayList<URL>(); | |||
final List<URL> libPathURLs = new ArrayList<URL>(); | |||
if (cpString != null) { | |||
addPath(cpString, false, libPathURLs); | |||
} | |||
for (String libPath : libPaths) { | |||
for (final String libPath : libPaths) { | |||
addPath(libPath, true, libPathURLs); | |||
} | |||
@@ -337,9 +339,9 @@ public class Launcher { | |||
* @return the URLs | |||
* @throws MalformedURLException if the URLs cannot be created. | |||
*/ | |||
private URL[] getSystemURLs(File antLauncherDir) throws MalformedURLException { | |||
private URL[] getSystemURLs(final File antLauncherDir) throws MalformedURLException { | |||
File antLibDir = null; | |||
String antLibDirProperty = System.getProperty(ANTLIBDIR_PROPERTY); | |||
final String antLibDirProperty = System.getProperty(ANTLIBDIR_PROPERTY); | |||
if (antLibDirProperty != null) { | |||
antLibDir = new File(antLibDirProperty); | |||
} | |||
@@ -356,7 +358,7 @@ public class Launcher { | |||
* @throws MalformedURLException if the URLs cannot be created. | |||
*/ | |||
private URL[] getUserURLs() throws MalformedURLException { | |||
File userLibDir | |||
final File userLibDir | |||
= new File(System.getProperty(USER_HOMEDIR), USER_LIBDIR); | |||
return Locator.getLocationURLs(userLibDir); | |||
@@ -372,13 +374,13 @@ public class Launcher { | |||
* @throws MalformedURLException if there is a problem. | |||
*/ | |||
private URL[] getJarArray ( | |||
URL[] libJars, URL[] userJars, URL[] systemJars, File toolsJar) | |||
final URL[] libJars, final URL[] userJars, final URL[] systemJars, final File toolsJar) | |||
throws MalformedURLException { | |||
int numJars = libJars.length + userJars.length + systemJars.length; | |||
if (toolsJar != null) { | |||
numJars++; | |||
} | |||
URL[] jars = new URL[numJars]; | |||
final URL[] jars = new URL[numJars]; | |||
System.arraycopy(libJars, 0, jars, 0, libJars.length); | |||
System.arraycopy(userJars, 0, jars, libJars.length, userJars.length); | |||
System.arraycopy(systemJars, 0, jars, userJars.length + libJars.length, | |||
@@ -395,14 +397,14 @@ public class Launcher { | |||
* @param name property name | |||
* @param value value | |||
*/ | |||
private void setProperty(String name, String value) { | |||
private void setProperty(final String name, final String value) { | |||
if (launchDiag) { | |||
System.out.println("Setting \"" + name + "\" to \"" + value + "\""); | |||
} | |||
System.setProperty(name, value); | |||
} | |||
private void logPath(String name,File path) { | |||
private void logPath(final String name,final File path) { | |||
if(launchDiag) { | |||
System.out.println(name+"= \""+path+"\""); | |||
} | |||
@@ -27,8 +27,6 @@ import java.text.CharacterIterator; | |||
import java.text.StringCharacterIterator; | |||
import java.util.Locale; | |||
import org.apache.tools.ant.util.FileUtils; | |||
// CheckStyle:LineLengthCheck OFF - urls are long! | |||
/** | |||
* The Locator is a utility class which is used to find certain items | |||
@@ -78,7 +78,7 @@ import org.apache.tools.ant.Project; | |||
* 7 -> Reverse | |||
* 8 -> Hidden | |||
* </pre> | |||
* | |||
* | |||
* Foreground is one of the following:<pre> | |||
* 30 -> Black | |||
* 31 -> Red | |||
@@ -207,7 +207,8 @@ public class AnsiColorLogger extends DefaultLogger { | |||
* @see DefaultLogger#printMessage | |||
*/ | |||
/** {@inheritDoc}. */ | |||
protected void printMessage(final String message, | |||
@Override | |||
protected void printMessage(final String message, | |||
final PrintStream stream, | |||
final int priority) { | |||
if (message != null && stream != null) { | |||
@@ -22,34 +22,40 @@ import org.apache.tools.ant.DefaultLogger; | |||
/** | |||
* A logger which logs nothing but build failure and what task might output | |||
* | |||
* | |||
* @since 1.9.0 | |||
*/ | |||
public class SilentLogger extends DefaultLogger { | |||
public void buildStarted(BuildEvent event) { | |||
@Override | |||
public void buildStarted(BuildEvent event) { | |||
// log nothing | |||
} | |||
public void buildFinished(BuildEvent event) { | |||
@Override | |||
public void buildFinished(BuildEvent event) { | |||
if (event.getException() != null) { | |||
super.buildFinished(event); | |||
} | |||
} | |||
public void targetStarted(BuildEvent event) { | |||
@Override | |||
public void targetStarted(BuildEvent event) { | |||
// log nothing | |||
} | |||
public void targetFinished(BuildEvent event) { | |||
@Override | |||
public void targetFinished(BuildEvent event) { | |||
// log nothing | |||
} | |||
public void taskStarted(BuildEvent event) { | |||
@Override | |||
public void taskStarted(BuildEvent event) { | |||
// log nothing | |||
} | |||
public void taskFinished(BuildEvent event) { | |||
@Override | |||
public void taskFinished(BuildEvent event) { | |||
// log nothing | |||
} | |||
@@ -57,7 +57,7 @@ public class AntStructure extends Task { | |||
* The output file. | |||
* @param output the output file | |||
*/ | |||
public void setOutput(File output) { | |||
public void setOutput(final File output) { | |||
this.output = output; | |||
} | |||
@@ -66,7 +66,7 @@ public class AntStructure extends Task { | |||
* @param p the printer to use. | |||
* @since Ant 1.7 | |||
*/ | |||
public void add(StructurePrinter p) { | |||
public void add(final StructurePrinter p) { | |||
printer = p; | |||
} | |||
@@ -75,7 +75,8 @@ public class AntStructure extends Task { | |||
* | |||
* @exception BuildException if the DTD cannot be written. | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
if (output == null) { | |||
throw new BuildException("output attribute is required", getLocation()); | |||
@@ -85,7 +86,7 @@ public class AntStructure extends Task { | |||
try { | |||
try { | |||
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(output), "UTF8")); | |||
} catch (UnsupportedEncodingException ue) { | |||
} catch (final UnsupportedEncodingException ue) { | |||
/* | |||
* Plain impossible with UTF8, see | |||
* http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html | |||
@@ -101,14 +102,14 @@ public class AntStructure extends Task { | |||
printer.printTargetDecl(out); | |||
for (String typeName : getProject().getCopyOfDataTypeDefinitions() | |||
for (final String typeName : getProject().getCopyOfDataTypeDefinitions() | |||
.keySet()) { | |||
printer.printElementDecl( | |||
out, getProject(), typeName, | |||
getProject().getDataTypeDefinitions().get(typeName)); | |||
} | |||
for (String tName : getProject().getCopyOfTaskDefinitions().keySet()) { | |||
for (final String tName : getProject().getCopyOfTaskDefinitions().keySet()) { | |||
printer.printElementDecl(out, getProject(), tName, | |||
getProject().getTaskDefinitions().get(tName)); | |||
} | |||
@@ -119,7 +120,7 @@ public class AntStructure extends Task { | |||
throw new IOException("Encountered an error writing Ant" | |||
+ " structure"); | |||
} | |||
} catch (IOException ioe) { | |||
} catch (final IOException ioe) { | |||
throw new BuildException("Error writing " | |||
+ output.getAbsolutePath(), ioe, getLocation()); | |||
} finally { | |||
@@ -136,7 +137,7 @@ public class AntStructure extends Task { | |||
* are called exactly once, {@link #printElementDecl} once for | |||
* each declared task and type.</p> | |||
*/ | |||
public static interface StructurePrinter { | |||
public interface StructurePrinter { | |||
/** | |||
* Prints the header of the generated output. | |||
* | |||
@@ -179,14 +180,16 @@ public class AntStructure extends Task { | |||
private static final String TASKS = "%tasks;"; | |||
private static final String TYPES = "%types;"; | |||
private Hashtable<String, String> visited = new Hashtable<String, String>(); | |||
private final Hashtable<String, String> visited = new Hashtable<String, String>(); | |||
public void printTail(PrintWriter out) { | |||
@Override | |||
public void printTail(final PrintWriter out) { | |||
visited.clear(); | |||
} | |||
public void printHead(PrintWriter out, Project p, Hashtable<String, Class<?>> tasks, | |||
Hashtable<String, Class<?>> types) { | |||
@Override | |||
public void printHead(final PrintWriter out, final Project p, final Hashtable<String, Class<?>> tasks, | |||
final Hashtable<String, Class<?>> types) { | |||
printHead(out, tasks.keys(), types.keys()); | |||
} | |||
@@ -197,14 +200,14 @@ public class AntStructure extends Task { | |||
* <p>Basically this prints the XML declaration, defines some | |||
* entities and the project element.</p> | |||
*/ | |||
private void printHead(PrintWriter out, Enumeration<String> tasks, | |||
Enumeration<String> types) { | |||
private void printHead(final PrintWriter out, final Enumeration<String> tasks, | |||
final Enumeration<String> types) { | |||
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); | |||
out.println("<!ENTITY % boolean \"(true|false|on|off|yes|no)\">"); | |||
out.print("<!ENTITY % tasks \""); | |||
boolean first = true; | |||
while (tasks.hasMoreElements()) { | |||
String tName = tasks.nextElement(); | |||
final String tName = tasks.nextElement(); | |||
if (!first) { | |||
out.print(" | "); | |||
} else { | |||
@@ -216,7 +219,7 @@ public class AntStructure extends Task { | |||
out.print("<!ENTITY % types \""); | |||
first = true; | |||
while (types.hasMoreElements()) { | |||
String typeName = types.nextElement(); | |||
final String typeName = types.nextElement(); | |||
if (!first) { | |||
out.print(" | "); | |||
} else { | |||
@@ -243,7 +246,8 @@ public class AntStructure extends Task { | |||
/** | |||
* Prints the definition for the target element. | |||
*/ | |||
public void printTargetDecl(PrintWriter out) { | |||
@Override | |||
public void printTargetDecl(final PrintWriter out) { | |||
out.print("<!ELEMENT target ("); | |||
out.print(TASKS); | |||
out.print(" | "); | |||
@@ -259,7 +263,7 @@ public class AntStructure extends Task { | |||
/** | |||
* Prints the definition for the target element. | |||
*/ | |||
private void printTargetAttrs(PrintWriter out, String tag) { | |||
private void printTargetAttrs(final PrintWriter out, final String tag) { | |||
out.print("<!ATTLIST "); | |||
out.println(tag); | |||
out.println(" id ID #IMPLIED"); | |||
@@ -276,8 +280,9 @@ public class AntStructure extends Task { | |||
/** | |||
* Print the definition for a given element. | |||
*/ | |||
public void printElementDecl(PrintWriter out, Project p, | |||
String name, Class<?> element) { | |||
@Override | |||
public void printElementDecl(final PrintWriter out, final Project p, | |||
final String name, final Class<?> element) { | |||
if (visited.containsKey(name)) { | |||
return; | |||
@@ -287,7 +292,7 @@ public class AntStructure extends Task { | |||
IntrospectionHelper ih = null; | |||
try { | |||
ih = IntrospectionHelper.getHelper(p, element); | |||
} catch (Throwable t) { | |||
} catch (final Throwable t) { | |||
/* | |||
* TODO - failed to load the class properly. | |||
* | |||
@@ -309,7 +314,7 @@ public class AntStructure extends Task { | |||
return; | |||
} | |||
Vector<String> v = new Vector<String>(); | |||
final Vector<String> v = new Vector<String>(); | |||
if (ih.supportsCharacters()) { | |||
v.addElement("#PCDATA"); | |||
} | |||
@@ -348,14 +353,14 @@ public class AntStructure extends Task { | |||
e = ih.getAttributes(); | |||
while (e.hasMoreElements()) { | |||
String attrName = (String) e.nextElement(); | |||
final String attrName = e.nextElement(); | |||
if ("id".equals(attrName)) { | |||
continue; | |||
} | |||
sb.append(LINE_SEP).append(" ") | |||
.append(attrName).append(" "); | |||
Class<?> type = ih.getAttributeType(attrName); | |||
final Class<?> type = ih.getAttributeType(attrName); | |||
if (type.equals(java.lang.Boolean.class) | |||
|| type.equals(java.lang.Boolean.TYPE)) { | |||
sb.append(BOOLEAN).append(" "); | |||
@@ -363,9 +368,9 @@ public class AntStructure extends Task { | |||
sb.append("IDREF "); | |||
} else if (EnumeratedAttribute.class.isAssignableFrom(type)) { | |||
try { | |||
EnumeratedAttribute ea = | |||
final EnumeratedAttribute ea = | |||
(EnumeratedAttribute) type.newInstance(); | |||
String[] values = ea.getValues(); | |||
final String[] values = ea.getValues(); | |||
if (values == null | |||
|| values.length == 0 | |||
|| !areNmtokens(values)) { | |||
@@ -380,15 +385,15 @@ public class AntStructure extends Task { | |||
} | |||
sb.append(") "); | |||
} | |||
} catch (InstantiationException ie) { | |||
} catch (final InstantiationException ie) { | |||
sb.append("CDATA "); | |||
} catch (IllegalAccessException ie) { | |||
} catch (final IllegalAccessException ie) { | |||
sb.append("CDATA "); | |||
} | |||
} else if (type.getSuperclass() != null | |||
&& type.getSuperclass().getName().equals("java.lang.Enum")) { | |||
try { | |||
Object[] values = (Object[]) type.getMethod("values", (Class[]) null) | |||
final Object[] values = (Object[]) type.getMethod("values", (Class[]) null) | |||
.invoke(null, (Object[]) null); | |||
if (values.length == 0) { | |||
sb.append("CDATA "); | |||
@@ -403,7 +408,7 @@ public class AntStructure extends Task { | |||
} | |||
sb.append(") "); | |||
} | |||
} catch (Exception x) { | |||
} catch (final Exception x) { | |||
sb.append("CDATA "); | |||
} | |||
} else { | |||
@@ -416,7 +421,7 @@ public class AntStructure extends Task { | |||
final int count = v.size(); | |||
for (int i = 0; i < count; i++) { | |||
String nestedName = (String) v.elementAt(i); | |||
final String nestedName = v.elementAt(i); | |||
if (!"#PCDATA".equals(nestedName) | |||
&& !TASKS.equals(nestedName) | |||
&& !TYPES.equals(nestedName)) { | |||
@@ -430,10 +435,10 @@ public class AntStructure extends Task { | |||
* @param s the string to test | |||
* @return true if the string matches the XML-NMTOKEN | |||
*/ | |||
public static final boolean isNmtoken(String s) { | |||
public static final boolean isNmtoken(final String s) { | |||
final int length = s.length(); | |||
for (int i = 0; i < length; i++) { | |||
char c = s.charAt(i); | |||
final char c = s.charAt(i); | |||
// TODO - we are committing CombiningChar and Extender here | |||
if (!Character.isLetterOrDigit(c) | |||
&& c != '.' && c != '-' && c != '_' && c != ':') { | |||
@@ -451,7 +456,7 @@ public class AntStructure extends Task { | |||
* @param s the array of string to test | |||
* @return true if all the strings in the array math XML-NMTOKEN | |||
*/ | |||
public static final boolean areNmtokens(String[] s) { | |||
public static final boolean areNmtokens(final String[] s) { | |||
for (int i = 0; i < s.length; i++) { | |||
if (!isNmtoken(s[i])) { | |||
return false; | |||
@@ -466,7 +471,7 @@ public class AntStructure extends Task { | |||
* @param s the string to test | |||
* @return true if the string matches the XML-NMTOKEN | |||
*/ | |||
protected boolean isNmtoken(String s) { | |||
protected boolean isNmtoken(final String s) { | |||
return DTDPrinter.isNmtoken(s); | |||
} | |||
@@ -478,7 +483,7 @@ public class AntStructure extends Task { | |||
* @param s the array of string to test | |||
* @return true if all the strings in the array math XML-NMTOKEN | |||
*/ | |||
protected boolean areNmtokens(String[] s) { | |||
protected boolean areNmtokens(final String[] s) { | |||
return DTDPrinter.areNmtokens(s); | |||
} | |||
} |
@@ -33,37 +33,38 @@ public class BindTargets extends Task { | |||
private String extensionPoint; | |||
private List<String> targets = new ArrayList<String>(); | |||
private final List<String> targets = new ArrayList<String>(); | |||
private OnMissingExtensionPoint onMissingExtensionPoint; | |||
public void setExtensionPoint(String extensionPoint) { | |||
public void setExtensionPoint(final String extensionPoint) { | |||
this.extensionPoint = extensionPoint; | |||
} | |||
public void setOnMissingExtensionPoint(String onMissingExtensionPoint) { | |||
public void setOnMissingExtensionPoint(final String onMissingExtensionPoint) { | |||
try { | |||
this.onMissingExtensionPoint = OnMissingExtensionPoint.valueOf(onMissingExtensionPoint); | |||
} catch (IllegalArgumentException e) { | |||
} catch (final IllegalArgumentException e) { | |||
throw new BuildException("Invalid onMissingExtensionPoint: " + onMissingExtensionPoint); | |||
} | |||
} | |||
public void setOnMissingExtensionPoint(OnMissingExtensionPoint onMissingExtensionPoint) { | |||
public void setOnMissingExtensionPoint(final OnMissingExtensionPoint onMissingExtensionPoint) { | |||
this.onMissingExtensionPoint = onMissingExtensionPoint; | |||
} | |||
public void setTargets(String target) { | |||
String[] inputs = target.split(","); | |||
public void setTargets(final String target) { | |||
final String[] inputs = target.split(","); | |||
for (int i = 0; i < inputs.length; i++) { | |||
String input = inputs[i].trim(); | |||
final String input = inputs[i].trim(); | |||
if (input.length() > 0) { | |||
targets.add(input); | |||
} | |||
} | |||
} | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
if (extensionPoint == null) { | |||
throw new BuildException("extensionPoint required", getLocation()); | |||
} | |||
@@ -77,13 +78,13 @@ public class BindTargets extends Task { | |||
if (onMissingExtensionPoint == null) { | |||
onMissingExtensionPoint = OnMissingExtensionPoint.FAIL; | |||
} | |||
ProjectHelper helper = (ProjectHelper) getProject().getReference( | |||
final ProjectHelper helper = (ProjectHelper) getProject().getReference( | |||
ProjectHelper.PROJECTHELPER_REFERENCE); | |||
for (Iterator<String> itTarget = targets.iterator(); itTarget.hasNext();) { | |||
for (final Iterator<String> itTarget = targets.iterator(); itTarget.hasNext();) { | |||
helper.getExtensionStack().add( | |||
new String[] { extensionPoint, itTarget.next(), | |||
onMissingExtensionPoint.name() }); | |||
new String[] {extensionPoint, itTarget.next(), | |||
onMissingExtensionPoint.name()}); | |||
} | |||
} | |||
@@ -23,7 +23,7 @@ package org.apache.tools.ant.taskdefs; | |||
* <p>Used in the current project two attributes are needed, the name that identifies | |||
* this component uniquely, and the full name of the class (including the packages) that | |||
* implements this component.</p> | |||
* | |||
* | |||
* @since Ant 1.8 | |||
* @ant.task category="internal" | |||
*/ | |||
@@ -95,8 +95,8 @@ public class Copy extends Task { | |||
protected Mapper mapperElement = null; | |||
protected FileUtils fileUtils; | |||
//CheckStyle:VisibilityModifier ON | |||
private Vector<FilterChain> filterChains = new Vector<FilterChain>(); | |||
private Vector<FilterSet> filterSets = new Vector<FilterSet>(); | |||
private final Vector<FilterChain> filterChains = new Vector<FilterChain>(); | |||
private final Vector<FilterSet> filterSets = new Vector<FilterSet>(); | |||
private String inputEncoding = null; | |||
private String outputEncoding = null; | |||
private long granularity = 0; | |||
@@ -127,7 +127,7 @@ public class Copy extends Task { | |||
* Set a single source file to copy. | |||
* @param file the file to copy. | |||
*/ | |||
public void setFile(File file) { | |||
public void setFile(final File file) { | |||
this.file = file; | |||
} | |||
@@ -135,7 +135,7 @@ public class Copy extends Task { | |||
* Set the destination file. | |||
* @param destFile the file to copy to. | |||
*/ | |||
public void setTofile(File destFile) { | |||
public void setTofile(final File destFile) { | |||
this.destFile = destFile; | |||
} | |||
@@ -143,7 +143,7 @@ public class Copy extends Task { | |||
* Set the destination directory. | |||
* @param destDir the destination directory. | |||
*/ | |||
public void setTodir(File destDir) { | |||
public void setTodir(final File destDir) { | |||
this.destDir = destDir; | |||
} | |||
@@ -152,7 +152,7 @@ public class Copy extends Task { | |||
* @return a filter chain object. | |||
*/ | |||
public FilterChain createFilterChain() { | |||
FilterChain filterChain = new FilterChain(); | |||
final FilterChain filterChain = new FilterChain(); | |||
filterChains.addElement(filterChain); | |||
return filterChain; | |||
} | |||
@@ -162,7 +162,7 @@ public class Copy extends Task { | |||
* @return a filter set object. | |||
*/ | |||
public FilterSet createFilterSet() { | |||
FilterSet filterSet = new FilterSet(); | |||
final FilterSet filterSet = new FilterSet(); | |||
filterSets.addElement(filterSet); | |||
return filterSet; | |||
} | |||
@@ -175,7 +175,8 @@ public class Copy extends Task { | |||
* replaced with setPreserveLastModified(boolean) to | |||
* consistently let the Introspection mechanism work. | |||
*/ | |||
public void setPreserveLastModified(String preserve) { | |||
@Deprecated | |||
public void setPreserveLastModified(final String preserve) { | |||
setPreserveLastModified(Project.toBoolean(preserve)); | |||
} | |||
@@ -183,7 +184,7 @@ public class Copy extends Task { | |||
* Give the copied files the same last modified time as the original files. | |||
* @param preserve if true preserve the modified time; default is false. | |||
*/ | |||
public void setPreserveLastModified(boolean preserve) { | |||
public void setPreserveLastModified(final boolean preserve) { | |||
preserveLastModified = preserve; | |||
} | |||
@@ -220,7 +221,7 @@ public class Copy extends Task { | |||
* Set filtering mode. | |||
* @param filtering if true enable filtering; default is false. | |||
*/ | |||
public void setFiltering(boolean filtering) { | |||
public void setFiltering(final boolean filtering) { | |||
this.filtering = filtering; | |||
} | |||
@@ -230,7 +231,7 @@ public class Copy extends Task { | |||
* even if the destination file(s) are younger than | |||
* the corresponding source file. Default is false. | |||
*/ | |||
public void setOverwrite(boolean overwrite) { | |||
public void setOverwrite(final boolean overwrite) { | |||
this.forceOverwrite = overwrite; | |||
} | |||
@@ -241,7 +242,7 @@ public class Copy extends Task { | |||
* | |||
* @since Ant 1.8.2 | |||
*/ | |||
public void setForce(boolean f) { | |||
public void setForce(final boolean f) { | |||
force = f; | |||
} | |||
@@ -263,7 +264,7 @@ public class Copy extends Task { | |||
* @param flatten if true flatten the destination directory. Default | |||
* is false. | |||
*/ | |||
public void setFlatten(boolean flatten) { | |||
public void setFlatten(final boolean flatten) { | |||
this.flatten = flatten; | |||
} | |||
@@ -272,7 +273,7 @@ public class Copy extends Task { | |||
* @param verbose whether to output the names of copied files. | |||
* Default is false. | |||
*/ | |||
public void setVerbose(boolean verbose) { | |||
public void setVerbose(final boolean verbose) { | |||
this.verbosity = verbose ? Project.MSG_INFO : Project.MSG_VERBOSE; | |||
} | |||
@@ -280,7 +281,7 @@ public class Copy extends Task { | |||
* Set whether to copy empty directories. | |||
* @param includeEmpty if true copy empty directories. Default is true. | |||
*/ | |||
public void setIncludeEmptyDirs(boolean includeEmpty) { | |||
public void setIncludeEmptyDirs(final boolean includeEmpty) { | |||
this.includeEmpty = includeEmpty; | |||
} | |||
@@ -292,7 +293,7 @@ public class Copy extends Task { | |||
* whether or not to display error messages when a file or | |||
* directory does not exist. Default is false. | |||
*/ | |||
public void setQuiet(boolean quiet) { | |||
public void setQuiet(final boolean quiet) { | |||
this.quiet = quiet; | |||
} | |||
@@ -307,7 +308,7 @@ public class Copy extends Task { | |||
* compatibility with earlier releases. | |||
* @since Ant 1.6 | |||
*/ | |||
public void setEnableMultipleMappings(boolean enableMultipleMappings) { | |||
public void setEnableMultipleMappings(final boolean enableMultipleMappings) { | |||
this.enableMultipleMappings = enableMultipleMappings; | |||
} | |||
@@ -324,7 +325,7 @@ public class Copy extends Task { | |||
* to the output but keep going. Default is true. | |||
* @param failonerror true or false. | |||
*/ | |||
public void setFailOnError(boolean failonerror) { | |||
public void setFailOnError(final boolean failonerror) { | |||
this.failonerror = failonerror; | |||
} | |||
@@ -332,7 +333,7 @@ public class Copy extends Task { | |||
* Add a set of files to copy. | |||
* @param set a set of files to copy. | |||
*/ | |||
public void addFileset(FileSet set) { | |||
public void addFileset(final FileSet set) { | |||
add(set); | |||
} | |||
@@ -341,7 +342,7 @@ public class Copy extends Task { | |||
* @param res a resource collection to copy. | |||
* @since Ant 1.7 | |||
*/ | |||
public void add(ResourceCollection res) { | |||
public void add(final ResourceCollection res) { | |||
rcs.add(res); | |||
} | |||
@@ -364,7 +365,7 @@ public class Copy extends Task { | |||
* @param fileNameMapper the mapper to add. | |||
* @since Ant 1.6.3 | |||
*/ | |||
public void add(FileNameMapper fileNameMapper) { | |||
public void add(final FileNameMapper fileNameMapper) { | |||
createMapper().add(fileNameMapper); | |||
} | |||
@@ -373,7 +374,7 @@ public class Copy extends Task { | |||
* @param encoding the character encoding. | |||
* @since 1.32, Ant 1.5 | |||
*/ | |||
public void setEncoding(String encoding) { | |||
public void setEncoding(final String encoding) { | |||
this.inputEncoding = encoding; | |||
if (outputEncoding == null) { | |||
outputEncoding = encoding; | |||
@@ -395,7 +396,7 @@ public class Copy extends Task { | |||
* @param encoding the output character encoding. | |||
* @since Ant 1.6 | |||
*/ | |||
public void setOutputEncoding(String encoding) { | |||
public void setOutputEncoding(final String encoding) { | |||
this.outputEncoding = encoding; | |||
} | |||
@@ -419,7 +420,7 @@ public class Copy extends Task { | |||
* date. | |||
* @since Ant 1.6.2 | |||
*/ | |||
public void setGranularity(long granularity) { | |||
public void setGranularity(final long granularity) { | |||
this.granularity = granularity; | |||
} | |||
@@ -427,21 +428,22 @@ public class Copy extends Task { | |||
* Perform the copy operation. | |||
* @exception BuildException if an error occurs. | |||
*/ | |||
public void execute() throws BuildException { | |||
File savedFile = file; // may be altered in validateAttributes | |||
File savedDestFile = destFile; | |||
File savedDestDir = destDir; | |||
@Override | |||
public void execute() throws BuildException { | |||
final File savedFile = file; // may be altered in validateAttributes | |||
final File savedDestFile = destFile; | |||
final File savedDestDir = destDir; | |||
ResourceCollection savedRc = null; | |||
if (file == null && destFile != null && rcs.size() == 1) { | |||
// will be removed in validateAttributes | |||
savedRc = (ResourceCollection) rcs.elementAt(0); | |||
savedRc = rcs.elementAt(0); | |||
} | |||
try { | |||
// make sure we don't have an illegal set of options | |||
try { | |||
validateAttributes(); | |||
} catch (BuildException e) { | |||
} catch (final BuildException e) { | |||
if (failonerror | |||
|| !getMessage(e) | |||
.equals(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE)) { | |||
@@ -472,21 +474,21 @@ public class Copy extends Task { | |||
separate lists and then each list is handled in one go. | |||
*/ | |||
HashMap<File, List<String>> filesByBasedir = new HashMap<File, List<String>>(); | |||
HashMap<File, List<String>> dirsByBasedir = new HashMap<File, List<String>>(); | |||
HashSet<File> baseDirs = new HashSet<File>(); | |||
ArrayList<Resource> nonFileResources = new ArrayList<Resource>(); | |||
final HashMap<File, List<String>> filesByBasedir = new HashMap<File, List<String>>(); | |||
final HashMap<File, List<String>> dirsByBasedir = new HashMap<File, List<String>>(); | |||
final HashSet<File> baseDirs = new HashSet<File>(); | |||
final ArrayList<Resource> nonFileResources = new ArrayList<Resource>(); | |||
final int size = rcs.size(); | |||
for (int i = 0; i < size; i++) { | |||
ResourceCollection rc = rcs.elementAt(i); | |||
final ResourceCollection rc = rcs.elementAt(i); | |||
// Step (1) - beware of the ZipFileSet | |||
if (rc instanceof FileSet && rc.isFilesystemOnly()) { | |||
FileSet fs = (FileSet) rc; | |||
final FileSet fs = (FileSet) rc; | |||
DirectoryScanner ds = null; | |||
try { | |||
ds = fs.getDirectoryScanner(getProject()); | |||
} catch (BuildException e) { | |||
} catch (final BuildException e) { | |||
if (failonerror | |||
|| !getMessage(e).endsWith(DirectoryScanner | |||
.DOES_NOT_EXIST_POSTFIX)) { | |||
@@ -498,10 +500,10 @@ public class Copy extends Task { | |||
continue; | |||
} | |||
} | |||
File fromDir = fs.getDir(getProject()); | |||
final File fromDir = fs.getDir(getProject()); | |||
String[] srcFiles = ds.getIncludedFiles(); | |||
String[] srcDirs = ds.getIncludedDirectories(); | |||
final String[] srcFiles = ds.getIncludedFiles(); | |||
final String[] srcDirs = ds.getIncludedDirectories(); | |||
if (!flatten && mapperElement == null | |||
&& ds.isEverythingIncluded() && !fs.hasPatterns()) { | |||
completeDirMap.put(fromDir, destDir); | |||
@@ -516,9 +518,9 @@ public class Copy extends Task { | |||
"Only FileSystem resources are supported."); | |||
} | |||
for (Resource r : rc) { | |||
for (final Resource r : rc) { | |||
if (!r.isExists()) { | |||
String message = "Warning: Could not find resource " | |||
final String message = "Warning: Could not find resource " | |||
+ r.toLongString() + " to copy."; | |||
if (!failonerror) { | |||
if (!quiet) { | |||
@@ -532,9 +534,9 @@ public class Copy extends Task { | |||
File baseDir = NULL_FILE_PLACEHOLDER; | |||
String name = r.getName(); | |||
FileProvider fp = r.as(FileProvider.class); | |||
final FileProvider fp = r.as(FileProvider.class); | |||
if (fp != null) { | |||
FileResource fr = ResourceUtils.asFileResource(fp); | |||
final FileResource fr = ResourceUtils.asFileResource(fp); | |||
baseDir = getKeyFile(fr.getBaseDir()); | |||
if (fr.getBaseDir() == null) { | |||
name = fr.getFile().getAbsolutePath(); | |||
@@ -562,7 +564,7 @@ public class Copy extends Task { | |||
// do all the copy operations now... | |||
try { | |||
doFileOperations(); | |||
} catch (BuildException e) { | |||
} catch (final BuildException e) { | |||
if (!failonerror) { | |||
if (!quiet) { | |||
log("Warning: " + getMessage(e), Project.MSG_ERR); | |||
@@ -573,17 +575,17 @@ public class Copy extends Task { | |||
} | |||
if (nonFileResources.size() > 0 || singleResource != null) { | |||
Resource[] nonFiles = | |||
(Resource[]) nonFileResources.toArray(new Resource[nonFileResources.size()]); | |||
final Resource[] nonFiles = | |||
nonFileResources.toArray(new Resource[nonFileResources.size()]); | |||
// restrict to out-of-date resources | |||
Map<Resource, String[]> map = scan(nonFiles, destDir); | |||
final Map<Resource, String[]> map = scan(nonFiles, destDir); | |||
if (singleResource != null) { | |||
map.put(singleResource, | |||
new String[] { destFile.getAbsolutePath() }); | |||
new String[] {destFile.getAbsolutePath()}); | |||
} | |||
try { | |||
doResourceOperations(map); | |||
} catch (BuildException e) { | |||
} catch (final BuildException e) { | |||
if (!failonerror) { | |||
if (!quiet) { | |||
log("Warning: " + getMessage(e), Project.MSG_ERR); | |||
@@ -630,7 +632,7 @@ public class Copy extends Task { | |||
+ " is up to date.", Project.MSG_VERBOSE); | |||
} | |||
} else { | |||
String message = "Warning: Could not find file " | |||
final String message = "Warning: Could not find file " | |||
+ file.getAbsolutePath() + " to copy."; | |||
if (!failonerror) { | |||
if (!quiet) { | |||
@@ -644,11 +646,11 @@ public class Copy extends Task { | |||
} | |||
private void iterateOverBaseDirs( | |||
HashSet<File> baseDirs, HashMap<File, List<String>> dirsByBasedir, HashMap<File, List<String>> filesByBasedir) { | |||
final HashSet<File> baseDirs, final HashMap<File, List<String>> dirsByBasedir, final HashMap<File, List<String>> filesByBasedir) { | |||
for (File f : baseDirs) { | |||
List<String> files = filesByBasedir.get(f); | |||
List<String> dirs = dirsByBasedir.get(f); | |||
for (final File f : baseDirs) { | |||
final List<String> files = filesByBasedir.get(f); | |||
final List<String> dirs = dirsByBasedir.get(f); | |||
String[] srcFiles = new String[0]; | |||
if (files != null) { | |||
@@ -689,7 +691,7 @@ public class Copy extends Task { | |||
throw new BuildException( | |||
"Cannot concatenate multiple files into a single file."); | |||
} else { | |||
ResourceCollection rc = (ResourceCollection) rcs.elementAt(0); | |||
final ResourceCollection rc = rcs.elementAt(0); | |||
if (!rc.isFilesystemOnly() && !supportsNonFileResources()) { | |||
throw new BuildException("Only FileSystem resources are" | |||
+ " supported."); | |||
@@ -697,8 +699,8 @@ public class Copy extends Task { | |||
if (rc.size() == 0) { | |||
throw new BuildException(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE); | |||
} else if (rc.size() == 1) { | |||
Resource res = rc.iterator().next(); | |||
FileProvider r = res.as(FileProvider.class); | |||
final Resource res = rc.iterator().next(); | |||
final FileProvider r = res.as(FileProvider.class); | |||
if (file == null) { | |||
if (r != null) { | |||
file = r.getFile(); | |||
@@ -730,9 +732,9 @@ public class Copy extends Task { | |||
* @param files A list of files to copy. | |||
* @param dirs A list of directories to copy. | |||
*/ | |||
protected void scan(File fromDir, File toDir, String[] files, | |||
String[] dirs) { | |||
FileNameMapper mapper = getMapper(); | |||
protected void scan(final File fromDir, final File toDir, final String[] files, | |||
final String[] dirs) { | |||
final FileNameMapper mapper = getMapper(); | |||
buildMap(fromDir, toDir, files, mapper, fileCopyMap); | |||
if (includeEmpty) { | |||
@@ -752,7 +754,7 @@ public class Copy extends Task { | |||
* | |||
* @since Ant 1.7 | |||
*/ | |||
protected Map<Resource, String[]> scan(Resource[] fromResources, File toDir) { | |||
protected Map<Resource, String[]> scan(final Resource[] fromResources, final File toDir) { | |||
return buildMap(fromResources, toDir, getMapper()); | |||
} | |||
@@ -765,11 +767,11 @@ public class Copy extends Task { | |||
* @param mapper a <code>FileNameMapper</code> value. | |||
* @param map a map of source file to array of destination files. | |||
*/ | |||
protected void buildMap(File fromDir, File toDir, String[] names, | |||
FileNameMapper mapper, Hashtable<String, String[]> map) { | |||
protected void buildMap(final File fromDir, final File toDir, final String[] names, | |||
final FileNameMapper mapper, final Hashtable<String, String[]> map) { | |||
String[] toCopy = null; | |||
if (forceOverwrite) { | |||
Vector<String> v = new Vector<String>(); | |||
final Vector<String> v = new Vector<String>(); | |||
for (int i = 0; i < names.length; i++) { | |||
if (mapper.mapFileName(names[i]) != null) { | |||
v.addElement(names[i]); | |||
@@ -778,12 +780,12 @@ public class Copy extends Task { | |||
toCopy = new String[v.size()]; | |||
v.copyInto(toCopy); | |||
} else { | |||
SourceFileScanner ds = new SourceFileScanner(this); | |||
final SourceFileScanner ds = new SourceFileScanner(this); | |||
toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity); | |||
} | |||
for (int i = 0; i < toCopy.length; i++) { | |||
File src = new File(fromDir, toCopy[i]); | |||
String[] mappedFiles = mapper.mapFileName(toCopy[i]); | |||
final File src = new File(fromDir, toCopy[i]); | |||
final String[] mappedFiles = mapper.mapFileName(toCopy[i]); | |||
if (!enableMultipleMappings) { | |||
map.put(src.getAbsolutePath(), | |||
@@ -807,12 +809,12 @@ public class Copy extends Task { | |||
* @return a map of source resource to array of destination files. | |||
* @since Ant 1.7 | |||
*/ | |||
protected Map<Resource, String[]> buildMap(Resource[] fromResources, final File toDir, | |||
FileNameMapper mapper) { | |||
HashMap<Resource, String[]> map = new HashMap<Resource, String[]>(); | |||
protected Map<Resource, String[]> buildMap(final Resource[] fromResources, final File toDir, | |||
final FileNameMapper mapper) { | |||
final HashMap<Resource, String[]> map = new HashMap<Resource, String[]>(); | |||
Resource[] toCopy = null; | |||
if (forceOverwrite) { | |||
Vector<Resource> v = new Vector<Resource>(); | |||
final Vector<Resource> v = new Vector<Resource>(); | |||
for (int i = 0; i < fromResources.length; i++) { | |||
if (mapper.mapFileName(fromResources[i].getName()) != null) { | |||
v.addElement(fromResources[i]); | |||
@@ -825,14 +827,15 @@ public class Copy extends Task { | |||
ResourceUtils.selectOutOfDateSources(this, fromResources, | |||
mapper, | |||
new ResourceFactory() { | |||
public Resource getResource(String name) { | |||
@Override | |||
public Resource getResource(final String name) { | |||
return new FileResource(toDir, name); | |||
} | |||
}, | |||
granularity); | |||
} | |||
for (int i = 0; i < toCopy.length; i++) { | |||
String[] mappedFiles = mapper.mapFileName(toCopy[i].getName()); | |||
final String[] mappedFiles = mapper.mapFileName(toCopy[i].getName()); | |||
for (int j = 0; j < mappedFiles.length; j++) { | |||
if (mappedFiles[j] == null) { | |||
throw new BuildException("Can't copy a resource without a" | |||
@@ -865,12 +868,12 @@ public class Copy extends Task { | |||
+ " file" + (fileCopyMap.size() == 1 ? "" : "s") | |||
+ " to " + destDir.getAbsolutePath()); | |||
for (Map.Entry<String, String[]> e : fileCopyMap.entrySet()) { | |||
String fromFile = e.getKey(); | |||
String[] toFiles = e.getValue(); | |||
for (final Map.Entry<String, String[]> e : fileCopyMap.entrySet()) { | |||
final String fromFile = e.getKey(); | |||
final String[] toFiles = e.getValue(); | |||
for (int i = 0; i < toFiles.length; i++) { | |||
String toFile = toFiles[i]; | |||
final String toFile = toFiles[i]; | |||
if (fromFile.equals(toFile)) { | |||
log("Skipping self-copy of " + fromFile, verbosity); | |||
@@ -879,13 +882,13 @@ public class Copy extends Task { | |||
try { | |||
log("Copying " + fromFile + " to " + toFile, verbosity); | |||
FilterSetCollection executionFilters = | |||
final FilterSetCollection executionFilters = | |||
new FilterSetCollection(); | |||
if (filtering) { | |||
executionFilters | |||
.addFilterSet(getProject().getGlobalFilterSet()); | |||
} | |||
for (FilterSet filterSet : filterSets) { | |||
for (final FilterSet filterSet : filterSets) { | |||
executionFilters.addFilterSet(filterSet); | |||
} | |||
fileUtils.copyFile(new File(fromFile), new File(toFile), | |||
@@ -895,10 +898,10 @@ public class Copy extends Task { | |||
/* append: */ false, inputEncoding, | |||
outputEncoding, getProject(), | |||
getForce()); | |||
} catch (IOException ioe) { | |||
} catch (final IOException ioe) { | |||
String msg = "Failed to copy " + fromFile + " to " + toFile | |||
+ " due to " + getDueTo(ioe); | |||
File targetFile = new File(toFile); | |||
final File targetFile = new File(toFile); | |||
if (!(ioe instanceof | |||
ResourceUtils.ReadOnlyTargetFileException) | |||
&& targetFile.exists() && !targetFile.delete()) { | |||
@@ -914,9 +917,9 @@ public class Copy extends Task { | |||
} | |||
if (includeEmpty) { | |||
int createCount = 0; | |||
for (String[] dirs : dirCopyMap.values()) { | |||
for (final String[] dirs : dirCopyMap.values()) { | |||
for (int i = 0; i < dirs.length; i++) { | |||
File d = new File(dirs[i]); | |||
final File d = new File(dirs[i]); | |||
if (!d.exists()) { | |||
if (!(d.mkdirs() || d.isDirectory())) { | |||
log("Unable to create directory " | |||
@@ -945,25 +948,25 @@ public class Copy extends Task { | |||
* @param map a map of source resource to array of destination files. | |||
* @since Ant 1.7 | |||
*/ | |||
protected void doResourceOperations(Map<Resource, String[]> map) { | |||
protected void doResourceOperations(final Map<Resource, String[]> map) { | |||
if (map.size() > 0) { | |||
log("Copying " + map.size() | |||
+ " resource" + (map.size() == 1 ? "" : "s") | |||
+ " to " + destDir.getAbsolutePath()); | |||
for (Map.Entry<Resource, String[]> e : map.entrySet()) { | |||
Resource fromResource = e.getKey(); | |||
for (String toFile : e.getValue()) { | |||
for (final Map.Entry<Resource, String[]> e : map.entrySet()) { | |||
final Resource fromResource = e.getKey(); | |||
for (final String toFile : e.getValue()) { | |||
try { | |||
log("Copying " + fromResource + " to " + toFile, | |||
verbosity); | |||
FilterSetCollection executionFilters = new FilterSetCollection(); | |||
final FilterSetCollection executionFilters = new FilterSetCollection(); | |||
if (filtering) { | |||
executionFilters | |||
.addFilterSet(getProject().getGlobalFilterSet()); | |||
} | |||
for (FilterSet filterSet : filterSets) { | |||
for (final FilterSet filterSet : filterSets) { | |||
executionFilters.addFilterSet(filterSet); | |||
} | |||
ResourceUtils.copyResource(fromResource, | |||
@@ -978,11 +981,11 @@ public class Copy extends Task { | |||
outputEncoding, | |||
getProject(), | |||
getForce()); | |||
} catch (IOException ioe) { | |||
} catch (final IOException ioe) { | |||
String msg = "Failed to copy " + fromResource | |||
+ " to " + toFile | |||
+ " due to " + getDueTo(ioe); | |||
File targetFile = new File(toFile); | |||
final File targetFile = new File(toFile); | |||
if (!(ioe instanceof | |||
ResourceUtils.ReadOnlyTargetFileException) | |||
&& targetFile.exists() && !targetFile.delete()) { | |||
@@ -1020,7 +1023,7 @@ public class Copy extends Task { | |||
* Adds the given strings to a list contained in the given map. | |||
* The file is the key into the map. | |||
*/ | |||
private static void add(File baseDir, String[] names, Map<File, List<String>> m) { | |||
private static void add(File baseDir, final String[] names, final Map<File, List<String>> m) { | |||
if (names != null) { | |||
baseDir = getKeyFile(baseDir); | |||
List<String> l = m.get(baseDir); | |||
@@ -1036,7 +1039,7 @@ public class Copy extends Task { | |||
* Adds the given string to a list contained in the given map. | |||
* The file is the key into the map. | |||
*/ | |||
private static void add(File baseDir, String name, Map<File, List<String>> m) { | |||
private static void add(final File baseDir, final String name, final Map<File, List<String>> m) { | |||
if (name != null) { | |||
add(baseDir, new String[] {name}, m); | |||
} | |||
@@ -1045,7 +1048,7 @@ public class Copy extends Task { | |||
/** | |||
* Either returns its argument or a plaeholder if the argument is null. | |||
*/ | |||
private static File getKeyFile(File f) { | |||
private static File getKeyFile(final File f) { | |||
return f == null ? NULL_FILE_PLACEHOLDER : f; | |||
} | |||
@@ -1071,7 +1074,7 @@ public class Copy extends Task { | |||
* @return ex.getMessage() if ex.getMessage() is not null | |||
* otherwise return ex.toString() | |||
*/ | |||
private String getMessage(Exception ex) { | |||
private String getMessage(final Exception ex) { | |||
return ex.getMessage() == null ? ex.toString() : ex.getMessage(); | |||
} | |||
@@ -1082,9 +1085,9 @@ public class Copy extends Task { | |||
* output the message | |||
* if the exception is MalformedInput add a little note. | |||
*/ | |||
private String getDueTo(Exception ex) { | |||
boolean baseIOException = ex.getClass() == IOException.class; | |||
StringBuffer message = new StringBuffer(); | |||
private String getDueTo(final Exception ex) { | |||
final boolean baseIOException = ex.getClass() == IOException.class; | |||
final StringBuffer message = new StringBuffer(); | |||
if (!baseIOException || ex.getMessage() == null) { | |||
message.append(ex.getClass().getName()); | |||
} | |||
@@ -65,7 +65,7 @@ public class EchoXML extends XMLFragment { | |||
public void setNamespacePolicy(NamespacePolicy n) { | |||
namespacePolicy = n; | |||
} | |||
/** | |||
* Set whether to append the output file. | |||
* @param b boolean append flag. | |||
@@ -115,7 +115,8 @@ public class EchoXML extends XMLFragment { | |||
setValue(s); | |||
} | |||
/** {@inheritDoc}. */ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {IGNORE, ELEMENTS, ALL}; | |||
} | |||
@@ -84,7 +84,7 @@ public class Get extends Task { | |||
private boolean skipExisting = false; | |||
private boolean httpUseCaches = true; // on by default | |||
private Mapper mapperElement = null; | |||
private String userAgent = | |||
private String userAgent = | |||
System.getProperty(MagicNames.HTTP_AGENT_PROPERTY, | |||
DEFAULT_AGENT_PREFIX + "/" | |||
+ Main.getShortAntVersion()); | |||
@@ -94,7 +94,8 @@ public class Get extends Task { | |||
* | |||
* @exception BuildException Thrown in unrecoverable error. | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
checkAttributes(); | |||
for (Resource r : sources) { | |||
@@ -166,7 +167,8 @@ public class Get extends Task { | |||
* is false. | |||
* @deprecated only gets the first configured resource | |||
*/ | |||
public boolean doGet(int logLevel, DownloadProgress progress) | |||
@Deprecated | |||
public boolean doGet(int logLevel, DownloadProgress progress) | |||
throws IOException { | |||
checkAttributes(); | |||
for (Resource r : sources) { | |||
@@ -430,7 +432,7 @@ public class Get extends Task { | |||
public void setSkipExisting(boolean s) { | |||
this.skipExisting = s; | |||
} | |||
/** | |||
* HTTP connections only - set the user-agent to be used | |||
* when communicating with remote server. if null, then | |||
@@ -456,7 +458,7 @@ public class Get extends Task { | |||
public void setHttpUseCaches(boolean httpUseCache) { | |||
this.httpUseCaches = httpUseCache; | |||
} | |||
/** | |||
* Define the mapper to map source to destination files. | |||
* @return a mapper to be configured. | |||
@@ -518,7 +520,8 @@ public class Get extends Task { | |||
/** | |||
* begin a download | |||
*/ | |||
public void beginDownload() { | |||
@Override | |||
public void beginDownload() { | |||
} | |||
@@ -526,13 +529,15 @@ public class Get extends Task { | |||
* tick handler | |||
* | |||
*/ | |||
public void onTick() { | |||
@Override | |||
public void onTick() { | |||
} | |||
/** | |||
* end a download | |||
*/ | |||
public void endDownload() { | |||
@Override | |||
public void endDownload() { | |||
} | |||
} | |||
@@ -557,7 +562,8 @@ public class Get extends Task { | |||
/** | |||
* begin a download | |||
*/ | |||
public void beginDownload() { | |||
@Override | |||
public void beginDownload() { | |||
dots = 0; | |||
} | |||
@@ -565,7 +571,8 @@ public class Get extends Task { | |||
* tick handler | |||
* | |||
*/ | |||
public void onTick() { | |||
@Override | |||
public void onTick() { | |||
out.print("."); | |||
if (dots++ > DOTS_PER_LINE) { | |||
out.flush(); | |||
@@ -576,7 +583,8 @@ public class Get extends Task { | |||
/** | |||
* end a download | |||
*/ | |||
public void endDownload() { | |||
@Override | |||
public void endDownload() { | |||
out.println(); | |||
out.flush(); | |||
} | |||
@@ -599,7 +607,7 @@ public class Get extends Task { | |||
private URLConnection connection; | |||
private int redirections = 0; | |||
private String userAgent = null; | |||
GetThread(URL source, File dest, | |||
boolean h, long t, DownloadProgress p, int l, String userAgent) { | |||
this.source = source; | |||
@@ -611,7 +619,8 @@ public class Get extends Task { | |||
this.userAgent = userAgent; | |||
} | |||
public void run() { | |||
@Override | |||
public void run() { | |||
try { | |||
success = get(); | |||
} catch (IOException ioex) { | |||
@@ -684,7 +693,7 @@ public class Get extends Task { | |||
} | |||
// Set the user agent | |||
connection.addRequestProperty("User-Agent", this.userAgent); | |||
// prepare Java 1.1 style credentials | |||
if (uname != null || pword != null) { | |||
String up = uname + ":" + pword; | |||
@@ -762,7 +771,7 @@ public class Get extends Task { | |||
} | |||
private boolean isMoved(int responseCode) { | |||
return responseCode == HttpURLConnection.HTTP_MOVED_PERM || | |||
return responseCode == HttpURLConnection.HTTP_MOVED_PERM || | |||
responseCode == HttpURLConnection.HTTP_MOVED_TEMP || | |||
responseCode == HttpURLConnection.HTTP_SEE_OTHER || | |||
responseCode == HTTP_MOVED_TEMP; | |||
@@ -56,7 +56,7 @@ public class Input extends Task { | |||
* this allows the use of a custom inputhandler. | |||
* @param refid the String refid. | |||
*/ | |||
public void setRefid(String refid) { | |||
public void setRefid(final String refid) { | |||
this.refid = refid; | |||
} | |||
/** | |||
@@ -70,7 +70,7 @@ public class Input extends Task { | |||
* Set the InputHandler classname. | |||
* @param classname the String classname. | |||
*/ | |||
public void setClassname(String classname) { | |||
public void setClassname(final String classname) { | |||
this.classname = classname; | |||
} | |||
/** | |||
@@ -84,7 +84,7 @@ public class Input extends Task { | |||
* Set the handler type. | |||
* @param type a HandlerType. | |||
*/ | |||
public void setType(HandlerType type) { | |||
public void setType(final HandlerType type) { | |||
this.type = type; | |||
} | |||
/** | |||
@@ -101,7 +101,7 @@ public class Input extends Task { | |||
if (refid != null) { | |||
try { | |||
return (InputHandler) (getProject().getReference(refid)); | |||
} catch (ClassCastException e) { | |||
} catch (final ClassCastException e) { | |||
throw new BuildException( | |||
refid + " does not denote an InputHandler", e); | |||
} | |||
@@ -120,16 +120,17 @@ public class Input extends Task { | |||
* "default", "propertyfile", "greedy", "secure" (since Ant 1.8). | |||
*/ | |||
public static class HandlerType extends EnumeratedAttribute { | |||
private static final String[] VALUES = { "default", "propertyfile", "greedy", "secure" }; | |||
private static final String[] VALUES = {"default", "propertyfile", "greedy", "secure"}; | |||
private static final InputHandler[] HANDLERS | |||
= { new DefaultInputHandler(), | |||
= {new DefaultInputHandler(), | |||
new PropertyFileInputHandler(), | |||
new GreedyInputHandler(), | |||
new SecureInputHandler() }; | |||
new SecureInputHandler()}; | |||
/** {@inheritDoc} */ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return VALUES; | |||
} | |||
private InputHandler getInputHandler() { | |||
@@ -152,7 +153,7 @@ public class Input extends Task { | |||
* | |||
* @param validargs A comma separated String defining valid input args. | |||
*/ | |||
public void setValidargs (String validargs) { | |||
public void setValidargs (final String validargs) { | |||
this.validargs = validargs; | |||
} | |||
@@ -163,7 +164,7 @@ public class Input extends Task { | |||
* | |||
* @param addproperty Name for the property to be created from input | |||
*/ | |||
public void setAddproperty (String addproperty) { | |||
public void setAddproperty (final String addproperty) { | |||
this.addproperty = addproperty; | |||
} | |||
@@ -171,7 +172,7 @@ public class Input extends Task { | |||
* Sets the Message which gets displayed to the user during the build run. | |||
* @param message The message to be displayed. | |||
*/ | |||
public void setMessage (String message) { | |||
public void setMessage (final String message) { | |||
this.message = message; | |||
messageAttribute = true; | |||
} | |||
@@ -183,7 +184,7 @@ public class Input extends Task { | |||
* @param defaultvalue Default value for the property if no input | |||
* is received | |||
*/ | |||
public void setDefaultvalue (String defaultvalue) { | |||
public void setDefaultvalue (final String defaultvalue) { | |||
this.defaultvalue = defaultvalue; | |||
} | |||
@@ -191,7 +192,7 @@ public class Input extends Task { | |||
* Set a multiline message. | |||
* @param msg The message to be displayed. | |||
*/ | |||
public void addText(String msg) { | |||
public void addText(final String msg) { | |||
if (messageAttribute && "".equals(msg.trim())) { | |||
return; | |||
} | |||
@@ -208,7 +209,8 @@ public class Input extends Task { | |||
* Actual method executed by ant. | |||
* @throws BuildException on error | |||
*/ | |||
public void execute () throws BuildException { | |||
@Override | |||
public void execute () throws BuildException { | |||
if (addproperty != null | |||
&& getProject().getProperty(addproperty) != null) { | |||
log("skipping " + getTaskName() + " as property " + addproperty | |||
@@ -218,14 +220,14 @@ public class Input extends Task { | |||
InputRequest request = null; | |||
if (validargs != null) { | |||
Vector<String> accept = StringUtils.split(validargs, ','); | |||
final Vector<String> accept = StringUtils.split(validargs, ','); | |||
request = new MultipleChoiceInputRequest(message, accept); | |||
} else { | |||
request = new InputRequest(message); | |||
} | |||
request.setDefaultValue(defaultvalue); | |||
InputHandler h = handler == null | |||
final InputHandler h = handler == null | |||
? getProject().getInputHandler() | |||
: handler.getInputHandler(); | |||
@@ -349,7 +349,7 @@ public abstract class JDBCTask extends Task { | |||
info.put("password", getPassword()); | |||
for (Iterator<Property> props = connectionProperties.iterator(); | |||
props.hasNext(); ) { | |||
props.hasNext();) { | |||
Property p = props.next(); | |||
String name = p.getName(); | |||
String value = p.getValue(); | |||
@@ -407,7 +407,7 @@ public abstract class JDBCTask extends Task { | |||
// in most cases. | |||
synchronized (LOADER_MAP) { | |||
if (caching) { | |||
loader = (AntClassLoader) LOADER_MAP.get(driver); | |||
loader = LOADER_MAP.get(driver); | |||
} | |||
if (loader == null) { | |||
log("Loading " + driver | |||
@@ -180,7 +180,7 @@ public class Javac extends MatchingTask { | |||
* | |||
* @param v Value to assign to debugLevel. | |||
*/ | |||
public void setDebugLevel(String v) { | |||
public void setDebugLevel(final String v) { | |||
this.debugLevel = v; | |||
} | |||
@@ -207,7 +207,7 @@ public class Javac extends MatchingTask { | |||
* | |||
* @param v Value to assign to source. | |||
*/ | |||
public void setSource(String v) { | |||
public void setSource(final String v) { | |||
this.source = v; | |||
} | |||
@@ -237,7 +237,7 @@ public class Javac extends MatchingTask { | |||
* Set the source directories to find the source Java files. | |||
* @param srcDir the source directories as a path | |||
*/ | |||
public void setSrcdir(Path srcDir) { | |||
public void setSrcdir(final Path srcDir) { | |||
if (src == null) { | |||
src = srcDir; | |||
} else { | |||
@@ -258,7 +258,7 @@ public class Javac extends MatchingTask { | |||
* files should be compiled. | |||
* @param destDir the destination director | |||
*/ | |||
public void setDestdir(File destDir) { | |||
public void setDestdir(final File destDir) { | |||
this.destDir = destDir; | |||
} | |||
@@ -275,7 +275,7 @@ public class Javac extends MatchingTask { | |||
* Set the sourcepath to be used for this compilation. | |||
* @param sourcepath the source path | |||
*/ | |||
public void setSourcepath(Path sourcepath) { | |||
public void setSourcepath(final Path sourcepath) { | |||
if (compileSourcepath == null) { | |||
compileSourcepath = sourcepath; | |||
} else { | |||
@@ -306,7 +306,7 @@ public class Javac extends MatchingTask { | |||
* Adds a reference to a source path defined elsewhere. | |||
* @param r a reference to a source path | |||
*/ | |||
public void setSourcepathRef(Reference r) { | |||
public void setSourcepathRef(final Reference r) { | |||
createSourcepath().setRefid(r); | |||
} | |||
@@ -315,7 +315,7 @@ public class Javac extends MatchingTask { | |||
* | |||
* @param classpath an Ant Path object containing the compilation classpath. | |||
*/ | |||
public void setClasspath(Path classpath) { | |||
public void setClasspath(final Path classpath) { | |||
if (compileClasspath == null) { | |||
compileClasspath = classpath; | |||
} else { | |||
@@ -346,7 +346,7 @@ public class Javac extends MatchingTask { | |||
* Adds a reference to a classpath defined elsewhere. | |||
* @param r a reference to a classpath | |||
*/ | |||
public void setClasspathRef(Reference r) { | |||
public void setClasspathRef(final Reference r) { | |||
createClasspath().setRefid(r); | |||
} | |||
@@ -356,7 +356,7 @@ public class Javac extends MatchingTask { | |||
* @param bootclasspath a path to use as a boot class path (may be more | |||
* than one) | |||
*/ | |||
public void setBootclasspath(Path bootclasspath) { | |||
public void setBootclasspath(final Path bootclasspath) { | |||
if (this.bootclasspath == null) { | |||
this.bootclasspath = bootclasspath; | |||
} else { | |||
@@ -388,7 +388,7 @@ public class Javac extends MatchingTask { | |||
* Adds a reference to a classpath defined elsewhere. | |||
* @param r a reference to a classpath | |||
*/ | |||
public void setBootClasspathRef(Reference r) { | |||
public void setBootClasspathRef(final Reference r) { | |||
createBootclasspath().setRefid(r); | |||
} | |||
@@ -397,7 +397,7 @@ public class Javac extends MatchingTask { | |||
* compilation. | |||
* @param extdirs a path | |||
*/ | |||
public void setExtdirs(Path extdirs) { | |||
public void setExtdirs(final Path extdirs) { | |||
if (this.extdirs == null) { | |||
this.extdirs = extdirs; | |||
} else { | |||
@@ -429,7 +429,7 @@ public class Javac extends MatchingTask { | |||
* If true, list the source files being handed off to the compiler. | |||
* @param list if true list the source files | |||
*/ | |||
public void setListfiles(boolean list) { | |||
public void setListfiles(final boolean list) { | |||
listFiles = list; | |||
} | |||
@@ -446,7 +446,7 @@ public class Javac extends MatchingTask { | |||
* even if there are compilation errors; defaults to true. | |||
* @param fail if true halt the build on failure | |||
*/ | |||
public void setFailonerror(boolean fail) { | |||
public void setFailonerror(final boolean fail) { | |||
failOnError = fail; | |||
} | |||
@@ -454,7 +454,7 @@ public class Javac extends MatchingTask { | |||
* @ant.attribute ignore="true" | |||
* @param proceed inverse of failoferror | |||
*/ | |||
public void setProceed(boolean proceed) { | |||
public void setProceed(final boolean proceed) { | |||
failOnError = !proceed; | |||
} | |||
@@ -471,7 +471,7 @@ public class Javac extends MatchingTask { | |||
* compiled with deprecation information; defaults to off. | |||
* @param deprecation if true turn on deprecation information | |||
*/ | |||
public void setDeprecation(boolean deprecation) { | |||
public void setDeprecation(final boolean deprecation) { | |||
this.deprecation = deprecation; | |||
} | |||
@@ -490,7 +490,7 @@ public class Javac extends MatchingTask { | |||
* (Examples: 83886080, 81920k, or 80m) | |||
* @param memoryInitialSize string to pass to VM | |||
*/ | |||
public void setMemoryInitialSize(String memoryInitialSize) { | |||
public void setMemoryInitialSize(final String memoryInitialSize) { | |||
this.memoryInitialSize = memoryInitialSize; | |||
} | |||
@@ -509,7 +509,7 @@ public class Javac extends MatchingTask { | |||
* (Examples: 83886080, 81920k, or 80m) | |||
* @param memoryMaximumSize string to pass to VM | |||
*/ | |||
public void setMemoryMaximumSize(String memoryMaximumSize) { | |||
public void setMemoryMaximumSize(final String memoryMaximumSize) { | |||
this.memoryMaximumSize = memoryMaximumSize; | |||
} | |||
@@ -525,7 +525,7 @@ public class Javac extends MatchingTask { | |||
* Set the Java source file encoding name. | |||
* @param encoding the source file encoding | |||
*/ | |||
public void setEncoding(String encoding) { | |||
public void setEncoding(final String encoding) { | |||
this.encoding = encoding; | |||
} | |||
@@ -542,7 +542,7 @@ public class Javac extends MatchingTask { | |||
* with debug information; defaults to off. | |||
* @param debug if true compile with debug information | |||
*/ | |||
public void setDebug(boolean debug) { | |||
public void setDebug(final boolean debug) { | |||
this.debug = debug; | |||
} | |||
@@ -558,7 +558,7 @@ public class Javac extends MatchingTask { | |||
* If true, compiles with optimization enabled. | |||
* @param optimize if true compile with optimization enabled | |||
*/ | |||
public void setOptimize(boolean optimize) { | |||
public void setOptimize(final boolean optimize) { | |||
this.optimize = optimize; | |||
} | |||
@@ -575,7 +575,7 @@ public class Javac extends MatchingTask { | |||
* that support this (jikes and classic). | |||
* @param depend if true enable dependency-tracking | |||
*/ | |||
public void setDepend(boolean depend) { | |||
public void setDepend(final boolean depend) { | |||
this.depend = depend; | |||
} | |||
@@ -591,7 +591,7 @@ public class Javac extends MatchingTask { | |||
* If true, asks the compiler for verbose output. | |||
* @param verbose if true, asks the compiler for verbose output | |||
*/ | |||
public void setVerbose(boolean verbose) { | |||
public void setVerbose(final boolean verbose) { | |||
this.verbose = verbose; | |||
} | |||
@@ -609,7 +609,7 @@ public class Javac extends MatchingTask { | |||
* "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "5", "6", "7" and "8". | |||
* @param target the target VM | |||
*/ | |||
public void setTarget(String target) { | |||
public void setTarget(final String target) { | |||
this.targetAttribute = target; | |||
} | |||
@@ -627,7 +627,7 @@ public class Javac extends MatchingTask { | |||
* If true, includes Ant's own classpath in the classpath. | |||
* @param include if true, includes Ant's own classpath in the classpath | |||
*/ | |||
public void setIncludeantruntime(boolean include) { | |||
public void setIncludeantruntime(final boolean include) { | |||
includeAntRuntime = Boolean.valueOf(include); | |||
} | |||
@@ -643,7 +643,7 @@ public class Javac extends MatchingTask { | |||
* If true, includes the Java runtime libraries in the classpath. | |||
* @param include if true, includes the Java runtime libraries in the classpath | |||
*/ | |||
public void setIncludejavaruntime(boolean include) { | |||
public void setIncludejavaruntime(final boolean include) { | |||
includeJavaRuntime = include; | |||
} | |||
@@ -661,7 +661,7 @@ public class Javac extends MatchingTask { | |||
* | |||
* @param f "true|false|on|off|yes|no" | |||
*/ | |||
public void setFork(boolean f) { | |||
public void setFork(final boolean f) { | |||
fork = f; | |||
} | |||
@@ -672,7 +672,7 @@ public class Javac extends MatchingTask { | |||
* as the compiler.</p> | |||
* @param forkExec the name of the executable | |||
*/ | |||
public void setExecutable(String forkExec) { | |||
public void setExecutable(final String forkExec) { | |||
forkedExecutable = forkExec; | |||
} | |||
@@ -719,7 +719,7 @@ public class Javac extends MatchingTask { | |||
* If true, enables the -nowarn option. | |||
* @param flag if true, enable the -nowarn option | |||
*/ | |||
public void setNowarn(boolean flag) { | |||
public void setNowarn(final boolean flag) { | |||
this.nowarn = flag; | |||
} | |||
@@ -736,7 +736,7 @@ public class Javac extends MatchingTask { | |||
* @return a ImplementationSpecificArgument to be configured | |||
*/ | |||
public ImplementationSpecificArgument createCompilerArg() { | |||
ImplementationSpecificArgument arg = | |||
final ImplementationSpecificArgument arg = | |||
new ImplementationSpecificArgument(); | |||
facade.addImplementationArgument(arg); | |||
return arg; | |||
@@ -747,15 +747,15 @@ public class Javac extends MatchingTask { | |||
* @return array of command line arguments, guaranteed to be non-null. | |||
*/ | |||
public String[] getCurrentCompilerArgs() { | |||
String chosen = facade.getExplicitChoice(); | |||
final String chosen = facade.getExplicitChoice(); | |||
try { | |||
// make sure facade knows about magic properties and fork setting | |||
String appliedCompiler = getCompiler(); | |||
final String appliedCompiler = getCompiler(); | |||
facade.setImplementation(appliedCompiler); | |||
String[] result = facade.getArgs(); | |||
String altCompilerName = getAltCompilerName(facade.getImplementation()); | |||
final String altCompilerName = getAltCompilerName(facade.getImplementation()); | |||
if (result.length == 0 && altCompilerName != null) { | |||
facade.setImplementation(altCompilerName); | |||
@@ -769,7 +769,7 @@ public class Javac extends MatchingTask { | |||
} | |||
} | |||
private String getAltCompilerName(String anImplementation) { | |||
private String getAltCompilerName(final String anImplementation) { | |||
if (JAVAC19.equalsIgnoreCase(anImplementation) | |||
|| JAVAC18.equalsIgnoreCase(anImplementation) | |||
|| JAVAC17.equalsIgnoreCase(anImplementation) | |||
@@ -784,7 +784,7 @@ public class Javac extends MatchingTask { | |||
return CLASSIC; | |||
} | |||
if (MODERN.equalsIgnoreCase(anImplementation)) { | |||
String nextSelected = assumedJavaVersion(); | |||
final String nextSelected = assumedJavaVersion(); | |||
if (JAVAC19.equalsIgnoreCase(nextSelected) | |||
|| JAVAC18.equalsIgnoreCase(nextSelected) | |||
|| JAVAC17.equalsIgnoreCase(nextSelected) | |||
@@ -810,7 +810,7 @@ public class Javac extends MatchingTask { | |||
* @since Ant 1.6 | |||
* @param tmpDir the temporary directory | |||
*/ | |||
public void setTempdir(File tmpDir) { | |||
public void setTempdir(final File tmpDir) { | |||
this.tmpDir = tmpDir; | |||
} | |||
@@ -831,7 +831,7 @@ public class Javac extends MatchingTask { | |||
* @param updatedProperty the property name to use. | |||
* @since Ant 1.7.1. | |||
*/ | |||
public void setUpdatedProperty(String updatedProperty) { | |||
public void setUpdatedProperty(final String updatedProperty) { | |||
this.updatedProperty = updatedProperty; | |||
} | |||
@@ -842,7 +842,7 @@ public class Javac extends MatchingTask { | |||
* @param errorProperty the property name to use. | |||
* @since Ant 1.7.1. | |||
*/ | |||
public void setErrorProperty(String errorProperty) { | |||
public void setErrorProperty(final String errorProperty) { | |||
this.errorProperty = errorProperty; | |||
} | |||
@@ -853,7 +853,7 @@ public class Javac extends MatchingTask { | |||
* The default value is "true". | |||
* @param includeDestClasses the value to use. | |||
*/ | |||
public void setIncludeDestClasses(boolean includeDestClasses) { | |||
public void setIncludeDestClasses(final boolean includeDestClasses) { | |||
this.includeDestClasses = includeDestClasses; | |||
} | |||
@@ -888,7 +888,7 @@ public class Javac extends MatchingTask { | |||
* Set the compiler adapter explicitly. | |||
* @since Ant 1.8.0 | |||
*/ | |||
public void add(CompilerAdapter adapter) { | |||
public void add(final CompilerAdapter adapter) { | |||
if (nestedAdapter != null) { | |||
throw new BuildException("Can't have more than one compiler" | |||
+ " adapter"); | |||
@@ -903,7 +903,7 @@ public class Javac extends MatchingTask { | |||
* | |||
* @since Ant 1.8.3 | |||
*/ | |||
public void setCreateMissingPackageInfoClass(boolean b) { | |||
public void setCreateMissingPackageInfoClass(final boolean b) { | |||
createMissingPackageInfoClass = b; | |||
} | |||
@@ -911,23 +911,24 @@ public class Javac extends MatchingTask { | |||
* Executes the task. | |||
* @exception BuildException if an error occurs | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
checkParameters(); | |||
resetFileLists(); | |||
// scan source directories and dest directory to build up | |||
// compile lists | |||
String[] list = src.list(); | |||
final String[] list = src.list(); | |||
for (int i = 0; i < list.length; i++) { | |||
File srcDir = getProject().resolveFile(list[i]); | |||
final File srcDir = getProject().resolveFile(list[i]); | |||
if (!srcDir.exists()) { | |||
throw new BuildException("srcdir \"" | |||
+ srcDir.getPath() | |||
+ "\" does not exist!", getLocation()); | |||
} | |||
DirectoryScanner ds = this.getDirectoryScanner(srcDir); | |||
String[] files = ds.getIncludedFiles(); | |||
final DirectoryScanner ds = this.getDirectoryScanner(srcDir); | |||
final String[] files = ds.getIncludedFiles(); | |||
scanDir(srcDir, destDir != null ? destDir : srcDir, files); | |||
} | |||
@@ -956,19 +957,19 @@ public class Javac extends MatchingTask { | |||
* @param destDir The destination directory | |||
* @param files An array of filenames | |||
*/ | |||
protected void scanDir(File srcDir, File destDir, String[] files) { | |||
GlobPatternMapper m = new GlobPatternMapper(); | |||
String[] extensions = findSupportedFileExtensions(); | |||
protected void scanDir(final File srcDir, final File destDir, final String[] files) { | |||
final GlobPatternMapper m = new GlobPatternMapper(); | |||
final String[] extensions = findSupportedFileExtensions(); | |||
for (int i = 0; i < extensions.length; i++) { | |||
m.setFrom(extensions[i]); | |||
m.setTo("*.class"); | |||
SourceFileScanner sfs = new SourceFileScanner(this); | |||
File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); | |||
final SourceFileScanner sfs = new SourceFileScanner(this); | |||
final File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); | |||
if (newFiles.length > 0) { | |||
lookForPackageInfos(srcDir, newFiles); | |||
File[] newCompileList | |||
final File[] newCompileList | |||
= new File[compileList.length + newFiles.length]; | |||
System.arraycopy(compileList, 0, newCompileList, 0, | |||
compileList.length); | |||
@@ -980,8 +981,8 @@ public class Javac extends MatchingTask { | |||
} | |||
private String[] findSupportedFileExtensions() { | |||
String compilerImpl = getCompiler(); | |||
CompilerAdapter adapter = | |||
final String compilerImpl = getCompiler(); | |||
final CompilerAdapter adapter = | |||
nestedAdapter != null ? nestedAdapter : | |||
CompilerAdapterFactory.getCompiler(compilerImpl, this, | |||
createCompilerClasspath()); | |||
@@ -992,7 +993,7 @@ public class Javac extends MatchingTask { | |||
} | |||
if (extensions == null) { | |||
extensions = new String[] { "java" }; | |||
extensions = new String[] {"java"}; | |||
} | |||
// now process the extensions to ensure that they are the | |||
@@ -1021,7 +1022,7 @@ public class Javac extends MatchingTask { | |||
* "javac1.1", "javac1.2", "javac1.3", "javac1.4", "javac1.5", | |||
* "javac1.6", "javac1.7", "javac1.8" or "javac1.9". | |||
*/ | |||
protected boolean isJdkCompiler(String compilerImpl) { | |||
protected boolean isJdkCompiler(final String compilerImpl) { | |||
return MODERN.equals(compilerImpl) | |||
|| CLASSIC.equals(compilerImpl) | |||
|| JAVAC19.equals(compilerImpl) | |||
@@ -1047,7 +1048,7 @@ public class Javac extends MatchingTask { | |||
* @param compiler the name of the compiler | |||
* @since Ant 1.5 | |||
*/ | |||
public void setCompiler(String compiler) { | |||
public void setCompiler(final String compiler) { | |||
facade.setImplementation(compiler); | |||
} | |||
@@ -1133,7 +1134,7 @@ public class Javac extends MatchingTask { | |||
* @since Ant 1.5 | |||
*/ | |||
protected void compile() { | |||
String compilerImpl = getCompiler(); | |||
final String compilerImpl = getCompiler(); | |||
if (compileList.length > 0) { | |||
log("Compiling " + compileList.length + " source file" | |||
@@ -1142,12 +1143,12 @@ public class Javac extends MatchingTask { | |||
if (listFiles) { | |||
for (int i = 0; i < compileList.length; i++) { | |||
String filename = compileList[i].getAbsolutePath(); | |||
final String filename = compileList[i].getAbsolutePath(); | |||
log(filename); | |||
} | |||
} | |||
CompilerAdapter adapter = | |||
final CompilerAdapter adapter = | |||
nestedAdapter != null ? nestedAdapter : | |||
CompilerAdapterFactory.getCompiler(compilerImpl, this, | |||
createCompilerClasspath()); | |||
@@ -1164,7 +1165,7 @@ public class Javac extends MatchingTask { | |||
? destDir | |||
: getProject() | |||
.resolveFile(src.list()[0])); | |||
} catch (IOException x) { | |||
} catch (final IOException x) { | |||
// Should this be made a nonfatal warning? | |||
throw new BuildException(x, getLocation()); | |||
} | |||
@@ -1196,25 +1197,25 @@ public class Javac extends MatchingTask { | |||
/** | |||
* @param impl the name of the compiler | |||
*/ | |||
public void setCompiler(String impl) { | |||
public void setCompiler(final String impl) { | |||
super.setImplementation(impl); | |||
} | |||
} | |||
private void lookForPackageInfos(File srcDir, File[] newFiles) { | |||
private void lookForPackageInfos(final File srcDir, final File[] newFiles) { | |||
for (int i = 0; i < newFiles.length; i++) { | |||
File f = newFiles[i]; | |||
final File f = newFiles[i]; | |||
if (!f.getName().equals("package-info.java")) { | |||
continue; | |||
} | |||
String path = FILE_UTILS.removeLeadingPath(srcDir, f). | |||
final String path = FILE_UTILS.removeLeadingPath(srcDir, f). | |||
replace(File.separatorChar, '/'); | |||
String suffix = "/package-info.java"; | |||
final String suffix = "/package-info.java"; | |||
if (!path.endsWith(suffix)) { | |||
log("anomalous package-info.java path: " + path, Project.MSG_WARN); | |||
continue; | |||
} | |||
String pkg = path.substring(0, path.length() - suffix.length()); | |||
final String pkg = path.substring(0, path.length() - suffix.length()); | |||
packageInfos.put(pkg, new Long(f.lastModified())); | |||
} | |||
} | |||
@@ -1224,22 +1225,22 @@ public class Javac extends MatchingTask { | |||
* Otherwise this task's up-to-date tracking mechanisms do not work. | |||
* @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=43114">Bug #43114</a> | |||
*/ | |||
private void generateMissingPackageInfoClasses(File dest) throws IOException { | |||
for (Entry<String, Long> entry : packageInfos.entrySet()) { | |||
String pkg = entry.getKey(); | |||
Long sourceLastMod = entry.getValue(); | |||
File pkgBinDir = new File(dest, pkg.replace('/', File.separatorChar)); | |||
private void generateMissingPackageInfoClasses(final File dest) throws IOException { | |||
for (final Entry<String, Long> entry : packageInfos.entrySet()) { | |||
final String pkg = entry.getKey(); | |||
final Long sourceLastMod = entry.getValue(); | |||
final File pkgBinDir = new File(dest, pkg.replace('/', File.separatorChar)); | |||
pkgBinDir.mkdirs(); | |||
File pkgInfoClass = new File(pkgBinDir, "package-info.class"); | |||
final File pkgInfoClass = new File(pkgBinDir, "package-info.class"); | |||
if (pkgInfoClass.isFile() && pkgInfoClass.lastModified() >= sourceLastMod.longValue()) { | |||
continue; | |||
} | |||
log("Creating empty " + pkgInfoClass); | |||
OutputStream os = new FileOutputStream(pkgInfoClass); | |||
final OutputStream os = new FileOutputStream(pkgInfoClass); | |||
try { | |||
os.write(PACKAGE_INFO_CLASS_HEADER); | |||
byte[] name = pkg.getBytes("UTF-8"); | |||
int length = name.length + /* "/package-info" */ 13; | |||
final byte[] name = pkg.getBytes("UTF-8"); | |||
final int length = name.length + /* "/package-info" */ 13; | |||
os.write((byte) length / 256); | |||
os.write((byte) length % 256); | |||
os.write(name); | |||
@@ -278,7 +278,8 @@ public class Javadoc extends Task { | |||
* Return a string rep for this object. | |||
* @return the package name. | |||
*/ | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
return getName(); | |||
} | |||
} | |||
@@ -362,7 +363,8 @@ public class Javadoc extends Task { | |||
/** | |||
* @return the allowed values for the access type. | |||
*/ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
// Protected first so if any GUI tool offers a default | |||
// based on enum #0, it will be right. | |||
return new String[] {"protected", "public", "package", "private"}; | |||
@@ -862,7 +864,8 @@ public class Javadoc extends Task { | |||
* @deprecated since 1.5.x. | |||
* Use the {@link #setExtdirs(Path)} version. | |||
*/ | |||
public void setExtdirs(String path) { | |||
@Deprecated | |||
public void setExtdirs(String path) { | |||
cmd.createArgument().setValue("-extdirs"); | |||
cmd.createArgument().setValue(path); | |||
} | |||
@@ -1698,7 +1701,8 @@ public class Javadoc extends Task { | |||
* Execute the task. | |||
* @throws BuildException on error | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
checkTaskName(); | |||
Vector<String> packagesToDoc = new Vector<String>(); | |||
@@ -2428,7 +2432,8 @@ public class Javadoc extends Task { | |||
// are there any java files in this directory? | |||
File pd = new File(baseDir, dirs[i]); | |||
String[] files = pd.list(new FilenameFilter () { | |||
public boolean accept(File dir1, String name) { | |||
@Override | |||
public boolean accept(File dir1, String name) { | |||
return name.endsWith(".java") | |||
|| (includeNoSourcePackages | |||
&& name.equals("package.html")); | |||
@@ -2570,7 +2575,8 @@ public class Javadoc extends Task { | |||
// | |||
private String queuedLine = null; | |||
private boolean sawWarnings = false; | |||
protected void processLine(String line, int messageLevel) { | |||
@Override | |||
protected void processLine(String line, int messageLevel) { | |||
if (line.contains("warning")) { | |||
sawWarnings = true; | |||
} | |||
@@ -2600,7 +2606,7 @@ public class Javadoc extends Task { | |||
queuedLine = null; | |||
} | |||
} | |||
public boolean sawWarnings() { | |||
return sawWarnings; | |||
} | |||
@@ -34,7 +34,7 @@ import org.apache.tools.ant.util.FileUtils; | |||
/** | |||
* <p>This task takes file and turns them into a URL, which it then assigns | |||
* to a property. Use when for setting up RMI codebases.</p> | |||
* | |||
* | |||
* <p>nested filesets are supported; if present, these are turned into the | |||
* url with the given separator between them (default = " ").</p> | |||
* | |||
@@ -151,7 +151,7 @@ public class MakeUrl extends Task { | |||
StringBuilder urls = new StringBuilder(); | |||
ListIterator<FileSet> list = filesets.listIterator(); | |||
while (list.hasNext()) { | |||
FileSet set = (FileSet) list.next(); | |||
FileSet set = list.next(); | |||
DirectoryScanner scanner = set.getDirectoryScanner(getProject()); | |||
String[] files = scanner.getIncludedFiles(); | |||
for (int i = 0; i < files.length; i++) { | |||
@@ -200,7 +200,7 @@ public class MakeUrl extends Task { | |||
StringBuilder urls = new StringBuilder(); | |||
ListIterator<Path> list = paths.listIterator(); | |||
while (list.hasNext()) { | |||
Path path = (Path) list.next(); | |||
Path path = list.next(); | |||
String[] elements = path.list(); | |||
for (int i = 0; i < elements.length; i++) { | |||
File f = new File(elements[i]); | |||
@@ -234,7 +234,8 @@ public class MakeUrl extends Task { | |||
* @throws org.apache.tools.ant.BuildException | |||
* if something goes wrong with the build | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
validate(); | |||
//now exit here if the property is already set | |||
if (getProject().getProperty(property) != null) { | |||
@@ -166,7 +166,8 @@ public class Manifest { | |||
* @see java.lang.Object#hashCode | |||
* @return a hashcode based on the key and values. | |||
*/ | |||
public int hashCode() { | |||
@Override | |||
public int hashCode() { | |||
int hashCode = 0; | |||
if (name != null) { | |||
@@ -182,7 +183,8 @@ public class Manifest { | |||
* @see java.lang.Object#equals | |||
* @return true if the key and values are the same. | |||
*/ | |||
public boolean equals(Object rhs) { | |||
@Override | |||
public boolean equals(Object rhs) { | |||
if (rhs == null || rhs.getClass() != getClass()) { | |||
return false; | |||
} | |||
@@ -312,7 +314,7 @@ public class Manifest { | |||
* @param line the continuation line. | |||
*/ | |||
public void addContinuation(String line) { | |||
String currentValue = (String) values.elementAt(currentIndex); | |||
String currentValue = values.elementAt(currentIndex); | |||
setValue(currentValue + line.substring(1)); | |||
} | |||
@@ -535,7 +537,7 @@ public class Manifest { | |||
Attribute currentCp = getAttribute(ATTRIBUTE_CLASSPATH); | |||
if (currentCp != null) { | |||
for (Enumeration<String> attribEnum = currentCp.getValues(); | |||
attribEnum.hasMoreElements(); ) { | |||
attribEnum.hasMoreElements();) { | |||
String value = attribEnum.nextElement(); | |||
classpathAttribute.addValue(value); | |||
} | |||
@@ -598,7 +600,7 @@ public class Manifest { | |||
* instances. | |||
*/ | |||
public Attribute getAttribute(String attributeName) { | |||
return (Attribute) attributes.get(attributeName.toLowerCase(Locale.ENGLISH)); | |||
return attributes.get(attributeName.toLowerCase(Locale.ENGLISH)); | |||
} | |||
/** | |||
@@ -686,7 +688,7 @@ public class Manifest { | |||
// classpath attributes go into a vector | |||
if (attributeKey.equals(ATTRIBUTE_CLASSPATH_LC)) { | |||
Attribute classpathAttribute = | |||
(Attribute) attributes.get(attributeKey); | |||
attributes.get(attributeKey); | |||
if (classpathAttribute == null) { | |||
storeAttribute(attribute); | |||
@@ -718,7 +720,8 @@ public class Manifest { | |||
* @return the cloned Section | |||
* @since Ant 1.5.2 | |||
*/ | |||
public Object clone() { | |||
@Override | |||
public Object clone() { | |||
Section cloned = new Section(); | |||
cloned.setName(name); | |||
Enumeration<String> e = getAttributeKeys(); | |||
@@ -757,7 +760,8 @@ public class Manifest { | |||
* @see java.lang.Object#hashCode | |||
* @return a hash value based on the attributes. | |||
*/ | |||
public int hashCode() { | |||
@Override | |||
public int hashCode() { | |||
return attributes.hashCode(); | |||
} | |||
@@ -766,7 +770,8 @@ public class Manifest { | |||
* @param rhs the object to check for equality. | |||
* @return true if the attributes are the same. | |||
*/ | |||
public boolean equals(Object rhs) { | |||
@Override | |||
public boolean equals(Object rhs) { | |||
if (rhs == null || rhs.getClass() != getClass()) { | |||
return false; | |||
} | |||
@@ -1055,7 +1060,8 @@ public class Manifest { | |||
* @return a multiline string with the Manifest as it | |||
* appears in a Manifest file. | |||
*/ | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
StringWriter sw = new StringWriter(); | |||
try { | |||
write(new PrintWriter(sw)); | |||
@@ -1093,7 +1099,8 @@ public class Manifest { | |||
* @see java.lang.Object#hashCode | |||
* @return a hashcode based on the version, main and sections. | |||
*/ | |||
public int hashCode() { | |||
@Override | |||
public int hashCode() { | |||
int hashCode = 0; | |||
if (manifestVersion != null) { | |||
@@ -1110,7 +1117,8 @@ public class Manifest { | |||
* @param rhs the object to check for equality. | |||
* @return true if the version, main and sections are the same. | |||
*/ | |||
public boolean equals(Object rhs) { | |||
@Override | |||
public boolean equals(Object rhs) { | |||
if (rhs == null || rhs.getClass() != getClass()) { | |||
return false; | |||
} | |||
@@ -1161,7 +1169,7 @@ public class Manifest { | |||
* does not exist in the manifest | |||
*/ | |||
public Section getSection(String name) { | |||
return (Section) sections.get(name); | |||
return sections.get(name); | |||
} | |||
/** | |||
@@ -168,7 +168,8 @@ public class PathConvert extends Task { | |||
/** | |||
* @return the list of values for this enumerated attribute. | |||
*/ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[]{"windows", "unix", "netware", "os/2", "tandem"}; | |||
} | |||
} | |||
@@ -225,7 +226,8 @@ public class PathConvert extends Task { | |||
* Use the method taking a TargetOs argument instead. | |||
* @see #setTargetos(PathConvert.TargetOs) | |||
*/ | |||
public void setTargetos(String target) { | |||
@Deprecated | |||
public void setTargetos(String target) { | |||
TargetOs to = new TargetOs(); | |||
to.setValue(target); | |||
setTargetos(to); | |||
@@ -331,7 +333,8 @@ public class PathConvert extends Task { | |||
* Do the execution. | |||
* @throws BuildException if something is invalid. | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
Resources savedPath = path; | |||
String savedPathSep = pathSep; // may be altered in validateSetup | |||
String savedDirSep = dirSep; // may be altered in validateSetup | |||
@@ -370,7 +373,7 @@ public class PathConvert extends Task { | |||
} | |||
} | |||
boolean first = true; | |||
for (Iterator mappedIter = ret.iterator(); mappedIter.hasNext(); ) { | |||
for (Iterator mappedIter = ret.iterator(); mappedIter.hasNext();) { | |||
String elem = mapElement((String) mappedIter.next()); // Apply the path prefix map | |||
// Now convert the path and file separator characters from the | |||
@@ -28,7 +28,7 @@ import org.apache.tools.ant.Task; | |||
/** | |||
* Task to install project helper into Ant's runtime | |||
* | |||
* | |||
* @since Ant 1.8.2 | |||
*/ | |||
public class ProjectHelperTask extends Task { | |||
@@ -39,7 +39,8 @@ public class ProjectHelperTask extends Task { | |||
this.projectHelpers.add(projectHelper); | |||
} | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
ProjectHelperRepository repo = ProjectHelperRepository.getInstance(); | |||
for (Iterator it = projectHelpers.iterator(); it.hasNext();) { | |||
ProjectHelper helper = (ProjectHelper) it.next(); | |||
@@ -431,7 +431,8 @@ public class Property extends Task { | |||
* deprecated without replacement. | |||
* @ant.attribute ignore="true" | |||
*/ | |||
public void setUserProperty(boolean userProperty) { | |||
@Deprecated | |||
public void setUserProperty(boolean userProperty) { | |||
log("DEPRECATED: Ignoring request to set user property in Property" | |||
+ " task.", Project.MSG_WARN); | |||
} | |||
@@ -440,7 +441,8 @@ public class Property extends Task { | |||
* get the value of this property | |||
* @return the current value or the empty string | |||
*/ | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
return value == null ? "" : value; | |||
} | |||
@@ -450,7 +452,8 @@ public class Property extends Task { | |||
* here is where it is loaded | |||
* @throws BuildException on error | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
if (getProject() == null) { | |||
throw new IllegalStateException("project has not been set"); | |||
} | |||
@@ -520,7 +523,7 @@ public class Property extends Task { | |||
} | |||
} | |||
} | |||
/** | |||
* load properties from a url | |||
* @param url url to load from | |||
@@ -651,7 +654,7 @@ public class Property extends Task { | |||
} | |||
log("Loading Environment " + prefix, Project.MSG_VERBOSE); | |||
Map osEnv = Execute.getEnvironmentVariables(); | |||
for (Iterator e = osEnv.entrySet().iterator(); e.hasNext(); ) { | |||
for (Iterator e = osEnv.entrySet().iterator(); e.hasNext();) { | |||
Map.Entry entry = (Map.Entry) e.next(); | |||
props.put(prefix + entry.getKey(), entry.getValue()); | |||
} | |||
@@ -712,7 +715,7 @@ public class Property extends Task { | |||
*/ | |||
private void resolveAllProperties(Map props) throws BuildException { | |||
PropertyHelper propertyHelper | |||
= (PropertyHelper) PropertyHelper.getPropertyHelper(getProject()); | |||
= PropertyHelper.getPropertyHelper(getProject()); | |||
new ResolvePropertyMap( | |||
getProject(), | |||
propertyHelper, | |||
@@ -61,16 +61,17 @@ public class Redirector { | |||
.getProperty("file.encoding"); | |||
private class PropertyOutputStream extends ByteArrayOutputStream { | |||
private String property; | |||
private final String property; | |||
private boolean closed = false; | |||
PropertyOutputStream(String property) { | |||
PropertyOutputStream(final String property) { | |||
super(); | |||
this.property = property; | |||
} | |||
public void close() throws IOException { | |||
@Override | |||
public void close() throws IOException { | |||
synchronized (outMutex) { | |||
if (!closed && !(appendOut && appendProperties)) { | |||
setPropertyFromBAOS(this, property); | |||
@@ -139,7 +140,7 @@ public class Redirector { | |||
private boolean createEmptyFilesErr = true; | |||
/** The task for which this redirector is working */ | |||
private ProjectComponent managingTask; | |||
private final ProjectComponent managingTask; | |||
/** The stream for output data */ | |||
private OutputStream outputStream = null; | |||
@@ -184,13 +185,13 @@ public class Redirector { | |||
private boolean logInputString = true; | |||
/** Mutex for in */ | |||
private Object inMutex = new Object(); | |||
private final Object inMutex = new Object(); | |||
/** Mutex for out */ | |||
private Object outMutex = new Object(); | |||
private final Object outMutex = new Object(); | |||
/** Mutex for err */ | |||
private Object errMutex = new Object(); | |||
private final Object errMutex = new Object(); | |||
/** Is the output binary or can we safely split it into lines? */ | |||
private boolean outputIsBinary = false; | |||
@@ -201,7 +202,7 @@ public class Redirector { | |||
* @param managingTask | |||
* the task for which the redirector is to work | |||
*/ | |||
public Redirector(Task managingTask) { | |||
public Redirector(final Task managingTask) { | |||
this((ProjectComponent) managingTask); | |||
} | |||
@@ -212,7 +213,7 @@ public class Redirector { | |||
* the project component for which the redirector is to work | |||
* @since Ant 1.6.3 | |||
*/ | |||
public Redirector(ProjectComponent managingTask) { | |||
public Redirector(final ProjectComponent managingTask) { | |||
this.managingTask = managingTask; | |||
} | |||
@@ -222,8 +223,8 @@ public class Redirector { | |||
* @param input | |||
* the file from which input is read. | |||
*/ | |||
public void setInput(File input) { | |||
setInput((input == null) ? null : new File[] { input }); | |||
public void setInput(final File input) { | |||
setInput((input == null) ? null : new File[] {input}); | |||
} | |||
/** | |||
@@ -232,12 +233,12 @@ public class Redirector { | |||
* @param input | |||
* the files from which input is read. | |||
*/ | |||
public void setInput(File[] input) { | |||
public void setInput(final File[] input) { | |||
synchronized (inMutex) { | |||
if (input == null) { | |||
this.input = null; | |||
} else { | |||
this.input = (File[]) input.clone(); | |||
this.input = input.clone(); | |||
} | |||
} | |||
} | |||
@@ -248,7 +249,7 @@ public class Redirector { | |||
* @param inputString | |||
* the string which is used as the input source | |||
*/ | |||
public void setInputString(String inputString) { | |||
public void setInputString(final String inputString) { | |||
synchronized (inMutex) { | |||
this.inputString = inputString; | |||
} | |||
@@ -262,7 +263,7 @@ public class Redirector { | |||
* true or false. | |||
* @since Ant 1.7 | |||
*/ | |||
public void setLogInputString(boolean logInputString) { | |||
public void setLogInputString(final boolean logInputString) { | |||
this.logInputString = logInputString; | |||
} | |||
@@ -273,7 +274,7 @@ public class Redirector { | |||
* the stream from which input will be read | |||
* @since Ant 1.6.3 | |||
*/ | |||
/* public */void setInputStream(InputStream inputStream) { | |||
/* public */void setInputStream(final InputStream inputStream) { | |||
synchronized (inMutex) { | |||
this.inputStream = inputStream; | |||
} | |||
@@ -286,8 +287,8 @@ public class Redirector { | |||
* @param out | |||
* the file to which output stream is written | |||
*/ | |||
public void setOutput(File out) { | |||
setOutput((out == null) ? null : new File[] { out }); | |||
public void setOutput(final File out) { | |||
setOutput((out == null) ? null : new File[] {out}); | |||
} | |||
/** | |||
@@ -297,12 +298,12 @@ public class Redirector { | |||
* @param out | |||
* the files to which output stream is written | |||
*/ | |||
public void setOutput(File[] out) { | |||
public void setOutput(final File[] out) { | |||
synchronized (outMutex) { | |||
if (out == null) { | |||
this.out = null; | |||
} else { | |||
this.out = (File[]) out.clone(); | |||
this.out = out.clone(); | |||
} | |||
} | |||
} | |||
@@ -313,7 +314,7 @@ public class Redirector { | |||
* @param outputEncoding | |||
* <code>String</code>. | |||
*/ | |||
public void setOutputEncoding(String outputEncoding) { | |||
public void setOutputEncoding(final String outputEncoding) { | |||
if (outputEncoding == null) { | |||
throw new IllegalArgumentException( | |||
"outputEncoding must not be null"); | |||
@@ -329,7 +330,7 @@ public class Redirector { | |||
* @param errorEncoding | |||
* <code>String</code>. | |||
*/ | |||
public void setErrorEncoding(String errorEncoding) { | |||
public void setErrorEncoding(final String errorEncoding) { | |||
if (errorEncoding == null) { | |||
throw new IllegalArgumentException("errorEncoding must not be null"); | |||
} | |||
@@ -344,7 +345,7 @@ public class Redirector { | |||
* @param inputEncoding | |||
* <code>String</code>. | |||
*/ | |||
public void setInputEncoding(String inputEncoding) { | |||
public void setInputEncoding(final String inputEncoding) { | |||
if (inputEncoding == null) { | |||
throw new IllegalArgumentException("inputEncoding must not be null"); | |||
} | |||
@@ -361,7 +362,7 @@ public class Redirector { | |||
* if true the standard error is sent to the Ant log system and | |||
* not sent to output. | |||
*/ | |||
public void setLogError(boolean logError) { | |||
public void setLogError(final boolean logError) { | |||
synchronized (errMutex) { | |||
this.logError = logError; | |||
} | |||
@@ -375,7 +376,7 @@ public class Redirector { | |||
* @param appendProperties | |||
* whether to append properties. | |||
*/ | |||
public void setAppendProperties(boolean appendProperties) { | |||
public void setAppendProperties(final boolean appendProperties) { | |||
synchronized (outMutex) { | |||
this.appendProperties = appendProperties; | |||
} | |||
@@ -387,8 +388,8 @@ public class Redirector { | |||
* @param error | |||
* the file to which error is to be written | |||
*/ | |||
public void setError(File error) { | |||
setError((error == null) ? null : new File[] { error }); | |||
public void setError(final File error) { | |||
setError((error == null) ? null : new File[] {error}); | |||
} | |||
/** | |||
@@ -397,12 +398,12 @@ public class Redirector { | |||
* @param error | |||
* the file to which error is to be written | |||
*/ | |||
public void setError(File[] error) { | |||
public void setError(final File[] error) { | |||
synchronized (errMutex) { | |||
if (error == null) { | |||
this.error = null; | |||
} else { | |||
this.error = (File[]) error.clone(); | |||
this.error = error.clone(); | |||
} | |||
} | |||
} | |||
@@ -413,7 +414,7 @@ public class Redirector { | |||
* @param outputProperty | |||
* the name of the property to be set with the task's output. | |||
*/ | |||
public void setOutputProperty(String outputProperty) { | |||
public void setOutputProperty(final String outputProperty) { | |||
if (outputProperty == null | |||
|| !(outputProperty.equals(this.outputProperty))) { | |||
synchronized (outMutex) { | |||
@@ -431,7 +432,7 @@ public class Redirector { | |||
* if true output and error streams are appended to their | |||
* respective files, if specified. | |||
*/ | |||
public void setAppend(boolean append) { | |||
public void setAppend(final boolean append) { | |||
synchronized (outMutex) { | |||
appendOut = append; | |||
} | |||
@@ -449,7 +450,7 @@ public class Redirector { | |||
* <code>boolean</code> | |||
* @since Ant 1.6.3 | |||
*/ | |||
public void setAlwaysLog(boolean alwaysLog) { | |||
public void setAlwaysLog(final boolean alwaysLog) { | |||
synchronized (outMutex) { | |||
alwaysLogOut = alwaysLog; | |||
} | |||
@@ -465,7 +466,7 @@ public class Redirector { | |||
* @param createEmptyFiles | |||
* <code>boolean</code>. | |||
*/ | |||
public void setCreateEmptyFiles(boolean createEmptyFiles) { | |||
public void setCreateEmptyFiles(final boolean createEmptyFiles) { | |||
synchronized (outMutex) { | |||
createEmptyFilesOut = createEmptyFiles; | |||
} | |||
@@ -480,7 +481,7 @@ public class Redirector { | |||
* @param errorProperty | |||
* the name of the property to be set with the error output. | |||
*/ | |||
public void setErrorProperty(String errorProperty) { | |||
public void setErrorProperty(final String errorProperty) { | |||
synchronized (errMutex) { | |||
if (errorProperty == null | |||
|| !(errorProperty.equals(this.errorProperty))) { | |||
@@ -496,7 +497,7 @@ public class Redirector { | |||
* @param inputFilterChains | |||
* <code>Vector</code> containing <code>FilterChain</code>. | |||
*/ | |||
public void setInputFilterChains(Vector<FilterChain> inputFilterChains) { | |||
public void setInputFilterChains(final Vector<FilterChain> inputFilterChains) { | |||
synchronized (inMutex) { | |||
this.inputFilterChains = inputFilterChains; | |||
} | |||
@@ -508,7 +509,7 @@ public class Redirector { | |||
* @param outputFilterChains | |||
* <code>Vector</code> containing <code>FilterChain</code>. | |||
*/ | |||
public void setOutputFilterChains(Vector<FilterChain> outputFilterChains) { | |||
public void setOutputFilterChains(final Vector<FilterChain> outputFilterChains) { | |||
synchronized (outMutex) { | |||
this.outputFilterChains = outputFilterChains; | |||
} | |||
@@ -520,7 +521,7 @@ public class Redirector { | |||
* @param errorFilterChains | |||
* <code>Vector</code> containing <code>FilterChain</code>. | |||
*/ | |||
public void setErrorFilterChains(Vector<FilterChain> errorFilterChains) { | |||
public void setErrorFilterChains(final Vector<FilterChain> errorFilterChains) { | |||
synchronized (errMutex) { | |||
this.errorFilterChains = errorFilterChains; | |||
} | |||
@@ -534,7 +535,7 @@ public class Redirector { | |||
* the same stream.</p> | |||
* @since 1.9.4 | |||
*/ | |||
public void setBinaryOutput(boolean b) { | |||
public void setBinaryOutput(final boolean b) { | |||
outputIsBinary = b; | |||
} | |||
@@ -549,13 +550,13 @@ public class Redirector { | |||
* @exception IOException | |||
* if the value cannot be read form the stream. | |||
*/ | |||
private void setPropertyFromBAOS(ByteArrayOutputStream baos, | |||
String propertyName) throws IOException { | |||
private void setPropertyFromBAOS(final ByteArrayOutputStream baos, | |||
final String propertyName) throws IOException { | |||
BufferedReader in = new BufferedReader(new StringReader(Execute | |||
final BufferedReader in = new BufferedReader(new StringReader(Execute | |||
.toString(baos))); | |||
String line = null; | |||
StringBuffer val = new StringBuffer(); | |||
final StringBuffer val = new StringBuffer(); | |||
while ((line = in.readLine()) != null) { | |||
if (val.length() != 0) { | |||
val.append(StringUtils.LINE_SEP); | |||
@@ -574,7 +575,7 @@ public class Redirector { | |||
synchronized (outMutex) { | |||
outStreams(); | |||
if (alwaysLogOut || outputStream == null) { | |||
OutputStream outputLog = new LogOutputStream(managingTask, | |||
final OutputStream outputLog = new LogOutputStream(managingTask, | |||
Project.MSG_INFO); | |||
outputStream = (outputStream == null) ? outputLog | |||
: new TeeOutputStream(outputLog, outputStream); | |||
@@ -583,7 +584,7 @@ public class Redirector { | |||
if ((outputFilterChains != null && outputFilterChains.size() > 0) | |||
|| !(outputEncoding.equalsIgnoreCase(inputEncoding))) { | |||
try { | |||
LeadPipeInputStream snk = new LeadPipeInputStream(); | |||
final LeadPipeInputStream snk = new LeadPipeInputStream(); | |||
snk.setManagingComponent(managingTask); | |||
InputStream outPumpIn = snk; | |||
@@ -593,7 +594,7 @@ public class Redirector { | |||
if (outputFilterChains != null | |||
&& outputFilterChains.size() > 0) { | |||
ChainReaderHelper helper = new ChainReaderHelper(); | |||
final ChainReaderHelper helper = new ChainReaderHelper(); | |||
helper.setProject(managingTask.getProject()); | |||
helper.setPrimaryReader(reader); | |||
helper.setFilterChains(outputFilterChains); | |||
@@ -601,12 +602,12 @@ public class Redirector { | |||
} | |||
outPumpIn = new ReaderInputStream(reader, outputEncoding); | |||
Thread t = new Thread(threadGroup, new StreamPumper( | |||
final Thread t = new Thread(threadGroup, new StreamPumper( | |||
outPumpIn, outputStream, true), "output pumper"); | |||
t.setPriority(Thread.MAX_PRIORITY); | |||
outputStream = new PipedOutputStream(snk); | |||
t.start(); | |||
} catch (IOException eyeOhEx) { | |||
} catch (final IOException eyeOhEx) { | |||
throw new BuildException("error setting up output stream", | |||
eyeOhEx); | |||
} | |||
@@ -616,7 +617,7 @@ public class Redirector { | |||
synchronized (errMutex) { | |||
errorStreams(); | |||
if (alwaysLogErr || errorStream == null) { | |||
OutputStream errorLog = new LogOutputStream(managingTask, | |||
final OutputStream errorLog = new LogOutputStream(managingTask, | |||
Project.MSG_WARN); | |||
errorStream = (errorStream == null) ? errorLog | |||
: new TeeOutputStream(errorLog, errorStream); | |||
@@ -625,7 +626,7 @@ public class Redirector { | |||
if ((errorFilterChains != null && errorFilterChains.size() > 0) | |||
|| !(errorEncoding.equalsIgnoreCase(inputEncoding))) { | |||
try { | |||
LeadPipeInputStream snk = new LeadPipeInputStream(); | |||
final LeadPipeInputStream snk = new LeadPipeInputStream(); | |||
snk.setManagingComponent(managingTask); | |||
InputStream errPumpIn = snk; | |||
@@ -635,7 +636,7 @@ public class Redirector { | |||
if (errorFilterChains != null | |||
&& errorFilterChains.size() > 0) { | |||
ChainReaderHelper helper = new ChainReaderHelper(); | |||
final ChainReaderHelper helper = new ChainReaderHelper(); | |||
helper.setProject(managingTask.getProject()); | |||
helper.setPrimaryReader(reader); | |||
helper.setFilterChains(errorFilterChains); | |||
@@ -643,12 +644,12 @@ public class Redirector { | |||
} | |||
errPumpIn = new ReaderInputStream(reader, errorEncoding); | |||
Thread t = new Thread(threadGroup, new StreamPumper( | |||
final Thread t = new Thread(threadGroup, new StreamPumper( | |||
errPumpIn, errorStream, true), "error pumper"); | |||
t.setPriority(Thread.MAX_PRIORITY); | |||
errorStream = new PipedOutputStream(snk); | |||
t.start(); | |||
} catch (IOException eyeOhEx) { | |||
} catch (final IOException eyeOhEx) { | |||
throw new BuildException("error setting up error stream", | |||
eyeOhEx); | |||
} | |||
@@ -667,13 +668,13 @@ public class Redirector { | |||
Project.MSG_VERBOSE); | |||
try { | |||
inputStream = new ConcatFileInputStream(input); | |||
} catch (IOException eyeOhEx) { | |||
} catch (final IOException eyeOhEx) { | |||
throw new BuildException(eyeOhEx); | |||
} | |||
((ConcatFileInputStream) inputStream) | |||
.setManagingComponent(managingTask); | |||
} else if (inputString != null) { | |||
StringBuffer buf = new StringBuffer("Using input "); | |||
final StringBuffer buf = new StringBuffer("Using input "); | |||
if (logInputString) { | |||
buf.append('"').append(inputString).append('"'); | |||
} else { | |||
@@ -685,12 +686,12 @@ public class Redirector { | |||
if (inputStream != null && inputFilterChains != null | |||
&& inputFilterChains.size() > 0) { | |||
ChainReaderHelper helper = new ChainReaderHelper(); | |||
final ChainReaderHelper helper = new ChainReaderHelper(); | |||
helper.setProject(managingTask.getProject()); | |||
try { | |||
helper.setPrimaryReader(new InputStreamReader(inputStream, | |||
inputEncoding)); | |||
} catch (IOException eyeOhEx) { | |||
} catch (final IOException eyeOhEx) { | |||
throw new BuildException("error setting up input stream", | |||
eyeOhEx); | |||
} | |||
@@ -704,7 +705,7 @@ public class Redirector { | |||
/** outStreams */ | |||
private void outStreams() { | |||
if (out != null && out.length > 0) { | |||
String logHead = new StringBuffer("Output ").append( | |||
final String logHead = new StringBuffer("Output ").append( | |||
((appendOut) ? "appended" : "redirected")).append(" to ") | |||
.toString(); | |||
outputStream = foldFiles(out, logHead, Project.MSG_VERBOSE, | |||
@@ -717,7 +718,7 @@ public class Redirector { | |||
+ outputProperty, Project.MSG_VERBOSE); | |||
} | |||
// shield it from being closed by a filtering StreamPumper | |||
OutputStream keepAliveOutput = new KeepAliveOutputStream(baos); | |||
final OutputStream keepAliveOutput = new KeepAliveOutputStream(baos); | |||
outputStream = (outputStream == null) ? keepAliveOutput | |||
: new TeeOutputStream(outputStream, keepAliveOutput); | |||
} else { | |||
@@ -727,14 +728,14 @@ public class Redirector { | |||
private void errorStreams() { | |||
if (error != null && error.length > 0) { | |||
String logHead = new StringBuffer("Error ").append( | |||
final String logHead = new StringBuffer("Error ").append( | |||
((appendErr) ? "appended" : "redirected")).append(" to ") | |||
.toString(); | |||
errorStream = foldFiles(error, logHead, Project.MSG_VERBOSE, | |||
appendErr, createEmptyFilesErr); | |||
} else if (!(logError || outputStream == null) && errorProperty == null) { | |||
long funnelTimeout = 0L; | |||
OutputStreamFunneler funneler = new OutputStreamFunneler( | |||
final long funnelTimeout = 0L; | |||
final OutputStreamFunneler funneler = new OutputStreamFunneler( | |||
outputStream, funnelTimeout); | |||
try { | |||
outputStream = funneler.getFunnelInstance(); | |||
@@ -743,7 +744,7 @@ public class Redirector { | |||
outputStream = new LineOrientedOutputStreamRedirector(outputStream); | |||
errorStream = new LineOrientedOutputStreamRedirector(errorStream); | |||
} | |||
} catch (IOException eyeOhEx) { | |||
} catch (final IOException eyeOhEx) { | |||
throw new BuildException( | |||
"error splitting output/error streams", eyeOhEx); | |||
} | |||
@@ -755,7 +756,7 @@ public class Redirector { | |||
+ errorProperty, Project.MSG_VERBOSE); | |||
} | |||
// shield it from being closed by a filtering StreamPumper | |||
OutputStream keepAliveError = new KeepAliveOutputStream(errorBaos); | |||
final OutputStream keepAliveError = new KeepAliveOutputStream(errorBaos); | |||
errorStream = (error == null || error.length == 0) ? keepAliveError | |||
: new TeeOutputStream(errorStream, keepAliveError); | |||
} else { | |||
@@ -774,7 +775,7 @@ public class Redirector { | |||
*/ | |||
public ExecuteStreamHandler createHandler() throws BuildException { | |||
createStreams(); | |||
boolean nonBlockingRead = input == null && inputString == null; | |||
final boolean nonBlockingRead = input == null && inputString == null; | |||
return new PumpStreamHandler(getOutputStream(), getErrorStream(), | |||
getInputStream(), nonBlockingRead); | |||
} | |||
@@ -785,7 +786,7 @@ public class Redirector { | |||
* @param output | |||
* the data to be output | |||
*/ | |||
protected void handleOutput(String output) { | |||
protected void handleOutput(final String output) { | |||
synchronized (outMutex) { | |||
if (outPrintStream == null) { | |||
outPrintStream = new PrintStream(outputStream); | |||
@@ -809,7 +810,7 @@ public class Redirector { | |||
* @exception IOException | |||
* if the data cannot be read | |||
*/ | |||
protected int handleInput(byte[] buffer, int offset, int length) | |||
protected int handleInput(final byte[] buffer, final int offset, final int length) | |||
throws IOException { | |||
synchronized (inMutex) { | |||
if (inputStream == null) { | |||
@@ -827,7 +828,7 @@ public class Redirector { | |||
* @param output | |||
* the data being flushed. | |||
*/ | |||
protected void handleFlush(String output) { | |||
protected void handleFlush(final String output) { | |||
synchronized (outMutex) { | |||
if (outPrintStream == null) { | |||
outPrintStream = new PrintStream(outputStream); | |||
@@ -843,7 +844,7 @@ public class Redirector { | |||
* @param output | |||
* the error output data. | |||
*/ | |||
protected void handleErrorOutput(String output) { | |||
protected void handleErrorOutput(final String output) { | |||
synchronized (errMutex) { | |||
if (errorPrintStream == null) { | |||
errorPrintStream = new PrintStream(errorStream); | |||
@@ -858,7 +859,7 @@ public class Redirector { | |||
* @param output | |||
* the error information being flushed. | |||
*/ | |||
protected void handleErrorFlush(String output) { | |||
protected void handleErrorFlush(final String output) { | |||
synchronized (errMutex) { | |||
if (errorPrintStream == null) { | |||
errorPrintStream = new PrintStream(errorStream); | |||
@@ -940,19 +941,19 @@ public class Redirector { | |||
try { | |||
managingTask.log("waiting for " + threadGroup.activeCount() | |||
+ " Threads:", Project.MSG_DEBUG); | |||
Thread[] thread = new Thread[threadGroup.activeCount()]; | |||
final Thread[] thread = new Thread[threadGroup.activeCount()]; | |||
threadGroup.enumerate(thread); | |||
for (int i = 0; i < thread.length && thread[i] != null; i++) { | |||
try { | |||
managingTask.log(thread[i].toString(), | |||
Project.MSG_DEBUG); | |||
} catch (NullPointerException enPeaEx) { | |||
} catch (final NullPointerException enPeaEx) { | |||
// Ignore exception | |||
} | |||
} | |||
wait(STREAMPUMPER_WAIT_INTERVAL); | |||
} catch (InterruptedException eyeEx) { | |||
Thread[] thread = new Thread[threadGroup.activeCount()]; | |||
} catch (final InterruptedException eyeEx) { | |||
final Thread[] thread = new Thread[threadGroup.activeCount()]; | |||
threadGroup.enumerate(thread); | |||
for (int i = 0; i < thread.length && thread[i] != null; i++) { | |||
thread[i].interrupt(); | |||
@@ -985,7 +986,7 @@ public class Redirector { | |||
if (baos != null) { | |||
try { | |||
baos.close(); | |||
} catch (IOException eyeOhEx) { | |||
} catch (final IOException eyeOhEx) { | |||
// Ignore exception | |||
} | |||
} | |||
@@ -994,22 +995,22 @@ public class Redirector { | |||
if (errorBaos != null) { | |||
try { | |||
errorBaos.close(); | |||
} catch (IOException eyeOhEx) { | |||
} catch (final IOException eyeOhEx) { | |||
// Ignore exception | |||
} | |||
} | |||
} | |||
} | |||
private OutputStream foldFiles(File[] file, String logHead, int loglevel, | |||
boolean append, boolean createEmptyFiles) { | |||
OutputStream result = new LazyFileOutputStream(file[0], append, | |||
private OutputStream foldFiles(final File[] file, final String logHead, final int loglevel, | |||
final boolean append, final boolean createEmptyFiles) { | |||
final OutputStream result = new LazyFileOutputStream(file[0], append, | |||
createEmptyFiles); | |||
managingTask.log(logHead + file[0], loglevel); | |||
char[] c = new char[logHead.length()]; | |||
final char[] c = new char[logHead.length()]; | |||
Arrays.fill(c, ' '); | |||
String indent = new String(c); | |||
final String indent = new String(c); | |||
for (int i = 1; i < file.length; i++) { | |||
outputStream = new TeeOutputStream(outputStream, | |||
@@ -39,14 +39,14 @@ import org.apache.tools.ant.util.facade.FacadeTaskHelper; | |||
/** | |||
* <p>Runs the rmic compiler against classes.</p> | |||
* | |||
* | |||
* <p>Rmic can be run on a single class (as specified with the classname | |||
* attribute) or a number of classes at once (all classes below base that | |||
* are neither _Stub nor _Skel classes). If you want to rmic a single | |||
* class and this class is a class nested into another class, you have to | |||
* specify the classname in the form <code>Outer$$Inner</code> instead of | |||
* <code>Outer.Inner</code>.</p> | |||
* | |||
* | |||
* <p>It is possible to refine the set of files that are being rmiced. This can | |||
* be done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, | |||
* <i>excludesfile</i> and <i>defaultexcludes</i> | |||
@@ -58,17 +58,17 @@ import org.apache.tools.ant.util.facade.FacadeTaskHelper; | |||
* you want to use default exclusions or not. See the section on | |||
* directory based tasks, on how the | |||
* inclusion/exclusion of files works, and how to write patterns.</p> | |||
* | |||
* | |||
* <p>This task forms an implicit FileSet and | |||
* supports all attributes of <code><fileset></code> | |||
* (<code>dir</code> becomes <code>base</code>) as well as the nested | |||
* <code><include></code>, <code><exclude></code> and | |||
* <code><patternset></code> elements.</p> | |||
* | |||
* | |||
* <p>It is possible to use different compilers. This can be selected | |||
* with the "build.rmic" property or the <code>compiler</code> | |||
* attribute. <a name="compilervalues">There are three choices</a>:</p> | |||
* | |||
* | |||
* <ul> | |||
* <li>sun (the standard compiler of the JDK)</li> | |||
* <li>kaffe (the standard compiler of | |||
@@ -587,7 +587,8 @@ public class Rmic extends MatchingTask { | |||
* @throws org.apache.tools.ant.BuildException | |||
* if there's a problem with baseDir or RMIC | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
try { | |||
compileList.clear(); | |||
@@ -90,7 +90,8 @@ public class SQLExec extends JDBCTask { | |||
/** The enumerated strings */ | |||
public static final String NORMAL = "normal", ROW = "row"; | |||
/** @return the enumerated strings */ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {NORMAL, ROW}; | |||
} | |||
} | |||
@@ -589,7 +590,8 @@ public class SQLExec extends JDBCTask { | |||
* Load the sql file and then execute it | |||
* @throws BuildException on error. | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
Vector savedTransaction = (Vector) transactions.clone(); | |||
String savedSqlCommand = sqlCommand; | |||
@@ -850,7 +852,8 @@ public class SQLExec extends JDBCTask { | |||
* @param out the place to print results | |||
* @throws SQLException on SQL problems. | |||
*/ | |||
protected void printResults(PrintStream out) throws SQLException { | |||
@Deprecated | |||
protected void printResults(PrintStream out) throws SQLException { | |||
ResultSet rs = getStatement().getResultSet(); | |||
try { | |||
printResults(rs, out); | |||
@@ -954,7 +957,8 @@ public class SQLExec extends JDBCTask { | |||
* <p>returns null if the connection does not connect to the | |||
* expected RDBMS.</p> | |||
*/ | |||
protected Connection getConnection() { | |||
@Override | |||
protected Connection getConnection() { | |||
if (conn == null) { | |||
conn = super.getConnection(); | |||
if (!isValidRdbms(conn)) { | |||
@@ -981,14 +985,15 @@ public class SQLExec extends JDBCTask { | |||
return statement; | |||
} | |||
/** | |||
* The action a task should perform on an error, | |||
* one of "continue", "stop" and "abort" | |||
*/ | |||
public static class OnError extends EnumeratedAttribute { | |||
/** @return the enumerated values */ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {"continue", "stop", "abort"}; | |||
} | |||
} | |||
@@ -321,7 +321,8 @@ public class SignJar extends AbstractJarSignerTask { | |||
* | |||
* @throws BuildException on errors | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
//validation logic | |||
final boolean hasJar = jar != null; | |||
final boolean hasSignedJar = signedjar != null; | |||
@@ -514,7 +515,7 @@ public class SignJar extends AbstractJarSignerTask { | |||
* is complex, and best explained in the source itself. Essentially if | |||
* either file doesnt exist, or the destfile has an out of date timestamp, | |||
* then the return value is false.</p> | |||
* | |||
* | |||
* <p>If we are signing ourself, the check {@link #isSigned(File)} is used to | |||
* trigger the process.</p> | |||
* | |||
@@ -26,11 +26,11 @@ import org.apache.tools.ant.Task; | |||
* | |||
* <p>A task for sleeping a short period of time, useful when a | |||
* build or deployment process requires an interval between tasks.</p> | |||
* | |||
* | |||
* <p>A negative value can be supplied to any of attributes provided the total sleep time | |||
* is positive, pending fundamental changes in physics and JVM | |||
* execution times</p> | |||
* | |||
* | |||
* <p>Note that sleep times are always hints to be interpreted by the OS how it feels | |||
* small times may either be ignored or rounded up to a minimum timeslice. Note | |||
* also that the system clocks often have a fairly low granularity too, which complicates | |||
@@ -171,7 +171,8 @@ public class Sleep extends Task { | |||
* | |||
* @exception BuildException Description of Exception | |||
*/ | |||
public void execute() | |||
@Override | |||
public void execute() | |||
throws BuildException { | |||
try { | |||
validate(); | |||
@@ -84,7 +84,7 @@ public class SubAnt extends Task { | |||
* <p> | |||
* This function may be overrided by providers of custom ProjectHelper so they can implement easily their sub | |||
* launcher. | |||
* | |||
* | |||
* @return the name of the default file | |||
* @since Ant 1.8.0 | |||
*/ | |||
@@ -98,7 +98,8 @@ public class SubAnt extends Task { | |||
* @param output a line of output | |||
* @since Ant 1.6.2 | |||
*/ | |||
public void handleOutput(String output) { | |||
@Override | |||
public void handleOutput(String output) { | |||
if (ant != null) { | |||
ant.handleOutput(output); | |||
} else { | |||
@@ -121,7 +122,8 @@ public class SubAnt extends Task { | |||
* | |||
* @since Ant 1.6.2 | |||
*/ | |||
public int handleInput(byte[] buffer, int offset, int length) | |||
@Override | |||
public int handleInput(byte[] buffer, int offset, int length) | |||
throws IOException { | |||
if (ant != null) { | |||
return ant.handleInput(buffer, offset, length); | |||
@@ -137,7 +139,8 @@ public class SubAnt extends Task { | |||
* | |||
* @since Ant 1.6.2 | |||
*/ | |||
public void handleFlush(String output) { | |||
@Override | |||
public void handleFlush(String output) { | |||
if (ant != null) { | |||
ant.handleFlush(output); | |||
} else { | |||
@@ -152,7 +155,8 @@ public class SubAnt extends Task { | |||
* | |||
* @since Ant 1.6.2 | |||
*/ | |||
public void handleErrorOutput(String output) { | |||
@Override | |||
public void handleErrorOutput(String output) { | |||
if (ant != null) { | |||
ant.handleErrorOutput(output); | |||
} else { | |||
@@ -167,7 +171,8 @@ public class SubAnt extends Task { | |||
* | |||
* @since Ant 1.6.2 | |||
*/ | |||
public void handleErrorFlush(String output) { | |||
@Override | |||
public void handleErrorFlush(String output) { | |||
if (ant != null) { | |||
ant.handleErrorFlush(output); | |||
} else { | |||
@@ -178,7 +183,8 @@ public class SubAnt extends Task { | |||
/** | |||
* Runs the various sub-builds. | |||
*/ | |||
public void execute() { | |||
@Override | |||
public void execute() { | |||
if (buildpath == null) { | |||
throw new BuildException("No buildpath specified"); | |||
} | |||
@@ -72,7 +72,8 @@ public class Sync extends Task { | |||
* @throws BuildException if there is a problem. | |||
* @see Task#init() | |||
*/ | |||
public void init() | |||
@Override | |||
public void init() | |||
throws BuildException { | |||
// Instantiate it | |||
myCopy = new MyCopy(); | |||
@@ -97,7 +98,8 @@ public class Sync extends Task { | |||
* @throws BuildException if there is an error. | |||
* @see Task#execute() | |||
*/ | |||
public void execute() | |||
@Override | |||
public void execute() | |||
throws BuildException { | |||
// The destination of the files to copy | |||
File toDir = myCopy.getToDir(); | |||
@@ -324,7 +326,7 @@ public class Sync extends Task { | |||
private int removeEmptyDirectories(Set preservedEmptyDirectories) { | |||
int removedCount = 0; | |||
for (Iterator iter = preservedEmptyDirectories.iterator(); | |||
iter.hasNext(); ) { | |||
iter.hasNext();) { | |||
File f = (File) iter.next(); | |||
String[] s = f.list(); | |||
if (s == null || s.length == 0) { | |||
@@ -399,7 +401,7 @@ public class Sync extends Task { | |||
myCopy.add(rc); | |||
} else { | |||
if (resources == null) { | |||
Restrict r = new Restrict(); | |||
Restrict r = new Restrict(); | |||
r.add(new Exists()); | |||
r.add(resources = new Resources()); | |||
myCopy.add(r); | |||
@@ -464,7 +466,8 @@ public class Sync extends Task { | |||
* @see Copy#scan(File, File, String[], String[]) | |||
*/ | |||
/** {@inheritDoc} */ | |||
protected void scan(File fromDir, File toDir, String[] files, | |||
@Override | |||
protected void scan(File fromDir, File toDir, String[] files, | |||
String[] dirs) { | |||
assertTrue("No mapper", mapperElement == null); | |||
@@ -482,7 +485,8 @@ public class Sync extends Task { | |||
* @see Copy#scan(Resource[], File) | |||
*/ | |||
/** {@inheritDoc} */ | |||
protected Map scan(Resource[] resources, File toDir) { | |||
@Override | |||
protected Map scan(Resource[] resources, File toDir) { | |||
assertTrue("No mapper", mapperElement == null); | |||
for (int i = 0; i < resources.length; i++) { | |||
@@ -512,7 +516,8 @@ public class Sync extends Task { | |||
* @return true always. | |||
* @since Ant 1.7 | |||
*/ | |||
protected boolean supportsNonFileResources() { | |||
@Override | |||
protected boolean supportsNonFileResources() { | |||
return true; | |||
} | |||
} | |||
@@ -543,7 +548,8 @@ public class Sync extends Task { | |||
* @param dir ignored | |||
* @throws BuildException always | |||
*/ | |||
public void setDir(File dir) throws BuildException { | |||
@Override | |||
public void setDir(File dir) throws BuildException { | |||
throw new BuildException("preserveintarget doesn't support the dir " | |||
+ "attribute"); | |||
} | |||
@@ -579,7 +585,7 @@ public class Sync extends Task { | |||
PatternSet ps = mergePatterns(getProject()); | |||
fs.appendIncludes(ps.getIncludePatterns(getProject())); | |||
fs.appendExcludes(ps.getExcludePatterns(getProject())); | |||
for (Enumeration e = selectorElements(); e.hasMoreElements(); ) { | |||
for (Enumeration e = selectorElements(); e.hasMoreElements();) { | |||
fs.appendSelector((FileSelector) e.nextElement()); | |||
} | |||
fs.setDefaultexcludes(getDefaultexcludes()); | |||
@@ -33,11 +33,11 @@ import org.apache.tools.zip.ZipOutputStream; | |||
* Contains special treatment for files that should end up in the | |||
* <code>WEB-INF/lib</code>, <code>WEB-INF/classes</code> or | |||
* <code>WEB-INF</code> directories of the Web Application Archive.</p> | |||
* | |||
* | |||
* <p>(The War task is a shortcut for specifying the particular layout of a WAR file. | |||
* The same thing can be accomplished by using the <i>prefix</i> and <i>fullpath</i> | |||
* attributes of zipfilesets in a Zip or Jar task.)</p> | |||
* | |||
* | |||
* <p>The extended zipfileset element from the zip task | |||
* (with attributes <i>prefix</i>, <i>fullpath</i>, and <i>src</i>) | |||
* is available in the War task.</p> | |||
@@ -151,7 +151,8 @@ public class War extends Jar { | |||
* @throws IOException on output error | |||
* @throws BuildException if invalid configuration | |||
*/ | |||
protected void initZipOutputStream(ZipOutputStream zOut) | |||
@Override | |||
protected void initZipOutputStream(ZipOutputStream zOut) | |||
throws IOException, BuildException { | |||
super.initZipOutputStream(zOut); | |||
} | |||
@@ -171,7 +172,8 @@ public class War extends Jar { | |||
* @param mode the Unix permissions to set. | |||
* @throws IOException on output error | |||
*/ | |||
protected void zipFile(File file, ZipOutputStream zOut, String vPath, | |||
@Override | |||
protected void zipFile(File file, ZipOutputStream zOut, String vPath, | |||
int mode) | |||
throws IOException { | |||
// If the file being added is WEB-INF/web.xml, we warn if it's | |||
@@ -215,7 +217,8 @@ public class War extends Jar { | |||
* Make sure we don't think we already have a web.xml next time this task | |||
* gets executed. | |||
*/ | |||
protected void cleanUp() { | |||
@Override | |||
protected void cleanUp() { | |||
if (addedWebXmlFile == null | |||
&& deploymentDescriptor == null | |||
&& needxmlfile | |||
@@ -51,7 +51,7 @@ public interface XSLTLiaison { | |||
* @param name the parameter name. | |||
* @param expression the parameter value as an expression string. | |||
* @throws Exception thrown if any problems happens. | |||
* @see XSLTLiaison4#addParam(java.lang.String, java.lang.Object) | |||
* @see XSLTLiaison4#addParam(java.lang.String, java.lang.Object) | |||
* @since Ant 1.3 | |||
*/ | |||
void addParam(String name, String expression) throws Exception; | |||
@@ -17,8 +17,6 @@ | |||
*/ | |||
package org.apache.tools.ant.taskdefs; | |||
import javax.xml.transform.Transformer; | |||
/** | |||
* Extends Proxy interface for XSLT processors: adds support for XSLT parameters | |||
* of various types (not only String) | |||
@@ -210,7 +210,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
* @since Ant 1.8.0 | |||
*/ | |||
private boolean failOnNoResources = true; | |||
/** | |||
* For evaluating template params | |||
* | |||
@@ -617,7 +617,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
*/ | |||
public boolean getSuppressWarnings() { | |||
return suppressWarnings; | |||
} | |||
} | |||
/** | |||
* Whether transformation errors should make the build fail. | |||
@@ -978,7 +978,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
/** The parameter's value */ | |||
private String expression = null; | |||
/** | |||
* Type of the expression. | |||
* @see ParamType | |||
@@ -1011,7 +1011,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
* The parameter value - | |||
* can be a primitive type value or an XPath expression. | |||
* @param expression the parameter's value/expression. | |||
* @see #setType(java.lang.String) | |||
* @see #setType(java.lang.String) | |||
*/ | |||
public void setExpression(String expression) { | |||
this.expression = expression; | |||
@@ -1024,7 +1024,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
public void setType(String type) { | |||
this.type = type; | |||
} | |||
/** | |||
* Get the parameter name | |||
* | |||
@@ -1113,7 +1113,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
&& ph.testUnlessCondition(unlessCond); | |||
} | |||
} // Param | |||
/** | |||
* Enum for types of the parameter expression. | |||
* | |||
@@ -1134,7 +1134,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
* <p>Default type (if omited) is primitive String. So if the expression is e.g | |||
* "true" with no type, in XSLT it will be only a text string, not true | |||
* boolean.</p> | |||
* | |||
* | |||
* @see Param#setType(java.lang.String) | |||
* @see Param#setExpression(java.lang.String) | |||
* @since Ant 1.9.3 | |||
@@ -1151,7 +1151,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
XPATH_NUMBER, | |||
XPATH_NODE, | |||
XPATH_NODESET; | |||
public static final Map<ParamType, QName> XPATH_TYPES; | |||
static { | |||
@@ -1230,11 +1230,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
public void init() throws BuildException { | |||
super.init(); | |||
xmlCatalog.setProject(getProject()); | |||
xpathFactory = XPathFactory.newInstance(); | |||
xpath = xpathFactory.newXPath(); | |||
xpath.setXPathVariableResolver(new XPathVariableResolver() { | |||
public Object resolveVariable(QName variableName) { | |||
@Override | |||
public Object resolveVariable(QName variableName) { | |||
return getProject().getProperty(variableName.toString()); | |||
} | |||
}); | |||
@@ -1247,7 +1248,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
* @exception BuildException if the stylesheet cannot be loaded. | |||
* @deprecated since Ant 1.7 | |||
*/ | |||
protected void configureLiaison(File stylesheet) throws BuildException { | |||
@Deprecated | |||
protected void configureLiaison(File stylesheet) throws BuildException { | |||
FileResource fr = new FileResource(); | |||
fr.setProject(getProject()); | |||
fr.setFile(stylesheet); | |||
@@ -1314,7 +1316,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
handleTransformationError(ex); | |||
} | |||
} | |||
/** | |||
* Evaluates parameter expression according to its type. | |||
* | |||
@@ -1530,7 +1532,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
* @return null | |||
* @throws BuildException never | |||
*/ | |||
public Object createDynamicElement(String name) throws BuildException { | |||
@Override | |||
public Object createDynamicElement(String name) throws BuildException { | |||
return null; | |||
} | |||
@@ -1541,7 +1544,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
* @param value the value of the attribute | |||
* @throws BuildException on error | |||
*/ | |||
public void setDynamicAttribute(String name, String value) throws BuildException { | |||
@Override | |||
public void setDynamicAttribute(String name, String value) throws BuildException { | |||
// only 'name' and 'value' exist. | |||
if ("name".equalsIgnoreCase(name)) { | |||
this.name = value; | |||
@@ -1576,11 +1580,14 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
* @since Ant 1.6.2 | |||
*/ | |||
private class StyleMapper implements FileNameMapper { | |||
public void setFrom(String from) { | |||
@Override | |||
public void setFrom(String from) { | |||
} | |||
public void setTo(String to) { | |||
@Override | |||
public void setTo(String to) { | |||
} | |||
public String[] mapFileName(String xmlFile) { | |||
@Override | |||
public String[] mapFileName(String xmlFile) { | |||
int dotPos = xmlFile.lastIndexOf('.'); | |||
if (dotPos > 0) { | |||
xmlFile = xmlFile.substring(0, dotPos); | |||
@@ -105,14 +105,16 @@ public class Zip extends MatchingTask { | |||
private static final ResourceSelector MISSING_SELECTOR = | |||
new ResourceSelector() { | |||
public boolean isSelected(Resource target) { | |||
@Override | |||
public boolean isSelected(Resource target) { | |||
return !target.isExists(); | |||
} | |||
}; | |||
private static final ResourceUtils.ResourceSelectorProvider | |||
MISSING_DIR_PROVIDER = new ResourceUtils.ResourceSelectorProvider() { | |||
public ResourceSelector | |||
@Override | |||
public ResourceSelector | |||
getTargetSelectorForSource(Resource sr) { | |||
return MISSING_SELECTOR; | |||
} | |||
@@ -237,7 +239,8 @@ public class Zip extends MatchingTask { | |||
* Use setDestFile(File) instead. | |||
* @ant.attribute ignore="true" | |||
*/ | |||
public void setZipfile(File zipFile) { | |||
@Deprecated | |||
public void setZipfile(File zipFile) { | |||
setDestFile(zipFile); | |||
} | |||
@@ -250,7 +253,8 @@ public class Zip extends MatchingTask { | |||
* Use setDestFile(File) instead. | |||
* @ant.attribute ignore="true" | |||
*/ | |||
public void setFile(File file) { | |||
@Deprecated | |||
public void setFile(File file) { | |||
setDestFile(file); | |||
} | |||
@@ -383,7 +387,8 @@ public class Zip extends MatchingTask { | |||
* The string values for the enumerated value | |||
* @return the values | |||
*/ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {"fail", "skip", "create"}; | |||
} | |||
} | |||
@@ -581,7 +586,8 @@ public class Zip extends MatchingTask { | |||
* validate and build | |||
* @throws BuildException on error | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
if (doubleFilePass) { | |||
skipWriting = true; | |||
@@ -628,7 +634,7 @@ public class Zip extends MatchingTask { | |||
} | |||
final int size = resources.size(); | |||
for (int i = 0; i < size; i++) { | |||
ResourceCollection rc = (ResourceCollection) resources.elementAt(i); | |||
ResourceCollection rc = resources.elementAt(i); | |||
vfss.addElement(rc); | |||
} | |||
@@ -702,7 +708,7 @@ public class Zip extends MatchingTask { | |||
final int addSize = addedFiles.size(); | |||
for (int i = 0; i < addSize; i++) { | |||
PatternSet.NameEntry ne = oldFiles.createExclude(); | |||
ne.setName((String) addedFiles.elementAt(i)); | |||
ne.setName(addedFiles.elementAt(i)); | |||
} | |||
DirectoryScanner ds = | |||
oldFiles.getDirectoryScanner(getProject()); | |||
@@ -855,7 +861,7 @@ public class Zip extends MatchingTask { | |||
for (int i = 0; i < size; i++) { | |||
logWhenWriting("Processing groupfileset ", Project.MSG_VERBOSE); | |||
FileSet fs = (FileSet) groupfilesets.elementAt(i); | |||
FileSet fs = groupfilesets.elementAt(i); | |||
FileScanner scanner = fs.getDirectoryScanner(getProject()); | |||
String[] files = scanner.getIncludedFiles(); | |||
File basedir = scanner.getBasedir(); | |||
@@ -1249,7 +1255,7 @@ public class Zip extends MatchingTask { | |||
ArchiveState as = getNonFileSetResourcesToAdd(rc, zipFile, | |||
needsUpdate); | |||
FileSet[] fs = (FileSet[]) filesets.toArray(new FileSet[filesets | |||
FileSet[] fs = filesets.toArray(new FileSet[filesets | |||
.size()]); | |||
ArchiveState as2 = getResourcesToAdd(fs, zipFile, as.isOutOfDate()); | |||
if (!as.isOutOfDate() && as2.isOutOfDate()) { | |||
@@ -1285,7 +1291,8 @@ public class Zip extends MatchingTask { | |||
* subclasses in several ways). | |||
*/ | |||
private static final ThreadLocal<Boolean> HAVE_NON_FILE_SET_RESOURCES_TO_ADD = new ThreadLocal<Boolean>() { | |||
protected Boolean initialValue() { | |||
@Override | |||
protected Boolean initialValue() { | |||
return Boolean.FALSE; | |||
} | |||
}; | |||
@@ -1630,7 +1637,8 @@ public class Zip extends MatchingTask { | |||
// make sure directories are in alpha-order - this also | |||
// ensures parents come before their children | |||
Collections.sort(dirs, new Comparator<Resource>() { | |||
public int compare(Resource r1, Resource r2) { | |||
@Override | |||
public int compare(Resource r1, Resource r2) { | |||
return r1.getName().compareTo(r2.getName()); | |||
} | |||
}); | |||
@@ -1739,7 +1747,7 @@ public class Zip extends MatchingTask { | |||
* @since Ant 1.8.0 | |||
*/ | |||
protected final ZipExtraField[] getCurrentExtraFields() { | |||
return (ZipExtraField[]) CURRENT_ZIP_EXTRA.get(); | |||
return CURRENT_ZIP_EXTRA.get(); | |||
} | |||
/** | |||
@@ -2032,7 +2040,8 @@ public class Zip extends MatchingTask { | |||
protected Resource[] selectFileResources(Resource[] orig) { | |||
return selectResources(orig, | |||
new ResourceSelector() { | |||
public boolean isSelected(Resource r) { | |||
@Override | |||
public boolean isSelected(Resource r) { | |||
if (!r.isDirectory()) { | |||
return true; | |||
} else if (doFilesonly) { | |||
@@ -2056,7 +2065,8 @@ public class Zip extends MatchingTask { | |||
protected Resource[] selectDirectoryResources(Resource[] orig) { | |||
return selectResources(orig, | |||
new ResourceSelector() { | |||
public boolean isSelected(Resource r) { | |||
@Override | |||
public boolean isSelected(Resource r) { | |||
return r.isDirectory(); | |||
} | |||
}); | |||
@@ -2108,7 +2118,8 @@ public class Zip extends MatchingTask { | |||
* @see EnumeratedAttribute#getValues() | |||
*/ | |||
/** {@inheritDoc} */ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {"add", "preserve", "fail"}; | |||
} | |||
} | |||
@@ -2184,7 +2195,8 @@ public class Zip extends MatchingTask { | |||
.NOT_ENCODEABLE); | |||
} | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {NEVER_KEY, ALWAYS_KEY, N_E_KEY}; | |||
} | |||
@@ -2242,7 +2254,8 @@ public class Zip extends MatchingTask { | |||
MODES.put(A_N_KEY, Zip64Mode.AsNeeded); | |||
} | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {NEVER_KEY, ALWAYS_KEY, A_N_KEY}; | |||
} | |||
@@ -32,24 +32,24 @@ import org.apache.tools.ant.types.Path; | |||
/** | |||
* <p>The implementation of the apt compiler for JDK 1.5.</p> | |||
* | |||
* | |||
* <p>As usual, the low level entry points for Java tools are neither documented or | |||
* stable; this entry point may change from that of 1.5.0_01-b08 without any | |||
* warning at all. The IDE decompile of the tool entry points is as follows:</p> | |||
* <pre> | |||
* public class Main { | |||
* public Main() ; | |||
* | |||
* | |||
* public static transient void main(String... strings); | |||
* | |||
* | |||
* public static transient int process(String... strings); | |||
* | |||
* | |||
* public static transient int process(PrintWriter printWriter, | |||
* String... strings); | |||
* public static transient int process( | |||
* AnnotationProcessorFactory annotationProcessorFactory, | |||
* String... strings); | |||
* | |||
* | |||
* public static transient int process( | |||
* AnnotationProcessorFactory annotationProcessorFactory, | |||
* PrintWriter printWriter, | |||
@@ -157,7 +157,8 @@ public class AptCompilerAdapter extends DefaultCompilerAdapter { | |||
* @return true on success. | |||
* @throws BuildException if the compilation has problems. | |||
*/ | |||
public boolean execute() throws BuildException { | |||
@Override | |||
public boolean execute() throws BuildException { | |||
attributes.log("Using apt compiler", Project.MSG_VERBOSE); | |||
//set up the javac options | |||
Commandline cmd = setupModernJavacCommand(); | |||
@@ -20,7 +20,7 @@ package org.apache.tools.ant.taskdefs.compilers; | |||
/** | |||
* Extension interface for compilers that support source extensions | |||
* other than .java. | |||
* | |||
* | |||
* @since Ant 1.8.2 | |||
*/ | |||
public interface CompilerAdapterExtension { | |||
@@ -32,7 +32,7 @@ public interface CompilerAdapterExtension { | |||
* <p>For example, most compiler adapters will return [ "java" ], | |||
* but a compiler adapter that can compile both Java and Groovy | |||
* source code would return [ "java", "groovy" ].</p> | |||
* | |||
* | |||
* @return list of source file extensions recognized by this | |||
* compiler adapter. | |||
*/ | |||
@@ -97,7 +97,8 @@ public abstract class DefaultCompilerAdapter | |||
* | |||
* @param attributes a configured Javac task. | |||
*/ | |||
public void setJavac(Javac attributes) { | |||
@Override | |||
public void setJavac(final Javac attributes) { | |||
this.attributes = attributes; | |||
src = attributes.getSrcdir(); | |||
destDir = attributes.getDestdir(); | |||
@@ -135,8 +136,9 @@ public abstract class DefaultCompilerAdapter | |||
* but specialized compilers can recognize multiple kinds | |||
* of files. | |||
*/ | |||
public String[] getSupportedFileExtensions() { | |||
return new String[] { "java" }; | |||
@Override | |||
public String[] getSupportedFileExtensions() { | |||
return new String[] {"java"}; | |||
} | |||
/** | |||
@@ -153,7 +155,7 @@ public abstract class DefaultCompilerAdapter | |||
* @return the compilation class path | |||
*/ | |||
protected Path getCompileClasspath() { | |||
Path classpath = new Path(project); | |||
final Path classpath = new Path(project); | |||
// add dest dir to classpath so that previously compiled and | |||
// untouched classes are on classpath | |||
@@ -187,7 +189,7 @@ public abstract class DefaultCompilerAdapter | |||
* @param cmd the command line | |||
* @return the command line | |||
*/ | |||
protected Commandline setupJavacCommandlineSwitches(Commandline cmd) { | |||
protected Commandline setupJavacCommandlineSwitches(final Commandline cmd) { | |||
return setupJavacCommandlineSwitches(cmd, false); | |||
} | |||
@@ -198,9 +200,9 @@ public abstract class DefaultCompilerAdapter | |||
* @param useDebugLevel if true set set the debug level with the -g switch | |||
* @return the command line | |||
*/ | |||
protected Commandline setupJavacCommandlineSwitches(Commandline cmd, | |||
boolean useDebugLevel) { | |||
Path classpath = getCompileClasspath(); | |||
protected Commandline setupJavacCommandlineSwitches(final Commandline cmd, | |||
final boolean useDebugLevel) { | |||
final Path classpath = getCompileClasspath(); | |||
// For -sourcepath, use the "sourcepath" value if present. | |||
// Otherwise default to the "srcdir" value. | |||
Path sourcepath = null; | |||
@@ -210,7 +212,7 @@ public abstract class DefaultCompilerAdapter | |||
sourcepath = src; | |||
} | |||
String memoryParameterPrefix = assumeJava11() ? "-J-" : "-J-X"; | |||
final String memoryParameterPrefix = assumeJava11() ? "-J-" : "-J-X"; | |||
if (memoryInitialSize != null) { | |||
if (!attributes.isForkedJavac()) { | |||
attributes.log("Since fork is false, ignoring " | |||
@@ -251,9 +253,9 @@ public abstract class DefaultCompilerAdapter | |||
// Just add "sourcepath" to classpath ( for JDK1.1 ) | |||
// as well as "bootclasspath" and "extdirs" | |||
if (assumeJava11()) { | |||
Path cp = new Path(project); | |||
final Path cp = new Path(project); | |||
Path bp = getBootClassPath(); | |||
final Path bp = getBootClassPath(); | |||
if (bp.size() > 0) { | |||
cp.append(bp); | |||
} | |||
@@ -277,7 +279,7 @@ public abstract class DefaultCompilerAdapter | |||
cmd.createArgument().setValue(target); | |||
} | |||
Path bp = getBootClassPath(); | |||
final Path bp = getBootClassPath(); | |||
if (bp.size() > 0) { | |||
cmd.createArgument().setValue("-bootclasspath"); | |||
cmd.createArgument().setPath(bp); | |||
@@ -295,7 +297,7 @@ public abstract class DefaultCompilerAdapter | |||
} | |||
if (debug) { | |||
if (useDebugLevel && !assumeJava11()) { | |||
String debugLevel = attributes.getDebugLevel(); | |||
final String debugLevel = attributes.getDebugLevel(); | |||
if (debugLevel != null) { | |||
cmd.createArgument().setValue("-g:" + debugLevel); | |||
} else { | |||
@@ -337,7 +339,7 @@ public abstract class DefaultCompilerAdapter | |||
* @param cmd the command line | |||
* @return the command line | |||
*/ | |||
protected Commandline setupModernJavacCommandlineSwitches(Commandline cmd) { | |||
protected Commandline setupModernJavacCommandlineSwitches(final Commandline cmd) { | |||
setupJavacCommandlineSwitches(cmd, true); | |||
if (!assumeJava13()) { // -source added with JDK 1.4 | |||
final String t = attributes.getTarget(); | |||
@@ -359,7 +361,7 @@ public abstract class DefaultCompilerAdapter | |||
* @return the command line | |||
*/ | |||
protected Commandline setupModernJavacCommand() { | |||
Commandline cmd = new Commandline(); | |||
final Commandline cmd = new Commandline(); | |||
setupModernJavacCommandlineSwitches(cmd); | |||
logAndAddFilesToCompile(cmd); | |||
@@ -380,8 +382,8 @@ public abstract class DefaultCompilerAdapter | |||
* @param debugLevelCheck if true set the debug level with the -g switch | |||
* @return the command line | |||
*/ | |||
protected Commandline setupJavacCommand(boolean debugLevelCheck) { | |||
Commandline cmd = new Commandline(); | |||
protected Commandline setupJavacCommand(final boolean debugLevelCheck) { | |||
final Commandline cmd = new Commandline(); | |||
setupJavacCommandlineSwitches(cmd, debugLevelCheck); | |||
logAndAddFilesToCompile(cmd); | |||
return cmd; | |||
@@ -392,11 +394,11 @@ public abstract class DefaultCompilerAdapter | |||
* "niceSourceList" | |||
* @param cmd the command line | |||
*/ | |||
protected void logAndAddFilesToCompile(Commandline cmd) { | |||
protected void logAndAddFilesToCompile(final Commandline cmd) { | |||
attributes.log("Compilation " + cmd.describeArguments(), | |||
Project.MSG_VERBOSE); | |||
StringBuffer niceSourceList = new StringBuffer("File"); | |||
final StringBuffer niceSourceList = new StringBuffer("File"); | |||
if (compileList.length != 1) { | |||
niceSourceList.append("s"); | |||
} | |||
@@ -405,7 +407,7 @@ public abstract class DefaultCompilerAdapter | |||
niceSourceList.append(StringUtils.LINE_SEP); | |||
for (int i = 0; i < compileList.length; i++) { | |||
String arg = compileList[i].getAbsolutePath(); | |||
final String arg = compileList[i].getAbsolutePath(); | |||
cmd.createArgument().setValue(arg); | |||
niceSourceList.append(" "); | |||
niceSourceList.append(arg); | |||
@@ -424,7 +426,7 @@ public abstract class DefaultCompilerAdapter | |||
* system. | |||
* @return the exit code of the compilation | |||
*/ | |||
protected int executeExternalCompile(String[] args, int firstFileName) { | |||
protected int executeExternalCompile(final String[] args, final int firstFileName) { | |||
return executeExternalCompile(args, firstFileName, true); | |||
} | |||
@@ -447,8 +449,8 @@ public abstract class DefaultCompilerAdapter | |||
* | |||
* @since Ant 1.6 | |||
*/ | |||
protected int executeExternalCompile(String[] args, int firstFileName, | |||
boolean quoteFiles) { | |||
protected int executeExternalCompile(final String[] args, final int firstFileName, | |||
final boolean quoteFiles) { | |||
String[] commandArray = null; | |||
File tmpFile = null; | |||
@@ -480,7 +482,7 @@ public abstract class DefaultCompilerAdapter | |||
commandArray = new String[firstFileName + 1]; | |||
System.arraycopy(args, 0, commandArray, 0, firstFileName); | |||
commandArray[firstFileName] = "@" + tmpFile; | |||
} catch (IOException e) { | |||
} catch (final IOException e) { | |||
throw new BuildException("Error creating temporary file", | |||
e, location); | |||
} finally { | |||
@@ -491,7 +493,7 @@ public abstract class DefaultCompilerAdapter | |||
} | |||
try { | |||
Execute exe = new Execute( | |||
final Execute exe = new Execute( | |||
new LogStreamHandler(attributes, | |||
Project.MSG_INFO, | |||
Project.MSG_WARN)); | |||
@@ -505,7 +507,7 @@ public abstract class DefaultCompilerAdapter | |||
exe.setCommandline(commandArray); | |||
exe.execute(); | |||
return exe.getExitValue(); | |||
} catch (IOException e) { | |||
} catch (final IOException e) { | |||
throw new BuildException("Error running " + args[0] | |||
+ " compiler", e, location); | |||
} | |||
@@ -522,7 +524,8 @@ public abstract class DefaultCompilerAdapter | |||
* @deprecated since 1.5.x. | |||
* Use org.apache.tools.ant.types.Path#addExtdirs instead. | |||
*/ | |||
protected void addExtdirsToClasspath(Path classpath) { | |||
@Deprecated | |||
protected void addExtdirsToClasspath(final Path classpath) { | |||
classpath.addExtdirs(extdirs); | |||
} | |||
@@ -530,7 +533,7 @@ public abstract class DefaultCompilerAdapter | |||
* Adds the command line arguments specific to the current implementation. | |||
* @param cmd the command line to use | |||
*/ | |||
protected void addCurrentCompilerArgs(Commandline cmd) { | |||
protected void addCurrentCompilerArgs(final Commandline cmd) { | |||
cmd.addArguments(getJavac().getCurrentCompilerArgs()); | |||
} | |||
@@ -619,7 +622,7 @@ public abstract class DefaultCompilerAdapter | |||
* Shall we assume command line switches for the given version of Java? | |||
* @since Ant 1.8.3 | |||
*/ | |||
private boolean assumeJavaXY(String javacXY, String javaEnvVersionXY) { | |||
private boolean assumeJavaXY(final String javacXY, final String javaEnvVersionXY) { | |||
return javacXY.equals(attributes.getCompilerVersion()) | |||
|| ("classic".equals(attributes.getCompilerVersion()) | |||
&& JavaEnvUtils.isJavaVersion(javaEnvVersionXY)) | |||
@@ -637,7 +640,7 @@ public abstract class DefaultCompilerAdapter | |||
* specified and the system bootclasspath. | |||
*/ | |||
protected Path getBootClassPath() { | |||
Path bp = new Path(project); | |||
final Path bp = new Path(project); | |||
if (bootclasspath != null) { | |||
bp.append(bootclasspath); | |||
} | |||
@@ -658,8 +661,8 @@ public abstract class DefaultCompilerAdapter | |||
return assumeJava11() ? null : "-g:none"; | |||
} | |||
private void setImplicitSourceSwitch(Commandline cmd, | |||
String target, String source) { | |||
private void setImplicitSourceSwitch(final Commandline cmd, | |||
final String target, final String source) { | |||
attributes.log("", Project.MSG_WARN); | |||
attributes.log(" WARNING", Project.MSG_WARN); | |||
attributes.log("", Project.MSG_WARN); | |||
@@ -723,7 +726,7 @@ public abstract class DefaultCompilerAdapter | |||
* <p>support for -source 1.1 and -source 1.2 has been added with | |||
* JDK 1.4.2 but isn't present in 1.5.0+</p> | |||
*/ | |||
private String adjustSourceValue(String source) { | |||
private String adjustSourceValue(final String source) { | |||
return (source.equals("1.1") || source.equals("1.2")) ? "1.3" : source; | |||
} | |||
} | |||
@@ -33,19 +33,19 @@ import org.apache.tools.ant.ProjectComponent; | |||
* <p>Test for a host being reachable using ICMP "ping" packets & echo operations. | |||
* Ping packets are very reliable for assessing reachability in a LAN or WAN, | |||
* but they do not get through any well-configured firewall. Echo (port 7) may.</p> | |||
* | |||
* | |||
* <p>This condition turns unknown host exceptions into false conditions. This is | |||
* because on a laptop, DNS is one of the first services lost when the network | |||
* goes; you are implicitly offline.</p> | |||
* | |||
* | |||
* <p>If a URL is supplied instead of a host, the hostname is extracted and used in | |||
* the test--all other parts of the URL are discarded.</p> | |||
* | |||
* | |||
* <p>The test may not work through firewalls; that is, something may be reachable | |||
* using a protocol such as HTTP, while the lower level ICMP packets get dropped | |||
* on the floor. Similarly, a host may be detected as reachable with ICMP, but not | |||
* reachable on other ports (i.e. port 80), because of firewalls.</p> | |||
* | |||
* | |||
* <p>Requires Java 5+ to work properly. On Java 1.4, if a hostname | |||
* can be resolved, the destination is assumed to be reachable.</p> | |||
* | |||
@@ -139,7 +139,8 @@ public class IsReachable extends ProjectComponent implements Condition { | |||
* @throws org.apache.tools.ant.BuildException | |||
* if an error occurs | |||
*/ | |||
public boolean eval() throws BuildException { | |||
@Override | |||
public boolean eval() throws BuildException { | |||
if (empty(host) && empty(url)) { | |||
throw new BuildException(ERROR_NO_HOSTNAME); | |||
} | |||
@@ -88,11 +88,11 @@ class ChangeLogParser { | |||
ArrayList names = new ArrayList(); | |||
if (packageName != null) { | |||
for (StringTokenizer tok = new StringTokenizer(packageName); | |||
tok.hasMoreTokens(); ) { | |||
tok.hasMoreTokens();) { | |||
names.add(tok.nextToken()); | |||
} | |||
} | |||
for (Iterator iter = modules.iterator(); iter.hasNext(); ) { | |||
for (Iterator iter = modules.iterator(); iter.hasNext();) { | |||
AbstractCvsTask.Module m = (AbstractCvsTask.Module) iter.next(); | |||
names.add(m.getName()); | |||
} | |||
@@ -144,7 +144,7 @@ public class CvsTagDiff extends AbstractCvsTask { | |||
private File mydestfile; | |||
/** | |||
* Used to skip over removed files | |||
* Used to skip over removed files | |||
*/ | |||
private boolean ignoreRemoved = false; | |||
@@ -167,7 +167,8 @@ public class CvsTagDiff extends AbstractCvsTask { | |||
* The package/module to analyze. | |||
* @param p the name of the package to analyse | |||
*/ | |||
public void setPackage(String p) { | |||
@Override | |||
public void setPackage(String p) { | |||
mypackage = p; | |||
} | |||
@@ -222,7 +223,7 @@ public class CvsTagDiff extends AbstractCvsTask { | |||
* @param b the ignore removed indicator. | |||
* | |||
* @since Ant 1.8.0 | |||
*/ | |||
*/ | |||
public void setIgnoreRemoved(boolean b) { | |||
ignoreRemoved = b; | |||
} | |||
@@ -233,7 +234,8 @@ public class CvsTagDiff extends AbstractCvsTask { | |||
* | |||
* @exception BuildException if an error occurs | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
// validate the input parameters | |||
validate(); | |||
@@ -80,7 +80,7 @@ public class CommandLauncher { | |||
/** | |||
* Launches the given command in a new process. | |||
* | |||
* | |||
* @param project | |||
* The project that the command is part of. | |||
* @param cmd | |||
@@ -104,7 +104,7 @@ public class CommandLauncher { | |||
/** | |||
* Launches the given command in a new process, in the given | |||
* working directory. | |||
* | |||
* | |||
* @param project | |||
* The project that the command is part of. | |||
* @param cmd | |||
@@ -35,7 +35,7 @@ public class CommandLauncherProxy extends CommandLauncher { | |||
/** | |||
* Launches the given command in a new process. Delegates this | |||
* method to the proxied launcher. | |||
* | |||
* | |||
* @param project | |||
* the Ant project. | |||
* @param cmd | |||
@@ -33,7 +33,7 @@ public class Java13CommandLauncher extends CommandLauncher { | |||
/** | |||
* Launches the given command in a new process, in the given | |||
* working directory. | |||
* | |||
* | |||
* @param project | |||
* the Ant project. | |||
* @param cmd | |||
@@ -34,7 +34,7 @@ public class MacCommandLauncher extends CommandLauncherProxy { | |||
/** | |||
* Launches the given command in a new process, in the given | |||
* working directory. | |||
* | |||
* | |||
* @param project | |||
* the Ant project. | |||
* @param cmd | |||
@@ -37,7 +37,7 @@ public class OS2CommandLauncher extends CommandLauncherProxy { | |||
/** | |||
* Launches the given command in a new process, in the given | |||
* working directory. | |||
* | |||
* | |||
* @param project | |||
* the Ant project. | |||
* @param cmd | |||
@@ -38,7 +38,7 @@ public class PerlScriptCommandLauncher extends CommandLauncherProxy { | |||
/** | |||
* Launches the given command in a new process, in the given | |||
* working directory. | |||
* | |||
* | |||
* @param project | |||
* the Ant project. | |||
* @param cmd | |||
@@ -38,7 +38,7 @@ public class ScriptCommandLauncher extends CommandLauncherProxy { | |||
/** | |||
* Launches the given command in a new process, in the given | |||
* working directory. | |||
* | |||
* | |||
* @param project | |||
* the Ant project. | |||
* @param cmd | |||
@@ -38,7 +38,7 @@ public class VmsCommandLauncher extends Java13CommandLauncher { | |||
/** | |||
* Launches the given command in a new process. | |||
* | |||
* | |||
* @param project | |||
* the Ant project. | |||
* @param cmd | |||
@@ -63,7 +63,7 @@ public class VmsCommandLauncher extends Java13CommandLauncher { | |||
* working directory. Note that under Java 1.4.0 and 1.4.1 on VMS | |||
* this method only works if <code>workingDir</code> is null or | |||
* the logical JAVA$FORK_SUPPORT_CHDIR needs to be set to TRUE. | |||
* | |||
* | |||
* @param project | |||
* the Ant project. | |||
* @param cmd | |||
@@ -35,7 +35,7 @@ public class WinNTCommandLauncher extends CommandLauncherProxy { | |||
/** | |||
* Launches the given command in a new process, in the given | |||
* working directory. | |||
* | |||
* | |||
* @param project | |||
* the Ant project. | |||
* @param cmd | |||
@@ -71,9 +71,9 @@ import org.apache.tools.ant.util.LayoutPreservingProperties; | |||
* </ul> | |||
* Other parameters are: | |||
* <ul> | |||
* <li>comment</li> | |||
* <li>key</li> | |||
* <li>operation</li> | |||
* <li>comment</li> | |||
* <li>key</li> | |||
* <li>operation</li> | |||
* <li>type</li> | |||
* <li>value (the final four being eliminated shortly)</li> | |||
* </ul> | |||
@@ -155,7 +155,8 @@ public class PropertyFile extends Task { | |||
* Execute the task. | |||
* @throws BuildException on error. | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
checkParameters(); | |||
readFile(); | |||
executeOperation(); | |||
@@ -378,7 +379,7 @@ public class PropertyFile extends Task { | |||
*/ | |||
protected void executeOn(Properties props) throws BuildException { | |||
checkParameters(); | |||
if (operation == Operation.DELETE_OPER) { | |||
props.remove(key); | |||
return; | |||
@@ -614,7 +615,8 @@ public class PropertyFile extends Task { | |||
public static final int DELETE_OPER = 3; | |||
/** {@inheritDoc}. */ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {"+", "-", "=", "del"}; | |||
} | |||
@@ -649,7 +651,8 @@ public class PropertyFile extends Task { | |||
public static final int STRING_TYPE = 2; | |||
/** {@inheritDoc} */ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {"int", "date", "string"}; | |||
} | |||
@@ -715,7 +718,8 @@ public class PropertyFile extends Task { | |||
} | |||
/** {@inheritDoc}. */ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return UNITS; | |||
} | |||
} | |||
@@ -213,7 +213,7 @@ public class ReplaceRegExp extends Task { | |||
* want to only replace the first occurrence of a regular expression on | |||
* each line, which is not easy to do when processing the file as a whole. | |||
* Defaults to <i>false</i>. | |||
* | |||
* | |||
* @param byline the byline attribute as a string | |||
* @deprecated since 1.6.x. | |||
* Use setByLine(boolean). | |||
@@ -234,7 +234,7 @@ public class ReplaceRegExp extends Task { | |||
* want to only replace the first occurrence of a regular expression on | |||
* each line, which is not easy to do when processing the file as a whole. | |||
* Defaults to <i>false</i>. | |||
* | |||
* | |||
* @param byline the byline attribute | |||
*/ | |||
public void setByLine(boolean byline) { | |||
@@ -465,7 +465,8 @@ public class ReplaceRegExp extends Task { | |||
* | |||
* @throws BuildException is there is a problem in the task execution. | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
if (regex == null) { | |||
throw new BuildException("No expression to match."); | |||
} | |||
@@ -143,7 +143,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* @param stylesheet a <code>File</code> value | |||
* @throws Exception on error | |||
*/ | |||
public void setStylesheet(File stylesheet) throws Exception { | |||
@Override | |||
public void setStylesheet(File stylesheet) throws Exception { | |||
FileResource fr = new FileResource(); | |||
fr.setProject(project); | |||
fr.setFile(stylesheet); | |||
@@ -155,7 +156,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* @param stylesheet a {@link org.apache.tools.ant.types.Resource} value | |||
* @throws Exception on error | |||
*/ | |||
public void setStylesheet(Resource stylesheet) throws Exception { | |||
@Override | |||
public void setStylesheet(Resource stylesheet) throws Exception { | |||
if (this.stylesheet != null) { | |||
// resetting the stylesheet - reset transformer | |||
transformer = null; | |||
@@ -175,7 +177,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* @param outfile the result file | |||
* @throws Exception on error | |||
*/ | |||
public void transform(File infile, File outfile) throws Exception { | |||
@Override | |||
public void transform(File infile, File outfile) throws Exception { | |||
if (transformer == null) { | |||
createTransformer(); | |||
} | |||
@@ -504,17 +507,19 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* @param name the name of the parameter | |||
* @param value the value of the parameter | |||
*/ | |||
public void addParam(String name, String value) { | |||
@Override | |||
public void addParam(String name, String value) { | |||
params.put(name, value); | |||
} | |||
/** | |||
* Add a parameter. | |||
* @param name the name of the parameter | |||
* @param value the value of the parameter | |||
* @since Ant 1.9.3 | |||
*/ | |||
public void addParam(String name, Object value) { | |||
@Override | |||
public void addParam(String name, Object value) { | |||
params.put(name, value); | |||
} | |||
@@ -522,7 +527,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* Set a logger. | |||
* @param l a logger. | |||
*/ | |||
public void setLogger(XSLTLogger l) { | |||
@Override | |||
public void setLogger(XSLTLogger l) { | |||
logger = l; | |||
} | |||
@@ -530,7 +536,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* Log an error. | |||
* @param e the exception to log. | |||
*/ | |||
public void error(TransformerException e) { | |||
@Override | |||
public void error(TransformerException e) { | |||
logError(e, "Error"); | |||
} | |||
@@ -538,7 +545,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* Log a fatal error. | |||
* @param e the exception to log. | |||
*/ | |||
public void fatalError(TransformerException e) { | |||
@Override | |||
public void fatalError(TransformerException e) { | |||
logError(e, "Fatal Error"); | |||
throw new BuildException("Fatal error during transformation using " + stylesheet + ": " + e.getMessageAndLocation(), e); | |||
} | |||
@@ -547,7 +555,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* Log a warning. | |||
* @param e the exception to log. | |||
*/ | |||
public void warning(TransformerException e) { | |||
@Override | |||
public void warning(TransformerException e) { | |||
if (!suppressWarnings) { | |||
logError(e, "Warning"); | |||
} | |||
@@ -601,7 +610,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* @deprecated since 1.5.x. | |||
* Use org.apache.tools.ant.util.JAXPUtils#getSystemId instead. | |||
*/ | |||
protected String getSystemId(File file) { | |||
@Deprecated | |||
protected String getSystemId(File file) { | |||
return JAXPUtils.getSystemId(file); | |||
} | |||
@@ -611,7 +621,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* @param xsltTask the XSLTProcess task instance from which this liasion | |||
* is to be configured. | |||
*/ | |||
public void configure(XSLTProcess xsltTask) { | |||
@Override | |||
public void configure(XSLTProcess xsltTask) { | |||
project = xsltTask.getProject(); | |||
XSLTProcess.Factory factory = xsltTask.getFactory(); | |||
if (factory != null) { | |||
@@ -43,7 +43,8 @@ public class MethodTypeCPInfo extends ConstantCPInfo { | |||
* @exception java.io.IOException if there is a problem reading the entry from | |||
* the stream. | |||
*/ | |||
public void read(DataInputStream cpStream) throws IOException { | |||
@Override | |||
public void read(final DataInputStream cpStream) throws IOException { | |||
methodDescriptorIndex = cpStream.readUnsignedShort(); | |||
} | |||
@@ -54,8 +55,9 @@ public class MethodTypeCPInfo extends ConstantCPInfo { | |||
* @param constantPool the constant pool of which this entry is a member | |||
* and against which this entry is to be resolved. | |||
*/ | |||
public void resolve(ConstantPool constantPool) { | |||
Utf8CPInfo methodClass | |||
@Override | |||
public void resolve(final ConstantPool constantPool) { | |||
final Utf8CPInfo methodClass | |||
= (Utf8CPInfo) constantPool.getEntry(methodDescriptorIndex); | |||
methodClass.resolve(constantPool); | |||
methodDescriptor = methodClass.getValue(); | |||
@@ -66,8 +68,9 @@ public class MethodTypeCPInfo extends ConstantCPInfo { | |||
* | |||
* @return the string representation of this constant pool entry. | |||
*/ | |||
public String toString() { | |||
if (! isResolved()) { | |||
@Override | |||
public String toString() { | |||
if (!isResolved()) { | |||
return "MethodDescriptorIndex: " + methodDescriptorIndex; | |||
} else { | |||
return "MethodDescriptor: " + methodDescriptor; | |||
@@ -166,7 +166,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||
* @param inString the string to use as the suffix. This parameter is | |||
* ignored. | |||
*/ | |||
public void setGenericJarSuffix(String inString) { | |||
@Override | |||
public void setGenericJarSuffix(String inString) { | |||
log("Since a generic JAR file is not created during processing, the " | |||
+ "iPlanet Deployment Tool does not support the " | |||
+ "\"genericjarsuffix\" attribute. It will be ignored.", | |||
@@ -174,7 +175,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||
} | |||
/** {@inheritDoc}. */ | |||
public void processDescriptor(String descriptorName, SAXParser saxParser) { | |||
@Override | |||
public void processDescriptor(String descriptorName, SAXParser saxParser) { | |||
this.descriptorName = descriptorName; | |||
this.iasDescriptorName = null; | |||
@@ -193,7 +195,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||
* descriptor | |||
* @throws BuildException If the user selections are invalid. | |||
*/ | |||
protected void checkConfiguration(String descriptorFileName, | |||
@Override | |||
protected void checkConfiguration(String descriptorFileName, | |||
SAXParser saxParser) throws BuildException { | |||
int startOfName = descriptorFileName.lastIndexOf(File.separatorChar) + 1; | |||
@@ -236,7 +239,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||
* @throws SAXException Any SAX exception, possibly wrapping another | |||
* exception | |||
*/ | |||
protected Hashtable parseEjbFiles(String descriptorFileName, | |||
@Override | |||
protected Hashtable parseEjbFiles(String descriptorFileName, | |||
SAXParser saxParser) throws IOException, SAXException { | |||
Hashtable files; | |||
@@ -257,7 +261,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||
} | |||
if (getConfig().dtdLocations != null) { | |||
for (Iterator i = getConfig().dtdLocations.iterator(); | |||
i.hasNext(); ) { | |||
i.hasNext();) { | |||
EjbJar.DTDLocation dtdLocation = | |||
(EjbJar.DTDLocation) i.next(); | |||
ejbc.registerDTD(dtdLocation.getPublicId(), | |||
@@ -308,7 +312,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||
* the completed JAR file. | |||
* @param ddPrefix not used | |||
*/ | |||
protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) { | |||
@Override | |||
protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) { | |||
ejbFiles.put(META_DIR + IAS_DD, new File(getConfig().descriptorDir, | |||
getIasDescriptorName())); | |||
} | |||
@@ -322,7 +327,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||
* | |||
* @return File representing the JAR file which will be written. | |||
*/ | |||
File getVendorOutputJarFile(String baseName) { | |||
@Override | |||
File getVendorOutputJarFile(String baseName) { | |||
File jarFile = new File(getDestDir(), baseName + jarSuffix); | |||
log("JAR file name: " + jarFile.toString(), Project.MSG_VERBOSE); | |||
return jarFile; | |||
@@ -335,7 +341,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||
* | |||
* @return <code>null</code>. | |||
*/ | |||
protected String getPublicId() { | |||
@Override | |||
protected String getPublicId() { | |||
return null; | |||
} | |||
@@ -37,7 +37,6 @@ import java.util.StringTokenizer; | |||
import javax.xml.parsers.SAXParser; | |||
import javax.xml.parsers.SAXParserFactory; | |||
import org.apache.tools.ant.BuildException; | |||
import org.xml.sax.AttributeList; | |||
import org.xml.sax.HandlerBase; | |||
import org.xml.sax.InputSource; | |||
@@ -113,7 +113,8 @@ public class ExtensionSet | |||
* @param reference the reference to which this instance is associated | |||
* @exception BuildException if this instance already has been configured. | |||
*/ | |||
public void setRefid(final Reference reference) | |||
@Override | |||
public void setRefid(final Reference reference) | |||
throws BuildException { | |||
if (!extensions.isEmpty() || !extensionsFilesets.isEmpty()) { | |||
throw tooManyAttributes(); | |||
@@ -121,7 +122,8 @@ public class ExtensionSet | |||
super.setRefid(reference); | |||
} | |||
protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
@Override | |||
protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
throws BuildException { | |||
if (isChecked()) { | |||
return; | |||
@@ -129,11 +131,11 @@ public class ExtensionSet | |||
if (isReference()) { | |||
super.dieOnCircularReference(stk, p); | |||
} else { | |||
for (Iterator i = extensions.iterator(); i.hasNext(); ) { | |||
for (Iterator i = extensions.iterator(); i.hasNext();) { | |||
pushAndInvokeCircularReferenceCheck((ExtensionAdapter) i.next(), | |||
stk, p); | |||
} | |||
for (Iterator i = extensionsFilesets.iterator(); i.hasNext(); ) { | |||
for (Iterator i = extensionsFilesets.iterator(); i.hasNext();) { | |||
pushAndInvokeCircularReferenceCheck((FileSet) i.next(), stk, p); | |||
} | |||
setChecked(true); | |||
@@ -144,7 +146,8 @@ public class ExtensionSet | |||
* @see java.lang.Object#toString() | |||
* @return the extensions in a string. | |||
*/ | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
return "ExtensionSet" + Arrays.asList(toExtensions(getProject())); | |||
} | |||
} |
@@ -48,7 +48,7 @@ public class JUnit4TestMethodAdapter implements Test { | |||
/** | |||
* Creates a new adapter for the given class and a method within the class. | |||
* | |||
* | |||
* @param testClass test class containing the method to be executed | |||
* @param methodNames names of the test methods that are to be executed | |||
* @exception java.lang.IllegalArgumentException | |||
@@ -72,7 +72,7 @@ public class JUnit4TestMethodAdapter implements Test { | |||
} | |||
} | |||
this.testClass = testClass; | |||
this.methodNames = (String[]) methodNames.clone(); | |||
this.methodNames = methodNames.clone(); | |||
this.cache = CustomJUnit4TestAdapterCache.getInstance(); | |||
// Warning: If 'testClass' is an old-style (pre-JUnit-4) class, | |||
@@ -87,7 +87,8 @@ public class JUnit4TestMethodAdapter implements Test { | |||
runner = request.getRunner(); | |||
} | |||
public int countTestCases() { | |||
@Override | |||
public int countTestCases() { | |||
return runner.testCount(); | |||
} | |||
@@ -103,11 +104,13 @@ public class JUnit4TestMethodAdapter implements Test { | |||
return testClass; | |||
} | |||
public void run(final TestResult result) { | |||
@Override | |||
public void run(final TestResult result) { | |||
runner.run(cache.getNotifier(result)); | |||
} | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
String testClassName = testClass.getName(); | |||
StringBuilder buf = new StringBuilder(testClassName.length() | |||
+ 12 * methodNames.length) | |||
@@ -144,7 +147,8 @@ public class JUnit4TestMethodAdapter implements Test { | |||
this.methodNames = methodNames; | |||
} | |||
public boolean shouldRun(Description description) { | |||
@Override | |||
public boolean shouldRun(Description description) { | |||
if (methodNames.length == 0) { | |||
return false; | |||
} | |||
@@ -165,10 +169,11 @@ public class JUnit4TestMethodAdapter implements Test { | |||
} | |||
} | |||
} | |||
return false; | |||
return false; | |||
} | |||
public String describe() { | |||
@Override | |||
public String describe() { | |||
StringBuilder buf = new StringBuilder(40); | |||
if (methodNames.length == 0) { | |||
buf.append("No methods"); | |||
@@ -364,7 +364,8 @@ public class JUnitTask extends Task { | |||
* list the possible values | |||
* @return array of allowed values | |||
*/ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {"true", "yes", "false", "no", | |||
"on", "off", "withOutAndErr"}; | |||
} | |||
@@ -455,7 +456,8 @@ public class JUnitTask extends Task { | |||
* @deprecated since ant 1.6 | |||
* @param sysp environment variable to add | |||
*/ | |||
public void addSysproperty(Environment.Variable sysp) { | |||
@Deprecated | |||
public void addSysproperty(Environment.Variable sysp) { | |||
getCommandline().addSysproperty(sysp); | |||
} | |||
@@ -703,7 +705,7 @@ public class JUnitTask extends Task { | |||
* Whether test listener events shall be generated. | |||
* | |||
* <p>Defaults to false.</p> | |||
* | |||
* | |||
* <p>This value will be overridden by the magic property | |||
* ant.junit.enabletestlistenerevents if it has been set.</p> | |||
* | |||
@@ -732,7 +734,8 @@ public class JUnitTask extends Task { | |||
* | |||
* @since Ant 1.4 | |||
*/ | |||
public void init() { | |||
@Override | |||
public void init() { | |||
antRuntimeClasses = new Path(getProject()); | |||
splitJUnit = !addClasspathResource("/junit/framework/TestCase.class"); | |||
addClasspathEntry("/org/apache/tools/ant/launch/AntMain.class"); | |||
@@ -779,7 +782,8 @@ public class JUnitTask extends Task { | |||
path.add(extra); | |||
} | |||
mirrorLoader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { | |||
public Object run() { | |||
@Override | |||
public Object run() { | |||
return new SplitClassLoader(myLoader, path, getProject(), | |||
new String[] { | |||
"BriefJUnitResultFormatter", | |||
@@ -812,7 +816,8 @@ public class JUnitTask extends Task { | |||
* @throws BuildException in case of test failures or errors | |||
* @since Ant 1.2 | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
checkMethodLists(); | |||
setupJUnitDelegate(); | |||
@@ -866,7 +871,8 @@ public class JUnitTask extends Task { | |||
this.id = id; | |||
} | |||
public void run() { | |||
@Override | |||
public void run() { | |||
try { | |||
masterTask.oneJunitThread(iterator, id); | |||
} catch (BuildException b) { | |||
@@ -877,7 +883,7 @@ public class JUnitTask extends Task { | |||
private JUnitTask masterTask; | |||
private Iterator<List> iterator; | |||
private int id; | |||
private int id; | |||
} | |||
/* | |||
@@ -1436,7 +1442,8 @@ public class JUnitTask extends Task { | |||
* @param output output coming from System.out | |||
* @since Ant 1.5 | |||
*/ | |||
protected void handleOutput(String output) { | |||
@Override | |||
protected void handleOutput(String output) { | |||
if (output.startsWith(TESTLISTENER_PREFIX)) { | |||
log(output, Project.MSG_VERBOSE); | |||
} else if (runner != null) { | |||
@@ -1465,7 +1472,8 @@ public class JUnitTask extends Task { | |||
* | |||
* @since Ant 1.6 | |||
*/ | |||
protected int handleInput(byte[] buffer, int offset, int length) | |||
@Override | |||
protected int handleInput(byte[] buffer, int offset, int length) | |||
throws IOException { | |||
if (runner != null) { | |||
return runner.handleInput(buffer, offset, length); | |||
@@ -1482,7 +1490,8 @@ public class JUnitTask extends Task { | |||
* @param output output coming from System.out | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleFlush(String output) { | |||
@Override | |||
protected void handleFlush(String output) { | |||
if (runner != null) { | |||
runner.handleFlush(output); | |||
if (showOutput) { | |||
@@ -1500,7 +1509,8 @@ public class JUnitTask extends Task { | |||
* @param output output coming from System.err | |||
* @since Ant 1.5 | |||
*/ | |||
public void handleErrorOutput(String output) { | |||
@Override | |||
public void handleErrorOutput(String output) { | |||
if (runner != null) { | |||
runner.handleErrorOutput(output); | |||
if (showOutput) { | |||
@@ -1519,7 +1529,8 @@ public class JUnitTask extends Task { | |||
* @param output coming from System.err | |||
* @since Ant 1.5.2 | |||
*/ | |||
public void handleErrorFlush(String output) { | |||
@Override | |||
public void handleErrorFlush(String output) { | |||
if (runner != null) { | |||
runner.handleErrorFlush(output); | |||
if (showOutput) { | |||
@@ -1783,7 +1794,7 @@ public class JUnitTask extends Task { | |||
} | |||
} | |||
static final String TIMEOUT_MESSAGE = | |||
static final String TIMEOUT_MESSAGE = | |||
"Timeout occurred. Please note the time in the report does" | |||
+ " not reflect the time until the timeout."; | |||
@@ -1999,7 +2010,8 @@ public class JUnitTask extends Task { | |||
* @param other | |||
* @return true if everything is equal | |||
*/ | |||
public boolean equals(Object other) { | |||
@Override | |||
public boolean equals(Object other) { | |||
if (other == null | |||
|| other.getClass() != ForkedTestConfiguration.class) { | |||
return false; | |||
@@ -2023,7 +2035,8 @@ public class JUnitTask extends Task { | |||
* in the range 0-7. | |||
* @return hash code value | |||
*/ | |||
public int hashCode() { | |||
@Override | |||
public int hashCode() { | |||
// CheckStyle:MagicNumber OFF | |||
return (filterTrace ? 1 : 0) | |||
+ (haltOnError ? 2 : 0) | |||
@@ -2066,7 +2079,8 @@ public class JUnitTask extends Task { | |||
} | |||
/** {@inheritDoc}. */ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {ONCE, PER_TEST, PER_BATCH}; | |||
} | |||
} | |||
@@ -2203,7 +2217,8 @@ public class JUnitTask extends Task { | |||
* @param line the line to log. | |||
* @param level the logging level to use. | |||
*/ | |||
protected void processLine(String line, int level) { | |||
@Override | |||
protected void processLine(String line, int level) { | |||
if (line.startsWith(TESTLISTENER_PREFIX)) { | |||
task.log(line, Project.MSG_VERBOSE); | |||
} else { | |||
@@ -55,7 +55,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
/** the names of test methods to execute */ | |||
private String[] methods = null; | |||
/** the name of the result file */ | |||
private String outfile = null; | |||
@@ -110,7 +110,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
*/ | |||
public JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, | |||
boolean filtertrace, String[] methods) { | |||
this(name, haltOnError, haltOnFailure, filtertrace, methods, 0); | |||
this(name, haltOnError, haltOnFailure, filtertrace, methods, 0); | |||
} | |||
/** | |||
@@ -527,7 +527,8 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
* @since Ant 1.5 | |||
* @return a clone of this test. | |||
*/ | |||
public Object clone() { | |||
@Override | |||
public Object clone() { | |||
try { | |||
JUnitTest t = (JUnitTest) super.clone(); | |||
t.props = props == null ? null : (Properties) props.clone(); | |||
@@ -75,7 +75,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
/** | |||
* Holds the registered formatters. | |||
*/ | |||
private Vector<JUnitTaskMirror.JUnitResultFormatterMirror> formatters = new Vector(); | |||
private final Vector<JUnitTaskMirror.JUnitResultFormatterMirror> formatters = new Vector(); | |||
/** | |||
* Collects TestResults. | |||
@@ -138,7 +138,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
/** | |||
* The TestSuite we are currently running. | |||
*/ | |||
private JUnitTest junitTest; | |||
private final JUnitTest junitTest; | |||
/** output written during the test */ | |||
private PrintStream systemError; | |||
@@ -153,7 +153,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
private static boolean multipleTests = false; | |||
/** ClassLoader passed in in non-forked mode. */ | |||
private ClassLoader loader; | |||
private final ClassLoader loader; | |||
/** Do we print TestListener events? */ | |||
private boolean logTestListenerEvents = false; | |||
@@ -169,7 +169,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
/** Names of test methods to execute */ | |||
private String[] methods = null; | |||
/** | |||
* Constructor for fork=true or when the user hasn't specified a | |||
* classpath. | |||
@@ -178,8 +178,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param filtertrace whether to filter junit.*.* stack frames out of exceptions | |||
* @param haltOnFailure whether to stop the run if failure is found. | |||
*/ | |||
public JUnitTestRunner(JUnitTest test, boolean haltOnError, | |||
boolean filtertrace, boolean haltOnFailure) { | |||
public JUnitTestRunner(final JUnitTest test, final boolean haltOnError, | |||
final boolean filtertrace, final boolean haltOnFailure) { | |||
this(test, haltOnError, filtertrace, haltOnFailure, false); | |||
} | |||
@@ -192,9 +192,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param haltOnFailure whether to stop the run if failure is found. | |||
* @param showOutput whether to send output to System.out/.err as well as formatters. | |||
*/ | |||
public JUnitTestRunner(JUnitTest test, boolean haltOnError, | |||
boolean filtertrace, boolean haltOnFailure, | |||
boolean showOutput) { | |||
public JUnitTestRunner(final JUnitTest test, final boolean haltOnError, | |||
final boolean filtertrace, final boolean haltOnFailure, | |||
final boolean showOutput) { | |||
this(test, haltOnError, filtertrace, haltOnFailure, showOutput, false); | |||
} | |||
@@ -209,9 +209,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param logTestListenerEvents whether to print TestListener events. | |||
* @since Ant 1.7 | |||
*/ | |||
public JUnitTestRunner(JUnitTest test, boolean haltOnError, | |||
boolean filtertrace, boolean haltOnFailure, | |||
boolean showOutput, boolean logTestListenerEvents) { | |||
public JUnitTestRunner(final JUnitTest test, final boolean haltOnError, | |||
final boolean filtertrace, final boolean haltOnFailure, | |||
final boolean showOutput, final boolean logTestListenerEvents) { | |||
this(test, null, haltOnError, filtertrace, haltOnFailure, showOutput, | |||
logTestListenerEvents, null); | |||
} | |||
@@ -228,9 +228,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param logTestListenerEvents whether to print TestListener events. | |||
* @since 1.8.2 | |||
*/ | |||
public JUnitTestRunner(JUnitTest test, String[] methods, boolean haltOnError, | |||
boolean filtertrace, boolean haltOnFailure, | |||
boolean showOutput, boolean logTestListenerEvents) { | |||
public JUnitTestRunner(final JUnitTest test, final String[] methods, final boolean haltOnError, | |||
final boolean filtertrace, final boolean haltOnFailure, | |||
final boolean showOutput, final boolean logTestListenerEvents) { | |||
this(test, methods, haltOnError, filtertrace, haltOnFailure, showOutput, | |||
logTestListenerEvents, null); | |||
} | |||
@@ -243,9 +243,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param haltOnFailure whether to stop the run if failure is found. | |||
* @param loader the classloader to use running the test. | |||
*/ | |||
public JUnitTestRunner(JUnitTest test, boolean haltOnError, | |||
boolean filtertrace, boolean haltOnFailure, | |||
ClassLoader loader) { | |||
public JUnitTestRunner(final JUnitTest test, final boolean haltOnError, | |||
final boolean filtertrace, final boolean haltOnFailure, | |||
final ClassLoader loader) { | |||
this(test, haltOnError, filtertrace, haltOnFailure, false, loader); | |||
} | |||
@@ -258,9 +258,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param showOutput whether to send output to System.out/.err as well as formatters. | |||
* @param loader the classloader to use running the test. | |||
*/ | |||
public JUnitTestRunner(JUnitTest test, boolean haltOnError, | |||
boolean filtertrace, boolean haltOnFailure, | |||
boolean showOutput, ClassLoader loader) { | |||
public JUnitTestRunner(final JUnitTest test, final boolean haltOnError, | |||
final boolean filtertrace, final boolean haltOnFailure, | |||
final boolean showOutput, final ClassLoader loader) { | |||
this(test, haltOnError, filtertrace, haltOnFailure, showOutput, | |||
false, loader); | |||
} | |||
@@ -276,11 +276,11 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param loader the classloader to use running the test. | |||
* @since Ant 1.7 | |||
*/ | |||
public JUnitTestRunner(JUnitTest test, boolean haltOnError, | |||
boolean filtertrace, boolean haltOnFailure, | |||
boolean showOutput, boolean logTestListenerEvents, | |||
ClassLoader loader) { | |||
this(test, null, haltOnError, filtertrace, haltOnFailure, showOutput, | |||
public JUnitTestRunner(final JUnitTest test, final boolean haltOnError, | |||
final boolean filtertrace, final boolean haltOnFailure, | |||
final boolean showOutput, final boolean logTestListenerEvents, | |||
final ClassLoader loader) { | |||
this(test, null, haltOnError, filtertrace, haltOnFailure, showOutput, | |||
logTestListenerEvents, loader); | |||
} | |||
@@ -289,10 +289,10 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* Constructor to use when the user has specified a classpath. | |||
* @since 1.8.2 | |||
*/ | |||
public JUnitTestRunner(JUnitTest test, String[] methods, boolean haltOnError, | |||
boolean filtertrace, boolean haltOnFailure, | |||
boolean showOutput, boolean logTestListenerEvents, | |||
ClassLoader loader) { | |||
public JUnitTestRunner(final JUnitTest test, final String[] methods, final boolean haltOnError, | |||
final boolean filtertrace, final boolean haltOnFailure, | |||
final boolean showOutput, final boolean logTestListenerEvents, | |||
final ClassLoader loader) { | |||
super(); | |||
JUnitTestRunner.filtertrace = filtertrace; // TODO clumsy, should use instance field somehow | |||
this.junitTest = test; | |||
@@ -310,17 +310,18 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
private PrintStream createEmptyStream() { | |||
return new PrintStream( | |||
new OutputStream() { | |||
public void write(int b) { | |||
@Override | |||
public void write(final int b) { | |||
} | |||
}); | |||
} | |||
private PrintStream createTeePrint(PrintStream ps1, PrintStream ps2) { | |||
private PrintStream createTeePrint(final PrintStream ps1, final PrintStream ps2) { | |||
return new PrintStream(new TeeOutputStream(ps1, ps2)); | |||
} | |||
private void setupIOStreams(ByteArrayOutputStream o, | |||
ByteArrayOutputStream e) { | |||
private void setupIOStreams(final ByteArrayOutputStream o, | |||
final ByteArrayOutputStream e) { | |||
systemOut = new PrintStream(o); | |||
systemError = new PrintStream(e); | |||
@@ -354,7 +355,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
/** | |||
* Run the test. | |||
*/ | |||
public void run() { | |||
@Override | |||
public void run() { | |||
res = new IgnoredTestResult(); | |||
res.addListener(wrapListener(this)); | |||
final int size = formatters.size(); | |||
@@ -362,8 +364,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
res.addListener(wrapListener((TestListener) formatters.elementAt(i))); | |||
} | |||
ByteArrayOutputStream errStrm = new ByteArrayOutputStream(); | |||
ByteArrayOutputStream outStrm = new ByteArrayOutputStream(); | |||
final ByteArrayOutputStream errStrm = new ByteArrayOutputStream(); | |||
final ByteArrayOutputStream outStrm = new ByteArrayOutputStream(); | |||
setupIOStreams(outStrm, errStrm); | |||
@@ -391,7 +393,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
try { | |||
// check if there is a suite method | |||
suiteMethod = testClass.getMethod("suite", new Class[0]); | |||
} catch (NoSuchMethodException e) { | |||
} catch (final NoSuchMethodException e) { | |||
// no appropriate suite method found. We don't report any | |||
// error here since it might be perfectly normal. | |||
} | |||
@@ -461,14 +463,14 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
useSingleMethodAdapter = true; | |||
} | |||
} | |||
} catch (ClassNotFoundException e) { | |||
} catch (final ClassNotFoundException e) { | |||
// OK, fall back to JUnit 3. | |||
} | |||
} | |||
junit4 = junit4TestAdapterClass != null; | |||
if (junitTest.isSkipNonTests()) { | |||
if (!containsTests( testClass, junit4)) { | |||
if (!containsTests(testClass, junit4)) { | |||
return; | |||
} | |||
} | |||
@@ -500,7 +502,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} else if (methods.length == 1) { | |||
suite = TestSuite.createTest(testClass, methods[0]); | |||
} else { | |||
TestSuite testSuite = new TestSuite(testClass.getName()); | |||
final TestSuite testSuite = new TestSuite(testClass.getName()); | |||
for (int i = 0; i < methods.length; i++) { | |||
testSuite.addTest( | |||
TestSuite.createTest(testClass, methods[i])); | |||
@@ -511,12 +513,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} | |||
} catch (Throwable e) { | |||
} catch (final Throwable e) { | |||
retCode = ERRORS; | |||
exception = e; | |||
} | |||
long start = System.currentTimeMillis(); | |||
final long start = System.currentTimeMillis(); | |||
fireStartTestSuite(); | |||
startTestSuiteSuccess = true; | |||
@@ -535,7 +537,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} finally { | |||
if (junit4 || | |||
suite.getClass().getName().equals(JUNIT_4_TEST_ADAPTER)) { | |||
int[] cnts = findJUnit4FailureErrorCount(res); | |||
final int[] cnts = findJUnit4FailureErrorCount(res); | |||
junitTest.setCounts(res.runCount() + res.ignoredCount(), cnts[0], cnts[1], res.ignoredCount() + res.skippedCount()); | |||
} else { | |||
junitTest.setCounts(res.runCount() + res.ignoredCount(), res.failureCount(), | |||
@@ -563,12 +565,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
String out, err; | |||
try { | |||
out = new String(outStrm.toByteArray()); | |||
} catch (OutOfMemoryError ex) { | |||
} catch (final OutOfMemoryError ex) { | |||
out = "out of memory on output stream"; | |||
} | |||
try { | |||
err = new String(errStrm.toByteArray()); | |||
} catch (OutOfMemoryError ex) { | |||
} catch (final OutOfMemoryError ex) { | |||
err = "out of memory on error stream"; | |||
} | |||
sendOutAndErr(out, err); | |||
@@ -584,14 +586,14 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} | |||
} | |||
private static boolean containsTests(Class<?> testClass, boolean isJUnit4) { | |||
private static boolean containsTests(final Class<?> testClass, final boolean isJUnit4) { | |||
Class testAnnotation = null; | |||
Class suiteAnnotation = null; | |||
Class runWithAnnotation = null; | |||
try { | |||
testAnnotation = Class.forName("org.junit.Test"); | |||
} catch (ClassNotFoundException e) { | |||
} catch (final ClassNotFoundException e) { | |||
if (isJUnit4) { | |||
// odd - we think we're JUnit4 but don't support the test annotation. We therefore can't have any tests! | |||
return false; | |||
@@ -601,12 +603,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
try { | |||
suiteAnnotation = Class.forName("org.junit.Suite.SuiteClasses"); | |||
} catch(ClassNotFoundException ex) { | |||
} catch(final ClassNotFoundException ex) { | |||
// ignore - we don't have this annotation so make sure we don't check for it | |||
} | |||
try { | |||
runWithAnnotation = Class.forName("org.junit.runner.RunWith"); | |||
} catch(ClassNotFoundException ex) { | |||
} catch(final ClassNotFoundException ex) { | |||
// also ignore as this annotation doesn't exist so tests can't use it | |||
} | |||
@@ -617,7 +619,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} | |||
// check if we have any inner classes that contain suitable test methods | |||
for (Class<?> innerClass : testClass.getDeclaredClasses()) { | |||
for (final Class<?> innerClass : testClass.getDeclaredClasses()) { | |||
if (containsTests(innerClass, isJUnit4) || containsTests(innerClass, !isJUnit4)) { | |||
return true; | |||
} | |||
@@ -645,7 +647,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} | |||
} | |||
for (Method m : testClass.getMethods()) { | |||
for (final Method m : testClass.getMethods()) { | |||
if (isJUnit4) { | |||
// check if suspected JUnit4 classes have methods with @Test annotation | |||
if (m.getAnnotation(testAnnotation) != null) { | |||
@@ -676,7 +678,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* | |||
* @return 2 if errors occurred, 1 if tests failed else 0. | |||
*/ | |||
public int getRetCode() { | |||
@Override | |||
public int getRetCode() { | |||
return retCode; | |||
} | |||
@@ -686,8 +689,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* <p>A new Test is started. | |||
* @param t the test. | |||
*/ | |||
public void startTest(Test t) { | |||
String testName = JUnitVersionHelper.getTestCaseName(t); | |||
@Override | |||
public void startTest(final Test t) { | |||
final String testName = JUnitVersionHelper.getTestCaseName(t); | |||
logTestListenerEvent("startTest(" + testName + ")"); | |||
} | |||
@@ -697,19 +701,20 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* <p>A Test is finished. | |||
* @param test the test. | |||
*/ | |||
public void endTest(Test test) { | |||
String testName = JUnitVersionHelper.getTestCaseName(test); | |||
@Override | |||
public void endTest(final Test test) { | |||
final String testName = JUnitVersionHelper.getTestCaseName(test); | |||
logTestListenerEvent("endTest(" + testName + ")"); | |||
} | |||
private void logTestListenerEvent(String msg) { | |||
if (logTestListenerEvents) { | |||
PrintStream out = savedOut != null ? savedOut : System.out; | |||
final PrintStream out = savedOut != null ? savedOut : System.out; | |||
out.flush(); | |||
if (msg == null) { | |||
msg = "null"; | |||
} | |||
StringTokenizer msgLines = new StringTokenizer(msg, "\r\n", false); | |||
final StringTokenizer msgLines = new StringTokenizer(msg, "\r\n", false); | |||
while (msgLines.hasMoreTokens()) { | |||
out.println(JUnitTask.TESTLISTENER_PREFIX | |||
+ msgLines.nextToken()); | |||
@@ -725,8 +730,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param test the test. | |||
* @param t the exception thrown by the test. | |||
*/ | |||
public void addFailure(Test test, Throwable t) { | |||
String testName = JUnitVersionHelper.getTestCaseName(test); | |||
public void addFailure(final Test test, final Throwable t) { | |||
final String testName = JUnitVersionHelper.getTestCaseName(test); | |||
logTestListenerEvent("addFailure(" + testName + ", " + t.getMessage() + ")"); | |||
if (haltOnFailure) { | |||
res.stop(); | |||
@@ -740,7 +745,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param test the test. | |||
* @param t the assertion thrown by the test. | |||
*/ | |||
public void addFailure(Test test, AssertionFailedError t) { | |||
@Override | |||
public void addFailure(final Test test, final AssertionFailedError t) { | |||
addFailure(test, (Throwable) t); | |||
} | |||
@@ -751,8 +757,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param test the test. | |||
* @param t the error thrown by the test. | |||
*/ | |||
public void addError(Test test, Throwable t) { | |||
String testName = JUnitVersionHelper.getTestCaseName(test); | |||
@Override | |||
public void addError(final Test test, final Throwable t) { | |||
final String testName = JUnitVersionHelper.getTestCaseName(test); | |||
logTestListenerEvent("addError(" + testName + ", " + t.getMessage() + ")"); | |||
if (haltOnError) { | |||
res.stop(); | |||
@@ -764,7 +771,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @since Ant 1.6 | |||
* @param permissions the permissions to use. | |||
*/ | |||
public void setPermissions(Permissions permissions) { | |||
@Override | |||
public void setPermissions(final Permissions permissions) { | |||
perm = permissions; | |||
} | |||
@@ -772,7 +780,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* Handle a string destined for standard output. | |||
* @param output the string to output | |||
*/ | |||
public void handleOutput(String output) { | |||
@Override | |||
public void handleOutput(final String output) { | |||
if (!logTestListenerEvents && output.startsWith(JUnitTask.TESTLISTENER_PREFIX)) { | |||
// ignore | |||
} else if (systemOut != null) { | |||
@@ -791,36 +800,40 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* | |||
* @since Ant 1.6 | |||
*/ | |||
public int handleInput(byte[] buffer, int offset, int length) | |||
@Override | |||
public int handleInput(final byte[] buffer, final int offset, final int length) | |||
throws IOException { | |||
return -1; | |||
} | |||
/** {@inheritDoc}. */ | |||
public void handleErrorOutput(String output) { | |||
@Override | |||
public void handleErrorOutput(final String output) { | |||
if (systemError != null) { | |||
systemError.print(output); | |||
} | |||
} | |||
/** {@inheritDoc}. */ | |||
public void handleFlush(String output) { | |||
@Override | |||
public void handleFlush(final String output) { | |||
if (systemOut != null) { | |||
systemOut.print(output); | |||
} | |||
} | |||
/** {@inheritDoc}. */ | |||
public void handleErrorFlush(String output) { | |||
@Override | |||
public void handleErrorFlush(final String output) { | |||
if (systemError != null) { | |||
systemError.print(output); | |||
} | |||
} | |||
private void sendOutAndErr(String out, String err) { | |||
private void sendOutAndErr(final String out, final String err) { | |||
final int size = formatters.size(); | |||
for (int i = 0; i < size; i++) { | |||
JUnitResultFormatter formatter = | |||
final JUnitResultFormatter formatter = | |||
((JUnitResultFormatter) formatters.elementAt(i)); | |||
formatter.setSystemOutput(out); | |||
@@ -848,12 +861,13 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* Add a formatter. | |||
* @param f the formatter to add. | |||
*/ | |||
public void addFormatter(JUnitResultFormatter f) { | |||
public void addFormatter(final JUnitResultFormatter f) { | |||
formatters.addElement(f); | |||
} | |||
/** {@inheritDoc}. */ | |||
public void addFormatter(JUnitTaskMirror.JUnitResultFormatterMirror f) { | |||
@Override | |||
public void addFormatter(final JUnitTaskMirror.JUnitResultFormatterMirror f) { | |||
formatters.addElement(f); | |||
} | |||
@@ -890,12 +904,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param args the command line arguments. | |||
* @throws IOException on error. | |||
*/ | |||
public static void main(String[] args) throws IOException { | |||
public static void main(final String[] args) throws IOException { | |||
String[] methods = null; | |||
boolean haltError = false; | |||
boolean haltFail = false; | |||
boolean stackfilter = true; | |||
Properties props = new Properties(); | |||
final Properties props = new Properties(); | |||
boolean showOut = false; | |||
boolean outputToFormat = true; | |||
boolean logFailedTests = true; | |||
@@ -916,9 +930,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
for (int i = 1; i < args.length; i++) { | |||
if (args[i].startsWith(Constants.METHOD_NAMES)) { | |||
try { | |||
String methodsList = args[i].substring(Constants.METHOD_NAMES.length()); | |||
final String methodsList = args[i].substring(Constants.METHOD_NAMES.length()); | |||
methods = JUnitTest.parseTestMethodNamesList(methodsList); | |||
} catch (IllegalArgumentException ex) { | |||
} catch (final IllegalArgumentException ex) { | |||
System.err.println("Invalid specification of test method names: " + args[i]); | |||
System.exit(ERRORS); | |||
} | |||
@@ -934,12 +948,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} else if (args[i].startsWith(Constants.FORMATTER)) { | |||
try { | |||
createAndStoreFormatter(args[i].substring(Constants.FORMATTER.length())); | |||
} catch (BuildException be) { | |||
} catch (final BuildException be) { | |||
System.err.println(be.getMessage()); | |||
System.exit(ERRORS); | |||
} | |||
} else if (args[i].startsWith(Constants.PROPSFILE)) { | |||
FileInputStream in = new FileInputStream(args[i] | |||
final FileInputStream in = new FileInputStream(args[i] | |||
.substring(Constants.PROPSFILE.length())); | |||
props.load(in); | |||
in.close(); | |||
@@ -958,21 +972,21 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
skipNonTests = Project.toBoolean( | |||
args[i].substring(Constants.SKIP_NON_TESTS.length())); | |||
} else if (args[i].startsWith(Constants.THREADID)) { | |||
antThreadID = Integer.parseInt( args[i].substring(Constants.THREADID.length()) ); | |||
antThreadID = Integer.parseInt(args[i].substring(Constants.THREADID.length())); | |||
} | |||
} | |||
// Add/overlay system properties on the properties from the Ant project | |||
Hashtable p = System.getProperties(); | |||
for (Enumeration e = p.keys(); e.hasMoreElements();) { | |||
Object key = e.nextElement(); | |||
final Hashtable p = System.getProperties(); | |||
for (final Enumeration e = p.keys(); e.hasMoreElements();) { | |||
final Object key = e.nextElement(); | |||
props.put(key, p.get(key)); | |||
} | |||
int returnCode = SUCCESS; | |||
if (multipleTests) { | |||
try { | |||
java.io.BufferedReader reader = | |||
final java.io.BufferedReader reader = | |||
new java.io.BufferedReader(new java.io.FileReader(args[0])); | |||
String testCaseName; | |||
String[] testMethodNames; | |||
@@ -981,9 +995,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
boolean failureOccurred = false; | |||
String line = null; | |||
while ((line = reader.readLine()) != null) { | |||
StringTokenizer st = new StringTokenizer(line, ","); | |||
String testListSpec = st.nextToken(); | |||
int colonIndex = testListSpec.indexOf(':'); | |||
final StringTokenizer st = new StringTokenizer(line, ","); | |||
final String testListSpec = st.nextToken(); | |||
final int colonIndex = testListSpec.indexOf(':'); | |||
if (colonIndex == -1) { | |||
testCaseName = testListSpec; | |||
testMethodNames = null; | |||
@@ -994,7 +1008,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
.substring(colonIndex + 1) | |||
.replace('+', ',')); | |||
} | |||
JUnitTest t = new JUnitTest(testCaseName); | |||
final JUnitTest t = new JUnitTest(testCaseName); | |||
t.setTodir(new File(st.nextToken())); | |||
t.setOutfile(st.nextToken()); | |||
t.setProperties(props); | |||
@@ -1021,11 +1035,11 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} | |||
} | |||
} | |||
} catch (IOException e) { | |||
} catch (final IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} else { | |||
JUnitTest t = new JUnitTest(args[0]); | |||
final JUnitTest t = new JUnitTest(args[0]); | |||
t.setThread(antThreadID); | |||
t.setProperties(props); | |||
t.setSkipNonTests(skipNonTests); | |||
@@ -1040,43 +1054,52 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
private static Vector fromCmdLine = new Vector(); | |||
private static void transferFormatters(JUnitTestRunner runner, | |||
JUnitTest test) { | |||
private static void transferFormatters(final JUnitTestRunner runner, | |||
final JUnitTest test) { | |||
runner.addFormatter(new JUnitResultFormatter() { | |||
public void startTestSuite(JUnitTest suite) throws BuildException { | |||
@Override | |||
public void startTestSuite(final JUnitTest suite) throws BuildException { | |||
} | |||
public void endTestSuite(JUnitTest suite) throws BuildException { | |||
@Override | |||
public void endTestSuite(final JUnitTest suite) throws BuildException { | |||
} | |||
public void setOutput(OutputStream out) { | |||
@Override | |||
public void setOutput(final OutputStream out) { | |||
} | |||
public void setSystemOutput(String out) { | |||
@Override | |||
public void setSystemOutput(final String out) { | |||
} | |||
public void setSystemError(String err) { | |||
@Override | |||
public void setSystemError(final String err) { | |||
} | |||
public void addError(Test arg0, Throwable arg1) { | |||
@Override | |||
public void addError(final Test arg0, final Throwable arg1) { | |||
} | |||
public void addFailure(Test arg0, AssertionFailedError arg1) { | |||
@Override | |||
public void addFailure(final Test arg0, final AssertionFailedError arg1) { | |||
} | |||
public void endTest(Test arg0) { | |||
@Override | |||
public void endTest(final Test arg0) { | |||
} | |||
public void startTest(Test arg0) { | |||
@Override | |||
public void startTest(final Test arg0) { | |||
registerTestCase(JUnitVersionHelper.getTestCaseName(arg0)); | |||
} | |||
}); | |||
final int size = fromCmdLine.size(); | |||
for (int i = 0; i < size; i++) { | |||
FormatterElement fe = (FormatterElement) fromCmdLine.elementAt(i); | |||
final FormatterElement fe = (FormatterElement) fromCmdLine.elementAt(i); | |||
if (multipleTests && fe.getUseFile()) { | |||
File destFile = | |||
final File destFile = | |||
new File(test.getTodir(), | |||
test.getOutfile() + fe.getExtension()); | |||
fe.setOutfile(destFile); | |||
@@ -1088,10 +1111,10 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
/** | |||
* Line format is: formatter=<classname>(,<pathname>)? | |||
*/ | |||
private static void createAndStoreFormatter(String line) | |||
private static void createAndStoreFormatter(final String line) | |||
throws BuildException { | |||
FormatterElement fe = new FormatterElement(); | |||
int pos = line.indexOf(','); | |||
final FormatterElement fe = new FormatterElement(); | |||
final int pos = line.indexOf(','); | |||
if (pos == -1) { | |||
fe.setClassname(line); | |||
fe.setUseFile(false); | |||
@@ -1101,7 +1124,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
if (!multipleTests) { | |||
fe.setOutfile(new File(line.substring(pos + 1))); | |||
} else { | |||
int fName = line.indexOf(IGNORED_FILE_NAME); | |||
final int fName = line.indexOf(IGNORED_FILE_NAME); | |||
if (fName > -1) { | |||
fe.setExtension(line | |||
.substring(fName | |||
@@ -1118,8 +1141,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param t the exception to filter. | |||
* @return the filtered stack trace. | |||
*/ | |||
public static String getFilteredTrace(Throwable t) { | |||
String trace = StringUtils.getStackTrace(t); | |||
public static String getFilteredTrace(final Throwable t) { | |||
final String trace = StringUtils.getStackTrace(t); | |||
return JUnitTestRunner.filterStack(trace); | |||
} | |||
@@ -1128,14 +1151,14 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* @param stack the stack trace to filter. | |||
* @return the filtered stack. | |||
*/ | |||
public static String filterStack(String stack) { | |||
public static String filterStack(final String stack) { | |||
if (!filtertrace) { | |||
return stack; | |||
} | |||
StringWriter sw = new StringWriter(); | |||
BufferedWriter pw = new BufferedWriter(sw); | |||
StringReader sr = new StringReader(stack); | |||
BufferedReader br = new BufferedReader(sr); | |||
final StringWriter sw = new StringWriter(); | |||
final BufferedWriter pw = new BufferedWriter(sw); | |||
final StringReader sr = new StringReader(stack); | |||
final BufferedReader br = new BufferedReader(sr); | |||
String line; | |||
try { | |||
@@ -1147,7 +1170,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} | |||
firstLine = false; | |||
} | |||
} catch (Exception e) { | |||
} catch (final Exception e) { | |||
return stack; // return the stack unfiltered | |||
} finally { | |||
FileUtils.close(pw); | |||
@@ -1155,7 +1178,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
return sw.toString(); | |||
} | |||
private static boolean filterLine(String line) { | |||
private static boolean filterLine(final String line) { | |||
for (int i = 0; i < DEFAULT_TRACE_FILTERS.length; i++) { | |||
if (line.indexOf(DEFAULT_TRACE_FILTERS[i]) != -1) { | |||
return true; | |||
@@ -1167,11 +1190,11 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
/** | |||
* @since Ant 1.6.2 | |||
*/ | |||
private static int launch(JUnitTest t, String[] methods, boolean haltError, | |||
boolean stackfilter, boolean haltFail, | |||
boolean showOut, boolean outputToFormat, | |||
boolean logTestListenerEvents) { | |||
JUnitTestRunner runner = | |||
private static int launch(final JUnitTest t, final String[] methods, final boolean haltError, | |||
final boolean stackfilter, final boolean haltFail, | |||
final boolean showOut, final boolean outputToFormat, | |||
final boolean logTestListenerEvents) { | |||
final JUnitTestRunner runner = | |||
new JUnitTestRunner(t, methods, haltError, stackfilter, haltFail, showOut, | |||
logTestListenerEvents, null); | |||
runner.forked = true; | |||
@@ -1199,7 +1222,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} | |||
} | |||
private static void registerTestCase(String testCase) { | |||
private static void registerTestCase(final String testCase) { | |||
if (crashFile != null) { | |||
try { | |||
FileWriter out = null; | |||
@@ -1210,7 +1233,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} finally { | |||
FileUtils.close(out); | |||
} | |||
} catch (IOException e) { | |||
} catch (final IOException e) { | |||
// ignored. | |||
} | |||
} | |||
@@ -1224,7 +1247,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
*/ | |||
private TestListenerWrapper wrapListener(final TestListener testListener) { | |||
return new TestListenerWrapper(testListener) { | |||
public void addError(Test test, Throwable t) { | |||
@Override | |||
public void addError(final Test test, final Throwable t) { | |||
if (junit4 && t instanceof AssertionFailedError) { | |||
// JUnit 4 does not distinguish between errors and failures | |||
// even in the JUnit 3 adapter. | |||
@@ -1235,8 +1259,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
// JUnit 4-specific test GUIs will show just "failures". | |||
// But Ant's output shows "failures" vs. "errors". | |||
// We would prefer to show "failure" for things that logically are. | |||
String msg = t.getMessage(); | |||
AssertionFailedError failure = msg != null | |||
final String msg = t.getMessage(); | |||
final AssertionFailedError failure = msg != null | |||
? new AssertionFailedError(msg) : new AssertionFailedError(); | |||
failure.setStackTrace(t.getStackTrace()); | |||
testListener.addFailure(test, failure); | |||
@@ -1244,20 +1268,23 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
testListener.addError(test, t); | |||
} | |||
} | |||
public void addFailure(Test test, AssertionFailedError t) { | |||
@Override | |||
public void addFailure(final Test test, final AssertionFailedError t) { | |||
testListener.addFailure(test, t); | |||
} | |||
public void addFailure(Test test, Throwable t) { // pre-3.4 | |||
public void addFailure(final Test test, final Throwable t) { // pre-3.4 | |||
if (t instanceof AssertionFailedError) { | |||
testListener.addFailure(test, (AssertionFailedError) t); | |||
} else { | |||
testListener.addError(test, t); | |||
} | |||
} | |||
public void endTest(Test test) { | |||
@Override | |||
public void endTest(final Test test) { | |||
testListener.endTest(test); | |||
} | |||
public void startTest(Test test) { | |||
@Override | |||
public void startTest(final Test test) { | |||
testListener.startTest(test); | |||
} | |||
}; | |||
@@ -1268,7 +1295,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
* since the adapter claims that all failures are errors. | |||
* @since Ant 1.7 | |||
*/ | |||
private int[] findJUnit4FailureErrorCount(TestResult result) { | |||
private int[] findJUnit4FailureErrorCount(final TestResult result) { | |||
int failures = 0; | |||
int errors = 0; | |||
Enumeration e = result.failures(); | |||
@@ -1278,7 +1305,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} | |||
e = result.errors(); | |||
while (e.hasMoreElements()) { | |||
Throwable t = ((TestFailure) e.nextElement()).thrownException(); | |||
final Throwable t = ((TestFailure) e.nextElement()).thrownException(); | |||
if (t instanceof AssertionFailedError | |||
|| t instanceof AssertionError) { | |||
failures++; | |||
@@ -43,7 +43,8 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { | |||
* Records the suite's name to later determine the class to invoke | |||
* tearDown on. | |||
*/ | |||
public void startTestSuite(final JUnitTest suite) { | |||
@Override | |||
public void startTestSuite(final JUnitTest suite) { | |||
suiteName = suite.getName(); | |||
if (suiteName != null && | |||
suiteName.endsWith(JUnitTask.NAME_OF_DUMMY_TEST)) { | |||
@@ -57,7 +58,8 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { | |||
* test we get when a Batch fails and the error is an actual | |||
* error generated by Ant. | |||
*/ | |||
public void addError(final Test fakeTest, final Throwable t) { | |||
@Override | |||
public void addError(final Test fakeTest, final Throwable t) { | |||
if (suiteName != null | |||
&& fakeTest instanceof JUnitTaskMirrorImpl.VmExitErrorTest) { | |||
tearDown(); | |||
@@ -67,19 +69,26 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { | |||
// no need to implement the rest | |||
public void addFailure(Test test, Throwable t) {} | |||
public void addFailure(Test test, AssertionFailedError t) {} | |||
@Override | |||
public void addFailure(Test test, AssertionFailedError t) {} | |||
public void startTest(Test test) {} | |||
@Override | |||
public void startTest(Test test) {} | |||
public void endTest(Test test) {} | |||
@Override | |||
public void endTest(Test test) {} | |||
public void endTestSuite(JUnitTest suite) {} | |||
public void setOutput(OutputStream out) {} | |||
@Override | |||
public void endTestSuite(JUnitTest suite) {} | |||
public void setSystemOutput(String out) {} | |||
@Override | |||
public void setOutput(OutputStream out) {} | |||
public void setSystemError(String err) {} | |||
@Override | |||
public void setSystemOutput(String out) {} | |||
@Override | |||
public void setSystemError(String err) {} | |||
private void tearDown() { | |||
try { | |||
@@ -76,7 +76,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
private Element rootElement; | |||
/** | |||
* Element for the current test. | |||
* | |||
* | |||
* The keying of this map is a bit of a hack: tests are keyed by caseName(className) since | |||
* the Test we get for Test-start isn't the same as the Test we get during test-assumption-fail, | |||
* so we can't easily match Test objects without manually iterating over all keys and checking | |||
@@ -109,17 +109,20 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
} | |||
/** {@inheritDoc}. */ | |||
public void setOutput(OutputStream out) { | |||
@Override | |||
public void setOutput(OutputStream out) { | |||
this.out = out; | |||
} | |||
/** {@inheritDoc}. */ | |||
public void setSystemOutput(String out) { | |||
@Override | |||
public void setSystemOutput(String out) { | |||
formatOutput(SYSTEM_OUT, out); | |||
} | |||
/** {@inheritDoc}. */ | |||
public void setSystemError(String out) { | |||
@Override | |||
public void setSystemError(String out) { | |||
formatOutput(SYSTEM_ERR, out); | |||
} | |||
@@ -127,7 +130,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
* The whole testsuite started. | |||
* @param suite the testsuite. | |||
*/ | |||
public void startTestSuite(JUnitTest suite) { | |||
@Override | |||
public void startTestSuite(JUnitTest suite) { | |||
doc = getDocumentBuilder().newDocument(); | |||
rootElement = doc.createElement(TESTSUITE); | |||
String n = suite.getName(); | |||
@@ -178,7 +182,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
* @param suite the testsuite. | |||
* @throws BuildException on error. | |||
*/ | |||
public void endTestSuite(JUnitTest suite) throws BuildException { | |||
@Override | |||
public void endTestSuite(JUnitTest suite) throws BuildException { | |||
rootElement.setAttribute(ATTR_TESTS, "" + suite.runCount()); | |||
rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); | |||
rootElement.setAttribute(ATTR_ERRORS, "" + suite.errorCount()); | |||
@@ -214,7 +219,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
* <p>A new Test is started. | |||
* @param t the test. | |||
*/ | |||
public void startTest(Test t) { | |||
@Override | |||
public void startTest(Test t) { | |||
testStarts.put(createDescription(t), System.currentTimeMillis()); | |||
} | |||
@@ -228,7 +234,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
* <p>A Test is finished. | |||
* @param test the test. | |||
*/ | |||
public void endTest(Test test) { | |||
@Override | |||
public void endTest(Test test) { | |||
String testDescription = createDescription(test); | |||
// Fix for bug #5637 - if a junit.extensions.TestSetup is | |||
@@ -276,7 +283,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
* @param test the test. | |||
* @param t the assertion. | |||
*/ | |||
public void addFailure(Test test, AssertionFailedError t) { | |||
@Override | |||
public void addFailure(Test test, AssertionFailedError t) { | |||
addFailure(test, (Throwable) t); | |||
} | |||
@@ -287,7 +295,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
* @param test the test. | |||
* @param t the error. | |||
*/ | |||
public void addError(Test test, Throwable t) { | |||
@Override | |||
public void addError(Test test, Throwable t) { | |||
formatError(ERROR, test, t); | |||
} | |||
@@ -324,7 +333,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
nested.appendChild(doc.createCDATASection(output)); | |||
} | |||
public void testIgnored(Test test) { | |||
@Override | |||
public void testIgnored(Test test) { | |||
formatSkip(test, JUnitVersionHelper.getIgnoreMessage(test)); | |||
if (test != null) { | |||
ignoredTests.put(createDescription(test), test); | |||
@@ -354,7 +364,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
} | |||
public void testAssumptionFailure(Test test, Throwable failure) { | |||
@Override | |||
public void testAssumptionFailure(Test test, Throwable failure) { | |||
formatSkip(test, failure.getMessage()); | |||
skippedTests.put(createDescription(test), test); | |||
@@ -20,6 +20,5 @@ package org.apache.tools.ant.taskdefs.optional.net; | |||
import org.apache.tools.ant.BuildException; | |||
public interface FTPTaskMirror { | |||
public void doFTP() throws BuildException; | |||
void doFTP() throws BuildException; | |||
} |
@@ -71,7 +71,8 @@ public class SplashTask extends Task { | |||
* @deprecated since 1.5.x. | |||
* Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | |||
*/ | |||
public void setUseproxy(boolean useProxy) { | |||
@Deprecated | |||
public void setUseproxy(boolean useProxy) { | |||
this.useProxy = useProxy; | |||
} | |||
@@ -81,7 +82,8 @@ public class SplashTask extends Task { | |||
* @deprecated since 1.5.x. | |||
* Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | |||
*/ | |||
public void setProxy(String proxy) { | |||
@Deprecated | |||
public void setProxy(String proxy) { | |||
this.proxy = proxy; | |||
} | |||
@@ -91,7 +93,8 @@ public class SplashTask extends Task { | |||
* @deprecated since 1.5.x. | |||
* Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | |||
*/ | |||
public void setPort(String port) { | |||
@Deprecated | |||
public void setPort(String port) { | |||
this.port = port; | |||
} | |||
@@ -101,7 +104,8 @@ public class SplashTask extends Task { | |||
* @deprecated since 1.5.x. | |||
* Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | |||
*/ | |||
public void setUser(String user) { | |||
@Deprecated | |||
public void setUser(String user) { | |||
this.user = user; | |||
} | |||
@@ -111,7 +115,8 @@ public class SplashTask extends Task { | |||
* @deprecated since 1.5.x. | |||
* Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | |||
*/ | |||
public void setPassword(String password) { | |||
@Deprecated | |||
public void setPassword(String password) { | |||
this.password = password; | |||
} | |||
@@ -140,7 +145,7 @@ public class SplashTask extends Task { | |||
/** | |||
* Sets the display text presented in the splash window. | |||
* optional; defaults to "Building ..." | |||
* optional; defaults to "Building ..." | |||
* @param displayText the display text presented the splash window | |||
* @since Ant 1.8.0 | |||
*/ | |||
@@ -152,7 +157,8 @@ public class SplashTask extends Task { | |||
* Execute the task. | |||
* @throws BuildException on error | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
if (splash != null) { | |||
splash.setVisible(false); | |||
getProject().removeBuildListener(splash); | |||
@@ -119,13 +119,12 @@ public class Directory { | |||
* @return the child directory, or null if not found | |||
*/ | |||
public Directory getChild(File dir) { | |||
for (Iterator i = childDirectories.iterator(); i.hasNext(); ) { | |||
for (Iterator i = childDirectories.iterator(); i.hasNext();) { | |||
Directory current = (Directory) i.next(); | |||
if (current.getDirectory().equals(dir)) { | |||
return current; | |||
} | |||
} | |||
return null; | |||
} | |||
@@ -135,7 +134,8 @@ public class Directory { | |||
* @param obj the object to compare to | |||
* @return true if this object has an equal directory field as the other object | |||
*/ | |||
public boolean equals(Object obj) { | |||
@Override | |||
public boolean equals(Object obj) { | |||
if (obj == this) { | |||
return true; | |||
} | |||
@@ -153,7 +153,8 @@ public class Directory { | |||
* The hashcode method. | |||
* @return the hash code of the directory field | |||
*/ | |||
public int hashCode() { | |||
@Override | |||
public int hashCode() { | |||
return directory.hashCode(); | |||
} | |||
@@ -100,7 +100,7 @@ public class SSHExec extends SSHBase { | |||
* | |||
* @param command The new command value | |||
*/ | |||
public void setCommand(String command) { | |||
public void setCommand(final String command) { | |||
this.command = command; | |||
} | |||
@@ -109,7 +109,7 @@ public class SSHExec extends SSHBase { | |||
* @param f the value to use. | |||
* @since Ant 1.7.1 | |||
*/ | |||
public void setCommandResource(String f) { | |||
public void setCommandResource(final String f) { | |||
this.commandResource = new FileResource(new File(f)); | |||
} | |||
@@ -120,7 +120,7 @@ public class SSHExec extends SSHBase { | |||
* | |||
* @param timeout The new timeout value in seconds | |||
*/ | |||
public void setTimeout(long timeout) { | |||
public void setTimeout(final long timeout) { | |||
maxwait = timeout; | |||
} | |||
@@ -129,7 +129,7 @@ public class SSHExec extends SSHBase { | |||
* | |||
* @param output The file to write to. | |||
*/ | |||
public void setOutput(File output) { | |||
public void setOutput(final File output) { | |||
outputFile = output; | |||
} | |||
@@ -139,7 +139,7 @@ public class SSHExec extends SSHBase { | |||
* @param output The file to write to. | |||
* @since Apache Ant 1.9.4 | |||
*/ | |||
public void setErrorOutput(File output) { | |||
public void setErrorOutput(final File output) { | |||
errorFile = output; | |||
} | |||
@@ -150,7 +150,7 @@ public class SSHExec extends SSHBase { | |||
* | |||
* @since Ant 1.8.0 | |||
*/ | |||
public void setInput(File input) { | |||
public void setInput(final File input) { | |||
inputFile = input; | |||
} | |||
@@ -162,7 +162,7 @@ public class SSHExec extends SSHBase { | |||
* | |||
* @since Ant 1.8.0 | |||
*/ | |||
public void setInputProperty(String inputProperty) { | |||
public void setInputProperty(final String inputProperty) { | |||
this.inputProperty = inputProperty; | |||
} | |||
@@ -173,7 +173,7 @@ public class SSHExec extends SSHBase { | |||
* | |||
* @since Ant 1.8.3 | |||
*/ | |||
public void setInputString(String inputString) { | |||
public void setInputString(final String inputString) { | |||
this.inputString = inputString; | |||
} | |||
@@ -184,7 +184,7 @@ public class SSHExec extends SSHBase { | |||
* | |||
* @param append True to append to an existing file, false to overwrite. | |||
*/ | |||
public void setAppend(boolean append) { | |||
public void setAppend(final boolean append) { | |||
this.append = append; | |||
} | |||
@@ -196,7 +196,7 @@ public class SSHExec extends SSHBase { | |||
* @param append True to append to an existing file, false to overwrite. | |||
* @since Apache Ant 1.9.4 | |||
*/ | |||
public void setErrAppend(boolean appenderr) { | |||
public void setErrAppend(final boolean appenderr) { | |||
this.appenderr = appenderr; | |||
} | |||
@@ -206,7 +206,7 @@ public class SSHExec extends SSHBase { | |||
* @param property The name of the property in which the command output | |||
* will be stored. | |||
*/ | |||
public void setOutputproperty(String property) { | |||
public void setOutputproperty(final String property) { | |||
outputProperty = property; | |||
} | |||
@@ -217,7 +217,7 @@ public class SSHExec extends SSHBase { | |||
* will be stored. | |||
* @since Apache Ant 1.9.4 | |||
*/ | |||
public void setErrorproperty (String property) { | |||
public void setErrorproperty (final String property) { | |||
errorProperty = property; | |||
} | |||
@@ -228,7 +228,7 @@ public class SSHExec extends SSHBase { | |||
* will be stored. | |||
* @since Apache Ant 1.9.4 | |||
*/ | |||
public void setResultproperty(String property) { | |||
public void setResultproperty(final String property) { | |||
resultProperty = property; | |||
} | |||
@@ -236,17 +236,17 @@ public class SSHExec extends SSHBase { | |||
* Whether a pseudo-tty should be allocated. | |||
* @since Apache Ant 1.8.3 | |||
*/ | |||
public void setUsePty(boolean b) { | |||
public void setUsePty(final boolean b) { | |||
usePty = b; | |||
} | |||
/** | |||
* If set, input will be taken from System.in | |||
* | |||
* | |||
* @param useSystemIn True to use System.in as InputStream, false otherwise | |||
* @since Apache Ant 1.9.4 | |||
*/ | |||
public void setUseSystemIn(boolean useSystemIn) { | |||
public void setUseSystemIn(final boolean useSystemIn) { | |||
this.useSystemIn = useSystemIn; | |||
} | |||
@@ -255,7 +255,7 @@ public class SSHExec extends SSHBase { | |||
* If suppressSystemOut is <code>false</code>, normal behavior | |||
* @since Ant 1.9.0 | |||
*/ | |||
public void setSuppressSystemOut(boolean suppressSystemOut) { | |||
public void setSuppressSystemOut(final boolean suppressSystemOut) { | |||
this.suppressSystemOut = suppressSystemOut; | |||
} | |||
@@ -264,7 +264,7 @@ public class SSHExec extends SSHBase { | |||
* If suppressSystemErr is <code>false</code>, normal behavior | |||
* @since Ant 1.9.4 | |||
*/ | |||
public void setSuppressSystemErr(boolean suppressSystemErr) { | |||
public void setSuppressSystemErr(final boolean suppressSystemErr) { | |||
this.suppressSystemErr = suppressSystemErr; | |||
} | |||
@@ -273,7 +273,8 @@ public class SSHExec extends SSHBase { | |||
* | |||
* @exception BuildException Most likely a network error or bad parameter. | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
if (getHost() == null) { | |||
throw new BuildException("Host is required."); | |||
@@ -289,7 +290,7 @@ public class SSHExec extends SSHBase { | |||
throw new BuildException("Command or commandResource is required."); | |||
} | |||
int numberOfInputs = (inputFile != null ? 1 : 0) | |||
final int numberOfInputs = (inputFile != null ? 1 : 0) | |||
+ (inputProperty != null ? 1 : 0) | |||
+ (inputString != null ? 1 : 0); | |||
if (numberOfInputs > 1) { | |||
@@ -304,7 +305,7 @@ public class SSHExec extends SSHBase { | |||
} | |||
Session session = null; | |||
StringBuffer output = new StringBuffer(); | |||
final StringBuffer output = new StringBuffer(); | |||
try { | |||
session = openSession(); | |||
/* called once */ | |||
@@ -313,7 +314,7 @@ public class SSHExec extends SSHBase { | |||
executeCommand(session, command, output); | |||
} else { // read command resource and execute for each command | |||
try { | |||
BufferedReader br = new BufferedReader( | |||
final BufferedReader br = new BufferedReader( | |||
new InputStreamReader(commandResource.getInputStream())); | |||
String cmd; | |||
while ((cmd = br.readLine()) != null) { | |||
@@ -323,7 +324,7 @@ public class SSHExec extends SSHBase { | |||
output.append("\n"); | |||
} | |||
FileUtils.close(br); | |||
} catch (IOException e) { | |||
} catch (final IOException e) { | |||
if (getFailonerror()) { | |||
throw new BuildException(e); | |||
} else { | |||
@@ -332,7 +333,7 @@ public class SSHExec extends SSHBase { | |||
} | |||
} | |||
} | |||
} catch (JSchException e) { | |||
} catch (final JSchException e) { | |||
if (getFailonerror()) { | |||
throw new BuildException(e); | |||
} else { | |||
@@ -348,18 +349,18 @@ public class SSHExec extends SSHBase { | |||
} | |||
} | |||
private void executeCommand(Session session, String cmd, StringBuffer sb) | |||
private void executeCommand(final Session session, final String cmd, final StringBuffer sb) | |||
throws BuildException { | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
ByteArrayOutputStream errout = new ByteArrayOutputStream(); | |||
OutputStream teeErr = suppressSystemErr ? errout : new TeeOutputStream(errout, KeepAliveOutputStream.wrapSystemErr()); | |||
OutputStream tee = suppressSystemOut ? out : new TeeOutputStream(out, KeepAliveOutputStream.wrapSystemOut()); | |||
final ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
final ByteArrayOutputStream errout = new ByteArrayOutputStream(); | |||
final OutputStream teeErr = suppressSystemErr ? errout : new TeeOutputStream(errout, KeepAliveOutputStream.wrapSystemErr()); | |||
final OutputStream tee = suppressSystemOut ? out : new TeeOutputStream(out, KeepAliveOutputStream.wrapSystemOut()); | |||
InputStream istream = null ; | |||
InputStream istream = null; | |||
if (inputFile != null) { | |||
try { | |||
istream = new FileInputStream(inputFile) ; | |||
} catch (IOException e) { | |||
istream = new FileInputStream(inputFile); | |||
} catch (final IOException e) { | |||
// because we checked the existence before, this one | |||
// shouldn't happen What if the file exists, but there | |||
// are no read permissions? | |||
@@ -368,9 +369,9 @@ public class SSHExec extends SSHBase { | |||
} | |||
} | |||
if (inputProperty != null) { | |||
String inputData = getProject().getProperty(inputProperty) ; | |||
final String inputData = getProject().getProperty(inputProperty); | |||
if (inputData != null) { | |||
istream = new ByteArrayInputStream(inputData.getBytes()) ; | |||
istream = new ByteArrayInputStream(inputData.getBytes()); | |||
} | |||
} | |||
if (inputString != null) { | |||
@@ -398,14 +399,15 @@ public class SSHExec extends SSHBase { | |||
// wait for it to finish | |||
thread = | |||
new Thread() { | |||
public void run() { | |||
@Override | |||
public void run() { | |||
while (!channel.isClosed()) { | |||
if (thread == null) { | |||
return; | |||
} | |||
try { | |||
sleep(RETRY_INTERVAL); | |||
} catch (Exception e) { | |||
} catch (final Exception e) { | |||
// ignored | |||
} | |||
} | |||
@@ -438,13 +440,13 @@ public class SSHExec extends SSHBase { | |||
} | |||
// this is the wrong test if the remote OS is OpenVMS, | |||
// but there doesn't seem to be a way to detect it. | |||
int ec = channel.getExitStatus(); | |||
final int ec = channel.getExitStatus(); | |||
// set resultproperty | |||
if (resultProperty != null) { | |||
getProject().setNewProperty(resultProperty, Integer.toString(ec)); | |||
} | |||
if (ec != 0) { | |||
String msg = "Remote command failed with exit status " + ec; | |||
final String msg = "Remote command failed with exit status " + ec; | |||
if (getFailonerror()) { | |||
throw new BuildException(msg); | |||
} else { | |||
@@ -452,9 +454,9 @@ public class SSHExec extends SSHBase { | |||
} | |||
} | |||
} | |||
} catch (BuildException e) { | |||
} catch (final BuildException e) { | |||
throw e; | |||
} catch (JSchException e) { | |||
} catch (final JSchException e) { | |||
if (e.getMessage().indexOf("session is down") >= 0) { | |||
if (getFailonerror()) { | |||
throw new BuildException(TIMEOUT_MESSAGE, e); | |||
@@ -469,7 +471,7 @@ public class SSHExec extends SSHBase { | |||
Project.MSG_ERR); | |||
} | |||
} | |||
} catch (Exception e) { | |||
} catch (final Exception e) { | |||
if (getFailonerror()) { | |||
throw new BuildException(e); | |||
} else { | |||
@@ -490,13 +492,13 @@ public class SSHExec extends SSHBase { | |||
* @param append if true, append to existing file, else overwrite | |||
* @exception Exception most likely an IOException | |||
*/ | |||
private void writeToFile(String from, boolean append, File to) | |||
private void writeToFile(final String from, final boolean append, final File to) | |||
throws IOException { | |||
FileWriter out = null; | |||
try { | |||
out = new FileWriter(to.getAbsolutePath(), append); | |||
StringReader in = new StringReader(from); | |||
char[] buffer = new char[BUFFER_SIZE]; | |||
final StringReader in = new StringReader(from); | |||
final char[] buffer = new char[BUFFER_SIZE]; | |||
int bytesRead; | |||
while (true) { | |||
bytesRead = in.read(buffer); | |||
@@ -130,7 +130,8 @@ public class SSHSession extends SSHBase { | |||
* @exception BuildException if one of the nested tasks fails, or | |||
* network error or bad parameter. | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
if (getHost() == null) { | |||
throw new BuildException("Host is required."); | |||
} | |||
@@ -277,13 +278,13 @@ public class SSHSession extends SSHBase { | |||
return lport; | |||
} | |||
public String getLHost() { | |||
if (lhost == null) { | |||
if (lhost == null) { | |||
throw new BuildException("lhost is required for RemoteTunnel."); | |||
} | |||
return lhost; | |||
} | |||
public int getRPort() { | |||
if (rport == 0) { | |||
if (rport == 0) { | |||
throw new BuildException("rport is required for RemoteTunnel."); | |||
} | |||
return rport; | |||
@@ -315,7 +316,8 @@ public class SSHSession extends SSHBase { | |||
* | |||
* @param task an unknown element. | |||
*/ | |||
public void addTask(Task task) { | |||
@Override | |||
public void addTask(Task task) { | |||
nested.add(task); | |||
} | |||
@@ -123,7 +123,7 @@ public class Scp extends SSHBase { | |||
*/ | |||
public void setPreservelastmodified(boolean yesOrNo) { | |||
this.preserveLastModified = yesOrNo; | |||
} | |||
} | |||
/** | |||
* Similiar to {@link #setTodir setTodir} but explicitly states | |||
@@ -145,7 +145,7 @@ public class Scp extends SSHBase { | |||
+ "following: user:password@host:/path" | |||
+ " - the :password part is optional"); | |||
} | |||
} | |||
} | |||
/** | |||
* Changes the file name to the given name while receiving it, | |||
@@ -196,7 +196,8 @@ public class Scp extends SSHBase { | |||
* Initialize this task. | |||
* @throws BuildException on error | |||
*/ | |||
public void init() throws BuildException { | |||
@Override | |||
public void init() throws BuildException { | |||
super.init(); | |||
this.toUri = null; | |||
this.fromUri = null; | |||
@@ -207,7 +208,8 @@ public class Scp extends SSHBase { | |||
* Execute this task. | |||
* @throws BuildException on error | |||
*/ | |||
public void execute() throws BuildException { | |||
@Override | |||
public void execute() throws BuildException { | |||
if (toUri == null) { | |||
throw exactlyOne(TO_ATTRS); | |||
} | |||
@@ -362,7 +364,7 @@ public class Scp extends SSHBase { | |||
// no password, will require keyfile | |||
setUsername(uri.substring(0, indexOfAt)); | |||
} else { | |||
throw new BuildException("no username was given. Can't authenticate."); | |||
throw new BuildException("no username was given. Can't authenticate."); | |||
} | |||
if (getUserInfo().getPassword() == null | |||
@@ -129,7 +129,8 @@ public class Symlink extends DispatchTask { | |||
* Initialize the task. | |||
* @throws BuildException on error. | |||
*/ | |||
public void init() throws BuildException { | |||
@Override | |||
public void init() throws BuildException { | |||
super.init(); | |||
setDefaults(); | |||
} | |||
@@ -138,7 +139,8 @@ public class Symlink extends DispatchTask { | |||
* The standard method for executing any task. | |||
* @throws BuildException on error. | |||
*/ | |||
public synchronized void execute() throws BuildException { | |||
@Override | |||
public synchronized void execute() throws BuildException { | |||
if (executing) { | |||
throw new BuildException( | |||
"Infinite recursion detected in Symlink.execute()"); | |||
@@ -325,7 +327,8 @@ public class Symlink extends DispatchTask { | |||
* | |||
* @param action The action to perform. | |||
*/ | |||
public void setAction(String action) { | |||
@Override | |||
public void setAction(String action) { | |||
super.setAction(action); | |||
} | |||
@@ -383,7 +386,8 @@ public class Symlink extends DispatchTask { | |||
* org.apache.tools.ant.util.SymbolicLinkUtils#deleteSymbolicLink | |||
* instead | |||
*/ | |||
public static void deleteSymlink(String path) | |||
@Deprecated | |||
public static void deleteSymlink(String path) | |||
throws IOException, FileNotFoundException { | |||
SYMLINK_UTILS.deleteSymbolicLink(new File(path), null); | |||
} | |||
@@ -403,7 +407,7 @@ public class Symlink extends DispatchTask { | |||
* an exception.</p> | |||
* | |||
* <p>Since Ant 1.8.0 this method will try to delete the File object if | |||
* it reports it wouldn't exist (as symlinks pointing nowhere usually do). | |||
* it reports it wouldn't exist (as symlinks pointing nowhere usually do). | |||
* Prior version would throw a FileNotFoundException in that case.</p> | |||
* | |||
* @param linkfil A <code>File</code> object of the symlink to delete. | |||
@@ -416,7 +420,8 @@ public class Symlink extends DispatchTask { | |||
* org.apache.tools.ant.util.SymbolicLinkUtils#deleteSymbolicLink | |||
* instead | |||
*/ | |||
public static void deleteSymlink(File linkfil) | |||
@Deprecated | |||
public static void deleteSymlink(File linkfil) | |||
throws IOException { | |||
SYMLINK_UTILS.deleteSymbolicLink(linkfil, null); | |||
} | |||
@@ -374,7 +374,8 @@ public class FilterChain extends DataType | |||
* @param r the reference to which this instance is associated | |||
* @exception BuildException if this instance already has been configured. | |||
*/ | |||
public void setRefid(Reference r) throws BuildException { | |||
@Override | |||
public void setRefid(Reference r) throws BuildException { | |||
if (!filterReaders.isEmpty()) { | |||
throw tooManyAttributes(); | |||
} | |||
@@ -396,7 +397,8 @@ public class FilterChain extends DataType | |||
filterReaders.addElement(filter); | |||
} | |||
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
@Override | |||
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
throws BuildException { | |||
if (isChecked()) { | |||
return; | |||
@@ -404,7 +406,7 @@ public class FilterChain extends DataType | |||
if (isReference()) { | |||
super.dieOnCircularReference(stk, p); | |||
} else { | |||
for (Iterator<Object> i = filterReaders.iterator(); i.hasNext(); ) { | |||
for (Iterator<Object> i = filterReaders.iterator(); i.hasNext();) { | |||
Object o = i.next(); | |||
if (o instanceof DataType) { | |||
pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | |||
@@ -164,7 +164,8 @@ public class FilterSet extends DataType implements Cloneable { | |||
//inherit doc | |||
/** {@inheritDoc}. */ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return VALUES; | |||
} | |||
} | |||
@@ -229,7 +230,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
readingFiles = true; | |||
final int size = filtersFiles.size(); | |||
for (int i = 0; i < size; i++) { | |||
readFiltersFromFile((File) filtersFiles.get(i)); | |||
readFiltersFromFile(filtersFiles.get(i)); | |||
} | |||
filtersFiles.clear(); | |||
readingFiles = false; | |||
@@ -243,7 +244,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
* @return the filterset from the reference. | |||
*/ | |||
protected FilterSet getRef() { | |||
return (FilterSet) getCheckedRef(FilterSet.class, "filterset"); | |||
return getCheckedRef(FilterSet.class, "filterset"); | |||
} | |||
/** | |||
@@ -461,7 +462,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
/** | |||
* Adds the properties provided by the specified PropertySet to this filterset. | |||
* | |||
* | |||
* @param propertySet the propertyset to be added to this propertyset | |||
*/ | |||
public synchronized void addConfiguredPropertySet(PropertySet propertySet) { | |||
@@ -492,9 +493,10 @@ public class FilterSet extends DataType implements Cloneable { | |||
* | |||
* @throws BuildException if the clone cannot be performed. | |||
*/ | |||
public synchronized Object clone() throws BuildException { | |||
@Override | |||
public synchronized Object clone() throws BuildException { | |||
if (isReference()) { | |||
return ((FilterSet) getRef()).clone(); | |||
return getRef().clone(); | |||
} | |||
try { | |||
FilterSet fs = (FilterSet) super.clone(); | |||
@@ -621,7 +623,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
} else if (duplicateToken) { | |||
// should always be the case... | |||
if (passedTokens.size() > 0) { | |||
value = (String) passedTokens.remove(passedTokens.size() - 1); | |||
value = passedTokens.remove(passedTokens.size() - 1); | |||
if (passedTokens.size() == 0) { | |||
value = beginToken + value + endToken; | |||
duplicateToken = false; | |||
@@ -44,12 +44,12 @@ import org.apache.tools.ant.ExitException; | |||
*/ | |||
public class Permissions { | |||
private List<Permission> grantedPermissions = new LinkedList<Permission>(); | |||
private List<Permission> revokedPermissions = new LinkedList<Permission>(); | |||
private final List<Permission> grantedPermissions = new LinkedList<Permission>(); | |||
private final List<Permission> revokedPermissions = new LinkedList<Permission>(); | |||
private java.security.Permissions granted = null; | |||
private SecurityManager origSm = null; | |||
private boolean active = false; | |||
private boolean delegateToOldSM; | |||
private final boolean delegateToOldSM; | |||
// Mandatory constructor for permission object. | |||
private static final Class<?>[] PARAMS = {String.class, String.class}; | |||
@@ -68,7 +68,7 @@ public class Permissions { | |||
* will be used if the permission has not been explicitly granted or revoked | |||
* in this instance. | |||
*/ | |||
public Permissions(boolean delegateToOldSM) { | |||
public Permissions(final boolean delegateToOldSM) { | |||
this.delegateToOldSM = delegateToOldSM; | |||
} | |||
@@ -76,7 +76,7 @@ public class Permissions { | |||
* Adds a permission to be granted. | |||
* @param perm The Permissions.Permission to be granted. | |||
*/ | |||
public void addConfiguredGrant(Permissions.Permission perm) { | |||
public void addConfiguredGrant(final Permissions.Permission perm) { | |||
grantedPermissions.add(perm); | |||
} | |||
@@ -84,7 +84,7 @@ public class Permissions { | |||
* Adds a permission to be revoked. | |||
* @param perm The Permissions.Permission to be revoked | |||
*/ | |||
public void addConfiguredRevoke(Permissions.Permission perm) { | |||
public void addConfiguredRevoke(final Permissions.Permission perm) { | |||
revokedPermissions.add(perm); | |||
} | |||
@@ -107,17 +107,17 @@ public class Permissions { | |||
*/ | |||
private void init() throws BuildException { | |||
granted = new java.security.Permissions(); | |||
for (Permissions.Permission p : revokedPermissions) { | |||
for (final Permissions.Permission p : revokedPermissions) { | |||
if (p.getClassName() == null) { | |||
throw new BuildException("Revoked permission " + p + " does not contain a class."); | |||
} | |||
} | |||
for (Permissions.Permission p : grantedPermissions) { | |||
for (final Permissions.Permission p : grantedPermissions) { | |||
if (p.getClassName() == null) { | |||
throw new BuildException("Granted permission " + p | |||
+ " does not contain a class."); | |||
} else { | |||
java.security.Permission perm = createPermission(p); | |||
final java.security.Permission perm = createPermission(p); | |||
granted.add(perm); | |||
} | |||
} | |||
@@ -146,17 +146,17 @@ public class Permissions { | |||
} | |||
private java.security.Permission createPermission( | |||
Permissions.Permission permission) { | |||
final Permissions.Permission permission) { | |||
try { | |||
// First add explicitly already resolved permissions will not be | |||
// resolved when added as unresolved permission. | |||
Class<? extends java.security.Permission> clazz = Class.forName( | |||
final Class<? extends java.security.Permission> clazz = Class.forName( | |||
permission.getClassName()).asSubclass(java.security.Permission.class); | |||
String name = permission.getName(); | |||
String actions = permission.getActions(); | |||
Constructor<? extends java.security.Permission> ctr = clazz.getConstructor(PARAMS); | |||
return ctr.newInstance(new Object[] { name, actions }); | |||
} catch (Exception e) { | |||
final String name = permission.getName(); | |||
final String actions = permission.getActions(); | |||
final Constructor<? extends java.security.Permission> ctr = clazz.getConstructor(PARAMS); | |||
return ctr.newInstance(new Object[] {name, actions}); | |||
} catch (final Exception e) { | |||
// Let the UnresolvedPermission handle it. | |||
return new UnresolvedPermission(permission.getClassName(), | |||
permission.getName(), permission.getActions(), null); | |||
@@ -185,11 +185,12 @@ public class Permissions { | |||
* Overridden from java.lang.SecurityManager | |||
* @param status The exit status requested. | |||
*/ | |||
public void checkExit(int status) { | |||
java.security.Permission perm = new java.lang.RuntimePermission("exitVM", null); | |||
@Override | |||
public void checkExit(final int status) { | |||
final java.security.Permission perm = new java.lang.RuntimePermission("exitVM", null); | |||
try { | |||
checkPermission(perm); | |||
} catch (SecurityException e) { | |||
} catch (final SecurityException e) { | |||
throw new ExitException(e.getMessage(), status); | |||
} | |||
} | |||
@@ -200,7 +201,8 @@ public class Permissions { | |||
* | |||
* @param perm The permission requested. | |||
*/ | |||
public void checkPermission(java.security.Permission perm) { | |||
@Override | |||
public void checkPermission(final java.security.Permission perm) { | |||
if (active) { | |||
if (delegateToOldSM && !perm.getName().equals("exitVM")) { | |||
boolean permOK = false; | |||
@@ -228,8 +230,8 @@ public class Permissions { | |||
* throws an exception if this permission is revoked | |||
* @param perm the permission being checked | |||
*/ | |||
private void checkRevoked(java.security.Permission perm) { | |||
for (Permissions.Permission revoked : revokedPermissions) { | |||
private void checkRevoked(final java.security.Permission perm) { | |||
for (final Permissions.Permission revoked : revokedPermissions) { | |||
if (revoked.matches(perm)) { | |||
throw new SecurityException("Permission " + perm + " was revoked."); | |||
} | |||
@@ -248,7 +250,7 @@ public class Permissions { | |||
* Set the class, mandatory. | |||
* @param aClass The class name of the permission. | |||
*/ | |||
public void setClass(String aClass) { | |||
public void setClass(final String aClass) { | |||
className = aClass.trim(); | |||
} | |||
@@ -264,7 +266,7 @@ public class Permissions { | |||
* Set the name of the permission. | |||
* @param aName The name of the permission. | |||
*/ | |||
public void setName(String aName) { | |||
public void setName(final String aName) { | |||
name = aName.trim(); | |||
} | |||
@@ -280,7 +282,7 @@ public class Permissions { | |||
* Set the actions. | |||
* @param actions The actions of the permission. | |||
*/ | |||
public void setActions(String actions) { | |||
public void setActions(final String actions) { | |||
actionString = actions; | |||
if (actions.length() > 0) { | |||
this.actions = parseActions(actions); | |||
@@ -299,7 +301,7 @@ public class Permissions { | |||
* Learn whether the permission matches in case of a revoked permission. | |||
* @param perm The permission to check against. | |||
*/ | |||
boolean matches(java.security.Permission perm) { | |||
boolean matches(final java.security.Permission perm) { | |||
if (!className.equals(perm.getClass().getName())) { | |||
return false; | |||
} | |||
@@ -315,8 +317,8 @@ public class Permissions { | |||
} | |||
} | |||
if (actions != null) { | |||
Set<String> as = parseActions(perm.getActions()); | |||
int size = as.size(); | |||
final Set<String> as = parseActions(perm.getActions()); | |||
final int size = as.size(); | |||
as.removeAll(actions); | |||
if (as.size() == size) { | |||
// None of the actions revoked, so all allowed. | |||
@@ -330,11 +332,11 @@ public class Permissions { | |||
* Parses the actions into a set of separate strings. | |||
* @param actions The actions to be parsed. | |||
*/ | |||
private Set<String> parseActions(String actions) { | |||
Set<String> result = new HashSet<String>(); | |||
StringTokenizer tk = new StringTokenizer(actions, ","); | |||
private Set<String> parseActions(final String actions) { | |||
final Set<String> result = new HashSet<String>(); | |||
final StringTokenizer tk = new StringTokenizer(actions, ","); | |||
while (tk.hasMoreTokens()) { | |||
String item = tk.nextToken().trim(); | |||
final String item = tk.nextToken().trim(); | |||
if (!item.equals("")) { | |||
result.add(item); | |||
} | |||
@@ -346,7 +348,8 @@ public class Permissions { | |||
* Get a string description of the permissions. | |||
* @return string description of the permissions. | |||
*/ | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
return ("Permission: " + className + " (\"" + name + "\", \"" + actions + "\")"); | |||
} | |||
} | |||
@@ -19,8 +19,6 @@ package org.apache.tools.ant.types; | |||
import java.util.Iterator; | |||
import org.apache.tools.ant.types.resources.FileProvider; | |||
/** | |||
* Interface describing a collection of Resources. | |||
* @since Ant 1.7 | |||
@@ -38,7 +38,7 @@ public class CutDirsMapper implements FileNameMapper { | |||
/** | |||
* The number of leading directories to cut. | |||
*/ | |||
public void setDirs(int dirs) { | |||
public void setDirs(final int dirs) { | |||
this.dirs = dirs; | |||
} | |||
@@ -46,23 +46,26 @@ public class CutDirsMapper implements FileNameMapper { | |||
* Empty implementation. | |||
* @param ignore ignored. | |||
*/ | |||
public void setFrom(String ignore) { | |||
@Override | |||
public void setFrom(final String ignore) { | |||
} | |||
/** | |||
* Empty implementation. | |||
* @param ignore ignored. | |||
*/ | |||
public void setTo(String ignore) { | |||
@Override | |||
public void setTo(final String ignore) { | |||
} | |||
/** {@inheritDoc}. */ | |||
public String[] mapFileName(final String sourceFileName) { | |||
@Override | |||
public String[] mapFileName(final String sourceFileName) { | |||
if (dirs <= 0) { | |||
throw new BuildException("dirs must be set to a positive number"); | |||
} | |||
char fileSep = File.separatorChar; | |||
String fileSepCorrected = | |||
final char fileSep = File.separatorChar; | |||
final String fileSepCorrected = | |||
sourceFileName.replace('/', fileSep).replace('\\', fileSep); | |||
int nthMatch = fileSepCorrected.indexOf(fileSep); | |||
for (int n = 1; nthMatch > -1 && n < dirs; n++) { | |||
@@ -71,6 +74,6 @@ public class CutDirsMapper implements FileNameMapper { | |||
if (nthMatch == -1) { | |||
return null; | |||
} | |||
return new String[] { sourceFileName.substring(nthMatch + 1) }; | |||
return new String[] {sourceFileName.substring(nthMatch + 1)}; | |||
} | |||
} |
@@ -72,13 +72,14 @@ public class Archives extends DataType | |||
/** | |||
* Sums the sizes of nested archives. | |||
*/ | |||
public int size() { | |||
@Override | |||
public int size() { | |||
if (isReference()) { | |||
return ((Archives) getCheckedRef()).size(); | |||
} | |||
dieOnCircularReference(); | |||
int total = 0; | |||
for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext(); ) { | |||
for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext();) { | |||
total += i.next().size(); | |||
} | |||
return total; | |||
@@ -87,13 +88,14 @@ public class Archives extends DataType | |||
/** | |||
* Merges the nested collections. | |||
*/ | |||
public Iterator<Resource> iterator() { | |||
@Override | |||
public Iterator<Resource> iterator() { | |||
if (isReference()) { | |||
return ((Archives) getCheckedRef()).iterator(); | |||
} | |||
dieOnCircularReference(); | |||
List<Resource> l = new LinkedList<Resource>(); | |||
for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext(); ) { | |||
for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext();) { | |||
l.addAll(CollectionUtils | |||
.asCollection(i.next().iterator())); | |||
} | |||
@@ -103,7 +105,8 @@ public class Archives extends DataType | |||
/** | |||
* @return false | |||
*/ | |||
public boolean isFilesystemOnly() { | |||
@Override | |||
public boolean isFilesystemOnly() { | |||
if (isReference()) { | |||
return ((Archives) getCheckedRef()).isFilesystemOnly(); | |||
} | |||
@@ -115,7 +118,8 @@ public class Archives extends DataType | |||
* Overrides the base version. | |||
* @param r the Reference to set. | |||
*/ | |||
public void setRefid(Reference r) { | |||
@Override | |||
public void setRefid(Reference r) { | |||
if (zips.getResourceCollections().size() > 0 | |||
|| tars.getResourceCollections().size() > 0) { | |||
throw tooManyAttributes(); | |||
@@ -128,7 +132,8 @@ public class Archives extends DataType | |||
* well. | |||
* @return a cloned instance. | |||
*/ | |||
public Object clone() { | |||
@Override | |||
public Object clone() { | |||
try { | |||
Archives a = (Archives) super.clone(); | |||
a.zips = (Union) zips.clone(); | |||
@@ -174,7 +179,8 @@ public class Archives extends DataType | |||
* @param p the project to use to dereference the references. | |||
* @throws BuildException on error. | |||
*/ | |||
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
@Override | |||
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
throws BuildException { | |||
if (isChecked()) { | |||
return; | |||
@@ -55,7 +55,8 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||
* @return the size, as a long, 0 if the Resource does not exist (for | |||
* compatibility with java.io.File), or UNKNOWN_SIZE if not known. | |||
*/ | |||
public long getSize() { | |||
@Override | |||
public long getSize() { | |||
if (isExists()) { | |||
InputStream in = null; | |||
try { | |||
@@ -86,7 +87,8 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||
* @throws UnsupportedOperationException if InputStreams are not | |||
* supported for this Resource type. | |||
*/ | |||
public InputStream getInputStream() throws IOException { | |||
@Override | |||
public InputStream getInputStream() throws IOException { | |||
InputStream in = getResource().getInputStream(); | |||
if (in != null) { | |||
in = wrapStream(in); | |||
@@ -102,7 +104,8 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||
* @throws UnsupportedOperationException if OutputStreams are not | |||
* supported for this Resource type. | |||
*/ | |||
public OutputStream getOutputStream() throws IOException { | |||
@Override | |||
public OutputStream getOutputStream() throws IOException { | |||
OutputStream out = getResource().getOutputStream(); | |||
if (out != null) { | |||
out = wrapStream(out); | |||
@@ -113,14 +116,16 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||
/** | |||
* Suppress FileProvider, re-implement Appendable | |||
*/ | |||
public <T> T as(Class<T> clazz) { | |||
@Override | |||
public <T> T as(Class<T> clazz) { | |||
if (Appendable.class.isAssignableFrom(clazz)) { | |||
if (isAppendSupported()) { | |||
final Appendable a = | |||
getResource().as(Appendable.class); | |||
if (a != null) { | |||
return clazz.cast(new Appendable() { | |||
public OutputStream getAppendOutputStream() | |||
@Override | |||
public OutputStream getAppendOutputStream() | |||
throws IOException { | |||
OutputStream out = a.getAppendOutputStream(); | |||
if (out != null) { | |||
@@ -134,7 +139,7 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||
return null; | |||
} | |||
return FileProvider.class.isAssignableFrom(clazz) | |||
return FileProvider.class.isAssignableFrom(clazz) | |||
? null : getResource().as(clazz); | |||
} | |||
@@ -148,7 +153,7 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||
*/ | |||
protected boolean isAppendSupported() { | |||
return false; | |||
} | |||
} | |||
/** | |||
* Get a content-filtering/transforming InputStream. | |||
@@ -36,7 +36,8 @@ public class LazyResourceCollectionWrapper extends | |||
private FilteringIterator filteringIterator; | |||
protected Iterator<Resource> createIterator() { | |||
@Override | |||
protected Iterator<Resource> createIterator() { | |||
Iterator<Resource> iterator; | |||
if (isCache()) { | |||
if (filteringIterator == null) { | |||
@@ -51,7 +52,8 @@ public class LazyResourceCollectionWrapper extends | |||
return iterator; | |||
} | |||
protected int getSize() { | |||
@Override | |||
protected int getSize() { | |||
// to compute the size, just iterate: the iterator will take care of | |||
// caching | |||
Iterator<Resource> it = createIterator(); | |||
@@ -66,7 +68,7 @@ public class LazyResourceCollectionWrapper extends | |||
/** | |||
* Specify if the resource should be filtered or not. This function should | |||
* be overrided in order to define the filtering algorithm | |||
* | |||
* | |||
* @param r resource considered for filtration | |||
* @return whether the resource should be filtered or not | |||
*/ | |||
@@ -86,7 +88,8 @@ public class LazyResourceCollectionWrapper extends | |||
this.it = it; | |||
} | |||
public boolean hasNext() { | |||
@Override | |||
public boolean hasNext() { | |||
if (ended) { | |||
return false; | |||
} | |||
@@ -103,7 +106,8 @@ public class LazyResourceCollectionWrapper extends | |||
return true; | |||
} | |||
public Resource next() { | |||
@Override | |||
public Resource next() { | |||
if (!hasNext()) { | |||
throw new UnsupportedOperationException(); | |||
} | |||
@@ -112,7 +116,8 @@ public class LazyResourceCollectionWrapper extends | |||
return r; | |||
} | |||
public void remove() { | |||
@Override | |||
public void remove() { | |||
throw new UnsupportedOperationException(); | |||
} | |||
} | |||
@@ -129,7 +134,7 @@ public class LazyResourceCollectionWrapper extends | |||
/** | |||
* Default constructor | |||
* | |||
* | |||
* @param it | |||
* the iterator which will provide the resources to put in | |||
* cache | |||
@@ -138,7 +143,8 @@ public class LazyResourceCollectionWrapper extends | |||
this.it = it; | |||
} | |||
public boolean hasNext() { | |||
@Override | |||
public boolean hasNext() { | |||
synchronized (cachedResources) { | |||
// have we already cached the next entry ? | |||
if (cachedResources.size() > cusrsor) { | |||
@@ -155,7 +161,8 @@ public class LazyResourceCollectionWrapper extends | |||
return true; | |||
} | |||
public Resource next() { | |||
@Override | |||
public Resource next() { | |||
// first check that we have some to deliver | |||
if (!hasNext()) { | |||
throw new NoSuchElementException(); | |||
@@ -167,7 +174,8 @@ public class LazyResourceCollectionWrapper extends | |||
} | |||
} | |||
public void remove() { | |||
@Override | |||
public void remove() { | |||
throw new UnsupportedOperationException(); | |||
} | |||
} | |||
@@ -46,7 +46,8 @@ public class MappedResource extends ResourceDecorator { | |||
/** | |||
* Maps the name. | |||
*/ | |||
public String getName() { | |||
@Override | |||
public String getName() { | |||
String name = getResource().getName(); | |||
if (isReference()) { | |||
return name; | |||
@@ -59,7 +60,8 @@ public class MappedResource extends ResourceDecorator { | |||
* Not really supported since mapper is never null. | |||
* @param r reference to set | |||
*/ | |||
public void setRefid(Reference r) { | |||
@Override | |||
public void setRefid(Reference r) { | |||
if (mapper != null) { | |||
throw noChildrenAllowed(); | |||
} | |||
@@ -70,8 +72,9 @@ public class MappedResource extends ResourceDecorator { | |||
* Suppress FileProvider | |||
* @param clazz the type to implement | |||
*/ | |||
public <T> T as(Class<T> clazz) { | |||
return FileProvider.class.isAssignableFrom(clazz) | |||
@Override | |||
public <T> T as(Class<T> clazz) { | |||
return FileProvider.class.isAssignableFrom(clazz) | |||
? null : getResource().as(clazz); | |||
} | |||
@@ -79,7 +82,8 @@ public class MappedResource extends ResourceDecorator { | |||
* Get the hash code for this Resource. | |||
* @since Ant 1.8.1 | |||
*/ | |||
public int hashCode() { | |||
@Override | |||
public int hashCode() { | |||
String n = getName(); | |||
return n == null ? super.hashCode() : n.hashCode(); | |||
} | |||
@@ -89,7 +93,8 @@ public class MappedResource extends ResourceDecorator { | |||
* resource itself. | |||
* @since Ant 1.8.1 | |||
*/ | |||
public boolean equals(Object other) { | |||
@Override | |||
public boolean equals(Object other) { | |||
if (other == null || !other.getClass().equals(getClass())) { | |||
return false; | |||
} | |||
@@ -100,7 +105,8 @@ public class MappedResource extends ResourceDecorator { | |||
&& getResource().equals(m.getResource()); | |||
} | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
if (isReference()) { | |||
return getCheckedRef().toString(); | |||
} | |||
@@ -43,7 +43,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||
private List<File> baseDirs = new ArrayList<File>(); | |||
private Union union; | |||
public void setDir(File dir) { | |||
@Override | |||
public void setDir(File dir) { | |||
throw new BuildException(getDataTypeName() | |||
+ " doesn't support the dir attribute"); | |||
} | |||
@@ -96,7 +97,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||
baseDirs.add(r.getFile()); | |||
} | |||
public void setRefid(Reference r) { | |||
@Override | |||
public void setRefid(Reference r) { | |||
if (!baseDirs.isEmpty()) { | |||
throw tooManyAttributes(); | |||
} | |||
@@ -108,7 +110,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||
* as this one. | |||
* @return the cloned MultiRootFileSet. | |||
*/ | |||
public Object clone() { | |||
@Override | |||
public Object clone() { | |||
if (isReference()) { | |||
return ((MultiRootFileSet) getRef(getProject())).clone(); | |||
} else { | |||
@@ -123,7 +126,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||
* Fulfill the ResourceCollection contract. | |||
* @return an Iterator of Resources. | |||
*/ | |||
public Iterator<Resource> iterator() { | |||
@Override | |||
public Iterator<Resource> iterator() { | |||
if (isReference()) { | |||
return ((MultiRootFileSet) getRef(getProject())).iterator(); | |||
} | |||
@@ -134,7 +138,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||
* Fulfill the ResourceCollection contract. | |||
* @return number of elements as int. | |||
*/ | |||
public int size() { | |||
@Override | |||
public int size() { | |||
if (isReference()) { | |||
return ((MultiRootFileSet) getRef(getProject())).size(); | |||
} | |||
@@ -145,7 +150,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||
* Always returns true. | |||
* @return true indicating that all elements will be FileResources. | |||
*/ | |||
public boolean isFilesystemOnly() { | |||
@Override | |||
public boolean isFilesystemOnly() { | |||
return true; | |||
} | |||
@@ -154,7 +160,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||
* | |||
* @return a <code>String</code> of included directories. | |||
*/ | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
if (isReference()) { | |||
return ((MultiRootFileSet) getRef(getProject())).toString(); | |||
} | |||
@@ -190,18 +197,20 @@ public class MultiRootFileSet extends AbstractFileSet | |||
implements ResourceCollection { | |||
private final SetType type; | |||
private Worker(MultiRootFileSet fs, SetType type, File dir) { | |||
super(fs); | |||
this.type = type; | |||
setDir(dir); | |||
} | |||
public boolean isFilesystemOnly() { | |||
@Override | |||
public boolean isFilesystemOnly() { | |||
return true; | |||
} | |||
public Iterator<Resource> iterator() { | |||
@Override | |||
public Iterator<Resource> iterator() { | |||
DirectoryScanner ds = getDirectoryScanner(getProject()); | |||
String[] names = type == SetType.file | |||
? ds.getIncludedFiles() | |||
@@ -217,7 +226,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||
names); | |||
} | |||
public int size() { | |||
@Override | |||
public int size() { | |||
DirectoryScanner ds = getDirectoryScanner(getProject()); | |||
int count = type == SetType.file | |||
? ds.getIncludedFilesCount() | |||
@@ -44,7 +44,7 @@ public class Type implements ResourceSelector { | |||
* Implements the type attribute. | |||
*/ | |||
public static class FileDir extends EnumeratedAttribute { | |||
private static final String[] VALUES = new String[] { FILE_ATTR, DIR_ATTR, ANY_ATTR }; | |||
private static final String[] VALUES = new String[] {FILE_ATTR, DIR_ATTR, ANY_ATTR}; | |||
/** | |||
* Default constructor. | |||
@@ -56,7 +56,7 @@ public class Type implements ResourceSelector { | |||
* Convenience constructor. | |||
* @param value the String EnumeratedAttribute value. | |||
*/ | |||
public FileDir(String value) { | |||
public FileDir(final String value) { | |||
setValue(value); | |||
} | |||
@@ -64,7 +64,8 @@ public class Type implements ResourceSelector { | |||
* Return the possible values. | |||
* @return a String array. | |||
*/ | |||
public String[] getValues() { | |||
@Override | |||
public String[] getValues() { | |||
return VALUES; | |||
} | |||
} | |||
@@ -81,7 +82,7 @@ public class Type implements ResourceSelector { | |||
* Convenience constructor. | |||
* @param fd the FileDir type. | |||
*/ | |||
public Type(FileDir fd) { | |||
public Type(final FileDir fd) { | |||
setType(fd); | |||
} | |||
@@ -89,7 +90,7 @@ public class Type implements ResourceSelector { | |||
* Set type; file|dir. | |||
* @param fd a FileDir object. | |||
*/ | |||
public void setType(FileDir fd) { | |||
public void setType(final FileDir fd) { | |||
type = fd; | |||
} | |||
@@ -98,11 +99,12 @@ public class Type implements ResourceSelector { | |||
* @param r the Resource to check. | |||
* @return whether the Resource was selected. | |||
*/ | |||
public boolean isSelected(Resource r) { | |||
@Override | |||
public boolean isSelected(final Resource r) { | |||
if (type == null) { | |||
throw new BuildException("The type attribute is required."); | |||
} | |||
int i = type.getIndex(); | |||
final int i = type.getIndex(); | |||
return i == 2 || (r.isDirectory() ? i == 1 : i == 0); | |||
} | |||
@@ -88,12 +88,13 @@ public abstract class MappingSelector extends BaseSelector { | |||
} | |||
this.map = fileNameMapper; | |||
} | |||
/** | |||
* Checks to make sure all settings are kosher. In this case, it | |||
* means that the dest attribute has been set and we have a mapper. | |||
*/ | |||
public void verifySettings() { | |||
@Override | |||
public void verifySettings() { | |||
if (targetdir == null) { | |||
setError("The targetdir attribute is required."); | |||
} | |||
@@ -118,7 +119,8 @@ public abstract class MappingSelector extends BaseSelector { | |||
* @param file is a java.io.File object the selector can use | |||
* @return whether the file should be selected or not | |||
*/ | |||
public boolean isSelected(File basedir, String filename, File file) { | |||
@Override | |||
public boolean isSelected(File basedir, String filename, File file) { | |||
// throw BuildException on error | |||
validate(); | |||
@@ -51,8 +51,9 @@ public class PresentSelector extends BaseSelector { | |||
/** | |||
* @return a string describing this object | |||
*/ | |||
public String toString() { | |||
StringBuilder buf = new StringBuilder("{presentselector targetdir: "); | |||
@Override | |||
public String toString() { | |||
final StringBuilder buf = new StringBuilder("{presentselector targetdir: "); | |||
if (targetdir == null) { | |||
buf.append("NOT YET SET"); | |||
} else { | |||
@@ -79,7 +80,7 @@ public class PresentSelector extends BaseSelector { | |||
* | |||
* @param targetdir the directory to scan looking for matching files. | |||
*/ | |||
public void setTargetdir(File targetdir) { | |||
public void setTargetdir(final File targetdir) { | |||
this.targetdir = targetdir; | |||
} | |||
@@ -102,7 +103,7 @@ public class PresentSelector extends BaseSelector { | |||
* @throws BuildException if more than one mapper defined | |||
* @since Ant 1.8.0 | |||
*/ | |||
public void addConfigured(FileNameMapper fileNameMapper) { | |||
public void addConfigured(final FileNameMapper fileNameMapper) { | |||
if (map != null || mapperElement != null) { | |||
throw new BuildException("Cannot define more than one mapper"); | |||
} | |||
@@ -121,7 +122,7 @@ public class PresentSelector extends BaseSelector { | |||
* @param fp An attribute set to either <code>srconly</code or | |||
* <code>both</code>. | |||
*/ | |||
public void setPresent(FilePresence fp) { | |||
public void setPresent(final FilePresence fp) { | |||
if (fp.getIndex() == 0) { | |||
destmustexist = false; | |||
} | |||
@@ -131,7 +132,8 @@ public class PresentSelector extends BaseSelector { | |||
* Checks to make sure all settings are kosher. In this case, it | |||
* means that the targetdir attribute has been set and we have a mapper. | |||
*/ | |||
public void verifySettings() { | |||
@Override | |||
public void verifySettings() { | |||
if (targetdir == null) { | |||
setError("The targetdir attribute is required."); | |||
} | |||
@@ -156,13 +158,14 @@ public class PresentSelector extends BaseSelector { | |||
* @param file is a java.io.File object the selector can use | |||
* @return whether the file should be selected or not | |||
*/ | |||
public boolean isSelected(File basedir, String filename, File file) { | |||
@Override | |||
public boolean isSelected(final File basedir, final String filename, final File file) { | |||
// throw BuildException on error | |||
validate(); | |||
// Determine file whose existence is to be checked | |||
String[] destfiles = map.mapFileName(filename); | |||
final String[] destfiles = map.mapFileName(filename); | |||
// If filename does not match the To attribute of the mapper | |||
// then filter it out of the files we are considering | |||
if (destfiles == null) { | |||
@@ -173,8 +176,8 @@ public class PresentSelector extends BaseSelector { | |||
throw new BuildException("Invalid destination file results for " | |||
+ targetdir + " with filename " + filename); | |||
} | |||
String destname = destfiles[0]; | |||
File destfile = FileUtils.getFileUtils().resolveFile(targetdir, destname); | |||
final String destname = destfiles[0]; | |||
final File destfile = FileUtils.getFileUtils().resolveFile(targetdir, destname); | |||
return destfile.exists() == destmustexist; | |||
} | |||
@@ -186,8 +189,9 @@ public class PresentSelector extends BaseSelector { | |||
/** | |||
* @return the values as an array of strings | |||
*/ | |||
public String[] getValues() { | |||
return new String[] { "srconly", "both" }; | |||
@Override | |||
public String[] getValues() { | |||
return new String[] {"srconly", "both"}; | |||
} | |||
} | |||
@@ -50,14 +50,14 @@ public class TokenizedPath { | |||
private final String[] tokenizedPath; | |||
/** | |||
* Initialize the TokenizedPath by parsing it. | |||
* Initialize the TokenizedPath by parsing it. | |||
* @param path The path to tokenize. Must not be | |||
* <code>null</code>. | |||
*/ | |||
public TokenizedPath(String path) { | |||
this(path, SelectorUtils.tokenizePathAsArray(path)); | |||
} | |||
/** | |||
* Creates a new path as a child of another path. | |||
* | |||
@@ -86,10 +86,11 @@ public class TokenizedPath { | |||
/** | |||
* @return The original path String | |||
*/ | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
return path; | |||
} | |||
/** | |||
* The depth (or length) of a path. | |||
*/ | |||
@@ -160,12 +161,14 @@ public class TokenizedPath { | |||
/** | |||
* true if the original paths are equal. | |||
*/ | |||
public boolean equals(Object o) { | |||
@Override | |||
public boolean equals(Object o) { | |||
return o instanceof TokenizedPath | |||
&& path.equals(((TokenizedPath) o).path); | |||
} | |||
public int hashCode() { | |||
@Override | |||
public int hashCode() { | |||
return path.hashCode(); | |||
} | |||
@@ -213,7 +216,7 @@ public class TokenizedPath { | |||
* this path. | |||
*/ | |||
public TokenizedPattern toPattern() { | |||
return new TokenizedPattern(path, tokenizedPath); | |||
return new TokenizedPattern(path, tokenizedPath); | |||
} | |||
} |
@@ -521,7 +521,7 @@ public class DOMElementWriter { | |||
while (prevEnd < len) { | |||
final int end = (cdataEndPos < 0 ? len : cdataEndPos); | |||
// Write out stretches of legal characters in the range [prevEnd, end). | |||
for (int prevLegalCharPos = prevEnd; prevLegalCharPos < end; /*empty*/) { | |||
for (int prevLegalCharPos = prevEnd; prevLegalCharPos < end;/*empty*/) { | |||
int illegalCharPos; | |||
for (illegalCharPos = prevLegalCharPos; true; ++illegalCharPos) { | |||
if (illegalCharPos >= end | |||
@@ -211,7 +211,7 @@ public final class JavaEnvUtils { | |||
* Searching for changes (grep -r -i -n "@since 1.9" .) in the sources gave | |||
* only one hit: a new constant in the class SourceVersion. | |||
* So we have to check that ... | |||
* | |||
* | |||
* @throws Exception if we can't load the class or don't find the new constant. | |||
* This is the behavior when searching for new features on older versions. | |||
* @since Ant 1.9.4 | |||
@@ -109,7 +109,7 @@ public class LayoutPreservingProperties extends Properties { | |||
* Create a new, empty, Properties collection, with the specified defaults. | |||
* @param defaults the default property values | |||
*/ | |||
public LayoutPreservingProperties(Properties defaults) { | |||
public LayoutPreservingProperties(final Properties defaults) { | |||
super(defaults); | |||
} | |||
@@ -134,27 +134,30 @@ public class LayoutPreservingProperties extends Properties { | |||
* removed when a property is removed; <code>false</code> | |||
* otherwise | |||
*/ | |||
public void setRemoveComments(boolean val) { | |||
public void setRemoveComments(final boolean val) { | |||
removeComments = val; | |||
} | |||
public void load(InputStream inStream) throws IOException { | |||
String s = readLines(inStream); | |||
byte[] ba = s.getBytes(ResourceUtils.ISO_8859_1); | |||
ByteArrayInputStream bais = new ByteArrayInputStream(ba); | |||
@Override | |||
public void load(final InputStream inStream) throws IOException { | |||
final String s = readLines(inStream); | |||
final byte[] ba = s.getBytes(ResourceUtils.ISO_8859_1); | |||
final ByteArrayInputStream bais = new ByteArrayInputStream(ba); | |||
super.load(bais); | |||
} | |||
public Object put(Object key, Object value) throws NullPointerException { | |||
Object obj = super.put(key, value); | |||
@Override | |||
public Object put(final Object key, final Object value) throws NullPointerException { | |||
final Object obj = super.put(key, value); | |||
// the above call will have failed if key or value are null | |||
innerSetProperty(key.toString(), value.toString()); | |||
return obj; | |||
} | |||
public Object setProperty(String key, String value) | |||
@Override | |||
public Object setProperty(final String key, final String value) | |||
throws NullPointerException { | |||
Object obj = super.setProperty(key, value); | |||
final Object obj = super.setProperty(key, value); | |||
// the above call will have failed if key or value are null | |||
innerSetProperty(key, value); | |||
return obj; | |||
@@ -172,27 +175,29 @@ public class LayoutPreservingProperties extends Properties { | |||
value = escapeValue(value); | |||
if (keyedPairLines.containsKey(key)) { | |||
Integer i = (Integer) keyedPairLines.get(key); | |||
Pair p = (Pair) logicalLines.get(i.intValue()); | |||
final Integer i = (Integer) keyedPairLines.get(key); | |||
final Pair p = (Pair) logicalLines.get(i.intValue()); | |||
p.setValue(value); | |||
} else { | |||
key = escapeName(key); | |||
Pair p = new Pair(key, value); | |||
final Pair p = new Pair(key, value); | |||
p.setNew(true); | |||
keyedPairLines.put(key, new Integer(logicalLines.size())); | |||
logicalLines.add(p); | |||
} | |||
} | |||
public void clear() { | |||
@Override | |||
public void clear() { | |||
super.clear(); | |||
keyedPairLines.clear(); | |||
logicalLines.clear(); | |||
} | |||
public Object remove(Object key) { | |||
Object obj = super.remove(key); | |||
Integer i = (Integer) keyedPairLines.remove(key); | |||
@Override | |||
public Object remove(final Object key) { | |||
final Object obj = super.remove(key); | |||
final Integer i = (Integer) keyedPairLines.remove(key); | |||
if (null != i) { | |||
if (removeComments) { | |||
removeCommentsEndingAt(i.intValue()); | |||
@@ -202,16 +207,17 @@ public class LayoutPreservingProperties extends Properties { | |||
return obj; | |||
} | |||
public Object clone() { | |||
LayoutPreservingProperties dolly = | |||
@Override | |||
public Object clone() { | |||
final LayoutPreservingProperties dolly = | |||
(LayoutPreservingProperties) super.clone(); | |||
dolly.keyedPairLines = (HashMap) this.keyedPairLines.clone(); | |||
dolly.logicalLines = (ArrayList) this.logicalLines.clone(); | |||
final int size = dolly.logicalLines.size(); | |||
for (int j = 0; j < size; j++) { | |||
LogicalLine line = (LogicalLine) dolly.logicalLines.get(j); | |||
final LogicalLine line = (LogicalLine) dolly.logicalLines.get(j); | |||
if (line instanceof Pair) { | |||
Pair p = (Pair) line; | |||
final Pair p = (Pair) line; | |||
dolly.logicalLines.set(j, p.clone()); | |||
} | |||
// no reason to clone other lines are they are immutable | |||
@@ -224,11 +230,11 @@ public class LayoutPreservingProperties extends Properties { | |||
* stream. | |||
* @param out the stream to write to | |||
*/ | |||
public void listLines(PrintStream out) { | |||
public void listLines(final PrintStream out) { | |||
out.println("-- logical lines --"); | |||
Iterator i = logicalLines.iterator(); | |||
final Iterator i = logicalLines.iterator(); | |||
while (i.hasNext()) { | |||
LogicalLine line = (LogicalLine) i.next(); | |||
final LogicalLine line = (LogicalLine) i.next(); | |||
if (line instanceof Blank) { | |||
out.println("blank: \"" + line + "\""); | |||
} else if (line instanceof Comment) { | |||
@@ -243,17 +249,18 @@ public class LayoutPreservingProperties extends Properties { | |||
* Save the properties to a file. | |||
* @param dest the file to write to | |||
*/ | |||
public void saveAs(File dest) throws IOException { | |||
FileOutputStream fos = new FileOutputStream(dest); | |||
public void saveAs(final File dest) throws IOException { | |||
final FileOutputStream fos = new FileOutputStream(dest); | |||
store(fos, null); | |||
fos.close(); | |||
} | |||
public void store(OutputStream out, String header) throws IOException { | |||
OutputStreamWriter osw = new OutputStreamWriter(out, ResourceUtils.ISO_8859_1); | |||
@Override | |||
public void store(final OutputStream out, final String header) throws IOException { | |||
final OutputStreamWriter osw = new OutputStreamWriter(out, ResourceUtils.ISO_8859_1); | |||
int skipLines = 0; | |||
int totalLines = logicalLines.size(); | |||
final int totalLines = logicalLines.size(); | |||
if (header != null) { | |||
osw.write("#" + header + LS); | |||
@@ -274,16 +281,16 @@ public class LayoutPreservingProperties extends Properties { | |||
.get(skipLines) | |||
.toString().substring(1)); | |||
skipLines++; | |||
} catch (java.text.ParseException pe) { | |||
} catch (final java.text.ParseException pe) { | |||
// not an existing date comment | |||
} | |||
} | |||
osw.write("#" + DateUtils.getDateForHeader() + LS); | |||
boolean writtenSep = false; | |||
for (Iterator i = logicalLines.subList(skipLines, totalLines).iterator(); | |||
i.hasNext(); ) { | |||
LogicalLine line = (LogicalLine) i.next(); | |||
for (final Iterator i = logicalLines.subList(skipLines, totalLines).iterator(); | |||
i.hasNext();) { | |||
final LogicalLine line = (LogicalLine) i.next(); | |||
if (line instanceof Pair) { | |||
if (((Pair)line).isNew()) { | |||
if (!writtenSep) { | |||
@@ -306,9 +313,9 @@ public class LayoutPreservingProperties extends Properties { | |||
* file. | |||
* @param is the stream from which to read the data | |||
*/ | |||
private String readLines(InputStream is) throws IOException { | |||
InputStreamReader isr = new InputStreamReader(is, ResourceUtils.ISO_8859_1); | |||
PushbackReader pbr = new PushbackReader(isr, 1); | |||
private String readLines(final InputStream is) throws IOException { | |||
final InputStreamReader isr = new InputStreamReader(is, ResourceUtils.ISO_8859_1); | |||
final PushbackReader pbr = new PushbackReader(isr, 1); | |||
if (logicalLines.size() > 0) { | |||
// we add a blank line for spacing | |||
@@ -316,12 +323,12 @@ public class LayoutPreservingProperties extends Properties { | |||
} | |||
String s = readFirstLine(pbr); | |||
BufferedReader br = new BufferedReader(pbr); | |||
final BufferedReader br = new BufferedReader(pbr); | |||
boolean continuation = false; | |||
boolean comment = false; | |||
StringBuffer fileBuffer = new StringBuffer(); | |||
StringBuffer logicalLineBuffer = new StringBuffer(); | |||
final StringBuffer fileBuffer = new StringBuffer(); | |||
final StringBuffer logicalLineBuffer = new StringBuffer(); | |||
while (s != null) { | |||
fileBuffer.append(s).append(LS); | |||
@@ -349,7 +356,7 @@ public class LayoutPreservingProperties extends Properties { | |||
line = new Blank(); | |||
} else { | |||
line = new Pair(logicalLineBuffer.toString()); | |||
String key = unescape(((Pair)line).getName()); | |||
final String key = unescape(((Pair)line).getName()); | |||
if (keyedPairLines.containsKey(key)) { | |||
// this key is already present, so we remove it and add | |||
// the new one | |||
@@ -376,8 +383,8 @@ public class LayoutPreservingProperties extends Properties { | |||
* | |||
* @since Ant 1.8.2 | |||
*/ | |||
private String readFirstLine(PushbackReader r) throws IOException { | |||
StringBuffer sb = new StringBuffer(80); | |||
private String readFirstLine(final PushbackReader r) throws IOException { | |||
final StringBuffer sb = new StringBuffer(80); | |||
int ch = r.read(); | |||
boolean hasCR = false; | |||
// when reaching EOF before the first EOL, assume native line | |||
@@ -413,14 +420,14 @@ public class LayoutPreservingProperties extends Properties { | |||
* @return <code>true</code> if the line is to be continued, | |||
* <code>false</code> otherwise | |||
*/ | |||
private boolean requiresContinuation(String s) { | |||
char[] ca = s.toCharArray(); | |||
private boolean requiresContinuation(final String s) { | |||
final char[] ca = s.toCharArray(); | |||
int i = ca.length - 1; | |||
while (i > 0 && ca[i] == '\\') { | |||
i--; | |||
} | |||
// trailing backslashes | |||
int tb = ca.length - i - 1; | |||
final int tb = ca.length - i - 1; | |||
return tb % 2 == 1; | |||
} | |||
@@ -431,7 +438,7 @@ public class LayoutPreservingProperties extends Properties { | |||
* @param s the string to unescape (coming from the source file) | |||
* @return the unescaped string | |||
*/ | |||
private String unescape(String s) { | |||
private String unescape(final String s) { | |||
/* | |||
* The following combinations are converted: | |||
* \n newline | |||
@@ -444,10 +451,10 @@ public class LayoutPreservingProperties extends Properties { | |||
* \b becomes 'b'. | |||
*/ | |||
char[] ch = new char[s.length() + 1]; | |||
final char[] ch = new char[s.length() + 1]; | |||
s.getChars(0, s.length(), ch, 0); | |||
ch[s.length()] = '\n'; | |||
StringBuffer buffy = new StringBuffer(s.length()); | |||
final StringBuffer buffy = new StringBuffer(s.length()); | |||
for (int i = 0; i < ch.length; i++) { | |||
char c = ch[i]; | |||
if (c == '\n') { | |||
@@ -485,8 +492,8 @@ public class LayoutPreservingProperties extends Properties { | |||
* @param ch the character array containing the unicode character code | |||
* @return the character extracted | |||
*/ | |||
private char unescapeUnicode(char[] ch, int i) { | |||
String s = new String(ch, i, 4); | |||
private char unescapeUnicode(final char[] ch, final int i) { | |||
final String s = new String(ch, i, 4); | |||
return (char) Integer.parseInt(s, 16); | |||
} | |||
@@ -497,7 +504,7 @@ public class LayoutPreservingProperties extends Properties { | |||
* @param s the string to escape | |||
* @return the escaped string | |||
*/ | |||
private String escapeValue(String s) { | |||
private String escapeValue(final String s) { | |||
return escape(s, false); | |||
} | |||
@@ -510,7 +517,7 @@ public class LayoutPreservingProperties extends Properties { | |||
* @param s the string to escape | |||
* @return the escaped string | |||
*/ | |||
private String escapeName(String s) { | |||
private String escapeName(final String s) { | |||
return escape(s, true); | |||
} | |||
@@ -524,19 +531,19 @@ public class LayoutPreservingProperties extends Properties { | |||
* leading whitespace | |||
* @return the escaped string | |||
*/ | |||
private String escape(String s, boolean escapeAllSpaces) { | |||
private String escape(final String s, final boolean escapeAllSpaces) { | |||
if (s == null) { | |||
return null; | |||
} | |||
char[] ch = new char[s.length()]; | |||
final char[] ch = new char[s.length()]; | |||
s.getChars(0, s.length(), ch, 0); | |||
String forEscaping = "\t\f\r\n\\:=#!"; | |||
String escaped = "tfrn\\:=#!"; | |||
StringBuffer buffy = new StringBuffer(s.length()); | |||
final String forEscaping = "\t\f\r\n\\:=#!"; | |||
final String escaped = "tfrn\\:=#!"; | |||
final StringBuffer buffy = new StringBuffer(s.length()); | |||
boolean leadingSpace = true; | |||
for (int i = 0; i < ch.length; i++) { | |||
char c = ch[i]; | |||
final char c = ch[i]; | |||
if (c == ' ') { | |||
if (escapeAllSpaces || leadingSpace) { | |||
buffy.append("\\"); | |||
@@ -544,7 +551,7 @@ public class LayoutPreservingProperties extends Properties { | |||
} else { | |||
leadingSpace = false; | |||
} | |||
int p = forEscaping.indexOf(c); | |||
final int p = forEscaping.indexOf(c); | |||
if (p != -1) { | |||
buffy.append("\\").append(escaped.substring(p,p+1)); | |||
} else if (c < 0x0020 || c > 0x007e) { | |||
@@ -562,7 +569,7 @@ public class LayoutPreservingProperties extends Properties { | |||
* @param ch the character to encode | |||
* @return the unicode escape sequence | |||
*/ | |||
private String escapeUnicode(char ch) { | |||
private String escapeUnicode(final char ch) { | |||
return "\\" + UnicodeUtil.EscapeUnicode(ch); | |||
} | |||
@@ -580,7 +587,7 @@ public class LayoutPreservingProperties extends Properties { | |||
* B1. | |||
*/ | |||
int end = pos - 1; | |||
final int end = pos - 1; | |||
// step pos back until it hits something non-blank | |||
for (pos = end; pos > 0; pos--) { | |||
@@ -603,7 +610,7 @@ public class LayoutPreservingProperties extends Properties { | |||
} | |||
// now we want to delete from pos+1 to end | |||
for (pos++ ;pos <= end; pos++) { | |||
for (pos++; pos <= end; pos++) { | |||
logicalLines.set(pos, null); | |||
} | |||
} | |||
@@ -611,18 +618,19 @@ public class LayoutPreservingProperties extends Properties { | |||
/** | |||
* A logical line of the properties input stream. | |||
*/ | |||
private static abstract class LogicalLine { | |||
private abstract static class LogicalLine { | |||
private String text; | |||
public LogicalLine(String text) { | |||
public LogicalLine(final String text) { | |||
this.text = text; | |||
} | |||
public void setText(String text) { | |||
public void setText(final String text) { | |||
this.text = text; | |||
} | |||
public String toString() { | |||
@Override | |||
public String toString() { | |||
return text; | |||
} | |||
} | |||
@@ -640,7 +648,7 @@ public class LayoutPreservingProperties extends Properties { | |||
* A comment line of the input stream. | |||
*/ | |||
private class Comment extends LogicalLine { | |||
public Comment(String text) { | |||
public Comment(final String text) { | |||
super(text); | |||
} | |||
} | |||
@@ -655,12 +663,12 @@ public class LayoutPreservingProperties extends Properties { | |||
private String value; | |||
private boolean added; | |||
public Pair(String text) { | |||
public Pair(final String text) { | |||
super(text); | |||
parsePair(text); | |||
} | |||
public Pair(String name, String value) { | |||
public Pair(final String name, final String value) { | |||
this(name + "=" + value); | |||
} | |||
@@ -672,7 +680,7 @@ public class LayoutPreservingProperties extends Properties { | |||
return value; | |||
} | |||
public void setValue(String value) { | |||
public void setValue(final String value) { | |||
this.value = value; | |||
setText(name + "=" + value); | |||
} | |||
@@ -681,24 +689,25 @@ public class LayoutPreservingProperties extends Properties { | |||
return added; | |||
} | |||
public void setNew(boolean val) { | |||
public void setNew(final boolean val) { | |||
added = val; | |||
} | |||
public Object clone() { | |||
@Override | |||
public Object clone() { | |||
Object dolly = null; | |||
try { | |||
dolly = super.clone(); | |||
} catch (CloneNotSupportedException e) { | |||
} catch (final CloneNotSupportedException e) { | |||
// should be fine | |||
e.printStackTrace(); | |||
} | |||
return dolly; | |||
} | |||
private void parsePair(String text) { | |||
private void parsePair(final String text) { | |||
// need to find first non-escaped '=', ':', '\t' or ' '. | |||
int pos = findFirstSeparator(text); | |||
final int pos = findFirstSeparator(text); | |||
if (pos == -1) { | |||
// trim leading whitespace only | |||
name = text; | |||
@@ -711,7 +720,7 @@ public class LayoutPreservingProperties extends Properties { | |||
name = stripStart(name, " \t\f"); | |||
} | |||
private String stripStart(String s, String chars) { | |||
private String stripStart(final String s, final String chars) { | |||
if (s == null) { | |||
return null; | |||
} | |||
@@ -745,14 +754,14 @@ public class LayoutPreservingProperties extends Properties { | |||
return indexOfAny(s, " :=\t"); | |||
} | |||
private int indexOfAny(String s, String chars) { | |||
private int indexOfAny(final String s, final String chars) { | |||
if (s == null || chars == null) { | |||
return -1; | |||
} | |||
int p = s.length() + 1; | |||
for (int i = 0; i < chars.length(); i++) { | |||
int x = s.indexOf(chars.charAt(i)); | |||
final int x = s.indexOf(chars.charAt(i)); | |||
if (x != -1 && x < p) { | |||
p = x; | |||
} | |||
@@ -50,7 +50,8 @@ public abstract class LineOrientedOutputStream extends OutputStream { | |||
* @param cc data to log (byte). | |||
* @throws IOException if there is an error. | |||
*/ | |||
public final void write(int cc) throws IOException { | |||
@Override | |||
public final void write(int cc) throws IOException { | |||
final byte c = (byte) cc; | |||
if ((c == LF) || (c == CR)) { | |||
if (!skip) { | |||
@@ -66,7 +67,8 @@ public abstract class LineOrientedOutputStream extends OutputStream { | |||
* Flush this log stream | |||
* @throws IOException if there is an error. | |||
*/ | |||
public void flush() throws IOException { | |||
@Override | |||
public void flush() throws IOException { | |||
} | |||
/** | |||
@@ -111,7 +113,8 @@ public abstract class LineOrientedOutputStream extends OutputStream { | |||
* Writes all remaining | |||
* @throws IOException if there is an error. | |||
*/ | |||
public void close() throws IOException { | |||
@Override | |||
public void close() throws IOException { | |||
if (buffer.size() > 0) { | |||
processBuffer(); | |||
} | |||
@@ -127,7 +130,8 @@ public abstract class LineOrientedOutputStream extends OutputStream { | |||
* | |||
* @throws IOException if the data cannot be written into the stream. | |||
*/ | |||
public final void write(byte[] b, int off, int len) throws IOException { | |||
@Override | |||
public final void write(byte[] b, int off, int len) throws IOException { | |||
// find the line breaks and pass other chars through in blocks | |||
int offset = off; | |||
int blockStartOffset = offset; | |||
@@ -26,12 +26,12 @@ import java.io.OutputStream; | |||
* If the source stream doesn't end with a end of line, one will be added. This | |||
* is particularly useful in combination with the OutputStreamFunneler so each | |||
* funneled stream get its line. | |||
* | |||
* | |||
* @since Ant 1.8.3 | |||
*/ | |||
public class LineOrientedOutputStreamRedirector | |||
extends | |||
LineOrientedOutputStream { | |||
extends LineOrientedOutputStream { | |||
private OutputStream stream; | |||
// these should be in the ASCII range and hopefully are single bytes | |||
@@ -42,22 +42,26 @@ public class LineOrientedOutputStreamRedirector | |||
public LineOrientedOutputStreamRedirector(OutputStream stream) { | |||
this.stream = stream; | |||
} | |||
protected void processLine(byte[] b) throws IOException { | |||
@Override | |||
protected void processLine(byte[] b) throws IOException { | |||
stream.write(b); | |||
stream.write(EOL); | |||
} | |||
protected void processLine(String line) throws IOException { | |||
@Override | |||
protected void processLine(String line) throws IOException { | |||
stream.write((line + System.getProperty("line.separator")).getBytes()); | |||
} | |||
public void close() throws IOException { | |||
@Override | |||
public void close() throws IOException { | |||
super.close(); | |||
stream.close(); | |||
} | |||
public void flush() throws IOException { | |||
@Override | |||
public void flush() throws IOException { | |||
super.flush(); | |||
stream.flush(); | |||
} | |||
@@ -88,10 +88,10 @@ public class ResourceUtils { | |||
* copied or processed, because the targets are out of date or do | |||
* not exist. | |||
*/ | |||
public static Resource[] selectOutOfDateSources(ProjectComponent logTo, | |||
Resource[] source, | |||
FileNameMapper mapper, | |||
ResourceFactory targets) { | |||
public static Resource[] selectOutOfDateSources(final ProjectComponent logTo, | |||
final Resource[] source, | |||
final FileNameMapper mapper, | |||
final ResourceFactory targets) { | |||
return selectOutOfDateSources(logTo, source, mapper, targets, | |||
FILE_UTILS.getFileTimestampGranularity()); | |||
} | |||
@@ -113,14 +113,14 @@ public class ResourceUtils { | |||
* not exist. | |||
* @since Ant 1.6.2 | |||
*/ | |||
public static Resource[] selectOutOfDateSources(ProjectComponent logTo, | |||
Resource[] source, | |||
FileNameMapper mapper, | |||
ResourceFactory targets, | |||
long granularity) { | |||
Union u = new Union(); | |||
public static Resource[] selectOutOfDateSources(final ProjectComponent logTo, | |||
final Resource[] source, | |||
final FileNameMapper mapper, | |||
final ResourceFactory targets, | |||
final long granularity) { | |||
final Union u = new Union(); | |||
u.addAll(Arrays.asList(source)); | |||
ResourceCollection rc | |||
final ResourceCollection rc | |||
= selectOutOfDateSources(logTo, u, mapper, targets, granularity); | |||
return rc.size() == 0 ? new Resource[0] : ((Union) rc).listResources(); | |||
} | |||
@@ -137,18 +137,20 @@ public class ResourceUtils { | |||
* @return ResourceCollection. | |||
* @since Ant 1.7 | |||
*/ | |||
public static ResourceCollection selectOutOfDateSources(ProjectComponent logTo, | |||
ResourceCollection source, | |||
FileNameMapper mapper, | |||
ResourceFactory targets, | |||
public static ResourceCollection selectOutOfDateSources(final ProjectComponent logTo, | |||
final ResourceCollection source, | |||
final FileNameMapper mapper, | |||
final ResourceFactory targets, | |||
final long granularity) { | |||
logFuture(logTo, source, granularity); | |||
ResourceSelectorProvider p = | |||
final ResourceSelectorProvider p = | |||
new ResourceSelectorProvider() { | |||
public ResourceSelector | |||
@Override | |||
public ResourceSelector | |||
getTargetSelectorForSource(final Resource sr) { | |||
return new ResourceSelector() { | |||
public boolean isSelected(Resource target) { | |||
@Override | |||
public boolean isSelected(final Resource target) { | |||
/* Extra I/O, probably wasted: | |||
if (target.isDirectory()) { | |||
return false; | |||
@@ -166,7 +168,7 @@ public class ResourceUtils { | |||
/** | |||
* Tells which sources should be reprocessed because the given | |||
* selector selects at least one target. | |||
* | |||
* | |||
* @param logTo where to send (more or less) interesting output. | |||
* @param source ResourceCollection. | |||
* @param mapper filename mapper indicating how to find the target Resources. | |||
@@ -177,19 +179,19 @@ public class ResourceUtils { | |||
* @return ResourceCollection. | |||
* @since Ant 1.8.0 | |||
*/ | |||
public static ResourceCollection selectSources(ProjectComponent logTo, | |||
public static ResourceCollection selectSources(final ProjectComponent logTo, | |||
ResourceCollection source, | |||
FileNameMapper mapper, | |||
ResourceFactory targets, | |||
ResourceSelectorProvider selector) { | |||
final FileNameMapper mapper, | |||
final ResourceFactory targets, | |||
final ResourceSelectorProvider selector) { | |||
if (source.size() == 0) { | |||
logTo.log("No sources found.", Project.MSG_VERBOSE); | |||
return Resources.NONE; | |||
} | |||
source = Union.getInstance(source); | |||
Union result = new Union(); | |||
for (Resource sr : source) { | |||
final Union result = new Union(); | |||
for (final Resource sr : source) { | |||
String srName = sr.getName(); | |||
srName = srName == null | |||
? srName : srName.replace('/', File.separatorChar); | |||
@@ -197,7 +199,7 @@ public class ResourceUtils { | |||
String[] targetnames = null; | |||
try { | |||
targetnames = mapper.mapFileName(srName); | |||
} catch (Exception e) { | |||
} catch (final Exception e) { | |||
logTo.log("Caught " + e + " mapping resource " + sr, | |||
Project.MSG_VERBOSE); | |||
} | |||
@@ -211,18 +213,18 @@ public class ResourceUtils { | |||
targetnames[i] = "(no name)"; | |||
} | |||
} | |||
Union targetColl = new Union(); | |||
final Union targetColl = new Union(); | |||
for (int i = 0; i < targetnames.length; i++) { | |||
targetColl.add(targets.getResource( | |||
targetnames[i].replace(File.separatorChar, '/'))); | |||
} | |||
//find the out-of-date targets: | |||
Restrict r = new Restrict(); | |||
final Restrict r = new Restrict(); | |||
r.add(selector.getTargetSelectorForSource(sr)); | |||
r.add(targetColl); | |||
if (r.size() > 0) { | |||
result.add(sr); | |||
Resource t = r.iterator().next(); | |||
final Resource t = r.iterator().next(); | |||
logTo.log(sr.getName() + " added as " + t.getName() | |||
+ (t.isExists() ? " is outdated." : " doesn\'t exist."), | |||
Project.MSG_VERBOSE); | |||
@@ -250,7 +252,7 @@ public class ResourceUtils { | |||
* | |||
* @since Ant 1.7 | |||
*/ | |||
public static void copyResource(Resource source, Resource dest) throws IOException { | |||
public static void copyResource(final Resource source, final Resource dest) throws IOException { | |||
copyResource(source, dest, null); | |||
} | |||
@@ -268,7 +270,7 @@ public class ResourceUtils { | |||
* | |||
* @since Ant 1.7 | |||
*/ | |||
public static void copyResource(Resource source, Resource dest, Project project) | |||
public static void copyResource(final Resource source, final Resource dest, final Project project) | |||
throws IOException { | |||
copyResource(source, dest, null, null, false, | |||
false, null, null, project); | |||
@@ -301,11 +303,11 @@ public class ResourceUtils { | |||
* | |||
* @since Ant 1.7 | |||
*/ | |||
public static void copyResource(Resource source, Resource dest, | |||
FilterSetCollection filters, Vector filterChains, | |||
boolean overwrite, boolean preserveLastModified, | |||
String inputEncoding, String outputEncoding, | |||
Project project) | |||
public static void copyResource(final Resource source, final Resource dest, | |||
final FilterSetCollection filters, final Vector filterChains, | |||
final boolean overwrite, final boolean preserveLastModified, | |||
final String inputEncoding, final String outputEncoding, | |||
final Project project) | |||
throws IOException { | |||
copyResource(source, dest, filters, filterChains, overwrite, preserveLastModified, false, inputEncoding, outputEncoding, project); | |||
} | |||
@@ -338,12 +340,12 @@ public class ResourceUtils { | |||
* | |||
* @since Ant 1.8 | |||
*/ | |||
public static void copyResource(Resource source, Resource dest, | |||
FilterSetCollection filters, Vector filterChains, | |||
boolean overwrite, boolean preserveLastModified, | |||
boolean append, | |||
String inputEncoding, String outputEncoding, | |||
Project project) | |||
public static void copyResource(final Resource source, final Resource dest, | |||
final FilterSetCollection filters, final Vector filterChains, | |||
final boolean overwrite, final boolean preserveLastModified, | |||
final boolean append, | |||
final String inputEncoding, final String outputEncoding, | |||
final Project project) | |||
throws IOException { | |||
copyResource(source, dest, filters, filterChains, overwrite, | |||
preserveLastModified, append, inputEncoding, | |||
@@ -378,12 +380,12 @@ public class ResourceUtils { | |||
* | |||
* @since Ant 1.8.2 | |||
*/ | |||
public static void copyResource(Resource source, Resource dest, | |||
FilterSetCollection filters, Vector filterChains, | |||
boolean overwrite, boolean preserveLastModified, | |||
boolean append, | |||
String inputEncoding, String outputEncoding, | |||
Project project, boolean force) | |||
public static void copyResource(final Resource source, final Resource dest, | |||
final FilterSetCollection filters, final Vector filterChains, | |||
final boolean overwrite, final boolean preserveLastModified, | |||
final boolean append, | |||
final String inputEncoding, final String outputEncoding, | |||
final Project project, final boolean force) | |||
throws IOException { | |||
if (!(overwrite || SelectorUtils.isOutOfDate(source, dest, FileUtils.getFileUtils() | |||
.getFileTimestampGranularity()))) { | |||
@@ -429,12 +431,12 @@ public class ResourceUtils { | |||
boolean copied = false; | |||
if (source.as(FileProvider.class) != null | |||
&& destFile != null && !append) { | |||
File sourceFile = | |||
final File sourceFile = | |||
source.as(FileProvider.class).getFile(); | |||
try { | |||
copyUsingFileChannels(sourceFile, destFile); | |||
copied = true; | |||
} catch (IOException ex) { | |||
} catch (final IOException ex) { | |||
project.log("Attempt to copy " + sourceFile | |||
+ " to " + destFile + " using NIO Channels" | |||
+ " failed due to '" + ex.getMessage() | |||
@@ -447,7 +449,7 @@ public class ResourceUtils { | |||
} | |||
} | |||
if (preserveLastModified) { | |||
Touchable t = dest.as(Touchable.class); | |||
final Touchable t = dest.as(Touchable.class); | |||
if (t != null) { | |||
setLastModified(t, source.getLastModified()); | |||
} | |||
@@ -464,7 +466,7 @@ public class ResourceUtils { | |||
* if this is -1, the current time is used. | |||
* @since Ant 1.7 | |||
*/ | |||
public static void setLastModified(Touchable t, long time) { | |||
public static void setLastModified(final Touchable t, final long time) { | |||
t.touch((time < 0) ? System.currentTimeMillis() : time); | |||
} | |||
@@ -481,7 +483,7 @@ public class ResourceUtils { | |||
* @throws IOException if the Resources cannot be read. | |||
* @since Ant 1.7 | |||
*/ | |||
public static boolean contentEquals(Resource r1, Resource r2, boolean text) throws IOException { | |||
public static boolean contentEquals(final Resource r1, final Resource r2, final boolean text) throws IOException { | |||
if (r1.isExists() != r2.isExists()) { | |||
return false; | |||
} | |||
@@ -499,8 +501,8 @@ public class ResourceUtils { | |||
return true; | |||
} | |||
if (!text) { | |||
long s1 = r1.getSize(); | |||
long s2 = r2.getSize(); | |||
final long s1 = r1.getSize(); | |||
final long s2 = r2.getSize(); | |||
if (s1 != Resource.UNKNOWN_SIZE && s2 != Resource.UNKNOWN_SIZE | |||
&& s1 != s2) { | |||
return false; | |||
@@ -522,20 +524,20 @@ public class ResourceUtils { | |||
* @throws IOException if the Resources cannot be read. | |||
* @since Ant 1.7 | |||
*/ | |||
public static int compareContent(Resource r1, Resource r2, boolean text) throws IOException { | |||
public static int compareContent(final Resource r1, final Resource r2, final boolean text) throws IOException { | |||
if (r1.equals(r2)) { | |||
return 0; | |||
} | |||
boolean e1 = r1.isExists(); | |||
boolean e2 = r2.isExists(); | |||
final boolean e1 = r1.isExists(); | |||
final boolean e2 = r2.isExists(); | |||
if (!(e1 || e2)) { | |||
return 0; | |||
} | |||
if (e1 != e2) { | |||
return e1 ? 1 : -1; | |||
} | |||
boolean d1 = r1.isDirectory(); | |||
boolean d2 = r2.isDirectory(); | |||
final boolean d1 = r1.isDirectory(); | |||
final boolean d2 = r2.isDirectory(); | |||
if (d1 && d2) { | |||
return 0; | |||
} | |||
@@ -554,11 +556,11 @@ public class ResourceUtils { | |||
* FileResource with fileProvider's file. | |||
* @since Ant 1.8 | |||
*/ | |||
public static FileResource asFileResource(FileProvider fileProvider) { | |||
public static FileResource asFileResource(final FileProvider fileProvider) { | |||
if (fileProvider instanceof FileResource || fileProvider == null) { | |||
return (FileResource) fileProvider; | |||
} | |||
FileResource result = new FileResource(fileProvider.getFile()); | |||
final FileResource result = new FileResource(fileProvider.getFile()); | |||
result.setProject(Project.getProject(fileProvider)); | |||
return result; | |||
} | |||
@@ -578,7 +580,7 @@ public class ResourceUtils { | |||
* @throws IOException if the Resources cannot be read. | |||
* @since Ant 1.7 | |||
*/ | |||
private static int binaryCompare(Resource r1, Resource r2) throws IOException { | |||
private static int binaryCompare(final Resource r1, final Resource r2) throws IOException { | |||
InputStream in1 = null; | |||
InputStream in2 = null; | |||
try { | |||
@@ -586,7 +588,7 @@ public class ResourceUtils { | |||
in2 = new BufferedInputStream(r2.getInputStream()); | |||
for (int b1 = in1.read(); b1 != -1; b1 = in1.read()) { | |||
int b2 = in2.read(); | |||
final int b2 = in2.read(); | |||
if (b1 != b2) { | |||
return b1 > b2 ? 1 : -1; | |||
} | |||
@@ -608,7 +610,7 @@ public class ResourceUtils { | |||
* @throws IOException if the Resources cannot be read. | |||
* @since Ant 1.7 | |||
*/ | |||
private static int textCompare(Resource r1, Resource r2) throws IOException { | |||
private static int textCompare(final Resource r1, final Resource r2) throws IOException { | |||
BufferedReader in1 = null; | |||
BufferedReader in2 = null; | |||
try { | |||
@@ -617,7 +619,7 @@ public class ResourceUtils { | |||
String expected = in1.readLine(); | |||
while (expected != null) { | |||
String actual = in2.readLine(); | |||
final String actual = in2.readLine(); | |||
if (!expected.equals(actual)) { | |||
if (actual == null) { | |||
return 1; | |||
@@ -640,27 +642,27 @@ public class ResourceUtils { | |||
* @param granularity the timestamp granularity to use. | |||
* @since Ant 1.7 | |||
*/ | |||
private static void logFuture(ProjectComponent logTo, | |||
ResourceCollection rc, long granularity) { | |||
long now = System.currentTimeMillis() + granularity; | |||
Date sel = new Date(); | |||
private static void logFuture(final ProjectComponent logTo, | |||
final ResourceCollection rc, final long granularity) { | |||
final long now = System.currentTimeMillis() + granularity; | |||
final Date sel = new Date(); | |||
sel.setMillis(now); | |||
sel.setWhen(TimeComparison.AFTER); | |||
Restrict future = new Restrict(); | |||
final Restrict future = new Restrict(); | |||
future.add(sel); | |||
future.add(rc); | |||
for (Resource r : future) { | |||
for (final Resource r : future) { | |||
logTo.log("Warning: " + r.getName() + " modified in the future.", Project.MSG_WARN); | |||
} | |||
} | |||
private static void copyWithFilterSets(Resource source, Resource dest, | |||
FilterSetCollection filters, | |||
Vector filterChains, | |||
boolean filterChainsAvailable, | |||
boolean append, String inputEncoding, | |||
String outputEncoding, | |||
Project project) | |||
private static void copyWithFilterSets(final Resource source, final Resource dest, | |||
final FilterSetCollection filters, | |||
final Vector filterChains, | |||
final boolean filterChainsAvailable, | |||
final boolean append, final String inputEncoding, | |||
final String outputEncoding, | |||
final Project project) | |||
throws IOException { | |||
BufferedReader in = null; | |||
BufferedWriter out = null; | |||
@@ -673,7 +675,7 @@ public class ResourceUtils { | |||
inputEncoding); | |||
} | |||
in = new BufferedReader(isr); | |||
OutputStream os = getOutputStream(dest, append, project); | |||
final OutputStream os = getOutputStream(dest, append, project); | |||
OutputStreamWriter osw; | |||
if (outputEncoding == null) { | |||
osw = new OutputStreamWriter(os); | |||
@@ -682,15 +684,15 @@ public class ResourceUtils { | |||
} | |||
out = new BufferedWriter(osw); | |||
if (filterChainsAvailable) { | |||
ChainReaderHelper crh = new ChainReaderHelper(); | |||
final ChainReaderHelper crh = new ChainReaderHelper(); | |||
crh.setBufferSize(FileUtils.BUF_SIZE); | |||
crh.setPrimaryReader(in); | |||
crh.setFilterChains(filterChains); | |||
crh.setProject(project); | |||
Reader rdr = crh.getAssembledReader(); | |||
final Reader rdr = crh.getAssembledReader(); | |||
in = new BufferedReader(rdr); | |||
} | |||
LineTokenizer lineTokenizer = new LineTokenizer(); | |||
final LineTokenizer lineTokenizer = new LineTokenizer(); | |||
lineTokenizer.setIncludeDelims(true); | |||
String newline = null; | |||
String line = lineTokenizer.getToken(in); | |||
@@ -711,14 +713,14 @@ public class ResourceUtils { | |||
} | |||
} | |||
private static void copyWithFilterChainsOrTranscoding(Resource source, | |||
Resource dest, | |||
Vector filterChains, | |||
boolean filterChainsAvailable, | |||
boolean append, | |||
String inputEncoding, | |||
String outputEncoding, | |||
Project project) | |||
private static void copyWithFilterChainsOrTranscoding(final Resource source, | |||
final Resource dest, | |||
final Vector filterChains, | |||
final boolean filterChainsAvailable, | |||
final boolean append, | |||
final String inputEncoding, | |||
final String outputEncoding, | |||
final Project project) | |||
throws IOException { | |||
BufferedReader in = null; | |||
BufferedWriter out = null; | |||
@@ -731,7 +733,7 @@ public class ResourceUtils { | |||
inputEncoding); | |||
} | |||
in = new BufferedReader(isr); | |||
OutputStream os = getOutputStream(dest, append, project); | |||
final OutputStream os = getOutputStream(dest, append, project); | |||
OutputStreamWriter osw; | |||
if (outputEncoding == null) { | |||
osw = new OutputStreamWriter(os); | |||
@@ -740,17 +742,17 @@ public class ResourceUtils { | |||
} | |||
out = new BufferedWriter(osw); | |||
if (filterChainsAvailable) { | |||
ChainReaderHelper crh = new ChainReaderHelper(); | |||
final ChainReaderHelper crh = new ChainReaderHelper(); | |||
crh.setBufferSize(FileUtils.BUF_SIZE); | |||
crh.setPrimaryReader(in); | |||
crh.setFilterChains(filterChains); | |||
crh.setProject(project); | |||
Reader rdr = crh.getAssembledReader(); | |||
final Reader rdr = crh.getAssembledReader(); | |||
in = new BufferedReader(rdr); | |||
} | |||
char[] buffer = new char[FileUtils.BUF_SIZE]; | |||
final char[] buffer = new char[FileUtils.BUF_SIZE]; | |||
while (true) { | |||
int nRead = in.read(buffer, 0, buffer.length); | |||
final int nRead = in.read(buffer, 0, buffer.length); | |||
if (nRead == -1) { | |||
break; | |||
} | |||
@@ -762,11 +764,11 @@ public class ResourceUtils { | |||
} | |||
} | |||
private static void copyUsingFileChannels(File sourceFile, | |||
File destFile) | |||
private static void copyUsingFileChannels(final File sourceFile, | |||
final File destFile) | |||
throws IOException { | |||
File parent = destFile.getParentFile(); | |||
final File parent = destFile.getParentFile(); | |||
if (parent != null && !parent.isDirectory() | |||
&& !(parent.mkdirs() || parent.isDirectory())) { | |||
throw new IOException("failed to create the parent directory" | |||
@@ -781,14 +783,14 @@ public class ResourceUtils { | |||
try { | |||
in = new FileInputStream(sourceFile); | |||
out = new FileOutputStream(destFile); | |||
srcChannel = in.getChannel(); | |||
destChannel = out.getChannel(); | |||
long position = 0; | |||
long count = srcChannel.size(); | |||
final long count = srcChannel.size(); | |||
while (position < count) { | |||
long chunk = Math.min(MAX_IO_CHUNK_SIZE, count - position); | |||
final long chunk = Math.min(MAX_IO_CHUNK_SIZE, count - position); | |||
position += | |||
destChannel.transferFrom(srcChannel, position, chunk); | |||
} | |||
@@ -800,8 +802,8 @@ public class ResourceUtils { | |||
} | |||
} | |||
private static void copyUsingStreams(Resource source, Resource dest, | |||
boolean append, Project project) | |||
private static void copyUsingStreams(final Resource source, final Resource dest, | |||
final boolean append, final Project project) | |||
throws IOException { | |||
InputStream in = null; | |||
OutputStream out = null; | |||
@@ -809,7 +811,7 @@ public class ResourceUtils { | |||
in = source.getInputStream(); | |||
out = getOutputStream(dest, append, project); | |||
byte[] buffer = new byte[FileUtils.BUF_SIZE]; | |||
final byte[] buffer = new byte[FileUtils.BUF_SIZE]; | |||
int count = 0; | |||
do { | |||
out.write(buffer, 0, count); | |||
@@ -821,10 +823,10 @@ public class ResourceUtils { | |||
} | |||
} | |||
private static OutputStream getOutputStream(Resource resource, boolean append, Project project) | |||
private static OutputStream getOutputStream(final Resource resource, final boolean append, final Project project) | |||
throws IOException { | |||
if (append) { | |||
Appendable a = resource.as(Appendable.class); | |||
final Appendable a = resource.as(Appendable.class); | |||
if (a != null) { | |||
return a.getAppendOutputStream(); | |||
} | |||
@@ -834,7 +836,7 @@ public class ResourceUtils { | |||
return resource.getOutputStream(); | |||
} | |||
public static interface ResourceSelectorProvider { | |||
public interface ResourceSelectorProvider { | |||
ResourceSelector getTargetSelectorForSource(Resource source); | |||
} | |||
@@ -842,7 +844,9 @@ public class ResourceUtils { | |||
* @since Ant 1.9.4 | |||
*/ | |||
public static class ReadOnlyTargetFileException extends IOException { | |||
public ReadOnlyTargetFileException(File destFile) { | |||
private static final long serialVersionUID = 1L; | |||
public ReadOnlyTargetFileException(final File destFile) { | |||
super("can't write to read-only destination file " + destFile); | |||
} | |||
} | |||
@@ -171,13 +171,14 @@ public class SymbolicLinkUtils { | |||
* @return true if the file is a broken symbolic link. | |||
* @throws IOException on error. | |||
*/ | |||
public boolean isDanglingSymbolicLink(File parent, String name) | |||
public boolean isDanglingSymbolicLink(File parent, String name) | |||
throws IOException { | |||
File f = new File(parent, name); | |||
if (!f.exists()) { | |||
final String localName = f.getName(); | |||
String[] c = parent.list(new FilenameFilter() { | |||
public boolean accept(File d, String n) { | |||
@Override | |||
public boolean accept(File d, String n) { | |||
return localName.equals(n); | |||
} | |||
}); | |||
@@ -41,6 +41,6 @@ public class UnicodeUtil { | |||
- s.length() + i, | |||
s.charAt(i)); | |||
} | |||
return unicodeBuf; | |||
return unicodeBuf; | |||
} | |||
} |