git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272320 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -160,7 +160,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||
| (url == null)) { | |||
| try { | |||
| File pathComponent | |||
| = (File)pathComponents.elementAt(pathElementsIndex); | |||
| = (File) pathComponents.elementAt(pathElementsIndex); | |||
| url = getResourceURL(pathComponent, this.resourceName); | |||
| pathElementsIndex++; | |||
| } catch (BuildException e) { | |||
| @@ -649,7 +649,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||
| Enumeration e = pathComponents.elements(); | |||
| while (e.hasMoreElements() && stream == null) { | |||
| File pathComponent = (File)e.nextElement(); | |||
| File pathComponent = (File) e.nextElement(); | |||
| stream = getResourceStream(pathComponent, name); | |||
| } | |||
| return stream; | |||
| @@ -699,7 +699,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||
| } | |||
| } else { | |||
| // is the zip file in the cache | |||
| ZipFile zipFile = (ZipFile)zipFiles.get(file); | |||
| ZipFile zipFile = (ZipFile) zipFiles.get(file); | |||
| if (zipFile == null) { | |||
| zipFile = new ZipFile(file); | |||
| zipFiles.put(file, zipFile); | |||
| @@ -741,7 +741,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||
| boolean useParentFirst = parentFirst; | |||
| for (Enumeration e = systemPackages.elements(); e.hasMoreElements();) { | |||
| String packageName = (String)e.nextElement(); | |||
| String packageName = (String) e.nextElement(); | |||
| if (resourceName.startsWith(packageName)) { | |||
| useParentFirst = true; | |||
| break; | |||
| @@ -749,7 +749,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||
| } | |||
| for (Enumeration e = loaderPackages.elements(); e.hasMoreElements();) { | |||
| String packageName = (String)e.nextElement(); | |||
| String packageName = (String) e.nextElement(); | |||
| if (resourceName.startsWith(packageName)) { | |||
| useParentFirst = false; | |||
| break; | |||
| @@ -789,7 +789,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||
| // it or wasn't consulted. | |||
| Enumeration e = pathComponents.elements(); | |||
| while (e.hasMoreElements() && url == null) { | |||
| File pathComponent = (File)e.nextElement(); | |||
| File pathComponent = (File) e.nextElement(); | |||
| url = getResourceURL(pathComponent, name); | |||
| if (url != null) { | |||
| log("Resource " + name | |||
| @@ -859,7 +859,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||
| } | |||
| } | |||
| } else { | |||
| ZipFile zipFile = (ZipFile)zipFiles.get(file); | |||
| ZipFile zipFile = (ZipFile) zipFiles.get(file); | |||
| if (zipFile == null) { | |||
| zipFile = new ZipFile(file); | |||
| zipFiles.put(file, zipFile); | |||
| @@ -993,18 +993,16 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||
| Object[] args | |||
| = new Object[] {classname, classData, new Integer(0), | |||
| new Integer(classData.length), domain}; | |||
| return (Class)defineClassProtectionDomain.invoke(this, args); | |||
| return (Class) defineClassProtectionDomain.invoke(this, args); | |||
| } catch (InvocationTargetException ite) { | |||
| Throwable t = ite.getTargetException(); | |||
| if (t instanceof ClassFormatError) { | |||
| throw (ClassFormatError)t; | |||
| throw (ClassFormatError) t; | |||
| } else if (t instanceof NoClassDefFoundError) { | |||
| throw (NoClassDefFoundError)t; | |||
| } | |||
| else if (t instanceof SecurityException) { | |||
| throw (SecurityException)t; | |||
| } | |||
| else { | |||
| throw (NoClassDefFoundError) t; | |||
| } else if (t instanceof SecurityException) { | |||
| throw (SecurityException) t; | |||
| } else { | |||
| throw new IOException(t.toString()); | |||
| } | |||
| } catch (Exception e) { | |||
| @@ -1053,17 +1051,15 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||
| try { | |||
| Enumeration e = pathComponents.elements(); | |||
| while (e.hasMoreElements()) { | |||
| File pathComponent = (File)e.nextElement(); | |||
| File pathComponent = (File) e.nextElement(); | |||
| try { | |||
| stream = getResourceStream(pathComponent, classFilename); | |||
| if (stream != null) { | |||
| return getClassFromStream(stream, name); | |||
| } | |||
| } | |||
| catch (SecurityException se) { | |||
| } catch (SecurityException se) { | |||
| throw se; | |||
| } | |||
| catch (IOException ioe) { | |||
| } catch (IOException ioe) { | |||
| // ioe.printStackTrace(); | |||
| log("Exception reading component " + pathComponent , | |||
| Project.MSG_VERBOSE); | |||
| @@ -1110,8 +1106,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||
| public void cleanup() { | |||
| pathComponents = null; | |||
| project = null; | |||
| for (Enumeration e = zipFiles.elements(); e.hasMoreElements(); ) { | |||
| ZipFile zipFile = (ZipFile)e.nextElement(); | |||
| for (Enumeration e = zipFiles.elements(); e.hasMoreElements();) { | |||
| ZipFile zipFile = (ZipFile) e.nextElement(); | |||
| try { | |||
| zipFile.close(); | |||
| } catch (IOException ioe) { | |||
| @@ -88,7 +88,8 @@ public class DemuxOutputStream extends OutputStream { | |||
| } | |||
| /** Maximum buffer size. */ | |||
| private final static int MAX_SIZE = 1024; | |||
| private static final int MAX_SIZE = 1024; | |||
| /** Mapping from thread to buffer (Thread to BufferInfo). */ | |||
| private Hashtable buffers = new Hashtable(); | |||
| @@ -124,7 +125,7 @@ public class DemuxOutputStream extends OutputStream { | |||
| */ | |||
| private BufferInfo getBufferInfo() { | |||
| Thread current = Thread.currentThread(); | |||
| BufferInfo bufferInfo = (BufferInfo)buffers.get(current); | |||
| BufferInfo bufferInfo = (BufferInfo) buffers.get(current); | |||
| if (bufferInfo == null) { | |||
| bufferInfo = new BufferInfo(); | |||
| bufferInfo.buffer = new ByteArrayOutputStream(); | |||
| @@ -139,11 +140,10 @@ public class DemuxOutputStream extends OutputStream { | |||
| */ | |||
| private void resetBufferInfo() { | |||
| Thread current = Thread.currentThread(); | |||
| BufferInfo bufferInfo = (BufferInfo)buffers.get(current); | |||
| BufferInfo bufferInfo = (BufferInfo) buffers.get(current); | |||
| try { | |||
| bufferInfo.buffer.close(); | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| // Shouldn't happen | |||
| } | |||
| bufferInfo.buffer = new ByteArrayOutputStream(); | |||
| @@ -166,7 +166,7 @@ public class DemuxOutputStream extends OutputStream { | |||
| * @exception IOException if the data cannot be written to the stream | |||
| */ | |||
| public void write(int cc) throws IOException { | |||
| final byte c = (byte)cc; | |||
| final byte c = (byte) cc; | |||
| BufferInfo bufferInfo = getBufferInfo(); | |||
| if ((c == '\n') || (c == '\r')) { | |||
| @@ -147,7 +147,7 @@ public class DirectoryScanner implements FileScanner { | |||
| * | |||
| * @see #addDefaultExcludes() | |||
| */ | |||
| protected final static String[] DEFAULTEXCLUDES = { | |||
| protected static final String[] DEFAULTEXCLUDES = { | |||
| "**/*~", | |||
| "**/#*#", | |||
| "**/.#*", | |||
| @@ -264,17 +264,17 @@ public class DirectoryScanner implements FileScanner { | |||
| Vector strDirs = tokenizePath (str); | |||
| int patIdxStart = 0; | |||
| int patIdxEnd = patDirs.size()-1; | |||
| int patIdxEnd = patDirs.size() - 1; | |||
| int strIdxStart = 0; | |||
| int strIdxEnd = strDirs.size()-1; | |||
| int strIdxEnd = strDirs.size() - 1; | |||
| // up to first '**' | |||
| while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { | |||
| String patDir = (String)patDirs.elementAt(patIdxStart); | |||
| String patDir = (String) patDirs.elementAt(patIdxStart); | |||
| if (patDir.equals("**")) { | |||
| break; | |||
| } | |||
| if (!match(patDir,(String)strDirs.elementAt(strIdxStart), isCaseSensitive)) { | |||
| if (!match(patDir, (String) strDirs.elementAt(strIdxStart), isCaseSensitive)) { | |||
| return false; | |||
| } | |||
| patIdxStart++; | |||
| @@ -322,7 +322,8 @@ public class DirectoryScanner implements FileScanner { | |||
| * @return <code>true</code> if the pattern matches against the string, | |||
| * or <code>false</code> otherwise. | |||
| */ | |||
| protected static boolean matchPath(String pattern, String str, boolean isCaseSensitive) { | |||
| protected static boolean matchPath(String pattern, String str, | |||
| boolean isCaseSensitive) { | |||
| // When str starts with a File.separator, pattern has to start with a | |||
| // File.separator. | |||
| // When pattern starts with a File.separator, str has to start with a | |||
| @@ -336,17 +337,17 @@ public class DirectoryScanner implements FileScanner { | |||
| Vector strDirs = tokenizePath (str); | |||
| int patIdxStart = 0; | |||
| int patIdxEnd = patDirs.size()-1; | |||
| int patIdxEnd = patDirs.size() - 1; | |||
| int strIdxStart = 0; | |||
| int strIdxEnd = strDirs.size()-1; | |||
| int strIdxEnd = strDirs.size() - 1; | |||
| // up to first '**' | |||
| while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { | |||
| String patDir = (String)patDirs.elementAt(patIdxStart); | |||
| String patDir = (String) patDirs.elementAt(patIdxStart); | |||
| if (patDir.equals("**")) { | |||
| break; | |||
| } | |||
| if (!match(patDir,(String)strDirs.elementAt(strIdxStart), isCaseSensitive)) { | |||
| if (!match(patDir, (String) strDirs.elementAt(strIdxStart), isCaseSensitive)) { | |||
| return false; | |||
| } | |||
| patIdxStart++; | |||
| @@ -369,11 +370,11 @@ public class DirectoryScanner implements FileScanner { | |||
| // up to last '**' | |||
| while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { | |||
| String patDir = (String)patDirs.elementAt(patIdxEnd); | |||
| String patDir = (String) patDirs.elementAt(patIdxEnd); | |||
| if (patDir.equals("**")) { | |||
| break; | |||
| } | |||
| if (!match(patDir,(String)strDirs.elementAt(strIdxEnd), isCaseSensitive)) { | |||
| if (!match(patDir, (String) strDirs.elementAt(strIdxEnd), isCaseSensitive)) { | |||
| return false; | |||
| } | |||
| patIdxEnd--; | |||
| @@ -391,33 +392,35 @@ public class DirectoryScanner implements FileScanner { | |||
| while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { | |||
| int patIdxTmp = -1; | |||
| for (int i = patIdxStart+1; i <= patIdxEnd; i++) { | |||
| for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { | |||
| if (patDirs.elementAt(i).equals("**")) { | |||
| patIdxTmp = i; | |||
| break; | |||
| } | |||
| } | |||
| if (patIdxTmp == patIdxStart+1) { | |||
| if (patIdxTmp == patIdxStart + 1) { | |||
| // '**/**' situation, so skip one | |||
| patIdxStart++; | |||
| continue; | |||
| } | |||
| // Find the pattern between padIdxStart & padIdxTmp in str between | |||
| // strIdxStart & strIdxEnd | |||
| int patLength = (patIdxTmp-patIdxStart-1); | |||
| int strLength = (strIdxEnd-strIdxStart+1); | |||
| int patLength = (patIdxTmp - patIdxStart - 1); | |||
| int strLength = (strIdxEnd - strIdxStart + 1); | |||
| int foundIdx = -1; | |||
| strLoop: | |||
| for (int i = 0; i <= strLength - patLength; i++) { | |||
| for (int j = 0; j < patLength; j++) { | |||
| String subPat = (String)patDirs.elementAt(patIdxStart+j+1); | |||
| String subStr = (String)strDirs.elementAt(strIdxStart+i+j); | |||
| if (!match(subPat,subStr, isCaseSensitive)) { | |||
| String subPat | |||
| = (String) patDirs.elementAt(patIdxStart + j + 1); | |||
| String subStr | |||
| = (String) strDirs.elementAt(strIdxStart + i + j); | |||
| if (!match(subPat, subStr, isCaseSensitive)) { | |||
| continue strLoop; | |||
| } | |||
| } | |||
| foundIdx = strIdxStart+i; | |||
| foundIdx = strIdxStart + i; | |||
| break; | |||
| } | |||
| @@ -426,7 +429,7 @@ strLoop: | |||
| } | |||
| patIdxStart = patIdxTmp; | |||
| strIdxStart = foundIdx+patLength; | |||
| strIdxStart = foundIdx + patLength; | |||
| } | |||
| for (int i = patIdxStart; i <= patIdxEnd; i++) { | |||
| @@ -473,13 +476,14 @@ strLoop: | |||
| * @return <code>true</code> if the string matches against the pattern, | |||
| * or <code>false</code> otherwise. | |||
| */ | |||
| protected static boolean match(String pattern, String str, boolean isCaseSensitive) { | |||
| protected static boolean match(String pattern, String str, | |||
| boolean isCaseSensitive) { | |||
| char[] patArr = pattern.toCharArray(); | |||
| char[] strArr = str.toCharArray(); | |||
| int patIdxStart = 0; | |||
| int patIdxEnd = patArr.length-1; | |||
| int patIdxEnd = patArr.length - 1; | |||
| int strIdxStart = 0; | |||
| int strIdxEnd = strArr.length-1; | |||
| int strIdxEnd = strArr.length - 1; | |||
| char ch; | |||
| boolean containsStar = false; | |||
| @@ -515,7 +519,7 @@ strLoop: | |||
| } | |||
| // Process characters before first star | |||
| while((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) { | |||
| while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) { | |||
| if (ch != '?') { | |||
| if (isCaseSensitive && ch != strArr[strIdxStart]) { | |||
| return false;// Character mismatch | |||
| @@ -540,7 +544,7 @@ strLoop: | |||
| } | |||
| // Process characters after last star | |||
| while((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) { | |||
| while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) { | |||
| if (ch != '?') { | |||
| if (isCaseSensitive && ch != strArr[strIdxEnd]) { | |||
| return false;// Character mismatch | |||
| @@ -568,38 +572,39 @@ strLoop: | |||
| // always to a '*'. | |||
| while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { | |||
| int patIdxTmp = -1; | |||
| for (int i = patIdxStart+1; i <= patIdxEnd; i++) { | |||
| for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { | |||
| if (patArr[i] == '*') { | |||
| patIdxTmp = i; | |||
| break; | |||
| } | |||
| } | |||
| if (patIdxTmp == patIdxStart+1) { | |||
| if (patIdxTmp == patIdxStart + 1) { | |||
| // Two stars next to each other, skip the first one. | |||
| patIdxStart++; | |||
| continue; | |||
| } | |||
| // Find the pattern between padIdxStart & padIdxTmp in str between | |||
| // strIdxStart & strIdxEnd | |||
| int patLength = (patIdxTmp-patIdxStart-1); | |||
| int strLength = (strIdxEnd-strIdxStart+1); | |||
| int patLength = (patIdxTmp - patIdxStart - 1); | |||
| int strLength = (strIdxEnd - strIdxStart + 1); | |||
| int foundIdx = -1; | |||
| strLoop: | |||
| for (int i = 0; i <= strLength - patLength; i++) { | |||
| for (int j = 0; j < patLength; j++) { | |||
| ch = patArr[patIdxStart+j+1]; | |||
| ch = patArr[patIdxStart + j + 1]; | |||
| if (ch != '?') { | |||
| if (isCaseSensitive && ch != strArr[strIdxStart+i+j]) { | |||
| if (isCaseSensitive | |||
| && ch != strArr[strIdxStart + i + j]) { | |||
| continue strLoop; | |||
| } | |||
| if (!isCaseSensitive && Character.toUpperCase(ch) != | |||
| Character.toUpperCase(strArr[strIdxStart+i+j])) { | |||
| Character.toUpperCase(strArr[strIdxStart + i + j])) { | |||
| continue strLoop; | |||
| } | |||
| } | |||
| } | |||
| foundIdx = strIdxStart+i; | |||
| foundIdx = strIdxStart + i; | |||
| break; | |||
| } | |||
| @@ -608,7 +613,7 @@ strLoop: | |||
| } | |||
| patIdxStart = patIdxTmp; | |||
| strIdxStart = foundIdx+patLength; | |||
| strIdxStart = foundIdx + patLength; | |||
| } | |||
| // All characters in the string are used. Check if only '*'s are left | |||
| @@ -631,7 +636,7 @@ strLoop: | |||
| */ | |||
| private static Vector tokenizePath (String path) { | |||
| Vector ret = new Vector(); | |||
| StringTokenizer st = new StringTokenizer(path,File.separator); | |||
| StringTokenizer st = new StringTokenizer(path, File.separator); | |||
| while (st.hasMoreTokens()) { | |||
| ret.addElement(st.nextToken()); | |||
| } | |||
| @@ -648,7 +653,7 @@ strLoop: | |||
| * Must not be <code>null</code>. | |||
| */ | |||
| public void setBasedir(String basedir) { | |||
| setBasedir(new File(basedir.replace('/',File.separatorChar).replace('\\',File.separatorChar))); | |||
| setBasedir(new File(basedir.replace('/', File.separatorChar).replace('\\', File.separatorChar))); | |||
| } | |||
| /** | |||
| @@ -702,7 +707,7 @@ strLoop: | |||
| this.includes = new String[includes.length]; | |||
| for (int i = 0; i < includes.length; i++) { | |||
| String pattern; | |||
| pattern = includes[i].replace('/',File.separatorChar).replace('\\',File.separatorChar); | |||
| pattern = includes[i].replace('/', File.separatorChar).replace('\\', File.separatorChar); | |||
| if (pattern.endsWith(File.separator)) { | |||
| pattern += "**"; | |||
| } | |||
| @@ -730,7 +735,7 @@ strLoop: | |||
| this.excludes = new String[excludes.length]; | |||
| for (int i = 0; i < excludes.length; i++) { | |||
| String pattern; | |||
| pattern = excludes[i].replace('/',File.separatorChar).replace('\\',File.separatorChar); | |||
| pattern = excludes[i].replace('/', File.separatorChar).replace('\\', File.separatorChar); | |||
| if (pattern.endsWith(File.separator)) { | |||
| pattern += "**"; | |||
| } | |||
| @@ -818,17 +823,17 @@ strLoop: | |||
| String[] notIncl = new String[dirsNotIncluded.size()]; | |||
| dirsNotIncluded.copyInto(notIncl); | |||
| for (int i=0; i<excl.length; i++) { | |||
| for (int i = 0; i < excl.length; i++) { | |||
| if (!couldHoldIncluded(excl[i])) { | |||
| scandir(new File(basedir, excl[i]), | |||
| excl[i]+File.separator, false); | |||
| excl[i] + File.separator, false); | |||
| } | |||
| } | |||
| for (int i=0; i<notIncl.length; i++) { | |||
| for (int i = 0; i < notIncl.length; i++) { | |||
| if (!couldHoldIncluded(notIncl[i])) { | |||
| scandir(new File(basedir, notIncl[i]), | |||
| notIncl[i]+File.separator, false); | |||
| notIncl[i] + File.separator, false); | |||
| } | |||
| } | |||
| @@ -871,31 +876,31 @@ strLoop: | |||
| } | |||
| for (int i = 0; i < newfiles.length; i++) { | |||
| String name = vpath+newfiles[i]; | |||
| File file = new File(dir,newfiles[i]); | |||
| String name = vpath + newfiles[i]; | |||
| File file = new File(dir, newfiles[i]); | |||
| if (file.isDirectory()) { | |||
| if (isIncluded(name)) { | |||
| if (!isExcluded(name)) { | |||
| dirsIncluded.addElement(name); | |||
| if (fast) { | |||
| scandir(file, name+File.separator, fast); | |||
| scandir(file, name + File.separator, fast); | |||
| } | |||
| } else { | |||
| everythingIncluded = false; | |||
| dirsExcluded.addElement(name); | |||
| if (fast && couldHoldIncluded(name)) { | |||
| scandir(file, name+File.separator, fast); | |||
| scandir(file, name + File.separator, fast); | |||
| } | |||
| } | |||
| } else { | |||
| everythingIncluded = false; | |||
| dirsNotIncluded.addElement(name); | |||
| if (fast && couldHoldIncluded(name)) { | |||
| scandir(file, name+File.separator, fast); | |||
| scandir(file, name + File.separator, fast); | |||
| } | |||
| } | |||
| if (!fast) { | |||
| scandir(file, name+File.separator, fast); | |||
| scandir(file, name + File.separator, fast); | |||
| } | |||
| } else if (file.isFile()) { | |||
| if (isIncluded(name)) { | |||
| @@ -940,7 +945,7 @@ strLoop: | |||
| */ | |||
| protected boolean couldHoldIncluded(String name) { | |||
| for (int i = 0; i < includes.length; i++) { | |||
| if (matchPatternStart(includes[i],name, isCaseSensitive)) { | |||
| if (matchPatternStart(includes[i], name, isCaseSensitive)) { | |||
| return true; | |||
| } | |||
| } | |||
| @@ -957,7 +962,7 @@ strLoop: | |||
| */ | |||
| protected boolean isExcluded(String name) { | |||
| for (int i = 0; i < excludes.length; i++) { | |||
| if (matchPath(excludes[i],name, isCaseSensitive)) { | |||
| if (matchPath(excludes[i], name, isCaseSensitive)) { | |||
| return true; | |||
| } | |||
| } | |||
| @@ -976,7 +981,7 @@ strLoop: | |||
| int count = filesIncluded.size(); | |||
| String[] files = new String[count]; | |||
| for (int i = 0; i < count; i++) { | |||
| files[i] = (String)filesIncluded.elementAt(i); | |||
| files[i] = (String) filesIncluded.elementAt(i); | |||
| } | |||
| return files; | |||
| } | |||
| @@ -996,7 +1001,7 @@ strLoop: | |||
| int count = filesNotIncluded.size(); | |||
| String[] files = new String[count]; | |||
| for (int i = 0; i < count; i++) { | |||
| files[i] = (String)filesNotIncluded.elementAt(i); | |||
| files[i] = (String) filesNotIncluded.elementAt(i); | |||
| } | |||
| return files; | |||
| } | |||
| @@ -1017,7 +1022,7 @@ strLoop: | |||
| int count = filesExcluded.size(); | |||
| String[] files = new String[count]; | |||
| for (int i = 0; i < count; i++) { | |||
| files[i] = (String)filesExcluded.elementAt(i); | |||
| files[i] = (String) filesExcluded.elementAt(i); | |||
| } | |||
| return files; | |||
| } | |||
| @@ -1034,7 +1039,7 @@ strLoop: | |||
| int count = dirsIncluded.size(); | |||
| String[] directories = new String[count]; | |||
| for (int i = 0; i < count; i++) { | |||
| directories[i] = (String)dirsIncluded.elementAt(i); | |||
| directories[i] = (String) dirsIncluded.elementAt(i); | |||
| } | |||
| return directories; | |||
| } | |||
| @@ -1054,7 +1059,7 @@ strLoop: | |||
| int count = dirsNotIncluded.size(); | |||
| String[] directories = new String[count]; | |||
| for (int i = 0; i < count; i++) { | |||
| directories[i] = (String)dirsNotIncluded.elementAt(i); | |||
| directories[i] = (String) dirsNotIncluded.elementAt(i); | |||
| } | |||
| return directories; | |||
| } | |||
| @@ -1075,7 +1080,7 @@ strLoop: | |||
| int count = dirsExcluded.size(); | |||
| String[] directories = new String[count]; | |||
| for (int i = 0; i < count; i++) { | |||
| directories[i] = (String)dirsExcluded.elementAt(i); | |||
| directories[i] = (String) dirsExcluded.elementAt(i); | |||
| } | |||
| return directories; | |||
| } | |||
| @@ -1088,10 +1093,10 @@ strLoop: | |||
| String[] newExcludes; | |||
| newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length]; | |||
| if (excludesLength > 0) { | |||
| System.arraycopy(excludes,0,newExcludes,0,excludesLength); | |||
| System.arraycopy(excludes, 0, newExcludes, 0, excludesLength); | |||
| } | |||
| for (int i = 0; i < DEFAULTEXCLUDES.length; i++) { | |||
| newExcludes[i+excludesLength] = DEFAULTEXCLUDES[i].replace('/',File.separatorChar).replace('\\',File.separatorChar); | |||
| newExcludes[i + excludesLength] = DEFAULTEXCLUDES[i].replace('/', File.separatorChar).replace('\\', File.separatorChar); | |||
| } | |||
| excludes = newExcludes; | |||
| } | |||
| @@ -140,7 +140,7 @@ public interface FileScanner { | |||
| * incorrectly (i.e. if it is <code>null</code>, doesn't exist, | |||
| * or isn't a directory). | |||
| */ | |||
| void scan(); | |||
| void scan() throws IllegalStateException; | |||
| /** | |||
| * Sets the base directory to be scanned. This is the directory which is | |||
| @@ -135,7 +135,7 @@ public class IntrospectionHelper implements BuildListener { | |||
| Class[] wrappers = {Boolean.class, Byte.class, Character.class, | |||
| Short.class, Integer.class, Long.class, | |||
| Float.class, Double.class}; | |||
| for (int i=0; i < primitives.length; i++) { | |||
| for (int i = 0; i < primitives.length; i++) { | |||
| PRIMITIVE_TYPE_MAP.put (primitives[i], wrappers[i]); | |||
| } | |||
| } | |||
| @@ -204,7 +204,7 @@ public class IntrospectionHelper implements BuildListener { | |||
| this.bean = bean; | |||
| Method[] methods = bean.getMethods(); | |||
| for (int i=0; i<methods.length; i++) { | |||
| for (int i = 0; i < methods.length; i++) { | |||
| final Method m = methods[i]; | |||
| final String name = m.getName(); | |||
| Class returnType = m.getReturnType(); | |||
| @@ -392,7 +392,8 @@ public class IntrospectionHelper implements BuildListener { | |||
| public void setAttribute(Project p, Object element, String attributeName, | |||
| String value) | |||
| throws BuildException { | |||
| AttributeSetter as = (AttributeSetter) attributeSetters.get(attributeName); | |||
| AttributeSetter as | |||
| = (AttributeSetter) attributeSetters.get(attributeName); | |||
| if (as == null) { | |||
| String msg = p.getElementName(element) + | |||
| //String msg = "Class " + element.getClass().getName() + | |||
| @@ -434,11 +435,10 @@ public class IntrospectionHelper implements BuildListener { | |||
| throws BuildException { | |||
| if (addText == null) { | |||
| // Element doesn't handle text content | |||
| if ( text.trim().length() == 0 ) { | |||
| if (text.trim().length() == 0) { | |||
| // Only whitespace - ignore | |||
| return; | |||
| } | |||
| else { | |||
| } else { | |||
| // Not whitespace - fail | |||
| String msg = project.getElementName(element) + | |||
| " doesn't support nested text data."; | |||
| @@ -480,8 +480,8 @@ public class IntrospectionHelper implements BuildListener { | |||
| * element instance, or if the creating method | |||
| * fails. | |||
| */ | |||
| public Object createElement(Project project, Object parent, String elementName) | |||
| throws BuildException { | |||
| public Object createElement(Project project, Object parent, | |||
| String elementName) throws BuildException { | |||
| NestedCreator nc = (NestedCreator) nestedCreators.get(elementName); | |||
| if (nc == null) { | |||
| String msg = project.getElementName(parent) + | |||
| @@ -529,12 +529,12 @@ public class IntrospectionHelper implements BuildListener { | |||
| * | |||
| * @exception BuildException if the storage method fails. | |||
| */ | |||
| public void storeElement(Project project, Object parent, Object child, String elementName) | |||
| throws BuildException { | |||
| public void storeElement(Project project, Object parent, Object child, | |||
| String elementName) throws BuildException { | |||
| if (elementName == null) { | |||
| return; | |||
| } | |||
| NestedStorer ns = (NestedStorer)nestedStorers.get(elementName); | |||
| NestedStorer ns = (NestedStorer) nestedStorers.get(elementName); | |||
| if (ns == null) { | |||
| return; | |||
| } | |||
| @@ -663,7 +663,8 @@ public class IntrospectionHelper implements BuildListener { | |||
| */ | |||
| private AttributeSetter createAttributeSetter(final Method m, | |||
| Class arg) { | |||
| // use wrappers for primitive classes, e.g. int and Integer are treated identically | |||
| // use wrappers for primitive classes, e.g. int and | |||
| // Integer are treated identically | |||
| final Class reflectedArg = PRIMITIVE_TYPE_MAP.containsKey (arg) | |||
| ? (Class) PRIMITIVE_TYPE_MAP.get(arg) : arg; | |||
| @@ -685,8 +686,8 @@ public class IntrospectionHelper implements BuildListener { | |||
| } | |||
| }; | |||
| // boolean and Boolean get special treatment because we have a nice method | |||
| // in Project | |||
| // boolean and Boolean get special treatment because we | |||
| // have a nice method in Project | |||
| } else if (java.lang.Boolean.class.equals(reflectedArg)) { | |||
| return new AttributeSetter() { | |||
| public void set(Project p, Object parent, String value) | |||
| @@ -737,7 +738,7 @@ public class IntrospectionHelper implements BuildListener { | |||
| throws InvocationTargetException, IllegalAccessException, BuildException { | |||
| try { | |||
| org.apache.tools.ant.types.EnumeratedAttribute ea = | |||
| (org.apache.tools.ant.types.EnumeratedAttribute)reflectedArg.newInstance(); | |||
| (org.apache.tools.ant.types.EnumeratedAttribute) reflectedArg.newInstance(); | |||
| ea.setValue(value); | |||
| m.invoke(parent, new EnumeratedAttribute[] {ea}); | |||
| } catch (InstantiationException ie) { | |||
| @@ -792,8 +793,7 @@ public class IntrospectionHelper implements BuildListener { | |||
| * | |||
| * @return a description of the element type | |||
| */ | |||
| protected String getElementName(Project project, Object element) | |||
| { | |||
| protected String getElementName(Project project, Object element) { | |||
| return project.getElementName(element); | |||
| } | |||
| @@ -69,7 +69,7 @@ public class Location { | |||
| private int columnNumber; | |||
| /** Location to use when one is needed but no information is available */ | |||
| public final static Location UNKNOWN_LOCATION = new Location(); | |||
| public static final Location UNKNOWN_LOCATION = new Location(); | |||
| /** | |||
| * Creates an "unknown" location. | |||
| @@ -79,7 +79,7 @@ import java.util.Enumeration; | |||
| public class Main { | |||
| /** The default build file name. */ | |||
| public final static String DEFAULT_BUILD_FILENAME = "build.xml"; | |||
| public static final String DEFAULT_BUILD_FILENAME = "build.xml"; | |||
| /** Our current message output status. Follows Project.MSG_XXX. */ | |||
| private int msgOutputLevel = Project.MSG_INFO; | |||
| @@ -174,7 +174,7 @@ public class Main { | |||
| if (additionalUserProperties != null) { | |||
| for (Enumeration e = additionalUserProperties.keys(); | |||
| e.hasMoreElements(); ) { | |||
| e.hasMoreElements();) { | |||
| String key = (String) e.nextElement(); | |||
| String property = additionalUserProperties.getProperty(key); | |||
| m.definedProps.put(key, property); | |||
| @@ -334,8 +334,7 @@ public class Main { | |||
| } | |||
| try { | |||
| loggerClassname = args[++i]; | |||
| } | |||
| catch (ArrayIndexOutOfBoundsException aioobe) { | |||
| } catch (ArrayIndexOutOfBoundsException aioobe) { | |||
| System.out.println("You must specify a classname when " + | |||
| "using the -logger argument"); | |||
| return; | |||
| @@ -410,8 +409,7 @@ public class Main { | |||
| try { | |||
| fis = new FileInputStream(filename); | |||
| props.load(fis); | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| System.out.println("Could not load property file " | |||
| + filename + ": " + e.getMessage()); | |||
| } finally { | |||
| @@ -537,8 +535,8 @@ public class Main { | |||
| // use a system manager that prevents from System.exit() | |||
| // only in JDK > 1.1 | |||
| SecurityManager oldsm = null; | |||
| if ( !Project.JAVA_1_0.equals(Project.getJavaVersion()) && | |||
| !Project.JAVA_1_1.equals(Project.getJavaVersion()) ){ | |||
| if (!Project.JAVA_1_0.equals(Project.getJavaVersion()) && | |||
| !Project.JAVA_1_1.equals(Project.getJavaVersion())){ | |||
| oldsm = System.getSecurityManager(); | |||
| //SecurityManager can not be installed here for backwards | |||
| @@ -559,13 +557,13 @@ public class Main { | |||
| // set user-define properties | |||
| Enumeration e = definedProps.keys(); | |||
| while (e.hasMoreElements()) { | |||
| String arg = (String)e.nextElement(); | |||
| String value = (String)definedProps.get(arg); | |||
| String arg = (String) e.nextElement(); | |||
| String value = (String) definedProps.get(arg); | |||
| project.setUserProperty(arg, value); | |||
| } | |||
| project.setUserProperty("ant.file", | |||
| buildFile.getAbsolutePath() ); | |||
| buildFile.getAbsolutePath()); | |||
| // first use the ProjectHelper to create the project object | |||
| // from the given build file. | |||
| @@ -585,7 +583,7 @@ public class Main { | |||
| if (projectHelp) { | |||
| printDescription(project); | |||
| printTargets(project, msgOutputLevel > Project.MSG_INFO ); | |||
| printTargets(project, msgOutputLevel > Project.MSG_INFO); | |||
| return; | |||
| } | |||
| @@ -595,8 +593,7 @@ public class Main { | |||
| } | |||
| project.executeTargets(targets); | |||
| } | |||
| finally { | |||
| } finally { | |||
| // put back the original security manager | |||
| //The following will never eval to true. (PD) | |||
| if (oldsm != null){ | |||
| @@ -606,16 +603,13 @@ public class Main { | |||
| System.setOut(out); | |||
| System.setErr(err); | |||
| } | |||
| } | |||
| catch (RuntimeException exc) { | |||
| } catch (RuntimeException exc) { | |||
| error = exc; | |||
| throw exc; | |||
| } | |||
| catch (Error err) { | |||
| } catch (Error err) { | |||
| error = err; | |||
| throw err; | |||
| } | |||
| finally { | |||
| } finally { | |||
| if (!projectHelp) { | |||
| project.fireBuildFinished(error); | |||
| } | |||
| @@ -640,8 +634,7 @@ public class Main { | |||
| BuildListener listener = | |||
| (BuildListener) Class.forName(className).newInstance(); | |||
| project.addBuildListener(listener); | |||
| } | |||
| catch (Throwable exc) { | |||
| } catch (Throwable exc) { | |||
| throw new BuildException("Unable to instantiate listener " | |||
| + className, exc); | |||
| } | |||
| @@ -662,21 +655,19 @@ public class Main { | |||
| BuildLogger logger = null; | |||
| if (loggerClassname != null) { | |||
| try { | |||
| logger = (BuildLogger)(Class.forName(loggerClassname).newInstance()); | |||
| } | |||
| catch (ClassCastException e) { | |||
| logger = (BuildLogger) (Class.forName(loggerClassname).newInstance()); | |||
| } catch (ClassCastException e) { | |||
| System.err.println("The specified logger class " | |||
| + loggerClassname | |||
| + " does not implement the BuildLogger interface"); | |||
| throw new RuntimeException(); | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| System.err.println("Unable to instantiate specified logger " | |||
| + "class " + loggerClassname + " : " + e.getClass().getName()); | |||
| + "class " + loggerClassname + " : " | |||
| + e.getClass().getName()); | |||
| throw new RuntimeException(); | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| logger = new DefaultLogger(); | |||
| } | |||
| @@ -801,7 +792,7 @@ public class Main { | |||
| Vector subNames = new Vector(); | |||
| while (ptargets.hasMoreElements()) { | |||
| currentTarget = (Target)ptargets.nextElement(); | |||
| currentTarget = (Target) ptargets.nextElement(); | |||
| targetName = currentTarget.getName(); | |||
| targetDescription = currentTarget.getDescription(); | |||
| // maintain a sorted list of targets | |||
| @@ -827,7 +818,7 @@ public class Main { | |||
| String defaultTarget = project.getDefaultTarget(); | |||
| if (defaultTarget != null && !"".equals(defaultTarget)) { | |||
| // shouldn't need to check but... | |||
| System.out.println( "Default target: " + defaultTarget); | |||
| System.out.println("Default target: " + defaultTarget); | |||
| } | |||
| } | |||
| @@ -844,7 +835,7 @@ public class Main { | |||
| private static int findTargetPosition(Vector names, String name) { | |||
| int res = names.size(); | |||
| for (int i = 0; i < names.size() && res == names.size(); i++) { | |||
| if (name.compareTo((String)names.elementAt(i)) < 0) { | |||
| if (name.compareTo((String) names.elementAt(i)) < 0) { | |||
| res = i; | |||
| } | |||
| } | |||
| @@ -884,7 +875,7 @@ public class Main { | |||
| msg.append(" "); | |||
| msg.append(names.elementAt(i)); | |||
| if (descriptions != null) { | |||
| msg.append(spaces.substring(0, maxlen - ((String)names.elementAt(i)).length() + 2)); | |||
| msg.append(spaces.substring(0, maxlen - ((String) names.elementAt(i)).length() + 2)); | |||
| msg.append(descriptions.elementAt(i)); | |||
| } | |||
| msg.append(lSep); | |||
| @@ -107,17 +107,17 @@ public class NoBannerLogger extends DefaultLogger { | |||
| */ | |||
| public void messageLogged(BuildEvent event) { | |||
| if( event.getPriority() > msgOutputLevel || | |||
| null == event.getMessage() || | |||
| "".equals( event.getMessage().trim() ) ) { | |||
| return; | |||
| if (event.getPriority() > msgOutputLevel | |||
| || null == event.getMessage() | |||
| || "".equals(event.getMessage().trim())) { | |||
| return; | |||
| } | |||
| if( null != targetName ) { | |||
| if (null != targetName) { | |||
| out.println(StringUtils.LINE_SEP + targetName + ":"); | |||
| targetName = null; | |||
| } | |||
| super.messageLogged( event ); | |||
| super.messageLogged(event); | |||
| } | |||
| } | |||
| @@ -104,8 +104,7 @@ public class PathTokenizer { | |||
| // For NetWare, use the boolean=true mode, so we can use delimiter | |||
| // information to make a better decision later. | |||
| tokenizer = new StringTokenizer(path, ":;", true); | |||
| } | |||
| else { | |||
| } else { | |||
| // on Windows and Unix, we can ignore delimiters and still have | |||
| // enough information to tokenize correctly. | |||
| tokenizer = new StringTokenizer(path, ":;", false); | |||
| @@ -142,8 +141,7 @@ public class PathTokenizer { | |||
| if (lookahead != null) { | |||
| token = lookahead; | |||
| lookahead = null; | |||
| } | |||
| else { | |||
| } else { | |||
| token = tokenizer.nextToken().trim(); | |||
| } | |||
| @@ -159,14 +157,12 @@ public class PathTokenizer { | |||
| // starts with a slash or backslash, so we know this is a | |||
| // drive spec | |||
| token += ":" + nextToken; | |||
| } | |||
| else { | |||
| } else { | |||
| // store the token just read for next time | |||
| lookahead = nextToken; | |||
| } | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| // we are on NetWare, tokenizing is handled a little differently, | |||
| // due to the fact that NetWare has multiple-character volume names. | |||
| if (token.equals(File.pathSeparator)) { | |||
| @@ -186,15 +182,13 @@ public class PathTokenizer { | |||
| String oneMore = tokenizer.nextToken().trim(); | |||
| if (!oneMore.equals(File.pathSeparator)) { | |||
| token += ":" + oneMore; | |||
| } | |||
| else { | |||
| } else { | |||
| token += ":"; | |||
| } | |||
| } | |||
| // implicit else: ignore the ':' since we have either a | |||
| // UNIX or a relative path | |||
| } | |||
| else { | |||
| } else { | |||
| // store the token just read for next time | |||
| lookahead = nextToken; | |||
| } | |||
| @@ -88,42 +88,42 @@ import org.apache.tools.ant.util.JavaEnvUtils; | |||
| public class Project { | |||
| /** Message priority of "error". */ | |||
| public final static int MSG_ERR = 0; | |||
| public static final int MSG_ERR = 0; | |||
| /** Message priority of "warning". */ | |||
| public final static int MSG_WARN = 1; | |||
| public static final int MSG_WARN = 1; | |||
| /** Message priority of "information". */ | |||
| public final static int MSG_INFO = 2; | |||
| public static final int MSG_INFO = 2; | |||
| /** Message priority of "verbose". */ | |||
| public final static int MSG_VERBOSE = 3; | |||
| public static final int MSG_VERBOSE = 3; | |||
| /** Message priority of "debug". */ | |||
| public final static int MSG_DEBUG = 4; | |||
| public static final int MSG_DEBUG = 4; | |||
| /** | |||
| * Constant for the "visiting" state, used when | |||
| * traversing a DFS of target dependencies. | |||
| */ | |||
| private final static String VISITING = "VISITING"; | |||
| private static final String VISITING = "VISITING"; | |||
| /** | |||
| * Constant for the "visited" state, used when | |||
| * traversing a DFS of target dependencies. | |||
| */ | |||
| private final static String VISITED = "VISITED"; | |||
| private static final String VISITED = "VISITED"; | |||
| /** Version constant for Java 1.0 */ | |||
| public final static String JAVA_1_0 = JavaEnvUtils.JAVA_1_0; | |||
| public static final String JAVA_1_0 = JavaEnvUtils.JAVA_1_0; | |||
| /** Version constant for Java 1.1 */ | |||
| public final static String JAVA_1_1 = JavaEnvUtils.JAVA_1_1; | |||
| public static final String JAVA_1_1 = JavaEnvUtils.JAVA_1_1; | |||
| /** Version constant for Java 1.2 */ | |||
| public final static String JAVA_1_2 = JavaEnvUtils.JAVA_1_2; | |||
| public static final String JAVA_1_2 = JavaEnvUtils.JAVA_1_2; | |||
| /** Version constant for Java 1.3 */ | |||
| public final static String JAVA_1_3 = JavaEnvUtils.JAVA_1_3; | |||
| public static final String JAVA_1_3 = JavaEnvUtils.JAVA_1_3; | |||
| /** Version constant for Java 1.4 */ | |||
| public final static String JAVA_1_4 = JavaEnvUtils.JAVA_1_4; | |||
| public static final String JAVA_1_4 = JavaEnvUtils.JAVA_1_4; | |||
| /** Default filter start token. */ | |||
| public final static String TOKEN_START = FilterSet.DEFAULT_TOKEN_START; | |||
| public static final String TOKEN_START = FilterSet.DEFAULT_TOKEN_START; | |||
| /** Default filter end token. */ | |||
| public final static String TOKEN_END = FilterSet.DEFAULT_TOKEN_END; | |||
| public static final String TOKEN_END = FilterSet.DEFAULT_TOKEN_END; | |||
| /** Name of this project. */ | |||
| private String name; | |||
| @@ -676,7 +676,7 @@ public class Project { | |||
| + " is not a directory"); | |||
| } | |||
| this.baseDir = baseDir; | |||
| setPropertyInternal( "basedir", this.baseDir.getPath()); | |||
| setPropertyInternal("basedir", this.baseDir.getPath()); | |||
| String msg = "Project base dir set to: " + this.baseDir; | |||
| log(msg, MSG_VERBOSE); | |||
| } | |||
| @@ -768,7 +768,7 @@ public class Project { | |||
| */ | |||
| public void addTaskDefinition(String taskName, Class taskClass) | |||
| throws BuildException { | |||
| Class old = (Class)taskClassDefinitions.get(taskName); | |||
| Class old = (Class) taskClassDefinitions.get(taskName); | |||
| if (null != old) { | |||
| if (old.equals(taskClass)) { | |||
| log("Ignoring override for task " + taskName | |||
| @@ -812,7 +812,7 @@ public class Project { | |||
| throw new BuildException(message); | |||
| } | |||
| try { | |||
| taskClass.getConstructor( null ); | |||
| taskClass.getConstructor(null); | |||
| // don't have to check for public, since | |||
| // getConstructor finds public constructors only. | |||
| } catch (NoSuchMethodException e) { | |||
| @@ -821,7 +821,7 @@ public class Project { | |||
| log(message, Project.MSG_ERR); | |||
| throw new BuildException(message); | |||
| } | |||
| if (!Task.class.isAssignableFrom(taskClass) ) { | |||
| if (!Task.class.isAssignableFrom(taskClass)) { | |||
| TaskAdapter.checkTaskClass(taskClass, this); | |||
| } | |||
| } | |||
| @@ -851,7 +851,7 @@ public class Project { | |||
| * Must not be <code>null</code>. | |||
| */ | |||
| public void addDataTypeDefinition(String typeName, Class typeClass) { | |||
| Class old = (Class)dataClassDefinitions.get(typeName); | |||
| Class old = (Class) dataClassDefinitions.get(typeName); | |||
| if (null != old) { | |||
| if (old.equals(typeClass)) { | |||
| log("Ignoring override for datatype " + typeName | |||
| @@ -978,7 +978,7 @@ public class Project { | |||
| Object o = c.newInstance(); | |||
| Task task = null; | |||
| if (o instanceof Task) { | |||
| task = (Task)o; | |||
| task = (Task) o; | |||
| } else { | |||
| // "Generic" Bean - use the setter pattern | |||
| // and an Adapter | |||
| @@ -1085,7 +1085,7 @@ public class Project { | |||
| o = ctor.newInstance(new Object[] {this}); | |||
| } | |||
| if (o instanceof ProjectComponent) { | |||
| ((ProjectComponent)o).setProject(this); | |||
| ((ProjectComponent) o).setProject(this); | |||
| } | |||
| String msg = " +DataType: " + typeName; | |||
| log (msg, MSG_DEBUG); | |||
| @@ -1115,7 +1115,7 @@ public class Project { | |||
| Throwable error = null; | |||
| for (int i = 0; i < targetNames.size(); i++) { | |||
| executeTarget((String)targetNames.elementAt(i)); | |||
| executeTarget((String) targetNames.elementAt(i)); | |||
| } | |||
| } | |||
| @@ -1129,15 +1129,13 @@ public class Project { | |||
| * or information (<code>false</code>). | |||
| */ | |||
| public void demuxOutput(String line, boolean isError) { | |||
| Task task = (Task)threadTasks.get(Thread.currentThread()); | |||
| Task task = (Task) threadTasks.get(Thread.currentThread()); | |||
| if (task == null) { | |||
| fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO); | |||
| } | |||
| else { | |||
| } else { | |||
| if (isError) { | |||
| task.handleErrorOutput(line); | |||
| } | |||
| else { | |||
| } else { | |||
| task.handleOutput(line); | |||
| } | |||
| } | |||
| @@ -1231,7 +1229,7 @@ public class Project { | |||
| * @see PathTokenizer | |||
| */ | |||
| public static String translatePath(String toProcess) { | |||
| if ( toProcess == null || toProcess.length() == 0 ) { | |||
| if (toProcess == null || toProcess.length() == 0) { | |||
| return ""; | |||
| } | |||
| @@ -1510,12 +1508,11 @@ public class Project { | |||
| tsort(root, targets, state, visiting, ret); | |||
| log("Build sequence for target `" + root + "' is " + ret, MSG_VERBOSE); | |||
| for (Enumeration en = targets.keys(); en.hasMoreElements();) { | |||
| String curTarget = (String)(en.nextElement()); | |||
| String curTarget = (String) en.nextElement(); | |||
| String st = (String) state.get(curTarget); | |||
| if (st == null) { | |||
| tsort(curTarget, targets, state, visiting, ret); | |||
| } | |||
| else if (st == VISITING) { | |||
| } else if (st == VISITING) { | |||
| throw new RuntimeException("Unexpected node in visiting state: " | |||
| + curTarget); | |||
| } | |||
| @@ -1571,7 +1568,7 @@ public class Project { | |||
| state.put(root, VISITING); | |||
| visiting.push(root); | |||
| Target target = (Target)(targets.get(root)); | |||
| Target target = (Target) targets.get(root); | |||
| // Make sure we exist | |||
| if (target == null) { | |||
| @@ -1580,7 +1577,7 @@ public class Project { | |||
| sb.append("' does not exist in this project. "); | |||
| visiting.pop(); | |||
| if (!visiting.empty()) { | |||
| String parent = (String)visiting.peek(); | |||
| String parent = (String) visiting.peek(); | |||
| sb.append("It is used from target `"); | |||
| sb.append(parent); | |||
| sb.append("'."); | |||
| @@ -1591,12 +1588,11 @@ public class Project { | |||
| for (Enumeration en = target.getDependencies(); en.hasMoreElements();) { | |||
| String cur = (String) en.nextElement(); | |||
| String m = (String)state.get(cur); | |||
| String m = (String) state.get(cur); | |||
| if (m == null) { | |||
| // Not been visited | |||
| tsort(cur, targets, state, visiting, ret); | |||
| } | |||
| else if (m == VISITING) { | |||
| } else if (m == VISITING) { | |||
| // Currently visiting this node, so have a cycle | |||
| throw makeCircularException(cur, visiting); | |||
| } | |||
| @@ -1625,7 +1621,7 @@ public class Project { | |||
| sb.append(end); | |||
| String c; | |||
| do { | |||
| c = (String)stk.pop(); | |||
| c = (String) stk.pop(); | |||
| sb.append(" <- "); | |||
| sb.append(c); | |||
| } while (!c.equals(end)); | |||
| @@ -1899,7 +1895,7 @@ public class Project { | |||
| * null if no task is registered. | |||
| */ | |||
| public Task getThreadTask(Thread thread) { | |||
| return (Task)threadTasks.get(thread); | |||
| return (Task) threadTasks.get(thread); | |||
| } | |||
| @@ -105,7 +105,8 @@ public abstract class ProjectComponent { | |||
| * Logs a mesage with the given priority. | |||
| * | |||
| * @param msg The message to be logged. Should not be <code>null</code>. | |||
| * @param msgLevel the message priority at which this message is to be logged. | |||
| * @param msgLevel the message priority at which this message is | |||
| * to be logged. | |||
| */ | |||
| public void log(String msg, int msgLevel) { | |||
| if (project != null) { | |||
| @@ -198,7 +198,7 @@ public class ProjectHelper { | |||
| if (helperClassName != null && | |||
| !"".equals(helperClassName)) { | |||
| helper = newHelper( helperClassName ); | |||
| helper = newHelper(helperClassName); | |||
| } | |||
| } | |||
| } catch (Exception ex) { | |||
| @@ -281,7 +281,7 @@ public class ProjectHelper { | |||
| public static void configure(Object target, AttributeList attrs, | |||
| Project project) throws BuildException { | |||
| if (target instanceof TaskAdapter) { | |||
| target = ((TaskAdapter)target).getProxy(); | |||
| target = ((TaskAdapter) target).getProxy(); | |||
| } | |||
| IntrospectionHelper ih = | |||
| @@ -292,7 +292,7 @@ public class ProjectHelper { | |||
| for (int i = 0; i < attrs.getLength(); i++) { | |||
| // reflect these into the target | |||
| String value = replaceProperties(project, attrs.getValue(i), | |||
| project.getProperties() ); | |||
| project.getProperties()); | |||
| try { | |||
| ih.setAttribute(project, target, | |||
| attrs.getName(i).toLowerCase(Locale.US), value); | |||
| @@ -341,7 +341,7 @@ public class ProjectHelper { | |||
| public static void addText(Project project, Object target, String text) | |||
| throws BuildException { | |||
| if (text == null ) { | |||
| if (text == null) { | |||
| return; | |||
| } | |||
| @@ -368,7 +368,8 @@ public class ProjectHelper { | |||
| */ | |||
| public static void storeChild(Project project, Object parent, | |||
| Object child, String tag) { | |||
| IntrospectionHelper ih = IntrospectionHelper.getHelper(parent.getClass()); | |||
| IntrospectionHelper ih | |||
| = IntrospectionHelper.getHelper(parent.getClass()); | |||
| ih.storeElement(project, parent, child, tag); | |||
| } | |||
| @@ -427,9 +428,9 @@ public class ProjectHelper { | |||
| Enumeration i = fragments.elements(); | |||
| Enumeration j = propertyRefs.elements(); | |||
| while (i.hasMoreElements()) { | |||
| String fragment = (String)i.nextElement(); | |||
| String fragment = (String) i.nextElement(); | |||
| if (fragment == null) { | |||
| String propertyName = (String)j.nextElement(); | |||
| String propertyName = (String) j.nextElement(); | |||
| if (!keys.containsKey(propertyName)) { | |||
| project.log("Property ${" + propertyName | |||
| + "} has not been set", Project.MSG_VERBOSE); | |||
| @@ -476,12 +477,11 @@ public class ProjectHelper { | |||
| } | |||
| //if we are at the end of the string, we tack on a $ | |||
| //then move past it | |||
| if( pos == (value.length() - 1)) { | |||
| if (pos == (value.length() - 1)) { | |||
| fragments.addElement("$"); | |||
| prev = pos + 1; | |||
| } | |||
| //peek ahead to see if the next char is a property or not | |||
| else if (value.charAt(pos + 1) != '{' ) { | |||
| } else if (value.charAt(pos + 1) != '{') { | |||
| //peek ahead to see if the next char is a property or not | |||
| //not a property: insert the char as a literal | |||
| fragments.addElement(value.substring(pos + 1, pos + 2)); | |||
| prev = pos + 2; | |||
| @@ -490,7 +490,7 @@ public class ProjectHelper { | |||
| int endName = value.indexOf('}', pos); | |||
| if (endName < 0) { | |||
| throw new BuildException("Syntax error in property: " | |||
| + value ); | |||
| + value); | |||
| } | |||
| String propertyName = value.substring(pos + 2, endName); | |||
| fragments.addElement(null); | |||
| @@ -208,7 +208,8 @@ public class RuntimeConfigurable { | |||
| } | |||
| Enumeration enum = children.elements(); | |||
| while (enum.hasMoreElements()) { | |||
| RuntimeConfigurable child = (RuntimeConfigurable) enum.nextElement(); | |||
| RuntimeConfigurable child | |||
| = (RuntimeConfigurable) enum.nextElement(); | |||
| if (child.wrappedObject instanceof Task) { | |||
| Task childTask = (Task) child.wrappedObject; | |||
| childTask.setRuntimeConfigurableWrapper(child); | |||
| @@ -216,7 +217,8 @@ public class RuntimeConfigurable { | |||
| } else { | |||
| child.maybeConfigure(p); | |||
| } | |||
| ProjectHelper.storeChild(p, wrappedObject, child.wrappedObject, child.getElementTag().toLowerCase(Locale.US)); | |||
| ProjectHelper.storeChild(p, wrappedObject, child.wrappedObject, | |||
| child.getElementTag().toLowerCase(Locale.US)); | |||
| } | |||
| if (id != null) { | |||
| @@ -120,9 +120,9 @@ public class Target implements TaskContainer { | |||
| // Make sure the dependency is not empty string | |||
| if (token.equals("") || token.equals(",")) { | |||
| throw new BuildException( "Syntax Error: Depend attribute " + | |||
| "for target \"" + getName() + | |||
| "\" has an empty string for dependency." ); | |||
| throw new BuildException("Syntax Error: Depend " | |||
| + "attribute for target \"" + getName() | |||
| + "\" has an empty string for dependency."); | |||
| } | |||
| addDependency(token); | |||
| @@ -132,9 +132,9 @@ public class Target implements TaskContainer { | |||
| if (tok.hasMoreTokens()) { | |||
| token = tok.nextToken(); | |||
| if (!tok.hasMoreTokens() || !token.equals(",")) { | |||
| throw new BuildException( "Syntax Error: Depend attribute " + | |||
| "for target \"" + getName() + | |||
| "\" ends with a , character" ); | |||
| throw new BuildException("Syntax Error: Depend " | |||
| + "attribute for target \"" + getName() | |||
| + "\" ends with a , character"); | |||
| } | |||
| } | |||
| } | |||
| @@ -313,11 +313,11 @@ public class Target implements TaskContainer { | |||
| } | |||
| } | |||
| } else if (!testIfCondition()) { | |||
| project.log(this, "Skipped because property '" + this.ifCondition + "' not set.", | |||
| Project.MSG_VERBOSE); | |||
| project.log(this, "Skipped because property '" + this.ifCondition | |||
| + "' not set.", Project.MSG_VERBOSE); | |||
| } else { | |||
| project.log(this, "Skipped because property '" + this.unlessCondition + "' set.", | |||
| Project.MSG_VERBOSE); | |||
| project.log(this, "Skipped because property '" | |||
| + this.unlessCondition + "' set.", Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| @@ -333,8 +333,7 @@ public class Target implements TaskContainer { | |||
| project.fireTargetStarted(this); | |||
| execute(); | |||
| project.fireTargetFinished(this, null); | |||
| } | |||
| catch(RuntimeException exc) { | |||
| } catch (RuntimeException exc) { | |||
| project.fireTargetFinished(this, exc); | |||
| throw exc; | |||
| } | |||
| @@ -151,7 +151,7 @@ public abstract class Task extends ProjectComponent { | |||
| * available. | |||
| * | |||
| */ | |||
| public void setDescription( String desc ) { | |||
| public void setDescription(String desc) { | |||
| description = desc; | |||
| } | |||
| @@ -312,8 +312,7 @@ public abstract class Task extends ProjectComponent { | |||
| maybeConfigure(); | |||
| execute(); | |||
| project.fireTaskFinished(this, null); | |||
| } | |||
| catch (RuntimeException exc) { | |||
| } catch (RuntimeException exc) { | |||
| if (exc instanceof BuildException) { | |||
| BuildException be = (BuildException) exc; | |||
| if (be.getLocation() == Location.UNKNOWN_LOCATION) { | |||
| @@ -9,7 +9,7 @@ | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| @@ -17,7 +17,7 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| @@ -66,7 +66,7 @@ import java.lang.reflect.Method; | |||
| public class TaskAdapter extends Task { | |||
| /** Object to act as a proxy for. */ | |||
| Object proxy; | |||
| private Object proxy; | |||
| /** | |||
| * Checks whether or not a class is suitable to be adapted by TaskAdapter. | |||
| @@ -86,20 +86,23 @@ public class TaskAdapter extends Task { | |||
| * | |||
| * @see Project#checkTaskClass(Class) | |||
| */ | |||
| public static void checkTaskClass(final Class taskClass, final Project project) { | |||
| public static void checkTaskClass(final Class taskClass, | |||
| final Project project) { | |||
| // don't have to check for interface, since then | |||
| // taskClass would be abstract too. | |||
| try { | |||
| final Method executeM = taskClass.getMethod( "execute", null ); | |||
| final Method executeM = taskClass.getMethod("execute", null); | |||
| // don't have to check for public, since | |||
| // getMethod finds public method only. | |||
| // don't have to check for abstract, since then | |||
| // taskClass would be abstract too. | |||
| if(!Void.TYPE.equals(executeM.getReturnType())) { | |||
| final String message = "return type of execute() should be void but was \""+executeM.getReturnType()+"\" in " + taskClass; | |||
| if (!Void.TYPE.equals(executeM.getReturnType())) { | |||
| final String message = "return type of execute() should be " | |||
| + "void but was \"" + executeM.getReturnType() + "\" in " | |||
| + taskClass; | |||
| project.log(message, Project.MSG_WARN); | |||
| } | |||
| } catch(NoSuchMethodException e) { | |||
| } catch (NoSuchMethodException e) { | |||
| final String message = "No public execute() in " + taskClass; | |||
| project.log(message, Project.MSG_ERR); | |||
| throw new BuildException(message); | |||
| @@ -117,27 +120,29 @@ public class TaskAdapter extends Task { | |||
| try { | |||
| Class c = proxy.getClass(); | |||
| setProjectM = | |||
| c.getMethod( "setProject", new Class[] {Project.class}); | |||
| if(setProjectM != null) { | |||
| c.getMethod("setProject", new Class[] {Project.class}); | |||
| if (setProjectM != null) { | |||
| setProjectM.invoke(proxy, new Object[] {project}); | |||
| } | |||
| } catch (NoSuchMethodException e) { | |||
| // ignore this if the class being used as a task does not have | |||
| // a set project method. | |||
| } catch( Exception ex ) { | |||
| } catch (Exception ex) { | |||
| log("Error setting project in " + proxy.getClass(), | |||
| Project.MSG_ERR); | |||
| throw new BuildException( ex ); | |||
| throw new BuildException(ex); | |||
| } | |||
| Method executeM=null; | |||
| Method executeM = null; | |||
| try { | |||
| Class c=proxy.getClass(); | |||
| executeM=c.getMethod( "execute", new Class[0] ); | |||
| if( executeM == null ) { | |||
| log("No public execute() in " + proxy.getClass(), Project.MSG_ERR); | |||
| throw new BuildException("No public execute() in " + proxy.getClass()); | |||
| Class c = proxy.getClass(); | |||
| executeM = c.getMethod("execute", new Class[0]); | |||
| if (executeM == null) { | |||
| log("No public execute() in " + proxy.getClass(), | |||
| Project.MSG_ERR); | |||
| throw new BuildException("No public execute() in " | |||
| + proxy.getClass()); | |||
| } | |||
| executeM.invoke(proxy, null); | |||
| return; | |||
| @@ -149,9 +154,9 @@ public class TaskAdapter extends Task { | |||
| } else { | |||
| throw new BuildException(t); | |||
| } | |||
| } catch( Exception ex ) { | |||
| } catch (Exception ex) { | |||
| log("Error in " + proxy.getClass(), Project.MSG_ERR); | |||
| throw new BuildException( ex ); | |||
| throw new BuildException(ex); | |||
| } | |||
| } | |||
| @@ -136,7 +136,7 @@ public class UnknownElement extends Task { | |||
| */ | |||
| protected void handleOutput(String line) { | |||
| if (realThing instanceof Task) { | |||
| ((Task)realThing).handleOutput(line); | |||
| ((Task) realThing).handleOutput(line); | |||
| } else { | |||
| super.handleOutput(line); | |||
| } | |||
| @@ -149,7 +149,7 @@ public class UnknownElement extends Task { | |||
| */ | |||
| protected void handleErrorOutput(String line) { | |||
| if (realThing instanceof Task) { | |||
| ((Task)realThing).handleErrorOutput(line); | |||
| ((Task) realThing).handleErrorOutput(line); | |||
| } else { | |||
| super.handleErrorOutput(line); | |||
| } | |||
| @@ -87,7 +87,7 @@ import org.apache.tools.ant.util.StringUtils; | |||
| public class XmlLogger implements BuildListener { | |||
| /** DocumentBuilder to use when creating the document to start with. */ | |||
| private final static DocumentBuilder builder = getDocumentBuilder(); | |||
| private static final DocumentBuilder builder = getDocumentBuilder(); | |||
| /** | |||
| * Returns a default DocumentBuilder instance or throws an | |||
| @@ -98,32 +98,31 @@ public class XmlLogger implements BuildListener { | |||
| private static DocumentBuilder getDocumentBuilder() { | |||
| try { | |||
| return DocumentBuilderFactory.newInstance().newDocumentBuilder(); | |||
| } | |||
| catch(Exception exc) { | |||
| } catch (Exception exc) { | |||
| throw new ExceptionInInitializerError(exc); | |||
| } | |||
| } | |||
| /** XML element name for a build. */ | |||
| private final static String BUILD_TAG = "build"; | |||
| private static final String BUILD_TAG = "build"; | |||
| /** XML element name for a target. */ | |||
| private final static String TARGET_TAG = "target"; | |||
| private static final String TARGET_TAG = "target"; | |||
| /** XML element name for a task. */ | |||
| private final static String TASK_TAG = "task"; | |||
| private static final String TASK_TAG = "task"; | |||
| /** XML element name for a message. */ | |||
| private final static String MESSAGE_TAG = "message"; | |||
| private static final String MESSAGE_TAG = "message"; | |||
| /** XML attribute name for a name. */ | |||
| private final static String NAME_ATTR = "name"; | |||
| private static final String NAME_ATTR = "name"; | |||
| /** XML attribute name for a time. */ | |||
| private final static String TIME_ATTR = "time"; | |||
| private static final String TIME_ATTR = "time"; | |||
| /** XML attribute name for a message priority. */ | |||
| private final static String PRIORITY_ATTR = "priority"; | |||
| private static final String PRIORITY_ATTR = "priority"; | |||
| /** XML attribute name for a file location. */ | |||
| private final static String LOCATION_ATTR = "location"; | |||
| private static final String LOCATION_ATTR = "location"; | |||
| /** XML attribute name for an error description. */ | |||
| private final static String ERROR_ATTR = "error"; | |||
| private static final String ERROR_ATTR = "error"; | |||
| /** XML element name for a stack trace. */ | |||
| private final static String STACKTRACE_TAG = "stacktrace"; | |||
| private static final String STACKTRACE_TAG = "stacktrace"; | |||
| /** The complete log document for this build. */ | |||
| private Document doc = builder.newDocument(); | |||
| @@ -147,9 +146,9 @@ public class XmlLogger implements BuildListener { | |||
| * Start time in milliseconds | |||
| * (as returned by <code>System.currentTimeMillis()</code>). | |||
| */ | |||
| long startTime; | |||
| private long startTime; | |||
| /** Element created at the start time. */ | |||
| Element element; | |||
| private Element element; | |||
| } | |||
| /** | |||
| @@ -179,14 +178,16 @@ public class XmlLogger implements BuildListener { | |||
| */ | |||
| public void buildFinished(BuildEvent event) { | |||
| long totalTime = System.currentTimeMillis() - buildElement.startTime; | |||
| buildElement.element.setAttribute(TIME_ATTR, DefaultLogger.formatTime(totalTime)); | |||
| buildElement.element.setAttribute(TIME_ATTR, | |||
| DefaultLogger.formatTime(totalTime)); | |||
| if (event.getException() != null) { | |||
| buildElement.element.setAttribute(ERROR_ATTR, event.getException().toString()); | |||
| buildElement.element.setAttribute(ERROR_ATTR, | |||
| event.getException().toString()); | |||
| // print the stacktrace in the build file it is always useful... | |||
| // better have too much info than not enough. | |||
| Throwable t = event.getException(); | |||
| Text errText = doc.createCDATASection(StringUtils.getStackTrace(t)); | |||
| Text errText = doc.createCDATASection(StringUtils.getStackTrace(t)); | |||
| Element stacktrace = doc.createElement(STACKTRACE_TAG); | |||
| stacktrace.appendChild(errText); | |||
| buildElement.element.appendChild(stacktrace); | |||
| @@ -196,9 +197,10 @@ public class XmlLogger implements BuildListener { | |||
| if (outFilename == null) { | |||
| outFilename = "log.xml"; | |||
| } | |||
| String xslUri=event.getProject().getProperty("ant.XmlLogger.stylesheet.uri"); | |||
| if(xslUri==null) { | |||
| xslUri="log.xsl"; | |||
| String xslUri | |||
| = event.getProject().getProperty("ant.XmlLogger.stylesheet.uri"); | |||
| if (xslUri == null) { | |||
| xslUri = "log.xsl"; | |||
| } | |||
| Writer out = null; | |||
| try { | |||
| @@ -207,12 +209,13 @@ public class XmlLogger implements BuildListener { | |||
| FileOutputStream fos = new FileOutputStream(outFilename); | |||
| out = new OutputStreamWriter(fos, "UTF8"); | |||
| out.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); | |||
| if(xslUri.length()>0) { | |||
| out.write("<?xml-stylesheet type=\"text/xsl\" href=\""+xslUri+"\"?>\n\n"); | |||
| if (xslUri.length() > 0) { | |||
| out.write("<?xml-stylesheet type=\"text/xsl\" href=\"" | |||
| + xslUri + "\"?>\n\n"); | |||
| } | |||
| (new DOMElementWriter()).write(buildElement.element, out, 0, "\t"); | |||
| out.flush(); | |||
| } catch(IOException exc) { | |||
| } catch (IOException exc) { | |||
| throw new BuildException("Unable to write log file", exc); | |||
| } finally { | |||
| if (out != null){ | |||
| @@ -229,7 +232,7 @@ public class XmlLogger implements BuildListener { | |||
| * @return the stack of timed elements for the current thread | |||
| */ | |||
| private Stack getStack() { | |||
| Stack threadStack = (Stack)threadStacks.get(Thread.currentThread()); | |||
| Stack threadStack = (Stack) threadStacks.get(Thread.currentThread()); | |||
| if (threadStack == null) { | |||
| threadStack = new Stack(); | |||
| threadStacks.put(Thread.currentThread(), threadStack); | |||
| @@ -264,27 +267,29 @@ public class XmlLogger implements BuildListener { | |||
| */ | |||
| public void targetFinished(BuildEvent event) { | |||
| Target target = event.getTarget(); | |||
| TimedElement targetElement = (TimedElement)targets.get(target); | |||
| TimedElement targetElement = (TimedElement) targets.get(target); | |||
| if (targetElement != null) { | |||
| long totalTime = System.currentTimeMillis() - targetElement.startTime; | |||
| targetElement.element.setAttribute(TIME_ATTR, DefaultLogger.formatTime(totalTime)); | |||
| long totalTime | |||
| = System.currentTimeMillis() - targetElement.startTime; | |||
| targetElement.element.setAttribute(TIME_ATTR, | |||
| DefaultLogger.formatTime(totalTime)); | |||
| TimedElement parentElement = null; | |||
| Stack threadStack = getStack(); | |||
| if (!threadStack.empty()) { | |||
| TimedElement poppedStack = (TimedElement)threadStack.pop(); | |||
| TimedElement poppedStack = (TimedElement) threadStack.pop(); | |||
| if (poppedStack != targetElement) { | |||
| throw new RuntimeException("Mismatch - popped element = " + poppedStack.element + | |||
| " finished target element = " + targetElement.element); | |||
| throw new RuntimeException("Mismatch - popped element = " | |||
| + poppedStack.element + " finished target element = " | |||
| + targetElement.element); | |||
| } | |||
| if (!threadStack.empty()) { | |||
| parentElement = (TimedElement)threadStack.peek(); | |||
| parentElement = (TimedElement) threadStack.peek(); | |||
| } | |||
| } | |||
| if (parentElement == null) { | |||
| buildElement.element.appendChild(targetElement.element); | |||
| } | |||
| else { | |||
| } else { | |||
| parentElement.element.appendChild(targetElement.element); | |||
| } | |||
| } | |||
| @@ -306,7 +311,8 @@ public class XmlLogger implements BuildListener { | |||
| String name = event.getTask().getTaskName(); | |||
| taskElement.element.setAttribute(NAME_ATTR, name); | |||
| taskElement.element.setAttribute(LOCATION_ATTR, event.getTask().getLocation().toString()); | |||
| taskElement.element.setAttribute(LOCATION_ATTR, | |||
| event.getTask().getLocation().toString()); | |||
| tasks.put(task, taskElement); | |||
| getStack().push(taskElement); | |||
| } | |||
| @@ -320,27 +326,28 @@ public class XmlLogger implements BuildListener { | |||
| */ | |||
| public void taskFinished(BuildEvent event) { | |||
| Task task = event.getTask(); | |||
| TimedElement taskElement = (TimedElement)tasks.get(task); | |||
| TimedElement taskElement = (TimedElement) tasks.get(task); | |||
| if (taskElement != null) { | |||
| long totalTime = System.currentTimeMillis() - taskElement.startTime; | |||
| taskElement.element.setAttribute(TIME_ATTR, DefaultLogger.formatTime(totalTime)); | |||
| taskElement.element.setAttribute(TIME_ATTR, | |||
| DefaultLogger.formatTime(totalTime)); | |||
| Target target = task.getOwningTarget(); | |||
| TimedElement targetElement = null; | |||
| if (target != null) { | |||
| targetElement = (TimedElement)targets.get(target); | |||
| targetElement = (TimedElement) targets.get(target); | |||
| } | |||
| if (targetElement == null) { | |||
| buildElement.element.appendChild(taskElement.element); | |||
| } | |||
| else { | |||
| } else { | |||
| targetElement.element.appendChild(taskElement.element); | |||
| } | |||
| Stack threadStack = getStack(); | |||
| if (!threadStack.empty()) { | |||
| TimedElement poppedStack = (TimedElement)threadStack.pop(); | |||
| TimedElement poppedStack = (TimedElement) threadStack.pop(); | |||
| if (poppedStack != taskElement) { | |||
| throw new RuntimeException("Mismatch - popped element = " + poppedStack.element + | |||
| " finished task element = " + taskElement.element); | |||
| throw new RuntimeException("Mismatch - popped element = " | |||
| + poppedStack.element + " finished task element = " | |||
| + taskElement.element); | |||
| } | |||
| } | |||
| } | |||
| @@ -374,25 +381,25 @@ public class XmlLogger implements BuildListener { | |||
| Task task = event.getTask(); | |||
| Target target = event.getTarget(); | |||
| if (task != null) { | |||
| parentElement = (TimedElement)tasks.get(task); | |||
| parentElement = (TimedElement) tasks.get(task); | |||
| } | |||
| if (parentElement == null && target != null) { | |||
| parentElement = (TimedElement)targets.get(target); | |||
| parentElement = (TimedElement) targets.get(target); | |||
| } | |||
| if (parentElement == null) { | |||
| Stack threadStack = (Stack)threadStacks.get(Thread.currentThread()); | |||
| Stack threadStack | |||
| = (Stack) threadStacks.get(Thread.currentThread()); | |||
| if (threadStack != null) { | |||
| if (!threadStack.empty()) { | |||
| parentElement = (TimedElement)threadStack.peek(); | |||
| parentElement = (TimedElement) threadStack.peek(); | |||
| } | |||
| } | |||
| } | |||
| if (parentElement != null) { | |||
| parentElement.element.appendChild(messageElement); | |||
| } | |||
| else { | |||
| } else { | |||
| buildElement.element.appendChild(messageElement); | |||
| } | |||
| } | |||