@@ -86,7 +86,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
/** | /** | ||||
* The name of the resource being searched for. | * The name of the resource being searched for. | ||||
*/ | */ | ||||
private String resourceName; | |||||
private final String resourceName; | |||||
/** | /** | ||||
* The index of the next classpath element to search. | * 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. | * @param name the name of the resource to search for. | ||||
*/ | */ | ||||
ResourceEnumeration(String name) { | |||||
ResourceEnumeration(final String name) { | |||||
this.resourceName = name; | this.resourceName = name; | ||||
this.pathElementsIndex = 0; | this.pathElementsIndex = 0; | ||||
findNextResource(); | findNextResource(); | ||||
@@ -119,7 +119,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* @return <code>true</code> if there are more elements in the | * @return <code>true</code> if there are more elements in the | ||||
* enumeration; <code>false</code> otherwise. | * enumeration; <code>false</code> otherwise. | ||||
*/ | */ | ||||
public boolean hasMoreElements() { | |||||
@Override | |||||
public boolean hasMoreElements() { | |||||
return (this.nextResource != null); | return (this.nextResource != null); | ||||
} | } | ||||
@@ -128,8 +129,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @return the next resource in the enumeration | * @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) { | if (ret == null) { | ||||
throw new NoSuchElementException(); | throw new NoSuchElementException(); | ||||
} | } | ||||
@@ -147,10 +149,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
URL url = null; | URL url = null; | ||||
while ((pathElementsIndex < pathComponents.size()) && (url == null)) { | while ((pathElementsIndex < pathComponents.size()) && (url == null)) { | ||||
try { | try { | ||||
File pathComponent = (File) pathComponents.elementAt(pathElementsIndex); | |||||
final File pathComponent = pathComponents.elementAt(pathElementsIndex); | |||||
url = getResourceURL(pathComponent, this.resourceName); | url = getResourceURL(pathComponent, this.resourceName); | ||||
pathElementsIndex++; | pathElementsIndex++; | ||||
} catch (BuildException e) { | |||||
} catch (final BuildException e) { | |||||
// ignore path elements which are not valid relative to the | // ignore path elements which are not valid relative to the | ||||
// project | // project | ||||
} | } | ||||
@@ -173,7 +175,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* The components of the classpath that the classloader searches | * The components of the classpath that the classloader searches | ||||
* for classes. | * 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. | * 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 | * loader regardless of whether the parent class loader is being searched | ||||
* first or not. | * 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 | * 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 | * regardless of whether the parent class loader is being searched first | ||||
* or not. | * 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 | * 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>(); | private Hashtable<File, JarFile> jarFiles = new Hashtable<File, JarFile>(); | ||||
/** Static map of jar file/time to manifest class-path entries */ | /** 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 | * The context loader saved when setting the thread's current | ||||
@@ -241,7 +244,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* belong. | * belong. | ||||
* @param classpath The classpath to use to load classes. | * @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); | setParent(parent); | ||||
setClassPath(classpath); | setClassPath(classpath); | ||||
setProject(project); | setProject(project); | ||||
@@ -265,7 +268,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* May be <code>null</code>, in which case no path | * May be <code>null</code>, in which case no path | ||||
* elements are set up to start with. | * elements are set up to start with. | ||||
*/ | */ | ||||
public AntClassLoader(Project project, Path classpath) { | |||||
public AntClassLoader(final Project project, final Path classpath) { | |||||
setParent(null); | setParent(null); | ||||
setProject(project); | setProject(project); | ||||
setClassPath(classpath); | setClassPath(classpath); | ||||
@@ -288,7 +291,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* load the a class through this loader. | * load the a class through this loader. | ||||
*/ | */ | ||||
public AntClassLoader( | 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); | this(project, classpath); | ||||
if (parent != null) { | if (parent != null) { | ||||
setParent(parent); | setParent(parent); | ||||
@@ -309,7 +312,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* classloader should be consulted before trying to | * classloader should be consulted before trying to | ||||
* load the a class through this loader. | * 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); | this(null, project, classpath, parentFirst); | ||||
} | } | ||||
@@ -326,7 +329,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* classloader should be consulted before trying to | * classloader should be consulted before trying to | ||||
* load the a class through this loader. | * load the a class through this loader. | ||||
*/ | */ | ||||
public AntClassLoader(ClassLoader parent, boolean parentFirst) { | |||||
public AntClassLoader(final ClassLoader parent, final boolean parentFirst) { | |||||
setParent(parent); | setParent(parent); | ||||
project = null; | project = null; | ||||
this.parentFirst = parentFirst; | this.parentFirst = parentFirst; | ||||
@@ -337,7 +340,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param project the project instance | * @param project the project instance | ||||
*/ | */ | ||||
public void setProject(Project project) { | |||||
public void setProject(final Project project) { | |||||
this.project = project; | this.project = project; | ||||
if (project != null) { | if (project != null) { | ||||
project.addBuildListener(this); | project.addBuildListener(this); | ||||
@@ -351,15 +354,15 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* @param classpath the search classpath consisting of directories and | * @param classpath the search classpath consisting of directories and | ||||
* jar/zip files. | * jar/zip files. | ||||
*/ | */ | ||||
public void setClassPath(Path classpath) { | |||||
public void setClassPath(final Path classpath) { | |||||
pathComponents.removeAllElements(); | pathComponents.removeAllElements(); | ||||
if (classpath != null) { | 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) { | for (int i = 0; i < pathElements.length; ++i) { | ||||
try { | try { | ||||
addPathElement(pathElements[i]); | addPathElement(pathElements[i]); | ||||
} catch (BuildException e) { | |||||
} catch (final BuildException e) { | |||||
// ignore path elements which are invalid | // ignore path elements which are invalid | ||||
// relative to the project | // relative to the project | ||||
} | } | ||||
@@ -373,7 +376,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param parent the parent class loader. | * @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; | 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 | * @param parentFirst if true, delegate initial class search to the parent | ||||
* classloader. | * classloader. | ||||
*/ | */ | ||||
public void setParentFirst(boolean parentFirst) { | |||||
public void setParentFirst(final boolean parentFirst) { | |||||
this.parentFirst = parentFirst; | this.parentFirst = parentFirst; | ||||
} | } | ||||
@@ -397,7 +400,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param priority The logging priority of the message. | * @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) { | if (project != null) { | ||||
project.log(message, priority); | 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 | * @exception BuildException if the given path element cannot be resolved | ||||
* against the project. | * 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); | pathElement); | ||||
try { | try { | ||||
addPathFile(pathComponent); | addPathFile(pathComponent); | ||||
} catch (IOException e) { | |||||
} catch (final IOException e) { | |||||
throw new BuildException(e); | throw new BuildException(e); | ||||
} | } | ||||
} | } | ||||
@@ -460,7 +463,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* their CLASSPATH entry in the manifest file. | * their CLASSPATH entry in the manifest file. | ||||
* @param file the jar file or directory to add. | * @param file the jar file or directory to add. | ||||
*/ | */ | ||||
public void addPathComponent(File file) { | |||||
public void addPathComponent(final File file) { | |||||
if (pathComponents.contains(file)) { | if (pathComponents.contains(file)) { | ||||
return; | return; | ||||
} | } | ||||
@@ -477,7 +480,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @throws IOException if data needed from the file cannot be read. | * @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)) { | if (!pathComponents.contains(pathComponent)) { | ||||
pathComponents.addElement(pathComponent); | pathComponents.addElement(pathComponent); | ||||
} | } | ||||
@@ -485,14 +488,14 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
return; | return; | ||||
} | } | ||||
String absPathPlusTimeAndLength = pathComponent.getAbsolutePath() | |||||
final String absPathPlusTimeAndLength = pathComponent.getAbsolutePath() | |||||
+ pathComponent.lastModified() + "-" + pathComponent.length(); | + pathComponent.lastModified() + "-" + pathComponent.length(); | ||||
String classpath = (String) pathMap.get(absPathPlusTimeAndLength); | |||||
String classpath = pathMap.get(absPathPlusTimeAndLength); | |||||
if (classpath == null) { | if (classpath == null) { | ||||
JarFile jarFile = null; | JarFile jarFile = null; | ||||
try { | try { | ||||
jarFile = new JarFile(pathComponent); | jarFile = new JarFile(pathComponent); | ||||
Manifest manifest = jarFile.getManifest(); | |||||
final Manifest manifest = jarFile.getManifest(); | |||||
if (manifest == null) { | if (manifest == null) { | ||||
return; | return; | ||||
} | } | ||||
@@ -510,19 +513,19 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
} | } | ||||
if (!"".equals(classpath)) { | 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()) { | 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")) { | if (!libraryURL.getProtocol().equals("file")) { | ||||
log("Skipping jar library " + classpathElement | log("Skipping jar library " + classpathElement | ||||
+ " since only relative URLs are supported by this" + " loader", | + " since only relative URLs are supported by this" + " loader", | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
continue; | 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)) { | if (libraryFile.exists() && !isInPath(libraryFile)) { | ||||
addPathFile(libraryFile); | addPathFile(libraryFile); | ||||
} | } | ||||
@@ -539,7 +542,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
public String getClasspath() { | public String getClasspath() { | ||||
final StringBuilder sb = new StringBuilder(); | final StringBuilder sb = new StringBuilder(); | ||||
boolean firstPass = true; | boolean firstPass = true; | ||||
Enumeration<File> componentEnum = pathComponents.elements(); | |||||
final Enumeration<File> componentEnum = pathComponents.elements(); | |||||
while (componentEnum.hasMoreElements()) { | while (componentEnum.hasMoreElements()) { | ||||
if (!firstPass) { | if (!firstPass) { | ||||
sb.append(System.getProperty("path.separator")); | 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 | * @param isolated Whether or not this classloader should run in | ||||
* isolated mode. | * isolated mode. | ||||
*/ | */ | ||||
public synchronized void setIsolated(boolean isolated) { | |||||
public synchronized void setIsolated(final boolean isolated) { | |||||
ignoreBase = isolated; | ignoreBase = isolated; | ||||
} | } | ||||
@@ -574,7 +577,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* @deprecated since 1.6.x. | * @deprecated since 1.6.x. | ||||
* Use Class.forName with initialize=true instead. | * 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 | // ***HACK*** We ask the VM to create an instance | ||||
// by voluntarily providing illegal arguments to force | // by voluntarily providing illegal arguments to force | ||||
// the VM to run the class' static initializer, while | // 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); | cons[0].newInstance((Object[]) strs); | ||||
// Expecting an exception to be thrown by this call: | // Expecting an exception to be thrown by this call: | ||||
// IllegalArgumentException: wrong number of Arguments | // IllegalArgumentException: wrong number of Arguments | ||||
} catch (Exception e) { | |||||
} catch (final Exception e) { | |||||
// Ignore - we are interested only in the side | // Ignore - we are interested only in the side | ||||
// effect - that of getting the static initializers | // effect - that of getting the static initializers | ||||
// invoked. As we do not want to call a valid | // 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. | * @param packageRoot The root of all packages to be included. | ||||
* Should not be <code>null</code>. | * Should not be <code>null</code>. | ||||
*/ | */ | ||||
public void addSystemPackageRoot(String packageRoot) { | |||||
public void addSystemPackageRoot(final String packageRoot) { | |||||
systemPackages.addElement(packageRoot + (packageRoot.endsWith(".") ? "" : ".")); | 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. | * @param packageRoot The root of all packages to be included. | ||||
* Should not be <code>null</code>. | * Should not be <code>null</code>. | ||||
*/ | */ | ||||
public void addLoaderPackageRoot(String packageRoot) { | |||||
public void addLoaderPackageRoot(final String packageRoot) { | |||||
loaderPackages.addElement(packageRoot + (packageRoot.endsWith(".") ? "" : ".")); | 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 | * @exception ClassNotFoundException if the requested class does not exist | ||||
* on this loader's classpath. | * 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); | log("force loading " + classname, Project.MSG_DEBUG); | ||||
Class<?> theClass = findLoadedClass(classname); | Class<?> theClass = findLoadedClass(classname); | ||||
@@ -675,7 +679,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* @exception ClassNotFoundException if the requested class does not exist | * @exception ClassNotFoundException if the requested class does not exist | ||||
* on this loader's classpath. | * 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); | log("force system loading " + classname, Project.MSG_DEBUG); | ||||
Class<?> theClass = findLoadedClass(classname); | 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 | * @return a stream to the required resource or <code>null</code> if the | ||||
* resource cannot be found on the loader's classpath. | * resource cannot be found on the loader's classpath. | ||||
*/ | */ | ||||
public InputStream getResourceAsStream(String name) { | |||||
@Override | |||||
public InputStream getResourceAsStream(final String name) { | |||||
InputStream resourceStream = null; | InputStream resourceStream = null; | ||||
if (isParentFirst(name)) { | if (isParentFirst(name)) { | ||||
resourceStream = loadBaseResource(name); | resourceStream = loadBaseResource(name); | ||||
@@ -712,7 +717,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
} | } | ||||
if (resourceStream == null && !isParentFirst(name)) { | if (resourceStream == null && !isParentFirst(name)) { | ||||
if (ignoreBase) { | if (ignoreBase) { | ||||
resourceStream = getRootLoader() == null ? null : getRootLoader().getResourceAsStream(name); | |||||
resourceStream = getRootLoader() == null | |||||
? null | |||||
: getRootLoader().getResourceAsStream(name); | |||||
} else { | } else { | ||||
resourceStream = loadBaseResource(name); | 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 | * @return a stream to the required resource or <code>null</code> if | ||||
* the resource cannot be found on the loader's classpath. | * 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 | // we need to search the components of the path to see if we can | ||||
// find the class we want. | // find the class we want. | ||||
InputStream stream = null; | InputStream stream = null; | ||||
Enumeration<File> e = pathComponents.elements(); | |||||
final Enumeration<File> e = pathComponents.elements(); | |||||
while (e.hasMoreElements() && stream == null) { | while (e.hasMoreElements() && stream == null) { | ||||
File pathComponent = e.nextElement(); | |||||
final File pathComponent = e.nextElement(); | |||||
stream = getResourceStream(pathComponent, name); | stream = getResourceStream(pathComponent, name); | ||||
} | } | ||||
return stream; | 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 | * @return a stream to the named resource, or <code>null</code> if | ||||
* the resource cannot be found. | * 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); | 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 | * @return a stream to the required resource or <code>null</code> if | ||||
* the resource cannot be found in the given file. | * 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 { | try { | ||||
JarFile jarFile = (JarFile) jarFiles.get(file); | |||||
JarFile jarFile = jarFiles.get(file); | |||||
if (jarFile == null && file.isDirectory()) { | if (jarFile == null && file.isDirectory()) { | ||||
File resource = new File(file, resourceName); | |||||
final File resource = new File(file, resourceName); | |||||
if (resource.exists()) { | if (resource.exists()) { | ||||
return new FileInputStream(resource); | return new FileInputStream(resource); | ||||
} | } | ||||
@@ -793,14 +800,14 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
} | } | ||||
//to eliminate a race condition, retrieve the entry | //to eliminate a race condition, retrieve the entry | ||||
//that is in the hash table under that filename | //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) { | if (entry != null) { | ||||
return jarFile.getInputStream(entry); | return jarFile.getInputStream(entry); | ||||
} | } | ||||
} | } | ||||
} catch (Exception e) { | |||||
} catch (final Exception e) { | |||||
log("Ignoring Exception " + e.getClass().getName() + ": " + e.getMessage() | log("Ignoring Exception " + e.getClass().getName() + ": " + e.getMessage() | ||||
+ " reading resource " + resourceName + " from " + file, Project.MSG_VERBOSE); | + " 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 | * @return whether or not the parent classloader should be checked for a | ||||
* resource before this one is. | * resource before this one is. | ||||
*/ | */ | ||||
private boolean isParentFirst(String resourceName) { | |||||
private boolean isParentFirst(final String resourceName) { | |||||
// default to the global setting and then see | // default to the global setting and then see | ||||
// if this class belongs to a package which has been | // if this class belongs to a package which has been | ||||
// designated to use a specific loader first | // designated to use a specific loader first | ||||
@@ -830,15 +837,15 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
boolean useParentFirst = parentFirst; | 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)) { | if (resourceName.startsWith(packageName)) { | ||||
useParentFirst = true; | useParentFirst = true; | ||||
break; | 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)) { | if (resourceName.startsWith(packageName)) { | ||||
useParentFirst = false; | useParentFirst = false; | ||||
break; | break; | ||||
@@ -871,7 +878,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* resource could not be found or the caller doesn't have | * resource could not be found or the caller doesn't have | ||||
* adequate privileges to get the resource. | * 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 need to search the components of the path to see if | ||||
// we can find the class we want. | // we can find the class we want. | ||||
URL url = null; | URL url = null; | ||||
@@ -883,9 +891,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
} else { | } else { | ||||
// try and load from this loader if the parent either didn't find | // try and load from this loader if the parent either didn't find | ||||
// it or wasn't consulted. | // it or wasn't consulted. | ||||
Enumeration<File> e = pathComponents.elements(); | |||||
final Enumeration<File> e = pathComponents.elements(); | |||||
while (e.hasMoreElements() && url == null) { | while (e.hasMoreElements() && url == null) { | ||||
File pathComponent = e.nextElement(); | |||||
final File pathComponent = e.nextElement(); | |||||
url = getResourceURL(pathComponent, name); | url = getResourceURL(pathComponent, name); | ||||
if (url != null) { | if (url != null) { | ||||
log("Resource " + name + " loaded from ant loader", Project.MSG_DEBUG); | 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 | * <p>Would override getResources if that wasn't final in Java | ||||
* 1.4.</p> | * 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 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public Enumeration<URL> getNamedResources(String name) | |||||
public Enumeration<URL> getNamedResources(final String name) | |||||
throws IOException { | throws IOException { | ||||
return findResources(name, false); | return findResources(name, false); | ||||
} | } | ||||
@@ -933,7 +945,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* @return an enumeration of URLs for the resources | * @return an enumeration of URLs for the resources | ||||
* @exception IOException if I/O errors occurs (can't happen) | * @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); | return findResources(name, true); | ||||
} | } | ||||
@@ -949,10 +962,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* @return an enumeration of URLs for the resources | * @return an enumeration of URLs for the resources | ||||
* @exception IOException if I/O errors occurs (can't happen) | * @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 { | throws IOException { | ||||
Enumeration<URL> mine = new ResourceEnumeration(name); | |||||
final Enumeration<URL> mine = new ResourceEnumeration(name); | |||||
Enumeration<URL> base; | Enumeration<URL> base; | ||||
if (parent != null && (!parentHasBeenSearched || parent != getParent())) { | if (parent != null && (!parentHasBeenSearched || parent != getParent())) { | ||||
// Delegate to the parent: | // 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 | * @return a stream to the required resource or <code>null</code> if the | ||||
* resource cannot be found in the given file object. | * 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 { | try { | ||||
JarFile jarFile = (JarFile) jarFiles.get(file); | |||||
JarFile jarFile = jarFiles.get(file); | |||||
if (jarFile == null && file.isDirectory()) { | if (jarFile == null && file.isDirectory()) { | ||||
File resource = new File(file, resourceName); | |||||
final File resource = new File(file, resourceName); | |||||
if (resource.exists()) { | if (resource.exists()) { | ||||
try { | try { | ||||
return FILE_UTILS.getFileURL(resource); | return FILE_UTILS.getFileURL(resource); | ||||
} catch (MalformedURLException ex) { | |||||
} catch (final MalformedURLException ex) { | |||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
@@ -1006,7 +1019,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
if (jarFile == null) { | if (jarFile == null) { | ||||
if (file.exists()) { | if (file.exists()) { | ||||
if (!isZip(file)) { | if (!isZip(file)) { | ||||
String msg = "CLASSPATH element " + file | |||||
final String msg = "CLASSPATH element " + file | |||||
+ " is not a JAR."; | + " is not a JAR."; | ||||
log(msg, Project.MSG_WARN); | log(msg, Project.MSG_WARN); | ||||
System.err.println(msg); | System.err.println(msg); | ||||
@@ -1018,19 +1031,19 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
return null; | return null; | ||||
} | } | ||||
// potential race-condition | // 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) { | if (entry != null) { | ||||
try { | try { | ||||
return new URL("jar:" + FILE_UTILS.getFileURL(file) + "!/" + entry); | return new URL("jar:" + FILE_UTILS.getFileURL(file) + "!/" + entry); | ||||
} catch (MalformedURLException ex) { | |||||
} catch (final MalformedURLException ex) { | |||||
return null; | 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); | log(msg + e, Project.MSG_WARN); | ||||
System.err.println(msg); | System.err.println(msg); | ||||
e.printStackTrace(); | 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 | * on the system classpath (when not in isolated mode) or this loader's | ||||
* classpath. | * classpath. | ||||
*/ | */ | ||||
protected synchronized Class<?> loadClass(String classname, boolean resolve) | |||||
@Override | |||||
protected synchronized Class<?> loadClass(final String classname, final boolean resolve) | |||||
throws ClassNotFoundException { | throws ClassNotFoundException { | ||||
// 'sync' is needed - otherwise 2 threads can load the same class | // 'sync' is needed - otherwise 2 threads can load the same class | ||||
// twice, resulting in LinkageError: duplicated class definition. | // twice, resulting in LinkageError: duplicated class definition. | ||||
@@ -1073,7 +1087,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
theClass = findBaseClass(classname); | theClass = findBaseClass(classname); | ||||
log("Class " + classname + " loaded from parent loader " + "(parentFirst)", | log("Class " + classname + " loaded from parent loader " + "(parentFirst)", | ||||
Project.MSG_DEBUG); | Project.MSG_DEBUG); | ||||
} catch (ClassNotFoundException cnfe) { | |||||
} catch (final ClassNotFoundException cnfe) { | |||||
theClass = findClass(classname); | theClass = findClass(classname); | ||||
log("Class " + classname + " loaded from ant loader " + "(parentFirst)", | log("Class " + classname + " loaded from ant loader " + "(parentFirst)", | ||||
Project.MSG_DEBUG); | Project.MSG_DEBUG); | ||||
@@ -1082,7 +1096,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
try { | try { | ||||
theClass = findClass(classname); | theClass = findClass(classname); | ||||
log("Class " + classname + " loaded from ant loader", Project.MSG_DEBUG); | log("Class " + classname + " loaded from ant loader", Project.MSG_DEBUG); | ||||
} catch (ClassNotFoundException cnfe) { | |||||
} catch (final ClassNotFoundException cnfe) { | |||||
if (ignoreBase) { | if (ignoreBase) { | ||||
throw cnfe; | throw cnfe; | ||||
} | } | ||||
@@ -1105,7 +1119,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @return the classname in filesystem format (eg java/lang/Integer.class) | * @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"; | return classname.replace('.', '/') + ".class"; | ||||
} | } | ||||
@@ -1122,15 +1136,15 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @throws IOException if the class data cannot be read. | * @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 { | throws IOException { | ||||
definePackage(container, classname); | 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, | getCertificates(container, | ||||
classResource)); | classResource)); | ||||
ProtectionDomain classesPd = | |||||
final ProtectionDomain classesPd = | |||||
new ProtectionDomain(src, currentPd.getPermissions(), | new ProtectionDomain(src, currentPd.getPermissions(), | ||||
this, | this, | ||||
currentPd.getPrincipals()); | currentPd.getPrincipals()); | ||||
@@ -1148,18 +1162,18 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* @exception IOException if the package information cannot be read from the | * @exception IOException if the package information cannot be read from the | ||||
* container. | * 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) { | if (classIndex == -1) { | ||||
return; | return; | ||||
} | } | ||||
String packageName = className.substring(0, classIndex); | |||||
final String packageName = className.substring(0, classIndex); | |||||
if (getPackage(packageName) != null) { | if (getPackage(packageName) != null) { | ||||
// already defined | // already defined | ||||
return; | return; | ||||
} | } | ||||
// define the package now | // define the package now | ||||
Manifest manifest = getJarManifest(container); | |||||
final Manifest manifest = getJarManifest(container); | |||||
if (manifest == null) { | if (manifest == null) { | ||||
definePackage(packageName, null, null, null, null, null, null, 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. | * @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()) { | if (container.isDirectory()) { | ||||
return null; | return null; | ||||
} | } | ||||
JarFile jarFile = (JarFile) jarFiles.get(container); | |||||
final JarFile jarFile = jarFiles.get(container); | |||||
if (jarFile == null) { | if (jarFile == null) { | ||||
return null; | return null; | ||||
} | } | ||||
@@ -1201,16 +1215,16 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @exception IOException if the manifest cannot be read. | * @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 { | throws IOException { | ||||
if (container.isDirectory()) { | if (container.isDirectory()) { | ||||
return null; | return null; | ||||
} | } | ||||
JarFile jarFile = (JarFile) jarFiles.get(container); | |||||
final JarFile jarFile = jarFiles.get(container); | |||||
if (jarFile == null) { | if (jarFile == null) { | ||||
return null; | return null; | ||||
} | } | ||||
JarEntry ent = jarFile.getJarEntry(entry); | |||||
final JarEntry ent = jarFile.getJarEntry(entry); | |||||
return ent == null ? null : ent.getCertificates(); | 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 packageName the name of the package being defined. | ||||
* @param manifest the jar's manifest | * @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 specificationTitle = null; | ||||
String specificationVendor = null; | String specificationVendor = null; | ||||
@@ -1234,7 +1248,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
String sealedString = null; | String sealedString = null; | ||||
URL sealBase = null; | URL sealBase = null; | ||||
Attributes sectionAttributes = manifest.getAttributes(sectionName); | |||||
final Attributes sectionAttributes = manifest.getAttributes(sectionName); | |||||
if (sectionAttributes != null) { | if (sectionAttributes != null) { | ||||
specificationTitle = sectionAttributes.getValue(Name.SPECIFICATION_TITLE); | specificationTitle = sectionAttributes.getValue(Name.SPECIFICATION_TITLE); | ||||
specificationVendor = sectionAttributes.getValue(Name.SPECIFICATION_VENDOR); | specificationVendor = sectionAttributes.getValue(Name.SPECIFICATION_VENDOR); | ||||
@@ -1244,7 +1258,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
implementationVersion = sectionAttributes.getValue(Name.IMPLEMENTATION_VERSION); | implementationVersion = sectionAttributes.getValue(Name.IMPLEMENTATION_VERSION); | ||||
sealedString = sectionAttributes.getValue(Name.SEALED); | sealedString = sectionAttributes.getValue(Name.SEALED); | ||||
} | } | ||||
Attributes mainAttributes = manifest.getMainAttributes(); | |||||
final Attributes mainAttributes = manifest.getMainAttributes(); | |||||
if (mainAttributes != null) { | if (mainAttributes != null) { | ||||
if (specificationTitle == null) { | if (specificationTitle == null) { | ||||
specificationTitle = mainAttributes.getValue(Name.SPECIFICATION_TITLE); | specificationTitle = mainAttributes.getValue(Name.SPECIFICATION_TITLE); | ||||
@@ -1271,7 +1285,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
if (sealedString != null && sealedString.equalsIgnoreCase("true")) { | if (sealedString != null && sealedString.equalsIgnoreCase("true")) { | ||||
try { | try { | ||||
sealBase = new URL(FileUtils.getFileUtils().toURI(container.getAbsolutePath())); | sealBase = new URL(FileUtils.getFileUtils().toURI(container.getAbsolutePath())); | ||||
} catch (MalformedURLException e) { | |||||
} catch (final MalformedURLException e) { | |||||
// ignore | // ignore | ||||
} | } | ||||
} | } | ||||
@@ -1295,16 +1309,16 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* @exception SecurityException if there is a security problem while | * @exception SecurityException if there is a security problem while | ||||
* reading the class from the stream. | * 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 { | throws IOException, SecurityException { | ||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||||
int bytesRead = -1; | 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) { | while ((bytesRead = stream.read(buffer, 0, BUFFER_SIZE)) != -1) { | ||||
baos.write(buffer, 0, bytesRead); | baos.write(buffer, 0, bytesRead); | ||||
} | } | ||||
byte[] classData = baos.toByteArray(); | |||||
final byte[] classData = baos.toByteArray(); | |||||
return defineClassFromData(container, classData, classname); | 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 | * @exception ClassNotFoundException if the requested class does not exist | ||||
* on this loader's classpath. | * 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); | log("Finding class " + name, Project.MSG_DEBUG); | ||||
return findClassInComponents(name); | return findClassInComponents(name); | ||||
} | } | ||||
@@ -1331,7 +1346,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @return true if the file is in the class path | * @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); | return pathComponents.contains(component); | ||||
} | } | ||||
@@ -1346,14 +1361,14 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* @exception ClassNotFoundException if the requested class does not exist | * @exception ClassNotFoundException if the requested class does not exist | ||||
* on this loader's classpath. | * on this loader's classpath. | ||||
*/ | */ | ||||
private Class<?> findClassInComponents(String name) | |||||
private Class<?> findClassInComponents(final String name) | |||||
throws ClassNotFoundException { | throws ClassNotFoundException { | ||||
// we need to search the components of the path to see if | // we need to search the components of the path to see if | ||||
// we can find the class we want. | // 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()) { | while (e.hasMoreElements()) { | ||||
File pathComponent = (File) e.nextElement(); | |||||
final File pathComponent = e.nextElement(); | |||||
InputStream stream = null; | InputStream stream = null; | ||||
try { | try { | ||||
stream = getResourceStream(pathComponent, classFilename); | stream = getResourceStream(pathComponent, classFilename); | ||||
@@ -1362,9 +1377,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
+ classFilename, Project.MSG_DEBUG); | + classFilename, Project.MSG_DEBUG); | ||||
return getClassFromStream(stream, name, pathComponent); | return getClassFromStream(stream, name, pathComponent); | ||||
} | } | ||||
} catch (SecurityException se) { | |||||
} catch (final SecurityException se) { | |||||
throw se; | throw se; | ||||
} catch (IOException ioe) { | |||||
} catch (final IOException ioe) { | |||||
// ioe.printStackTrace(); | // ioe.printStackTrace(); | ||||
log("Exception reading component " + pathComponent + " (reason: " | log("Exception reading component " + pathComponent + " (reason: " | ||||
+ ioe.getMessage() + ")", Project.MSG_VERBOSE); | + 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 | * @exception ClassNotFoundException if the requested class does not exist | ||||
* on this loader's classpath. | * 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); | return parent == null ? findSystemClass(name) : parent.loadClass(name); | ||||
} | } | ||||
@@ -1399,11 +1414,11 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* files are closed. | * files are closed. | ||||
*/ | */ | ||||
public synchronized void cleanup() { | 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 { | try { | ||||
jarFile.close(); | jarFile.close(); | ||||
} catch (IOException ioe) { | |||||
} catch (final IOException ioe) { | |||||
// ignore | // ignore | ||||
} | } | ||||
} | } | ||||
@@ -1418,6 +1433,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* Gets the parent as has been specified in the constructor or via | * Gets the parent as has been specified in the constructor or via | ||||
* setParent. | * setParent. | ||||
* | * | ||||
* @return classloader | |||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public ClassLoader getConfiguredParent() { | public ClassLoader getConfiguredParent() { | ||||
@@ -1429,7 +1445,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the buildStarted event | * @param event the buildStarted event | ||||
*/ | */ | ||||
public void buildStarted(BuildEvent event) { | |||||
@Override | |||||
public void buildStarted(final BuildEvent event) { | |||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1439,7 +1456,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the buildFinished event | * @param event the buildFinished event | ||||
*/ | */ | ||||
public void buildFinished(BuildEvent event) { | |||||
@Override | |||||
public void buildFinished(final BuildEvent event) { | |||||
cleanup(); | cleanup(); | ||||
} | } | ||||
@@ -1452,7 +1470,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
public void subBuildFinished(BuildEvent event) { | |||||
@Override | |||||
public void subBuildFinished(final BuildEvent event) { | |||||
if (event.getProject() == project) { | if (event.getProject() == project) { | ||||
cleanup(); | cleanup(); | ||||
} | } | ||||
@@ -1465,7 +1484,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
public void subBuildStarted(BuildEvent event) { | |||||
@Override | |||||
public void subBuildStarted(final BuildEvent event) { | |||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1474,7 +1494,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the targetStarted event | * @param event the targetStarted event | ||||
*/ | */ | ||||
public void targetStarted(BuildEvent event) { | |||||
@Override | |||||
public void targetStarted(final BuildEvent event) { | |||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1483,7 +1504,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the targetFinished event | * @param event the targetFinished event | ||||
*/ | */ | ||||
public void targetFinished(BuildEvent event) { | |||||
@Override | |||||
public void targetFinished(final BuildEvent event) { | |||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1492,7 +1514,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the taskStarted event | * @param event the taskStarted event | ||||
*/ | */ | ||||
public void taskStarted(BuildEvent event) { | |||||
@Override | |||||
public void taskStarted(final BuildEvent event) { | |||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1501,7 +1524,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the taskFinished event | * @param event the taskFinished event | ||||
*/ | */ | ||||
public void taskFinished(BuildEvent event) { | |||||
@Override | |||||
public void taskFinished(final BuildEvent event) { | |||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1510,7 +1534,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the messageLogged event | * @param event the messageLogged event | ||||
*/ | */ | ||||
public void messageLogged(BuildEvent event) { | |||||
@Override | |||||
public void messageLogged(final BuildEvent event) { | |||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1519,10 +1544,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* here | * here | ||||
*/ | */ | ||||
public void addJavaLibraries() { | 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()) { | while (e.hasMoreElements()) { | ||||
String packageName = e.nextElement(); | |||||
final String packageName = e.nextElement(); | |||||
addSystemPackageRoot(packageName); | addSystemPackageRoot(packageName); | ||||
} | } | ||||
} | } | ||||
@@ -1531,7 +1556,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* Returns a <code>String</code> representing this loader. | * Returns a <code>String</code> representing this loader. | ||||
* @return the path that this classloader has. | * @return the path that this classloader has. | ||||
*/ | */ | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
return "AntClassLoader[" + getClasspath() + "]"; | return "AntClassLoader[" + getClasspath() + "]"; | ||||
} | } | ||||
@@ -1545,7 +1571,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
try { | try { | ||||
subClassToLoad = | subClassToLoad = | ||||
Class.forName("org.apache.tools.ant.loader.AntClassLoader5"); | 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 | // this is Java5 but the installation is lacking our subclass | ||||
} | } | ||||
} | } | ||||
@@ -1554,10 +1580,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
/** | /** | ||||
* Factory method | * 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) { | if (subClassToLoad != null) { | ||||
return (AntClassLoader) | return (AntClassLoader) | ||||
ReflectUtil.newInstance(subClassToLoad, | ReflectUtil.newInstance(subClassToLoad, | ||||
@@ -1574,10 +1600,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
private static final ZipLong SINGLE_SEGMENT_SPLIT_MARKER = | private static final ZipLong SINGLE_SEGMENT_SPLIT_MARKER = | ||||
new ZipLong(0X30304B50L); | 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)) { | if (readFully(file, sig)) { | ||||
ZipLong start = new ZipLong(sig); | |||||
final ZipLong start = new ZipLong(sig); | |||||
return ZipLong.LFH_SIG.equals(start) // normal file | return ZipLong.LFH_SIG.equals(start) // normal file | ||||
|| EOCD_SIG.equals(start) // empty zip | || EOCD_SIG.equals(start) // empty zip | ||||
|| ZipLong.DD_SIG.equals(start) // split zip | || ZipLong.DD_SIG.equals(start) // split zip | ||||
@@ -1586,8 +1612,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
return false; | 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 { | try { | ||||
final int len = b.length; | final int len = b.length; | ||||
int count = 0, x = 0; | int count = 0, x = 0; | ||||
@@ -27,7 +27,7 @@ import java.util.List; | |||||
* ones. It is then recommended to chose specific 'enough' argument name, | * ones. It is then recommended to chose specific 'enough' argument name, | ||||
* avoiding for instance one letter arguments. By the way, if there any | * avoiding for instance one letter arguments. By the way, if there any | ||||
* conflict, Ant will take precedence. | * conflict, Ant will take precedence. | ||||
* | |||||
* | |||||
* @since 1.9 | * @since 1.9 | ||||
*/ | */ | ||||
public interface ArgumentProcessor { | public interface ArgumentProcessor { | ||||
@@ -64,7 +64,7 @@ public interface ArgumentProcessor { | |||||
/** | /** | ||||
* Print the usage of the supported arguments | * Print the usage of the supported arguments | ||||
* | |||||
* | |||||
* @see org.apache.tools.ant.Main#printUsage() | * @see org.apache.tools.ant.Main#printUsage() | ||||
*/ | */ | ||||
void printUsage(PrintStream writer); | void printUsage(PrintStream writer); | ||||
@@ -39,7 +39,7 @@ import org.apache.tools.ant.util.LoaderUtils; | |||||
* <p> | * <p> | ||||
* Use the system property <code>ant.argument-processor.debug</code> to enable | * Use the system property <code>ant.argument-processor.debug</code> to enable | ||||
* the print of debug log. | * the print of debug log. | ||||
* | |||||
* | |||||
* @since 1.9 | * @since 1.9 | ||||
*/ | */ | ||||
public class ArgumentProcessorRegistry { | public class ArgumentProcessorRegistry { | ||||
@@ -37,7 +37,7 @@ public interface BuildListener extends EventListener { | |||||
* <p>This event is fired before the project instance is fully | * <p>This event is fired before the project instance is fully | ||||
* configured. In particular no properties have been set and the | * configured. In particular no properties have been set and the | ||||
* project may not know its name or default target, yet.</p> | * project may not know its name or default target, yet.</p> | ||||
* | |||||
* | |||||
* @param event An event with any relevant extra information. | * @param event An event with any relevant extra information. | ||||
* Must not be <code>null</code>. | * Must not be <code>null</code>. | ||||
*/ | */ | ||||
@@ -145,7 +145,8 @@ public class DirectoryScanner | |||||
* Use the {@link #getDefaultExcludes getDefaultExcludes} | * Use the {@link #getDefaultExcludes getDefaultExcludes} | ||||
* method instead. | * method instead. | ||||
*/ | */ | ||||
protected static final String[] DEFAULTEXCLUDES = { | |||||
@Deprecated | |||||
protected static final String[] DEFAULTEXCLUDES = { | |||||
// Miscellaneous typical temporary files | // Miscellaneous typical temporary files | ||||
SelectorUtils.DEEP_TREE_MATCH + "/*~", | SelectorUtils.DEEP_TREE_MATCH + "/*~", | ||||
SelectorUtils.DEEP_TREE_MATCH + "/#*#", | SelectorUtils.DEEP_TREE_MATCH + "/#*#", | ||||
@@ -558,7 +559,7 @@ public class DirectoryScanner | |||||
*/ | */ | ||||
public static String[] getDefaultExcludes() { | public static String[] getDefaultExcludes() { | ||||
synchronized (defaultExcludes) { | synchronized (defaultExcludes) { | ||||
return (String[]) defaultExcludes.toArray(new String[defaultExcludes | |||||
return defaultExcludes.toArray(new String[defaultExcludes | |||||
.size()]); | .size()]); | ||||
} | } | ||||
} | } | ||||
@@ -618,7 +619,8 @@ public class DirectoryScanner | |||||
* | * | ||||
* @param basedir The base directory to scan. | * @param basedir The base directory to scan. | ||||
*/ | */ | ||||
public void setBasedir(String basedir) { | |||||
@Override | |||||
public void setBasedir(String basedir) { | |||||
setBasedir(basedir == null ? (File) null | setBasedir(basedir == null ? (File) null | ||||
: new File(basedir.replace('/', File.separatorChar).replace( | : new File(basedir.replace('/', File.separatorChar).replace( | ||||
'\\', File.separatorChar))); | '\\', File.separatorChar))); | ||||
@@ -630,7 +632,8 @@ public class DirectoryScanner | |||||
* | * | ||||
* @param basedir The base directory for scanning. | * @param basedir The base directory for scanning. | ||||
*/ | */ | ||||
public synchronized void setBasedir(File basedir) { | |||||
@Override | |||||
public synchronized void setBasedir(File basedir) { | |||||
this.basedir = basedir; | this.basedir = basedir; | ||||
} | } | ||||
@@ -640,7 +643,8 @@ public class DirectoryScanner | |||||
* | * | ||||
* @return the base directory to be scanned. | * @return the base directory to be scanned. | ||||
*/ | */ | ||||
public synchronized File getBasedir() { | |||||
@Override | |||||
public synchronized File getBasedir() { | |||||
return basedir; | return basedir; | ||||
} | } | ||||
@@ -661,7 +665,8 @@ public class DirectoryScanner | |||||
* @param isCaseSensitive whether or not the file system should be | * @param isCaseSensitive whether or not the file system should be | ||||
* regarded as a case sensitive one. | * regarded as a case sensitive one. | ||||
*/ | */ | ||||
public synchronized void setCaseSensitive(boolean isCaseSensitive) { | |||||
@Override | |||||
public synchronized void setCaseSensitive(boolean isCaseSensitive) { | |||||
this.isCaseSensitive = isCaseSensitive; | this.isCaseSensitive = isCaseSensitive; | ||||
} | } | ||||
@@ -719,7 +724,8 @@ public class DirectoryScanner | |||||
* list is given, all elements must be | * list is given, all elements must be | ||||
* non-<code>null</code>. | * non-<code>null</code>. | ||||
*/ | */ | ||||
public synchronized void setIncludes(String[] includes) { | |||||
@Override | |||||
public synchronized void setIncludes(String[] includes) { | |||||
if (includes == null) { | if (includes == null) { | ||||
this.includes = null; | this.includes = null; | ||||
} else { | } else { | ||||
@@ -742,7 +748,8 @@ public class DirectoryScanner | |||||
* should be excluded. If a non-<code>null</code> list is | * should be excluded. If a non-<code>null</code> list is | ||||
* given, all elements must be non-<code>null</code>. | * 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) { | if (excludes == null) { | ||||
this.excludes = null; | this.excludes = null; | ||||
} else { | } else { | ||||
@@ -807,7 +814,8 @@ public class DirectoryScanner | |||||
* | * | ||||
* @param selectors specifies the selectors to be invoked on a scan. | * @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; | this.selectors = selectors; | ||||
} | } | ||||
@@ -832,7 +840,8 @@ public class DirectoryScanner | |||||
* @exception IllegalStateException if the base directory was set | * @exception IllegalStateException if the base directory was set | ||||
* incorrectly (i.e. if it doesn't exist or isn't a directory). | * 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) { | synchronized (scanLock) { | ||||
if (scanning) { | if (scanning) { | ||||
while (scanning) { | while (scanning) { | ||||
@@ -1023,7 +1032,7 @@ public class DirectoryScanner | |||||
scandir(myfile, currentPath, true); | scandir(myfile, currentPath, true); | ||||
} | } | ||||
} else if (myfile.isFile()) { | } else if (myfile.isFile()) { | ||||
String originalpattern = (String) entry.getValue(); | |||||
String originalpattern = entry.getValue(); | |||||
boolean included = isCaseSensitive() | boolean included = isCaseSensitive() | ||||
? originalpattern.equals(currentelement) | ? originalpattern.equals(currentelement) | ||||
: originalpattern.equalsIgnoreCase(currentelement); | : originalpattern.equalsIgnoreCase(currentelement); | ||||
@@ -1239,7 +1248,7 @@ public class DirectoryScanner | |||||
noLinks.add(newfiles[i]); | noLinks.add(newfiles[i]); | ||||
} | } | ||||
} | } | ||||
newfiles = (String[]) (noLinks.toArray(new String[noLinks.size()])); | |||||
newfiles = (noLinks.toArray(new String[noLinks.size()])); | |||||
} else { | } else { | ||||
directoryNamesFollowed.addFirst(dir.getName()); | directoryNamesFollowed.addFirst(dir.getName()); | ||||
} | } | ||||
@@ -1424,7 +1433,7 @@ public class DirectoryScanner | |||||
} | } | ||||
} | } | ||||
for (Iterator<TokenizedPath> iter = includeNonPatterns.values().iterator(); | for (Iterator<TokenizedPath> iter = includeNonPatterns.values().iterator(); | ||||
iter.hasNext(); ) { | |||||
iter.hasNext();) { | |||||
if (couldHoldIncluded(tokenizedName, | if (couldHoldIncluded(tokenizedName, | ||||
iter.next().toPattern())) { | iter.next().toPattern())) { | ||||
return true; | return true; | ||||
@@ -1567,7 +1576,8 @@ public class DirectoryScanner | |||||
* @return the names of the files which matched at least one of the | * @return the names of the files which matched at least one of the | ||||
* include patterns and none of the exclude patterns. | * include patterns and none of the exclude patterns. | ||||
*/ | */ | ||||
public String[] getIncludedFiles() { | |||||
@Override | |||||
public String[] getIncludedFiles() { | |||||
String[] files; | String[] files; | ||||
synchronized (this) { | synchronized (this) { | ||||
if (filesIncluded == null) { | if (filesIncluded == null) { | ||||
@@ -1602,7 +1612,8 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
public synchronized String[] getNotIncludedFiles() { | |||||
@Override | |||||
public synchronized String[] getNotIncludedFiles() { | |||||
slowScan(); | slowScan(); | ||||
String[] files = new String[filesNotIncluded.size()]; | String[] files = new String[filesNotIncluded.size()]; | ||||
filesNotIncluded.copyInto(files); | filesNotIncluded.copyInto(files); | ||||
@@ -1620,7 +1631,8 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
public synchronized String[] getExcludedFiles() { | |||||
@Override | |||||
public synchronized String[] getExcludedFiles() { | |||||
slowScan(); | slowScan(); | ||||
String[] files = new String[filesExcluded.size()]; | String[] files = new String[filesExcluded.size()]; | ||||
filesExcluded.copyInto(files); | filesExcluded.copyInto(files); | ||||
@@ -1638,7 +1650,8 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
public synchronized String[] getDeselectedFiles() { | |||||
@Override | |||||
public synchronized String[] getDeselectedFiles() { | |||||
slowScan(); | slowScan(); | ||||
String[] files = new String[filesDeselected.size()]; | String[] files = new String[filesDeselected.size()]; | ||||
filesDeselected.copyInto(files); | filesDeselected.copyInto(files); | ||||
@@ -1653,7 +1666,8 @@ public class DirectoryScanner | |||||
* @return the names of the directories which matched at least one of the | * @return the names of the directories which matched at least one of the | ||||
* include patterns and none of the exclude patterns. | * include patterns and none of the exclude patterns. | ||||
*/ | */ | ||||
public String[] getIncludedDirectories() { | |||||
@Override | |||||
public String[] getIncludedDirectories() { | |||||
String[] directories; | String[] directories; | ||||
synchronized (this) { | synchronized (this) { | ||||
if (dirsIncluded == null) { | if (dirsIncluded == null) { | ||||
@@ -1688,7 +1702,8 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
public synchronized String[] getNotIncludedDirectories() { | |||||
@Override | |||||
public synchronized String[] getNotIncludedDirectories() { | |||||
slowScan(); | slowScan(); | ||||
String[] directories = new String[dirsNotIncluded.size()]; | String[] directories = new String[dirsNotIncluded.size()]; | ||||
dirsNotIncluded.copyInto(directories); | dirsNotIncluded.copyInto(directories); | ||||
@@ -1706,7 +1721,8 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
public synchronized String[] getExcludedDirectories() { | |||||
@Override | |||||
public synchronized String[] getExcludedDirectories() { | |||||
slowScan(); | slowScan(); | ||||
String[] directories = new String[dirsExcluded.size()]; | String[] directories = new String[dirsExcluded.size()]; | ||||
dirsExcluded.copyInto(directories); | dirsExcluded.copyInto(directories); | ||||
@@ -1724,7 +1740,8 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
public synchronized String[] getDeselectedDirectories() { | |||||
@Override | |||||
public synchronized String[] getDeselectedDirectories() { | |||||
slowScan(); | slowScan(); | ||||
String[] directories = new String[dirsDeselected.size()]; | String[] directories = new String[dirsDeselected.size()]; | ||||
dirsDeselected.copyInto(directories); | dirsDeselected.copyInto(directories); | ||||
@@ -1743,7 +1760,7 @@ public class DirectoryScanner | |||||
public synchronized String[] getNotFollowedSymlinks() { | public synchronized String[] getNotFollowedSymlinks() { | ||||
String[] links; | String[] links; | ||||
synchronized (this) { | synchronized (this) { | ||||
links = (String[]) notFollowedSymlinks | |||||
links = notFollowedSymlinks | |||||
.toArray(new String[notFollowedSymlinks.size()]); | .toArray(new String[notFollowedSymlinks.size()]); | ||||
} | } | ||||
Arrays.sort(links); | Arrays.sort(links); | ||||
@@ -1753,7 +1770,8 @@ public class DirectoryScanner | |||||
/** | /** | ||||
* Add default exclusions to the current exclusions set. | * Add default exclusions to the current exclusions set. | ||||
*/ | */ | ||||
public synchronized void addDefaultExcludes() { | |||||
@Override | |||||
public synchronized void addDefaultExcludes() { | |||||
int excludesLength = excludes == null ? 0 : excludes.length; | int excludesLength = excludes == null ? 0 : excludes.length; | ||||
String[] newExcludes; | String[] newExcludes; | ||||
String[] defaultExcludesTemp = getDefaultExcludes(); | String[] defaultExcludesTemp = getDefaultExcludes(); | ||||
@@ -1776,7 +1794,8 @@ public class DirectoryScanner | |||||
* @return the resource with the given name. | * @return the resource with the given name. | ||||
* @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
*/ | */ | ||||
public synchronized Resource getResource(String name) { | |||||
@Override | |||||
public synchronized Resource getResource(String name) { | |||||
return new FileResource(basedir, name); | return new FileResource(basedir, name); | ||||
} | } | ||||
@@ -1847,7 +1866,7 @@ public class DirectoryScanner | |||||
al.add(new TokenizedPattern(patterns[i])); | 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 | * Kind of task attribute that can be evaluated before being assigned | ||||
* | |||||
* | |||||
* @see RuntimeConfigurable | * @see RuntimeConfigurable | ||||
*/ | */ | ||||
public interface Evaluable { | public interface Evaluable { | ||||
@@ -26,7 +26,6 @@ package org.apache.tools.ant; | |||||
public class ExtensionPoint extends Target { | public class ExtensionPoint extends Target { | ||||
public ExtensionPoint() { | public ExtensionPoint() { | ||||
} | } | ||||
/** | /** | ||||
@@ -45,15 +44,17 @@ public class ExtensionPoint extends Target { | |||||
/** | /** | ||||
* Throws an exception. | * Throws an exception. | ||||
*/ | */ | ||||
public final void addTask(Task task) { | |||||
@Override | |||||
public final void addTask(Task task) { | |||||
throw new BuildException(NO_CHILDREN_ALLOWED); | throw new BuildException(NO_CHILDREN_ALLOWED); | ||||
} | } | ||||
/** | /** | ||||
* Throws an exception. | * Throws an exception. | ||||
*/ | */ | ||||
public final void addDataType(RuntimeConfigurable r) { | |||||
@Override | |||||
public final void addDataType(RuntimeConfigurable r) { | |||||
throw new BuildException(NO_CHILDREN_ALLOWED); | throw new BuildException(NO_CHILDREN_ALLOWED); | ||||
} | } | ||||
} | } |
@@ -86,16 +86,16 @@ public class Main implements AntMain { | |||||
private static PrintStream err = System.err; | private static PrintStream err = System.err; | ||||
/** The build targets. */ | /** 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. */ | /** 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. */ | /** 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. */ | /** 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 */ | /** Indicates whether this build is to support interactive input */ | ||||
private boolean allowInput = true; | private boolean allowInput = true; | ||||
@@ -154,13 +154,15 @@ public class Main implements AntMain { | |||||
*/ | */ | ||||
private boolean proxy = false; | 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 | // No existing property takes precedence | ||||
return null; | return null; | ||||
}}; | |||||
} | |||||
}; | |||||
@@ -172,8 +174,8 @@ public class Main implements AntMain { | |||||
* @param t Throwable to print the message of. | * @param t Throwable to print the message of. | ||||
* Must not be <code>null</code>. | * 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) { | if (message != null) { | ||||
System.err.println(message); | System.err.println(message); | ||||
} | } | ||||
@@ -191,9 +193,9 @@ public class Main implements AntMain { | |||||
* @param coreLoader Classloader used for core classes. May be | * @param coreLoader Classloader used for core classes. May be | ||||
* <code>null</code> in which case the system classloader is used. | * <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); | m.startAnt(args, additionalUserProperties, coreLoader); | ||||
} | } | ||||
@@ -206,12 +208,13 @@ public class Main implements AntMain { | |||||
* | * | ||||
* @since Ant 1.6 | * @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 { | try { | ||||
processArgs(args); | processArgs(args); | ||||
} catch (Throwable exc) { | |||||
} catch (final Throwable exc) { | |||||
handleLogfile(); | handleLogfile(); | ||||
printMessage(exc); | printMessage(exc); | ||||
exit(1); | exit(1); | ||||
@@ -219,10 +222,10 @@ public class Main implements AntMain { | |||||
} | } | ||||
if (additionalUserProperties != null) { | if (additionalUserProperties != null) { | ||||
for (Enumeration<?> e = additionalUserProperties.keys(); | |||||
for (final Enumeration<?> e = additionalUserProperties.keys(); | |||||
e.hasMoreElements();) { | 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); | definedProps.put(key, property); | ||||
} | } | ||||
} | } | ||||
@@ -233,17 +236,17 @@ public class Main implements AntMain { | |||||
try { | try { | ||||
runBuild(coreLoader); | runBuild(coreLoader); | ||||
exitCode = 0; | exitCode = 0; | ||||
} catch (ExitStatusException ese) { | |||||
} catch (final ExitStatusException ese) { | |||||
exitCode = ese.getStatus(); | exitCode = ese.getStatus(); | ||||
if (exitCode != 0) { | if (exitCode != 0) { | ||||
throw ese; | throw ese; | ||||
} | } | ||||
} | } | ||||
} catch (BuildException be) { | |||||
} catch (final BuildException be) { | |||||
if (err != System.err) { | if (err != System.err) { | ||||
printMessage(be); | printMessage(be); | ||||
} | } | ||||
} catch (Throwable exc) { | |||||
} catch (final Throwable exc) { | |||||
exc.printStackTrace(); | exc.printStackTrace(); | ||||
printMessage(exc); | printMessage(exc); | ||||
} finally { | } finally { | ||||
@@ -258,7 +261,7 @@ public class Main implements AntMain { | |||||
* However, it is possible to do something else. | * However, it is possible to do something else. | ||||
* @param exitCode code to exit with | * @param exitCode code to exit with | ||||
*/ | */ | ||||
protected void exit(int exitCode) { | |||||
protected void exit(final int exitCode) { | |||||
System.exit(exitCode); | System.exit(exitCode); | ||||
} | } | ||||
@@ -281,7 +284,7 @@ public class Main implements AntMain { | |||||
* | * | ||||
* @param args Command line arguments. Must not be <code>null</code>. | * @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); | start(args, null, null); | ||||
} | } | ||||
@@ -303,7 +306,8 @@ public class Main implements AntMain { | |||||
* | * | ||||
* @deprecated since 1.6.x | * @deprecated since 1.6.x | ||||
*/ | */ | ||||
protected Main(String[] args) throws BuildException { | |||||
@Deprecated | |||||
protected Main(final String[] args) throws BuildException { | |||||
processArgs(args); | processArgs(args); | ||||
} | } | ||||
@@ -316,7 +320,7 @@ public class Main implements AntMain { | |||||
* | * | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
private void processArgs(String[] args) { | |||||
private void processArgs(final String[] args) { | |||||
String searchForThis = null; | String searchForThis = null; | ||||
boolean searchForFile = false; | boolean searchForFile = false; | ||||
PrintStream logTo = null; | PrintStream logTo = null; | ||||
@@ -327,10 +331,10 @@ public class Main implements AntMain { | |||||
boolean justPrintVersion = false; | boolean justPrintVersion = false; | ||||
boolean justPrintDiagnostics = false; | boolean justPrintDiagnostics = false; | ||||
ArgumentProcessorRegistry processorRegistry = ArgumentProcessorRegistry.getInstance(); | |||||
final ArgumentProcessorRegistry processorRegistry = ArgumentProcessorRegistry.getInstance(); | |||||
for (int i = 0; i < args.length; i++) { | for (int i = 0; i < args.length; i++) { | ||||
String arg = args[i]; | |||||
final String arg = args[i]; | |||||
if (arg.equals("-help") || arg.equals("-h")) { | if (arg.equals("-help") || arg.equals("-h")) { | ||||
justPrintUsage = true; | justPrintUsage = true; | ||||
@@ -350,17 +354,17 @@ public class Main implements AntMain { | |||||
allowInput = false; | allowInput = false; | ||||
} else if (arg.equals("-logfile") || arg.equals("-l")) { | } else if (arg.equals("-logfile") || arg.equals("-l")) { | ||||
try { | try { | ||||
File logFile = new File(args[i + 1]); | |||||
final File logFile = new File(args[i + 1]); | |||||
i++; | i++; | ||||
logTo = new PrintStream(new FileOutputStream(logFile)); | logTo = new PrintStream(new FileOutputStream(logFile)); | ||||
isLogFileUsed = true; | 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 " | + "Make sure the path exists and you have write " | ||||
+ "permissions."; | + "permissions."; | ||||
throw new BuildException(msg); | 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"; | + "using the -log argument"; | ||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} | } | ||||
@@ -396,7 +400,7 @@ public class Main implements AntMain { | |||||
//catch script/ant mismatch with a meaningful message | //catch script/ant mismatch with a meaningful message | ||||
//we could ignore it, but there are likely to be other | //we could ignore it, but there are likely to be other | ||||
//version problems, so we stamp down on the configuration now | //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." | + "an option " + arg + " that is only for the launcher class." | ||||
+ "\nThis can be caused by a version mismatch between " | + "\nThis can be caused by a version mismatch between " | ||||
+ "the ant script/.bat file and Ant itself."; | + "the ant script/.bat file and Ant itself."; | ||||
@@ -405,8 +409,8 @@ public class Main implements AntMain { | |||||
proxy = true; | proxy = true; | ||||
} else if (arg.startsWith("-")) { | } else if (arg.startsWith("-")) { | ||||
boolean processed = false; | 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) { | if (newI != -1) { | ||||
List<String> extraArgs = extraArguments.get(processor.getClass()); | List<String> extraArgs = extraArguments.get(processor.getClass()); | ||||
if (extraArgs == null) { | if (extraArgs == null) { | ||||
@@ -422,7 +426,7 @@ public class Main implements AntMain { | |||||
} | } | ||||
if (!processed) { | if (!processed) { | ||||
// we don't have any more args to recognize! | // we don't have any more args to recognize! | ||||
String msg = "Unknown argument: " + arg; | |||||
final String msg = "Unknown argument: " + arg; | |||||
System.err.println(msg); | System.err.println(msg); | ||||
printUsage(); | printUsage(); | ||||
throw new BuildException(""); | throw new BuildException(""); | ||||
@@ -458,9 +462,9 @@ public class Main implements AntMain { | |||||
} | } | ||||
} else { | } else { | ||||
// no search file specified: so search an existing default file | // no search file specified: so search an existing default file | ||||
Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers(); | |||||
final Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers(); | |||||
do { | do { | ||||
ProjectHelper helper = it.next(); | |||||
final ProjectHelper helper = it.next(); | |||||
searchForThis = helper.getDefaultBuildFile(); | searchForThis = helper.getDefaultBuildFile(); | ||||
if (msgOutputLevel >= Project.MSG_VERBOSE) { | if (msgOutputLevel >= Project.MSG_VERBOSE) { | ||||
System.out.println("Searching the default build file: " + searchForThis); | System.out.println("Searching the default build file: " + searchForThis); | ||||
@@ -473,9 +477,9 @@ public class Main implements AntMain { | |||||
} | } | ||||
} else { | } else { | ||||
// no build file specified: so search an existing default file | // no build file specified: so search an existing default file | ||||
Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers(); | |||||
final Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers(); | |||||
do { | do { | ||||
ProjectHelper helper = it.next(); | |||||
final ProjectHelper helper = it.next(); | |||||
buildFile = new File(helper.getDefaultBuildFile()); | buildFile = new File(helper.getDefaultBuildFile()); | ||||
if (msgOutputLevel >= Project.MSG_VERBOSE) { | if (msgOutputLevel >= Project.MSG_VERBOSE) { | ||||
System.out.println("Trying the default build file: " + buildFile); | System.out.println("Trying the default build file: " + buildFile); | ||||
@@ -491,7 +495,7 @@ public class Main implements AntMain { | |||||
} | } | ||||
if (buildFile.isDirectory()) { | if (buildFile.isDirectory()) { | ||||
File whatYouMeant = new File(buildFile, "build.xml"); | |||||
final File whatYouMeant = new File(buildFile, "build.xml"); | |||||
if (whatYouMeant.isFile()) { | if (whatYouMeant.isFile()) { | ||||
buildFile = whatYouMeant; | buildFile = whatYouMeant; | ||||
} else { | } else { | ||||
@@ -525,11 +529,11 @@ public class Main implements AntMain { | |||||
// -------------------------------------------------------- | // -------------------------------------------------------- | ||||
/** Handle the -buildfile, -file, -f argument */ | /** Handle the -buildfile, -file, -f argument */ | ||||
private int handleArgBuildFile(String[] args, int pos) { | |||||
private int handleArgBuildFile(final String[] args, int pos) { | |||||
try { | try { | ||||
buildFile = new File( | buildFile = new File( | ||||
args[++pos].replace('/', File.separatorChar)); | args[++pos].replace('/', File.separatorChar)); | ||||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||||
throw new BuildException( | throw new BuildException( | ||||
"You must specify a buildfile when using the -buildfile argument"); | "You must specify a buildfile when using the -buildfile argument"); | ||||
} | } | ||||
@@ -537,12 +541,12 @@ public class Main implements AntMain { | |||||
} | } | ||||
/** Handle -listener argument */ | /** Handle -listener argument */ | ||||
private int handleArgListener(String[] args, int pos) { | |||||
private int handleArgListener(final String[] args, int pos) { | |||||
try { | try { | ||||
listeners.addElement(args[pos + 1]); | listeners.addElement(args[pos + 1]); | ||||
pos++; | 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"; | + "using the -listener argument"; | ||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} | } | ||||
@@ -550,7 +554,7 @@ public class Main implements AntMain { | |||||
} | } | ||||
/** Handler -D argument */ | /** 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 | /* Interestingly enough, we get to here when a user | ||||
* uses -Dname=value. However, in some cases, the OS | * uses -Dname=value. However, in some cases, the OS | ||||
* goes ahead and parses this out to args | * 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 | * I don't know how to predict when the JDK is going | ||||
* to help or not, so we simply look for the equals sign. | * 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 name = arg.substring(2, arg.length()); | ||||
String value = null; | String value = null; | ||||
int posEq = name.indexOf("="); | |||||
final int posEq = name.indexOf("="); | |||||
if (posEq > 0) { | if (posEq > 0) { | ||||
value = name.substring(posEq + 1); | value = name.substring(posEq + 1); | ||||
name = name.substring(0, posEq); | name = name.substring(0, posEq); | ||||
@@ -579,14 +583,14 @@ public class Main implements AntMain { | |||||
} | } | ||||
/** Handle the -logger argument. */ | /** Handle the -logger argument. */ | ||||
private int handleArgLogger(String[] args, int pos) { | |||||
private int handleArgLogger(final String[] args, int pos) { | |||||
if (loggerClassname != null) { | if (loggerClassname != null) { | ||||
throw new BuildException( | throw new BuildException( | ||||
"Only one logger class may be specified."); | "Only one logger class may be specified."); | ||||
} | } | ||||
try { | try { | ||||
loggerClassname = args[++pos]; | loggerClassname = args[++pos]; | ||||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||||
throw new BuildException( | throw new BuildException( | ||||
"You must specify a classname when using the -logger argument"); | "You must specify a classname when using the -logger argument"); | ||||
} | } | ||||
@@ -594,14 +598,14 @@ public class Main implements AntMain { | |||||
} | } | ||||
/** Handle the -inputhandler argument. */ | /** Handle the -inputhandler argument. */ | ||||
private int handleArgInputHandler(String[] args, int pos) { | |||||
private int handleArgInputHandler(final String[] args, int pos) { | |||||
if (inputHandlerClassname != null) { | if (inputHandlerClassname != null) { | ||||
throw new BuildException("Only one input handler class may " | throw new BuildException("Only one input handler class may " | ||||
+ "be specified."); | + "be specified."); | ||||
} | } | ||||
try { | try { | ||||
inputHandlerClassname = args[++pos]; | inputHandlerClassname = args[++pos]; | ||||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||||
throw new BuildException("You must specify a classname when" | throw new BuildException("You must specify a classname when" | ||||
+ " using the -inputhandler" | + " using the -inputhandler" | ||||
+ " argument"); | + " argument"); | ||||
@@ -610,11 +614,11 @@ public class Main implements AntMain { | |||||
} | } | ||||
/** Handle the -propertyfile argument. */ | /** Handle the -propertyfile argument. */ | ||||
private int handleArgPropertyFile(String[] args, int pos) { | |||||
private int handleArgPropertyFile(final String[] args, int pos) { | |||||
try { | try { | ||||
propertyFiles.addElement(args[++pos]); | 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"; | + "using the -propertyfile argument"; | ||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} | } | ||||
@@ -622,14 +626,14 @@ public class Main implements AntMain { | |||||
} | } | ||||
/** Handle the -nice argument. */ | /** Handle the -nice argument. */ | ||||
private int handleArgNice(String[] args, int pos) { | |||||
private int handleArgNice(final String[] args, int pos) { | |||||
try { | try { | ||||
threadPriority = Integer.decode(args[++pos]); | threadPriority = Integer.decode(args[++pos]); | ||||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||||
} catch (final ArrayIndexOutOfBoundsException aioobe) { | |||||
throw new BuildException( | throw new BuildException( | ||||
"You must supply a niceness value (1-10)" | "You must supply a niceness value (1-10)" | ||||
+ " after the -nice option"); | + " after the -nice option"); | ||||
} catch (NumberFormatException e) { | |||||
} catch (final NumberFormatException e) { | |||||
throw new BuildException("Unrecognized niceness value: " | throw new BuildException("Unrecognized niceness value: " | ||||
+ args[pos]); | + args[pos]); | ||||
} | } | ||||
@@ -648,13 +652,13 @@ public class Main implements AntMain { | |||||
/** Load the property files specified by -propertyfile */ | /** Load the property files specified by -propertyfile */ | ||||
private void loadPropertyFiles() { | private void loadPropertyFiles() { | ||||
for (String filename : propertyFiles) { | |||||
Properties props = new Properties(); | |||||
for (final String filename : propertyFiles) { | |||||
final Properties props = new Properties(); | |||||
FileInputStream fis = null; | FileInputStream fis = null; | ||||
try { | try { | ||||
fis = new FileInputStream(filename); | fis = new FileInputStream(filename); | ||||
props.load(fis); | props.load(fis); | ||||
} catch (IOException e) { | |||||
} catch (final IOException e) { | |||||
System.out.println("Could not load property file " | System.out.println("Could not load property file " | ||||
+ filename + ": " + e.getMessage()); | + filename + ": " + e.getMessage()); | ||||
} finally { | } finally { | ||||
@@ -662,9 +666,9 @@ public class Main implements AntMain { | |||||
} | } | ||||
// ensure that -D properties take precedence | // ensure that -D properties take precedence | ||||
Enumeration<?> propertyNames = props.propertyNames(); | |||||
final Enumeration<?> propertyNames = props.propertyNames(); | |||||
while (propertyNames.hasMoreElements()) { | while (propertyNames.hasMoreElements()) { | ||||
String name = (String) propertyNames.nextElement(); | |||||
final String name = (String) propertyNames.nextElement(); | |||||
if (definedProps.getProperty(name) == null) { | if (definedProps.getProperty(name) == null) { | ||||
definedProps.put(name, props.getProperty(name)); | 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>. | * @param file File to find parent of. Must not be <code>null</code>. | ||||
* @return Parent file or null if none | * @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) { | if (parent != null && msgOutputLevel >= Project.MSG_VERBOSE) { | ||||
System.out.println("Searching in " + parent.getAbsolutePath()); | 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 | * @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) { | if (msgOutputLevel >= Project.MSG_INFO) { | ||||
System.out.println("Searching for " + suffix + " ..."); | System.out.println("Searching for " + suffix + " ..."); | ||||
} | } | ||||
@@ -743,16 +748,16 @@ public class Main implements AntMain { | |||||
* | * | ||||
* @exception BuildException if the build fails | * @exception BuildException if the build fails | ||||
*/ | */ | ||||
private void runBuild(ClassLoader coreLoader) throws BuildException { | |||||
private void runBuild(final ClassLoader coreLoader) throws BuildException { | |||||
if (!readyToRun) { | if (!readyToRun) { | ||||
return; | 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 (extraArgs != null) { | ||||
if (processor.handleArg(extraArgs)) { | if (processor.handleArg(extraArgs)) { | ||||
return; | return; | ||||
@@ -769,9 +774,9 @@ public class Main implements AntMain { | |||||
addBuildListeners(project); | addBuildListeners(project); | ||||
addInputHandler(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() | // use a system manager that prevents from System.exit() | ||||
SecurityManager oldsm = null; | SecurityManager oldsm = null; | ||||
@@ -800,7 +805,7 @@ public class Main implements AntMain { | |||||
project.log("Setting Ant's thread priority to " | project.log("Setting Ant's thread priority to " | ||||
+ threadPriority, Project.MSG_VERBOSE); | + threadPriority, Project.MSG_VERBOSE); | ||||
Thread.currentThread().setPriority(threadPriority.intValue()); | Thread.currentThread().setPriority(threadPriority.intValue()); | ||||
} catch (SecurityException swallowed) { | |||||
} catch (final SecurityException swallowed) { | |||||
//we cannot set the priority here. | //we cannot set the priority here. | ||||
project.log("A security manager refused to set the -nice value"); | project.log("A security manager refused to set the -nice value"); | ||||
} | } | ||||
@@ -811,12 +816,12 @@ public class Main implements AntMain { | |||||
project.setKeepGoingMode(keepGoingMode); | project.setKeepGoingMode(keepGoingMode); | ||||
if (proxy) { | if (proxy) { | ||||
//proxy setup if enabled | //proxy setup if enabled | ||||
ProxySetup proxySetup = new ProxySetup(project); | |||||
final ProxySetup proxySetup = new ProxySetup(project); | |||||
proxySetup.enableProxies(); | 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) { | if (extraArgs != null) { | ||||
processor.prepareConfigure(project, extraArgs); | processor.prepareConfigure(project, extraArgs); | ||||
} | } | ||||
@@ -824,8 +829,8 @@ public class Main implements AntMain { | |||||
ProjectHelper.configureProject(project, buildFile); | 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 (extraArgs != null) { | ||||
if (processor.handleArg(project, extraArgs)) { | if (processor.handleArg(project, extraArgs)) { | ||||
return; | return; | ||||
@@ -859,17 +864,17 @@ public class Main implements AntMain { | |||||
System.setErr(savedErr); | System.setErr(savedErr); | ||||
System.setIn(savedIn); | System.setIn(savedIn); | ||||
} | } | ||||
} catch (RuntimeException exc) { | |||||
} catch (final RuntimeException exc) { | |||||
error = exc; | error = exc; | ||||
throw exc; | throw exc; | ||||
} catch (Error e) { | |||||
} catch (final Error e) { | |||||
error = e; | error = e; | ||||
throw e; | throw e; | ||||
} finally { | } finally { | ||||
if (!projectHelp) { | if (!projectHelp) { | ||||
try { | try { | ||||
project.fireBuildFinished(error); | project.fireBuildFinished(error); | ||||
} catch (Throwable t) { | |||||
} catch (final Throwable t) { | |||||
// yes, I know it is bad style to catch Throwable, | // yes, I know it is bad style to catch Throwable, | ||||
// but if we don't, we lose valuable information | // but if we don't, we lose valuable information | ||||
System.err.println("Caught an exception while logging the" | System.err.println("Caught an exception while logging the" | ||||
@@ -893,20 +898,22 @@ public class Main implements AntMain { | |||||
project.init(); | project.init(); | ||||
// resolve properties | // resolve properties | ||||
PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(project); | |||||
final PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(project); | |||||
@SuppressWarnings({ "rawtypes", "unchecked" }) | @SuppressWarnings({ "rawtypes", "unchecked" }) | ||||
final | |||||
Map raw = new HashMap(definedProps); | Map raw = new HashMap(definedProps); | ||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
final | |||||
Map<String, Object> props = raw; | Map<String, Object> props = raw; | ||||
ResolvePropertyMap resolver = new ResolvePropertyMap(project, | |||||
final ResolvePropertyMap resolver = new ResolvePropertyMap(project, | |||||
NOPROPERTIES, propertyHelper.getExpanders()); | NOPROPERTIES, propertyHelper.getExpanders()); | ||||
resolver.resolveAllProperties(props, null, false); | resolver.resolveAllProperties(props, null, false); | ||||
// set user-define properties | // 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)); | project.setUserProperty(arg, String.valueOf(value)); | ||||
} | } | ||||
@@ -923,15 +930,15 @@ public class Main implements AntMain { | |||||
* @param project The project to add listeners to. | * @param project The project to add listeners to. | ||||
* Must not be <code>null</code>. | * Must not be <code>null</code>. | ||||
*/ | */ | ||||
protected void addBuildListeners(Project project) { | |||||
protected void addBuildListeners(final Project project) { | |||||
// Add the default listener | // Add the default listener | ||||
project.addBuildListener(createLogger()); | project.addBuildListener(createLogger()); | ||||
final int count = listeners.size(); | final int count = listeners.size(); | ||||
for (int i = 0; i < count; i++) { | 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, | (BuildListener) ClasspathUtils.newInstance(className, | ||||
Main.class.getClassLoader(), BuildListener.class); | Main.class.getClassLoader(), BuildListener.class); | ||||
project.setProjectReference(listener); | project.setProjectReference(listener); | ||||
@@ -948,7 +955,7 @@ public class Main implements AntMain { | |||||
* @exception BuildException if a specified InputHandler | * @exception BuildException if a specified InputHandler | ||||
* implementation could not be loaded. | * implementation could not be loaded. | ||||
*/ | */ | ||||
private void addInputHandler(Project project) throws BuildException { | |||||
private void addInputHandler(final Project project) throws BuildException { | |||||
InputHandler handler = null; | InputHandler handler = null; | ||||
if (inputHandlerClassname == null) { | if (inputHandlerClassname == null) { | ||||
handler = new DefaultInputHandler(); | handler = new DefaultInputHandler(); | ||||
@@ -982,7 +989,7 @@ public class Main implements AntMain { | |||||
logger = (BuildLogger) ClasspathUtils.newInstance( | logger = (BuildLogger) ClasspathUtils.newInstance( | ||||
loggerClassname, Main.class.getClassLoader(), | loggerClassname, Main.class.getClassLoader(), | ||||
BuildLogger.class); | BuildLogger.class); | ||||
} catch (BuildException e) { | |||||
} catch (final BuildException e) { | |||||
System.err.println("The specified logger class " | System.err.println("The specified logger class " | ||||
+ loggerClassname | + loggerClassname | ||||
+ " could not be used because " + e.getMessage()); | + " 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(" -noclasspath Run ant without using CLASSPATH"); | ||||
System.out.println(" -autoproxy Java1.5+: use the OS proxy settings"); | System.out.println(" -autoproxy Java1.5+: use the OS proxy settings"); | ||||
System.out.println(" -main <class> override Ant's normal entry point"); | 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); | processor.printUsage(System.out); | ||||
} | } | ||||
} | } | ||||
@@ -1050,7 +1057,7 @@ public class Main implements AntMain { | |||||
* | * | ||||
* @exception BuildException if the version information is unavailable | * @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()); | 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. | * Cache of the short Ant version information when it has been loaded. | ||||
*/ | */ | ||||
private static String shortAntVersion = null; | private static String shortAntVersion = null; | ||||
/** | /** | ||||
* Returns the Ant version information, if available. Once the information | * Returns the Ant version information, if available. Once the information | ||||
* has been loaded once, it's cached and returned from the cache on future | * 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 { | public static synchronized String getAntVersion() throws BuildException { | ||||
if (antVersion == null) { | if (antVersion == null) { | ||||
try { | try { | ||||
Properties props = new Properties(); | |||||
InputStream in = | |||||
final Properties props = new Properties(); | |||||
final InputStream in = | |||||
Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt"); | Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt"); | ||||
props.load(in); | props.load(in); | ||||
in.close(); | in.close(); | ||||
shortAntVersion = props.getProperty("VERSION"); | shortAntVersion = props.getProperty("VERSION"); | ||||
StringBuffer msg = new StringBuffer(); | |||||
final StringBuffer msg = new StringBuffer(); | |||||
msg.append("Apache Ant(TM) version "); | msg.append("Apache Ant(TM) version "); | ||||
msg.append(shortAntVersion); | msg.append(shortAntVersion); | ||||
msg.append(" compiled on "); | msg.append(" compiled on "); | ||||
msg.append(props.getProperty("DATE")); | msg.append(props.getProperty("DATE")); | ||||
antVersion = msg.toString(); | antVersion = msg.toString(); | ||||
} catch (IOException ioe) { | |||||
} catch (final IOException ioe) { | |||||
throw new BuildException("Could not load the version information:" | throw new BuildException("Could not load the version information:" | ||||
+ ioe.getMessage()); | + ioe.getMessage()); | ||||
} catch (NullPointerException npe) { | |||||
} catch (final NullPointerException npe) { | |||||
throw new BuildException("Could not load the version information."); | throw new BuildException("Could not load the version information."); | ||||
} | } | ||||
} | } | ||||
return antVersion; | return antVersion; | ||||
} | } | ||||
/** | /** | ||||
* Returns the short Ant version information, if available. Once the information | * 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 | * has been loaded once, it's cached and returned from the cache on future | ||||
* calls. | * calls. | ||||
* | |||||
* | |||||
* @return the short Ant version information as a String | * @return the short Ant version information as a String | ||||
* (always non-<code>null</code>) | * (always non-<code>null</code>) | ||||
* | |||||
* | |||||
* @throws BuildException BuildException if the version information is unavailable | * @throws BuildException BuildException if the version information is unavailable | ||||
* @since Ant 1.9.3 | * @since Ant 1.9.3 | ||||
*/ | */ | ||||
@@ -1125,7 +1132,7 @@ public class Main implements AntMain { | |||||
* @param project The project to display a description of. | * @param project The project to display a description of. | ||||
* Must not be <code>null</code>. | * Must not be <code>null</code>. | ||||
*/ | */ | ||||
private static void printDescription(Project project) { | |||||
private static void printDescription(final Project project) { | |||||
if (project.getDescription() != null) { | if (project.getDescription() != null) { | ||||
project.log(project.getDescription()); | project.log(project.getDescription()); | ||||
} | } | ||||
@@ -1139,12 +1146,12 @@ public class Main implements AntMain { | |||||
* @param targets the targets to filter. | * @param targets the targets to filter. | ||||
* @return the filtered targets. | * @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 | // Place this entry in the location map if | ||||
// a) location is not in the map | // a) location is not in the map | ||||
// b) location is in map, but its name is longer | // 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 | 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); | ret.put(target.getName(), target); | ||||
} | } | ||||
return ret; | return ret; | ||||
@@ -1171,34 +1178,34 @@ public class Main implements AntMain { | |||||
* @param printSubTargets Whether or not subtarget names should also be | * @param printSubTargets Whether or not subtarget names should also be | ||||
* printed. | * 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 | // find the target with the longest name | ||||
int maxLength = 0; | 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 | // split the targets in top-level and sub-targets depending | ||||
// on the presence of a description | // 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("")) { | if (targetName.equals("")) { | ||||
continue; | continue; | ||||
} | } | ||||
String targetDescription = currentTarget.getDescription(); | |||||
final String targetDescription = currentTarget.getDescription(); | |||||
// maintain a sorted list of targets | // maintain a sorted list of targets | ||||
if (targetDescription == null) { | if (targetDescription == null) { | ||||
int pos = findTargetPosition(subNames, targetName); | |||||
final int pos = findTargetPosition(subNames, targetName); | |||||
subNames.insertElementAt(targetName, pos); | subNames.insertElementAt(targetName, pos); | ||||
if (printDependencies) { | if (printDependencies) { | ||||
subDependencies.insertElementAt(currentTarget.getDependencies(), pos); | subDependencies.insertElementAt(currentTarget.getDependencies(), pos); | ||||
} | } | ||||
} else { | } else { | ||||
int pos = findTargetPosition(topNames, targetName); | |||||
final int pos = findTargetPosition(topNames, targetName); | |||||
topNames.insertElementAt(targetName, pos); | topNames.insertElementAt(targetName, pos); | ||||
topDescriptions.insertElementAt(targetDescription, pos); | topDescriptions.insertElementAt(targetDescription, pos); | ||||
if (targetName.length() > maxLength) { | if (targetName.length() > maxLength) { | ||||
@@ -1221,7 +1228,7 @@ public class Main implements AntMain { | |||||
printTargets(project, subNames, null, subDependencies, "Other targets:", 0); | printTargets(project, subNames, null, subDependencies, "Other targets:", 0); | ||||
} | } | ||||
String defaultTarget = project.getDefaultTarget(); | |||||
final String defaultTarget = project.getDefaultTarget(); | |||||
if (defaultTarget != null && !"".equals(defaultTarget)) { | if (defaultTarget != null && !"".equals(defaultTarget)) { | ||||
// shouldn't need to check but... | // shouldn't need to check but... | ||||
project.log("Default target: " + defaultTarget); | 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 | * @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(); | final int size = names.size(); | ||||
int res = size; | int res = size; | ||||
for (int i = 0; i < size && res == size; i++) { | 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 | * position so they line up (so long as the names really | ||||
* <i>are</i> shorter than this). | * <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 | // 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 | // got a bit annoyed that I couldn't find a pad function | ||||
String spaces = " "; | String spaces = " "; | ||||
while (spaces.length() <= maxlen) { | while (spaces.length() <= maxlen) { | ||||
spaces += spaces; | spaces += spaces; | ||||
} | } | ||||
StringBuilder msg = new StringBuilder(); | |||||
final StringBuilder msg = new StringBuilder(); | |||||
msg.append(heading + lSep + lSep); | msg.append(heading + lSep + lSep); | ||||
final int size = names.size(); | final int size = names.size(); | ||||
for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | ||||
@@ -1296,7 +1303,7 @@ public class Main implements AntMain { | |||||
} | } | ||||
msg.append(lSep); | msg.append(lSep); | ||||
if (!dependencies.isEmpty()) { | if (!dependencies.isEmpty()) { | ||||
Enumeration<String> deps = dependencies.elementAt(i); | |||||
final Enumeration<String> deps = dependencies.elementAt(i); | |||||
if (deps.hasMoreElements()) { | if (deps.hasMoreElements()) { | ||||
msg.append(" depends on: "); | msg.append(" depends on: "); | ||||
while (deps.hasMoreElements()) { | while (deps.hasMoreElements()) { | ||||
@@ -101,7 +101,7 @@ public class ProjectHelper { | |||||
* | * | ||||
* @since 1.8.2 | * @since 1.8.2 | ||||
*/ | */ | ||||
public final static class OnMissingExtensionPoint { | |||||
public static final class OnMissingExtensionPoint { | |||||
/** fail if the extension-point is not defined */ | /** fail if the extension-point is not defined */ | ||||
public static final OnMissingExtensionPoint FAIL = new OnMissingExtensionPoint( | public static final OnMissingExtensionPoint FAIL = new OnMissingExtensionPoint( | ||||
@@ -181,7 +181,7 @@ public class ProjectHelper { | |||||
return extensionStack; | 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. | * The prefix to prepend to imported target names. | ||||
@@ -205,7 +205,7 @@ public class ProjectHelper { | |||||
targetPrefix.set(prefix); | targetPrefix.set(prefix); | ||||
} | } | ||||
private final static ThreadLocal<String> prefixSeparator = new ThreadLocal<String>() { | |||||
private static final ThreadLocal<String> prefixSeparator = new ThreadLocal<String>() { | |||||
protected String initialValue() { | protected String initialValue() { | ||||
return "."; | return "."; | ||||
} | } | ||||
@@ -231,7 +231,7 @@ public class ProjectHelper { | |||||
prefixSeparator.set(sep); | prefixSeparator.set(sep); | ||||
} | } | ||||
private final static ThreadLocal<Boolean> inIncludeMode = new ThreadLocal<Boolean>() { | |||||
private static final ThreadLocal<Boolean> inIncludeMode = new ThreadLocal<Boolean>() { | |||||
protected Boolean initialValue() { | protected Boolean initialValue() { | ||||
return Boolean.FALSE; | return Boolean.FALSE; | ||||
} | } | ||||
@@ -36,7 +36,7 @@ import org.apache.tools.ant.types.Parameter; | |||||
* </filterchain> | * </filterchain> | ||||
* </copy> | * </copy> | ||||
* </pre> | * </pre> | ||||
* | |||||
* | |||||
* <p>Copies all java sources from <i>src</i> to <i>build</i> and adds the | * <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 | * content of <i>apache-license-java.txt</i> add the beginning of each | ||||
* file.</p> | * file.</p> | ||||
@@ -90,7 +90,8 @@ public final class ConcatFilter extends BaseParamFilterReader | |||||
* @exception IOException if the underlying stream throws an IOException | * @exception IOException if the underlying stream throws an IOException | ||||
* during reading | * during reading | ||||
*/ | */ | ||||
public int read() throws IOException { | |||||
@Override | |||||
public int read() throws IOException { | |||||
// do the "singleton" initialization | // do the "singleton" initialization | ||||
if (!getInitialized()) { | if (!getInitialized()) { | ||||
initialize(); | initialize(); | ||||
@@ -170,7 +171,8 @@ public final class ConcatFilter extends BaseParamFilterReader | |||||
* @return a new filter based on this configuration, but filtering | * @return a new filter based on this configuration, but filtering | ||||
* the specified reader | * the specified reader | ||||
*/ | */ | ||||
public Reader chain(final Reader rdr) { | |||||
@Override | |||||
public Reader chain(final Reader rdr) { | |||||
ConcatFilter newFilter = new ConcatFilter(rdr); | ConcatFilter newFilter = new ConcatFilter(rdr); | ||||
newFilter.setPrepend(getPrepend()); | newFilter.setPrepend(getPrepend()); | ||||
newFilter.setAppend(getAppend()); | newFilter.setAppend(getAppend()); | ||||
@@ -105,15 +105,15 @@ public class Launcher { | |||||
* | * | ||||
* @param args commandline arguments | * @param args commandline arguments | ||||
*/ | */ | ||||
public static void main(String[] args) { | |||||
public static void main(final String[] args) { | |||||
int exitCode; | int exitCode; | ||||
try { | try { | ||||
Launcher launcher = new Launcher(); | |||||
final Launcher launcher = new Launcher(); | |||||
exitCode = launcher.run(args); | exitCode = launcher.run(args); | ||||
} catch (LaunchException e) { | |||||
} catch (final LaunchException e) { | |||||
exitCode = EXIT_CODE_ERROR; | exitCode = EXIT_CODE_ERROR; | ||||
System.err.println(e.getMessage()); | System.err.println(e.getMessage()); | ||||
} catch (Throwable t) { | |||||
} catch (final Throwable t) { | |||||
exitCode = EXIT_CODE_ERROR; | exitCode = EXIT_CODE_ERROR; | ||||
t.printStackTrace(System.err); | t.printStackTrace(System.err); | ||||
} | } | ||||
@@ -136,26 +136,28 @@ public class Launcher { | |||||
* @param libPathURLs the list of paths to add to | * @param libPathURLs the list of paths to add to | ||||
* @throws MalformedURLException if we can't create a URL | * @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 { | throws MalformedURLException { | ||||
StringTokenizer tokenizer = new StringTokenizer(path, File.pathSeparator); | |||||
final StringTokenizer tokenizer = new StringTokenizer(path, File.pathSeparator); | |||||
while (tokenizer.hasMoreElements()) { | 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()) { | if (elementName.indexOf('%') != -1 && !element.exists()) { | ||||
continue; | continue; | ||||
} | } | ||||
if (getJars && element.isDirectory()) { | if (getJars && element.isDirectory()) { | ||||
// add any jars in the directory | // 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) { | for (int j = 0; j < dirURLs.length; ++j) { | ||||
if (launchDiag) { System.out.println("adding library JAR: " + dirURLs[j]);} | if (launchDiag) { System.out.println("adding library JAR: " + dirURLs[j]);} | ||||
libPathURLs.add(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); | libPathURLs.add(url); | ||||
} | } | ||||
} | } | ||||
@@ -170,13 +172,13 @@ public class Launcher { | |||||
* cannot be created. | * cannot be created. | ||||
* @throws LaunchException for launching problems | * @throws LaunchException for launching problems | ||||
*/ | */ | ||||
private int run(String[] args) | |||||
private int run(final String[] args) | |||||
throws LaunchException, MalformedURLException { | throws LaunchException, MalformedURLException { | ||||
String antHomeProperty = System.getProperty(ANTHOME_PROPERTY); | |||||
final String antHomeProperty = System.getProperty(ANTHOME_PROPERTY); | |||||
File antHome = null; | 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; | String mainClassname = MAIN_CLASS; | ||||
if (antHomeProperty != null) { | if (antHomeProperty != null) { | ||||
@@ -193,9 +195,9 @@ public class Launcher { | |||||
+ "ant could not be located (estimated value="+antHome.getAbsolutePath()+")"); | + "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; | String cpString = null; | ||||
List<String> argList = new ArrayList<String>(); | |||||
final List<String> argList = new ArrayList<String>(); | |||||
String[] newArgs; | String[] newArgs; | ||||
boolean noUserLib = false; | boolean noUserLib = false; | ||||
boolean noClassPath = false; | boolean noClassPath = false; | ||||
@@ -244,21 +246,21 @@ public class Launcher { | |||||
if (argList.size() == args.length) { | if (argList.size() == args.length) { | ||||
newArgs = args; | newArgs = args; | ||||
} else { | } 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); | 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); | logPath("tools.jar",toolsJAR); | ||||
URL[] jars = getJarArray( | |||||
final URL[] jars = getJarArray( | |||||
libURLs, userURLs, systemURLs, toolsJAR); | libURLs, userURLs, systemURLs, toolsJAR); | ||||
// now update the class.path property | // now update the class.path property | ||||
StringBuffer baseClassPath | |||||
final StringBuffer baseClassPath | |||||
= new StringBuffer(System.getProperty(JAVA_CLASS_PATH)); | = new StringBuffer(System.getProperty(JAVA_CLASS_PATH)); | ||||
if (baseClassPath.charAt(baseClassPath.length() - 1) | if (baseClassPath.charAt(baseClassPath.length() - 1) | ||||
== File.pathSeparatorChar) { | == File.pathSeparatorChar) { | ||||
@@ -272,27 +274,27 @@ public class Launcher { | |||||
setProperty(JAVA_CLASS_PATH, baseClassPath.toString()); | 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); | Thread.currentThread().setContextClassLoader(loader); | ||||
Class<?> mainClass = null; | Class<?> mainClass = null; | ||||
int exitCode = 0; | int exitCode = 0; | ||||
Throwable thrown=null; | Throwable thrown=null; | ||||
try { | try { | ||||
mainClass = loader.loadClass(mainClassname); | mainClass = loader.loadClass(mainClassname); | ||||
AntMain main = (AntMain) mainClass.newInstance(); | |||||
final AntMain main = (AntMain) mainClass.newInstance(); | |||||
main.startAnt(newArgs, null, null); | main.startAnt(newArgs, null, null); | ||||
} catch (InstantiationException ex) { | |||||
} catch (final InstantiationException ex) { | |||||
System.err.println( | System.err.println( | ||||
"Incompatible version of " + mainClassname + " detected"); | "Incompatible version of " + mainClassname + " detected"); | ||||
File mainJar = Locator.getClassSource(mainClass); | |||||
final File mainJar = Locator.getClassSource(mainClass); | |||||
System.err.println( | System.err.println( | ||||
"Location of this class " + mainJar); | "Location of this class " + mainJar); | ||||
thrown = ex; | thrown = ex; | ||||
} catch (ClassNotFoundException cnfe) { | |||||
} catch (final ClassNotFoundException cnfe) { | |||||
System.err.println( | System.err.println( | ||||
"Failed to locate" + mainClassname); | "Failed to locate" + mainClassname); | ||||
thrown = cnfe; | thrown = cnfe; | ||||
} catch (Throwable t) { | |||||
} catch (final Throwable t) { | |||||
t.printStackTrace(System.err); | t.printStackTrace(System.err); | ||||
thrown=t; | thrown=t; | ||||
} | } | ||||
@@ -314,15 +316,15 @@ public class Launcher { | |||||
* @return an array of URLs. | * @return an array of URLs. | ||||
* @throws MalformedURLException if the URLs cannot be created. | * @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 { | throws MalformedURLException { | ||||
List<URL> libPathURLs = new ArrayList<URL>(); | |||||
final List<URL> libPathURLs = new ArrayList<URL>(); | |||||
if (cpString != null) { | if (cpString != null) { | ||||
addPath(cpString, false, libPathURLs); | addPath(cpString, false, libPathURLs); | ||||
} | } | ||||
for (String libPath : libPaths) { | |||||
for (final String libPath : libPaths) { | |||||
addPath(libPath, true, libPathURLs); | addPath(libPath, true, libPathURLs); | ||||
} | } | ||||
@@ -337,9 +339,9 @@ public class Launcher { | |||||
* @return the URLs | * @return the URLs | ||||
* @throws MalformedURLException if the URLs cannot be created. | * @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; | File antLibDir = null; | ||||
String antLibDirProperty = System.getProperty(ANTLIBDIR_PROPERTY); | |||||
final String antLibDirProperty = System.getProperty(ANTLIBDIR_PROPERTY); | |||||
if (antLibDirProperty != null) { | if (antLibDirProperty != null) { | ||||
antLibDir = new File(antLibDirProperty); | antLibDir = new File(antLibDirProperty); | ||||
} | } | ||||
@@ -356,7 +358,7 @@ public class Launcher { | |||||
* @throws MalformedURLException if the URLs cannot be created. | * @throws MalformedURLException if the URLs cannot be created. | ||||
*/ | */ | ||||
private URL[] getUserURLs() throws MalformedURLException { | private URL[] getUserURLs() throws MalformedURLException { | ||||
File userLibDir | |||||
final File userLibDir | |||||
= new File(System.getProperty(USER_HOMEDIR), USER_LIBDIR); | = new File(System.getProperty(USER_HOMEDIR), USER_LIBDIR); | ||||
return Locator.getLocationURLs(userLibDir); | return Locator.getLocationURLs(userLibDir); | ||||
@@ -372,13 +374,13 @@ public class Launcher { | |||||
* @throws MalformedURLException if there is a problem. | * @throws MalformedURLException if there is a problem. | ||||
*/ | */ | ||||
private URL[] getJarArray ( | 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 { | throws MalformedURLException { | ||||
int numJars = libJars.length + userJars.length + systemJars.length; | int numJars = libJars.length + userJars.length + systemJars.length; | ||||
if (toolsJar != null) { | if (toolsJar != null) { | ||||
numJars++; | numJars++; | ||||
} | } | ||||
URL[] jars = new URL[numJars]; | |||||
final URL[] jars = new URL[numJars]; | |||||
System.arraycopy(libJars, 0, jars, 0, libJars.length); | System.arraycopy(libJars, 0, jars, 0, libJars.length); | ||||
System.arraycopy(userJars, 0, jars, libJars.length, userJars.length); | System.arraycopy(userJars, 0, jars, libJars.length, userJars.length); | ||||
System.arraycopy(systemJars, 0, jars, userJars.length + libJars.length, | System.arraycopy(systemJars, 0, jars, userJars.length + libJars.length, | ||||
@@ -395,14 +397,14 @@ public class Launcher { | |||||
* @param name property name | * @param name property name | ||||
* @param value value | * @param value value | ||||
*/ | */ | ||||
private void setProperty(String name, String value) { | |||||
private void setProperty(final String name, final String value) { | |||||
if (launchDiag) { | if (launchDiag) { | ||||
System.out.println("Setting \"" + name + "\" to \"" + value + "\""); | System.out.println("Setting \"" + name + "\" to \"" + value + "\""); | ||||
} | } | ||||
System.setProperty(name, value); | System.setProperty(name, value); | ||||
} | } | ||||
private void logPath(String name,File path) { | |||||
private void logPath(final String name,final File path) { | |||||
if(launchDiag) { | if(launchDiag) { | ||||
System.out.println(name+"= \""+path+"\""); | System.out.println(name+"= \""+path+"\""); | ||||
} | } | ||||
@@ -27,8 +27,6 @@ import java.text.CharacterIterator; | |||||
import java.text.StringCharacterIterator; | import java.text.StringCharacterIterator; | ||||
import java.util.Locale; | import java.util.Locale; | ||||
import org.apache.tools.ant.util.FileUtils; | |||||
// CheckStyle:LineLengthCheck OFF - urls are long! | // CheckStyle:LineLengthCheck OFF - urls are long! | ||||
/** | /** | ||||
* The Locator is a utility class which is used to find certain items | * 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 | * 7 -> Reverse | ||||
* 8 -> Hidden | * 8 -> Hidden | ||||
* </pre> | * </pre> | ||||
* | |||||
* | |||||
* Foreground is one of the following:<pre> | * Foreground is one of the following:<pre> | ||||
* 30 -> Black | * 30 -> Black | ||||
* 31 -> Red | * 31 -> Red | ||||
@@ -207,7 +207,8 @@ public class AnsiColorLogger extends DefaultLogger { | |||||
* @see DefaultLogger#printMessage | * @see DefaultLogger#printMessage | ||||
*/ | */ | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
protected void printMessage(final String message, | |||||
@Override | |||||
protected void printMessage(final String message, | |||||
final PrintStream stream, | final PrintStream stream, | ||||
final int priority) { | final int priority) { | ||||
if (message != null && stream != null) { | 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 | * A logger which logs nothing but build failure and what task might output | ||||
* | |||||
* | |||||
* @since 1.9.0 | * @since 1.9.0 | ||||
*/ | */ | ||||
public class SilentLogger extends DefaultLogger { | public class SilentLogger extends DefaultLogger { | ||||
public void buildStarted(BuildEvent event) { | |||||
@Override | |||||
public void buildStarted(BuildEvent event) { | |||||
// log nothing | // log nothing | ||||
} | } | ||||
public void buildFinished(BuildEvent event) { | |||||
@Override | |||||
public void buildFinished(BuildEvent event) { | |||||
if (event.getException() != null) { | if (event.getException() != null) { | ||||
super.buildFinished(event); | super.buildFinished(event); | ||||
} | } | ||||
} | } | ||||
public void targetStarted(BuildEvent event) { | |||||
@Override | |||||
public void targetStarted(BuildEvent event) { | |||||
// log nothing | // log nothing | ||||
} | } | ||||
public void targetFinished(BuildEvent event) { | |||||
@Override | |||||
public void targetFinished(BuildEvent event) { | |||||
// log nothing | // log nothing | ||||
} | } | ||||
public void taskStarted(BuildEvent event) { | |||||
@Override | |||||
public void taskStarted(BuildEvent event) { | |||||
// log nothing | // log nothing | ||||
} | } | ||||
public void taskFinished(BuildEvent event) { | |||||
@Override | |||||
public void taskFinished(BuildEvent event) { | |||||
// log nothing | // log nothing | ||||
} | } | ||||
@@ -57,7 +57,7 @@ public class AntStructure extends Task { | |||||
* The output file. | * The output file. | ||||
* @param output the output file | * @param output the output file | ||||
*/ | */ | ||||
public void setOutput(File output) { | |||||
public void setOutput(final File output) { | |||||
this.output = output; | this.output = output; | ||||
} | } | ||||
@@ -66,7 +66,7 @@ public class AntStructure extends Task { | |||||
* @param p the printer to use. | * @param p the printer to use. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
public void add(StructurePrinter p) { | |||||
public void add(final StructurePrinter p) { | |||||
printer = p; | printer = p; | ||||
} | } | ||||
@@ -75,7 +75,8 @@ public class AntStructure extends Task { | |||||
* | * | ||||
* @exception BuildException if the DTD cannot be written. | * @exception BuildException if the DTD cannot be written. | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
if (output == null) { | if (output == null) { | ||||
throw new BuildException("output attribute is required", getLocation()); | throw new BuildException("output attribute is required", getLocation()); | ||||
@@ -85,7 +86,7 @@ public class AntStructure extends Task { | |||||
try { | try { | ||||
try { | try { | ||||
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(output), "UTF8")); | out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(output), "UTF8")); | ||||
} catch (UnsupportedEncodingException ue) { | |||||
} catch (final UnsupportedEncodingException ue) { | |||||
/* | /* | ||||
* Plain impossible with UTF8, see | * Plain impossible with UTF8, see | ||||
* http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html | * 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); | printer.printTargetDecl(out); | ||||
for (String typeName : getProject().getCopyOfDataTypeDefinitions() | |||||
for (final String typeName : getProject().getCopyOfDataTypeDefinitions() | |||||
.keySet()) { | .keySet()) { | ||||
printer.printElementDecl( | printer.printElementDecl( | ||||
out, getProject(), typeName, | out, getProject(), typeName, | ||||
getProject().getDataTypeDefinitions().get(typeName)); | getProject().getDataTypeDefinitions().get(typeName)); | ||||
} | } | ||||
for (String tName : getProject().getCopyOfTaskDefinitions().keySet()) { | |||||
for (final String tName : getProject().getCopyOfTaskDefinitions().keySet()) { | |||||
printer.printElementDecl(out, getProject(), tName, | printer.printElementDecl(out, getProject(), tName, | ||||
getProject().getTaskDefinitions().get(tName)); | getProject().getTaskDefinitions().get(tName)); | ||||
} | } | ||||
@@ -119,7 +120,7 @@ public class AntStructure extends Task { | |||||
throw new IOException("Encountered an error writing Ant" | throw new IOException("Encountered an error writing Ant" | ||||
+ " structure"); | + " structure"); | ||||
} | } | ||||
} catch (IOException ioe) { | |||||
} catch (final IOException ioe) { | |||||
throw new BuildException("Error writing " | throw new BuildException("Error writing " | ||||
+ output.getAbsolutePath(), ioe, getLocation()); | + output.getAbsolutePath(), ioe, getLocation()); | ||||
} finally { | } finally { | ||||
@@ -136,7 +137,7 @@ public class AntStructure extends Task { | |||||
* are called exactly once, {@link #printElementDecl} once for | * are called exactly once, {@link #printElementDecl} once for | ||||
* each declared task and type.</p> | * each declared task and type.</p> | ||||
*/ | */ | ||||
public static interface StructurePrinter { | |||||
public interface StructurePrinter { | |||||
/** | /** | ||||
* Prints the header of the generated output. | * 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 TASKS = "%tasks;"; | ||||
private static final String TYPES = "%types;"; | 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(); | 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()); | printHead(out, tasks.keys(), types.keys()); | ||||
} | } | ||||
@@ -197,14 +200,14 @@ public class AntStructure extends Task { | |||||
* <p>Basically this prints the XML declaration, defines some | * <p>Basically this prints the XML declaration, defines some | ||||
* entities and the project element.</p> | * 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("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); | ||||
out.println("<!ENTITY % boolean \"(true|false|on|off|yes|no)\">"); | out.println("<!ENTITY % boolean \"(true|false|on|off|yes|no)\">"); | ||||
out.print("<!ENTITY % tasks \""); | out.print("<!ENTITY % tasks \""); | ||||
boolean first = true; | boolean first = true; | ||||
while (tasks.hasMoreElements()) { | while (tasks.hasMoreElements()) { | ||||
String tName = tasks.nextElement(); | |||||
final String tName = tasks.nextElement(); | |||||
if (!first) { | if (!first) { | ||||
out.print(" | "); | out.print(" | "); | ||||
} else { | } else { | ||||
@@ -216,7 +219,7 @@ public class AntStructure extends Task { | |||||
out.print("<!ENTITY % types \""); | out.print("<!ENTITY % types \""); | ||||
first = true; | first = true; | ||||
while (types.hasMoreElements()) { | while (types.hasMoreElements()) { | ||||
String typeName = types.nextElement(); | |||||
final String typeName = types.nextElement(); | |||||
if (!first) { | if (!first) { | ||||
out.print(" | "); | out.print(" | "); | ||||
} else { | } else { | ||||
@@ -243,7 +246,8 @@ public class AntStructure extends Task { | |||||
/** | /** | ||||
* Prints the definition for the target element. | * 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("<!ELEMENT target ("); | ||||
out.print(TASKS); | out.print(TASKS); | ||||
out.print(" | "); | out.print(" | "); | ||||
@@ -259,7 +263,7 @@ public class AntStructure extends Task { | |||||
/** | /** | ||||
* Prints the definition for the target element. | * 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.print("<!ATTLIST "); | ||||
out.println(tag); | out.println(tag); | ||||
out.println(" id ID #IMPLIED"); | out.println(" id ID #IMPLIED"); | ||||
@@ -276,8 +280,9 @@ public class AntStructure extends Task { | |||||
/** | /** | ||||
* Print the definition for a given element. | * 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)) { | if (visited.containsKey(name)) { | ||||
return; | return; | ||||
@@ -287,7 +292,7 @@ public class AntStructure extends Task { | |||||
IntrospectionHelper ih = null; | IntrospectionHelper ih = null; | ||||
try { | try { | ||||
ih = IntrospectionHelper.getHelper(p, element); | ih = IntrospectionHelper.getHelper(p, element); | ||||
} catch (Throwable t) { | |||||
} catch (final Throwable t) { | |||||
/* | /* | ||||
* TODO - failed to load the class properly. | * TODO - failed to load the class properly. | ||||
* | * | ||||
@@ -309,7 +314,7 @@ public class AntStructure extends Task { | |||||
return; | return; | ||||
} | } | ||||
Vector<String> v = new Vector<String>(); | |||||
final Vector<String> v = new Vector<String>(); | |||||
if (ih.supportsCharacters()) { | if (ih.supportsCharacters()) { | ||||
v.addElement("#PCDATA"); | v.addElement("#PCDATA"); | ||||
} | } | ||||
@@ -348,14 +353,14 @@ public class AntStructure extends Task { | |||||
e = ih.getAttributes(); | e = ih.getAttributes(); | ||||
while (e.hasMoreElements()) { | while (e.hasMoreElements()) { | ||||
String attrName = (String) e.nextElement(); | |||||
final String attrName = e.nextElement(); | |||||
if ("id".equals(attrName)) { | if ("id".equals(attrName)) { | ||||
continue; | continue; | ||||
} | } | ||||
sb.append(LINE_SEP).append(" ") | sb.append(LINE_SEP).append(" ") | ||||
.append(attrName).append(" "); | .append(attrName).append(" "); | ||||
Class<?> type = ih.getAttributeType(attrName); | |||||
final Class<?> type = ih.getAttributeType(attrName); | |||||
if (type.equals(java.lang.Boolean.class) | if (type.equals(java.lang.Boolean.class) | ||||
|| type.equals(java.lang.Boolean.TYPE)) { | || type.equals(java.lang.Boolean.TYPE)) { | ||||
sb.append(BOOLEAN).append(" "); | sb.append(BOOLEAN).append(" "); | ||||
@@ -363,9 +368,9 @@ public class AntStructure extends Task { | |||||
sb.append("IDREF "); | sb.append("IDREF "); | ||||
} else if (EnumeratedAttribute.class.isAssignableFrom(type)) { | } else if (EnumeratedAttribute.class.isAssignableFrom(type)) { | ||||
try { | try { | ||||
EnumeratedAttribute ea = | |||||
final EnumeratedAttribute ea = | |||||
(EnumeratedAttribute) type.newInstance(); | (EnumeratedAttribute) type.newInstance(); | ||||
String[] values = ea.getValues(); | |||||
final String[] values = ea.getValues(); | |||||
if (values == null | if (values == null | ||||
|| values.length == 0 | || values.length == 0 | ||||
|| !areNmtokens(values)) { | || !areNmtokens(values)) { | ||||
@@ -380,15 +385,15 @@ public class AntStructure extends Task { | |||||
} | } | ||||
sb.append(") "); | sb.append(") "); | ||||
} | } | ||||
} catch (InstantiationException ie) { | |||||
} catch (final InstantiationException ie) { | |||||
sb.append("CDATA "); | sb.append("CDATA "); | ||||
} catch (IllegalAccessException ie) { | |||||
} catch (final IllegalAccessException ie) { | |||||
sb.append("CDATA "); | sb.append("CDATA "); | ||||
} | } | ||||
} else if (type.getSuperclass() != null | } else if (type.getSuperclass() != null | ||||
&& type.getSuperclass().getName().equals("java.lang.Enum")) { | && type.getSuperclass().getName().equals("java.lang.Enum")) { | ||||
try { | try { | ||||
Object[] values = (Object[]) type.getMethod("values", (Class[]) null) | |||||
final Object[] values = (Object[]) type.getMethod("values", (Class[]) null) | |||||
.invoke(null, (Object[]) null); | .invoke(null, (Object[]) null); | ||||
if (values.length == 0) { | if (values.length == 0) { | ||||
sb.append("CDATA "); | sb.append("CDATA "); | ||||
@@ -403,7 +408,7 @@ public class AntStructure extends Task { | |||||
} | } | ||||
sb.append(") "); | sb.append(") "); | ||||
} | } | ||||
} catch (Exception x) { | |||||
} catch (final Exception x) { | |||||
sb.append("CDATA "); | sb.append("CDATA "); | ||||
} | } | ||||
} else { | } else { | ||||
@@ -416,7 +421,7 @@ public class AntStructure extends Task { | |||||
final int count = v.size(); | final int count = v.size(); | ||||
for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
String nestedName = (String) v.elementAt(i); | |||||
final String nestedName = v.elementAt(i); | |||||
if (!"#PCDATA".equals(nestedName) | if (!"#PCDATA".equals(nestedName) | ||||
&& !TASKS.equals(nestedName) | && !TASKS.equals(nestedName) | ||||
&& !TYPES.equals(nestedName)) { | && !TYPES.equals(nestedName)) { | ||||
@@ -430,10 +435,10 @@ public class AntStructure extends Task { | |||||
* @param s the string to test | * @param s the string to test | ||||
* @return true if the string matches the XML-NMTOKEN | * @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(); | final int length = s.length(); | ||||
for (int i = 0; i < length; i++) { | 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 | // TODO - we are committing CombiningChar and Extender here | ||||
if (!Character.isLetterOrDigit(c) | if (!Character.isLetterOrDigit(c) | ||||
&& c != '.' && c != '-' && c != '_' && c != ':') { | && c != '.' && c != '-' && c != '_' && c != ':') { | ||||
@@ -451,7 +456,7 @@ public class AntStructure extends Task { | |||||
* @param s the array of string to test | * @param s the array of string to test | ||||
* @return true if all the strings in the array math XML-NMTOKEN | * @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++) { | for (int i = 0; i < s.length; i++) { | ||||
if (!isNmtoken(s[i])) { | if (!isNmtoken(s[i])) { | ||||
return false; | return false; | ||||
@@ -466,7 +471,7 @@ public class AntStructure extends Task { | |||||
* @param s the string to test | * @param s the string to test | ||||
* @return true if the string matches the XML-NMTOKEN | * @return true if the string matches the XML-NMTOKEN | ||||
*/ | */ | ||||
protected boolean isNmtoken(String s) { | |||||
protected boolean isNmtoken(final String s) { | |||||
return DTDPrinter.isNmtoken(s); | return DTDPrinter.isNmtoken(s); | ||||
} | } | ||||
@@ -478,7 +483,7 @@ public class AntStructure extends Task { | |||||
* @param s the array of string to test | * @param s the array of string to test | ||||
* @return true if all the strings in the array math XML-NMTOKEN | * @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); | return DTDPrinter.areNmtokens(s); | ||||
} | } | ||||
} | } |
@@ -33,37 +33,38 @@ public class BindTargets extends Task { | |||||
private String extensionPoint; | private String extensionPoint; | ||||
private List<String> targets = new ArrayList<String>(); | |||||
private final List<String> targets = new ArrayList<String>(); | |||||
private OnMissingExtensionPoint onMissingExtensionPoint; | private OnMissingExtensionPoint onMissingExtensionPoint; | ||||
public void setExtensionPoint(String extensionPoint) { | |||||
public void setExtensionPoint(final String extensionPoint) { | |||||
this.extensionPoint = extensionPoint; | this.extensionPoint = extensionPoint; | ||||
} | } | ||||
public void setOnMissingExtensionPoint(String onMissingExtensionPoint) { | |||||
public void setOnMissingExtensionPoint(final String onMissingExtensionPoint) { | |||||
try { | try { | ||||
this.onMissingExtensionPoint = OnMissingExtensionPoint.valueOf(onMissingExtensionPoint); | this.onMissingExtensionPoint = OnMissingExtensionPoint.valueOf(onMissingExtensionPoint); | ||||
} catch (IllegalArgumentException e) { | |||||
} catch (final IllegalArgumentException e) { | |||||
throw new BuildException("Invalid onMissingExtensionPoint: " + onMissingExtensionPoint); | throw new BuildException("Invalid onMissingExtensionPoint: " + onMissingExtensionPoint); | ||||
} | } | ||||
} | } | ||||
public void setOnMissingExtensionPoint(OnMissingExtensionPoint onMissingExtensionPoint) { | |||||
public void setOnMissingExtensionPoint(final OnMissingExtensionPoint onMissingExtensionPoint) { | |||||
this.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++) { | for (int i = 0; i < inputs.length; i++) { | ||||
String input = inputs[i].trim(); | |||||
final String input = inputs[i].trim(); | |||||
if (input.length() > 0) { | if (input.length() > 0) { | ||||
targets.add(input); | targets.add(input); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
if (extensionPoint == null) { | if (extensionPoint == null) { | ||||
throw new BuildException("extensionPoint required", getLocation()); | throw new BuildException("extensionPoint required", getLocation()); | ||||
} | } | ||||
@@ -77,13 +78,13 @@ public class BindTargets extends Task { | |||||
if (onMissingExtensionPoint == null) { | if (onMissingExtensionPoint == null) { | ||||
onMissingExtensionPoint = OnMissingExtensionPoint.FAIL; | onMissingExtensionPoint = OnMissingExtensionPoint.FAIL; | ||||
} | } | ||||
ProjectHelper helper = (ProjectHelper) getProject().getReference( | |||||
final ProjectHelper helper = (ProjectHelper) getProject().getReference( | |||||
ProjectHelper.PROJECTHELPER_REFERENCE); | ProjectHelper.PROJECTHELPER_REFERENCE); | ||||
for (Iterator<String> itTarget = targets.iterator(); itTarget.hasNext();) { | |||||
for (final Iterator<String> itTarget = targets.iterator(); itTarget.hasNext();) { | |||||
helper.getExtensionStack().add( | 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 | * <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 | * this component uniquely, and the full name of the class (including the packages) that | ||||
* implements this component.</p> | * implements this component.</p> | ||||
* | |||||
* | |||||
* @since Ant 1.8 | * @since Ant 1.8 | ||||
* @ant.task category="internal" | * @ant.task category="internal" | ||||
*/ | */ | ||||
@@ -95,8 +95,8 @@ public class Copy extends Task { | |||||
protected Mapper mapperElement = null; | protected Mapper mapperElement = null; | ||||
protected FileUtils fileUtils; | protected FileUtils fileUtils; | ||||
//CheckStyle:VisibilityModifier ON | //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 inputEncoding = null; | ||||
private String outputEncoding = null; | private String outputEncoding = null; | ||||
private long granularity = 0; | private long granularity = 0; | ||||
@@ -127,7 +127,7 @@ public class Copy extends Task { | |||||
* Set a single source file to copy. | * Set a single source file to copy. | ||||
* @param file the file to copy. | * @param file the file to copy. | ||||
*/ | */ | ||||
public void setFile(File file) { | |||||
public void setFile(final File file) { | |||||
this.file = file; | this.file = file; | ||||
} | } | ||||
@@ -135,7 +135,7 @@ public class Copy extends Task { | |||||
* Set the destination file. | * Set the destination file. | ||||
* @param destFile the file to copy to. | * @param destFile the file to copy to. | ||||
*/ | */ | ||||
public void setTofile(File destFile) { | |||||
public void setTofile(final File destFile) { | |||||
this.destFile = destFile; | this.destFile = destFile; | ||||
} | } | ||||
@@ -143,7 +143,7 @@ public class Copy extends Task { | |||||
* Set the destination directory. | * Set the destination directory. | ||||
* @param destDir the destination directory. | * @param destDir the destination directory. | ||||
*/ | */ | ||||
public void setTodir(File destDir) { | |||||
public void setTodir(final File destDir) { | |||||
this.destDir = destDir; | this.destDir = destDir; | ||||
} | } | ||||
@@ -152,7 +152,7 @@ public class Copy extends Task { | |||||
* @return a filter chain object. | * @return a filter chain object. | ||||
*/ | */ | ||||
public FilterChain createFilterChain() { | public FilterChain createFilterChain() { | ||||
FilterChain filterChain = new FilterChain(); | |||||
final FilterChain filterChain = new FilterChain(); | |||||
filterChains.addElement(filterChain); | filterChains.addElement(filterChain); | ||||
return filterChain; | return filterChain; | ||||
} | } | ||||
@@ -162,7 +162,7 @@ public class Copy extends Task { | |||||
* @return a filter set object. | * @return a filter set object. | ||||
*/ | */ | ||||
public FilterSet createFilterSet() { | public FilterSet createFilterSet() { | ||||
FilterSet filterSet = new FilterSet(); | |||||
final FilterSet filterSet = new FilterSet(); | |||||
filterSets.addElement(filterSet); | filterSets.addElement(filterSet); | ||||
return filterSet; | return filterSet; | ||||
} | } | ||||
@@ -175,7 +175,8 @@ public class Copy extends Task { | |||||
* replaced with setPreserveLastModified(boolean) to | * replaced with setPreserveLastModified(boolean) to | ||||
* consistently let the Introspection mechanism work. | * consistently let the Introspection mechanism work. | ||||
*/ | */ | ||||
public void setPreserveLastModified(String preserve) { | |||||
@Deprecated | |||||
public void setPreserveLastModified(final String preserve) { | |||||
setPreserveLastModified(Project.toBoolean(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. | * Give the copied files the same last modified time as the original files. | ||||
* @param preserve if true preserve the modified time; default is false. | * @param preserve if true preserve the modified time; default is false. | ||||
*/ | */ | ||||
public void setPreserveLastModified(boolean preserve) { | |||||
public void setPreserveLastModified(final boolean preserve) { | |||||
preserveLastModified = preserve; | preserveLastModified = preserve; | ||||
} | } | ||||
@@ -220,7 +221,7 @@ public class Copy extends Task { | |||||
* Set filtering mode. | * Set filtering mode. | ||||
* @param filtering if true enable filtering; default is false. | * @param filtering if true enable filtering; default is false. | ||||
*/ | */ | ||||
public void setFiltering(boolean filtering) { | |||||
public void setFiltering(final boolean filtering) { | |||||
this.filtering = filtering; | this.filtering = filtering; | ||||
} | } | ||||
@@ -230,7 +231,7 @@ public class Copy extends Task { | |||||
* even if the destination file(s) are younger than | * even if the destination file(s) are younger than | ||||
* the corresponding source file. Default is false. | * the corresponding source file. Default is false. | ||||
*/ | */ | ||||
public void setOverwrite(boolean overwrite) { | |||||
public void setOverwrite(final boolean overwrite) { | |||||
this.forceOverwrite = overwrite; | this.forceOverwrite = overwrite; | ||||
} | } | ||||
@@ -241,7 +242,7 @@ public class Copy extends Task { | |||||
* | * | ||||
* @since Ant 1.8.2 | * @since Ant 1.8.2 | ||||
*/ | */ | ||||
public void setForce(boolean f) { | |||||
public void setForce(final boolean f) { | |||||
force = f; | force = f; | ||||
} | } | ||||
@@ -263,7 +264,7 @@ public class Copy extends Task { | |||||
* @param flatten if true flatten the destination directory. Default | * @param flatten if true flatten the destination directory. Default | ||||
* is false. | * is false. | ||||
*/ | */ | ||||
public void setFlatten(boolean flatten) { | |||||
public void setFlatten(final boolean flatten) { | |||||
this.flatten = flatten; | this.flatten = flatten; | ||||
} | } | ||||
@@ -272,7 +273,7 @@ public class Copy extends Task { | |||||
* @param verbose whether to output the names of copied files. | * @param verbose whether to output the names of copied files. | ||||
* Default is false. | * Default is false. | ||||
*/ | */ | ||||
public void setVerbose(boolean verbose) { | |||||
public void setVerbose(final boolean verbose) { | |||||
this.verbosity = verbose ? Project.MSG_INFO : Project.MSG_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. | * Set whether to copy empty directories. | ||||
* @param includeEmpty if true copy empty directories. Default is true. | * @param includeEmpty if true copy empty directories. Default is true. | ||||
*/ | */ | ||||
public void setIncludeEmptyDirs(boolean includeEmpty) { | |||||
public void setIncludeEmptyDirs(final boolean includeEmpty) { | |||||
this.includeEmpty = includeEmpty; | this.includeEmpty = includeEmpty; | ||||
} | } | ||||
@@ -292,7 +293,7 @@ public class Copy extends Task { | |||||
* whether or not to display error messages when a file or | * whether or not to display error messages when a file or | ||||
* directory does not exist. Default is false. | * directory does not exist. Default is false. | ||||
*/ | */ | ||||
public void setQuiet(boolean quiet) { | |||||
public void setQuiet(final boolean quiet) { | |||||
this.quiet = quiet; | this.quiet = quiet; | ||||
} | } | ||||
@@ -307,7 +308,7 @@ public class Copy extends Task { | |||||
* compatibility with earlier releases. | * compatibility with earlier releases. | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
public void setEnableMultipleMappings(boolean enableMultipleMappings) { | |||||
public void setEnableMultipleMappings(final boolean enableMultipleMappings) { | |||||
this.enableMultipleMappings = enableMultipleMappings; | this.enableMultipleMappings = enableMultipleMappings; | ||||
} | } | ||||
@@ -324,7 +325,7 @@ public class Copy extends Task { | |||||
* to the output but keep going. Default is true. | * to the output but keep going. Default is true. | ||||
* @param failonerror true or false. | * @param failonerror true or false. | ||||
*/ | */ | ||||
public void setFailOnError(boolean failonerror) { | |||||
public void setFailOnError(final boolean failonerror) { | |||||
this.failonerror = failonerror; | this.failonerror = failonerror; | ||||
} | } | ||||
@@ -332,7 +333,7 @@ public class Copy extends Task { | |||||
* Add a set of files to copy. | * Add a set of files to copy. | ||||
* @param set 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); | add(set); | ||||
} | } | ||||
@@ -341,7 +342,7 @@ public class Copy extends Task { | |||||
* @param res a resource collection to copy. | * @param res a resource collection to copy. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
public void add(ResourceCollection res) { | |||||
public void add(final ResourceCollection res) { | |||||
rcs.add(res); | rcs.add(res); | ||||
} | } | ||||
@@ -364,7 +365,7 @@ public class Copy extends Task { | |||||
* @param fileNameMapper the mapper to add. | * @param fileNameMapper the mapper to add. | ||||
* @since Ant 1.6.3 | * @since Ant 1.6.3 | ||||
*/ | */ | ||||
public void add(FileNameMapper fileNameMapper) { | |||||
public void add(final FileNameMapper fileNameMapper) { | |||||
createMapper().add(fileNameMapper); | createMapper().add(fileNameMapper); | ||||
} | } | ||||
@@ -373,7 +374,7 @@ public class Copy extends Task { | |||||
* @param encoding the character encoding. | * @param encoding the character encoding. | ||||
* @since 1.32, Ant 1.5 | * @since 1.32, Ant 1.5 | ||||
*/ | */ | ||||
public void setEncoding(String encoding) { | |||||
public void setEncoding(final String encoding) { | |||||
this.inputEncoding = encoding; | this.inputEncoding = encoding; | ||||
if (outputEncoding == null) { | if (outputEncoding == null) { | ||||
outputEncoding = encoding; | outputEncoding = encoding; | ||||
@@ -395,7 +396,7 @@ public class Copy extends Task { | |||||
* @param encoding the output character encoding. | * @param encoding the output character encoding. | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
public void setOutputEncoding(String encoding) { | |||||
public void setOutputEncoding(final String encoding) { | |||||
this.outputEncoding = encoding; | this.outputEncoding = encoding; | ||||
} | } | ||||
@@ -419,7 +420,7 @@ public class Copy extends Task { | |||||
* date. | * date. | ||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
public void setGranularity(long granularity) { | |||||
public void setGranularity(final long granularity) { | |||||
this.granularity = granularity; | this.granularity = granularity; | ||||
} | } | ||||
@@ -427,21 +428,22 @@ public class Copy extends Task { | |||||
* Perform the copy operation. | * Perform the copy operation. | ||||
* @exception BuildException if an error occurs. | * @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; | ResourceCollection savedRc = null; | ||||
if (file == null && destFile != null && rcs.size() == 1) { | if (file == null && destFile != null && rcs.size() == 1) { | ||||
// will be removed in validateAttributes | // will be removed in validateAttributes | ||||
savedRc = (ResourceCollection) rcs.elementAt(0); | |||||
savedRc = rcs.elementAt(0); | |||||
} | } | ||||
try { | try { | ||||
// make sure we don't have an illegal set of options | // make sure we don't have an illegal set of options | ||||
try { | try { | ||||
validateAttributes(); | validateAttributes(); | ||||
} catch (BuildException e) { | |||||
} catch (final BuildException e) { | |||||
if (failonerror | if (failonerror | ||||
|| !getMessage(e) | || !getMessage(e) | ||||
.equals(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE)) { | .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. | 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(); | final int size = rcs.size(); | ||||
for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | ||||
ResourceCollection rc = rcs.elementAt(i); | |||||
final ResourceCollection rc = rcs.elementAt(i); | |||||
// Step (1) - beware of the ZipFileSet | // Step (1) - beware of the ZipFileSet | ||||
if (rc instanceof FileSet && rc.isFilesystemOnly()) { | if (rc instanceof FileSet && rc.isFilesystemOnly()) { | ||||
FileSet fs = (FileSet) rc; | |||||
final FileSet fs = (FileSet) rc; | |||||
DirectoryScanner ds = null; | DirectoryScanner ds = null; | ||||
try { | try { | ||||
ds = fs.getDirectoryScanner(getProject()); | ds = fs.getDirectoryScanner(getProject()); | ||||
} catch (BuildException e) { | |||||
} catch (final BuildException e) { | |||||
if (failonerror | if (failonerror | ||||
|| !getMessage(e).endsWith(DirectoryScanner | || !getMessage(e).endsWith(DirectoryScanner | ||||
.DOES_NOT_EXIST_POSTFIX)) { | .DOES_NOT_EXIST_POSTFIX)) { | ||||
@@ -498,10 +500,10 @@ public class Copy extends Task { | |||||
continue; | 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 | if (!flatten && mapperElement == null | ||||
&& ds.isEverythingIncluded() && !fs.hasPatterns()) { | && ds.isEverythingIncluded() && !fs.hasPatterns()) { | ||||
completeDirMap.put(fromDir, destDir); | completeDirMap.put(fromDir, destDir); | ||||
@@ -516,9 +518,9 @@ public class Copy extends Task { | |||||
"Only FileSystem resources are supported."); | "Only FileSystem resources are supported."); | ||||
} | } | ||||
for (Resource r : rc) { | |||||
for (final Resource r : rc) { | |||||
if (!r.isExists()) { | if (!r.isExists()) { | ||||
String message = "Warning: Could not find resource " | |||||
final String message = "Warning: Could not find resource " | |||||
+ r.toLongString() + " to copy."; | + r.toLongString() + " to copy."; | ||||
if (!failonerror) { | if (!failonerror) { | ||||
if (!quiet) { | if (!quiet) { | ||||
@@ -532,9 +534,9 @@ public class Copy extends Task { | |||||
File baseDir = NULL_FILE_PLACEHOLDER; | File baseDir = NULL_FILE_PLACEHOLDER; | ||||
String name = r.getName(); | String name = r.getName(); | ||||
FileProvider fp = r.as(FileProvider.class); | |||||
final FileProvider fp = r.as(FileProvider.class); | |||||
if (fp != null) { | if (fp != null) { | ||||
FileResource fr = ResourceUtils.asFileResource(fp); | |||||
final FileResource fr = ResourceUtils.asFileResource(fp); | |||||
baseDir = getKeyFile(fr.getBaseDir()); | baseDir = getKeyFile(fr.getBaseDir()); | ||||
if (fr.getBaseDir() == null) { | if (fr.getBaseDir() == null) { | ||||
name = fr.getFile().getAbsolutePath(); | name = fr.getFile().getAbsolutePath(); | ||||
@@ -562,7 +564,7 @@ public class Copy extends Task { | |||||
// do all the copy operations now... | // do all the copy operations now... | ||||
try { | try { | ||||
doFileOperations(); | doFileOperations(); | ||||
} catch (BuildException e) { | |||||
} catch (final BuildException e) { | |||||
if (!failonerror) { | if (!failonerror) { | ||||
if (!quiet) { | if (!quiet) { | ||||
log("Warning: " + getMessage(e), Project.MSG_ERR); | log("Warning: " + getMessage(e), Project.MSG_ERR); | ||||
@@ -573,17 +575,17 @@ public class Copy extends Task { | |||||
} | } | ||||
if (nonFileResources.size() > 0 || singleResource != null) { | 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 | // restrict to out-of-date resources | ||||
Map<Resource, String[]> map = scan(nonFiles, destDir); | |||||
final Map<Resource, String[]> map = scan(nonFiles, destDir); | |||||
if (singleResource != null) { | if (singleResource != null) { | ||||
map.put(singleResource, | map.put(singleResource, | ||||
new String[] { destFile.getAbsolutePath() }); | |||||
new String[] {destFile.getAbsolutePath()}); | |||||
} | } | ||||
try { | try { | ||||
doResourceOperations(map); | doResourceOperations(map); | ||||
} catch (BuildException e) { | |||||
} catch (final BuildException e) { | |||||
if (!failonerror) { | if (!failonerror) { | ||||
if (!quiet) { | if (!quiet) { | ||||
log("Warning: " + getMessage(e), Project.MSG_ERR); | log("Warning: " + getMessage(e), Project.MSG_ERR); | ||||
@@ -630,7 +632,7 @@ public class Copy extends Task { | |||||
+ " is up to date.", Project.MSG_VERBOSE); | + " is up to date.", Project.MSG_VERBOSE); | ||||
} | } | ||||
} else { | } else { | ||||
String message = "Warning: Could not find file " | |||||
final String message = "Warning: Could not find file " | |||||
+ file.getAbsolutePath() + " to copy."; | + file.getAbsolutePath() + " to copy."; | ||||
if (!failonerror) { | if (!failonerror) { | ||||
if (!quiet) { | if (!quiet) { | ||||
@@ -644,11 +646,11 @@ public class Copy extends Task { | |||||
} | } | ||||
private void iterateOverBaseDirs( | 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]; | String[] srcFiles = new String[0]; | ||||
if (files != null) { | if (files != null) { | ||||
@@ -689,7 +691,7 @@ public class Copy extends Task { | |||||
throw new BuildException( | throw new BuildException( | ||||
"Cannot concatenate multiple files into a single file."); | "Cannot concatenate multiple files into a single file."); | ||||
} else { | } else { | ||||
ResourceCollection rc = (ResourceCollection) rcs.elementAt(0); | |||||
final ResourceCollection rc = rcs.elementAt(0); | |||||
if (!rc.isFilesystemOnly() && !supportsNonFileResources()) { | if (!rc.isFilesystemOnly() && !supportsNonFileResources()) { | ||||
throw new BuildException("Only FileSystem resources are" | throw new BuildException("Only FileSystem resources are" | ||||
+ " supported."); | + " supported."); | ||||
@@ -697,8 +699,8 @@ public class Copy extends Task { | |||||
if (rc.size() == 0) { | if (rc.size() == 0) { | ||||
throw new BuildException(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE); | throw new BuildException(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE); | ||||
} else if (rc.size() == 1) { | } 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 (file == null) { | ||||
if (r != null) { | if (r != null) { | ||||
file = r.getFile(); | file = r.getFile(); | ||||
@@ -730,9 +732,9 @@ public class Copy extends Task { | |||||
* @param files A list of files to copy. | * @param files A list of files to copy. | ||||
* @param dirs A list of directories 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); | buildMap(fromDir, toDir, files, mapper, fileCopyMap); | ||||
if (includeEmpty) { | if (includeEmpty) { | ||||
@@ -752,7 +754,7 @@ public class Copy extends Task { | |||||
* | * | ||||
* @since Ant 1.7 | * @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()); | return buildMap(fromResources, toDir, getMapper()); | ||||
} | } | ||||
@@ -765,11 +767,11 @@ public class Copy extends Task { | |||||
* @param mapper a <code>FileNameMapper</code> value. | * @param mapper a <code>FileNameMapper</code> value. | ||||
* @param map a map of source file to array of destination files. | * @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; | String[] toCopy = null; | ||||
if (forceOverwrite) { | if (forceOverwrite) { | ||||
Vector<String> v = new Vector<String>(); | |||||
final Vector<String> v = new Vector<String>(); | |||||
for (int i = 0; i < names.length; i++) { | for (int i = 0; i < names.length; i++) { | ||||
if (mapper.mapFileName(names[i]) != null) { | if (mapper.mapFileName(names[i]) != null) { | ||||
v.addElement(names[i]); | v.addElement(names[i]); | ||||
@@ -778,12 +780,12 @@ public class Copy extends Task { | |||||
toCopy = new String[v.size()]; | toCopy = new String[v.size()]; | ||||
v.copyInto(toCopy); | v.copyInto(toCopy); | ||||
} else { | } else { | ||||
SourceFileScanner ds = new SourceFileScanner(this); | |||||
final SourceFileScanner ds = new SourceFileScanner(this); | |||||
toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity); | toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity); | ||||
} | } | ||||
for (int i = 0; i < toCopy.length; i++) { | 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) { | if (!enableMultipleMappings) { | ||||
map.put(src.getAbsolutePath(), | map.put(src.getAbsolutePath(), | ||||
@@ -807,12 +809,12 @@ public class Copy extends Task { | |||||
* @return a map of source resource to array of destination files. | * @return a map of source resource to array of destination files. | ||||
* @since Ant 1.7 | * @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; | Resource[] toCopy = null; | ||||
if (forceOverwrite) { | if (forceOverwrite) { | ||||
Vector<Resource> v = new Vector<Resource>(); | |||||
final Vector<Resource> v = new Vector<Resource>(); | |||||
for (int i = 0; i < fromResources.length; i++) { | for (int i = 0; i < fromResources.length; i++) { | ||||
if (mapper.mapFileName(fromResources[i].getName()) != null) { | if (mapper.mapFileName(fromResources[i].getName()) != null) { | ||||
v.addElement(fromResources[i]); | v.addElement(fromResources[i]); | ||||
@@ -825,14 +827,15 @@ public class Copy extends Task { | |||||
ResourceUtils.selectOutOfDateSources(this, fromResources, | ResourceUtils.selectOutOfDateSources(this, fromResources, | ||||
mapper, | mapper, | ||||
new ResourceFactory() { | new ResourceFactory() { | ||||
public Resource getResource(String name) { | |||||
@Override | |||||
public Resource getResource(final String name) { | |||||
return new FileResource(toDir, name); | return new FileResource(toDir, name); | ||||
} | } | ||||
}, | }, | ||||
granularity); | granularity); | ||||
} | } | ||||
for (int i = 0; i < toCopy.length; i++) { | 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++) { | for (int j = 0; j < mappedFiles.length; j++) { | ||||
if (mappedFiles[j] == null) { | if (mappedFiles[j] == null) { | ||||
throw new BuildException("Can't copy a resource without a" | throw new BuildException("Can't copy a resource without a" | ||||
@@ -865,12 +868,12 @@ public class Copy extends Task { | |||||
+ " file" + (fileCopyMap.size() == 1 ? "" : "s") | + " file" + (fileCopyMap.size() == 1 ? "" : "s") | ||||
+ " to " + destDir.getAbsolutePath()); | + " 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++) { | for (int i = 0; i < toFiles.length; i++) { | ||||
String toFile = toFiles[i]; | |||||
final String toFile = toFiles[i]; | |||||
if (fromFile.equals(toFile)) { | if (fromFile.equals(toFile)) { | ||||
log("Skipping self-copy of " + fromFile, verbosity); | log("Skipping self-copy of " + fromFile, verbosity); | ||||
@@ -879,13 +882,13 @@ public class Copy extends Task { | |||||
try { | try { | ||||
log("Copying " + fromFile + " to " + toFile, verbosity); | log("Copying " + fromFile + " to " + toFile, verbosity); | ||||
FilterSetCollection executionFilters = | |||||
final FilterSetCollection executionFilters = | |||||
new FilterSetCollection(); | new FilterSetCollection(); | ||||
if (filtering) { | if (filtering) { | ||||
executionFilters | executionFilters | ||||
.addFilterSet(getProject().getGlobalFilterSet()); | .addFilterSet(getProject().getGlobalFilterSet()); | ||||
} | } | ||||
for (FilterSet filterSet : filterSets) { | |||||
for (final FilterSet filterSet : filterSets) { | |||||
executionFilters.addFilterSet(filterSet); | executionFilters.addFilterSet(filterSet); | ||||
} | } | ||||
fileUtils.copyFile(new File(fromFile), new File(toFile), | fileUtils.copyFile(new File(fromFile), new File(toFile), | ||||
@@ -895,10 +898,10 @@ public class Copy extends Task { | |||||
/* append: */ false, inputEncoding, | /* append: */ false, inputEncoding, | ||||
outputEncoding, getProject(), | outputEncoding, getProject(), | ||||
getForce()); | getForce()); | ||||
} catch (IOException ioe) { | |||||
} catch (final IOException ioe) { | |||||
String msg = "Failed to copy " + fromFile + " to " + toFile | String msg = "Failed to copy " + fromFile + " to " + toFile | ||||
+ " due to " + getDueTo(ioe); | + " due to " + getDueTo(ioe); | ||||
File targetFile = new File(toFile); | |||||
final File targetFile = new File(toFile); | |||||
if (!(ioe instanceof | if (!(ioe instanceof | ||||
ResourceUtils.ReadOnlyTargetFileException) | ResourceUtils.ReadOnlyTargetFileException) | ||||
&& targetFile.exists() && !targetFile.delete()) { | && targetFile.exists() && !targetFile.delete()) { | ||||
@@ -914,9 +917,9 @@ public class Copy extends Task { | |||||
} | } | ||||
if (includeEmpty) { | if (includeEmpty) { | ||||
int createCount = 0; | int createCount = 0; | ||||
for (String[] dirs : dirCopyMap.values()) { | |||||
for (final String[] dirs : dirCopyMap.values()) { | |||||
for (int i = 0; i < dirs.length; i++) { | 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.exists()) { | ||||
if (!(d.mkdirs() || d.isDirectory())) { | if (!(d.mkdirs() || d.isDirectory())) { | ||||
log("Unable to create directory " | 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. | * @param map a map of source resource to array of destination files. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
protected void doResourceOperations(Map<Resource, String[]> map) { | |||||
protected void doResourceOperations(final Map<Resource, String[]> map) { | |||||
if (map.size() > 0) { | if (map.size() > 0) { | ||||
log("Copying " + map.size() | log("Copying " + map.size() | ||||
+ " resource" + (map.size() == 1 ? "" : "s") | + " resource" + (map.size() == 1 ? "" : "s") | ||||
+ " to " + destDir.getAbsolutePath()); | + " 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 { | try { | ||||
log("Copying " + fromResource + " to " + toFile, | log("Copying " + fromResource + " to " + toFile, | ||||
verbosity); | verbosity); | ||||
FilterSetCollection executionFilters = new FilterSetCollection(); | |||||
final FilterSetCollection executionFilters = new FilterSetCollection(); | |||||
if (filtering) { | if (filtering) { | ||||
executionFilters | executionFilters | ||||
.addFilterSet(getProject().getGlobalFilterSet()); | .addFilterSet(getProject().getGlobalFilterSet()); | ||||
} | } | ||||
for (FilterSet filterSet : filterSets) { | |||||
for (final FilterSet filterSet : filterSets) { | |||||
executionFilters.addFilterSet(filterSet); | executionFilters.addFilterSet(filterSet); | ||||
} | } | ||||
ResourceUtils.copyResource(fromResource, | ResourceUtils.copyResource(fromResource, | ||||
@@ -978,11 +981,11 @@ public class Copy extends Task { | |||||
outputEncoding, | outputEncoding, | ||||
getProject(), | getProject(), | ||||
getForce()); | getForce()); | ||||
} catch (IOException ioe) { | |||||
} catch (final IOException ioe) { | |||||
String msg = "Failed to copy " + fromResource | String msg = "Failed to copy " + fromResource | ||||
+ " to " + toFile | + " to " + toFile | ||||
+ " due to " + getDueTo(ioe); | + " due to " + getDueTo(ioe); | ||||
File targetFile = new File(toFile); | |||||
final File targetFile = new File(toFile); | |||||
if (!(ioe instanceof | if (!(ioe instanceof | ||||
ResourceUtils.ReadOnlyTargetFileException) | ResourceUtils.ReadOnlyTargetFileException) | ||||
&& targetFile.exists() && !targetFile.delete()) { | && 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. | * Adds the given strings to a list contained in the given map. | ||||
* The file is the key into the 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) { | if (names != null) { | ||||
baseDir = getKeyFile(baseDir); | baseDir = getKeyFile(baseDir); | ||||
List<String> l = m.get(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. | * Adds the given string to a list contained in the given map. | ||||
* The file is the key into the 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) { | if (name != null) { | ||||
add(baseDir, new String[] {name}, m); | 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. | * 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; | 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 | * @return ex.getMessage() if ex.getMessage() is not null | ||||
* otherwise return ex.toString() | * otherwise return ex.toString() | ||||
*/ | */ | ||||
private String getMessage(Exception ex) { | |||||
private String getMessage(final Exception ex) { | |||||
return ex.getMessage() == null ? ex.toString() : ex.getMessage(); | return ex.getMessage() == null ? ex.toString() : ex.getMessage(); | ||||
} | } | ||||
@@ -1082,9 +1085,9 @@ public class Copy extends Task { | |||||
* output the message | * output the message | ||||
* if the exception is MalformedInput add a little note. | * 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) { | if (!baseIOException || ex.getMessage() == null) { | ||||
message.append(ex.getClass().getName()); | message.append(ex.getClass().getName()); | ||||
} | } | ||||
@@ -65,7 +65,7 @@ public class EchoXML extends XMLFragment { | |||||
public void setNamespacePolicy(NamespacePolicy n) { | public void setNamespacePolicy(NamespacePolicy n) { | ||||
namespacePolicy = n; | namespacePolicy = n; | ||||
} | } | ||||
/** | /** | ||||
* Set whether to append the output file. | * Set whether to append the output file. | ||||
* @param b boolean append flag. | * @param b boolean append flag. | ||||
@@ -115,7 +115,8 @@ public class EchoXML extends XMLFragment { | |||||
setValue(s); | setValue(s); | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {IGNORE, ELEMENTS, ALL}; | return new String[] {IGNORE, ELEMENTS, ALL}; | ||||
} | } | ||||
@@ -84,7 +84,7 @@ public class Get extends Task { | |||||
private boolean skipExisting = false; | private boolean skipExisting = false; | ||||
private boolean httpUseCaches = true; // on by default | private boolean httpUseCaches = true; // on by default | ||||
private Mapper mapperElement = null; | private Mapper mapperElement = null; | ||||
private String userAgent = | |||||
private String userAgent = | |||||
System.getProperty(MagicNames.HTTP_AGENT_PROPERTY, | System.getProperty(MagicNames.HTTP_AGENT_PROPERTY, | ||||
DEFAULT_AGENT_PREFIX + "/" | DEFAULT_AGENT_PREFIX + "/" | ||||
+ Main.getShortAntVersion()); | + Main.getShortAntVersion()); | ||||
@@ -94,7 +94,8 @@ public class Get extends Task { | |||||
* | * | ||||
* @exception BuildException Thrown in unrecoverable error. | * @exception BuildException Thrown in unrecoverable error. | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
checkAttributes(); | checkAttributes(); | ||||
for (Resource r : sources) { | for (Resource r : sources) { | ||||
@@ -166,7 +167,8 @@ public class Get extends Task { | |||||
* is false. | * is false. | ||||
* @deprecated only gets the first configured resource | * @deprecated only gets the first configured resource | ||||
*/ | */ | ||||
public boolean doGet(int logLevel, DownloadProgress progress) | |||||
@Deprecated | |||||
public boolean doGet(int logLevel, DownloadProgress progress) | |||||
throws IOException { | throws IOException { | ||||
checkAttributes(); | checkAttributes(); | ||||
for (Resource r : sources) { | for (Resource r : sources) { | ||||
@@ -430,7 +432,7 @@ public class Get extends Task { | |||||
public void setSkipExisting(boolean s) { | public void setSkipExisting(boolean s) { | ||||
this.skipExisting = s; | this.skipExisting = s; | ||||
} | } | ||||
/** | /** | ||||
* HTTP connections only - set the user-agent to be used | * HTTP connections only - set the user-agent to be used | ||||
* when communicating with remote server. if null, then | * when communicating with remote server. if null, then | ||||
@@ -456,7 +458,7 @@ public class Get extends Task { | |||||
public void setHttpUseCaches(boolean httpUseCache) { | public void setHttpUseCaches(boolean httpUseCache) { | ||||
this.httpUseCaches = httpUseCache; | this.httpUseCaches = httpUseCache; | ||||
} | } | ||||
/** | /** | ||||
* Define the mapper to map source to destination files. | * Define the mapper to map source to destination files. | ||||
* @return a mapper to be configured. | * @return a mapper to be configured. | ||||
@@ -518,7 +520,8 @@ public class Get extends Task { | |||||
/** | /** | ||||
* begin a download | * begin a download | ||||
*/ | */ | ||||
public void beginDownload() { | |||||
@Override | |||||
public void beginDownload() { | |||||
} | } | ||||
@@ -526,13 +529,15 @@ public class Get extends Task { | |||||
* tick handler | * tick handler | ||||
* | * | ||||
*/ | */ | ||||
public void onTick() { | |||||
@Override | |||||
public void onTick() { | |||||
} | } | ||||
/** | /** | ||||
* end a download | * end a download | ||||
*/ | */ | ||||
public void endDownload() { | |||||
@Override | |||||
public void endDownload() { | |||||
} | } | ||||
} | } | ||||
@@ -557,7 +562,8 @@ public class Get extends Task { | |||||
/** | /** | ||||
* begin a download | * begin a download | ||||
*/ | */ | ||||
public void beginDownload() { | |||||
@Override | |||||
public void beginDownload() { | |||||
dots = 0; | dots = 0; | ||||
} | } | ||||
@@ -565,7 +571,8 @@ public class Get extends Task { | |||||
* tick handler | * tick handler | ||||
* | * | ||||
*/ | */ | ||||
public void onTick() { | |||||
@Override | |||||
public void onTick() { | |||||
out.print("."); | out.print("."); | ||||
if (dots++ > DOTS_PER_LINE) { | if (dots++ > DOTS_PER_LINE) { | ||||
out.flush(); | out.flush(); | ||||
@@ -576,7 +583,8 @@ public class Get extends Task { | |||||
/** | /** | ||||
* end a download | * end a download | ||||
*/ | */ | ||||
public void endDownload() { | |||||
@Override | |||||
public void endDownload() { | |||||
out.println(); | out.println(); | ||||
out.flush(); | out.flush(); | ||||
} | } | ||||
@@ -599,7 +607,7 @@ public class Get extends Task { | |||||
private URLConnection connection; | private URLConnection connection; | ||||
private int redirections = 0; | private int redirections = 0; | ||||
private String userAgent = null; | private String userAgent = null; | ||||
GetThread(URL source, File dest, | GetThread(URL source, File dest, | ||||
boolean h, long t, DownloadProgress p, int l, String userAgent) { | boolean h, long t, DownloadProgress p, int l, String userAgent) { | ||||
this.source = source; | this.source = source; | ||||
@@ -611,7 +619,8 @@ public class Get extends Task { | |||||
this.userAgent = userAgent; | this.userAgent = userAgent; | ||||
} | } | ||||
public void run() { | |||||
@Override | |||||
public void run() { | |||||
try { | try { | ||||
success = get(); | success = get(); | ||||
} catch (IOException ioex) { | } catch (IOException ioex) { | ||||
@@ -684,7 +693,7 @@ public class Get extends Task { | |||||
} | } | ||||
// Set the user agent | // Set the user agent | ||||
connection.addRequestProperty("User-Agent", this.userAgent); | connection.addRequestProperty("User-Agent", this.userAgent); | ||||
// prepare Java 1.1 style credentials | // prepare Java 1.1 style credentials | ||||
if (uname != null || pword != null) { | if (uname != null || pword != null) { | ||||
String up = uname + ":" + pword; | String up = uname + ":" + pword; | ||||
@@ -762,7 +771,7 @@ public class Get extends Task { | |||||
} | } | ||||
private boolean isMoved(int responseCode) { | 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_MOVED_TEMP || | ||||
responseCode == HttpURLConnection.HTTP_SEE_OTHER || | responseCode == HttpURLConnection.HTTP_SEE_OTHER || | ||||
responseCode == HTTP_MOVED_TEMP; | responseCode == HTTP_MOVED_TEMP; | ||||
@@ -56,7 +56,7 @@ public class Input extends Task { | |||||
* this allows the use of a custom inputhandler. | * this allows the use of a custom inputhandler. | ||||
* @param refid the String refid. | * @param refid the String refid. | ||||
*/ | */ | ||||
public void setRefid(String refid) { | |||||
public void setRefid(final String refid) { | |||||
this.refid = refid; | this.refid = refid; | ||||
} | } | ||||
/** | /** | ||||
@@ -70,7 +70,7 @@ public class Input extends Task { | |||||
* Set the InputHandler classname. | * Set the InputHandler classname. | ||||
* @param classname the String classname. | * @param classname the String classname. | ||||
*/ | */ | ||||
public void setClassname(String classname) { | |||||
public void setClassname(final String classname) { | |||||
this.classname = classname; | this.classname = classname; | ||||
} | } | ||||
/** | /** | ||||
@@ -84,7 +84,7 @@ public class Input extends Task { | |||||
* Set the handler type. | * Set the handler type. | ||||
* @param type a HandlerType. | * @param type a HandlerType. | ||||
*/ | */ | ||||
public void setType(HandlerType type) { | |||||
public void setType(final HandlerType type) { | |||||
this.type = type; | this.type = type; | ||||
} | } | ||||
/** | /** | ||||
@@ -101,7 +101,7 @@ public class Input extends Task { | |||||
if (refid != null) { | if (refid != null) { | ||||
try { | try { | ||||
return (InputHandler) (getProject().getReference(refid)); | return (InputHandler) (getProject().getReference(refid)); | ||||
} catch (ClassCastException e) { | |||||
} catch (final ClassCastException e) { | |||||
throw new BuildException( | throw new BuildException( | ||||
refid + " does not denote an InputHandler", e); | refid + " does not denote an InputHandler", e); | ||||
} | } | ||||
@@ -120,16 +120,17 @@ public class Input extends Task { | |||||
* "default", "propertyfile", "greedy", "secure" (since Ant 1.8). | * "default", "propertyfile", "greedy", "secure" (since Ant 1.8). | ||||
*/ | */ | ||||
public static class HandlerType extends EnumeratedAttribute { | 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 | private static final InputHandler[] HANDLERS | ||||
= { new DefaultInputHandler(), | |||||
= {new DefaultInputHandler(), | |||||
new PropertyFileInputHandler(), | new PropertyFileInputHandler(), | ||||
new GreedyInputHandler(), | new GreedyInputHandler(), | ||||
new SecureInputHandler() }; | |||||
new SecureInputHandler()}; | |||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return VALUES; | return VALUES; | ||||
} | } | ||||
private InputHandler getInputHandler() { | private InputHandler getInputHandler() { | ||||
@@ -152,7 +153,7 @@ public class Input extends Task { | |||||
* | * | ||||
* @param validargs A comma separated String defining valid input args. | * @param validargs A comma separated String defining valid input args. | ||||
*/ | */ | ||||
public void setValidargs (String validargs) { | |||||
public void setValidargs (final String validargs) { | |||||
this.validargs = validargs; | this.validargs = validargs; | ||||
} | } | ||||
@@ -163,7 +164,7 @@ public class Input extends Task { | |||||
* | * | ||||
* @param addproperty Name for the property to be created from input | * @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; | 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. | * Sets the Message which gets displayed to the user during the build run. | ||||
* @param message The message to be displayed. | * @param message The message to be displayed. | ||||
*/ | */ | ||||
public void setMessage (String message) { | |||||
public void setMessage (final String message) { | |||||
this.message = message; | this.message = message; | ||||
messageAttribute = true; | messageAttribute = true; | ||||
} | } | ||||
@@ -183,7 +184,7 @@ public class Input extends Task { | |||||
* @param defaultvalue Default value for the property if no input | * @param defaultvalue Default value for the property if no input | ||||
* is received | * is received | ||||
*/ | */ | ||||
public void setDefaultvalue (String defaultvalue) { | |||||
public void setDefaultvalue (final String defaultvalue) { | |||||
this.defaultvalue = defaultvalue; | this.defaultvalue = defaultvalue; | ||||
} | } | ||||
@@ -191,7 +192,7 @@ public class Input extends Task { | |||||
* Set a multiline message. | * Set a multiline message. | ||||
* @param msg The message to be displayed. | * @param msg The message to be displayed. | ||||
*/ | */ | ||||
public void addText(String msg) { | |||||
public void addText(final String msg) { | |||||
if (messageAttribute && "".equals(msg.trim())) { | if (messageAttribute && "".equals(msg.trim())) { | ||||
return; | return; | ||||
} | } | ||||
@@ -208,7 +209,8 @@ public class Input extends Task { | |||||
* Actual method executed by ant. | * Actual method executed by ant. | ||||
* @throws BuildException on error | * @throws BuildException on error | ||||
*/ | */ | ||||
public void execute () throws BuildException { | |||||
@Override | |||||
public void execute () throws BuildException { | |||||
if (addproperty != null | if (addproperty != null | ||||
&& getProject().getProperty(addproperty) != null) { | && getProject().getProperty(addproperty) != null) { | ||||
log("skipping " + getTaskName() + " as property " + addproperty | log("skipping " + getTaskName() + " as property " + addproperty | ||||
@@ -218,14 +220,14 @@ public class Input extends Task { | |||||
InputRequest request = null; | InputRequest request = null; | ||||
if (validargs != null) { | if (validargs != null) { | ||||
Vector<String> accept = StringUtils.split(validargs, ','); | |||||
final Vector<String> accept = StringUtils.split(validargs, ','); | |||||
request = new MultipleChoiceInputRequest(message, accept); | request = new MultipleChoiceInputRequest(message, accept); | ||||
} else { | } else { | ||||
request = new InputRequest(message); | request = new InputRequest(message); | ||||
} | } | ||||
request.setDefaultValue(defaultvalue); | request.setDefaultValue(defaultvalue); | ||||
InputHandler h = handler == null | |||||
final InputHandler h = handler == null | |||||
? getProject().getInputHandler() | ? getProject().getInputHandler() | ||||
: handler.getInputHandler(); | : handler.getInputHandler(); | ||||
@@ -349,7 +349,7 @@ public abstract class JDBCTask extends Task { | |||||
info.put("password", getPassword()); | info.put("password", getPassword()); | ||||
for (Iterator<Property> props = connectionProperties.iterator(); | for (Iterator<Property> props = connectionProperties.iterator(); | ||||
props.hasNext(); ) { | |||||
props.hasNext();) { | |||||
Property p = props.next(); | Property p = props.next(); | ||||
String name = p.getName(); | String name = p.getName(); | ||||
String value = p.getValue(); | String value = p.getValue(); | ||||
@@ -407,7 +407,7 @@ public abstract class JDBCTask extends Task { | |||||
// in most cases. | // in most cases. | ||||
synchronized (LOADER_MAP) { | synchronized (LOADER_MAP) { | ||||
if (caching) { | if (caching) { | ||||
loader = (AntClassLoader) LOADER_MAP.get(driver); | |||||
loader = LOADER_MAP.get(driver); | |||||
} | } | ||||
if (loader == null) { | if (loader == null) { | ||||
log("Loading " + driver | log("Loading " + driver | ||||
@@ -180,7 +180,7 @@ public class Javac extends MatchingTask { | |||||
* | * | ||||
* @param v Value to assign to debugLevel. | * @param v Value to assign to debugLevel. | ||||
*/ | */ | ||||
public void setDebugLevel(String v) { | |||||
public void setDebugLevel(final String v) { | |||||
this.debugLevel = v; | this.debugLevel = v; | ||||
} | } | ||||
@@ -207,7 +207,7 @@ public class Javac extends MatchingTask { | |||||
* | * | ||||
* @param v Value to assign to source. | * @param v Value to assign to source. | ||||
*/ | */ | ||||
public void setSource(String v) { | |||||
public void setSource(final String v) { | |||||
this.source = v; | this.source = v; | ||||
} | } | ||||
@@ -237,7 +237,7 @@ public class Javac extends MatchingTask { | |||||
* Set the source directories to find the source Java files. | * Set the source directories to find the source Java files. | ||||
* @param srcDir the source directories as a path | * @param srcDir the source directories as a path | ||||
*/ | */ | ||||
public void setSrcdir(Path srcDir) { | |||||
public void setSrcdir(final Path srcDir) { | |||||
if (src == null) { | if (src == null) { | ||||
src = srcDir; | src = srcDir; | ||||
} else { | } else { | ||||
@@ -258,7 +258,7 @@ public class Javac extends MatchingTask { | |||||
* files should be compiled. | * files should be compiled. | ||||
* @param destDir the destination director | * @param destDir the destination director | ||||
*/ | */ | ||||
public void setDestdir(File destDir) { | |||||
public void setDestdir(final File destDir) { | |||||
this.destDir = destDir; | this.destDir = destDir; | ||||
} | } | ||||
@@ -275,7 +275,7 @@ public class Javac extends MatchingTask { | |||||
* Set the sourcepath to be used for this compilation. | * Set the sourcepath to be used for this compilation. | ||||
* @param sourcepath the source path | * @param sourcepath the source path | ||||
*/ | */ | ||||
public void setSourcepath(Path sourcepath) { | |||||
public void setSourcepath(final Path sourcepath) { | |||||
if (compileSourcepath == null) { | if (compileSourcepath == null) { | ||||
compileSourcepath = sourcepath; | compileSourcepath = sourcepath; | ||||
} else { | } else { | ||||
@@ -306,7 +306,7 @@ public class Javac extends MatchingTask { | |||||
* Adds a reference to a source path defined elsewhere. | * Adds a reference to a source path defined elsewhere. | ||||
* @param r a reference to a source path | * @param r a reference to a source path | ||||
*/ | */ | ||||
public void setSourcepathRef(Reference r) { | |||||
public void setSourcepathRef(final Reference r) { | |||||
createSourcepath().setRefid(r); | createSourcepath().setRefid(r); | ||||
} | } | ||||
@@ -315,7 +315,7 @@ public class Javac extends MatchingTask { | |||||
* | * | ||||
* @param classpath an Ant Path object containing the compilation classpath. | * @param classpath an Ant Path object containing the compilation classpath. | ||||
*/ | */ | ||||
public void setClasspath(Path classpath) { | |||||
public void setClasspath(final Path classpath) { | |||||
if (compileClasspath == null) { | if (compileClasspath == null) { | ||||
compileClasspath = classpath; | compileClasspath = classpath; | ||||
} else { | } else { | ||||
@@ -346,7 +346,7 @@ public class Javac extends MatchingTask { | |||||
* Adds a reference to a classpath defined elsewhere. | * Adds a reference to a classpath defined elsewhere. | ||||
* @param r a reference to a classpath | * @param r a reference to a classpath | ||||
*/ | */ | ||||
public void setClasspathRef(Reference r) { | |||||
public void setClasspathRef(final Reference r) { | |||||
createClasspath().setRefid(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 | * @param bootclasspath a path to use as a boot class path (may be more | ||||
* than one) | * than one) | ||||
*/ | */ | ||||
public void setBootclasspath(Path bootclasspath) { | |||||
public void setBootclasspath(final Path bootclasspath) { | |||||
if (this.bootclasspath == null) { | if (this.bootclasspath == null) { | ||||
this.bootclasspath = bootclasspath; | this.bootclasspath = bootclasspath; | ||||
} else { | } else { | ||||
@@ -388,7 +388,7 @@ public class Javac extends MatchingTask { | |||||
* Adds a reference to a classpath defined elsewhere. | * Adds a reference to a classpath defined elsewhere. | ||||
* @param r a reference to a classpath | * @param r a reference to a classpath | ||||
*/ | */ | ||||
public void setBootClasspathRef(Reference r) { | |||||
public void setBootClasspathRef(final Reference r) { | |||||
createBootclasspath().setRefid(r); | createBootclasspath().setRefid(r); | ||||
} | } | ||||
@@ -397,7 +397,7 @@ public class Javac extends MatchingTask { | |||||
* compilation. | * compilation. | ||||
* @param extdirs a path | * @param extdirs a path | ||||
*/ | */ | ||||
public void setExtdirs(Path extdirs) { | |||||
public void setExtdirs(final Path extdirs) { | |||||
if (this.extdirs == null) { | if (this.extdirs == null) { | ||||
this.extdirs = extdirs; | this.extdirs = extdirs; | ||||
} else { | } else { | ||||
@@ -429,7 +429,7 @@ public class Javac extends MatchingTask { | |||||
* If true, list the source files being handed off to the compiler. | * If true, list the source files being handed off to the compiler. | ||||
* @param list if true list the source files | * @param list if true list the source files | ||||
*/ | */ | ||||
public void setListfiles(boolean list) { | |||||
public void setListfiles(final boolean list) { | |||||
listFiles = list; | listFiles = list; | ||||
} | } | ||||
@@ -446,7 +446,7 @@ public class Javac extends MatchingTask { | |||||
* even if there are compilation errors; defaults to true. | * even if there are compilation errors; defaults to true. | ||||
* @param fail if true halt the build on failure | * @param fail if true halt the build on failure | ||||
*/ | */ | ||||
public void setFailonerror(boolean fail) { | |||||
public void setFailonerror(final boolean fail) { | |||||
failOnError = fail; | failOnError = fail; | ||||
} | } | ||||
@@ -454,7 +454,7 @@ public class Javac extends MatchingTask { | |||||
* @ant.attribute ignore="true" | * @ant.attribute ignore="true" | ||||
* @param proceed inverse of failoferror | * @param proceed inverse of failoferror | ||||
*/ | */ | ||||
public void setProceed(boolean proceed) { | |||||
public void setProceed(final boolean proceed) { | |||||
failOnError = !proceed; | failOnError = !proceed; | ||||
} | } | ||||
@@ -471,7 +471,7 @@ public class Javac extends MatchingTask { | |||||
* compiled with deprecation information; defaults to off. | * compiled with deprecation information; defaults to off. | ||||
* @param deprecation if true turn on deprecation information | * @param deprecation if true turn on deprecation information | ||||
*/ | */ | ||||
public void setDeprecation(boolean deprecation) { | |||||
public void setDeprecation(final boolean deprecation) { | |||||
this.deprecation = deprecation; | this.deprecation = deprecation; | ||||
} | } | ||||
@@ -490,7 +490,7 @@ public class Javac extends MatchingTask { | |||||
* (Examples: 83886080, 81920k, or 80m) | * (Examples: 83886080, 81920k, or 80m) | ||||
* @param memoryInitialSize string to pass to VM | * @param memoryInitialSize string to pass to VM | ||||
*/ | */ | ||||
public void setMemoryInitialSize(String memoryInitialSize) { | |||||
public void setMemoryInitialSize(final String memoryInitialSize) { | |||||
this.memoryInitialSize = memoryInitialSize; | this.memoryInitialSize = memoryInitialSize; | ||||
} | } | ||||
@@ -509,7 +509,7 @@ public class Javac extends MatchingTask { | |||||
* (Examples: 83886080, 81920k, or 80m) | * (Examples: 83886080, 81920k, or 80m) | ||||
* @param memoryMaximumSize string to pass to VM | * @param memoryMaximumSize string to pass to VM | ||||
*/ | */ | ||||
public void setMemoryMaximumSize(String memoryMaximumSize) { | |||||
public void setMemoryMaximumSize(final String memoryMaximumSize) { | |||||
this.memoryMaximumSize = memoryMaximumSize; | this.memoryMaximumSize = memoryMaximumSize; | ||||
} | } | ||||
@@ -525,7 +525,7 @@ public class Javac extends MatchingTask { | |||||
* Set the Java source file encoding name. | * Set the Java source file encoding name. | ||||
* @param encoding the source file encoding | * @param encoding the source file encoding | ||||
*/ | */ | ||||
public void setEncoding(String encoding) { | |||||
public void setEncoding(final String encoding) { | |||||
this.encoding = encoding; | this.encoding = encoding; | ||||
} | } | ||||
@@ -542,7 +542,7 @@ public class Javac extends MatchingTask { | |||||
* with debug information; defaults to off. | * with debug information; defaults to off. | ||||
* @param debug if true compile with debug information | * @param debug if true compile with debug information | ||||
*/ | */ | ||||
public void setDebug(boolean debug) { | |||||
public void setDebug(final boolean debug) { | |||||
this.debug = debug; | this.debug = debug; | ||||
} | } | ||||
@@ -558,7 +558,7 @@ public class Javac extends MatchingTask { | |||||
* If true, compiles with optimization enabled. | * If true, compiles with optimization enabled. | ||||
* @param optimize if true compile 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; | this.optimize = optimize; | ||||
} | } | ||||
@@ -575,7 +575,7 @@ public class Javac extends MatchingTask { | |||||
* that support this (jikes and classic). | * that support this (jikes and classic). | ||||
* @param depend if true enable dependency-tracking | * @param depend if true enable dependency-tracking | ||||
*/ | */ | ||||
public void setDepend(boolean depend) { | |||||
public void setDepend(final boolean depend) { | |||||
this.depend = depend; | this.depend = depend; | ||||
} | } | ||||
@@ -591,7 +591,7 @@ public class Javac extends MatchingTask { | |||||
* If true, asks the compiler for verbose output. | * If true, asks the compiler for verbose output. | ||||
* @param verbose 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; | 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". | * "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 | * @param target the target VM | ||||
*/ | */ | ||||
public void setTarget(String target) { | |||||
public void setTarget(final String target) { | |||||
this.targetAttribute = target; | this.targetAttribute = target; | ||||
} | } | ||||
@@ -627,7 +627,7 @@ public class Javac extends MatchingTask { | |||||
* If true, includes Ant's own classpath in the classpath. | * If true, includes Ant's own classpath in the classpath. | ||||
* @param include 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); | includeAntRuntime = Boolean.valueOf(include); | ||||
} | } | ||||
@@ -643,7 +643,7 @@ public class Javac extends MatchingTask { | |||||
* If true, includes the Java runtime libraries in the classpath. | * If true, includes the Java runtime libraries in the classpath. | ||||
* @param include 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; | includeJavaRuntime = include; | ||||
} | } | ||||
@@ -661,7 +661,7 @@ public class Javac extends MatchingTask { | |||||
* | * | ||||
* @param f "true|false|on|off|yes|no" | * @param f "true|false|on|off|yes|no" | ||||
*/ | */ | ||||
public void setFork(boolean f) { | |||||
public void setFork(final boolean f) { | |||||
fork = f; | fork = f; | ||||
} | } | ||||
@@ -672,7 +672,7 @@ public class Javac extends MatchingTask { | |||||
* as the compiler.</p> | * as the compiler.</p> | ||||
* @param forkExec the name of the executable | * @param forkExec the name of the executable | ||||
*/ | */ | ||||
public void setExecutable(String forkExec) { | |||||
public void setExecutable(final String forkExec) { | |||||
forkedExecutable = forkExec; | forkedExecutable = forkExec; | ||||
} | } | ||||
@@ -719,7 +719,7 @@ public class Javac extends MatchingTask { | |||||
* If true, enables the -nowarn option. | * If true, enables the -nowarn option. | ||||
* @param flag if true, enable 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; | this.nowarn = flag; | ||||
} | } | ||||
@@ -736,7 +736,7 @@ public class Javac extends MatchingTask { | |||||
* @return a ImplementationSpecificArgument to be configured | * @return a ImplementationSpecificArgument to be configured | ||||
*/ | */ | ||||
public ImplementationSpecificArgument createCompilerArg() { | public ImplementationSpecificArgument createCompilerArg() { | ||||
ImplementationSpecificArgument arg = | |||||
final ImplementationSpecificArgument arg = | |||||
new ImplementationSpecificArgument(); | new ImplementationSpecificArgument(); | ||||
facade.addImplementationArgument(arg); | facade.addImplementationArgument(arg); | ||||
return arg; | return arg; | ||||
@@ -747,15 +747,15 @@ public class Javac extends MatchingTask { | |||||
* @return array of command line arguments, guaranteed to be non-null. | * @return array of command line arguments, guaranteed to be non-null. | ||||
*/ | */ | ||||
public String[] getCurrentCompilerArgs() { | public String[] getCurrentCompilerArgs() { | ||||
String chosen = facade.getExplicitChoice(); | |||||
final String chosen = facade.getExplicitChoice(); | |||||
try { | try { | ||||
// make sure facade knows about magic properties and fork setting | // make sure facade knows about magic properties and fork setting | ||||
String appliedCompiler = getCompiler(); | |||||
final String appliedCompiler = getCompiler(); | |||||
facade.setImplementation(appliedCompiler); | facade.setImplementation(appliedCompiler); | ||||
String[] result = facade.getArgs(); | String[] result = facade.getArgs(); | ||||
String altCompilerName = getAltCompilerName(facade.getImplementation()); | |||||
final String altCompilerName = getAltCompilerName(facade.getImplementation()); | |||||
if (result.length == 0 && altCompilerName != null) { | if (result.length == 0 && altCompilerName != null) { | ||||
facade.setImplementation(altCompilerName); | 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) | if (JAVAC19.equalsIgnoreCase(anImplementation) | ||||
|| JAVAC18.equalsIgnoreCase(anImplementation) | || JAVAC18.equalsIgnoreCase(anImplementation) | ||||
|| JAVAC17.equalsIgnoreCase(anImplementation) | || JAVAC17.equalsIgnoreCase(anImplementation) | ||||
@@ -784,7 +784,7 @@ public class Javac extends MatchingTask { | |||||
return CLASSIC; | return CLASSIC; | ||||
} | } | ||||
if (MODERN.equalsIgnoreCase(anImplementation)) { | if (MODERN.equalsIgnoreCase(anImplementation)) { | ||||
String nextSelected = assumedJavaVersion(); | |||||
final String nextSelected = assumedJavaVersion(); | |||||
if (JAVAC19.equalsIgnoreCase(nextSelected) | if (JAVAC19.equalsIgnoreCase(nextSelected) | ||||
|| JAVAC18.equalsIgnoreCase(nextSelected) | || JAVAC18.equalsIgnoreCase(nextSelected) | ||||
|| JAVAC17.equalsIgnoreCase(nextSelected) | || JAVAC17.equalsIgnoreCase(nextSelected) | ||||
@@ -810,7 +810,7 @@ public class Javac extends MatchingTask { | |||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
* @param tmpDir the temporary directory | * @param tmpDir the temporary directory | ||||
*/ | */ | ||||
public void setTempdir(File tmpDir) { | |||||
public void setTempdir(final File tmpDir) { | |||||
this.tmpDir = tmpDir; | this.tmpDir = tmpDir; | ||||
} | } | ||||
@@ -831,7 +831,7 @@ public class Javac extends MatchingTask { | |||||
* @param updatedProperty the property name to use. | * @param updatedProperty the property name to use. | ||||
* @since Ant 1.7.1. | * @since Ant 1.7.1. | ||||
*/ | */ | ||||
public void setUpdatedProperty(String updatedProperty) { | |||||
public void setUpdatedProperty(final String updatedProperty) { | |||||
this.updatedProperty = updatedProperty; | this.updatedProperty = updatedProperty; | ||||
} | } | ||||
@@ -842,7 +842,7 @@ public class Javac extends MatchingTask { | |||||
* @param errorProperty the property name to use. | * @param errorProperty the property name to use. | ||||
* @since Ant 1.7.1. | * @since Ant 1.7.1. | ||||
*/ | */ | ||||
public void setErrorProperty(String errorProperty) { | |||||
public void setErrorProperty(final String errorProperty) { | |||||
this.errorProperty = errorProperty; | this.errorProperty = errorProperty; | ||||
} | } | ||||
@@ -853,7 +853,7 @@ public class Javac extends MatchingTask { | |||||
* The default value is "true". | * The default value is "true". | ||||
* @param includeDestClasses the value to use. | * @param includeDestClasses the value to use. | ||||
*/ | */ | ||||
public void setIncludeDestClasses(boolean includeDestClasses) { | |||||
public void setIncludeDestClasses(final boolean includeDestClasses) { | |||||
this.includeDestClasses = includeDestClasses; | this.includeDestClasses = includeDestClasses; | ||||
} | } | ||||
@@ -888,7 +888,7 @@ public class Javac extends MatchingTask { | |||||
* Set the compiler adapter explicitly. | * Set the compiler adapter explicitly. | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void add(CompilerAdapter adapter) { | |||||
public void add(final CompilerAdapter adapter) { | |||||
if (nestedAdapter != null) { | if (nestedAdapter != null) { | ||||
throw new BuildException("Can't have more than one compiler" | throw new BuildException("Can't have more than one compiler" | ||||
+ " adapter"); | + " adapter"); | ||||
@@ -903,7 +903,7 @@ public class Javac extends MatchingTask { | |||||
* | * | ||||
* @since Ant 1.8.3 | * @since Ant 1.8.3 | ||||
*/ | */ | ||||
public void setCreateMissingPackageInfoClass(boolean b) { | |||||
public void setCreateMissingPackageInfoClass(final boolean b) { | |||||
createMissingPackageInfoClass = b; | createMissingPackageInfoClass = b; | ||||
} | } | ||||
@@ -911,23 +911,24 @@ public class Javac extends MatchingTask { | |||||
* Executes the task. | * Executes the task. | ||||
* @exception BuildException if an error occurs | * @exception BuildException if an error occurs | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
checkParameters(); | checkParameters(); | ||||
resetFileLists(); | resetFileLists(); | ||||
// scan source directories and dest directory to build up | // scan source directories and dest directory to build up | ||||
// compile lists | // compile lists | ||||
String[] list = src.list(); | |||||
final String[] list = src.list(); | |||||
for (int i = 0; i < list.length; i++) { | for (int i = 0; i < list.length; i++) { | ||||
File srcDir = getProject().resolveFile(list[i]); | |||||
final File srcDir = getProject().resolveFile(list[i]); | |||||
if (!srcDir.exists()) { | if (!srcDir.exists()) { | ||||
throw new BuildException("srcdir \"" | throw new BuildException("srcdir \"" | ||||
+ srcDir.getPath() | + srcDir.getPath() | ||||
+ "\" does not exist!", getLocation()); | + "\" 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); | scanDir(srcDir, destDir != null ? destDir : srcDir, files); | ||||
} | } | ||||
@@ -956,19 +957,19 @@ public class Javac extends MatchingTask { | |||||
* @param destDir The destination directory | * @param destDir The destination directory | ||||
* @param files An array of filenames | * @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++) { | for (int i = 0; i < extensions.length; i++) { | ||||
m.setFrom(extensions[i]); | m.setFrom(extensions[i]); | ||||
m.setTo("*.class"); | 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) { | if (newFiles.length > 0) { | ||||
lookForPackageInfos(srcDir, newFiles); | lookForPackageInfos(srcDir, newFiles); | ||||
File[] newCompileList | |||||
final File[] newCompileList | |||||
= new File[compileList.length + newFiles.length]; | = new File[compileList.length + newFiles.length]; | ||||
System.arraycopy(compileList, 0, newCompileList, 0, | System.arraycopy(compileList, 0, newCompileList, 0, | ||||
compileList.length); | compileList.length); | ||||
@@ -980,8 +981,8 @@ public class Javac extends MatchingTask { | |||||
} | } | ||||
private String[] findSupportedFileExtensions() { | private String[] findSupportedFileExtensions() { | ||||
String compilerImpl = getCompiler(); | |||||
CompilerAdapter adapter = | |||||
final String compilerImpl = getCompiler(); | |||||
final CompilerAdapter adapter = | |||||
nestedAdapter != null ? nestedAdapter : | nestedAdapter != null ? nestedAdapter : | ||||
CompilerAdapterFactory.getCompiler(compilerImpl, this, | CompilerAdapterFactory.getCompiler(compilerImpl, this, | ||||
createCompilerClasspath()); | createCompilerClasspath()); | ||||
@@ -992,7 +993,7 @@ public class Javac extends MatchingTask { | |||||
} | } | ||||
if (extensions == null) { | if (extensions == null) { | ||||
extensions = new String[] { "java" }; | |||||
extensions = new String[] {"java"}; | |||||
} | } | ||||
// now process the extensions to ensure that they are the | // 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.1", "javac1.2", "javac1.3", "javac1.4", "javac1.5", | ||||
* "javac1.6", "javac1.7", "javac1.8" or "javac1.9". | * "javac1.6", "javac1.7", "javac1.8" or "javac1.9". | ||||
*/ | */ | ||||
protected boolean isJdkCompiler(String compilerImpl) { | |||||
protected boolean isJdkCompiler(final String compilerImpl) { | |||||
return MODERN.equals(compilerImpl) | return MODERN.equals(compilerImpl) | ||||
|| CLASSIC.equals(compilerImpl) | || CLASSIC.equals(compilerImpl) | ||||
|| JAVAC19.equals(compilerImpl) | || JAVAC19.equals(compilerImpl) | ||||
@@ -1047,7 +1048,7 @@ public class Javac extends MatchingTask { | |||||
* @param compiler the name of the compiler | * @param compiler the name of the compiler | ||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
*/ | */ | ||||
public void setCompiler(String compiler) { | |||||
public void setCompiler(final String compiler) { | |||||
facade.setImplementation(compiler); | facade.setImplementation(compiler); | ||||
} | } | ||||
@@ -1133,7 +1134,7 @@ public class Javac extends MatchingTask { | |||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
*/ | */ | ||||
protected void compile() { | protected void compile() { | ||||
String compilerImpl = getCompiler(); | |||||
final String compilerImpl = getCompiler(); | |||||
if (compileList.length > 0) { | if (compileList.length > 0) { | ||||
log("Compiling " + compileList.length + " source file" | log("Compiling " + compileList.length + " source file" | ||||
@@ -1142,12 +1143,12 @@ public class Javac extends MatchingTask { | |||||
if (listFiles) { | if (listFiles) { | ||||
for (int i = 0; i < compileList.length; i++) { | for (int i = 0; i < compileList.length; i++) { | ||||
String filename = compileList[i].getAbsolutePath(); | |||||
final String filename = compileList[i].getAbsolutePath(); | |||||
log(filename); | log(filename); | ||||
} | } | ||||
} | } | ||||
CompilerAdapter adapter = | |||||
final CompilerAdapter adapter = | |||||
nestedAdapter != null ? nestedAdapter : | nestedAdapter != null ? nestedAdapter : | ||||
CompilerAdapterFactory.getCompiler(compilerImpl, this, | CompilerAdapterFactory.getCompiler(compilerImpl, this, | ||||
createCompilerClasspath()); | createCompilerClasspath()); | ||||
@@ -1164,7 +1165,7 @@ public class Javac extends MatchingTask { | |||||
? destDir | ? destDir | ||||
: getProject() | : getProject() | ||||
.resolveFile(src.list()[0])); | .resolveFile(src.list()[0])); | ||||
} catch (IOException x) { | |||||
} catch (final IOException x) { | |||||
// Should this be made a nonfatal warning? | // Should this be made a nonfatal warning? | ||||
throw new BuildException(x, getLocation()); | throw new BuildException(x, getLocation()); | ||||
} | } | ||||
@@ -1196,25 +1197,25 @@ public class Javac extends MatchingTask { | |||||
/** | /** | ||||
* @param impl the name of the compiler | * @param impl the name of the compiler | ||||
*/ | */ | ||||
public void setCompiler(String impl) { | |||||
public void setCompiler(final String impl) { | |||||
super.setImplementation(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++) { | for (int i = 0; i < newFiles.length; i++) { | ||||
File f = newFiles[i]; | |||||
final File f = newFiles[i]; | |||||
if (!f.getName().equals("package-info.java")) { | if (!f.getName().equals("package-info.java")) { | ||||
continue; | continue; | ||||
} | } | ||||
String path = FILE_UTILS.removeLeadingPath(srcDir, f). | |||||
final String path = FILE_UTILS.removeLeadingPath(srcDir, f). | |||||
replace(File.separatorChar, '/'); | replace(File.separatorChar, '/'); | ||||
String suffix = "/package-info.java"; | |||||
final String suffix = "/package-info.java"; | |||||
if (!path.endsWith(suffix)) { | if (!path.endsWith(suffix)) { | ||||
log("anomalous package-info.java path: " + path, Project.MSG_WARN); | log("anomalous package-info.java path: " + path, Project.MSG_WARN); | ||||
continue; | 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())); | 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. | * 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> | * @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(); | 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()) { | if (pkgInfoClass.isFile() && pkgInfoClass.lastModified() >= sourceLastMod.longValue()) { | ||||
continue; | continue; | ||||
} | } | ||||
log("Creating empty " + pkgInfoClass); | log("Creating empty " + pkgInfoClass); | ||||
OutputStream os = new FileOutputStream(pkgInfoClass); | |||||
final OutputStream os = new FileOutputStream(pkgInfoClass); | |||||
try { | try { | ||||
os.write(PACKAGE_INFO_CLASS_HEADER); | 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((byte) length % 256); | os.write((byte) length % 256); | ||||
os.write(name); | os.write(name); | ||||
@@ -278,7 +278,8 @@ public class Javadoc extends Task { | |||||
* Return a string rep for this object. | * Return a string rep for this object. | ||||
* @return the package name. | * @return the package name. | ||||
*/ | */ | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
return getName(); | return getName(); | ||||
} | } | ||||
} | } | ||||
@@ -362,7 +363,8 @@ public class Javadoc extends Task { | |||||
/** | /** | ||||
* @return the allowed values for the access type. | * @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 | // Protected first so if any GUI tool offers a default | ||||
// based on enum #0, it will be right. | // based on enum #0, it will be right. | ||||
return new String[] {"protected", "public", "package", "private"}; | return new String[] {"protected", "public", "package", "private"}; | ||||
@@ -862,7 +864,8 @@ public class Javadoc extends Task { | |||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Use the {@link #setExtdirs(Path)} version. | * Use the {@link #setExtdirs(Path)} version. | ||||
*/ | */ | ||||
public void setExtdirs(String path) { | |||||
@Deprecated | |||||
public void setExtdirs(String path) { | |||||
cmd.createArgument().setValue("-extdirs"); | cmd.createArgument().setValue("-extdirs"); | ||||
cmd.createArgument().setValue(path); | cmd.createArgument().setValue(path); | ||||
} | } | ||||
@@ -1698,7 +1701,8 @@ public class Javadoc extends Task { | |||||
* Execute the task. | * Execute the task. | ||||
* @throws BuildException on error | * @throws BuildException on error | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
checkTaskName(); | checkTaskName(); | ||||
Vector<String> packagesToDoc = new Vector<String>(); | Vector<String> packagesToDoc = new Vector<String>(); | ||||
@@ -2428,7 +2432,8 @@ public class Javadoc extends Task { | |||||
// are there any java files in this directory? | // are there any java files in this directory? | ||||
File pd = new File(baseDir, dirs[i]); | File pd = new File(baseDir, dirs[i]); | ||||
String[] files = pd.list(new FilenameFilter () { | 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") | return name.endsWith(".java") | ||||
|| (includeNoSourcePackages | || (includeNoSourcePackages | ||||
&& name.equals("package.html")); | && name.equals("package.html")); | ||||
@@ -2570,7 +2575,8 @@ public class Javadoc extends Task { | |||||
// | // | ||||
private String queuedLine = null; | private String queuedLine = null; | ||||
private boolean sawWarnings = false; | private boolean sawWarnings = false; | ||||
protected void processLine(String line, int messageLevel) { | |||||
@Override | |||||
protected void processLine(String line, int messageLevel) { | |||||
if (line.contains("warning")) { | if (line.contains("warning")) { | ||||
sawWarnings = true; | sawWarnings = true; | ||||
} | } | ||||
@@ -2600,7 +2606,7 @@ public class Javadoc extends Task { | |||||
queuedLine = null; | queuedLine = null; | ||||
} | } | ||||
} | } | ||||
public boolean sawWarnings() { | public boolean sawWarnings() { | ||||
return 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 | * <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> | * to a property. Use when for setting up RMI codebases.</p> | ||||
* | |||||
* | |||||
* <p>nested filesets are supported; if present, these are turned into the | * <p>nested filesets are supported; if present, these are turned into the | ||||
* url with the given separator between them (default = " ").</p> | * url with the given separator between them (default = " ").</p> | ||||
* | * | ||||
@@ -151,7 +151,7 @@ public class MakeUrl extends Task { | |||||
StringBuilder urls = new StringBuilder(); | StringBuilder urls = new StringBuilder(); | ||||
ListIterator<FileSet> list = filesets.listIterator(); | ListIterator<FileSet> list = filesets.listIterator(); | ||||
while (list.hasNext()) { | while (list.hasNext()) { | ||||
FileSet set = (FileSet) list.next(); | |||||
FileSet set = list.next(); | |||||
DirectoryScanner scanner = set.getDirectoryScanner(getProject()); | DirectoryScanner scanner = set.getDirectoryScanner(getProject()); | ||||
String[] files = scanner.getIncludedFiles(); | String[] files = scanner.getIncludedFiles(); | ||||
for (int i = 0; i < files.length; i++) { | for (int i = 0; i < files.length; i++) { | ||||
@@ -200,7 +200,7 @@ public class MakeUrl extends Task { | |||||
StringBuilder urls = new StringBuilder(); | StringBuilder urls = new StringBuilder(); | ||||
ListIterator<Path> list = paths.listIterator(); | ListIterator<Path> list = paths.listIterator(); | ||||
while (list.hasNext()) { | while (list.hasNext()) { | ||||
Path path = (Path) list.next(); | |||||
Path path = list.next(); | |||||
String[] elements = path.list(); | String[] elements = path.list(); | ||||
for (int i = 0; i < elements.length; i++) { | for (int i = 0; i < elements.length; i++) { | ||||
File f = new File(elements[i]); | File f = new File(elements[i]); | ||||
@@ -234,7 +234,8 @@ public class MakeUrl extends Task { | |||||
* @throws org.apache.tools.ant.BuildException | * @throws org.apache.tools.ant.BuildException | ||||
* if something goes wrong with the build | * if something goes wrong with the build | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
validate(); | validate(); | ||||
//now exit here if the property is already set | //now exit here if the property is already set | ||||
if (getProject().getProperty(property) != null) { | if (getProject().getProperty(property) != null) { | ||||
@@ -166,7 +166,8 @@ public class Manifest { | |||||
* @see java.lang.Object#hashCode | * @see java.lang.Object#hashCode | ||||
* @return a hashcode based on the key and values. | * @return a hashcode based on the key and values. | ||||
*/ | */ | ||||
public int hashCode() { | |||||
@Override | |||||
public int hashCode() { | |||||
int hashCode = 0; | int hashCode = 0; | ||||
if (name != null) { | if (name != null) { | ||||
@@ -182,7 +183,8 @@ public class Manifest { | |||||
* @see java.lang.Object#equals | * @see java.lang.Object#equals | ||||
* @return true if the key and values are the same. | * @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()) { | if (rhs == null || rhs.getClass() != getClass()) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -312,7 +314,7 @@ public class Manifest { | |||||
* @param line the continuation line. | * @param line the continuation line. | ||||
*/ | */ | ||||
public void addContinuation(String line) { | public void addContinuation(String line) { | ||||
String currentValue = (String) values.elementAt(currentIndex); | |||||
String currentValue = values.elementAt(currentIndex); | |||||
setValue(currentValue + line.substring(1)); | setValue(currentValue + line.substring(1)); | ||||
} | } | ||||
@@ -535,7 +537,7 @@ public class Manifest { | |||||
Attribute currentCp = getAttribute(ATTRIBUTE_CLASSPATH); | Attribute currentCp = getAttribute(ATTRIBUTE_CLASSPATH); | ||||
if (currentCp != null) { | if (currentCp != null) { | ||||
for (Enumeration<String> attribEnum = currentCp.getValues(); | for (Enumeration<String> attribEnum = currentCp.getValues(); | ||||
attribEnum.hasMoreElements(); ) { | |||||
attribEnum.hasMoreElements();) { | |||||
String value = attribEnum.nextElement(); | String value = attribEnum.nextElement(); | ||||
classpathAttribute.addValue(value); | classpathAttribute.addValue(value); | ||||
} | } | ||||
@@ -598,7 +600,7 @@ public class Manifest { | |||||
* instances. | * instances. | ||||
*/ | */ | ||||
public Attribute getAttribute(String attributeName) { | 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 | // classpath attributes go into a vector | ||||
if (attributeKey.equals(ATTRIBUTE_CLASSPATH_LC)) { | if (attributeKey.equals(ATTRIBUTE_CLASSPATH_LC)) { | ||||
Attribute classpathAttribute = | Attribute classpathAttribute = | ||||
(Attribute) attributes.get(attributeKey); | |||||
attributes.get(attributeKey); | |||||
if (classpathAttribute == null) { | if (classpathAttribute == null) { | ||||
storeAttribute(attribute); | storeAttribute(attribute); | ||||
@@ -718,7 +720,8 @@ public class Manifest { | |||||
* @return the cloned Section | * @return the cloned Section | ||||
* @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
*/ | */ | ||||
public Object clone() { | |||||
@Override | |||||
public Object clone() { | |||||
Section cloned = new Section(); | Section cloned = new Section(); | ||||
cloned.setName(name); | cloned.setName(name); | ||||
Enumeration<String> e = getAttributeKeys(); | Enumeration<String> e = getAttributeKeys(); | ||||
@@ -757,7 +760,8 @@ public class Manifest { | |||||
* @see java.lang.Object#hashCode | * @see java.lang.Object#hashCode | ||||
* @return a hash value based on the attributes. | * @return a hash value based on the attributes. | ||||
*/ | */ | ||||
public int hashCode() { | |||||
@Override | |||||
public int hashCode() { | |||||
return attributes.hashCode(); | return attributes.hashCode(); | ||||
} | } | ||||
@@ -766,7 +770,8 @@ public class Manifest { | |||||
* @param rhs the object to check for equality. | * @param rhs the object to check for equality. | ||||
* @return true if the attributes are the same. | * @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()) { | if (rhs == null || rhs.getClass() != getClass()) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -1055,7 +1060,8 @@ public class Manifest { | |||||
* @return a multiline string with the Manifest as it | * @return a multiline string with the Manifest as it | ||||
* appears in a Manifest file. | * appears in a Manifest file. | ||||
*/ | */ | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
StringWriter sw = new StringWriter(); | StringWriter sw = new StringWriter(); | ||||
try { | try { | ||||
write(new PrintWriter(sw)); | write(new PrintWriter(sw)); | ||||
@@ -1093,7 +1099,8 @@ public class Manifest { | |||||
* @see java.lang.Object#hashCode | * @see java.lang.Object#hashCode | ||||
* @return a hashcode based on the version, main and sections. | * @return a hashcode based on the version, main and sections. | ||||
*/ | */ | ||||
public int hashCode() { | |||||
@Override | |||||
public int hashCode() { | |||||
int hashCode = 0; | int hashCode = 0; | ||||
if (manifestVersion != null) { | if (manifestVersion != null) { | ||||
@@ -1110,7 +1117,8 @@ public class Manifest { | |||||
* @param rhs the object to check for equality. | * @param rhs the object to check for equality. | ||||
* @return true if the version, main and sections are the same. | * @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()) { | if (rhs == null || rhs.getClass() != getClass()) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -1161,7 +1169,7 @@ public class Manifest { | |||||
* does not exist in the manifest | * does not exist in the manifest | ||||
*/ | */ | ||||
public Section getSection(String name) { | 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. | * @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"}; | 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. | * Use the method taking a TargetOs argument instead. | ||||
* @see #setTargetos(PathConvert.TargetOs) | * @see #setTargetos(PathConvert.TargetOs) | ||||
*/ | */ | ||||
public void setTargetos(String target) { | |||||
@Deprecated | |||||
public void setTargetos(String target) { | |||||
TargetOs to = new TargetOs(); | TargetOs to = new TargetOs(); | ||||
to.setValue(target); | to.setValue(target); | ||||
setTargetos(to); | setTargetos(to); | ||||
@@ -331,7 +333,8 @@ public class PathConvert extends Task { | |||||
* Do the execution. | * Do the execution. | ||||
* @throws BuildException if something is invalid. | * @throws BuildException if something is invalid. | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
Resources savedPath = path; | Resources savedPath = path; | ||||
String savedPathSep = pathSep; // may be altered in validateSetup | String savedPathSep = pathSep; // may be altered in validateSetup | ||||
String savedDirSep = dirSep; // 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; | 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 | String elem = mapElement((String) mappedIter.next()); // Apply the path prefix map | ||||
// Now convert the path and file separator characters from the | // 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 | * Task to install project helper into Ant's runtime | ||||
* | |||||
* | |||||
* @since Ant 1.8.2 | * @since Ant 1.8.2 | ||||
*/ | */ | ||||
public class ProjectHelperTask extends Task { | public class ProjectHelperTask extends Task { | ||||
@@ -39,7 +39,8 @@ public class ProjectHelperTask extends Task { | |||||
this.projectHelpers.add(projectHelper); | this.projectHelpers.add(projectHelper); | ||||
} | } | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
ProjectHelperRepository repo = ProjectHelperRepository.getInstance(); | ProjectHelperRepository repo = ProjectHelperRepository.getInstance(); | ||||
for (Iterator it = projectHelpers.iterator(); it.hasNext();) { | for (Iterator it = projectHelpers.iterator(); it.hasNext();) { | ||||
ProjectHelper helper = (ProjectHelper) it.next(); | ProjectHelper helper = (ProjectHelper) it.next(); | ||||
@@ -431,7 +431,8 @@ public class Property extends Task { | |||||
* deprecated without replacement. | * deprecated without replacement. | ||||
* @ant.attribute ignore="true" | * @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" | log("DEPRECATED: Ignoring request to set user property in Property" | ||||
+ " task.", Project.MSG_WARN); | + " task.", Project.MSG_WARN); | ||||
} | } | ||||
@@ -440,7 +441,8 @@ public class Property extends Task { | |||||
* get the value of this property | * get the value of this property | ||||
* @return the current value or the empty string | * @return the current value or the empty string | ||||
*/ | */ | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
return value == null ? "" : value; | return value == null ? "" : value; | ||||
} | } | ||||
@@ -450,7 +452,8 @@ public class Property extends Task { | |||||
* here is where it is loaded | * here is where it is loaded | ||||
* @throws BuildException on error | * @throws BuildException on error | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
if (getProject() == null) { | if (getProject() == null) { | ||||
throw new IllegalStateException("project has not been set"); | throw new IllegalStateException("project has not been set"); | ||||
} | } | ||||
@@ -520,7 +523,7 @@ public class Property extends Task { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* load properties from a url | * load properties from a url | ||||
* @param url url to load from | * @param url url to load from | ||||
@@ -651,7 +654,7 @@ public class Property extends Task { | |||||
} | } | ||||
log("Loading Environment " + prefix, Project.MSG_VERBOSE); | log("Loading Environment " + prefix, Project.MSG_VERBOSE); | ||||
Map osEnv = Execute.getEnvironmentVariables(); | 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(); | Map.Entry entry = (Map.Entry) e.next(); | ||||
props.put(prefix + entry.getKey(), entry.getValue()); | props.put(prefix + entry.getKey(), entry.getValue()); | ||||
} | } | ||||
@@ -712,7 +715,7 @@ public class Property extends Task { | |||||
*/ | */ | ||||
private void resolveAllProperties(Map props) throws BuildException { | private void resolveAllProperties(Map props) throws BuildException { | ||||
PropertyHelper propertyHelper | PropertyHelper propertyHelper | ||||
= (PropertyHelper) PropertyHelper.getPropertyHelper(getProject()); | |||||
= PropertyHelper.getPropertyHelper(getProject()); | |||||
new ResolvePropertyMap( | new ResolvePropertyMap( | ||||
getProject(), | getProject(), | ||||
propertyHelper, | propertyHelper, | ||||
@@ -61,16 +61,17 @@ public class Redirector { | |||||
.getProperty("file.encoding"); | .getProperty("file.encoding"); | ||||
private class PropertyOutputStream extends ByteArrayOutputStream { | private class PropertyOutputStream extends ByteArrayOutputStream { | ||||
private String property; | |||||
private final String property; | |||||
private boolean closed = false; | private boolean closed = false; | ||||
PropertyOutputStream(String property) { | |||||
PropertyOutputStream(final String property) { | |||||
super(); | super(); | ||||
this.property = property; | this.property = property; | ||||
} | } | ||||
public void close() throws IOException { | |||||
@Override | |||||
public void close() throws IOException { | |||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
if (!closed && !(appendOut && appendProperties)) { | if (!closed && !(appendOut && appendProperties)) { | ||||
setPropertyFromBAOS(this, property); | setPropertyFromBAOS(this, property); | ||||
@@ -139,7 +140,7 @@ public class Redirector { | |||||
private boolean createEmptyFilesErr = true; | private boolean createEmptyFilesErr = true; | ||||
/** The task for which this redirector is working */ | /** The task for which this redirector is working */ | ||||
private ProjectComponent managingTask; | |||||
private final ProjectComponent managingTask; | |||||
/** The stream for output data */ | /** The stream for output data */ | ||||
private OutputStream outputStream = null; | private OutputStream outputStream = null; | ||||
@@ -184,13 +185,13 @@ public class Redirector { | |||||
private boolean logInputString = true; | private boolean logInputString = true; | ||||
/** Mutex for in */ | /** Mutex for in */ | ||||
private Object inMutex = new Object(); | |||||
private final Object inMutex = new Object(); | |||||
/** Mutex for out */ | /** Mutex for out */ | ||||
private Object outMutex = new Object(); | |||||
private final Object outMutex = new Object(); | |||||
/** Mutex for err */ | /** 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? */ | /** Is the output binary or can we safely split it into lines? */ | ||||
private boolean outputIsBinary = false; | private boolean outputIsBinary = false; | ||||
@@ -201,7 +202,7 @@ public class Redirector { | |||||
* @param managingTask | * @param managingTask | ||||
* the task for which the redirector is to work | * the task for which the redirector is to work | ||||
*/ | */ | ||||
public Redirector(Task managingTask) { | |||||
public Redirector(final Task managingTask) { | |||||
this((ProjectComponent) managingTask); | this((ProjectComponent) managingTask); | ||||
} | } | ||||
@@ -212,7 +213,7 @@ public class Redirector { | |||||
* the project component for which the redirector is to work | * the project component for which the redirector is to work | ||||
* @since Ant 1.6.3 | * @since Ant 1.6.3 | ||||
*/ | */ | ||||
public Redirector(ProjectComponent managingTask) { | |||||
public Redirector(final ProjectComponent managingTask) { | |||||
this.managingTask = managingTask; | this.managingTask = managingTask; | ||||
} | } | ||||
@@ -222,8 +223,8 @@ public class Redirector { | |||||
* @param input | * @param input | ||||
* the file from which input is read. | * 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 | * @param input | ||||
* the files from which input is read. | * the files from which input is read. | ||||
*/ | */ | ||||
public void setInput(File[] input) { | |||||
public void setInput(final File[] input) { | |||||
synchronized (inMutex) { | synchronized (inMutex) { | ||||
if (input == null) { | if (input == null) { | ||||
this.input = null; | this.input = null; | ||||
} else { | } else { | ||||
this.input = (File[]) input.clone(); | |||||
this.input = input.clone(); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -248,7 +249,7 @@ public class Redirector { | |||||
* @param inputString | * @param inputString | ||||
* the string which is used as the input source | * the string which is used as the input source | ||||
*/ | */ | ||||
public void setInputString(String inputString) { | |||||
public void setInputString(final String inputString) { | |||||
synchronized (inMutex) { | synchronized (inMutex) { | ||||
this.inputString = inputString; | this.inputString = inputString; | ||||
} | } | ||||
@@ -262,7 +263,7 @@ public class Redirector { | |||||
* true or false. | * true or false. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
public void setLogInputString(boolean logInputString) { | |||||
public void setLogInputString(final boolean logInputString) { | |||||
this.logInputString = logInputString; | this.logInputString = logInputString; | ||||
} | } | ||||
@@ -273,7 +274,7 @@ public class Redirector { | |||||
* the stream from which input will be read | * the stream from which input will be read | ||||
* @since Ant 1.6.3 | * @since Ant 1.6.3 | ||||
*/ | */ | ||||
/* public */void setInputStream(InputStream inputStream) { | |||||
/* public */void setInputStream(final InputStream inputStream) { | |||||
synchronized (inMutex) { | synchronized (inMutex) { | ||||
this.inputStream = inputStream; | this.inputStream = inputStream; | ||||
} | } | ||||
@@ -286,8 +287,8 @@ public class Redirector { | |||||
* @param out | * @param out | ||||
* the file to which output stream is written | * 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 | * @param out | ||||
* the files to which output stream is written | * the files to which output stream is written | ||||
*/ | */ | ||||
public void setOutput(File[] out) { | |||||
public void setOutput(final File[] out) { | |||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
if (out == null) { | if (out == null) { | ||||
this.out = null; | this.out = null; | ||||
} else { | } else { | ||||
this.out = (File[]) out.clone(); | |||||
this.out = out.clone(); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -313,7 +314,7 @@ public class Redirector { | |||||
* @param outputEncoding | * @param outputEncoding | ||||
* <code>String</code>. | * <code>String</code>. | ||||
*/ | */ | ||||
public void setOutputEncoding(String outputEncoding) { | |||||
public void setOutputEncoding(final String outputEncoding) { | |||||
if (outputEncoding == null) { | if (outputEncoding == null) { | ||||
throw new IllegalArgumentException( | throw new IllegalArgumentException( | ||||
"outputEncoding must not be null"); | "outputEncoding must not be null"); | ||||
@@ -329,7 +330,7 @@ public class Redirector { | |||||
* @param errorEncoding | * @param errorEncoding | ||||
* <code>String</code>. | * <code>String</code>. | ||||
*/ | */ | ||||
public void setErrorEncoding(String errorEncoding) { | |||||
public void setErrorEncoding(final String errorEncoding) { | |||||
if (errorEncoding == null) { | if (errorEncoding == null) { | ||||
throw new IllegalArgumentException("errorEncoding must not be null"); | throw new IllegalArgumentException("errorEncoding must not be null"); | ||||
} | } | ||||
@@ -344,7 +345,7 @@ public class Redirector { | |||||
* @param inputEncoding | * @param inputEncoding | ||||
* <code>String</code>. | * <code>String</code>. | ||||
*/ | */ | ||||
public void setInputEncoding(String inputEncoding) { | |||||
public void setInputEncoding(final String inputEncoding) { | |||||
if (inputEncoding == null) { | if (inputEncoding == null) { | ||||
throw new IllegalArgumentException("inputEncoding must not be 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 | * if true the standard error is sent to the Ant log system and | ||||
* not sent to output. | * not sent to output. | ||||
*/ | */ | ||||
public void setLogError(boolean logError) { | |||||
public void setLogError(final boolean logError) { | |||||
synchronized (errMutex) { | synchronized (errMutex) { | ||||
this.logError = logError; | this.logError = logError; | ||||
} | } | ||||
@@ -375,7 +376,7 @@ public class Redirector { | |||||
* @param appendProperties | * @param appendProperties | ||||
* whether to append properties. | * whether to append properties. | ||||
*/ | */ | ||||
public void setAppendProperties(boolean appendProperties) { | |||||
public void setAppendProperties(final boolean appendProperties) { | |||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
this.appendProperties = appendProperties; | this.appendProperties = appendProperties; | ||||
} | } | ||||
@@ -387,8 +388,8 @@ public class Redirector { | |||||
* @param error | * @param error | ||||
* the file to which error is to be written | * 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 | * @param error | ||||
* the file to which error is to be written | * the file to which error is to be written | ||||
*/ | */ | ||||
public void setError(File[] error) { | |||||
public void setError(final File[] error) { | |||||
synchronized (errMutex) { | synchronized (errMutex) { | ||||
if (error == null) { | if (error == null) { | ||||
this.error = null; | this.error = null; | ||||
} else { | } else { | ||||
this.error = (File[]) error.clone(); | |||||
this.error = error.clone(); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -413,7 +414,7 @@ public class Redirector { | |||||
* @param outputProperty | * @param outputProperty | ||||
* the name of the property to be set with the task's output. | * 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 | if (outputProperty == null | ||||
|| !(outputProperty.equals(this.outputProperty))) { | || !(outputProperty.equals(this.outputProperty))) { | ||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
@@ -431,7 +432,7 @@ public class Redirector { | |||||
* if true output and error streams are appended to their | * if true output and error streams are appended to their | ||||
* respective files, if specified. | * respective files, if specified. | ||||
*/ | */ | ||||
public void setAppend(boolean append) { | |||||
public void setAppend(final boolean append) { | |||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
appendOut = append; | appendOut = append; | ||||
} | } | ||||
@@ -449,7 +450,7 @@ public class Redirector { | |||||
* <code>boolean</code> | * <code>boolean</code> | ||||
* @since Ant 1.6.3 | * @since Ant 1.6.3 | ||||
*/ | */ | ||||
public void setAlwaysLog(boolean alwaysLog) { | |||||
public void setAlwaysLog(final boolean alwaysLog) { | |||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
alwaysLogOut = alwaysLog; | alwaysLogOut = alwaysLog; | ||||
} | } | ||||
@@ -465,7 +466,7 @@ public class Redirector { | |||||
* @param createEmptyFiles | * @param createEmptyFiles | ||||
* <code>boolean</code>. | * <code>boolean</code>. | ||||
*/ | */ | ||||
public void setCreateEmptyFiles(boolean createEmptyFiles) { | |||||
public void setCreateEmptyFiles(final boolean createEmptyFiles) { | |||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
createEmptyFilesOut = createEmptyFiles; | createEmptyFilesOut = createEmptyFiles; | ||||
} | } | ||||
@@ -480,7 +481,7 @@ public class Redirector { | |||||
* @param errorProperty | * @param errorProperty | ||||
* the name of the property to be set with the error output. | * 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) { | synchronized (errMutex) { | ||||
if (errorProperty == null | if (errorProperty == null | ||||
|| !(errorProperty.equals(this.errorProperty))) { | || !(errorProperty.equals(this.errorProperty))) { | ||||
@@ -496,7 +497,7 @@ public class Redirector { | |||||
* @param inputFilterChains | * @param inputFilterChains | ||||
* <code>Vector</code> containing <code>FilterChain</code>. | * <code>Vector</code> containing <code>FilterChain</code>. | ||||
*/ | */ | ||||
public void setInputFilterChains(Vector<FilterChain> inputFilterChains) { | |||||
public void setInputFilterChains(final Vector<FilterChain> inputFilterChains) { | |||||
synchronized (inMutex) { | synchronized (inMutex) { | ||||
this.inputFilterChains = inputFilterChains; | this.inputFilterChains = inputFilterChains; | ||||
} | } | ||||
@@ -508,7 +509,7 @@ public class Redirector { | |||||
* @param outputFilterChains | * @param outputFilterChains | ||||
* <code>Vector</code> containing <code>FilterChain</code>. | * <code>Vector</code> containing <code>FilterChain</code>. | ||||
*/ | */ | ||||
public void setOutputFilterChains(Vector<FilterChain> outputFilterChains) { | |||||
public void setOutputFilterChains(final Vector<FilterChain> outputFilterChains) { | |||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
this.outputFilterChains = outputFilterChains; | this.outputFilterChains = outputFilterChains; | ||||
} | } | ||||
@@ -520,7 +521,7 @@ public class Redirector { | |||||
* @param errorFilterChains | * @param errorFilterChains | ||||
* <code>Vector</code> containing <code>FilterChain</code>. | * <code>Vector</code> containing <code>FilterChain</code>. | ||||
*/ | */ | ||||
public void setErrorFilterChains(Vector<FilterChain> errorFilterChains) { | |||||
public void setErrorFilterChains(final Vector<FilterChain> errorFilterChains) { | |||||
synchronized (errMutex) { | synchronized (errMutex) { | ||||
this.errorFilterChains = errorFilterChains; | this.errorFilterChains = errorFilterChains; | ||||
} | } | ||||
@@ -534,7 +535,7 @@ public class Redirector { | |||||
* the same stream.</p> | * the same stream.</p> | ||||
* @since 1.9.4 | * @since 1.9.4 | ||||
*/ | */ | ||||
public void setBinaryOutput(boolean b) { | |||||
public void setBinaryOutput(final boolean b) { | |||||
outputIsBinary = b; | outputIsBinary = b; | ||||
} | } | ||||
@@ -549,13 +550,13 @@ public class Redirector { | |||||
* @exception IOException | * @exception IOException | ||||
* if the value cannot be read form the stream. | * 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))); | .toString(baos))); | ||||
String line = null; | String line = null; | ||||
StringBuffer val = new StringBuffer(); | |||||
final StringBuffer val = new StringBuffer(); | |||||
while ((line = in.readLine()) != null) { | while ((line = in.readLine()) != null) { | ||||
if (val.length() != 0) { | if (val.length() != 0) { | ||||
val.append(StringUtils.LINE_SEP); | val.append(StringUtils.LINE_SEP); | ||||
@@ -574,7 +575,7 @@ public class Redirector { | |||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
outStreams(); | outStreams(); | ||||
if (alwaysLogOut || outputStream == null) { | if (alwaysLogOut || outputStream == null) { | ||||
OutputStream outputLog = new LogOutputStream(managingTask, | |||||
final OutputStream outputLog = new LogOutputStream(managingTask, | |||||
Project.MSG_INFO); | Project.MSG_INFO); | ||||
outputStream = (outputStream == null) ? outputLog | outputStream = (outputStream == null) ? outputLog | ||||
: new TeeOutputStream(outputLog, outputStream); | : new TeeOutputStream(outputLog, outputStream); | ||||
@@ -583,7 +584,7 @@ public class Redirector { | |||||
if ((outputFilterChains != null && outputFilterChains.size() > 0) | if ((outputFilterChains != null && outputFilterChains.size() > 0) | ||||
|| !(outputEncoding.equalsIgnoreCase(inputEncoding))) { | || !(outputEncoding.equalsIgnoreCase(inputEncoding))) { | ||||
try { | try { | ||||
LeadPipeInputStream snk = new LeadPipeInputStream(); | |||||
final LeadPipeInputStream snk = new LeadPipeInputStream(); | |||||
snk.setManagingComponent(managingTask); | snk.setManagingComponent(managingTask); | ||||
InputStream outPumpIn = snk; | InputStream outPumpIn = snk; | ||||
@@ -593,7 +594,7 @@ public class Redirector { | |||||
if (outputFilterChains != null | if (outputFilterChains != null | ||||
&& outputFilterChains.size() > 0) { | && outputFilterChains.size() > 0) { | ||||
ChainReaderHelper helper = new ChainReaderHelper(); | |||||
final ChainReaderHelper helper = new ChainReaderHelper(); | |||||
helper.setProject(managingTask.getProject()); | helper.setProject(managingTask.getProject()); | ||||
helper.setPrimaryReader(reader); | helper.setPrimaryReader(reader); | ||||
helper.setFilterChains(outputFilterChains); | helper.setFilterChains(outputFilterChains); | ||||
@@ -601,12 +602,12 @@ public class Redirector { | |||||
} | } | ||||
outPumpIn = new ReaderInputStream(reader, outputEncoding); | 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"); | outPumpIn, outputStream, true), "output pumper"); | ||||
t.setPriority(Thread.MAX_PRIORITY); | t.setPriority(Thread.MAX_PRIORITY); | ||||
outputStream = new PipedOutputStream(snk); | outputStream = new PipedOutputStream(snk); | ||||
t.start(); | t.start(); | ||||
} catch (IOException eyeOhEx) { | |||||
} catch (final IOException eyeOhEx) { | |||||
throw new BuildException("error setting up output stream", | throw new BuildException("error setting up output stream", | ||||
eyeOhEx); | eyeOhEx); | ||||
} | } | ||||
@@ -616,7 +617,7 @@ public class Redirector { | |||||
synchronized (errMutex) { | synchronized (errMutex) { | ||||
errorStreams(); | errorStreams(); | ||||
if (alwaysLogErr || errorStream == null) { | if (alwaysLogErr || errorStream == null) { | ||||
OutputStream errorLog = new LogOutputStream(managingTask, | |||||
final OutputStream errorLog = new LogOutputStream(managingTask, | |||||
Project.MSG_WARN); | Project.MSG_WARN); | ||||
errorStream = (errorStream == null) ? errorLog | errorStream = (errorStream == null) ? errorLog | ||||
: new TeeOutputStream(errorLog, errorStream); | : new TeeOutputStream(errorLog, errorStream); | ||||
@@ -625,7 +626,7 @@ public class Redirector { | |||||
if ((errorFilterChains != null && errorFilterChains.size() > 0) | if ((errorFilterChains != null && errorFilterChains.size() > 0) | ||||
|| !(errorEncoding.equalsIgnoreCase(inputEncoding))) { | || !(errorEncoding.equalsIgnoreCase(inputEncoding))) { | ||||
try { | try { | ||||
LeadPipeInputStream snk = new LeadPipeInputStream(); | |||||
final LeadPipeInputStream snk = new LeadPipeInputStream(); | |||||
snk.setManagingComponent(managingTask); | snk.setManagingComponent(managingTask); | ||||
InputStream errPumpIn = snk; | InputStream errPumpIn = snk; | ||||
@@ -635,7 +636,7 @@ public class Redirector { | |||||
if (errorFilterChains != null | if (errorFilterChains != null | ||||
&& errorFilterChains.size() > 0) { | && errorFilterChains.size() > 0) { | ||||
ChainReaderHelper helper = new ChainReaderHelper(); | |||||
final ChainReaderHelper helper = new ChainReaderHelper(); | |||||
helper.setProject(managingTask.getProject()); | helper.setProject(managingTask.getProject()); | ||||
helper.setPrimaryReader(reader); | helper.setPrimaryReader(reader); | ||||
helper.setFilterChains(errorFilterChains); | helper.setFilterChains(errorFilterChains); | ||||
@@ -643,12 +644,12 @@ public class Redirector { | |||||
} | } | ||||
errPumpIn = new ReaderInputStream(reader, errorEncoding); | 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"); | errPumpIn, errorStream, true), "error pumper"); | ||||
t.setPriority(Thread.MAX_PRIORITY); | t.setPriority(Thread.MAX_PRIORITY); | ||||
errorStream = new PipedOutputStream(snk); | errorStream = new PipedOutputStream(snk); | ||||
t.start(); | t.start(); | ||||
} catch (IOException eyeOhEx) { | |||||
} catch (final IOException eyeOhEx) { | |||||
throw new BuildException("error setting up error stream", | throw new BuildException("error setting up error stream", | ||||
eyeOhEx); | eyeOhEx); | ||||
} | } | ||||
@@ -667,13 +668,13 @@ public class Redirector { | |||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
try { | try { | ||||
inputStream = new ConcatFileInputStream(input); | inputStream = new ConcatFileInputStream(input); | ||||
} catch (IOException eyeOhEx) { | |||||
} catch (final IOException eyeOhEx) { | |||||
throw new BuildException(eyeOhEx); | throw new BuildException(eyeOhEx); | ||||
} | } | ||||
((ConcatFileInputStream) inputStream) | ((ConcatFileInputStream) inputStream) | ||||
.setManagingComponent(managingTask); | .setManagingComponent(managingTask); | ||||
} else if (inputString != null) { | } else if (inputString != null) { | ||||
StringBuffer buf = new StringBuffer("Using input "); | |||||
final StringBuffer buf = new StringBuffer("Using input "); | |||||
if (logInputString) { | if (logInputString) { | ||||
buf.append('"').append(inputString).append('"'); | buf.append('"').append(inputString).append('"'); | ||||
} else { | } else { | ||||
@@ -685,12 +686,12 @@ public class Redirector { | |||||
if (inputStream != null && inputFilterChains != null | if (inputStream != null && inputFilterChains != null | ||||
&& inputFilterChains.size() > 0) { | && inputFilterChains.size() > 0) { | ||||
ChainReaderHelper helper = new ChainReaderHelper(); | |||||
final ChainReaderHelper helper = new ChainReaderHelper(); | |||||
helper.setProject(managingTask.getProject()); | helper.setProject(managingTask.getProject()); | ||||
try { | try { | ||||
helper.setPrimaryReader(new InputStreamReader(inputStream, | helper.setPrimaryReader(new InputStreamReader(inputStream, | ||||
inputEncoding)); | inputEncoding)); | ||||
} catch (IOException eyeOhEx) { | |||||
} catch (final IOException eyeOhEx) { | |||||
throw new BuildException("error setting up input stream", | throw new BuildException("error setting up input stream", | ||||
eyeOhEx); | eyeOhEx); | ||||
} | } | ||||
@@ -704,7 +705,7 @@ public class Redirector { | |||||
/** outStreams */ | /** outStreams */ | ||||
private void outStreams() { | private void outStreams() { | ||||
if (out != null && out.length > 0) { | if (out != null && out.length > 0) { | ||||
String logHead = new StringBuffer("Output ").append( | |||||
final String logHead = new StringBuffer("Output ").append( | |||||
((appendOut) ? "appended" : "redirected")).append(" to ") | ((appendOut) ? "appended" : "redirected")).append(" to ") | ||||
.toString(); | .toString(); | ||||
outputStream = foldFiles(out, logHead, Project.MSG_VERBOSE, | outputStream = foldFiles(out, logHead, Project.MSG_VERBOSE, | ||||
@@ -717,7 +718,7 @@ public class Redirector { | |||||
+ outputProperty, Project.MSG_VERBOSE); | + outputProperty, Project.MSG_VERBOSE); | ||||
} | } | ||||
// shield it from being closed by a filtering StreamPumper | // shield it from being closed by a filtering StreamPumper | ||||
OutputStream keepAliveOutput = new KeepAliveOutputStream(baos); | |||||
final OutputStream keepAliveOutput = new KeepAliveOutputStream(baos); | |||||
outputStream = (outputStream == null) ? keepAliveOutput | outputStream = (outputStream == null) ? keepAliveOutput | ||||
: new TeeOutputStream(outputStream, keepAliveOutput); | : new TeeOutputStream(outputStream, keepAliveOutput); | ||||
} else { | } else { | ||||
@@ -727,14 +728,14 @@ public class Redirector { | |||||
private void errorStreams() { | private void errorStreams() { | ||||
if (error != null && error.length > 0) { | if (error != null && error.length > 0) { | ||||
String logHead = new StringBuffer("Error ").append( | |||||
final String logHead = new StringBuffer("Error ").append( | |||||
((appendErr) ? "appended" : "redirected")).append(" to ") | ((appendErr) ? "appended" : "redirected")).append(" to ") | ||||
.toString(); | .toString(); | ||||
errorStream = foldFiles(error, logHead, Project.MSG_VERBOSE, | errorStream = foldFiles(error, logHead, Project.MSG_VERBOSE, | ||||
appendErr, createEmptyFilesErr); | appendErr, createEmptyFilesErr); | ||||
} else if (!(logError || outputStream == null) && errorProperty == null) { | } 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); | outputStream, funnelTimeout); | ||||
try { | try { | ||||
outputStream = funneler.getFunnelInstance(); | outputStream = funneler.getFunnelInstance(); | ||||
@@ -743,7 +744,7 @@ public class Redirector { | |||||
outputStream = new LineOrientedOutputStreamRedirector(outputStream); | outputStream = new LineOrientedOutputStreamRedirector(outputStream); | ||||
errorStream = new LineOrientedOutputStreamRedirector(errorStream); | errorStream = new LineOrientedOutputStreamRedirector(errorStream); | ||||
} | } | ||||
} catch (IOException eyeOhEx) { | |||||
} catch (final IOException eyeOhEx) { | |||||
throw new BuildException( | throw new BuildException( | ||||
"error splitting output/error streams", eyeOhEx); | "error splitting output/error streams", eyeOhEx); | ||||
} | } | ||||
@@ -755,7 +756,7 @@ public class Redirector { | |||||
+ errorProperty, Project.MSG_VERBOSE); | + errorProperty, Project.MSG_VERBOSE); | ||||
} | } | ||||
// shield it from being closed by a filtering StreamPumper | // 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 | errorStream = (error == null || error.length == 0) ? keepAliveError | ||||
: new TeeOutputStream(errorStream, keepAliveError); | : new TeeOutputStream(errorStream, keepAliveError); | ||||
} else { | } else { | ||||
@@ -774,7 +775,7 @@ public class Redirector { | |||||
*/ | */ | ||||
public ExecuteStreamHandler createHandler() throws BuildException { | public ExecuteStreamHandler createHandler() throws BuildException { | ||||
createStreams(); | createStreams(); | ||||
boolean nonBlockingRead = input == null && inputString == null; | |||||
final boolean nonBlockingRead = input == null && inputString == null; | |||||
return new PumpStreamHandler(getOutputStream(), getErrorStream(), | return new PumpStreamHandler(getOutputStream(), getErrorStream(), | ||||
getInputStream(), nonBlockingRead); | getInputStream(), nonBlockingRead); | ||||
} | } | ||||
@@ -785,7 +786,7 @@ public class Redirector { | |||||
* @param output | * @param output | ||||
* the data to be output | * the data to be output | ||||
*/ | */ | ||||
protected void handleOutput(String output) { | |||||
protected void handleOutput(final String output) { | |||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
if (outPrintStream == null) { | if (outPrintStream == null) { | ||||
outPrintStream = new PrintStream(outputStream); | outPrintStream = new PrintStream(outputStream); | ||||
@@ -809,7 +810,7 @@ public class Redirector { | |||||
* @exception IOException | * @exception IOException | ||||
* if the data cannot be read | * 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 { | throws IOException { | ||||
synchronized (inMutex) { | synchronized (inMutex) { | ||||
if (inputStream == null) { | if (inputStream == null) { | ||||
@@ -827,7 +828,7 @@ public class Redirector { | |||||
* @param output | * @param output | ||||
* the data being flushed. | * the data being flushed. | ||||
*/ | */ | ||||
protected void handleFlush(String output) { | |||||
protected void handleFlush(final String output) { | |||||
synchronized (outMutex) { | synchronized (outMutex) { | ||||
if (outPrintStream == null) { | if (outPrintStream == null) { | ||||
outPrintStream = new PrintStream(outputStream); | outPrintStream = new PrintStream(outputStream); | ||||
@@ -843,7 +844,7 @@ public class Redirector { | |||||
* @param output | * @param output | ||||
* the error output data. | * the error output data. | ||||
*/ | */ | ||||
protected void handleErrorOutput(String output) { | |||||
protected void handleErrorOutput(final String output) { | |||||
synchronized (errMutex) { | synchronized (errMutex) { | ||||
if (errorPrintStream == null) { | if (errorPrintStream == null) { | ||||
errorPrintStream = new PrintStream(errorStream); | errorPrintStream = new PrintStream(errorStream); | ||||
@@ -858,7 +859,7 @@ public class Redirector { | |||||
* @param output | * @param output | ||||
* the error information being flushed. | * the error information being flushed. | ||||
*/ | */ | ||||
protected void handleErrorFlush(String output) { | |||||
protected void handleErrorFlush(final String output) { | |||||
synchronized (errMutex) { | synchronized (errMutex) { | ||||
if (errorPrintStream == null) { | if (errorPrintStream == null) { | ||||
errorPrintStream = new PrintStream(errorStream); | errorPrintStream = new PrintStream(errorStream); | ||||
@@ -940,19 +941,19 @@ public class Redirector { | |||||
try { | try { | ||||
managingTask.log("waiting for " + threadGroup.activeCount() | managingTask.log("waiting for " + threadGroup.activeCount() | ||||
+ " Threads:", Project.MSG_DEBUG); | + " Threads:", Project.MSG_DEBUG); | ||||
Thread[] thread = new Thread[threadGroup.activeCount()]; | |||||
final Thread[] thread = new Thread[threadGroup.activeCount()]; | |||||
threadGroup.enumerate(thread); | threadGroup.enumerate(thread); | ||||
for (int i = 0; i < thread.length && thread[i] != null; i++) { | for (int i = 0; i < thread.length && thread[i] != null; i++) { | ||||
try { | try { | ||||
managingTask.log(thread[i].toString(), | managingTask.log(thread[i].toString(), | ||||
Project.MSG_DEBUG); | Project.MSG_DEBUG); | ||||
} catch (NullPointerException enPeaEx) { | |||||
} catch (final NullPointerException enPeaEx) { | |||||
// Ignore exception | // Ignore exception | ||||
} | } | ||||
} | } | ||||
wait(STREAMPUMPER_WAIT_INTERVAL); | 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); | threadGroup.enumerate(thread); | ||||
for (int i = 0; i < thread.length && thread[i] != null; i++) { | for (int i = 0; i < thread.length && thread[i] != null; i++) { | ||||
thread[i].interrupt(); | thread[i].interrupt(); | ||||
@@ -985,7 +986,7 @@ public class Redirector { | |||||
if (baos != null) { | if (baos != null) { | ||||
try { | try { | ||||
baos.close(); | baos.close(); | ||||
} catch (IOException eyeOhEx) { | |||||
} catch (final IOException eyeOhEx) { | |||||
// Ignore exception | // Ignore exception | ||||
} | } | ||||
} | } | ||||
@@ -994,22 +995,22 @@ public class Redirector { | |||||
if (errorBaos != null) { | if (errorBaos != null) { | ||||
try { | try { | ||||
errorBaos.close(); | errorBaos.close(); | ||||
} catch (IOException eyeOhEx) { | |||||
} catch (final IOException eyeOhEx) { | |||||
// Ignore exception | // 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); | createEmptyFiles); | ||||
managingTask.log(logHead + file[0], loglevel); | managingTask.log(logHead + file[0], loglevel); | ||||
char[] c = new char[logHead.length()]; | |||||
final char[] c = new char[logHead.length()]; | |||||
Arrays.fill(c, ' '); | Arrays.fill(c, ' '); | ||||
String indent = new String(c); | |||||
final String indent = new String(c); | |||||
for (int i = 1; i < file.length; i++) { | for (int i = 1; i < file.length; i++) { | ||||
outputStream = new TeeOutputStream(outputStream, | 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>Runs the rmic compiler against classes.</p> | ||||
* | |||||
* | |||||
* <p>Rmic can be run on a single class (as specified with the classname | * <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 | * 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 | * 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 | * 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 | * specify the classname in the form <code>Outer$$Inner</code> instead of | ||||
* <code>Outer.Inner</code>.</p> | * <code>Outer.Inner</code>.</p> | ||||
* | |||||
* | |||||
* <p>It is possible to refine the set of files that are being rmiced. This can | * <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>, | * be done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, | ||||
* <i>excludesfile</i> and <i>defaultexcludes</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 | * you want to use default exclusions or not. See the section on | ||||
* directory based tasks, on how the | * directory based tasks, on how the | ||||
* inclusion/exclusion of files works, and how to write patterns.</p> | * inclusion/exclusion of files works, and how to write patterns.</p> | ||||
* | |||||
* | |||||
* <p>This task forms an implicit FileSet and | * <p>This task forms an implicit FileSet and | ||||
* supports all attributes of <code><fileset></code> | * supports all attributes of <code><fileset></code> | ||||
* (<code>dir</code> becomes <code>base</code>) as well as the nested | * (<code>dir</code> becomes <code>base</code>) as well as the nested | ||||
* <code><include></code>, <code><exclude></code> and | * <code><include></code>, <code><exclude></code> and | ||||
* <code><patternset></code> elements.</p> | * <code><patternset></code> elements.</p> | ||||
* | |||||
* | |||||
* <p>It is possible to use different compilers. This can be selected | * <p>It is possible to use different compilers. This can be selected | ||||
* with the "build.rmic" property or the <code>compiler</code> | * with the "build.rmic" property or the <code>compiler</code> | ||||
* attribute. <a name="compilervalues">There are three choices</a>:</p> | * attribute. <a name="compilervalues">There are three choices</a>:</p> | ||||
* | |||||
* | |||||
* <ul> | * <ul> | ||||
* <li>sun (the standard compiler of the JDK)</li> | * <li>sun (the standard compiler of the JDK)</li> | ||||
* <li>kaffe (the standard compiler of | * <li>kaffe (the standard compiler of | ||||
@@ -587,7 +587,8 @@ public class Rmic extends MatchingTask { | |||||
* @throws org.apache.tools.ant.BuildException | * @throws org.apache.tools.ant.BuildException | ||||
* if there's a problem with baseDir or RMIC | * if there's a problem with baseDir or RMIC | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
try { | try { | ||||
compileList.clear(); | compileList.clear(); | ||||
@@ -90,7 +90,8 @@ public class SQLExec extends JDBCTask { | |||||
/** The enumerated strings */ | /** The enumerated strings */ | ||||
public static final String NORMAL = "normal", ROW = "row"; | public static final String NORMAL = "normal", ROW = "row"; | ||||
/** @return the enumerated strings */ | /** @return the enumerated strings */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {NORMAL, ROW}; | return new String[] {NORMAL, ROW}; | ||||
} | } | ||||
} | } | ||||
@@ -589,7 +590,8 @@ public class SQLExec extends JDBCTask { | |||||
* Load the sql file and then execute it | * Load the sql file and then execute it | ||||
* @throws BuildException on error. | * @throws BuildException on error. | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
Vector savedTransaction = (Vector) transactions.clone(); | Vector savedTransaction = (Vector) transactions.clone(); | ||||
String savedSqlCommand = sqlCommand; | String savedSqlCommand = sqlCommand; | ||||
@@ -850,7 +852,8 @@ public class SQLExec extends JDBCTask { | |||||
* @param out the place to print results | * @param out the place to print results | ||||
* @throws SQLException on SQL problems. | * @throws SQLException on SQL problems. | ||||
*/ | */ | ||||
protected void printResults(PrintStream out) throws SQLException { | |||||
@Deprecated | |||||
protected void printResults(PrintStream out) throws SQLException { | |||||
ResultSet rs = getStatement().getResultSet(); | ResultSet rs = getStatement().getResultSet(); | ||||
try { | try { | ||||
printResults(rs, out); | printResults(rs, out); | ||||
@@ -954,7 +957,8 @@ public class SQLExec extends JDBCTask { | |||||
* <p>returns null if the connection does not connect to the | * <p>returns null if the connection does not connect to the | ||||
* expected RDBMS.</p> | * expected RDBMS.</p> | ||||
*/ | */ | ||||
protected Connection getConnection() { | |||||
@Override | |||||
protected Connection getConnection() { | |||||
if (conn == null) { | if (conn == null) { | ||||
conn = super.getConnection(); | conn = super.getConnection(); | ||||
if (!isValidRdbms(conn)) { | if (!isValidRdbms(conn)) { | ||||
@@ -981,14 +985,15 @@ public class SQLExec extends JDBCTask { | |||||
return statement; | return statement; | ||||
} | } | ||||
/** | /** | ||||
* The action a task should perform on an error, | * The action a task should perform on an error, | ||||
* one of "continue", "stop" and "abort" | * one of "continue", "stop" and "abort" | ||||
*/ | */ | ||||
public static class OnError extends EnumeratedAttribute { | public static class OnError extends EnumeratedAttribute { | ||||
/** @return the enumerated values */ | /** @return the enumerated values */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {"continue", "stop", "abort"}; | return new String[] {"continue", "stop", "abort"}; | ||||
} | } | ||||
} | } | ||||
@@ -321,7 +321,8 @@ public class SignJar extends AbstractJarSignerTask { | |||||
* | * | ||||
* @throws BuildException on errors | * @throws BuildException on errors | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
//validation logic | //validation logic | ||||
final boolean hasJar = jar != null; | final boolean hasJar = jar != null; | ||||
final boolean hasSignedJar = signedjar != 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 | * is complex, and best explained in the source itself. Essentially if | ||||
* either file doesnt exist, or the destfile has an out of date timestamp, | * either file doesnt exist, or the destfile has an out of date timestamp, | ||||
* then the return value is false.</p> | * then the return value is false.</p> | ||||
* | |||||
* | |||||
* <p>If we are signing ourself, the check {@link #isSigned(File)} is used to | * <p>If we are signing ourself, the check {@link #isSigned(File)} is used to | ||||
* trigger the process.</p> | * 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 | * <p>A task for sleeping a short period of time, useful when a | ||||
* build or deployment process requires an interval between tasks.</p> | * 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 | * <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 | * is positive, pending fundamental changes in physics and JVM | ||||
* execution times</p> | * execution times</p> | ||||
* | |||||
* | |||||
* <p>Note that sleep times are always hints to be interpreted by the OS how it feels | * <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 | * 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 | * 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 | * @exception BuildException Description of Exception | ||||
*/ | */ | ||||
public void execute() | |||||
@Override | |||||
public void execute() | |||||
throws BuildException { | throws BuildException { | ||||
try { | try { | ||||
validate(); | validate(); | ||||
@@ -84,7 +84,7 @@ public class SubAnt extends Task { | |||||
* <p> | * <p> | ||||
* This function may be overrided by providers of custom ProjectHelper so they can implement easily their sub | * This function may be overrided by providers of custom ProjectHelper so they can implement easily their sub | ||||
* launcher. | * launcher. | ||||
* | |||||
* | |||||
* @return the name of the default file | * @return the name of the default file | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
@@ -98,7 +98,8 @@ public class SubAnt extends Task { | |||||
* @param output a line of output | * @param output a line of output | ||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
public void handleOutput(String output) { | |||||
@Override | |||||
public void handleOutput(String output) { | |||||
if (ant != null) { | if (ant != null) { | ||||
ant.handleOutput(output); | ant.handleOutput(output); | ||||
} else { | } else { | ||||
@@ -121,7 +122,8 @@ public class SubAnt extends Task { | |||||
* | * | ||||
* @since Ant 1.6.2 | * @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 { | throws IOException { | ||||
if (ant != null) { | if (ant != null) { | ||||
return ant.handleInput(buffer, offset, length); | return ant.handleInput(buffer, offset, length); | ||||
@@ -137,7 +139,8 @@ public class SubAnt extends Task { | |||||
* | * | ||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
public void handleFlush(String output) { | |||||
@Override | |||||
public void handleFlush(String output) { | |||||
if (ant != null) { | if (ant != null) { | ||||
ant.handleFlush(output); | ant.handleFlush(output); | ||||
} else { | } else { | ||||
@@ -152,7 +155,8 @@ public class SubAnt extends Task { | |||||
* | * | ||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
public void handleErrorOutput(String output) { | |||||
@Override | |||||
public void handleErrorOutput(String output) { | |||||
if (ant != null) { | if (ant != null) { | ||||
ant.handleErrorOutput(output); | ant.handleErrorOutput(output); | ||||
} else { | } else { | ||||
@@ -167,7 +171,8 @@ public class SubAnt extends Task { | |||||
* | * | ||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
public void handleErrorFlush(String output) { | |||||
@Override | |||||
public void handleErrorFlush(String output) { | |||||
if (ant != null) { | if (ant != null) { | ||||
ant.handleErrorFlush(output); | ant.handleErrorFlush(output); | ||||
} else { | } else { | ||||
@@ -178,7 +183,8 @@ public class SubAnt extends Task { | |||||
/** | /** | ||||
* Runs the various sub-builds. | * Runs the various sub-builds. | ||||
*/ | */ | ||||
public void execute() { | |||||
@Override | |||||
public void execute() { | |||||
if (buildpath == null) { | if (buildpath == null) { | ||||
throw new BuildException("No buildpath specified"); | throw new BuildException("No buildpath specified"); | ||||
} | } | ||||
@@ -72,7 +72,8 @@ public class Sync extends Task { | |||||
* @throws BuildException if there is a problem. | * @throws BuildException if there is a problem. | ||||
* @see Task#init() | * @see Task#init() | ||||
*/ | */ | ||||
public void init() | |||||
@Override | |||||
public void init() | |||||
throws BuildException { | throws BuildException { | ||||
// Instantiate it | // Instantiate it | ||||
myCopy = new MyCopy(); | myCopy = new MyCopy(); | ||||
@@ -97,7 +98,8 @@ public class Sync extends Task { | |||||
* @throws BuildException if there is an error. | * @throws BuildException if there is an error. | ||||
* @see Task#execute() | * @see Task#execute() | ||||
*/ | */ | ||||
public void execute() | |||||
@Override | |||||
public void execute() | |||||
throws BuildException { | throws BuildException { | ||||
// The destination of the files to copy | // The destination of the files to copy | ||||
File toDir = myCopy.getToDir(); | File toDir = myCopy.getToDir(); | ||||
@@ -324,7 +326,7 @@ public class Sync extends Task { | |||||
private int removeEmptyDirectories(Set preservedEmptyDirectories) { | private int removeEmptyDirectories(Set preservedEmptyDirectories) { | ||||
int removedCount = 0; | int removedCount = 0; | ||||
for (Iterator iter = preservedEmptyDirectories.iterator(); | for (Iterator iter = preservedEmptyDirectories.iterator(); | ||||
iter.hasNext(); ) { | |||||
iter.hasNext();) { | |||||
File f = (File) iter.next(); | File f = (File) iter.next(); | ||||
String[] s = f.list(); | String[] s = f.list(); | ||||
if (s == null || s.length == 0) { | if (s == null || s.length == 0) { | ||||
@@ -399,7 +401,7 @@ public class Sync extends Task { | |||||
myCopy.add(rc); | myCopy.add(rc); | ||||
} else { | } else { | ||||
if (resources == null) { | if (resources == null) { | ||||
Restrict r = new Restrict(); | |||||
Restrict r = new Restrict(); | |||||
r.add(new Exists()); | r.add(new Exists()); | ||||
r.add(resources = new Resources()); | r.add(resources = new Resources()); | ||||
myCopy.add(r); | myCopy.add(r); | ||||
@@ -464,7 +466,8 @@ public class Sync extends Task { | |||||
* @see Copy#scan(File, File, String[], String[]) | * @see Copy#scan(File, File, String[], String[]) | ||||
*/ | */ | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
protected void scan(File fromDir, File toDir, String[] files, | |||||
@Override | |||||
protected void scan(File fromDir, File toDir, String[] files, | |||||
String[] dirs) { | String[] dirs) { | ||||
assertTrue("No mapper", mapperElement == null); | assertTrue("No mapper", mapperElement == null); | ||||
@@ -482,7 +485,8 @@ public class Sync extends Task { | |||||
* @see Copy#scan(Resource[], File) | * @see Copy#scan(Resource[], File) | ||||
*/ | */ | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
protected Map scan(Resource[] resources, File toDir) { | |||||
@Override | |||||
protected Map scan(Resource[] resources, File toDir) { | |||||
assertTrue("No mapper", mapperElement == null); | assertTrue("No mapper", mapperElement == null); | ||||
for (int i = 0; i < resources.length; i++) { | for (int i = 0; i < resources.length; i++) { | ||||
@@ -512,7 +516,8 @@ public class Sync extends Task { | |||||
* @return true always. | * @return true always. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
protected boolean supportsNonFileResources() { | |||||
@Override | |||||
protected boolean supportsNonFileResources() { | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
@@ -543,7 +548,8 @@ public class Sync extends Task { | |||||
* @param dir ignored | * @param dir ignored | ||||
* @throws BuildException always | * @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 " | throw new BuildException("preserveintarget doesn't support the dir " | ||||
+ "attribute"); | + "attribute"); | ||||
} | } | ||||
@@ -579,7 +585,7 @@ public class Sync extends Task { | |||||
PatternSet ps = mergePatterns(getProject()); | PatternSet ps = mergePatterns(getProject()); | ||||
fs.appendIncludes(ps.getIncludePatterns(getProject())); | fs.appendIncludes(ps.getIncludePatterns(getProject())); | ||||
fs.appendExcludes(ps.getExcludePatterns(getProject())); | fs.appendExcludes(ps.getExcludePatterns(getProject())); | ||||
for (Enumeration e = selectorElements(); e.hasMoreElements(); ) { | |||||
for (Enumeration e = selectorElements(); e.hasMoreElements();) { | |||||
fs.appendSelector((FileSelector) e.nextElement()); | fs.appendSelector((FileSelector) e.nextElement()); | ||||
} | } | ||||
fs.setDefaultexcludes(getDefaultexcludes()); | fs.setDefaultexcludes(getDefaultexcludes()); | ||||
@@ -33,11 +33,11 @@ import org.apache.tools.zip.ZipOutputStream; | |||||
* Contains special treatment for files that should end up in the | * 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/lib</code>, <code>WEB-INF/classes</code> or | ||||
* <code>WEB-INF</code> directories of the Web Application Archive.</p> | * <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. | * <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> | * 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> | * attributes of zipfilesets in a Zip or Jar task.)</p> | ||||
* | |||||
* | |||||
* <p>The extended zipfileset element from the zip task | * <p>The extended zipfileset element from the zip task | ||||
* (with attributes <i>prefix</i>, <i>fullpath</i>, and <i>src</i>) | * (with attributes <i>prefix</i>, <i>fullpath</i>, and <i>src</i>) | ||||
* is available in the War task.</p> | * is available in the War task.</p> | ||||
@@ -151,7 +151,8 @@ public class War extends Jar { | |||||
* @throws IOException on output error | * @throws IOException on output error | ||||
* @throws BuildException if invalid configuration | * @throws BuildException if invalid configuration | ||||
*/ | */ | ||||
protected void initZipOutputStream(ZipOutputStream zOut) | |||||
@Override | |||||
protected void initZipOutputStream(ZipOutputStream zOut) | |||||
throws IOException, BuildException { | throws IOException, BuildException { | ||||
super.initZipOutputStream(zOut); | super.initZipOutputStream(zOut); | ||||
} | } | ||||
@@ -171,7 +172,8 @@ public class War extends Jar { | |||||
* @param mode the Unix permissions to set. | * @param mode the Unix permissions to set. | ||||
* @throws IOException on output error | * @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) | int mode) | ||||
throws IOException { | throws IOException { | ||||
// If the file being added is WEB-INF/web.xml, we warn if it's | // 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 | * Make sure we don't think we already have a web.xml next time this task | ||||
* gets executed. | * gets executed. | ||||
*/ | */ | ||||
protected void cleanUp() { | |||||
@Override | |||||
protected void cleanUp() { | |||||
if (addedWebXmlFile == null | if (addedWebXmlFile == null | ||||
&& deploymentDescriptor == null | && deploymentDescriptor == null | ||||
&& needxmlfile | && needxmlfile | ||||
@@ -51,7 +51,7 @@ public interface XSLTLiaison { | |||||
* @param name the parameter name. | * @param name the parameter name. | ||||
* @param expression the parameter value as an expression string. | * @param expression the parameter value as an expression string. | ||||
* @throws Exception thrown if any problems happens. | * @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 | * @since Ant 1.3 | ||||
*/ | */ | ||||
void addParam(String name, String expression) throws Exception; | void addParam(String name, String expression) throws Exception; | ||||
@@ -17,8 +17,6 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import javax.xml.transform.Transformer; | |||||
/** | /** | ||||
* Extends Proxy interface for XSLT processors: adds support for XSLT parameters | * Extends Proxy interface for XSLT processors: adds support for XSLT parameters | ||||
* of various types (not only String) | * of various types (not only String) | ||||
@@ -210,7 +210,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
private boolean failOnNoResources = true; | private boolean failOnNoResources = true; | ||||
/** | /** | ||||
* For evaluating template params | * For evaluating template params | ||||
* | * | ||||
@@ -617,7 +617,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
*/ | */ | ||||
public boolean getSuppressWarnings() { | public boolean getSuppressWarnings() { | ||||
return suppressWarnings; | return suppressWarnings; | ||||
} | |||||
} | |||||
/** | /** | ||||
* Whether transformation errors should make the build fail. | * Whether transformation errors should make the build fail. | ||||
@@ -978,7 +978,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
/** The parameter's value */ | /** The parameter's value */ | ||||
private String expression = null; | private String expression = null; | ||||
/** | /** | ||||
* Type of the expression. | * Type of the expression. | ||||
* @see ParamType | * @see ParamType | ||||
@@ -1011,7 +1011,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* The parameter value - | * The parameter value - | ||||
* can be a primitive type value or an XPath expression. | * can be a primitive type value or an XPath expression. | ||||
* @param expression the parameter's value/expression. | * @param expression the parameter's value/expression. | ||||
* @see #setType(java.lang.String) | |||||
* @see #setType(java.lang.String) | |||||
*/ | */ | ||||
public void setExpression(String expression) { | public void setExpression(String expression) { | ||||
this.expression = expression; | this.expression = expression; | ||||
@@ -1024,7 +1024,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
public void setType(String type) { | public void setType(String type) { | ||||
this.type = type; | this.type = type; | ||||
} | } | ||||
/** | /** | ||||
* Get the parameter name | * Get the parameter name | ||||
* | * | ||||
@@ -1113,7 +1113,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
&& ph.testUnlessCondition(unlessCond); | && ph.testUnlessCondition(unlessCond); | ||||
} | } | ||||
} // Param | } // Param | ||||
/** | /** | ||||
* Enum for types of the parameter expression. | * 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 | * <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 | * "true" with no type, in XSLT it will be only a text string, not true | ||||
* boolean.</p> | * boolean.</p> | ||||
* | |||||
* | |||||
* @see Param#setType(java.lang.String) | * @see Param#setType(java.lang.String) | ||||
* @see Param#setExpression(java.lang.String) | * @see Param#setExpression(java.lang.String) | ||||
* @since Ant 1.9.3 | * @since Ant 1.9.3 | ||||
@@ -1151,7 +1151,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
XPATH_NUMBER, | XPATH_NUMBER, | ||||
XPATH_NODE, | XPATH_NODE, | ||||
XPATH_NODESET; | XPATH_NODESET; | ||||
public static final Map<ParamType, QName> XPATH_TYPES; | public static final Map<ParamType, QName> XPATH_TYPES; | ||||
static { | static { | ||||
@@ -1230,11 +1230,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
public void init() throws BuildException { | public void init() throws BuildException { | ||||
super.init(); | super.init(); | ||||
xmlCatalog.setProject(getProject()); | xmlCatalog.setProject(getProject()); | ||||
xpathFactory = XPathFactory.newInstance(); | xpathFactory = XPathFactory.newInstance(); | ||||
xpath = xpathFactory.newXPath(); | xpath = xpathFactory.newXPath(); | ||||
xpath.setXPathVariableResolver(new XPathVariableResolver() { | xpath.setXPathVariableResolver(new XPathVariableResolver() { | ||||
public Object resolveVariable(QName variableName) { | |||||
@Override | |||||
public Object resolveVariable(QName variableName) { | |||||
return getProject().getProperty(variableName.toString()); | return getProject().getProperty(variableName.toString()); | ||||
} | } | ||||
}); | }); | ||||
@@ -1247,7 +1248,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @exception BuildException if the stylesheet cannot be loaded. | * @exception BuildException if the stylesheet cannot be loaded. | ||||
* @deprecated since Ant 1.7 | * @deprecated since Ant 1.7 | ||||
*/ | */ | ||||
protected void configureLiaison(File stylesheet) throws BuildException { | |||||
@Deprecated | |||||
protected void configureLiaison(File stylesheet) throws BuildException { | |||||
FileResource fr = new FileResource(); | FileResource fr = new FileResource(); | ||||
fr.setProject(getProject()); | fr.setProject(getProject()); | ||||
fr.setFile(stylesheet); | fr.setFile(stylesheet); | ||||
@@ -1314,7 +1316,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
handleTransformationError(ex); | handleTransformationError(ex); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Evaluates parameter expression according to its type. | * Evaluates parameter expression according to its type. | ||||
* | * | ||||
@@ -1530,7 +1532,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @return null | * @return null | ||||
* @throws BuildException never | * @throws BuildException never | ||||
*/ | */ | ||||
public Object createDynamicElement(String name) throws BuildException { | |||||
@Override | |||||
public Object createDynamicElement(String name) throws BuildException { | |||||
return null; | return null; | ||||
} | } | ||||
@@ -1541,7 +1544,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param value the value of the attribute | * @param value the value of the attribute | ||||
* @throws BuildException on error | * @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. | // only 'name' and 'value' exist. | ||||
if ("name".equalsIgnoreCase(name)) { | if ("name".equalsIgnoreCase(name)) { | ||||
this.name = value; | this.name = value; | ||||
@@ -1576,11 +1580,14 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
private class StyleMapper implements FileNameMapper { | 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('.'); | int dotPos = xmlFile.lastIndexOf('.'); | ||||
if (dotPos > 0) { | if (dotPos > 0) { | ||||
xmlFile = xmlFile.substring(0, dotPos); | xmlFile = xmlFile.substring(0, dotPos); | ||||
@@ -105,14 +105,16 @@ public class Zip extends MatchingTask { | |||||
private static final ResourceSelector MISSING_SELECTOR = | private static final ResourceSelector MISSING_SELECTOR = | ||||
new ResourceSelector() { | new ResourceSelector() { | ||||
public boolean isSelected(Resource target) { | |||||
@Override | |||||
public boolean isSelected(Resource target) { | |||||
return !target.isExists(); | return !target.isExists(); | ||||
} | } | ||||
}; | }; | ||||
private static final ResourceUtils.ResourceSelectorProvider | private static final ResourceUtils.ResourceSelectorProvider | ||||
MISSING_DIR_PROVIDER = new ResourceUtils.ResourceSelectorProvider() { | MISSING_DIR_PROVIDER = new ResourceUtils.ResourceSelectorProvider() { | ||||
public ResourceSelector | |||||
@Override | |||||
public ResourceSelector | |||||
getTargetSelectorForSource(Resource sr) { | getTargetSelectorForSource(Resource sr) { | ||||
return MISSING_SELECTOR; | return MISSING_SELECTOR; | ||||
} | } | ||||
@@ -237,7 +239,8 @@ public class Zip extends MatchingTask { | |||||
* Use setDestFile(File) instead. | * Use setDestFile(File) instead. | ||||
* @ant.attribute ignore="true" | * @ant.attribute ignore="true" | ||||
*/ | */ | ||||
public void setZipfile(File zipFile) { | |||||
@Deprecated | |||||
public void setZipfile(File zipFile) { | |||||
setDestFile(zipFile); | setDestFile(zipFile); | ||||
} | } | ||||
@@ -250,7 +253,8 @@ public class Zip extends MatchingTask { | |||||
* Use setDestFile(File) instead. | * Use setDestFile(File) instead. | ||||
* @ant.attribute ignore="true" | * @ant.attribute ignore="true" | ||||
*/ | */ | ||||
public void setFile(File file) { | |||||
@Deprecated | |||||
public void setFile(File file) { | |||||
setDestFile(file); | setDestFile(file); | ||||
} | } | ||||
@@ -383,7 +387,8 @@ public class Zip extends MatchingTask { | |||||
* The string values for the enumerated value | * The string values for the enumerated value | ||||
* @return the values | * @return the values | ||||
*/ | */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {"fail", "skip", "create"}; | return new String[] {"fail", "skip", "create"}; | ||||
} | } | ||||
} | } | ||||
@@ -581,7 +586,8 @@ public class Zip extends MatchingTask { | |||||
* validate and build | * validate and build | ||||
* @throws BuildException on error | * @throws BuildException on error | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
if (doubleFilePass) { | if (doubleFilePass) { | ||||
skipWriting = true; | skipWriting = true; | ||||
@@ -628,7 +634,7 @@ public class Zip extends MatchingTask { | |||||
} | } | ||||
final int size = resources.size(); | final int size = resources.size(); | ||||
for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | ||||
ResourceCollection rc = (ResourceCollection) resources.elementAt(i); | |||||
ResourceCollection rc = resources.elementAt(i); | |||||
vfss.addElement(rc); | vfss.addElement(rc); | ||||
} | } | ||||
@@ -702,7 +708,7 @@ public class Zip extends MatchingTask { | |||||
final int addSize = addedFiles.size(); | final int addSize = addedFiles.size(); | ||||
for (int i = 0; i < addSize; i++) { | for (int i = 0; i < addSize; i++) { | ||||
PatternSet.NameEntry ne = oldFiles.createExclude(); | PatternSet.NameEntry ne = oldFiles.createExclude(); | ||||
ne.setName((String) addedFiles.elementAt(i)); | |||||
ne.setName(addedFiles.elementAt(i)); | |||||
} | } | ||||
DirectoryScanner ds = | DirectoryScanner ds = | ||||
oldFiles.getDirectoryScanner(getProject()); | oldFiles.getDirectoryScanner(getProject()); | ||||
@@ -855,7 +861,7 @@ public class Zip extends MatchingTask { | |||||
for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | ||||
logWhenWriting("Processing groupfileset ", Project.MSG_VERBOSE); | logWhenWriting("Processing groupfileset ", Project.MSG_VERBOSE); | ||||
FileSet fs = (FileSet) groupfilesets.elementAt(i); | |||||
FileSet fs = groupfilesets.elementAt(i); | |||||
FileScanner scanner = fs.getDirectoryScanner(getProject()); | FileScanner scanner = fs.getDirectoryScanner(getProject()); | ||||
String[] files = scanner.getIncludedFiles(); | String[] files = scanner.getIncludedFiles(); | ||||
File basedir = scanner.getBasedir(); | File basedir = scanner.getBasedir(); | ||||
@@ -1249,7 +1255,7 @@ public class Zip extends MatchingTask { | |||||
ArchiveState as = getNonFileSetResourcesToAdd(rc, zipFile, | ArchiveState as = getNonFileSetResourcesToAdd(rc, zipFile, | ||||
needsUpdate); | needsUpdate); | ||||
FileSet[] fs = (FileSet[]) filesets.toArray(new FileSet[filesets | |||||
FileSet[] fs = filesets.toArray(new FileSet[filesets | |||||
.size()]); | .size()]); | ||||
ArchiveState as2 = getResourcesToAdd(fs, zipFile, as.isOutOfDate()); | ArchiveState as2 = getResourcesToAdd(fs, zipFile, as.isOutOfDate()); | ||||
if (!as.isOutOfDate() && as2.isOutOfDate()) { | if (!as.isOutOfDate() && as2.isOutOfDate()) { | ||||
@@ -1285,7 +1291,8 @@ public class Zip extends MatchingTask { | |||||
* subclasses in several ways). | * subclasses in several ways). | ||||
*/ | */ | ||||
private static final ThreadLocal<Boolean> HAVE_NON_FILE_SET_RESOURCES_TO_ADD = new ThreadLocal<Boolean>() { | 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; | return Boolean.FALSE; | ||||
} | } | ||||
}; | }; | ||||
@@ -1630,7 +1637,8 @@ public class Zip extends MatchingTask { | |||||
// make sure directories are in alpha-order - this also | // make sure directories are in alpha-order - this also | ||||
// ensures parents come before their children | // ensures parents come before their children | ||||
Collections.sort(dirs, new Comparator<Resource>() { | 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()); | return r1.getName().compareTo(r2.getName()); | ||||
} | } | ||||
}); | }); | ||||
@@ -1739,7 +1747,7 @@ public class Zip extends MatchingTask { | |||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
protected final ZipExtraField[] getCurrentExtraFields() { | 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) { | protected Resource[] selectFileResources(Resource[] orig) { | ||||
return selectResources(orig, | return selectResources(orig, | ||||
new ResourceSelector() { | new ResourceSelector() { | ||||
public boolean isSelected(Resource r) { | |||||
@Override | |||||
public boolean isSelected(Resource r) { | |||||
if (!r.isDirectory()) { | if (!r.isDirectory()) { | ||||
return true; | return true; | ||||
} else if (doFilesonly) { | } else if (doFilesonly) { | ||||
@@ -2056,7 +2065,8 @@ public class Zip extends MatchingTask { | |||||
protected Resource[] selectDirectoryResources(Resource[] orig) { | protected Resource[] selectDirectoryResources(Resource[] orig) { | ||||
return selectResources(orig, | return selectResources(orig, | ||||
new ResourceSelector() { | new ResourceSelector() { | ||||
public boolean isSelected(Resource r) { | |||||
@Override | |||||
public boolean isSelected(Resource r) { | |||||
return r.isDirectory(); | return r.isDirectory(); | ||||
} | } | ||||
}); | }); | ||||
@@ -2108,7 +2118,8 @@ public class Zip extends MatchingTask { | |||||
* @see EnumeratedAttribute#getValues() | * @see EnumeratedAttribute#getValues() | ||||
*/ | */ | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {"add", "preserve", "fail"}; | return new String[] {"add", "preserve", "fail"}; | ||||
} | } | ||||
} | } | ||||
@@ -2184,7 +2195,8 @@ public class Zip extends MatchingTask { | |||||
.NOT_ENCODEABLE); | .NOT_ENCODEABLE); | ||||
} | } | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {NEVER_KEY, ALWAYS_KEY, N_E_KEY}; | 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); | MODES.put(A_N_KEY, Zip64Mode.AsNeeded); | ||||
} | } | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {NEVER_KEY, ALWAYS_KEY, A_N_KEY}; | 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>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 | * <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 | * 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> | * warning at all. The IDE decompile of the tool entry points is as follows:</p> | ||||
* <pre> | * <pre> | ||||
* public class Main { | * public class Main { | ||||
* public Main() ; | * public Main() ; | ||||
* | |||||
* | |||||
* public static transient void main(String... strings); | * public static transient void main(String... strings); | ||||
* | |||||
* | |||||
* public static transient int process(String... strings); | * public static transient int process(String... strings); | ||||
* | |||||
* | |||||
* public static transient int process(PrintWriter printWriter, | * public static transient int process(PrintWriter printWriter, | ||||
* String... strings); | * String... strings); | ||||
* public static transient int process( | * public static transient int process( | ||||
* AnnotationProcessorFactory annotationProcessorFactory, | * AnnotationProcessorFactory annotationProcessorFactory, | ||||
* String... strings); | * String... strings); | ||||
* | |||||
* | |||||
* public static transient int process( | * public static transient int process( | ||||
* AnnotationProcessorFactory annotationProcessorFactory, | * AnnotationProcessorFactory annotationProcessorFactory, | ||||
* PrintWriter printWriter, | * PrintWriter printWriter, | ||||
@@ -157,7 +157,8 @@ public class AptCompilerAdapter extends DefaultCompilerAdapter { | |||||
* @return true on success. | * @return true on success. | ||||
* @throws BuildException if the compilation has problems. | * @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); | attributes.log("Using apt compiler", Project.MSG_VERBOSE); | ||||
//set up the javac options | //set up the javac options | ||||
Commandline cmd = setupModernJavacCommand(); | Commandline cmd = setupModernJavacCommand(); | ||||
@@ -20,7 +20,7 @@ package org.apache.tools.ant.taskdefs.compilers; | |||||
/** | /** | ||||
* Extension interface for compilers that support source extensions | * Extension interface for compilers that support source extensions | ||||
* other than .java. | * other than .java. | ||||
* | |||||
* | |||||
* @since Ant 1.8.2 | * @since Ant 1.8.2 | ||||
*/ | */ | ||||
public interface CompilerAdapterExtension { | public interface CompilerAdapterExtension { | ||||
@@ -32,7 +32,7 @@ public interface CompilerAdapterExtension { | |||||
* <p>For example, most compiler adapters will return [ "java" ], | * <p>For example, most compiler adapters will return [ "java" ], | ||||
* but a compiler adapter that can compile both Java and Groovy | * but a compiler adapter that can compile both Java and Groovy | ||||
* source code would return [ "java", "groovy" ].</p> | * source code would return [ "java", "groovy" ].</p> | ||||
* | |||||
* | |||||
* @return list of source file extensions recognized by this | * @return list of source file extensions recognized by this | ||||
* compiler adapter. | * compiler adapter. | ||||
*/ | */ | ||||
@@ -97,7 +97,8 @@ public abstract class DefaultCompilerAdapter | |||||
* | * | ||||
* @param attributes a configured Javac task. | * @param attributes a configured Javac task. | ||||
*/ | */ | ||||
public void setJavac(Javac attributes) { | |||||
@Override | |||||
public void setJavac(final Javac attributes) { | |||||
this.attributes = attributes; | this.attributes = attributes; | ||||
src = attributes.getSrcdir(); | src = attributes.getSrcdir(); | ||||
destDir = attributes.getDestdir(); | destDir = attributes.getDestdir(); | ||||
@@ -135,8 +136,9 @@ public abstract class DefaultCompilerAdapter | |||||
* but specialized compilers can recognize multiple kinds | * but specialized compilers can recognize multiple kinds | ||||
* of files. | * 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 | * @return the compilation class path | ||||
*/ | */ | ||||
protected Path getCompileClasspath() { | protected Path getCompileClasspath() { | ||||
Path classpath = new Path(project); | |||||
final Path classpath = new Path(project); | |||||
// add dest dir to classpath so that previously compiled and | // add dest dir to classpath so that previously compiled and | ||||
// untouched classes are on classpath | // untouched classes are on classpath | ||||
@@ -187,7 +189,7 @@ public abstract class DefaultCompilerAdapter | |||||
* @param cmd the command line | * @param cmd the command line | ||||
* @return the command line | * @return the command line | ||||
*/ | */ | ||||
protected Commandline setupJavacCommandlineSwitches(Commandline cmd) { | |||||
protected Commandline setupJavacCommandlineSwitches(final Commandline cmd) { | |||||
return setupJavacCommandlineSwitches(cmd, false); | 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 | * @param useDebugLevel if true set set the debug level with the -g switch | ||||
* @return the command line | * @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. | // For -sourcepath, use the "sourcepath" value if present. | ||||
// Otherwise default to the "srcdir" value. | // Otherwise default to the "srcdir" value. | ||||
Path sourcepath = null; | Path sourcepath = null; | ||||
@@ -210,7 +212,7 @@ public abstract class DefaultCompilerAdapter | |||||
sourcepath = src; | sourcepath = src; | ||||
} | } | ||||
String memoryParameterPrefix = assumeJava11() ? "-J-" : "-J-X"; | |||||
final String memoryParameterPrefix = assumeJava11() ? "-J-" : "-J-X"; | |||||
if (memoryInitialSize != null) { | if (memoryInitialSize != null) { | ||||
if (!attributes.isForkedJavac()) { | if (!attributes.isForkedJavac()) { | ||||
attributes.log("Since fork is false, ignoring " | attributes.log("Since fork is false, ignoring " | ||||
@@ -251,9 +253,9 @@ public abstract class DefaultCompilerAdapter | |||||
// Just add "sourcepath" to classpath ( for JDK1.1 ) | // Just add "sourcepath" to classpath ( for JDK1.1 ) | ||||
// as well as "bootclasspath" and "extdirs" | // as well as "bootclasspath" and "extdirs" | ||||
if (assumeJava11()) { | if (assumeJava11()) { | ||||
Path cp = new Path(project); | |||||
final Path cp = new Path(project); | |||||
Path bp = getBootClassPath(); | |||||
final Path bp = getBootClassPath(); | |||||
if (bp.size() > 0) { | if (bp.size() > 0) { | ||||
cp.append(bp); | cp.append(bp); | ||||
} | } | ||||
@@ -277,7 +279,7 @@ public abstract class DefaultCompilerAdapter | |||||
cmd.createArgument().setValue(target); | cmd.createArgument().setValue(target); | ||||
} | } | ||||
Path bp = getBootClassPath(); | |||||
final Path bp = getBootClassPath(); | |||||
if (bp.size() > 0) { | if (bp.size() > 0) { | ||||
cmd.createArgument().setValue("-bootclasspath"); | cmd.createArgument().setValue("-bootclasspath"); | ||||
cmd.createArgument().setPath(bp); | cmd.createArgument().setPath(bp); | ||||
@@ -295,7 +297,7 @@ public abstract class DefaultCompilerAdapter | |||||
} | } | ||||
if (debug) { | if (debug) { | ||||
if (useDebugLevel && !assumeJava11()) { | if (useDebugLevel && !assumeJava11()) { | ||||
String debugLevel = attributes.getDebugLevel(); | |||||
final String debugLevel = attributes.getDebugLevel(); | |||||
if (debugLevel != null) { | if (debugLevel != null) { | ||||
cmd.createArgument().setValue("-g:" + debugLevel); | cmd.createArgument().setValue("-g:" + debugLevel); | ||||
} else { | } else { | ||||
@@ -337,7 +339,7 @@ public abstract class DefaultCompilerAdapter | |||||
* @param cmd the command line | * @param cmd the command line | ||||
* @return the command line | * @return the command line | ||||
*/ | */ | ||||
protected Commandline setupModernJavacCommandlineSwitches(Commandline cmd) { | |||||
protected Commandline setupModernJavacCommandlineSwitches(final Commandline cmd) { | |||||
setupJavacCommandlineSwitches(cmd, true); | setupJavacCommandlineSwitches(cmd, true); | ||||
if (!assumeJava13()) { // -source added with JDK 1.4 | if (!assumeJava13()) { // -source added with JDK 1.4 | ||||
final String t = attributes.getTarget(); | final String t = attributes.getTarget(); | ||||
@@ -359,7 +361,7 @@ public abstract class DefaultCompilerAdapter | |||||
* @return the command line | * @return the command line | ||||
*/ | */ | ||||
protected Commandline setupModernJavacCommand() { | protected Commandline setupModernJavacCommand() { | ||||
Commandline cmd = new Commandline(); | |||||
final Commandline cmd = new Commandline(); | |||||
setupModernJavacCommandlineSwitches(cmd); | setupModernJavacCommandlineSwitches(cmd); | ||||
logAndAddFilesToCompile(cmd); | logAndAddFilesToCompile(cmd); | ||||
@@ -380,8 +382,8 @@ public abstract class DefaultCompilerAdapter | |||||
* @param debugLevelCheck if true set the debug level with the -g switch | * @param debugLevelCheck if true set the debug level with the -g switch | ||||
* @return the command line | * @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); | setupJavacCommandlineSwitches(cmd, debugLevelCheck); | ||||
logAndAddFilesToCompile(cmd); | logAndAddFilesToCompile(cmd); | ||||
return cmd; | return cmd; | ||||
@@ -392,11 +394,11 @@ public abstract class DefaultCompilerAdapter | |||||
* "niceSourceList" | * "niceSourceList" | ||||
* @param cmd the command line | * @param cmd the command line | ||||
*/ | */ | ||||
protected void logAndAddFilesToCompile(Commandline cmd) { | |||||
protected void logAndAddFilesToCompile(final Commandline cmd) { | |||||
attributes.log("Compilation " + cmd.describeArguments(), | attributes.log("Compilation " + cmd.describeArguments(), | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
StringBuffer niceSourceList = new StringBuffer("File"); | |||||
final StringBuffer niceSourceList = new StringBuffer("File"); | |||||
if (compileList.length != 1) { | if (compileList.length != 1) { | ||||
niceSourceList.append("s"); | niceSourceList.append("s"); | ||||
} | } | ||||
@@ -405,7 +407,7 @@ public abstract class DefaultCompilerAdapter | |||||
niceSourceList.append(StringUtils.LINE_SEP); | niceSourceList.append(StringUtils.LINE_SEP); | ||||
for (int i = 0; i < compileList.length; i++) { | for (int i = 0; i < compileList.length; i++) { | ||||
String arg = compileList[i].getAbsolutePath(); | |||||
final String arg = compileList[i].getAbsolutePath(); | |||||
cmd.createArgument().setValue(arg); | cmd.createArgument().setValue(arg); | ||||
niceSourceList.append(" "); | niceSourceList.append(" "); | ||||
niceSourceList.append(arg); | niceSourceList.append(arg); | ||||
@@ -424,7 +426,7 @@ public abstract class DefaultCompilerAdapter | |||||
* system. | * system. | ||||
* @return the exit code of the compilation | * @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); | return executeExternalCompile(args, firstFileName, true); | ||||
} | } | ||||
@@ -447,8 +449,8 @@ public abstract class DefaultCompilerAdapter | |||||
* | * | ||||
* @since Ant 1.6 | * @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; | String[] commandArray = null; | ||||
File tmpFile = null; | File tmpFile = null; | ||||
@@ -480,7 +482,7 @@ public abstract class DefaultCompilerAdapter | |||||
commandArray = new String[firstFileName + 1]; | commandArray = new String[firstFileName + 1]; | ||||
System.arraycopy(args, 0, commandArray, 0, firstFileName); | System.arraycopy(args, 0, commandArray, 0, firstFileName); | ||||
commandArray[firstFileName] = "@" + tmpFile; | commandArray[firstFileName] = "@" + tmpFile; | ||||
} catch (IOException e) { | |||||
} catch (final IOException e) { | |||||
throw new BuildException("Error creating temporary file", | throw new BuildException("Error creating temporary file", | ||||
e, location); | e, location); | ||||
} finally { | } finally { | ||||
@@ -491,7 +493,7 @@ public abstract class DefaultCompilerAdapter | |||||
} | } | ||||
try { | try { | ||||
Execute exe = new Execute( | |||||
final Execute exe = new Execute( | |||||
new LogStreamHandler(attributes, | new LogStreamHandler(attributes, | ||||
Project.MSG_INFO, | Project.MSG_INFO, | ||||
Project.MSG_WARN)); | Project.MSG_WARN)); | ||||
@@ -505,7 +507,7 @@ public abstract class DefaultCompilerAdapter | |||||
exe.setCommandline(commandArray); | exe.setCommandline(commandArray); | ||||
exe.execute(); | exe.execute(); | ||||
return exe.getExitValue(); | return exe.getExitValue(); | ||||
} catch (IOException e) { | |||||
} catch (final IOException e) { | |||||
throw new BuildException("Error running " + args[0] | throw new BuildException("Error running " + args[0] | ||||
+ " compiler", e, location); | + " compiler", e, location); | ||||
} | } | ||||
@@ -522,7 +524,8 @@ public abstract class DefaultCompilerAdapter | |||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Use org.apache.tools.ant.types.Path#addExtdirs instead. | * Use org.apache.tools.ant.types.Path#addExtdirs instead. | ||||
*/ | */ | ||||
protected void addExtdirsToClasspath(Path classpath) { | |||||
@Deprecated | |||||
protected void addExtdirsToClasspath(final Path classpath) { | |||||
classpath.addExtdirs(extdirs); | classpath.addExtdirs(extdirs); | ||||
} | } | ||||
@@ -530,7 +533,7 @@ public abstract class DefaultCompilerAdapter | |||||
* Adds the command line arguments specific to the current implementation. | * Adds the command line arguments specific to the current implementation. | ||||
* @param cmd the command line to use | * @param cmd the command line to use | ||||
*/ | */ | ||||
protected void addCurrentCompilerArgs(Commandline cmd) { | |||||
protected void addCurrentCompilerArgs(final Commandline cmd) { | |||||
cmd.addArguments(getJavac().getCurrentCompilerArgs()); | cmd.addArguments(getJavac().getCurrentCompilerArgs()); | ||||
} | } | ||||
@@ -619,7 +622,7 @@ public abstract class DefaultCompilerAdapter | |||||
* Shall we assume command line switches for the given version of Java? | * Shall we assume command line switches for the given version of Java? | ||||
* @since Ant 1.8.3 | * @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()) | return javacXY.equals(attributes.getCompilerVersion()) | ||||
|| ("classic".equals(attributes.getCompilerVersion()) | || ("classic".equals(attributes.getCompilerVersion()) | ||||
&& JavaEnvUtils.isJavaVersion(javaEnvVersionXY)) | && JavaEnvUtils.isJavaVersion(javaEnvVersionXY)) | ||||
@@ -637,7 +640,7 @@ public abstract class DefaultCompilerAdapter | |||||
* specified and the system bootclasspath. | * specified and the system bootclasspath. | ||||
*/ | */ | ||||
protected Path getBootClassPath() { | protected Path getBootClassPath() { | ||||
Path bp = new Path(project); | |||||
final Path bp = new Path(project); | |||||
if (bootclasspath != null) { | if (bootclasspath != null) { | ||||
bp.append(bootclasspath); | bp.append(bootclasspath); | ||||
} | } | ||||
@@ -658,8 +661,8 @@ public abstract class DefaultCompilerAdapter | |||||
return assumeJava11() ? null : "-g:none"; | 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("", Project.MSG_WARN); | ||||
attributes.log(" WARNING", Project.MSG_WARN); | attributes.log(" WARNING", Project.MSG_WARN); | ||||
attributes.log("", 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 | * <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> | * 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; | 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. | * <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, | * 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> | * 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 | * <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 | * because on a laptop, DNS is one of the first services lost when the network | ||||
* goes; you are implicitly offline.</p> | * goes; you are implicitly offline.</p> | ||||
* | |||||
* | |||||
* <p>If a URL is supplied instead of a host, the hostname is extracted and used in | * <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> | * 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 | * <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 | * 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 | * 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> | * 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 | * <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> | * 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 | * @throws org.apache.tools.ant.BuildException | ||||
* if an error occurs | * if an error occurs | ||||
*/ | */ | ||||
public boolean eval() throws BuildException { | |||||
@Override | |||||
public boolean eval() throws BuildException { | |||||
if (empty(host) && empty(url)) { | if (empty(host) && empty(url)) { | ||||
throw new BuildException(ERROR_NO_HOSTNAME); | throw new BuildException(ERROR_NO_HOSTNAME); | ||||
} | } | ||||
@@ -88,11 +88,11 @@ class ChangeLogParser { | |||||
ArrayList names = new ArrayList(); | ArrayList names = new ArrayList(); | ||||
if (packageName != null) { | if (packageName != null) { | ||||
for (StringTokenizer tok = new StringTokenizer(packageName); | for (StringTokenizer tok = new StringTokenizer(packageName); | ||||
tok.hasMoreTokens(); ) { | |||||
tok.hasMoreTokens();) { | |||||
names.add(tok.nextToken()); | 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(); | AbstractCvsTask.Module m = (AbstractCvsTask.Module) iter.next(); | ||||
names.add(m.getName()); | names.add(m.getName()); | ||||
} | } | ||||
@@ -144,7 +144,7 @@ public class CvsTagDiff extends AbstractCvsTask { | |||||
private File mydestfile; | private File mydestfile; | ||||
/** | /** | ||||
* Used to skip over removed files | |||||
* Used to skip over removed files | |||||
*/ | */ | ||||
private boolean ignoreRemoved = false; | private boolean ignoreRemoved = false; | ||||
@@ -167,7 +167,8 @@ public class CvsTagDiff extends AbstractCvsTask { | |||||
* The package/module to analyze. | * The package/module to analyze. | ||||
* @param p the name of the package to analyse | * @param p the name of the package to analyse | ||||
*/ | */ | ||||
public void setPackage(String p) { | |||||
@Override | |||||
public void setPackage(String p) { | |||||
mypackage = p; | mypackage = p; | ||||
} | } | ||||
@@ -222,7 +223,7 @@ public class CvsTagDiff extends AbstractCvsTask { | |||||
* @param b the ignore removed indicator. | * @param b the ignore removed indicator. | ||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | |||||
*/ | |||||
public void setIgnoreRemoved(boolean b) { | public void setIgnoreRemoved(boolean b) { | ||||
ignoreRemoved = b; | ignoreRemoved = b; | ||||
} | } | ||||
@@ -233,7 +234,8 @@ public class CvsTagDiff extends AbstractCvsTask { | |||||
* | * | ||||
* @exception BuildException if an error occurs | * @exception BuildException if an error occurs | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
// validate the input parameters | // validate the input parameters | ||||
validate(); | validate(); | ||||
@@ -80,7 +80,7 @@ public class CommandLauncher { | |||||
/** | /** | ||||
* Launches the given command in a new process. | * Launches the given command in a new process. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* The project that the command is part of. | * The project that the command is part of. | ||||
* @param cmd | * @param cmd | ||||
@@ -104,7 +104,7 @@ public class CommandLauncher { | |||||
/** | /** | ||||
* Launches the given command in a new process, in the given | * Launches the given command in a new process, in the given | ||||
* working directory. | * working directory. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* The project that the command is part of. | * The project that the command is part of. | ||||
* @param cmd | * @param cmd | ||||
@@ -35,7 +35,7 @@ public class CommandLauncherProxy extends CommandLauncher { | |||||
/** | /** | ||||
* Launches the given command in a new process. Delegates this | * Launches the given command in a new process. Delegates this | ||||
* method to the proxied launcher. | * method to the proxied launcher. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* the Ant project. | * the Ant project. | ||||
* @param cmd | * @param cmd | ||||
@@ -33,7 +33,7 @@ public class Java13CommandLauncher extends CommandLauncher { | |||||
/** | /** | ||||
* Launches the given command in a new process, in the given | * Launches the given command in a new process, in the given | ||||
* working directory. | * working directory. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* the Ant project. | * the Ant project. | ||||
* @param cmd | * @param cmd | ||||
@@ -34,7 +34,7 @@ public class MacCommandLauncher extends CommandLauncherProxy { | |||||
/** | /** | ||||
* Launches the given command in a new process, in the given | * Launches the given command in a new process, in the given | ||||
* working directory. | * working directory. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* the Ant project. | * the Ant project. | ||||
* @param cmd | * @param cmd | ||||
@@ -37,7 +37,7 @@ public class OS2CommandLauncher extends CommandLauncherProxy { | |||||
/** | /** | ||||
* Launches the given command in a new process, in the given | * Launches the given command in a new process, in the given | ||||
* working directory. | * working directory. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* the Ant project. | * the Ant project. | ||||
* @param cmd | * @param cmd | ||||
@@ -38,7 +38,7 @@ public class PerlScriptCommandLauncher extends CommandLauncherProxy { | |||||
/** | /** | ||||
* Launches the given command in a new process, in the given | * Launches the given command in a new process, in the given | ||||
* working directory. | * working directory. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* the Ant project. | * the Ant project. | ||||
* @param cmd | * @param cmd | ||||
@@ -38,7 +38,7 @@ public class ScriptCommandLauncher extends CommandLauncherProxy { | |||||
/** | /** | ||||
* Launches the given command in a new process, in the given | * Launches the given command in a new process, in the given | ||||
* working directory. | * working directory. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* the Ant project. | * the Ant project. | ||||
* @param cmd | * @param cmd | ||||
@@ -38,7 +38,7 @@ public class VmsCommandLauncher extends Java13CommandLauncher { | |||||
/** | /** | ||||
* Launches the given command in a new process. | * Launches the given command in a new process. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* the Ant project. | * the Ant project. | ||||
* @param cmd | * @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 | * 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 | * this method only works if <code>workingDir</code> is null or | ||||
* the logical JAVA$FORK_SUPPORT_CHDIR needs to be set to TRUE. | * the logical JAVA$FORK_SUPPORT_CHDIR needs to be set to TRUE. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* the Ant project. | * the Ant project. | ||||
* @param cmd | * @param cmd | ||||
@@ -35,7 +35,7 @@ public class WinNTCommandLauncher extends CommandLauncherProxy { | |||||
/** | /** | ||||
* Launches the given command in a new process, in the given | * Launches the given command in a new process, in the given | ||||
* working directory. | * working directory. | ||||
* | |||||
* | |||||
* @param project | * @param project | ||||
* the Ant project. | * the Ant project. | ||||
* @param cmd | * @param cmd | ||||
@@ -71,9 +71,9 @@ import org.apache.tools.ant.util.LayoutPreservingProperties; | |||||
* </ul> | * </ul> | ||||
* Other parameters are: | * Other parameters are: | ||||
* <ul> | * <ul> | ||||
* <li>comment</li> | |||||
* <li>key</li> | |||||
* <li>operation</li> | |||||
* <li>comment</li> | |||||
* <li>key</li> | |||||
* <li>operation</li> | |||||
* <li>type</li> | * <li>type</li> | ||||
* <li>value (the final four being eliminated shortly)</li> | * <li>value (the final four being eliminated shortly)</li> | ||||
* </ul> | * </ul> | ||||
@@ -155,7 +155,8 @@ public class PropertyFile extends Task { | |||||
* Execute the task. | * Execute the task. | ||||
* @throws BuildException on error. | * @throws BuildException on error. | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
checkParameters(); | checkParameters(); | ||||
readFile(); | readFile(); | ||||
executeOperation(); | executeOperation(); | ||||
@@ -378,7 +379,7 @@ public class PropertyFile extends Task { | |||||
*/ | */ | ||||
protected void executeOn(Properties props) throws BuildException { | protected void executeOn(Properties props) throws BuildException { | ||||
checkParameters(); | checkParameters(); | ||||
if (operation == Operation.DELETE_OPER) { | if (operation == Operation.DELETE_OPER) { | ||||
props.remove(key); | props.remove(key); | ||||
return; | return; | ||||
@@ -614,7 +615,8 @@ public class PropertyFile extends Task { | |||||
public static final int DELETE_OPER = 3; | public static final int DELETE_OPER = 3; | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {"+", "-", "=", "del"}; | return new String[] {"+", "-", "=", "del"}; | ||||
} | } | ||||
@@ -649,7 +651,8 @@ public class PropertyFile extends Task { | |||||
public static final int STRING_TYPE = 2; | public static final int STRING_TYPE = 2; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {"int", "date", "string"}; | return new String[] {"int", "date", "string"}; | ||||
} | } | ||||
@@ -715,7 +718,8 @@ public class PropertyFile extends Task { | |||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return UNITS; | return UNITS; | ||||
} | } | ||||
} | } | ||||
@@ -213,7 +213,7 @@ public class ReplaceRegExp extends Task { | |||||
* want to only replace the first occurrence of a regular expression on | * 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. | * each line, which is not easy to do when processing the file as a whole. | ||||
* Defaults to <i>false</i>. | * Defaults to <i>false</i>. | ||||
* | |||||
* | |||||
* @param byline the byline attribute as a string | * @param byline the byline attribute as a string | ||||
* @deprecated since 1.6.x. | * @deprecated since 1.6.x. | ||||
* Use setByLine(boolean). | * Use setByLine(boolean). | ||||
@@ -234,7 +234,7 @@ public class ReplaceRegExp extends Task { | |||||
* want to only replace the first occurrence of a regular expression on | * 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. | * each line, which is not easy to do when processing the file as a whole. | ||||
* Defaults to <i>false</i>. | * Defaults to <i>false</i>. | ||||
* | |||||
* | |||||
* @param byline the byline attribute | * @param byline the byline attribute | ||||
*/ | */ | ||||
public void setByLine(boolean byline) { | 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. | * @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) { | if (regex == null) { | ||||
throw new BuildException("No expression to match."); | 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 | * @param stylesheet a <code>File</code> value | ||||
* @throws Exception on error | * @throws Exception on error | ||||
*/ | */ | ||||
public void setStylesheet(File stylesheet) throws Exception { | |||||
@Override | |||||
public void setStylesheet(File stylesheet) throws Exception { | |||||
FileResource fr = new FileResource(); | FileResource fr = new FileResource(); | ||||
fr.setProject(project); | fr.setProject(project); | ||||
fr.setFile(stylesheet); | 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 | * @param stylesheet a {@link org.apache.tools.ant.types.Resource} value | ||||
* @throws Exception on error | * @throws Exception on error | ||||
*/ | */ | ||||
public void setStylesheet(Resource stylesheet) throws Exception { | |||||
@Override | |||||
public void setStylesheet(Resource stylesheet) throws Exception { | |||||
if (this.stylesheet != null) { | if (this.stylesheet != null) { | ||||
// resetting the stylesheet - reset transformer | // resetting the stylesheet - reset transformer | ||||
transformer = null; | transformer = null; | ||||
@@ -175,7 +177,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* @param outfile the result file | * @param outfile the result file | ||||
* @throws Exception on error | * @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) { | if (transformer == null) { | ||||
createTransformer(); | createTransformer(); | ||||
} | } | ||||
@@ -504,17 +507,19 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* @param name the name of the parameter | * @param name the name of the parameter | ||||
* @param value the value 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); | params.put(name, value); | ||||
} | } | ||||
/** | /** | ||||
* Add a parameter. | * Add a parameter. | ||||
* @param name the name of the parameter | * @param name the name of the parameter | ||||
* @param value the value of the parameter | * @param value the value of the parameter | ||||
* @since Ant 1.9.3 | * @since Ant 1.9.3 | ||||
*/ | */ | ||||
public void addParam(String name, Object value) { | |||||
@Override | |||||
public void addParam(String name, Object value) { | |||||
params.put(name, value); | params.put(name, value); | ||||
} | } | ||||
@@ -522,7 +527,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* Set a logger. | * Set a logger. | ||||
* @param l a logger. | * @param l a logger. | ||||
*/ | */ | ||||
public void setLogger(XSLTLogger l) { | |||||
@Override | |||||
public void setLogger(XSLTLogger l) { | |||||
logger = l; | logger = l; | ||||
} | } | ||||
@@ -530,7 +536,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* Log an error. | * Log an error. | ||||
* @param e the exception to log. | * @param e the exception to log. | ||||
*/ | */ | ||||
public void error(TransformerException e) { | |||||
@Override | |||||
public void error(TransformerException e) { | |||||
logError(e, "Error"); | logError(e, "Error"); | ||||
} | } | ||||
@@ -538,7 +545,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* Log a fatal error. | * Log a fatal error. | ||||
* @param e the exception to log. | * @param e the exception to log. | ||||
*/ | */ | ||||
public void fatalError(TransformerException e) { | |||||
@Override | |||||
public void fatalError(TransformerException e) { | |||||
logError(e, "Fatal Error"); | logError(e, "Fatal Error"); | ||||
throw new BuildException("Fatal error during transformation using " + stylesheet + ": " + e.getMessageAndLocation(), e); | 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. | * Log a warning. | ||||
* @param e the exception to log. | * @param e the exception to log. | ||||
*/ | */ | ||||
public void warning(TransformerException e) { | |||||
@Override | |||||
public void warning(TransformerException e) { | |||||
if (!suppressWarnings) { | if (!suppressWarnings) { | ||||
logError(e, "Warning"); | logError(e, "Warning"); | ||||
} | } | ||||
@@ -601,7 +610,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Use org.apache.tools.ant.util.JAXPUtils#getSystemId instead. | * Use org.apache.tools.ant.util.JAXPUtils#getSystemId instead. | ||||
*/ | */ | ||||
protected String getSystemId(File file) { | |||||
@Deprecated | |||||
protected String getSystemId(File file) { | |||||
return JAXPUtils.getSystemId(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 | * @param xsltTask the XSLTProcess task instance from which this liasion | ||||
* is to be configured. | * is to be configured. | ||||
*/ | */ | ||||
public void configure(XSLTProcess xsltTask) { | |||||
@Override | |||||
public void configure(XSLTProcess xsltTask) { | |||||
project = xsltTask.getProject(); | project = xsltTask.getProject(); | ||||
XSLTProcess.Factory factory = xsltTask.getFactory(); | XSLTProcess.Factory factory = xsltTask.getFactory(); | ||||
if (factory != null) { | 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 | * @exception java.io.IOException if there is a problem reading the entry from | ||||
* the stream. | * the stream. | ||||
*/ | */ | ||||
public void read(DataInputStream cpStream) throws IOException { | |||||
@Override | |||||
public void read(final DataInputStream cpStream) throws IOException { | |||||
methodDescriptorIndex = cpStream.readUnsignedShort(); | methodDescriptorIndex = cpStream.readUnsignedShort(); | ||||
} | } | ||||
@@ -54,8 +55,9 @@ public class MethodTypeCPInfo extends ConstantCPInfo { | |||||
* @param constantPool the constant pool of which this entry is a member | * @param constantPool the constant pool of which this entry is a member | ||||
* and against which this entry is to be resolved. | * 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); | = (Utf8CPInfo) constantPool.getEntry(methodDescriptorIndex); | ||||
methodClass.resolve(constantPool); | methodClass.resolve(constantPool); | ||||
methodDescriptor = methodClass.getValue(); | methodDescriptor = methodClass.getValue(); | ||||
@@ -66,8 +68,9 @@ public class MethodTypeCPInfo extends ConstantCPInfo { | |||||
* | * | ||||
* @return the string representation of this constant pool entry. | * @return the string representation of this constant pool entry. | ||||
*/ | */ | ||||
public String toString() { | |||||
if (! isResolved()) { | |||||
@Override | |||||
public String toString() { | |||||
if (!isResolved()) { | |||||
return "MethodDescriptorIndex: " + methodDescriptorIndex; | return "MethodDescriptorIndex: " + methodDescriptorIndex; | ||||
} else { | } else { | ||||
return "MethodDescriptor: " + methodDescriptor; | return "MethodDescriptor: " + methodDescriptor; | ||||
@@ -166,7 +166,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||||
* @param inString the string to use as the suffix. This parameter is | * @param inString the string to use as the suffix. This parameter is | ||||
* ignored. | * ignored. | ||||
*/ | */ | ||||
public void setGenericJarSuffix(String inString) { | |||||
@Override | |||||
public void setGenericJarSuffix(String inString) { | |||||
log("Since a generic JAR file is not created during processing, the " | log("Since a generic JAR file is not created during processing, the " | ||||
+ "iPlanet Deployment Tool does not support the " | + "iPlanet Deployment Tool does not support the " | ||||
+ "\"genericjarsuffix\" attribute. It will be ignored.", | + "\"genericjarsuffix\" attribute. It will be ignored.", | ||||
@@ -174,7 +175,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public void processDescriptor(String descriptorName, SAXParser saxParser) { | |||||
@Override | |||||
public void processDescriptor(String descriptorName, SAXParser saxParser) { | |||||
this.descriptorName = descriptorName; | this.descriptorName = descriptorName; | ||||
this.iasDescriptorName = null; | this.iasDescriptorName = null; | ||||
@@ -193,7 +195,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||||
* descriptor | * descriptor | ||||
* @throws BuildException If the user selections are invalid. | * @throws BuildException If the user selections are invalid. | ||||
*/ | */ | ||||
protected void checkConfiguration(String descriptorFileName, | |||||
@Override | |||||
protected void checkConfiguration(String descriptorFileName, | |||||
SAXParser saxParser) throws BuildException { | SAXParser saxParser) throws BuildException { | ||||
int startOfName = descriptorFileName.lastIndexOf(File.separatorChar) + 1; | int startOfName = descriptorFileName.lastIndexOf(File.separatorChar) + 1; | ||||
@@ -236,7 +239,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||||
* @throws SAXException Any SAX exception, possibly wrapping another | * @throws SAXException Any SAX exception, possibly wrapping another | ||||
* exception | * exception | ||||
*/ | */ | ||||
protected Hashtable parseEjbFiles(String descriptorFileName, | |||||
@Override | |||||
protected Hashtable parseEjbFiles(String descriptorFileName, | |||||
SAXParser saxParser) throws IOException, SAXException { | SAXParser saxParser) throws IOException, SAXException { | ||||
Hashtable files; | Hashtable files; | ||||
@@ -257,7 +261,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||||
} | } | ||||
if (getConfig().dtdLocations != null) { | if (getConfig().dtdLocations != null) { | ||||
for (Iterator i = getConfig().dtdLocations.iterator(); | for (Iterator i = getConfig().dtdLocations.iterator(); | ||||
i.hasNext(); ) { | |||||
i.hasNext();) { | |||||
EjbJar.DTDLocation dtdLocation = | EjbJar.DTDLocation dtdLocation = | ||||
(EjbJar.DTDLocation) i.next(); | (EjbJar.DTDLocation) i.next(); | ||||
ejbc.registerDTD(dtdLocation.getPublicId(), | ejbc.registerDTD(dtdLocation.getPublicId(), | ||||
@@ -308,7 +312,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||||
* the completed JAR file. | * the completed JAR file. | ||||
* @param ddPrefix not used | * @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, | ejbFiles.put(META_DIR + IAS_DD, new File(getConfig().descriptorDir, | ||||
getIasDescriptorName())); | getIasDescriptorName())); | ||||
} | } | ||||
@@ -322,7 +327,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||||
* | * | ||||
* @return File representing the JAR file which will be written. | * @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); | File jarFile = new File(getDestDir(), baseName + jarSuffix); | ||||
log("JAR file name: " + jarFile.toString(), Project.MSG_VERBOSE); | log("JAR file name: " + jarFile.toString(), Project.MSG_VERBOSE); | ||||
return jarFile; | return jarFile; | ||||
@@ -335,7 +341,8 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||||
* | * | ||||
* @return <code>null</code>. | * @return <code>null</code>. | ||||
*/ | */ | ||||
protected String getPublicId() { | |||||
@Override | |||||
protected String getPublicId() { | |||||
return null; | return null; | ||||
} | } | ||||
@@ -37,7 +37,6 @@ import java.util.StringTokenizer; | |||||
import javax.xml.parsers.SAXParser; | import javax.xml.parsers.SAXParser; | ||||
import javax.xml.parsers.SAXParserFactory; | import javax.xml.parsers.SAXParserFactory; | ||||
import org.apache.tools.ant.BuildException; | |||||
import org.xml.sax.AttributeList; | import org.xml.sax.AttributeList; | ||||
import org.xml.sax.HandlerBase; | import org.xml.sax.HandlerBase; | ||||
import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
@@ -113,7 +113,8 @@ public class ExtensionSet | |||||
* @param reference the reference to which this instance is associated | * @param reference the reference to which this instance is associated | ||||
* @exception BuildException if this instance already has been configured. | * @exception BuildException if this instance already has been configured. | ||||
*/ | */ | ||||
public void setRefid(final Reference reference) | |||||
@Override | |||||
public void setRefid(final Reference reference) | |||||
throws BuildException { | throws BuildException { | ||||
if (!extensions.isEmpty() || !extensionsFilesets.isEmpty()) { | if (!extensions.isEmpty() || !extensionsFilesets.isEmpty()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
@@ -121,7 +122,8 @@ public class ExtensionSet | |||||
super.setRefid(reference); | super.setRefid(reference); | ||||
} | } | ||||
protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||||
@Override | |||||
protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||||
throws BuildException { | throws BuildException { | ||||
if (isChecked()) { | if (isChecked()) { | ||||
return; | return; | ||||
@@ -129,11 +131,11 @@ public class ExtensionSet | |||||
if (isReference()) { | if (isReference()) { | ||||
super.dieOnCircularReference(stk, p); | super.dieOnCircularReference(stk, p); | ||||
} else { | } else { | ||||
for (Iterator i = extensions.iterator(); i.hasNext(); ) { | |||||
for (Iterator i = extensions.iterator(); i.hasNext();) { | |||||
pushAndInvokeCircularReferenceCheck((ExtensionAdapter) i.next(), | pushAndInvokeCircularReferenceCheck((ExtensionAdapter) i.next(), | ||||
stk, p); | stk, p); | ||||
} | } | ||||
for (Iterator i = extensionsFilesets.iterator(); i.hasNext(); ) { | |||||
for (Iterator i = extensionsFilesets.iterator(); i.hasNext();) { | |||||
pushAndInvokeCircularReferenceCheck((FileSet) i.next(), stk, p); | pushAndInvokeCircularReferenceCheck((FileSet) i.next(), stk, p); | ||||
} | } | ||||
setChecked(true); | setChecked(true); | ||||
@@ -144,7 +146,8 @@ public class ExtensionSet | |||||
* @see java.lang.Object#toString() | * @see java.lang.Object#toString() | ||||
* @return the extensions in a string. | * @return the extensions in a string. | ||||
*/ | */ | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
return "ExtensionSet" + Arrays.asList(toExtensions(getProject())); | 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. | * 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 testClass test class containing the method to be executed | ||||
* @param methodNames names of the test methods that are to be executed | * @param methodNames names of the test methods that are to be executed | ||||
* @exception java.lang.IllegalArgumentException | * @exception java.lang.IllegalArgumentException | ||||
@@ -72,7 +72,7 @@ public class JUnit4TestMethodAdapter implements Test { | |||||
} | } | ||||
} | } | ||||
this.testClass = testClass; | this.testClass = testClass; | ||||
this.methodNames = (String[]) methodNames.clone(); | |||||
this.methodNames = methodNames.clone(); | |||||
this.cache = CustomJUnit4TestAdapterCache.getInstance(); | this.cache = CustomJUnit4TestAdapterCache.getInstance(); | ||||
// Warning: If 'testClass' is an old-style (pre-JUnit-4) class, | // Warning: If 'testClass' is an old-style (pre-JUnit-4) class, | ||||
@@ -87,7 +87,8 @@ public class JUnit4TestMethodAdapter implements Test { | |||||
runner = request.getRunner(); | runner = request.getRunner(); | ||||
} | } | ||||
public int countTestCases() { | |||||
@Override | |||||
public int countTestCases() { | |||||
return runner.testCount(); | return runner.testCount(); | ||||
} | } | ||||
@@ -103,11 +104,13 @@ public class JUnit4TestMethodAdapter implements Test { | |||||
return testClass; | return testClass; | ||||
} | } | ||||
public void run(final TestResult result) { | |||||
@Override | |||||
public void run(final TestResult result) { | |||||
runner.run(cache.getNotifier(result)); | runner.run(cache.getNotifier(result)); | ||||
} | } | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
String testClassName = testClass.getName(); | String testClassName = testClass.getName(); | ||||
StringBuilder buf = new StringBuilder(testClassName.length() | StringBuilder buf = new StringBuilder(testClassName.length() | ||||
+ 12 * methodNames.length) | + 12 * methodNames.length) | ||||
@@ -144,7 +147,8 @@ public class JUnit4TestMethodAdapter implements Test { | |||||
this.methodNames = methodNames; | this.methodNames = methodNames; | ||||
} | } | ||||
public boolean shouldRun(Description description) { | |||||
@Override | |||||
public boolean shouldRun(Description description) { | |||||
if (methodNames.length == 0) { | if (methodNames.length == 0) { | ||||
return false; | 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); | StringBuilder buf = new StringBuilder(40); | ||||
if (methodNames.length == 0) { | if (methodNames.length == 0) { | ||||
buf.append("No methods"); | buf.append("No methods"); | ||||
@@ -364,7 +364,8 @@ public class JUnitTask extends Task { | |||||
* list the possible values | * list the possible values | ||||
* @return array of allowed values | * @return array of allowed values | ||||
*/ | */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {"true", "yes", "false", "no", | return new String[] {"true", "yes", "false", "no", | ||||
"on", "off", "withOutAndErr"}; | "on", "off", "withOutAndErr"}; | ||||
} | } | ||||
@@ -455,7 +456,8 @@ public class JUnitTask extends Task { | |||||
* @deprecated since ant 1.6 | * @deprecated since ant 1.6 | ||||
* @param sysp environment variable to add | * @param sysp environment variable to add | ||||
*/ | */ | ||||
public void addSysproperty(Environment.Variable sysp) { | |||||
@Deprecated | |||||
public void addSysproperty(Environment.Variable sysp) { | |||||
getCommandline().addSysproperty(sysp); | getCommandline().addSysproperty(sysp); | ||||
} | } | ||||
@@ -703,7 +705,7 @@ public class JUnitTask extends Task { | |||||
* Whether test listener events shall be generated. | * Whether test listener events shall be generated. | ||||
* | * | ||||
* <p>Defaults to false.</p> | * <p>Defaults to false.</p> | ||||
* | |||||
* | |||||
* <p>This value will be overridden by the magic property | * <p>This value will be overridden by the magic property | ||||
* ant.junit.enabletestlistenerevents if it has been set.</p> | * ant.junit.enabletestlistenerevents if it has been set.</p> | ||||
* | * | ||||
@@ -732,7 +734,8 @@ public class JUnitTask extends Task { | |||||
* | * | ||||
* @since Ant 1.4 | * @since Ant 1.4 | ||||
*/ | */ | ||||
public void init() { | |||||
@Override | |||||
public void init() { | |||||
antRuntimeClasses = new Path(getProject()); | antRuntimeClasses = new Path(getProject()); | ||||
splitJUnit = !addClasspathResource("/junit/framework/TestCase.class"); | splitJUnit = !addClasspathResource("/junit/framework/TestCase.class"); | ||||
addClasspathEntry("/org/apache/tools/ant/launch/AntMain.class"); | addClasspathEntry("/org/apache/tools/ant/launch/AntMain.class"); | ||||
@@ -779,7 +782,8 @@ public class JUnitTask extends Task { | |||||
path.add(extra); | path.add(extra); | ||||
} | } | ||||
mirrorLoader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { | mirrorLoader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { | ||||
public Object run() { | |||||
@Override | |||||
public Object run() { | |||||
return new SplitClassLoader(myLoader, path, getProject(), | return new SplitClassLoader(myLoader, path, getProject(), | ||||
new String[] { | new String[] { | ||||
"BriefJUnitResultFormatter", | "BriefJUnitResultFormatter", | ||||
@@ -812,7 +816,8 @@ public class JUnitTask extends Task { | |||||
* @throws BuildException in case of test failures or errors | * @throws BuildException in case of test failures or errors | ||||
* @since Ant 1.2 | * @since Ant 1.2 | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
checkMethodLists(); | checkMethodLists(); | ||||
setupJUnitDelegate(); | setupJUnitDelegate(); | ||||
@@ -866,7 +871,8 @@ public class JUnitTask extends Task { | |||||
this.id = id; | this.id = id; | ||||
} | } | ||||
public void run() { | |||||
@Override | |||||
public void run() { | |||||
try { | try { | ||||
masterTask.oneJunitThread(iterator, id); | masterTask.oneJunitThread(iterator, id); | ||||
} catch (BuildException b) { | } catch (BuildException b) { | ||||
@@ -877,7 +883,7 @@ public class JUnitTask extends Task { | |||||
private JUnitTask masterTask; | private JUnitTask masterTask; | ||||
private Iterator<List> iterator; | 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 | * @param output output coming from System.out | ||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
*/ | */ | ||||
protected void handleOutput(String output) { | |||||
@Override | |||||
protected void handleOutput(String output) { | |||||
if (output.startsWith(TESTLISTENER_PREFIX)) { | if (output.startsWith(TESTLISTENER_PREFIX)) { | ||||
log(output, Project.MSG_VERBOSE); | log(output, Project.MSG_VERBOSE); | ||||
} else if (runner != null) { | } else if (runner != null) { | ||||
@@ -1465,7 +1472,8 @@ public class JUnitTask extends Task { | |||||
* | * | ||||
* @since Ant 1.6 | * @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 { | throws IOException { | ||||
if (runner != null) { | if (runner != null) { | ||||
return runner.handleInput(buffer, offset, length); | return runner.handleInput(buffer, offset, length); | ||||
@@ -1482,7 +1490,8 @@ public class JUnitTask extends Task { | |||||
* @param output output coming from System.out | * @param output output coming from System.out | ||||
* @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
*/ | */ | ||||
protected void handleFlush(String output) { | |||||
@Override | |||||
protected void handleFlush(String output) { | |||||
if (runner != null) { | if (runner != null) { | ||||
runner.handleFlush(output); | runner.handleFlush(output); | ||||
if (showOutput) { | if (showOutput) { | ||||
@@ -1500,7 +1509,8 @@ public class JUnitTask extends Task { | |||||
* @param output output coming from System.err | * @param output output coming from System.err | ||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
*/ | */ | ||||
public void handleErrorOutput(String output) { | |||||
@Override | |||||
public void handleErrorOutput(String output) { | |||||
if (runner != null) { | if (runner != null) { | ||||
runner.handleErrorOutput(output); | runner.handleErrorOutput(output); | ||||
if (showOutput) { | if (showOutput) { | ||||
@@ -1519,7 +1529,8 @@ public class JUnitTask extends Task { | |||||
* @param output coming from System.err | * @param output coming from System.err | ||||
* @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
*/ | */ | ||||
public void handleErrorFlush(String output) { | |||||
@Override | |||||
public void handleErrorFlush(String output) { | |||||
if (runner != null) { | if (runner != null) { | ||||
runner.handleErrorFlush(output); | runner.handleErrorFlush(output); | ||||
if (showOutput) { | 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" | "Timeout occurred. Please note the time in the report does" | ||||
+ " not reflect the time until the timeout."; | + " not reflect the time until the timeout."; | ||||
@@ -1999,7 +2010,8 @@ public class JUnitTask extends Task { | |||||
* @param other | * @param other | ||||
* @return true if everything is equal | * @return true if everything is equal | ||||
*/ | */ | ||||
public boolean equals(Object other) { | |||||
@Override | |||||
public boolean equals(Object other) { | |||||
if (other == null | if (other == null | ||||
|| other.getClass() != ForkedTestConfiguration.class) { | || other.getClass() != ForkedTestConfiguration.class) { | ||||
return false; | return false; | ||||
@@ -2023,7 +2035,8 @@ public class JUnitTask extends Task { | |||||
* in the range 0-7. | * in the range 0-7. | ||||
* @return hash code value | * @return hash code value | ||||
*/ | */ | ||||
public int hashCode() { | |||||
@Override | |||||
public int hashCode() { | |||||
// CheckStyle:MagicNumber OFF | // CheckStyle:MagicNumber OFF | ||||
return (filterTrace ? 1 : 0) | return (filterTrace ? 1 : 0) | ||||
+ (haltOnError ? 2 : 0) | + (haltOnError ? 2 : 0) | ||||
@@ -2066,7 +2079,8 @@ public class JUnitTask extends Task { | |||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {ONCE, PER_TEST, PER_BATCH}; | return new String[] {ONCE, PER_TEST, PER_BATCH}; | ||||
} | } | ||||
} | } | ||||
@@ -2203,7 +2217,8 @@ public class JUnitTask extends Task { | |||||
* @param line the line to log. | * @param line the line to log. | ||||
* @param level the logging level to use. | * @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)) { | if (line.startsWith(TESTLISTENER_PREFIX)) { | ||||
task.log(line, Project.MSG_VERBOSE); | task.log(line, Project.MSG_VERBOSE); | ||||
} else { | } else { | ||||
@@ -55,7 +55,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||||
/** the names of test methods to execute */ | /** the names of test methods to execute */ | ||||
private String[] methods = null; | private String[] methods = null; | ||||
/** the name of the result file */ | /** the name of the result file */ | ||||
private String outfile = null; | private String outfile = null; | ||||
@@ -110,7 +110,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||||
*/ | */ | ||||
public JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, | public JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, | ||||
boolean filtertrace, String[] methods) { | 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 | * @since Ant 1.5 | ||||
* @return a clone of this test. | * @return a clone of this test. | ||||
*/ | */ | ||||
public Object clone() { | |||||
@Override | |||||
public Object clone() { | |||||
try { | try { | ||||
JUnitTest t = (JUnitTest) super.clone(); | JUnitTest t = (JUnitTest) super.clone(); | ||||
t.props = props == null ? null : (Properties) props.clone(); | t.props = props == null ? null : (Properties) props.clone(); | ||||
@@ -75,7 +75,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
/** | /** | ||||
* Holds the registered formatters. | * Holds the registered formatters. | ||||
*/ | */ | ||||
private Vector<JUnitTaskMirror.JUnitResultFormatterMirror> formatters = new Vector(); | |||||
private final Vector<JUnitTaskMirror.JUnitResultFormatterMirror> formatters = new Vector(); | |||||
/** | /** | ||||
* Collects TestResults. | * Collects TestResults. | ||||
@@ -138,7 +138,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
/** | /** | ||||
* The TestSuite we are currently running. | * The TestSuite we are currently running. | ||||
*/ | */ | ||||
private JUnitTest junitTest; | |||||
private final JUnitTest junitTest; | |||||
/** output written during the test */ | /** output written during the test */ | ||||
private PrintStream systemError; | private PrintStream systemError; | ||||
@@ -153,7 +153,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
private static boolean multipleTests = false; | private static boolean multipleTests = false; | ||||
/** ClassLoader passed in in non-forked mode. */ | /** ClassLoader passed in in non-forked mode. */ | ||||
private ClassLoader loader; | |||||
private final ClassLoader loader; | |||||
/** Do we print TestListener events? */ | /** Do we print TestListener events? */ | ||||
private boolean logTestListenerEvents = false; | private boolean logTestListenerEvents = false; | ||||
@@ -169,7 +169,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
/** Names of test methods to execute */ | /** Names of test methods to execute */ | ||||
private String[] methods = null; | private String[] methods = null; | ||||
/** | /** | ||||
* Constructor for fork=true or when the user hasn't specified a | * Constructor for fork=true or when the user hasn't specified a | ||||
* classpath. | * classpath. | ||||
@@ -178,8 +178,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param filtertrace whether to filter junit.*.* stack frames out of exceptions | * @param filtertrace whether to filter junit.*.* stack frames out of exceptions | ||||
* @param haltOnFailure whether to stop the run if failure is found. | * @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); | 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 haltOnFailure whether to stop the run if failure is found. | ||||
* @param showOutput whether to send output to System.out/.err as well as formatters. | * @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); | 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. | * @param logTestListenerEvents whether to print TestListener events. | ||||
* @since Ant 1.7 | * @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, | this(test, null, haltOnError, filtertrace, haltOnFailure, showOutput, | ||||
logTestListenerEvents, null); | logTestListenerEvents, null); | ||||
} | } | ||||
@@ -228,9 +228,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param logTestListenerEvents whether to print TestListener events. | * @param logTestListenerEvents whether to print TestListener events. | ||||
* @since 1.8.2 | * @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, | this(test, methods, haltOnError, filtertrace, haltOnFailure, showOutput, | ||||
logTestListenerEvents, null); | 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 haltOnFailure whether to stop the run if failure is found. | ||||
* @param loader the classloader to use running the test. | * @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); | 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 showOutput whether to send output to System.out/.err as well as formatters. | ||||
* @param loader the classloader to use running the test. | * @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, | this(test, haltOnError, filtertrace, haltOnFailure, showOutput, | ||||
false, loader); | false, loader); | ||||
} | } | ||||
@@ -276,11 +276,11 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param loader the classloader to use running the test. | * @param loader the classloader to use running the test. | ||||
* @since Ant 1.7 | * @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); | logTestListenerEvents, loader); | ||||
} | } | ||||
@@ -289,10 +289,10 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* Constructor to use when the user has specified a classpath. | * Constructor to use when the user has specified a classpath. | ||||
* @since 1.8.2 | * @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(); | super(); | ||||
JUnitTestRunner.filtertrace = filtertrace; // TODO clumsy, should use instance field somehow | JUnitTestRunner.filtertrace = filtertrace; // TODO clumsy, should use instance field somehow | ||||
this.junitTest = test; | this.junitTest = test; | ||||
@@ -310,17 +310,18 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
private PrintStream createEmptyStream() { | private PrintStream createEmptyStream() { | ||||
return new PrintStream( | return new PrintStream( | ||||
new OutputStream() { | 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)); | 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); | systemOut = new PrintStream(o); | ||||
systemError = new PrintStream(e); | systemError = new PrintStream(e); | ||||
@@ -354,7 +355,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
/** | /** | ||||
* Run the test. | * Run the test. | ||||
*/ | */ | ||||
public void run() { | |||||
@Override | |||||
public void run() { | |||||
res = new IgnoredTestResult(); | res = new IgnoredTestResult(); | ||||
res.addListener(wrapListener(this)); | res.addListener(wrapListener(this)); | ||||
final int size = formatters.size(); | final int size = formatters.size(); | ||||
@@ -362,8 +364,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
res.addListener(wrapListener((TestListener) formatters.elementAt(i))); | 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); | setupIOStreams(outStrm, errStrm); | ||||
@@ -391,7 +393,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
try { | try { | ||||
// check if there is a suite method | // check if there is a suite method | ||||
suiteMethod = testClass.getMethod("suite", new Class[0]); | suiteMethod = testClass.getMethod("suite", new Class[0]); | ||||
} catch (NoSuchMethodException e) { | |||||
} catch (final NoSuchMethodException e) { | |||||
// no appropriate suite method found. We don't report any | // no appropriate suite method found. We don't report any | ||||
// error here since it might be perfectly normal. | // error here since it might be perfectly normal. | ||||
} | } | ||||
@@ -461,14 +463,14 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
useSingleMethodAdapter = true; | useSingleMethodAdapter = true; | ||||
} | } | ||||
} | } | ||||
} catch (ClassNotFoundException e) { | |||||
} catch (final ClassNotFoundException e) { | |||||
// OK, fall back to JUnit 3. | // OK, fall back to JUnit 3. | ||||
} | } | ||||
} | } | ||||
junit4 = junit4TestAdapterClass != null; | junit4 = junit4TestAdapterClass != null; | ||||
if (junitTest.isSkipNonTests()) { | if (junitTest.isSkipNonTests()) { | ||||
if (!containsTests( testClass, junit4)) { | |||||
if (!containsTests(testClass, junit4)) { | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
@@ -500,7 +502,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} else if (methods.length == 1) { | } else if (methods.length == 1) { | ||||
suite = TestSuite.createTest(testClass, methods[0]); | suite = TestSuite.createTest(testClass, methods[0]); | ||||
} else { | } else { | ||||
TestSuite testSuite = new TestSuite(testClass.getName()); | |||||
final TestSuite testSuite = new TestSuite(testClass.getName()); | |||||
for (int i = 0; i < methods.length; i++) { | for (int i = 0; i < methods.length; i++) { | ||||
testSuite.addTest( | testSuite.addTest( | ||||
TestSuite.createTest(testClass, methods[i])); | 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; | retCode = ERRORS; | ||||
exception = e; | exception = e; | ||||
} | } | ||||
long start = System.currentTimeMillis(); | |||||
final long start = System.currentTimeMillis(); | |||||
fireStartTestSuite(); | fireStartTestSuite(); | ||||
startTestSuiteSuccess = true; | startTestSuiteSuccess = true; | ||||
@@ -535,7 +537,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} finally { | } finally { | ||||
if (junit4 || | if (junit4 || | ||||
suite.getClass().getName().equals(JUNIT_4_TEST_ADAPTER)) { | 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()); | junitTest.setCounts(res.runCount() + res.ignoredCount(), cnts[0], cnts[1], res.ignoredCount() + res.skippedCount()); | ||||
} else { | } else { | ||||
junitTest.setCounts(res.runCount() + res.ignoredCount(), res.failureCount(), | junitTest.setCounts(res.runCount() + res.ignoredCount(), res.failureCount(), | ||||
@@ -563,12 +565,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
String out, err; | String out, err; | ||||
try { | try { | ||||
out = new String(outStrm.toByteArray()); | out = new String(outStrm.toByteArray()); | ||||
} catch (OutOfMemoryError ex) { | |||||
} catch (final OutOfMemoryError ex) { | |||||
out = "out of memory on output stream"; | out = "out of memory on output stream"; | ||||
} | } | ||||
try { | try { | ||||
err = new String(errStrm.toByteArray()); | err = new String(errStrm.toByteArray()); | ||||
} catch (OutOfMemoryError ex) { | |||||
} catch (final OutOfMemoryError ex) { | |||||
err = "out of memory on error stream"; | err = "out of memory on error stream"; | ||||
} | } | ||||
sendOutAndErr(out, err); | 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 testAnnotation = null; | ||||
Class suiteAnnotation = null; | Class suiteAnnotation = null; | ||||
Class runWithAnnotation = null; | Class runWithAnnotation = null; | ||||
try { | try { | ||||
testAnnotation = Class.forName("org.junit.Test"); | testAnnotation = Class.forName("org.junit.Test"); | ||||
} catch (ClassNotFoundException e) { | |||||
} catch (final ClassNotFoundException e) { | |||||
if (isJUnit4) { | if (isJUnit4) { | ||||
// odd - we think we're JUnit4 but don't support the test annotation. We therefore can't have any tests! | // odd - we think we're JUnit4 but don't support the test annotation. We therefore can't have any tests! | ||||
return false; | return false; | ||||
@@ -601,12 +603,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
try { | try { | ||||
suiteAnnotation = Class.forName("org.junit.Suite.SuiteClasses"); | 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 | // ignore - we don't have this annotation so make sure we don't check for it | ||||
} | } | ||||
try { | try { | ||||
runWithAnnotation = Class.forName("org.junit.runner.RunWith"); | 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 | // 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 | // 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)) { | if (containsTests(innerClass, isJUnit4) || containsTests(innerClass, !isJUnit4)) { | ||||
return true; | 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) { | if (isJUnit4) { | ||||
// check if suspected JUnit4 classes have methods with @Test annotation | // check if suspected JUnit4 classes have methods with @Test annotation | ||||
if (m.getAnnotation(testAnnotation) != null) { | 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. | * @return 2 if errors occurred, 1 if tests failed else 0. | ||||
*/ | */ | ||||
public int getRetCode() { | |||||
@Override | |||||
public int getRetCode() { | |||||
return retCode; | return retCode; | ||||
} | } | ||||
@@ -686,8 +689,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* <p>A new Test is started. | * <p>A new Test is started. | ||||
* @param t the test. | * @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 + ")"); | logTestListenerEvent("startTest(" + testName + ")"); | ||||
} | } | ||||
@@ -697,19 +701,20 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* <p>A Test is finished. | * <p>A Test is finished. | ||||
* @param test the test. | * @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 + ")"); | logTestListenerEvent("endTest(" + testName + ")"); | ||||
} | } | ||||
private void logTestListenerEvent(String msg) { | private void logTestListenerEvent(String msg) { | ||||
if (logTestListenerEvents) { | if (logTestListenerEvents) { | ||||
PrintStream out = savedOut != null ? savedOut : System.out; | |||||
final PrintStream out = savedOut != null ? savedOut : System.out; | |||||
out.flush(); | out.flush(); | ||||
if (msg == null) { | if (msg == null) { | ||||
msg = "null"; | msg = "null"; | ||||
} | } | ||||
StringTokenizer msgLines = new StringTokenizer(msg, "\r\n", false); | |||||
final StringTokenizer msgLines = new StringTokenizer(msg, "\r\n", false); | |||||
while (msgLines.hasMoreTokens()) { | while (msgLines.hasMoreTokens()) { | ||||
out.println(JUnitTask.TESTLISTENER_PREFIX | out.println(JUnitTask.TESTLISTENER_PREFIX | ||||
+ msgLines.nextToken()); | + msgLines.nextToken()); | ||||
@@ -725,8 +730,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param test the test. | * @param test the test. | ||||
* @param t the exception thrown by 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() + ")"); | logTestListenerEvent("addFailure(" + testName + ", " + t.getMessage() + ")"); | ||||
if (haltOnFailure) { | if (haltOnFailure) { | ||||
res.stop(); | res.stop(); | ||||
@@ -740,7 +745,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param test the test. | * @param test the test. | ||||
* @param t the assertion thrown by 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); | addFailure(test, (Throwable) t); | ||||
} | } | ||||
@@ -751,8 +757,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param test the test. | * @param test the test. | ||||
* @param t the error thrown by 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() + ")"); | logTestListenerEvent("addError(" + testName + ", " + t.getMessage() + ")"); | ||||
if (haltOnError) { | if (haltOnError) { | ||||
res.stop(); | res.stop(); | ||||
@@ -764,7 +771,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
* @param permissions the permissions to use. | * @param permissions the permissions to use. | ||||
*/ | */ | ||||
public void setPermissions(Permissions permissions) { | |||||
@Override | |||||
public void setPermissions(final Permissions permissions) { | |||||
perm = permissions; | perm = permissions; | ||||
} | } | ||||
@@ -772,7 +780,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* Handle a string destined for standard output. | * Handle a string destined for standard output. | ||||
* @param output the string to 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)) { | if (!logTestListenerEvents && output.startsWith(JUnitTask.TESTLISTENER_PREFIX)) { | ||||
// ignore | // ignore | ||||
} else if (systemOut != null) { | } else if (systemOut != null) { | ||||
@@ -791,36 +800,40 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* | * | ||||
* @since Ant 1.6 | * @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 { | throws IOException { | ||||
return -1; | return -1; | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public void handleErrorOutput(String output) { | |||||
@Override | |||||
public void handleErrorOutput(final String output) { | |||||
if (systemError != null) { | if (systemError != null) { | ||||
systemError.print(output); | systemError.print(output); | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public void handleFlush(String output) { | |||||
@Override | |||||
public void handleFlush(final String output) { | |||||
if (systemOut != null) { | if (systemOut != null) { | ||||
systemOut.print(output); | systemOut.print(output); | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public void handleErrorFlush(String output) { | |||||
@Override | |||||
public void handleErrorFlush(final String output) { | |||||
if (systemError != null) { | if (systemError != null) { | ||||
systemError.print(output); | systemError.print(output); | ||||
} | } | ||||
} | } | ||||
private void sendOutAndErr(String out, String err) { | |||||
private void sendOutAndErr(final String out, final String err) { | |||||
final int size = formatters.size(); | final int size = formatters.size(); | ||||
for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | ||||
JUnitResultFormatter formatter = | |||||
final JUnitResultFormatter formatter = | |||||
((JUnitResultFormatter) formatters.elementAt(i)); | ((JUnitResultFormatter) formatters.elementAt(i)); | ||||
formatter.setSystemOutput(out); | formatter.setSystemOutput(out); | ||||
@@ -848,12 +861,13 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* Add a formatter. | * Add a formatter. | ||||
* @param f the formatter to add. | * @param f the formatter to add. | ||||
*/ | */ | ||||
public void addFormatter(JUnitResultFormatter f) { | |||||
public void addFormatter(final JUnitResultFormatter f) { | |||||
formatters.addElement(f); | formatters.addElement(f); | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public void addFormatter(JUnitTaskMirror.JUnitResultFormatterMirror f) { | |||||
@Override | |||||
public void addFormatter(final JUnitTaskMirror.JUnitResultFormatterMirror f) { | |||||
formatters.addElement(f); | formatters.addElement(f); | ||||
} | } | ||||
@@ -890,12 +904,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param args the command line arguments. | * @param args the command line arguments. | ||||
* @throws IOException on error. | * @throws IOException on error. | ||||
*/ | */ | ||||
public static void main(String[] args) throws IOException { | |||||
public static void main(final String[] args) throws IOException { | |||||
String[] methods = null; | String[] methods = null; | ||||
boolean haltError = false; | boolean haltError = false; | ||||
boolean haltFail = false; | boolean haltFail = false; | ||||
boolean stackfilter = true; | boolean stackfilter = true; | ||||
Properties props = new Properties(); | |||||
final Properties props = new Properties(); | |||||
boolean showOut = false; | boolean showOut = false; | ||||
boolean outputToFormat = true; | boolean outputToFormat = true; | ||||
boolean logFailedTests = true; | boolean logFailedTests = true; | ||||
@@ -916,9 +930,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
for (int i = 1; i < args.length; i++) { | for (int i = 1; i < args.length; i++) { | ||||
if (args[i].startsWith(Constants.METHOD_NAMES)) { | if (args[i].startsWith(Constants.METHOD_NAMES)) { | ||||
try { | try { | ||||
String methodsList = args[i].substring(Constants.METHOD_NAMES.length()); | |||||
final String methodsList = args[i].substring(Constants.METHOD_NAMES.length()); | |||||
methods = JUnitTest.parseTestMethodNamesList(methodsList); | methods = JUnitTest.parseTestMethodNamesList(methodsList); | ||||
} catch (IllegalArgumentException ex) { | |||||
} catch (final IllegalArgumentException ex) { | |||||
System.err.println("Invalid specification of test method names: " + args[i]); | System.err.println("Invalid specification of test method names: " + args[i]); | ||||
System.exit(ERRORS); | System.exit(ERRORS); | ||||
} | } | ||||
@@ -934,12 +948,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} else if (args[i].startsWith(Constants.FORMATTER)) { | } else if (args[i].startsWith(Constants.FORMATTER)) { | ||||
try { | try { | ||||
createAndStoreFormatter(args[i].substring(Constants.FORMATTER.length())); | createAndStoreFormatter(args[i].substring(Constants.FORMATTER.length())); | ||||
} catch (BuildException be) { | |||||
} catch (final BuildException be) { | |||||
System.err.println(be.getMessage()); | System.err.println(be.getMessage()); | ||||
System.exit(ERRORS); | System.exit(ERRORS); | ||||
} | } | ||||
} else if (args[i].startsWith(Constants.PROPSFILE)) { | } else if (args[i].startsWith(Constants.PROPSFILE)) { | ||||
FileInputStream in = new FileInputStream(args[i] | |||||
final FileInputStream in = new FileInputStream(args[i] | |||||
.substring(Constants.PROPSFILE.length())); | .substring(Constants.PROPSFILE.length())); | ||||
props.load(in); | props.load(in); | ||||
in.close(); | in.close(); | ||||
@@ -958,21 +972,21 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
skipNonTests = Project.toBoolean( | skipNonTests = Project.toBoolean( | ||||
args[i].substring(Constants.SKIP_NON_TESTS.length())); | args[i].substring(Constants.SKIP_NON_TESTS.length())); | ||||
} else if (args[i].startsWith(Constants.THREADID)) { | } 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 | // 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)); | props.put(key, p.get(key)); | ||||
} | } | ||||
int returnCode = SUCCESS; | int returnCode = SUCCESS; | ||||
if (multipleTests) { | if (multipleTests) { | ||||
try { | try { | ||||
java.io.BufferedReader reader = | |||||
final java.io.BufferedReader reader = | |||||
new java.io.BufferedReader(new java.io.FileReader(args[0])); | new java.io.BufferedReader(new java.io.FileReader(args[0])); | ||||
String testCaseName; | String testCaseName; | ||||
String[] testMethodNames; | String[] testMethodNames; | ||||
@@ -981,9 +995,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
boolean failureOccurred = false; | boolean failureOccurred = false; | ||||
String line = null; | String line = null; | ||||
while ((line = reader.readLine()) != 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) { | if (colonIndex == -1) { | ||||
testCaseName = testListSpec; | testCaseName = testListSpec; | ||||
testMethodNames = null; | testMethodNames = null; | ||||
@@ -994,7 +1008,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
.substring(colonIndex + 1) | .substring(colonIndex + 1) | ||||
.replace('+', ',')); | .replace('+', ',')); | ||||
} | } | ||||
JUnitTest t = new JUnitTest(testCaseName); | |||||
final JUnitTest t = new JUnitTest(testCaseName); | |||||
t.setTodir(new File(st.nextToken())); | t.setTodir(new File(st.nextToken())); | ||||
t.setOutfile(st.nextToken()); | t.setOutfile(st.nextToken()); | ||||
t.setProperties(props); | t.setProperties(props); | ||||
@@ -1021,11 +1035,11 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} catch (IOException e) { | |||||
} catch (final IOException e) { | |||||
e.printStackTrace(); | e.printStackTrace(); | ||||
} | } | ||||
} else { | } else { | ||||
JUnitTest t = new JUnitTest(args[0]); | |||||
final JUnitTest t = new JUnitTest(args[0]); | |||||
t.setThread(antThreadID); | t.setThread(antThreadID); | ||||
t.setProperties(props); | t.setProperties(props); | ||||
t.setSkipNonTests(skipNonTests); | t.setSkipNonTests(skipNonTests); | ||||
@@ -1040,43 +1054,52 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
private static Vector fromCmdLine = new Vector(); | 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() { | 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)); | registerTestCase(JUnitVersionHelper.getTestCaseName(arg0)); | ||||
} | } | ||||
}); | }); | ||||
final int size = fromCmdLine.size(); | final int size = fromCmdLine.size(); | ||||
for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | ||||
FormatterElement fe = (FormatterElement) fromCmdLine.elementAt(i); | |||||
final FormatterElement fe = (FormatterElement) fromCmdLine.elementAt(i); | |||||
if (multipleTests && fe.getUseFile()) { | if (multipleTests && fe.getUseFile()) { | ||||
File destFile = | |||||
final File destFile = | |||||
new File(test.getTodir(), | new File(test.getTodir(), | ||||
test.getOutfile() + fe.getExtension()); | test.getOutfile() + fe.getExtension()); | ||||
fe.setOutfile(destFile); | fe.setOutfile(destFile); | ||||
@@ -1088,10 +1111,10 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
/** | /** | ||||
* Line format is: formatter=<classname>(,<pathname>)? | * Line format is: formatter=<classname>(,<pathname>)? | ||||
*/ | */ | ||||
private static void createAndStoreFormatter(String line) | |||||
private static void createAndStoreFormatter(final String line) | |||||
throws BuildException { | throws BuildException { | ||||
FormatterElement fe = new FormatterElement(); | |||||
int pos = line.indexOf(','); | |||||
final FormatterElement fe = new FormatterElement(); | |||||
final int pos = line.indexOf(','); | |||||
if (pos == -1) { | if (pos == -1) { | ||||
fe.setClassname(line); | fe.setClassname(line); | ||||
fe.setUseFile(false); | fe.setUseFile(false); | ||||
@@ -1101,7 +1124,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
if (!multipleTests) { | if (!multipleTests) { | ||||
fe.setOutfile(new File(line.substring(pos + 1))); | fe.setOutfile(new File(line.substring(pos + 1))); | ||||
} else { | } else { | ||||
int fName = line.indexOf(IGNORED_FILE_NAME); | |||||
final int fName = line.indexOf(IGNORED_FILE_NAME); | |||||
if (fName > -1) { | if (fName > -1) { | ||||
fe.setExtension(line | fe.setExtension(line | ||||
.substring(fName | .substring(fName | ||||
@@ -1118,8 +1141,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param t the exception to filter. | * @param t the exception to filter. | ||||
* @return the filtered stack trace. | * @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); | return JUnitTestRunner.filterStack(trace); | ||||
} | } | ||||
@@ -1128,14 +1151,14 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param stack the stack trace to filter. | * @param stack the stack trace to filter. | ||||
* @return the filtered stack. | * @return the filtered stack. | ||||
*/ | */ | ||||
public static String filterStack(String stack) { | |||||
public static String filterStack(final String stack) { | |||||
if (!filtertrace) { | if (!filtertrace) { | ||||
return stack; | 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; | String line; | ||||
try { | try { | ||||
@@ -1147,7 +1170,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} | } | ||||
firstLine = false; | firstLine = false; | ||||
} | } | ||||
} catch (Exception e) { | |||||
} catch (final Exception e) { | |||||
return stack; // return the stack unfiltered | return stack; // return the stack unfiltered | ||||
} finally { | } finally { | ||||
FileUtils.close(pw); | FileUtils.close(pw); | ||||
@@ -1155,7 +1178,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
return sw.toString(); | 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++) { | for (int i = 0; i < DEFAULT_TRACE_FILTERS.length; i++) { | ||||
if (line.indexOf(DEFAULT_TRACE_FILTERS[i]) != -1) { | if (line.indexOf(DEFAULT_TRACE_FILTERS[i]) != -1) { | ||||
return true; | return true; | ||||
@@ -1167,11 +1190,11 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
/** | /** | ||||
* @since Ant 1.6.2 | * @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, | new JUnitTestRunner(t, methods, haltError, stackfilter, haltFail, showOut, | ||||
logTestListenerEvents, null); | logTestListenerEvents, null); | ||||
runner.forked = true; | 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) { | if (crashFile != null) { | ||||
try { | try { | ||||
FileWriter out = null; | FileWriter out = null; | ||||
@@ -1210,7 +1233,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} finally { | } finally { | ||||
FileUtils.close(out); | FileUtils.close(out); | ||||
} | } | ||||
} catch (IOException e) { | |||||
} catch (final IOException e) { | |||||
// ignored. | // ignored. | ||||
} | } | ||||
} | } | ||||
@@ -1224,7 +1247,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
*/ | */ | ||||
private TestListenerWrapper wrapListener(final TestListener testListener) { | private TestListenerWrapper wrapListener(final TestListener testListener) { | ||||
return new TestListenerWrapper(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) { | if (junit4 && t instanceof AssertionFailedError) { | ||||
// JUnit 4 does not distinguish between errors and failures | // JUnit 4 does not distinguish between errors and failures | ||||
// even in the JUnit 3 adapter. | // 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". | // JUnit 4-specific test GUIs will show just "failures". | ||||
// But Ant's output shows "failures" vs. "errors". | // But Ant's output shows "failures" vs. "errors". | ||||
// We would prefer to show "failure" for things that logically are. | // 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(); | ? new AssertionFailedError(msg) : new AssertionFailedError(); | ||||
failure.setStackTrace(t.getStackTrace()); | failure.setStackTrace(t.getStackTrace()); | ||||
testListener.addFailure(test, failure); | testListener.addFailure(test, failure); | ||||
@@ -1244,20 +1268,23 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
testListener.addError(test, t); | 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); | 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) { | if (t instanceof AssertionFailedError) { | ||||
testListener.addFailure(test, (AssertionFailedError) t); | testListener.addFailure(test, (AssertionFailedError) t); | ||||
} else { | } else { | ||||
testListener.addError(test, t); | testListener.addError(test, t); | ||||
} | } | ||||
} | } | ||||
public void endTest(Test test) { | |||||
@Override | |||||
public void endTest(final Test test) { | |||||
testListener.endTest(test); | testListener.endTest(test); | ||||
} | } | ||||
public void startTest(Test test) { | |||||
@Override | |||||
public void startTest(final Test test) { | |||||
testListener.startTest(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 the adapter claims that all failures are errors. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
private int[] findJUnit4FailureErrorCount(TestResult result) { | |||||
private int[] findJUnit4FailureErrorCount(final TestResult result) { | |||||
int failures = 0; | int failures = 0; | ||||
int errors = 0; | int errors = 0; | ||||
Enumeration e = result.failures(); | Enumeration e = result.failures(); | ||||
@@ -1278,7 +1305,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} | } | ||||
e = result.errors(); | e = result.errors(); | ||||
while (e.hasMoreElements()) { | while (e.hasMoreElements()) { | ||||
Throwable t = ((TestFailure) e.nextElement()).thrownException(); | |||||
final Throwable t = ((TestFailure) e.nextElement()).thrownException(); | |||||
if (t instanceof AssertionFailedError | if (t instanceof AssertionFailedError | ||||
|| t instanceof AssertionError) { | || t instanceof AssertionError) { | ||||
failures++; | failures++; | ||||
@@ -43,7 +43,8 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { | |||||
* Records the suite's name to later determine the class to invoke | * Records the suite's name to later determine the class to invoke | ||||
* tearDown on. | * tearDown on. | ||||
*/ | */ | ||||
public void startTestSuite(final JUnitTest suite) { | |||||
@Override | |||||
public void startTestSuite(final JUnitTest suite) { | |||||
suiteName = suite.getName(); | suiteName = suite.getName(); | ||||
if (suiteName != null && | if (suiteName != null && | ||||
suiteName.endsWith(JUnitTask.NAME_OF_DUMMY_TEST)) { | 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 | * test we get when a Batch fails and the error is an actual | ||||
* error generated by Ant. | * 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 | if (suiteName != null | ||||
&& fakeTest instanceof JUnitTaskMirrorImpl.VmExitErrorTest) { | && fakeTest instanceof JUnitTaskMirrorImpl.VmExitErrorTest) { | ||||
tearDown(); | tearDown(); | ||||
@@ -67,19 +69,26 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { | |||||
// no need to implement the rest | // no need to implement the rest | ||||
public void addFailure(Test test, Throwable t) {} | 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() { | private void tearDown() { | ||||
try { | try { | ||||
@@ -76,7 +76,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
private Element rootElement; | private Element rootElement; | ||||
/** | /** | ||||
* Element for the current test. | * Element for the current test. | ||||
* | |||||
* | |||||
* The keying of this map is a bit of a hack: tests are keyed by caseName(className) since | * 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, | * 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 | * 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}. */ | /** {@inheritDoc}. */ | ||||
public void setOutput(OutputStream out) { | |||||
@Override | |||||
public void setOutput(OutputStream out) { | |||||
this.out = out; | this.out = out; | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public void setSystemOutput(String out) { | |||||
@Override | |||||
public void setSystemOutput(String out) { | |||||
formatOutput(SYSTEM_OUT, out); | formatOutput(SYSTEM_OUT, out); | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public void setSystemError(String out) { | |||||
@Override | |||||
public void setSystemError(String out) { | |||||
formatOutput(SYSTEM_ERR, out); | formatOutput(SYSTEM_ERR, out); | ||||
} | } | ||||
@@ -127,7 +130,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* The whole testsuite started. | * The whole testsuite started. | ||||
* @param suite the testsuite. | * @param suite the testsuite. | ||||
*/ | */ | ||||
public void startTestSuite(JUnitTest suite) { | |||||
@Override | |||||
public void startTestSuite(JUnitTest suite) { | |||||
doc = getDocumentBuilder().newDocument(); | doc = getDocumentBuilder().newDocument(); | ||||
rootElement = doc.createElement(TESTSUITE); | rootElement = doc.createElement(TESTSUITE); | ||||
String n = suite.getName(); | String n = suite.getName(); | ||||
@@ -178,7 +182,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* @param suite the testsuite. | * @param suite the testsuite. | ||||
* @throws BuildException on error. | * @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_TESTS, "" + suite.runCount()); | ||||
rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); | rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); | ||||
rootElement.setAttribute(ATTR_ERRORS, "" + suite.errorCount()); | rootElement.setAttribute(ATTR_ERRORS, "" + suite.errorCount()); | ||||
@@ -214,7 +219,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* <p>A new Test is started. | * <p>A new Test is started. | ||||
* @param t the test. | * @param t the test. | ||||
*/ | */ | ||||
public void startTest(Test t) { | |||||
@Override | |||||
public void startTest(Test t) { | |||||
testStarts.put(createDescription(t), System.currentTimeMillis()); | testStarts.put(createDescription(t), System.currentTimeMillis()); | ||||
} | } | ||||
@@ -228,7 +234,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* <p>A Test is finished. | * <p>A Test is finished. | ||||
* @param test the test. | * @param test the test. | ||||
*/ | */ | ||||
public void endTest(Test test) { | |||||
@Override | |||||
public void endTest(Test test) { | |||||
String testDescription = createDescription(test); | String testDescription = createDescription(test); | ||||
// Fix for bug #5637 - if a junit.extensions.TestSetup is | // 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 test the test. | ||||
* @param t the assertion. | * @param t the assertion. | ||||
*/ | */ | ||||
public void addFailure(Test test, AssertionFailedError t) { | |||||
@Override | |||||
public void addFailure(Test test, AssertionFailedError t) { | |||||
addFailure(test, (Throwable) t); | addFailure(test, (Throwable) t); | ||||
} | } | ||||
@@ -287,7 +295,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* @param test the test. | * @param test the test. | ||||
* @param t the error. | * @param t the error. | ||||
*/ | */ | ||||
public void addError(Test test, Throwable t) { | |||||
@Override | |||||
public void addError(Test test, Throwable t) { | |||||
formatError(ERROR, test, t); | formatError(ERROR, test, t); | ||||
} | } | ||||
@@ -324,7 +333,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
nested.appendChild(doc.createCDATASection(output)); | nested.appendChild(doc.createCDATASection(output)); | ||||
} | } | ||||
public void testIgnored(Test test) { | |||||
@Override | |||||
public void testIgnored(Test test) { | |||||
formatSkip(test, JUnitVersionHelper.getIgnoreMessage(test)); | formatSkip(test, JUnitVersionHelper.getIgnoreMessage(test)); | ||||
if (test != null) { | if (test != null) { | ||||
ignoredTests.put(createDescription(test), test); | 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()); | formatSkip(test, failure.getMessage()); | ||||
skippedTests.put(createDescription(test), test); | skippedTests.put(createDescription(test), test); | ||||
@@ -20,6 +20,5 @@ package org.apache.tools.ant.taskdefs.optional.net; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
public interface FTPTaskMirror { | 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. | * @deprecated since 1.5.x. | ||||
* Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | * Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | ||||
*/ | */ | ||||
public void setUseproxy(boolean useProxy) { | |||||
@Deprecated | |||||
public void setUseproxy(boolean useProxy) { | |||||
this.useProxy = useProxy; | this.useProxy = useProxy; | ||||
} | } | ||||
@@ -81,7 +82,8 @@ public class SplashTask extends Task { | |||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | * Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | ||||
*/ | */ | ||||
public void setProxy(String proxy) { | |||||
@Deprecated | |||||
public void setProxy(String proxy) { | |||||
this.proxy = proxy; | this.proxy = proxy; | ||||
} | } | ||||
@@ -91,7 +93,8 @@ public class SplashTask extends Task { | |||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | * Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | ||||
*/ | */ | ||||
public void setPort(String port) { | |||||
@Deprecated | |||||
public void setPort(String port) { | |||||
this.port = port; | this.port = port; | ||||
} | } | ||||
@@ -101,7 +104,8 @@ public class SplashTask extends Task { | |||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | * Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | ||||
*/ | */ | ||||
public void setUser(String user) { | |||||
@Deprecated | |||||
public void setUser(String user) { | |||||
this.user = user; | this.user = user; | ||||
} | } | ||||
@@ -111,7 +115,8 @@ public class SplashTask extends Task { | |||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | * Use org.apache.tools.ant.taskdefs.optional.net.SetProxy | ||||
*/ | */ | ||||
public void setPassword(String password) { | |||||
@Deprecated | |||||
public void setPassword(String password) { | |||||
this.password = password; | this.password = password; | ||||
} | } | ||||
@@ -140,7 +145,7 @@ public class SplashTask extends Task { | |||||
/** | /** | ||||
* Sets the display text presented in the splash window. | * 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 | * @param displayText the display text presented the splash window | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
@@ -152,7 +157,8 @@ public class SplashTask extends Task { | |||||
* Execute the task. | * Execute the task. | ||||
* @throws BuildException on error | * @throws BuildException on error | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
if (splash != null) { | if (splash != null) { | ||||
splash.setVisible(false); | splash.setVisible(false); | ||||
getProject().removeBuildListener(splash); | getProject().removeBuildListener(splash); | ||||
@@ -119,13 +119,12 @@ public class Directory { | |||||
* @return the child directory, or null if not found | * @return the child directory, or null if not found | ||||
*/ | */ | ||||
public Directory getChild(File dir) { | public Directory getChild(File dir) { | ||||
for (Iterator i = childDirectories.iterator(); i.hasNext(); ) { | |||||
for (Iterator i = childDirectories.iterator(); i.hasNext();) { | |||||
Directory current = (Directory) i.next(); | Directory current = (Directory) i.next(); | ||||
if (current.getDirectory().equals(dir)) { | if (current.getDirectory().equals(dir)) { | ||||
return current; | return current; | ||||
} | } | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
@@ -135,7 +134,8 @@ public class Directory { | |||||
* @param obj the object to compare to | * @param obj the object to compare to | ||||
* @return true if this object has an equal directory field as the other object | * @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) { | if (obj == this) { | ||||
return true; | return true; | ||||
} | } | ||||
@@ -153,7 +153,8 @@ public class Directory { | |||||
* The hashcode method. | * The hashcode method. | ||||
* @return the hash code of the directory field | * @return the hash code of the directory field | ||||
*/ | */ | ||||
public int hashCode() { | |||||
@Override | |||||
public int hashCode() { | |||||
return directory.hashCode(); | return directory.hashCode(); | ||||
} | } | ||||
@@ -100,7 +100,7 @@ public class SSHExec extends SSHBase { | |||||
* | * | ||||
* @param command The new command value | * @param command The new command value | ||||
*/ | */ | ||||
public void setCommand(String command) { | |||||
public void setCommand(final String command) { | |||||
this.command = command; | this.command = command; | ||||
} | } | ||||
@@ -109,7 +109,7 @@ public class SSHExec extends SSHBase { | |||||
* @param f the value to use. | * @param f the value to use. | ||||
* @since Ant 1.7.1 | * @since Ant 1.7.1 | ||||
*/ | */ | ||||
public void setCommandResource(String f) { | |||||
public void setCommandResource(final String f) { | |||||
this.commandResource = new FileResource(new File(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 | * @param timeout The new timeout value in seconds | ||||
*/ | */ | ||||
public void setTimeout(long timeout) { | |||||
public void setTimeout(final long timeout) { | |||||
maxwait = timeout; | maxwait = timeout; | ||||
} | } | ||||
@@ -129,7 +129,7 @@ public class SSHExec extends SSHBase { | |||||
* | * | ||||
* @param output The file to write to. | * @param output The file to write to. | ||||
*/ | */ | ||||
public void setOutput(File output) { | |||||
public void setOutput(final File output) { | |||||
outputFile = output; | outputFile = output; | ||||
} | } | ||||
@@ -139,7 +139,7 @@ public class SSHExec extends SSHBase { | |||||
* @param output The file to write to. | * @param output The file to write to. | ||||
* @since Apache Ant 1.9.4 | * @since Apache Ant 1.9.4 | ||||
*/ | */ | ||||
public void setErrorOutput(File output) { | |||||
public void setErrorOutput(final File output) { | |||||
errorFile = output; | errorFile = output; | ||||
} | } | ||||
@@ -150,7 +150,7 @@ public class SSHExec extends SSHBase { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setInput(File input) { | |||||
public void setInput(final File input) { | |||||
inputFile = input; | inputFile = input; | ||||
} | } | ||||
@@ -162,7 +162,7 @@ public class SSHExec extends SSHBase { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setInputProperty(String inputProperty) { | |||||
public void setInputProperty(final String inputProperty) { | |||||
this.inputProperty = inputProperty; | this.inputProperty = inputProperty; | ||||
} | } | ||||
@@ -173,7 +173,7 @@ public class SSHExec extends SSHBase { | |||||
* | * | ||||
* @since Ant 1.8.3 | * @since Ant 1.8.3 | ||||
*/ | */ | ||||
public void setInputString(String inputString) { | |||||
public void setInputString(final String inputString) { | |||||
this.inputString = 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. | * @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; | this.append = append; | ||||
} | } | ||||
@@ -196,7 +196,7 @@ public class SSHExec extends SSHBase { | |||||
* @param append True to append to an existing file, false to overwrite. | * @param append True to append to an existing file, false to overwrite. | ||||
* @since Apache Ant 1.9.4 | * @since Apache Ant 1.9.4 | ||||
*/ | */ | ||||
public void setErrAppend(boolean appenderr) { | |||||
public void setErrAppend(final boolean appenderr) { | |||||
this.appenderr = 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 | * @param property The name of the property in which the command output | ||||
* will be stored. | * will be stored. | ||||
*/ | */ | ||||
public void setOutputproperty(String property) { | |||||
public void setOutputproperty(final String property) { | |||||
outputProperty = property; | outputProperty = property; | ||||
} | } | ||||
@@ -217,7 +217,7 @@ public class SSHExec extends SSHBase { | |||||
* will be stored. | * will be stored. | ||||
* @since Apache Ant 1.9.4 | * @since Apache Ant 1.9.4 | ||||
*/ | */ | ||||
public void setErrorproperty (String property) { | |||||
public void setErrorproperty (final String property) { | |||||
errorProperty = property; | errorProperty = property; | ||||
} | } | ||||
@@ -228,7 +228,7 @@ public class SSHExec extends SSHBase { | |||||
* will be stored. | * will be stored. | ||||
* @since Apache Ant 1.9.4 | * @since Apache Ant 1.9.4 | ||||
*/ | */ | ||||
public void setResultproperty(String property) { | |||||
public void setResultproperty(final String property) { | |||||
resultProperty = property; | resultProperty = property; | ||||
} | } | ||||
@@ -236,17 +236,17 @@ public class SSHExec extends SSHBase { | |||||
* Whether a pseudo-tty should be allocated. | * Whether a pseudo-tty should be allocated. | ||||
* @since Apache Ant 1.8.3 | * @since Apache Ant 1.8.3 | ||||
*/ | */ | ||||
public void setUsePty(boolean b) { | |||||
public void setUsePty(final boolean b) { | |||||
usePty = b; | usePty = b; | ||||
} | } | ||||
/** | /** | ||||
* If set, input will be taken from System.in | * If set, input will be taken from System.in | ||||
* | |||||
* | |||||
* @param useSystemIn True to use System.in as InputStream, false otherwise | * @param useSystemIn True to use System.in as InputStream, false otherwise | ||||
* @since Apache Ant 1.9.4 | * @since Apache Ant 1.9.4 | ||||
*/ | */ | ||||
public void setUseSystemIn(boolean useSystemIn) { | |||||
public void setUseSystemIn(final boolean useSystemIn) { | |||||
this.useSystemIn = useSystemIn; | this.useSystemIn = useSystemIn; | ||||
} | } | ||||
@@ -255,7 +255,7 @@ public class SSHExec extends SSHBase { | |||||
* If suppressSystemOut is <code>false</code>, normal behavior | * If suppressSystemOut is <code>false</code>, normal behavior | ||||
* @since Ant 1.9.0 | * @since Ant 1.9.0 | ||||
*/ | */ | ||||
public void setSuppressSystemOut(boolean suppressSystemOut) { | |||||
public void setSuppressSystemOut(final boolean suppressSystemOut) { | |||||
this.suppressSystemOut = suppressSystemOut; | this.suppressSystemOut = suppressSystemOut; | ||||
} | } | ||||
@@ -264,7 +264,7 @@ public class SSHExec extends SSHBase { | |||||
* If suppressSystemErr is <code>false</code>, normal behavior | * If suppressSystemErr is <code>false</code>, normal behavior | ||||
* @since Ant 1.9.4 | * @since Ant 1.9.4 | ||||
*/ | */ | ||||
public void setSuppressSystemErr(boolean suppressSystemErr) { | |||||
public void setSuppressSystemErr(final boolean suppressSystemErr) { | |||||
this.suppressSystemErr = suppressSystemErr; | this.suppressSystemErr = suppressSystemErr; | ||||
} | } | ||||
@@ -273,7 +273,8 @@ public class SSHExec extends SSHBase { | |||||
* | * | ||||
* @exception BuildException Most likely a network error or bad parameter. | * @exception BuildException Most likely a network error or bad parameter. | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
if (getHost() == null) { | if (getHost() == null) { | ||||
throw new BuildException("Host is required."); | throw new BuildException("Host is required."); | ||||
@@ -289,7 +290,7 @@ public class SSHExec extends SSHBase { | |||||
throw new BuildException("Command or commandResource is required."); | 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) | + (inputProperty != null ? 1 : 0) | ||||
+ (inputString != null ? 1 : 0); | + (inputString != null ? 1 : 0); | ||||
if (numberOfInputs > 1) { | if (numberOfInputs > 1) { | ||||
@@ -304,7 +305,7 @@ public class SSHExec extends SSHBase { | |||||
} | } | ||||
Session session = null; | Session session = null; | ||||
StringBuffer output = new StringBuffer(); | |||||
final StringBuffer output = new StringBuffer(); | |||||
try { | try { | ||||
session = openSession(); | session = openSession(); | ||||
/* called once */ | /* called once */ | ||||
@@ -313,7 +314,7 @@ public class SSHExec extends SSHBase { | |||||
executeCommand(session, command, output); | executeCommand(session, command, output); | ||||
} else { // read command resource and execute for each command | } else { // read command resource and execute for each command | ||||
try { | try { | ||||
BufferedReader br = new BufferedReader( | |||||
final BufferedReader br = new BufferedReader( | |||||
new InputStreamReader(commandResource.getInputStream())); | new InputStreamReader(commandResource.getInputStream())); | ||||
String cmd; | String cmd; | ||||
while ((cmd = br.readLine()) != null) { | while ((cmd = br.readLine()) != null) { | ||||
@@ -323,7 +324,7 @@ public class SSHExec extends SSHBase { | |||||
output.append("\n"); | output.append("\n"); | ||||
} | } | ||||
FileUtils.close(br); | FileUtils.close(br); | ||||
} catch (IOException e) { | |||||
} catch (final IOException e) { | |||||
if (getFailonerror()) { | if (getFailonerror()) { | ||||
throw new BuildException(e); | throw new BuildException(e); | ||||
} else { | } else { | ||||
@@ -332,7 +333,7 @@ public class SSHExec extends SSHBase { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} catch (JSchException e) { | |||||
} catch (final JSchException e) { | |||||
if (getFailonerror()) { | if (getFailonerror()) { | ||||
throw new BuildException(e); | throw new BuildException(e); | ||||
} else { | } 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 { | 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) { | if (inputFile != null) { | ||||
try { | try { | ||||
istream = new FileInputStream(inputFile) ; | |||||
} catch (IOException e) { | |||||
istream = new FileInputStream(inputFile); | |||||
} catch (final IOException e) { | |||||
// because we checked the existence before, this one | // because we checked the existence before, this one | ||||
// shouldn't happen What if the file exists, but there | // shouldn't happen What if the file exists, but there | ||||
// are no read permissions? | // are no read permissions? | ||||
@@ -368,9 +369,9 @@ public class SSHExec extends SSHBase { | |||||
} | } | ||||
} | } | ||||
if (inputProperty != null) { | if (inputProperty != null) { | ||||
String inputData = getProject().getProperty(inputProperty) ; | |||||
final String inputData = getProject().getProperty(inputProperty); | |||||
if (inputData != null) { | if (inputData != null) { | ||||
istream = new ByteArrayInputStream(inputData.getBytes()) ; | |||||
istream = new ByteArrayInputStream(inputData.getBytes()); | |||||
} | } | ||||
} | } | ||||
if (inputString != null) { | if (inputString != null) { | ||||
@@ -398,14 +399,15 @@ public class SSHExec extends SSHBase { | |||||
// wait for it to finish | // wait for it to finish | ||||
thread = | thread = | ||||
new Thread() { | new Thread() { | ||||
public void run() { | |||||
@Override | |||||
public void run() { | |||||
while (!channel.isClosed()) { | while (!channel.isClosed()) { | ||||
if (thread == null) { | if (thread == null) { | ||||
return; | return; | ||||
} | } | ||||
try { | try { | ||||
sleep(RETRY_INTERVAL); | sleep(RETRY_INTERVAL); | ||||
} catch (Exception e) { | |||||
} catch (final Exception e) { | |||||
// ignored | // ignored | ||||
} | } | ||||
} | } | ||||
@@ -438,13 +440,13 @@ public class SSHExec extends SSHBase { | |||||
} | } | ||||
// this is the wrong test if the remote OS is OpenVMS, | // this is the wrong test if the remote OS is OpenVMS, | ||||
// but there doesn't seem to be a way to detect it. | // but there doesn't seem to be a way to detect it. | ||||
int ec = channel.getExitStatus(); | |||||
final int ec = channel.getExitStatus(); | |||||
// set resultproperty | // set resultproperty | ||||
if (resultProperty != null) { | if (resultProperty != null) { | ||||
getProject().setNewProperty(resultProperty, Integer.toString(ec)); | getProject().setNewProperty(resultProperty, Integer.toString(ec)); | ||||
} | } | ||||
if (ec != 0) { | if (ec != 0) { | ||||
String msg = "Remote command failed with exit status " + ec; | |||||
final String msg = "Remote command failed with exit status " + ec; | |||||
if (getFailonerror()) { | if (getFailonerror()) { | ||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} else { | } else { | ||||
@@ -452,9 +454,9 @@ public class SSHExec extends SSHBase { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} catch (BuildException e) { | |||||
} catch (final BuildException e) { | |||||
throw e; | throw e; | ||||
} catch (JSchException e) { | |||||
} catch (final JSchException e) { | |||||
if (e.getMessage().indexOf("session is down") >= 0) { | if (e.getMessage().indexOf("session is down") >= 0) { | ||||
if (getFailonerror()) { | if (getFailonerror()) { | ||||
throw new BuildException(TIMEOUT_MESSAGE, e); | throw new BuildException(TIMEOUT_MESSAGE, e); | ||||
@@ -469,7 +471,7 @@ public class SSHExec extends SSHBase { | |||||
Project.MSG_ERR); | Project.MSG_ERR); | ||||
} | } | ||||
} | } | ||||
} catch (Exception e) { | |||||
} catch (final Exception e) { | |||||
if (getFailonerror()) { | if (getFailonerror()) { | ||||
throw new BuildException(e); | throw new BuildException(e); | ||||
} else { | } else { | ||||
@@ -490,13 +492,13 @@ public class SSHExec extends SSHBase { | |||||
* @param append if true, append to existing file, else overwrite | * @param append if true, append to existing file, else overwrite | ||||
* @exception Exception most likely an IOException | * @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 { | throws IOException { | ||||
FileWriter out = null; | FileWriter out = null; | ||||
try { | try { | ||||
out = new FileWriter(to.getAbsolutePath(), append); | 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; | int bytesRead; | ||||
while (true) { | while (true) { | ||||
bytesRead = in.read(buffer); | bytesRead = in.read(buffer); | ||||
@@ -130,7 +130,8 @@ public class SSHSession extends SSHBase { | |||||
* @exception BuildException if one of the nested tasks fails, or | * @exception BuildException if one of the nested tasks fails, or | ||||
* network error or bad parameter. | * network error or bad parameter. | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
if (getHost() == null) { | if (getHost() == null) { | ||||
throw new BuildException("Host is required."); | throw new BuildException("Host is required."); | ||||
} | } | ||||
@@ -277,13 +278,13 @@ public class SSHSession extends SSHBase { | |||||
return lport; | return lport; | ||||
} | } | ||||
public String getLHost() { | public String getLHost() { | ||||
if (lhost == null) { | |||||
if (lhost == null) { | |||||
throw new BuildException("lhost is required for RemoteTunnel."); | throw new BuildException("lhost is required for RemoteTunnel."); | ||||
} | } | ||||
return lhost; | return lhost; | ||||
} | } | ||||
public int getRPort() { | public int getRPort() { | ||||
if (rport == 0) { | |||||
if (rport == 0) { | |||||
throw new BuildException("rport is required for RemoteTunnel."); | throw new BuildException("rport is required for RemoteTunnel."); | ||||
} | } | ||||
return rport; | return rport; | ||||
@@ -315,7 +316,8 @@ public class SSHSession extends SSHBase { | |||||
* | * | ||||
* @param task an unknown element. | * @param task an unknown element. | ||||
*/ | */ | ||||
public void addTask(Task task) { | |||||
@Override | |||||
public void addTask(Task task) { | |||||
nested.add(task); | nested.add(task); | ||||
} | } | ||||
@@ -123,7 +123,7 @@ public class Scp extends SSHBase { | |||||
*/ | */ | ||||
public void setPreservelastmodified(boolean yesOrNo) { | public void setPreservelastmodified(boolean yesOrNo) { | ||||
this.preserveLastModified = yesOrNo; | this.preserveLastModified = yesOrNo; | ||||
} | |||||
} | |||||
/** | /** | ||||
* Similiar to {@link #setTodir setTodir} but explicitly states | * Similiar to {@link #setTodir setTodir} but explicitly states | ||||
@@ -145,7 +145,7 @@ public class Scp extends SSHBase { | |||||
+ "following: user:password@host:/path" | + "following: user:password@host:/path" | ||||
+ " - the :password part is optional"); | + " - the :password part is optional"); | ||||
} | } | ||||
} | |||||
} | |||||
/** | /** | ||||
* Changes the file name to the given name while receiving it, | * Changes the file name to the given name while receiving it, | ||||
@@ -196,7 +196,8 @@ public class Scp extends SSHBase { | |||||
* Initialize this task. | * Initialize this task. | ||||
* @throws BuildException on error | * @throws BuildException on error | ||||
*/ | */ | ||||
public void init() throws BuildException { | |||||
@Override | |||||
public void init() throws BuildException { | |||||
super.init(); | super.init(); | ||||
this.toUri = null; | this.toUri = null; | ||||
this.fromUri = null; | this.fromUri = null; | ||||
@@ -207,7 +208,8 @@ public class Scp extends SSHBase { | |||||
* Execute this task. | * Execute this task. | ||||
* @throws BuildException on error | * @throws BuildException on error | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
if (toUri == null) { | if (toUri == null) { | ||||
throw exactlyOne(TO_ATTRS); | throw exactlyOne(TO_ATTRS); | ||||
} | } | ||||
@@ -362,7 +364,7 @@ public class Scp extends SSHBase { | |||||
// no password, will require keyfile | // no password, will require keyfile | ||||
setUsername(uri.substring(0, indexOfAt)); | setUsername(uri.substring(0, indexOfAt)); | ||||
} else { | } 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 | if (getUserInfo().getPassword() == null | ||||
@@ -129,7 +129,8 @@ public class Symlink extends DispatchTask { | |||||
* Initialize the task. | * Initialize the task. | ||||
* @throws BuildException on error. | * @throws BuildException on error. | ||||
*/ | */ | ||||
public void init() throws BuildException { | |||||
@Override | |||||
public void init() throws BuildException { | |||||
super.init(); | super.init(); | ||||
setDefaults(); | setDefaults(); | ||||
} | } | ||||
@@ -138,7 +139,8 @@ public class Symlink extends DispatchTask { | |||||
* The standard method for executing any task. | * The standard method for executing any task. | ||||
* @throws BuildException on error. | * @throws BuildException on error. | ||||
*/ | */ | ||||
public synchronized void execute() throws BuildException { | |||||
@Override | |||||
public synchronized void execute() throws BuildException { | |||||
if (executing) { | if (executing) { | ||||
throw new BuildException( | throw new BuildException( | ||||
"Infinite recursion detected in Symlink.execute()"); | "Infinite recursion detected in Symlink.execute()"); | ||||
@@ -325,7 +327,8 @@ public class Symlink extends DispatchTask { | |||||
* | * | ||||
* @param action The action to perform. | * @param action The action to perform. | ||||
*/ | */ | ||||
public void setAction(String action) { | |||||
@Override | |||||
public void setAction(String action) { | |||||
super.setAction(action); | super.setAction(action); | ||||
} | } | ||||
@@ -383,7 +386,8 @@ public class Symlink extends DispatchTask { | |||||
* org.apache.tools.ant.util.SymbolicLinkUtils#deleteSymbolicLink | * org.apache.tools.ant.util.SymbolicLinkUtils#deleteSymbolicLink | ||||
* instead | * instead | ||||
*/ | */ | ||||
public static void deleteSymlink(String path) | |||||
@Deprecated | |||||
public static void deleteSymlink(String path) | |||||
throws IOException, FileNotFoundException { | throws IOException, FileNotFoundException { | ||||
SYMLINK_UTILS.deleteSymbolicLink(new File(path), null); | SYMLINK_UTILS.deleteSymbolicLink(new File(path), null); | ||||
} | } | ||||
@@ -403,7 +407,7 @@ public class Symlink extends DispatchTask { | |||||
* an exception.</p> | * an exception.</p> | ||||
* | * | ||||
* <p>Since Ant 1.8.0 this method will try to delete the File object if | * <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> | * Prior version would throw a FileNotFoundException in that case.</p> | ||||
* | * | ||||
* @param linkfil A <code>File</code> object of the symlink to delete. | * @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 | * org.apache.tools.ant.util.SymbolicLinkUtils#deleteSymbolicLink | ||||
* instead | * instead | ||||
*/ | */ | ||||
public static void deleteSymlink(File linkfil) | |||||
@Deprecated | |||||
public static void deleteSymlink(File linkfil) | |||||
throws IOException { | throws IOException { | ||||
SYMLINK_UTILS.deleteSymbolicLink(linkfil, null); | SYMLINK_UTILS.deleteSymbolicLink(linkfil, null); | ||||
} | } | ||||
@@ -374,7 +374,8 @@ public class FilterChain extends DataType | |||||
* @param r the reference to which this instance is associated | * @param r the reference to which this instance is associated | ||||
* @exception BuildException if this instance already has been configured. | * @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()) { | if (!filterReaders.isEmpty()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
@@ -396,7 +397,8 @@ public class FilterChain extends DataType | |||||
filterReaders.addElement(filter); | filterReaders.addElement(filter); | ||||
} | } | ||||
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||||
@Override | |||||
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||||
throws BuildException { | throws BuildException { | ||||
if (isChecked()) { | if (isChecked()) { | ||||
return; | return; | ||||
@@ -404,7 +406,7 @@ public class FilterChain extends DataType | |||||
if (isReference()) { | if (isReference()) { | ||||
super.dieOnCircularReference(stk, p); | super.dieOnCircularReference(stk, p); | ||||
} else { | } else { | ||||
for (Iterator<Object> i = filterReaders.iterator(); i.hasNext(); ) { | |||||
for (Iterator<Object> i = filterReaders.iterator(); i.hasNext();) { | |||||
Object o = i.next(); | Object o = i.next(); | ||||
if (o instanceof DataType) { | if (o instanceof DataType) { | ||||
pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | ||||
@@ -164,7 +164,8 @@ public class FilterSet extends DataType implements Cloneable { | |||||
//inherit doc | //inherit doc | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return VALUES; | return VALUES; | ||||
} | } | ||||
} | } | ||||
@@ -229,7 +230,7 @@ public class FilterSet extends DataType implements Cloneable { | |||||
readingFiles = true; | readingFiles = true; | ||||
final int size = filtersFiles.size(); | final int size = filtersFiles.size(); | ||||
for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | ||||
readFiltersFromFile((File) filtersFiles.get(i)); | |||||
readFiltersFromFile(filtersFiles.get(i)); | |||||
} | } | ||||
filtersFiles.clear(); | filtersFiles.clear(); | ||||
readingFiles = false; | readingFiles = false; | ||||
@@ -243,7 +244,7 @@ public class FilterSet extends DataType implements Cloneable { | |||||
* @return the filterset from the reference. | * @return the filterset from the reference. | ||||
*/ | */ | ||||
protected FilterSet getRef() { | 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. | * Adds the properties provided by the specified PropertySet to this filterset. | ||||
* | |||||
* | |||||
* @param propertySet the propertyset to be added to this propertyset | * @param propertySet the propertyset to be added to this propertyset | ||||
*/ | */ | ||||
public synchronized void addConfiguredPropertySet(PropertySet 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. | * @throws BuildException if the clone cannot be performed. | ||||
*/ | */ | ||||
public synchronized Object clone() throws BuildException { | |||||
@Override | |||||
public synchronized Object clone() throws BuildException { | |||||
if (isReference()) { | if (isReference()) { | ||||
return ((FilterSet) getRef()).clone(); | |||||
return getRef().clone(); | |||||
} | } | ||||
try { | try { | ||||
FilterSet fs = (FilterSet) super.clone(); | FilterSet fs = (FilterSet) super.clone(); | ||||
@@ -621,7 +623,7 @@ public class FilterSet extends DataType implements Cloneable { | |||||
} else if (duplicateToken) { | } else if (duplicateToken) { | ||||
// should always be the case... | // should always be the case... | ||||
if (passedTokens.size() > 0) { | if (passedTokens.size() > 0) { | ||||
value = (String) passedTokens.remove(passedTokens.size() - 1); | |||||
value = passedTokens.remove(passedTokens.size() - 1); | |||||
if (passedTokens.size() == 0) { | if (passedTokens.size() == 0) { | ||||
value = beginToken + value + endToken; | value = beginToken + value + endToken; | ||||
duplicateToken = false; | duplicateToken = false; | ||||
@@ -44,12 +44,12 @@ import org.apache.tools.ant.ExitException; | |||||
*/ | */ | ||||
public class Permissions { | 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 java.security.Permissions granted = null; | ||||
private SecurityManager origSm = null; | private SecurityManager origSm = null; | ||||
private boolean active = false; | private boolean active = false; | ||||
private boolean delegateToOldSM; | |||||
private final boolean delegateToOldSM; | |||||
// Mandatory constructor for permission object. | // Mandatory constructor for permission object. | ||||
private static final Class<?>[] PARAMS = {String.class, String.class}; | 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 | * will be used if the permission has not been explicitly granted or revoked | ||||
* in this instance. | * in this instance. | ||||
*/ | */ | ||||
public Permissions(boolean delegateToOldSM) { | |||||
public Permissions(final boolean delegateToOldSM) { | |||||
this.delegateToOldSM = delegateToOldSM; | this.delegateToOldSM = delegateToOldSM; | ||||
} | } | ||||
@@ -76,7 +76,7 @@ public class Permissions { | |||||
* Adds a permission to be granted. | * Adds a permission to be granted. | ||||
* @param perm The Permissions.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); | grantedPermissions.add(perm); | ||||
} | } | ||||
@@ -84,7 +84,7 @@ public class Permissions { | |||||
* Adds a permission to be revoked. | * Adds a permission to be revoked. | ||||
* @param perm The Permissions.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); | revokedPermissions.add(perm); | ||||
} | } | ||||
@@ -107,17 +107,17 @@ public class Permissions { | |||||
*/ | */ | ||||
private void init() throws BuildException { | private void init() throws BuildException { | ||||
granted = new java.security.Permissions(); | granted = new java.security.Permissions(); | ||||
for (Permissions.Permission p : revokedPermissions) { | |||||
for (final Permissions.Permission p : revokedPermissions) { | |||||
if (p.getClassName() == null) { | if (p.getClassName() == null) { | ||||
throw new BuildException("Revoked permission " + p + " does not contain a class."); | 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) { | if (p.getClassName() == null) { | ||||
throw new BuildException("Granted permission " + p | throw new BuildException("Granted permission " + p | ||||
+ " does not contain a class."); | + " does not contain a class."); | ||||
} else { | } else { | ||||
java.security.Permission perm = createPermission(p); | |||||
final java.security.Permission perm = createPermission(p); | |||||
granted.add(perm); | granted.add(perm); | ||||
} | } | ||||
} | } | ||||
@@ -146,17 +146,17 @@ public class Permissions { | |||||
} | } | ||||
private java.security.Permission createPermission( | private java.security.Permission createPermission( | ||||
Permissions.Permission permission) { | |||||
final Permissions.Permission permission) { | |||||
try { | try { | ||||
// First add explicitly already resolved permissions will not be | // First add explicitly already resolved permissions will not be | ||||
// resolved when added as unresolved permission. | // 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); | 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. | // Let the UnresolvedPermission handle it. | ||||
return new UnresolvedPermission(permission.getClassName(), | return new UnresolvedPermission(permission.getClassName(), | ||||
permission.getName(), permission.getActions(), null); | permission.getName(), permission.getActions(), null); | ||||
@@ -185,11 +185,12 @@ public class Permissions { | |||||
* Overridden from java.lang.SecurityManager | * Overridden from java.lang.SecurityManager | ||||
* @param status The exit status requested. | * @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 { | try { | ||||
checkPermission(perm); | checkPermission(perm); | ||||
} catch (SecurityException e) { | |||||
} catch (final SecurityException e) { | |||||
throw new ExitException(e.getMessage(), status); | throw new ExitException(e.getMessage(), status); | ||||
} | } | ||||
} | } | ||||
@@ -200,7 +201,8 @@ public class Permissions { | |||||
* | * | ||||
* @param perm The permission requested. | * @param perm The permission requested. | ||||
*/ | */ | ||||
public void checkPermission(java.security.Permission perm) { | |||||
@Override | |||||
public void checkPermission(final java.security.Permission perm) { | |||||
if (active) { | if (active) { | ||||
if (delegateToOldSM && !perm.getName().equals("exitVM")) { | if (delegateToOldSM && !perm.getName().equals("exitVM")) { | ||||
boolean permOK = false; | boolean permOK = false; | ||||
@@ -228,8 +230,8 @@ public class Permissions { | |||||
* throws an exception if this permission is revoked | * throws an exception if this permission is revoked | ||||
* @param perm the permission being checked | * @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)) { | if (revoked.matches(perm)) { | ||||
throw new SecurityException("Permission " + perm + " was revoked."); | throw new SecurityException("Permission " + perm + " was revoked."); | ||||
} | } | ||||
@@ -248,7 +250,7 @@ public class Permissions { | |||||
* Set the class, mandatory. | * Set the class, mandatory. | ||||
* @param aClass The class name of the permission. | * @param aClass The class name of the permission. | ||||
*/ | */ | ||||
public void setClass(String aClass) { | |||||
public void setClass(final String aClass) { | |||||
className = aClass.trim(); | className = aClass.trim(); | ||||
} | } | ||||
@@ -264,7 +266,7 @@ public class Permissions { | |||||
* Set the name of the permission. | * Set the name of the permission. | ||||
* @param aName 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(); | name = aName.trim(); | ||||
} | } | ||||
@@ -280,7 +282,7 @@ public class Permissions { | |||||
* Set the actions. | * Set the actions. | ||||
* @param actions The actions of the permission. | * @param actions The actions of the permission. | ||||
*/ | */ | ||||
public void setActions(String actions) { | |||||
public void setActions(final String actions) { | |||||
actionString = actions; | actionString = actions; | ||||
if (actions.length() > 0) { | if (actions.length() > 0) { | ||||
this.actions = parseActions(actions); | this.actions = parseActions(actions); | ||||
@@ -299,7 +301,7 @@ public class Permissions { | |||||
* Learn whether the permission matches in case of a revoked permission. | * Learn whether the permission matches in case of a revoked permission. | ||||
* @param perm The permission to check against. | * @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())) { | if (!className.equals(perm.getClass().getName())) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -315,8 +317,8 @@ public class Permissions { | |||||
} | } | ||||
} | } | ||||
if (actions != null) { | 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); | as.removeAll(actions); | ||||
if (as.size() == size) { | if (as.size() == size) { | ||||
// None of the actions revoked, so all allowed. | // None of the actions revoked, so all allowed. | ||||
@@ -330,11 +332,11 @@ public class Permissions { | |||||
* Parses the actions into a set of separate strings. | * Parses the actions into a set of separate strings. | ||||
* @param actions The actions to be parsed. | * @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()) { | while (tk.hasMoreTokens()) { | ||||
String item = tk.nextToken().trim(); | |||||
final String item = tk.nextToken().trim(); | |||||
if (!item.equals("")) { | if (!item.equals("")) { | ||||
result.add(item); | result.add(item); | ||||
} | } | ||||
@@ -346,7 +348,8 @@ public class Permissions { | |||||
* Get a string description of the permissions. | * Get a string description of the permissions. | ||||
* @return string description of the permissions. | * @return string description of the permissions. | ||||
*/ | */ | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
return ("Permission: " + className + " (\"" + name + "\", \"" + actions + "\")"); | return ("Permission: " + className + " (\"" + name + "\", \"" + actions + "\")"); | ||||
} | } | ||||
} | } | ||||
@@ -19,8 +19,6 @@ package org.apache.tools.ant.types; | |||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.tools.ant.types.resources.FileProvider; | |||||
/** | /** | ||||
* Interface describing a collection of Resources. | * Interface describing a collection of Resources. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
@@ -38,7 +38,7 @@ public class CutDirsMapper implements FileNameMapper { | |||||
/** | /** | ||||
* The number of leading directories to cut. | * The number of leading directories to cut. | ||||
*/ | */ | ||||
public void setDirs(int dirs) { | |||||
public void setDirs(final int dirs) { | |||||
this.dirs = dirs; | this.dirs = dirs; | ||||
} | } | ||||
@@ -46,23 +46,26 @@ public class CutDirsMapper implements FileNameMapper { | |||||
* Empty implementation. | * Empty implementation. | ||||
* @param ignore ignored. | * @param ignore ignored. | ||||
*/ | */ | ||||
public void setFrom(String ignore) { | |||||
@Override | |||||
public void setFrom(final String ignore) { | |||||
} | } | ||||
/** | /** | ||||
* Empty implementation. | * Empty implementation. | ||||
* @param ignore ignored. | * @param ignore ignored. | ||||
*/ | */ | ||||
public void setTo(String ignore) { | |||||
@Override | |||||
public void setTo(final String ignore) { | |||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
public String[] mapFileName(final String sourceFileName) { | |||||
@Override | |||||
public String[] mapFileName(final String sourceFileName) { | |||||
if (dirs <= 0) { | if (dirs <= 0) { | ||||
throw new BuildException("dirs must be set to a positive number"); | 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); | sourceFileName.replace('/', fileSep).replace('\\', fileSep); | ||||
int nthMatch = fileSepCorrected.indexOf(fileSep); | int nthMatch = fileSepCorrected.indexOf(fileSep); | ||||
for (int n = 1; nthMatch > -1 && n < dirs; n++) { | for (int n = 1; nthMatch > -1 && n < dirs; n++) { | ||||
@@ -71,6 +74,6 @@ public class CutDirsMapper implements FileNameMapper { | |||||
if (nthMatch == -1) { | if (nthMatch == -1) { | ||||
return null; | 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. | * Sums the sizes of nested archives. | ||||
*/ | */ | ||||
public int size() { | |||||
@Override | |||||
public int size() { | |||||
if (isReference()) { | if (isReference()) { | ||||
return ((Archives) getCheckedRef()).size(); | return ((Archives) getCheckedRef()).size(); | ||||
} | } | ||||
dieOnCircularReference(); | dieOnCircularReference(); | ||||
int total = 0; | int total = 0; | ||||
for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext(); ) { | |||||
for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext();) { | |||||
total += i.next().size(); | total += i.next().size(); | ||||
} | } | ||||
return total; | return total; | ||||
@@ -87,13 +88,14 @@ public class Archives extends DataType | |||||
/** | /** | ||||
* Merges the nested collections. | * Merges the nested collections. | ||||
*/ | */ | ||||
public Iterator<Resource> iterator() { | |||||
@Override | |||||
public Iterator<Resource> iterator() { | |||||
if (isReference()) { | if (isReference()) { | ||||
return ((Archives) getCheckedRef()).iterator(); | return ((Archives) getCheckedRef()).iterator(); | ||||
} | } | ||||
dieOnCircularReference(); | dieOnCircularReference(); | ||||
List<Resource> l = new LinkedList<Resource>(); | List<Resource> l = new LinkedList<Resource>(); | ||||
for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext(); ) { | |||||
for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext();) { | |||||
l.addAll(CollectionUtils | l.addAll(CollectionUtils | ||||
.asCollection(i.next().iterator())); | .asCollection(i.next().iterator())); | ||||
} | } | ||||
@@ -103,7 +105,8 @@ public class Archives extends DataType | |||||
/** | /** | ||||
* @return false | * @return false | ||||
*/ | */ | ||||
public boolean isFilesystemOnly() { | |||||
@Override | |||||
public boolean isFilesystemOnly() { | |||||
if (isReference()) { | if (isReference()) { | ||||
return ((Archives) getCheckedRef()).isFilesystemOnly(); | return ((Archives) getCheckedRef()).isFilesystemOnly(); | ||||
} | } | ||||
@@ -115,7 +118,8 @@ public class Archives extends DataType | |||||
* Overrides the base version. | * Overrides the base version. | ||||
* @param r the Reference to set. | * @param r the Reference to set. | ||||
*/ | */ | ||||
public void setRefid(Reference r) { | |||||
@Override | |||||
public void setRefid(Reference r) { | |||||
if (zips.getResourceCollections().size() > 0 | if (zips.getResourceCollections().size() > 0 | ||||
|| tars.getResourceCollections().size() > 0) { | || tars.getResourceCollections().size() > 0) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
@@ -128,7 +132,8 @@ public class Archives extends DataType | |||||
* well. | * well. | ||||
* @return a cloned instance. | * @return a cloned instance. | ||||
*/ | */ | ||||
public Object clone() { | |||||
@Override | |||||
public Object clone() { | |||||
try { | try { | ||||
Archives a = (Archives) super.clone(); | Archives a = (Archives) super.clone(); | ||||
a.zips = (Union) zips.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. | * @param p the project to use to dereference the references. | ||||
* @throws BuildException on error. | * @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 { | throws BuildException { | ||||
if (isChecked()) { | if (isChecked()) { | ||||
return; | 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 | * @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. | * compatibility with java.io.File), or UNKNOWN_SIZE if not known. | ||||
*/ | */ | ||||
public long getSize() { | |||||
@Override | |||||
public long getSize() { | |||||
if (isExists()) { | if (isExists()) { | ||||
InputStream in = null; | InputStream in = null; | ||||
try { | try { | ||||
@@ -86,7 +87,8 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||||
* @throws UnsupportedOperationException if InputStreams are not | * @throws UnsupportedOperationException if InputStreams are not | ||||
* supported for this Resource type. | * supported for this Resource type. | ||||
*/ | */ | ||||
public InputStream getInputStream() throws IOException { | |||||
@Override | |||||
public InputStream getInputStream() throws IOException { | |||||
InputStream in = getResource().getInputStream(); | InputStream in = getResource().getInputStream(); | ||||
if (in != null) { | if (in != null) { | ||||
in = wrapStream(in); | in = wrapStream(in); | ||||
@@ -102,7 +104,8 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||||
* @throws UnsupportedOperationException if OutputStreams are not | * @throws UnsupportedOperationException if OutputStreams are not | ||||
* supported for this Resource type. | * supported for this Resource type. | ||||
*/ | */ | ||||
public OutputStream getOutputStream() throws IOException { | |||||
@Override | |||||
public OutputStream getOutputStream() throws IOException { | |||||
OutputStream out = getResource().getOutputStream(); | OutputStream out = getResource().getOutputStream(); | ||||
if (out != null) { | if (out != null) { | ||||
out = wrapStream(out); | out = wrapStream(out); | ||||
@@ -113,14 +116,16 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||||
/** | /** | ||||
* Suppress FileProvider, re-implement Appendable | * 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 (Appendable.class.isAssignableFrom(clazz)) { | ||||
if (isAppendSupported()) { | if (isAppendSupported()) { | ||||
final Appendable a = | final Appendable a = | ||||
getResource().as(Appendable.class); | getResource().as(Appendable.class); | ||||
if (a != null) { | if (a != null) { | ||||
return clazz.cast(new Appendable() { | return clazz.cast(new Appendable() { | ||||
public OutputStream getAppendOutputStream() | |||||
@Override | |||||
public OutputStream getAppendOutputStream() | |||||
throws IOException { | throws IOException { | ||||
OutputStream out = a.getAppendOutputStream(); | OutputStream out = a.getAppendOutputStream(); | ||||
if (out != null) { | if (out != null) { | ||||
@@ -134,7 +139,7 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||||
return null; | return null; | ||||
} | } | ||||
return FileProvider.class.isAssignableFrom(clazz) | |||||
return FileProvider.class.isAssignableFrom(clazz) | |||||
? null : getResource().as(clazz); | ? null : getResource().as(clazz); | ||||
} | } | ||||
@@ -148,7 +153,7 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||||
*/ | */ | ||||
protected boolean isAppendSupported() { | protected boolean isAppendSupported() { | ||||
return false; | return false; | ||||
} | |||||
} | |||||
/** | /** | ||||
* Get a content-filtering/transforming InputStream. | * Get a content-filtering/transforming InputStream. | ||||
@@ -36,7 +36,8 @@ public class LazyResourceCollectionWrapper extends | |||||
private FilteringIterator filteringIterator; | private FilteringIterator filteringIterator; | ||||
protected Iterator<Resource> createIterator() { | |||||
@Override | |||||
protected Iterator<Resource> createIterator() { | |||||
Iterator<Resource> iterator; | Iterator<Resource> iterator; | ||||
if (isCache()) { | if (isCache()) { | ||||
if (filteringIterator == null) { | if (filteringIterator == null) { | ||||
@@ -51,7 +52,8 @@ public class LazyResourceCollectionWrapper extends | |||||
return iterator; | return iterator; | ||||
} | } | ||||
protected int getSize() { | |||||
@Override | |||||
protected int getSize() { | |||||
// to compute the size, just iterate: the iterator will take care of | // to compute the size, just iterate: the iterator will take care of | ||||
// caching | // caching | ||||
Iterator<Resource> it = createIterator(); | Iterator<Resource> it = createIterator(); | ||||
@@ -66,7 +68,7 @@ public class LazyResourceCollectionWrapper extends | |||||
/** | /** | ||||
* Specify if the resource should be filtered or not. This function should | * Specify if the resource should be filtered or not. This function should | ||||
* be overrided in order to define the filtering algorithm | * be overrided in order to define the filtering algorithm | ||||
* | |||||
* | |||||
* @param r resource considered for filtration | * @param r resource considered for filtration | ||||
* @return whether the resource should be filtered or not | * @return whether the resource should be filtered or not | ||||
*/ | */ | ||||
@@ -86,7 +88,8 @@ public class LazyResourceCollectionWrapper extends | |||||
this.it = it; | this.it = it; | ||||
} | } | ||||
public boolean hasNext() { | |||||
@Override | |||||
public boolean hasNext() { | |||||
if (ended) { | if (ended) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -103,7 +106,8 @@ public class LazyResourceCollectionWrapper extends | |||||
return true; | return true; | ||||
} | } | ||||
public Resource next() { | |||||
@Override | |||||
public Resource next() { | |||||
if (!hasNext()) { | if (!hasNext()) { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
@@ -112,7 +116,8 @@ public class LazyResourceCollectionWrapper extends | |||||
return r; | return r; | ||||
} | } | ||||
public void remove() { | |||||
@Override | |||||
public void remove() { | |||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
} | } | ||||
@@ -129,7 +134,7 @@ public class LazyResourceCollectionWrapper extends | |||||
/** | /** | ||||
* Default constructor | * Default constructor | ||||
* | |||||
* | |||||
* @param it | * @param it | ||||
* the iterator which will provide the resources to put in | * the iterator which will provide the resources to put in | ||||
* cache | * cache | ||||
@@ -138,7 +143,8 @@ public class LazyResourceCollectionWrapper extends | |||||
this.it = it; | this.it = it; | ||||
} | } | ||||
public boolean hasNext() { | |||||
@Override | |||||
public boolean hasNext() { | |||||
synchronized (cachedResources) { | synchronized (cachedResources) { | ||||
// have we already cached the next entry ? | // have we already cached the next entry ? | ||||
if (cachedResources.size() > cusrsor) { | if (cachedResources.size() > cusrsor) { | ||||
@@ -155,7 +161,8 @@ public class LazyResourceCollectionWrapper extends | |||||
return true; | return true; | ||||
} | } | ||||
public Resource next() { | |||||
@Override | |||||
public Resource next() { | |||||
// first check that we have some to deliver | // first check that we have some to deliver | ||||
if (!hasNext()) { | if (!hasNext()) { | ||||
throw new NoSuchElementException(); | throw new NoSuchElementException(); | ||||
@@ -167,7 +174,8 @@ public class LazyResourceCollectionWrapper extends | |||||
} | } | ||||
} | } | ||||
public void remove() { | |||||
@Override | |||||
public void remove() { | |||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
} | } | ||||
@@ -46,7 +46,8 @@ public class MappedResource extends ResourceDecorator { | |||||
/** | /** | ||||
* Maps the name. | * Maps the name. | ||||
*/ | */ | ||||
public String getName() { | |||||
@Override | |||||
public String getName() { | |||||
String name = getResource().getName(); | String name = getResource().getName(); | ||||
if (isReference()) { | if (isReference()) { | ||||
return name; | return name; | ||||
@@ -59,7 +60,8 @@ public class MappedResource extends ResourceDecorator { | |||||
* Not really supported since mapper is never null. | * Not really supported since mapper is never null. | ||||
* @param r reference to set | * @param r reference to set | ||||
*/ | */ | ||||
public void setRefid(Reference r) { | |||||
@Override | |||||
public void setRefid(Reference r) { | |||||
if (mapper != null) { | if (mapper != null) { | ||||
throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
} | } | ||||
@@ -70,8 +72,9 @@ public class MappedResource extends ResourceDecorator { | |||||
* Suppress FileProvider | * Suppress FileProvider | ||||
* @param clazz the type to implement | * @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); | ? null : getResource().as(clazz); | ||||
} | } | ||||
@@ -79,7 +82,8 @@ public class MappedResource extends ResourceDecorator { | |||||
* Get the hash code for this Resource. | * Get the hash code for this Resource. | ||||
* @since Ant 1.8.1 | * @since Ant 1.8.1 | ||||
*/ | */ | ||||
public int hashCode() { | |||||
@Override | |||||
public int hashCode() { | |||||
String n = getName(); | String n = getName(); | ||||
return n == null ? super.hashCode() : n.hashCode(); | return n == null ? super.hashCode() : n.hashCode(); | ||||
} | } | ||||
@@ -89,7 +93,8 @@ public class MappedResource extends ResourceDecorator { | |||||
* resource itself. | * resource itself. | ||||
* @since Ant 1.8.1 | * @since Ant 1.8.1 | ||||
*/ | */ | ||||
public boolean equals(Object other) { | |||||
@Override | |||||
public boolean equals(Object other) { | |||||
if (other == null || !other.getClass().equals(getClass())) { | if (other == null || !other.getClass().equals(getClass())) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -100,7 +105,8 @@ public class MappedResource extends ResourceDecorator { | |||||
&& getResource().equals(m.getResource()); | && getResource().equals(m.getResource()); | ||||
} | } | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
if (isReference()) { | if (isReference()) { | ||||
return getCheckedRef().toString(); | return getCheckedRef().toString(); | ||||
} | } | ||||
@@ -43,7 +43,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
private List<File> baseDirs = new ArrayList<File>(); | private List<File> baseDirs = new ArrayList<File>(); | ||||
private Union union; | private Union union; | ||||
public void setDir(File dir) { | |||||
@Override | |||||
public void setDir(File dir) { | |||||
throw new BuildException(getDataTypeName() | throw new BuildException(getDataTypeName() | ||||
+ " doesn't support the dir attribute"); | + " doesn't support the dir attribute"); | ||||
} | } | ||||
@@ -96,7 +97,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
baseDirs.add(r.getFile()); | baseDirs.add(r.getFile()); | ||||
} | } | ||||
public void setRefid(Reference r) { | |||||
@Override | |||||
public void setRefid(Reference r) { | |||||
if (!baseDirs.isEmpty()) { | if (!baseDirs.isEmpty()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
@@ -108,7 +110,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* as this one. | * as this one. | ||||
* @return the cloned MultiRootFileSet. | * @return the cloned MultiRootFileSet. | ||||
*/ | */ | ||||
public Object clone() { | |||||
@Override | |||||
public Object clone() { | |||||
if (isReference()) { | if (isReference()) { | ||||
return ((MultiRootFileSet) getRef(getProject())).clone(); | return ((MultiRootFileSet) getRef(getProject())).clone(); | ||||
} else { | } else { | ||||
@@ -123,7 +126,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* Fulfill the ResourceCollection contract. | * Fulfill the ResourceCollection contract. | ||||
* @return an Iterator of Resources. | * @return an Iterator of Resources. | ||||
*/ | */ | ||||
public Iterator<Resource> iterator() { | |||||
@Override | |||||
public Iterator<Resource> iterator() { | |||||
if (isReference()) { | if (isReference()) { | ||||
return ((MultiRootFileSet) getRef(getProject())).iterator(); | return ((MultiRootFileSet) getRef(getProject())).iterator(); | ||||
} | } | ||||
@@ -134,7 +138,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* Fulfill the ResourceCollection contract. | * Fulfill the ResourceCollection contract. | ||||
* @return number of elements as int. | * @return number of elements as int. | ||||
*/ | */ | ||||
public int size() { | |||||
@Override | |||||
public int size() { | |||||
if (isReference()) { | if (isReference()) { | ||||
return ((MultiRootFileSet) getRef(getProject())).size(); | return ((MultiRootFileSet) getRef(getProject())).size(); | ||||
} | } | ||||
@@ -145,7 +150,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* Always returns true. | * Always returns true. | ||||
* @return true indicating that all elements will be FileResources. | * @return true indicating that all elements will be FileResources. | ||||
*/ | */ | ||||
public boolean isFilesystemOnly() { | |||||
@Override | |||||
public boolean isFilesystemOnly() { | |||||
return true; | return true; | ||||
} | } | ||||
@@ -154,7 +160,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* | * | ||||
* @return a <code>String</code> of included directories. | * @return a <code>String</code> of included directories. | ||||
*/ | */ | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
if (isReference()) { | if (isReference()) { | ||||
return ((MultiRootFileSet) getRef(getProject())).toString(); | return ((MultiRootFileSet) getRef(getProject())).toString(); | ||||
} | } | ||||
@@ -190,18 +197,20 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
implements ResourceCollection { | implements ResourceCollection { | ||||
private final SetType type; | private final SetType type; | ||||
private Worker(MultiRootFileSet fs, SetType type, File dir) { | private Worker(MultiRootFileSet fs, SetType type, File dir) { | ||||
super(fs); | super(fs); | ||||
this.type = type; | this.type = type; | ||||
setDir(dir); | setDir(dir); | ||||
} | } | ||||
public boolean isFilesystemOnly() { | |||||
@Override | |||||
public boolean isFilesystemOnly() { | |||||
return true; | return true; | ||||
} | } | ||||
public Iterator<Resource> iterator() { | |||||
@Override | |||||
public Iterator<Resource> iterator() { | |||||
DirectoryScanner ds = getDirectoryScanner(getProject()); | DirectoryScanner ds = getDirectoryScanner(getProject()); | ||||
String[] names = type == SetType.file | String[] names = type == SetType.file | ||||
? ds.getIncludedFiles() | ? ds.getIncludedFiles() | ||||
@@ -217,7 +226,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
names); | names); | ||||
} | } | ||||
public int size() { | |||||
@Override | |||||
public int size() { | |||||
DirectoryScanner ds = getDirectoryScanner(getProject()); | DirectoryScanner ds = getDirectoryScanner(getProject()); | ||||
int count = type == SetType.file | int count = type == SetType.file | ||||
? ds.getIncludedFilesCount() | ? ds.getIncludedFilesCount() | ||||
@@ -44,7 +44,7 @@ public class Type implements ResourceSelector { | |||||
* Implements the type attribute. | * Implements the type attribute. | ||||
*/ | */ | ||||
public static class FileDir extends EnumeratedAttribute { | 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. | * Default constructor. | ||||
@@ -56,7 +56,7 @@ public class Type implements ResourceSelector { | |||||
* Convenience constructor. | * Convenience constructor. | ||||
* @param value the String EnumeratedAttribute value. | * @param value the String EnumeratedAttribute value. | ||||
*/ | */ | ||||
public FileDir(String value) { | |||||
public FileDir(final String value) { | |||||
setValue(value); | setValue(value); | ||||
} | } | ||||
@@ -64,7 +64,8 @@ public class Type implements ResourceSelector { | |||||
* Return the possible values. | * Return the possible values. | ||||
* @return a String array. | * @return a String array. | ||||
*/ | */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return VALUES; | return VALUES; | ||||
} | } | ||||
} | } | ||||
@@ -81,7 +82,7 @@ public class Type implements ResourceSelector { | |||||
* Convenience constructor. | * Convenience constructor. | ||||
* @param fd the FileDir type. | * @param fd the FileDir type. | ||||
*/ | */ | ||||
public Type(FileDir fd) { | |||||
public Type(final FileDir fd) { | |||||
setType(fd); | setType(fd); | ||||
} | } | ||||
@@ -89,7 +90,7 @@ public class Type implements ResourceSelector { | |||||
* Set type; file|dir. | * Set type; file|dir. | ||||
* @param fd a FileDir object. | * @param fd a FileDir object. | ||||
*/ | */ | ||||
public void setType(FileDir fd) { | |||||
public void setType(final FileDir fd) { | |||||
type = fd; | type = fd; | ||||
} | } | ||||
@@ -98,11 +99,12 @@ public class Type implements ResourceSelector { | |||||
* @param r the Resource to check. | * @param r the Resource to check. | ||||
* @return whether the Resource was selected. | * @return whether the Resource was selected. | ||||
*/ | */ | ||||
public boolean isSelected(Resource r) { | |||||
@Override | |||||
public boolean isSelected(final Resource r) { | |||||
if (type == null) { | if (type == null) { | ||||
throw new BuildException("The type attribute is required."); | 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); | return i == 2 || (r.isDirectory() ? i == 1 : i == 0); | ||||
} | } | ||||
@@ -88,12 +88,13 @@ public abstract class MappingSelector extends BaseSelector { | |||||
} | } | ||||
this.map = fileNameMapper; | this.map = fileNameMapper; | ||||
} | } | ||||
/** | /** | ||||
* Checks to make sure all settings are kosher. In this case, it | * 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. | * means that the dest attribute has been set and we have a mapper. | ||||
*/ | */ | ||||
public void verifySettings() { | |||||
@Override | |||||
public void verifySettings() { | |||||
if (targetdir == null) { | if (targetdir == null) { | ||||
setError("The targetdir attribute is required."); | 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 | * @param file is a java.io.File object the selector can use | ||||
* @return whether the file should be selected or not | * @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 | // throw BuildException on error | ||||
validate(); | validate(); | ||||
@@ -51,8 +51,9 @@ public class PresentSelector extends BaseSelector { | |||||
/** | /** | ||||
* @return a string describing this object | * @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) { | if (targetdir == null) { | ||||
buf.append("NOT YET SET"); | buf.append("NOT YET SET"); | ||||
} else { | } else { | ||||
@@ -79,7 +80,7 @@ public class PresentSelector extends BaseSelector { | |||||
* | * | ||||
* @param targetdir the directory to scan looking for matching files. | * @param targetdir the directory to scan looking for matching files. | ||||
*/ | */ | ||||
public void setTargetdir(File targetdir) { | |||||
public void setTargetdir(final File targetdir) { | |||||
this.targetdir = targetdir; | this.targetdir = targetdir; | ||||
} | } | ||||
@@ -102,7 +103,7 @@ public class PresentSelector extends BaseSelector { | |||||
* @throws BuildException if more than one mapper defined | * @throws BuildException if more than one mapper defined | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void addConfigured(FileNameMapper fileNameMapper) { | |||||
public void addConfigured(final FileNameMapper fileNameMapper) { | |||||
if (map != null || mapperElement != null) { | if (map != null || mapperElement != null) { | ||||
throw new BuildException("Cannot define more than one mapper"); | 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 | * @param fp An attribute set to either <code>srconly</code or | ||||
* <code>both</code>. | * <code>both</code>. | ||||
*/ | */ | ||||
public void setPresent(FilePresence fp) { | |||||
public void setPresent(final FilePresence fp) { | |||||
if (fp.getIndex() == 0) { | if (fp.getIndex() == 0) { | ||||
destmustexist = false; | destmustexist = false; | ||||
} | } | ||||
@@ -131,7 +132,8 @@ public class PresentSelector extends BaseSelector { | |||||
* Checks to make sure all settings are kosher. In this case, it | * 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. | * means that the targetdir attribute has been set and we have a mapper. | ||||
*/ | */ | ||||
public void verifySettings() { | |||||
@Override | |||||
public void verifySettings() { | |||||
if (targetdir == null) { | if (targetdir == null) { | ||||
setError("The targetdir attribute is required."); | 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 | * @param file is a java.io.File object the selector can use | ||||
* @return whether the file should be selected or not | * @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 | // throw BuildException on error | ||||
validate(); | validate(); | ||||
// Determine file whose existence is to be checked | // 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 | // If filename does not match the To attribute of the mapper | ||||
// then filter it out of the files we are considering | // then filter it out of the files we are considering | ||||
if (destfiles == null) { | if (destfiles == null) { | ||||
@@ -173,8 +176,8 @@ public class PresentSelector extends BaseSelector { | |||||
throw new BuildException("Invalid destination file results for " | throw new BuildException("Invalid destination file results for " | ||||
+ targetdir + " with filename " + filename); | + 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; | return destfile.exists() == destmustexist; | ||||
} | } | ||||
@@ -186,8 +189,9 @@ public class PresentSelector extends BaseSelector { | |||||
/** | /** | ||||
* @return the values as an array of strings | * @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; | 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 | * @param path The path to tokenize. Must not be | ||||
* <code>null</code>. | * <code>null</code>. | ||||
*/ | */ | ||||
public TokenizedPath(String path) { | public TokenizedPath(String path) { | ||||
this(path, SelectorUtils.tokenizePathAsArray(path)); | this(path, SelectorUtils.tokenizePathAsArray(path)); | ||||
} | } | ||||
/** | /** | ||||
* Creates a new path as a child of another path. | * Creates a new path as a child of another path. | ||||
* | * | ||||
@@ -86,10 +86,11 @@ public class TokenizedPath { | |||||
/** | /** | ||||
* @return The original path String | * @return The original path String | ||||
*/ | */ | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
return path; | return path; | ||||
} | } | ||||
/** | /** | ||||
* The depth (or length) of a path. | * The depth (or length) of a path. | ||||
*/ | */ | ||||
@@ -160,12 +161,14 @@ public class TokenizedPath { | |||||
/** | /** | ||||
* true if the original paths are equal. | * true if the original paths are equal. | ||||
*/ | */ | ||||
public boolean equals(Object o) { | |||||
@Override | |||||
public boolean equals(Object o) { | |||||
return o instanceof TokenizedPath | return o instanceof TokenizedPath | ||||
&& path.equals(((TokenizedPath) o).path); | && path.equals(((TokenizedPath) o).path); | ||||
} | } | ||||
public int hashCode() { | |||||
@Override | |||||
public int hashCode() { | |||||
return path.hashCode(); | return path.hashCode(); | ||||
} | } | ||||
@@ -213,7 +216,7 @@ public class TokenizedPath { | |||||
* this path. | * this path. | ||||
*/ | */ | ||||
public TokenizedPattern toPattern() { | public TokenizedPattern toPattern() { | ||||
return new TokenizedPattern(path, tokenizedPath); | |||||
return new TokenizedPattern(path, tokenizedPath); | |||||
} | } | ||||
} | } |
@@ -521,7 +521,7 @@ public class DOMElementWriter { | |||||
while (prevEnd < len) { | while (prevEnd < len) { | ||||
final int end = (cdataEndPos < 0 ? len : cdataEndPos); | final int end = (cdataEndPos < 0 ? len : cdataEndPos); | ||||
// Write out stretches of legal characters in the range [prevEnd, end). | // 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; | int illegalCharPos; | ||||
for (illegalCharPos = prevLegalCharPos; true; ++illegalCharPos) { | for (illegalCharPos = prevLegalCharPos; true; ++illegalCharPos) { | ||||
if (illegalCharPos >= end | 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 | * Searching for changes (grep -r -i -n "@since 1.9" .) in the sources gave | ||||
* only one hit: a new constant in the class SourceVersion. | * only one hit: a new constant in the class SourceVersion. | ||||
* So we have to check that ... | * So we have to check that ... | ||||
* | |||||
* | |||||
* @throws Exception if we can't load the class or don't find the new constant. | * @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. | * This is the behavior when searching for new features on older versions. | ||||
* @since Ant 1.9.4 | * @since Ant 1.9.4 | ||||
@@ -109,7 +109,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
* Create a new, empty, Properties collection, with the specified defaults. | * Create a new, empty, Properties collection, with the specified defaults. | ||||
* @param defaults the default property values | * @param defaults the default property values | ||||
*/ | */ | ||||
public LayoutPreservingProperties(Properties defaults) { | |||||
public LayoutPreservingProperties(final Properties defaults) { | |||||
super(defaults); | super(defaults); | ||||
} | } | ||||
@@ -134,27 +134,30 @@ public class LayoutPreservingProperties extends Properties { | |||||
* removed when a property is removed; <code>false</code> | * removed when a property is removed; <code>false</code> | ||||
* otherwise | * otherwise | ||||
*/ | */ | ||||
public void setRemoveComments(boolean val) { | |||||
public void setRemoveComments(final boolean val) { | |||||
removeComments = 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); | 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 | // the above call will have failed if key or value are null | ||||
innerSetProperty(key.toString(), value.toString()); | innerSetProperty(key.toString(), value.toString()); | ||||
return obj; | return obj; | ||||
} | } | ||||
public Object setProperty(String key, String value) | |||||
@Override | |||||
public Object setProperty(final String key, final String value) | |||||
throws NullPointerException { | 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 | // the above call will have failed if key or value are null | ||||
innerSetProperty(key, value); | innerSetProperty(key, value); | ||||
return obj; | return obj; | ||||
@@ -172,27 +175,29 @@ public class LayoutPreservingProperties extends Properties { | |||||
value = escapeValue(value); | value = escapeValue(value); | ||||
if (keyedPairLines.containsKey(key)) { | 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); | p.setValue(value); | ||||
} else { | } else { | ||||
key = escapeName(key); | key = escapeName(key); | ||||
Pair p = new Pair(key, value); | |||||
final Pair p = new Pair(key, value); | |||||
p.setNew(true); | p.setNew(true); | ||||
keyedPairLines.put(key, new Integer(logicalLines.size())); | keyedPairLines.put(key, new Integer(logicalLines.size())); | ||||
logicalLines.add(p); | logicalLines.add(p); | ||||
} | } | ||||
} | } | ||||
public void clear() { | |||||
@Override | |||||
public void clear() { | |||||
super.clear(); | super.clear(); | ||||
keyedPairLines.clear(); | keyedPairLines.clear(); | ||||
logicalLines.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 (null != i) { | ||||
if (removeComments) { | if (removeComments) { | ||||
removeCommentsEndingAt(i.intValue()); | removeCommentsEndingAt(i.intValue()); | ||||
@@ -202,16 +207,17 @@ public class LayoutPreservingProperties extends Properties { | |||||
return obj; | return obj; | ||||
} | } | ||||
public Object clone() { | |||||
LayoutPreservingProperties dolly = | |||||
@Override | |||||
public Object clone() { | |||||
final LayoutPreservingProperties dolly = | |||||
(LayoutPreservingProperties) super.clone(); | (LayoutPreservingProperties) super.clone(); | ||||
dolly.keyedPairLines = (HashMap) this.keyedPairLines.clone(); | dolly.keyedPairLines = (HashMap) this.keyedPairLines.clone(); | ||||
dolly.logicalLines = (ArrayList) this.logicalLines.clone(); | dolly.logicalLines = (ArrayList) this.logicalLines.clone(); | ||||
final int size = dolly.logicalLines.size(); | final int size = dolly.logicalLines.size(); | ||||
for (int j = 0; j < size; j++) { | 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) { | if (line instanceof Pair) { | ||||
Pair p = (Pair) line; | |||||
final Pair p = (Pair) line; | |||||
dolly.logicalLines.set(j, p.clone()); | dolly.logicalLines.set(j, p.clone()); | ||||
} | } | ||||
// no reason to clone other lines are they are immutable | // no reason to clone other lines are they are immutable | ||||
@@ -224,11 +230,11 @@ public class LayoutPreservingProperties extends Properties { | |||||
* stream. | * stream. | ||||
* @param out the stream to write to | * @param out the stream to write to | ||||
*/ | */ | ||||
public void listLines(PrintStream out) { | |||||
public void listLines(final PrintStream out) { | |||||
out.println("-- logical lines --"); | out.println("-- logical lines --"); | ||||
Iterator i = logicalLines.iterator(); | |||||
final Iterator i = logicalLines.iterator(); | |||||
while (i.hasNext()) { | while (i.hasNext()) { | ||||
LogicalLine line = (LogicalLine) i.next(); | |||||
final LogicalLine line = (LogicalLine) i.next(); | |||||
if (line instanceof Blank) { | if (line instanceof Blank) { | ||||
out.println("blank: \"" + line + "\""); | out.println("blank: \"" + line + "\""); | ||||
} else if (line instanceof Comment) { | } else if (line instanceof Comment) { | ||||
@@ -243,17 +249,18 @@ public class LayoutPreservingProperties extends Properties { | |||||
* Save the properties to a file. | * Save the properties to a file. | ||||
* @param dest the file to write to | * @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); | store(fos, null); | ||||
fos.close(); | 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 skipLines = 0; | ||||
int totalLines = logicalLines.size(); | |||||
final int totalLines = logicalLines.size(); | |||||
if (header != null) { | if (header != null) { | ||||
osw.write("#" + header + LS); | osw.write("#" + header + LS); | ||||
@@ -274,16 +281,16 @@ public class LayoutPreservingProperties extends Properties { | |||||
.get(skipLines) | .get(skipLines) | ||||
.toString().substring(1)); | .toString().substring(1)); | ||||
skipLines++; | skipLines++; | ||||
} catch (java.text.ParseException pe) { | |||||
} catch (final java.text.ParseException pe) { | |||||
// not an existing date comment | // not an existing date comment | ||||
} | } | ||||
} | } | ||||
osw.write("#" + DateUtils.getDateForHeader() + LS); | osw.write("#" + DateUtils.getDateForHeader() + LS); | ||||
boolean writtenSep = false; | 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 (line instanceof Pair) { | ||||
if (((Pair)line).isNew()) { | if (((Pair)line).isNew()) { | ||||
if (!writtenSep) { | if (!writtenSep) { | ||||
@@ -306,9 +313,9 @@ public class LayoutPreservingProperties extends Properties { | |||||
* file. | * file. | ||||
* @param is the stream from which to read the data | * @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) { | if (logicalLines.size() > 0) { | ||||
// we add a blank line for spacing | // we add a blank line for spacing | ||||
@@ -316,12 +323,12 @@ public class LayoutPreservingProperties extends Properties { | |||||
} | } | ||||
String s = readFirstLine(pbr); | String s = readFirstLine(pbr); | ||||
BufferedReader br = new BufferedReader(pbr); | |||||
final BufferedReader br = new BufferedReader(pbr); | |||||
boolean continuation = false; | boolean continuation = false; | ||||
boolean comment = 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) { | while (s != null) { | ||||
fileBuffer.append(s).append(LS); | fileBuffer.append(s).append(LS); | ||||
@@ -349,7 +356,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
line = new Blank(); | line = new Blank(); | ||||
} else { | } else { | ||||
line = new Pair(logicalLineBuffer.toString()); | line = new Pair(logicalLineBuffer.toString()); | ||||
String key = unescape(((Pair)line).getName()); | |||||
final String key = unescape(((Pair)line).getName()); | |||||
if (keyedPairLines.containsKey(key)) { | if (keyedPairLines.containsKey(key)) { | ||||
// this key is already present, so we remove it and add | // this key is already present, so we remove it and add | ||||
// the new one | // the new one | ||||
@@ -376,8 +383,8 @@ public class LayoutPreservingProperties extends Properties { | |||||
* | * | ||||
* @since Ant 1.8.2 | * @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(); | int ch = r.read(); | ||||
boolean hasCR = false; | boolean hasCR = false; | ||||
// when reaching EOF before the first EOL, assume native line | // 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, | * @return <code>true</code> if the line is to be continued, | ||||
* <code>false</code> otherwise | * <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; | int i = ca.length - 1; | ||||
while (i > 0 && ca[i] == '\\') { | while (i > 0 && ca[i] == '\\') { | ||||
i--; | i--; | ||||
} | } | ||||
// trailing backslashes | // trailing backslashes | ||||
int tb = ca.length - i - 1; | |||||
final int tb = ca.length - i - 1; | |||||
return tb % 2 == 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) | * @param s the string to unescape (coming from the source file) | ||||
* @return the unescaped string | * @return the unescaped string | ||||
*/ | */ | ||||
private String unescape(String s) { | |||||
private String unescape(final String s) { | |||||
/* | /* | ||||
* The following combinations are converted: | * The following combinations are converted: | ||||
* \n newline | * \n newline | ||||
@@ -444,10 +451,10 @@ public class LayoutPreservingProperties extends Properties { | |||||
* \b becomes 'b'. | * \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); | s.getChars(0, s.length(), ch, 0); | ||||
ch[s.length()] = '\n'; | 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++) { | for (int i = 0; i < ch.length; i++) { | ||||
char c = ch[i]; | char c = ch[i]; | ||||
if (c == '\n') { | if (c == '\n') { | ||||
@@ -485,8 +492,8 @@ public class LayoutPreservingProperties extends Properties { | |||||
* @param ch the character array containing the unicode character code | * @param ch the character array containing the unicode character code | ||||
* @return the character extracted | * @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); | return (char) Integer.parseInt(s, 16); | ||||
} | } | ||||
@@ -497,7 +504,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
* @param s the string to escape | * @param s the string to escape | ||||
* @return the escaped string | * @return the escaped string | ||||
*/ | */ | ||||
private String escapeValue(String s) { | |||||
private String escapeValue(final String s) { | |||||
return escape(s, false); | return escape(s, false); | ||||
} | } | ||||
@@ -510,7 +517,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
* @param s the string to escape | * @param s the string to escape | ||||
* @return the escaped string | * @return the escaped string | ||||
*/ | */ | ||||
private String escapeName(String s) { | |||||
private String escapeName(final String s) { | |||||
return escape(s, true); | return escape(s, true); | ||||
} | } | ||||
@@ -524,19 +531,19 @@ public class LayoutPreservingProperties extends Properties { | |||||
* leading whitespace | * leading whitespace | ||||
* @return the escaped string | * @return the escaped string | ||||
*/ | */ | ||||
private String escape(String s, boolean escapeAllSpaces) { | |||||
private String escape(final String s, final boolean escapeAllSpaces) { | |||||
if (s == null) { | if (s == null) { | ||||
return null; | return null; | ||||
} | } | ||||
char[] ch = new char[s.length()]; | |||||
final char[] ch = new char[s.length()]; | |||||
s.getChars(0, s.length(), ch, 0); | 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; | boolean leadingSpace = true; | ||||
for (int i = 0; i < ch.length; i++) { | for (int i = 0; i < ch.length; i++) { | ||||
char c = ch[i]; | |||||
final char c = ch[i]; | |||||
if (c == ' ') { | if (c == ' ') { | ||||
if (escapeAllSpaces || leadingSpace) { | if (escapeAllSpaces || leadingSpace) { | ||||
buffy.append("\\"); | buffy.append("\\"); | ||||
@@ -544,7 +551,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
} else { | } else { | ||||
leadingSpace = false; | leadingSpace = false; | ||||
} | } | ||||
int p = forEscaping.indexOf(c); | |||||
final int p = forEscaping.indexOf(c); | |||||
if (p != -1) { | if (p != -1) { | ||||
buffy.append("\\").append(escaped.substring(p,p+1)); | buffy.append("\\").append(escaped.substring(p,p+1)); | ||||
} else if (c < 0x0020 || c > 0x007e) { | } else if (c < 0x0020 || c > 0x007e) { | ||||
@@ -562,7 +569,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
* @param ch the character to encode | * @param ch the character to encode | ||||
* @return the unicode escape sequence | * @return the unicode escape sequence | ||||
*/ | */ | ||||
private String escapeUnicode(char ch) { | |||||
private String escapeUnicode(final char ch) { | |||||
return "\\" + UnicodeUtil.EscapeUnicode(ch); | return "\\" + UnicodeUtil.EscapeUnicode(ch); | ||||
} | } | ||||
@@ -580,7 +587,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
* B1. | * B1. | ||||
*/ | */ | ||||
int end = pos - 1; | |||||
final int end = pos - 1; | |||||
// step pos back until it hits something non-blank | // step pos back until it hits something non-blank | ||||
for (pos = end; pos > 0; pos--) { | 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 | // now we want to delete from pos+1 to end | ||||
for (pos++ ;pos <= end; pos++) { | |||||
for (pos++; pos <= end; pos++) { | |||||
logicalLines.set(pos, null); | logicalLines.set(pos, null); | ||||
} | } | ||||
} | } | ||||
@@ -611,18 +618,19 @@ public class LayoutPreservingProperties extends Properties { | |||||
/** | /** | ||||
* A logical line of the properties input stream. | * A logical line of the properties input stream. | ||||
*/ | */ | ||||
private static abstract class LogicalLine { | |||||
private abstract static class LogicalLine { | |||||
private String text; | private String text; | ||||
public LogicalLine(String text) { | |||||
public LogicalLine(final String text) { | |||||
this.text = text; | this.text = text; | ||||
} | } | ||||
public void setText(String text) { | |||||
public void setText(final String text) { | |||||
this.text = text; | this.text = text; | ||||
} | } | ||||
public String toString() { | |||||
@Override | |||||
public String toString() { | |||||
return text; | return text; | ||||
} | } | ||||
} | } | ||||
@@ -640,7 +648,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
* A comment line of the input stream. | * A comment line of the input stream. | ||||
*/ | */ | ||||
private class Comment extends LogicalLine { | private class Comment extends LogicalLine { | ||||
public Comment(String text) { | |||||
public Comment(final String text) { | |||||
super(text); | super(text); | ||||
} | } | ||||
} | } | ||||
@@ -655,12 +663,12 @@ public class LayoutPreservingProperties extends Properties { | |||||
private String value; | private String value; | ||||
private boolean added; | private boolean added; | ||||
public Pair(String text) { | |||||
public Pair(final String text) { | |||||
super(text); | super(text); | ||||
parsePair(text); | parsePair(text); | ||||
} | } | ||||
public Pair(String name, String value) { | |||||
public Pair(final String name, final String value) { | |||||
this(name + "=" + value); | this(name + "=" + value); | ||||
} | } | ||||
@@ -672,7 +680,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
return value; | return value; | ||||
} | } | ||||
public void setValue(String value) { | |||||
public void setValue(final String value) { | |||||
this.value = value; | this.value = value; | ||||
setText(name + "=" + value); | setText(name + "=" + value); | ||||
} | } | ||||
@@ -681,24 +689,25 @@ public class LayoutPreservingProperties extends Properties { | |||||
return added; | return added; | ||||
} | } | ||||
public void setNew(boolean val) { | |||||
public void setNew(final boolean val) { | |||||
added = val; | added = val; | ||||
} | } | ||||
public Object clone() { | |||||
@Override | |||||
public Object clone() { | |||||
Object dolly = null; | Object dolly = null; | ||||
try { | try { | ||||
dolly = super.clone(); | dolly = super.clone(); | ||||
} catch (CloneNotSupportedException e) { | |||||
} catch (final CloneNotSupportedException e) { | |||||
// should be fine | // should be fine | ||||
e.printStackTrace(); | e.printStackTrace(); | ||||
} | } | ||||
return dolly; | return dolly; | ||||
} | } | ||||
private void parsePair(String text) { | |||||
private void parsePair(final String text) { | |||||
// need to find first non-escaped '=', ':', '\t' or ' '. | // need to find first non-escaped '=', ':', '\t' or ' '. | ||||
int pos = findFirstSeparator(text); | |||||
final int pos = findFirstSeparator(text); | |||||
if (pos == -1) { | if (pos == -1) { | ||||
// trim leading whitespace only | // trim leading whitespace only | ||||
name = text; | name = text; | ||||
@@ -711,7 +720,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
name = stripStart(name, " \t\f"); | name = stripStart(name, " \t\f"); | ||||
} | } | ||||
private String stripStart(String s, String chars) { | |||||
private String stripStart(final String s, final String chars) { | |||||
if (s == null) { | if (s == null) { | ||||
return null; | return null; | ||||
} | } | ||||
@@ -745,14 +754,14 @@ public class LayoutPreservingProperties extends Properties { | |||||
return indexOfAny(s, " :=\t"); | 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) { | if (s == null || chars == null) { | ||||
return -1; | return -1; | ||||
} | } | ||||
int p = s.length() + 1; | int p = s.length() + 1; | ||||
for (int i = 0; i < chars.length(); i++) { | 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) { | if (x != -1 && x < p) { | ||||
p = x; | p = x; | ||||
} | } | ||||
@@ -50,7 +50,8 @@ public abstract class LineOrientedOutputStream extends OutputStream { | |||||
* @param cc data to log (byte). | * @param cc data to log (byte). | ||||
* @throws IOException if there is an error. | * @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; | final byte c = (byte) cc; | ||||
if ((c == LF) || (c == CR)) { | if ((c == LF) || (c == CR)) { | ||||
if (!skip) { | if (!skip) { | ||||
@@ -66,7 +67,8 @@ public abstract class LineOrientedOutputStream extends OutputStream { | |||||
* Flush this log stream | * Flush this log stream | ||||
* @throws IOException if there is an error. | * @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 | * Writes all remaining | ||||
* @throws IOException if there is an error. | * @throws IOException if there is an error. | ||||
*/ | */ | ||||
public void close() throws IOException { | |||||
@Override | |||||
public void close() throws IOException { | |||||
if (buffer.size() > 0) { | if (buffer.size() > 0) { | ||||
processBuffer(); | processBuffer(); | ||||
} | } | ||||
@@ -127,7 +130,8 @@ public abstract class LineOrientedOutputStream extends OutputStream { | |||||
* | * | ||||
* @throws IOException if the data cannot be written into the stream. | * @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 | // find the line breaks and pass other chars through in blocks | ||||
int offset = off; | int offset = off; | ||||
int blockStartOffset = offset; | 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 | * 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 | * is particularly useful in combination with the OutputStreamFunneler so each | ||||
* funneled stream get its line. | * funneled stream get its line. | ||||
* | |||||
* | |||||
* @since Ant 1.8.3 | * @since Ant 1.8.3 | ||||
*/ | */ | ||||
public class LineOrientedOutputStreamRedirector | public class LineOrientedOutputStreamRedirector | ||||
extends | |||||
LineOrientedOutputStream { | |||||
extends LineOrientedOutputStream { | |||||
private OutputStream stream; | private OutputStream stream; | ||||
// these should be in the ASCII range and hopefully are single bytes | // these should be in the ASCII range and hopefully are single bytes | ||||
@@ -42,22 +42,26 @@ public class LineOrientedOutputStreamRedirector | |||||
public LineOrientedOutputStreamRedirector(OutputStream stream) { | public LineOrientedOutputStreamRedirector(OutputStream stream) { | ||||
this.stream = stream; | this.stream = stream; | ||||
} | } | ||||
protected void processLine(byte[] b) throws IOException { | |||||
@Override | |||||
protected void processLine(byte[] b) throws IOException { | |||||
stream.write(b); | stream.write(b); | ||||
stream.write(EOL); | 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()); | stream.write((line + System.getProperty("line.separator")).getBytes()); | ||||
} | } | ||||
public void close() throws IOException { | |||||
@Override | |||||
public void close() throws IOException { | |||||
super.close(); | super.close(); | ||||
stream.close(); | stream.close(); | ||||
} | } | ||||
public void flush() throws IOException { | |||||
@Override | |||||
public void flush() throws IOException { | |||||
super.flush(); | super.flush(); | ||||
stream.flush(); | stream.flush(); | ||||
} | } | ||||
@@ -88,10 +88,10 @@ public class ResourceUtils { | |||||
* copied or processed, because the targets are out of date or do | * copied or processed, because the targets are out of date or do | ||||
* not exist. | * 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, | return selectOutOfDateSources(logTo, source, mapper, targets, | ||||
FILE_UTILS.getFileTimestampGranularity()); | FILE_UTILS.getFileTimestampGranularity()); | ||||
} | } | ||||
@@ -113,14 +113,14 @@ public class ResourceUtils { | |||||
* not exist. | * not exist. | ||||
* @since Ant 1.6.2 | * @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)); | u.addAll(Arrays.asList(source)); | ||||
ResourceCollection rc | |||||
final ResourceCollection rc | |||||
= selectOutOfDateSources(logTo, u, mapper, targets, granularity); | = selectOutOfDateSources(logTo, u, mapper, targets, granularity); | ||||
return rc.size() == 0 ? new Resource[0] : ((Union) rc).listResources(); | return rc.size() == 0 ? new Resource[0] : ((Union) rc).listResources(); | ||||
} | } | ||||
@@ -137,18 +137,20 @@ public class ResourceUtils { | |||||
* @return ResourceCollection. | * @return ResourceCollection. | ||||
* @since Ant 1.7 | * @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) { | final long granularity) { | ||||
logFuture(logTo, source, granularity); | logFuture(logTo, source, granularity); | ||||
ResourceSelectorProvider p = | |||||
final ResourceSelectorProvider p = | |||||
new ResourceSelectorProvider() { | new ResourceSelectorProvider() { | ||||
public ResourceSelector | |||||
@Override | |||||
public ResourceSelector | |||||
getTargetSelectorForSource(final Resource sr) { | getTargetSelectorForSource(final Resource sr) { | ||||
return new ResourceSelector() { | return new ResourceSelector() { | ||||
public boolean isSelected(Resource target) { | |||||
@Override | |||||
public boolean isSelected(final Resource target) { | |||||
/* Extra I/O, probably wasted: | /* Extra I/O, probably wasted: | ||||
if (target.isDirectory()) { | if (target.isDirectory()) { | ||||
return false; | return false; | ||||
@@ -166,7 +168,7 @@ public class ResourceUtils { | |||||
/** | /** | ||||
* Tells which sources should be reprocessed because the given | * Tells which sources should be reprocessed because the given | ||||
* selector selects at least one target. | * selector selects at least one target. | ||||
* | |||||
* | |||||
* @param logTo where to send (more or less) interesting output. | * @param logTo where to send (more or less) interesting output. | ||||
* @param source ResourceCollection. | * @param source ResourceCollection. | ||||
* @param mapper filename mapper indicating how to find the target Resources. | * @param mapper filename mapper indicating how to find the target Resources. | ||||
@@ -177,19 +179,19 @@ public class ResourceUtils { | |||||
* @return ResourceCollection. | * @return ResourceCollection. | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public static ResourceCollection selectSources(ProjectComponent logTo, | |||||
public static ResourceCollection selectSources(final ProjectComponent logTo, | |||||
ResourceCollection source, | ResourceCollection source, | ||||
FileNameMapper mapper, | |||||
ResourceFactory targets, | |||||
ResourceSelectorProvider selector) { | |||||
final FileNameMapper mapper, | |||||
final ResourceFactory targets, | |||||
final ResourceSelectorProvider selector) { | |||||
if (source.size() == 0) { | if (source.size() == 0) { | ||||
logTo.log("No sources found.", Project.MSG_VERBOSE); | logTo.log("No sources found.", Project.MSG_VERBOSE); | ||||
return Resources.NONE; | return Resources.NONE; | ||||
} | } | ||||
source = Union.getInstance(source); | 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(); | String srName = sr.getName(); | ||||
srName = srName == null | srName = srName == null | ||||
? srName : srName.replace('/', File.separatorChar); | ? srName : srName.replace('/', File.separatorChar); | ||||
@@ -197,7 +199,7 @@ public class ResourceUtils { | |||||
String[] targetnames = null; | String[] targetnames = null; | ||||
try { | try { | ||||
targetnames = mapper.mapFileName(srName); | targetnames = mapper.mapFileName(srName); | ||||
} catch (Exception e) { | |||||
} catch (final Exception e) { | |||||
logTo.log("Caught " + e + " mapping resource " + sr, | logTo.log("Caught " + e + " mapping resource " + sr, | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
} | } | ||||
@@ -211,18 +213,18 @@ public class ResourceUtils { | |||||
targetnames[i] = "(no name)"; | targetnames[i] = "(no name)"; | ||||
} | } | ||||
} | } | ||||
Union targetColl = new Union(); | |||||
final Union targetColl = new Union(); | |||||
for (int i = 0; i < targetnames.length; i++) { | for (int i = 0; i < targetnames.length; i++) { | ||||
targetColl.add(targets.getResource( | targetColl.add(targets.getResource( | ||||
targetnames[i].replace(File.separatorChar, '/'))); | targetnames[i].replace(File.separatorChar, '/'))); | ||||
} | } | ||||
//find the out-of-date targets: | //find the out-of-date targets: | ||||
Restrict r = new Restrict(); | |||||
final Restrict r = new Restrict(); | |||||
r.add(selector.getTargetSelectorForSource(sr)); | r.add(selector.getTargetSelectorForSource(sr)); | ||||
r.add(targetColl); | r.add(targetColl); | ||||
if (r.size() > 0) { | if (r.size() > 0) { | ||||
result.add(sr); | result.add(sr); | ||||
Resource t = r.iterator().next(); | |||||
final Resource t = r.iterator().next(); | |||||
logTo.log(sr.getName() + " added as " + t.getName() | logTo.log(sr.getName() + " added as " + t.getName() | ||||
+ (t.isExists() ? " is outdated." : " doesn\'t exist."), | + (t.isExists() ? " is outdated." : " doesn\'t exist."), | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
@@ -250,7 +252,7 @@ public class ResourceUtils { | |||||
* | * | ||||
* @since Ant 1.7 | * @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); | copyResource(source, dest, null); | ||||
} | } | ||||
@@ -268,7 +270,7 @@ public class ResourceUtils { | |||||
* | * | ||||
* @since Ant 1.7 | * @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 { | throws IOException { | ||||
copyResource(source, dest, null, null, false, | copyResource(source, dest, null, null, false, | ||||
false, null, null, project); | false, null, null, project); | ||||
@@ -301,11 +303,11 @@ public class ResourceUtils { | |||||
* | * | ||||
* @since Ant 1.7 | * @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 { | throws IOException { | ||||
copyResource(source, dest, filters, filterChains, overwrite, preserveLastModified, false, inputEncoding, outputEncoding, project); | copyResource(source, dest, filters, filterChains, overwrite, preserveLastModified, false, inputEncoding, outputEncoding, project); | ||||
} | } | ||||
@@ -338,12 +340,12 @@ public class ResourceUtils { | |||||
* | * | ||||
* @since Ant 1.8 | * @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 { | throws IOException { | ||||
copyResource(source, dest, filters, filterChains, overwrite, | copyResource(source, dest, filters, filterChains, overwrite, | ||||
preserveLastModified, append, inputEncoding, | preserveLastModified, append, inputEncoding, | ||||
@@ -378,12 +380,12 @@ public class ResourceUtils { | |||||
* | * | ||||
* @since Ant 1.8.2 | * @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 { | throws IOException { | ||||
if (!(overwrite || SelectorUtils.isOutOfDate(source, dest, FileUtils.getFileUtils() | if (!(overwrite || SelectorUtils.isOutOfDate(source, dest, FileUtils.getFileUtils() | ||||
.getFileTimestampGranularity()))) { | .getFileTimestampGranularity()))) { | ||||
@@ -429,12 +431,12 @@ public class ResourceUtils { | |||||
boolean copied = false; | boolean copied = false; | ||||
if (source.as(FileProvider.class) != null | if (source.as(FileProvider.class) != null | ||||
&& destFile != null && !append) { | && destFile != null && !append) { | ||||
File sourceFile = | |||||
final File sourceFile = | |||||
source.as(FileProvider.class).getFile(); | source.as(FileProvider.class).getFile(); | ||||
try { | try { | ||||
copyUsingFileChannels(sourceFile, destFile); | copyUsingFileChannels(sourceFile, destFile); | ||||
copied = true; | copied = true; | ||||
} catch (IOException ex) { | |||||
} catch (final IOException ex) { | |||||
project.log("Attempt to copy " + sourceFile | project.log("Attempt to copy " + sourceFile | ||||
+ " to " + destFile + " using NIO Channels" | + " to " + destFile + " using NIO Channels" | ||||
+ " failed due to '" + ex.getMessage() | + " failed due to '" + ex.getMessage() | ||||
@@ -447,7 +449,7 @@ public class ResourceUtils { | |||||
} | } | ||||
} | } | ||||
if (preserveLastModified) { | if (preserveLastModified) { | ||||
Touchable t = dest.as(Touchable.class); | |||||
final Touchable t = dest.as(Touchable.class); | |||||
if (t != null) { | if (t != null) { | ||||
setLastModified(t, source.getLastModified()); | setLastModified(t, source.getLastModified()); | ||||
} | } | ||||
@@ -464,7 +466,7 @@ public class ResourceUtils { | |||||
* if this is -1, the current time is used. | * if this is -1, the current time is used. | ||||
* @since Ant 1.7 | * @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); | t.touch((time < 0) ? System.currentTimeMillis() : time); | ||||
} | } | ||||
@@ -481,7 +483,7 @@ public class ResourceUtils { | |||||
* @throws IOException if the Resources cannot be read. | * @throws IOException if the Resources cannot be read. | ||||
* @since Ant 1.7 | * @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()) { | if (r1.isExists() != r2.isExists()) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -499,8 +501,8 @@ public class ResourceUtils { | |||||
return true; | return true; | ||||
} | } | ||||
if (!text) { | 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 | if (s1 != Resource.UNKNOWN_SIZE && s2 != Resource.UNKNOWN_SIZE | ||||
&& s1 != s2) { | && s1 != s2) { | ||||
return false; | return false; | ||||
@@ -522,20 +524,20 @@ public class ResourceUtils { | |||||
* @throws IOException if the Resources cannot be read. | * @throws IOException if the Resources cannot be read. | ||||
* @since Ant 1.7 | * @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)) { | if (r1.equals(r2)) { | ||||
return 0; | return 0; | ||||
} | } | ||||
boolean e1 = r1.isExists(); | |||||
boolean e2 = r2.isExists(); | |||||
final boolean e1 = r1.isExists(); | |||||
final boolean e2 = r2.isExists(); | |||||
if (!(e1 || e2)) { | if (!(e1 || e2)) { | ||||
return 0; | return 0; | ||||
} | } | ||||
if (e1 != e2) { | if (e1 != e2) { | ||||
return e1 ? 1 : -1; | 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) { | if (d1 && d2) { | ||||
return 0; | return 0; | ||||
} | } | ||||
@@ -554,11 +556,11 @@ public class ResourceUtils { | |||||
* FileResource with fileProvider's file. | * FileResource with fileProvider's file. | ||||
* @since Ant 1.8 | * @since Ant 1.8 | ||||
*/ | */ | ||||
public static FileResource asFileResource(FileProvider fileProvider) { | |||||
public static FileResource asFileResource(final FileProvider fileProvider) { | |||||
if (fileProvider instanceof FileResource || fileProvider == null) { | if (fileProvider instanceof FileResource || fileProvider == null) { | ||||
return (FileResource) fileProvider; | return (FileResource) fileProvider; | ||||
} | } | ||||
FileResource result = new FileResource(fileProvider.getFile()); | |||||
final FileResource result = new FileResource(fileProvider.getFile()); | |||||
result.setProject(Project.getProject(fileProvider)); | result.setProject(Project.getProject(fileProvider)); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -578,7 +580,7 @@ public class ResourceUtils { | |||||
* @throws IOException if the Resources cannot be read. | * @throws IOException if the Resources cannot be read. | ||||
* @since Ant 1.7 | * @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 in1 = null; | ||||
InputStream in2 = null; | InputStream in2 = null; | ||||
try { | try { | ||||
@@ -586,7 +588,7 @@ public class ResourceUtils { | |||||
in2 = new BufferedInputStream(r2.getInputStream()); | in2 = new BufferedInputStream(r2.getInputStream()); | ||||
for (int b1 = in1.read(); b1 != -1; b1 = in1.read()) { | for (int b1 = in1.read(); b1 != -1; b1 = in1.read()) { | ||||
int b2 = in2.read(); | |||||
final int b2 = in2.read(); | |||||
if (b1 != b2) { | if (b1 != b2) { | ||||
return b1 > b2 ? 1 : -1; | return b1 > b2 ? 1 : -1; | ||||
} | } | ||||
@@ -608,7 +610,7 @@ public class ResourceUtils { | |||||
* @throws IOException if the Resources cannot be read. | * @throws IOException if the Resources cannot be read. | ||||
* @since Ant 1.7 | * @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 in1 = null; | ||||
BufferedReader in2 = null; | BufferedReader in2 = null; | ||||
try { | try { | ||||
@@ -617,7 +619,7 @@ public class ResourceUtils { | |||||
String expected = in1.readLine(); | String expected = in1.readLine(); | ||||
while (expected != null) { | while (expected != null) { | ||||
String actual = in2.readLine(); | |||||
final String actual = in2.readLine(); | |||||
if (!expected.equals(actual)) { | if (!expected.equals(actual)) { | ||||
if (actual == null) { | if (actual == null) { | ||||
return 1; | return 1; | ||||
@@ -640,27 +642,27 @@ public class ResourceUtils { | |||||
* @param granularity the timestamp granularity to use. | * @param granularity the timestamp granularity to use. | ||||
* @since Ant 1.7 | * @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.setMillis(now); | ||||
sel.setWhen(TimeComparison.AFTER); | sel.setWhen(TimeComparison.AFTER); | ||||
Restrict future = new Restrict(); | |||||
final Restrict future = new Restrict(); | |||||
future.add(sel); | future.add(sel); | ||||
future.add(rc); | future.add(rc); | ||||
for (Resource r : future) { | |||||
for (final Resource r : future) { | |||||
logTo.log("Warning: " + r.getName() + " modified in the future.", Project.MSG_WARN); | 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 { | throws IOException { | ||||
BufferedReader in = null; | BufferedReader in = null; | ||||
BufferedWriter out = null; | BufferedWriter out = null; | ||||
@@ -673,7 +675,7 @@ public class ResourceUtils { | |||||
inputEncoding); | inputEncoding); | ||||
} | } | ||||
in = new BufferedReader(isr); | in = new BufferedReader(isr); | ||||
OutputStream os = getOutputStream(dest, append, project); | |||||
final OutputStream os = getOutputStream(dest, append, project); | |||||
OutputStreamWriter osw; | OutputStreamWriter osw; | ||||
if (outputEncoding == null) { | if (outputEncoding == null) { | ||||
osw = new OutputStreamWriter(os); | osw = new OutputStreamWriter(os); | ||||
@@ -682,15 +684,15 @@ public class ResourceUtils { | |||||
} | } | ||||
out = new BufferedWriter(osw); | out = new BufferedWriter(osw); | ||||
if (filterChainsAvailable) { | if (filterChainsAvailable) { | ||||
ChainReaderHelper crh = new ChainReaderHelper(); | |||||
final ChainReaderHelper crh = new ChainReaderHelper(); | |||||
crh.setBufferSize(FileUtils.BUF_SIZE); | crh.setBufferSize(FileUtils.BUF_SIZE); | ||||
crh.setPrimaryReader(in); | crh.setPrimaryReader(in); | ||||
crh.setFilterChains(filterChains); | crh.setFilterChains(filterChains); | ||||
crh.setProject(project); | crh.setProject(project); | ||||
Reader rdr = crh.getAssembledReader(); | |||||
final Reader rdr = crh.getAssembledReader(); | |||||
in = new BufferedReader(rdr); | in = new BufferedReader(rdr); | ||||
} | } | ||||
LineTokenizer lineTokenizer = new LineTokenizer(); | |||||
final LineTokenizer lineTokenizer = new LineTokenizer(); | |||||
lineTokenizer.setIncludeDelims(true); | lineTokenizer.setIncludeDelims(true); | ||||
String newline = null; | String newline = null; | ||||
String line = lineTokenizer.getToken(in); | 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 { | throws IOException { | ||||
BufferedReader in = null; | BufferedReader in = null; | ||||
BufferedWriter out = null; | BufferedWriter out = null; | ||||
@@ -731,7 +733,7 @@ public class ResourceUtils { | |||||
inputEncoding); | inputEncoding); | ||||
} | } | ||||
in = new BufferedReader(isr); | in = new BufferedReader(isr); | ||||
OutputStream os = getOutputStream(dest, append, project); | |||||
final OutputStream os = getOutputStream(dest, append, project); | |||||
OutputStreamWriter osw; | OutputStreamWriter osw; | ||||
if (outputEncoding == null) { | if (outputEncoding == null) { | ||||
osw = new OutputStreamWriter(os); | osw = new OutputStreamWriter(os); | ||||
@@ -740,17 +742,17 @@ public class ResourceUtils { | |||||
} | } | ||||
out = new BufferedWriter(osw); | out = new BufferedWriter(osw); | ||||
if (filterChainsAvailable) { | if (filterChainsAvailable) { | ||||
ChainReaderHelper crh = new ChainReaderHelper(); | |||||
final ChainReaderHelper crh = new ChainReaderHelper(); | |||||
crh.setBufferSize(FileUtils.BUF_SIZE); | crh.setBufferSize(FileUtils.BUF_SIZE); | ||||
crh.setPrimaryReader(in); | crh.setPrimaryReader(in); | ||||
crh.setFilterChains(filterChains); | crh.setFilterChains(filterChains); | ||||
crh.setProject(project); | crh.setProject(project); | ||||
Reader rdr = crh.getAssembledReader(); | |||||
final Reader rdr = crh.getAssembledReader(); | |||||
in = new BufferedReader(rdr); | in = new BufferedReader(rdr); | ||||
} | } | ||||
char[] buffer = new char[FileUtils.BUF_SIZE]; | |||||
final char[] buffer = new char[FileUtils.BUF_SIZE]; | |||||
while (true) { | while (true) { | ||||
int nRead = in.read(buffer, 0, buffer.length); | |||||
final int nRead = in.read(buffer, 0, buffer.length); | |||||
if (nRead == -1) { | if (nRead == -1) { | ||||
break; | 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 { | throws IOException { | ||||
File parent = destFile.getParentFile(); | |||||
final File parent = destFile.getParentFile(); | |||||
if (parent != null && !parent.isDirectory() | if (parent != null && !parent.isDirectory() | ||||
&& !(parent.mkdirs() || parent.isDirectory())) { | && !(parent.mkdirs() || parent.isDirectory())) { | ||||
throw new IOException("failed to create the parent directory" | throw new IOException("failed to create the parent directory" | ||||
@@ -781,14 +783,14 @@ public class ResourceUtils { | |||||
try { | try { | ||||
in = new FileInputStream(sourceFile); | in = new FileInputStream(sourceFile); | ||||
out = new FileOutputStream(destFile); | out = new FileOutputStream(destFile); | ||||
srcChannel = in.getChannel(); | srcChannel = in.getChannel(); | ||||
destChannel = out.getChannel(); | destChannel = out.getChannel(); | ||||
long position = 0; | long position = 0; | ||||
long count = srcChannel.size(); | |||||
final long count = srcChannel.size(); | |||||
while (position < count) { | 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 += | position += | ||||
destChannel.transferFrom(srcChannel, position, chunk); | 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 { | throws IOException { | ||||
InputStream in = null; | InputStream in = null; | ||||
OutputStream out = null; | OutputStream out = null; | ||||
@@ -809,7 +811,7 @@ public class ResourceUtils { | |||||
in = source.getInputStream(); | in = source.getInputStream(); | ||||
out = getOutputStream(dest, append, project); | out = getOutputStream(dest, append, project); | ||||
byte[] buffer = new byte[FileUtils.BUF_SIZE]; | |||||
final byte[] buffer = new byte[FileUtils.BUF_SIZE]; | |||||
int count = 0; | int count = 0; | ||||
do { | do { | ||||
out.write(buffer, 0, count); | 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 { | throws IOException { | ||||
if (append) { | if (append) { | ||||
Appendable a = resource.as(Appendable.class); | |||||
final Appendable a = resource.as(Appendable.class); | |||||
if (a != null) { | if (a != null) { | ||||
return a.getAppendOutputStream(); | return a.getAppendOutputStream(); | ||||
} | } | ||||
@@ -834,7 +836,7 @@ public class ResourceUtils { | |||||
return resource.getOutputStream(); | return resource.getOutputStream(); | ||||
} | } | ||||
public static interface ResourceSelectorProvider { | |||||
public interface ResourceSelectorProvider { | |||||
ResourceSelector getTargetSelectorForSource(Resource source); | ResourceSelector getTargetSelectorForSource(Resource source); | ||||
} | } | ||||
@@ -842,7 +844,9 @@ public class ResourceUtils { | |||||
* @since Ant 1.9.4 | * @since Ant 1.9.4 | ||||
*/ | */ | ||||
public static class ReadOnlyTargetFileException extends IOException { | 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); | 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. | * @return true if the file is a broken symbolic link. | ||||
* @throws IOException on error. | * @throws IOException on error. | ||||
*/ | */ | ||||
public boolean isDanglingSymbolicLink(File parent, String name) | |||||
public boolean isDanglingSymbolicLink(File parent, String name) | |||||
throws IOException { | throws IOException { | ||||
File f = new File(parent, name); | File f = new File(parent, name); | ||||
if (!f.exists()) { | if (!f.exists()) { | ||||
final String localName = f.getName(); | final String localName = f.getName(); | ||||
String[] c = parent.list(new FilenameFilter() { | 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); | return localName.equals(n); | ||||
} | } | ||||
}); | }); | ||||
@@ -41,6 +41,6 @@ public class UnicodeUtil { | |||||
- s.length() + i, | - s.length() + i, | ||||
s.charAt(i)); | s.charAt(i)); | ||||
} | } | ||||
return unicodeBuf; | |||||
return unicodeBuf; | |||||
} | } | ||||
} | } |