git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270031 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -132,14 +132,14 @@ public class RuntimeConfigurable { | |||
| public String getElementTag() { | |||
| return elementTag; | |||
| } | |||
| /** | |||
| * Configure the wrapped element and all children. | |||
| */ | |||
| public void maybeConfigure(Project p) throws BuildException { | |||
| String id = null; | |||
| String id = null; | |||
| if (attributes != null) { | |||
| ProjectHelper.configure(wrappedObject, attributes, p); | |||
| id = attributes.getValue("id"); | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -72,28 +72,28 @@ public class Deltree extends Task { | |||
| private File dir; | |||
| public void setDir(File dir) { | |||
| this.dir = dir; | |||
| this.dir = dir; | |||
| } | |||
| public void execute() throws BuildException { | |||
| log("DEPRECATED - The deltree task is deprecated. Use delete instead."); | |||
| if (dir == null) { | |||
| throw new BuildException("dir attribute must be set!", location); | |||
| } | |||
| } | |||
| if (dir.exists()) { | |||
| if (!dir.isDirectory()) { | |||
| if (!dir.delete()) { | |||
| throw new BuildException("Unable to delete directory " | |||
| if (dir.exists()) { | |||
| if (!dir.isDirectory()) { | |||
| if (!dir.delete()) { | |||
| throw new BuildException("Unable to delete directory " | |||
| + dir.getAbsolutePath(), | |||
| location); | |||
| } | |||
| return; | |||
| // String msg = "Given dir: " + dir.getAbsolutePath() + | |||
| // " is not a dir"; | |||
| // throw new BuildException(msg); | |||
| } | |||
| } | |||
| return; | |||
| // String msg = "Given dir: " + dir.getAbsolutePath() + | |||
| // " is not a dir"; | |||
| // throw new BuildException(msg); | |||
| } | |||
| log("Deleting: " + dir.getAbsolutePath()); | |||
| @@ -105,31 +105,31 @@ public class Deltree extends Task { | |||
| } | |||
| } | |||
| } | |||
| private void removeDir(File dir) throws IOException { | |||
| // check to make sure that the given dir isn't a symlink | |||
| // the comparison of absolute path and canonical path | |||
| // catches this | |||
| // if (dir.getCanonicalPath().equals(dir.getAbsolutePath())) { | |||
| // (costin) It will not work if /home/costin is symlink to /da0/home/costin ( taz | |||
| // for example ) | |||
| String[] list = dir.list(); | |||
| for (int i = 0; i < list.length; i++) { | |||
| String s = list[i]; | |||
| File f = new File(dir, s); | |||
| if (f.isDirectory()) { | |||
| removeDir(f); | |||
| } else { | |||
| if (!f.delete()) { | |||
| throw new BuildException("Unable to delete file " + f.getAbsolutePath()); | |||
| } | |||
| } | |||
| } | |||
| // if (dir.getCanonicalPath().equals(dir.getAbsolutePath())) { | |||
| // (costin) It will not work if /home/costin is symlink to /da0/home/costin ( taz | |||
| // for example ) | |||
| String[] list = dir.list(); | |||
| for (int i = 0; i < list.length; i++) { | |||
| String s = list[i]; | |||
| File f = new File(dir, s); | |||
| if (f.isDirectory()) { | |||
| removeDir(f); | |||
| } else { | |||
| if (!f.delete()) { | |||
| throw new BuildException("Unable to delete file " + f.getAbsolutePath()); | |||
| } | |||
| } | |||
| } | |||
| if (!dir.delete()) { | |||
| throw new BuildException("Unable to delete directory " + dir.getAbsolutePath()); | |||
| } | |||
| throw new BuildException("Unable to delete directory " + dir.getAbsolutePath()); | |||
| } | |||
| } | |||
| } | |||
| @@ -75,7 +75,7 @@ import java.io.FileNotFoundException; | |||
| * @author rubys@us.ibm.com | |||
| * @author thomas.haas@softwired-inc.com | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| * @author <a href="mailto:mariusz@rakiura.org">Mariusz Nowostawski</a> | |||
| * @author <a href="mailto:mariusz@rakiura.org">Mariusz Nowostawski</a> | |||
| */ | |||
| public class ExecTask extends Task { | |||
| @@ -95,7 +95,7 @@ public class ExecTask extends Task { | |||
| /** Controls whether the VM (1.3 and above) is used to execute the command */ | |||
| private boolean vmLauncher = true; | |||
| /** | |||
| * Timeout in milliseconds after which the process will be killed. | |||
| */ | |||
| @@ -146,7 +146,7 @@ public class ExecTask extends Task { | |||
| * the process | |||
| */ | |||
| public void setOutputproperty(String outputprop) { | |||
| this.outputprop = outputprop; | |||
| this.outputprop = outputprop; | |||
| } | |||
| /** | |||
| @@ -195,10 +195,10 @@ public class ExecTask extends Task { | |||
| throw new BuildException("no executable specified", location); | |||
| } | |||
| if (dir != null && !dir.exists()) { | |||
| throw new BuildException("The directory you specified does not exist"); | |||
| throw new BuildException("The directory you specified does not exist"); | |||
| } | |||
| if (dir != null && !dir.isDirectory()) { | |||
| throw new BuildException("The directory you specified is not a directory"); | |||
| throw new BuildException("The directory you specified is not a directory"); | |||
| } | |||
| } | |||
| @@ -224,7 +224,7 @@ public class ExecTask extends Task { | |||
| public void setVMLauncher(boolean vmLauncher) { | |||
| this.vmLauncher = vmLauncher; | |||
| } | |||
| /** | |||
| * Create an Execute instance with the correct working directory set. | |||
| */ | |||
| @@ -233,7 +233,7 @@ public class ExecTask extends Task { | |||
| if (dir == null) dir = project.getBaseDir(); | |||
| // show the command | |||
| log(cmdl.toString(), Project.MSG_VERBOSE); | |||
| Execute exe = new Execute(createHandler(), createWatchdog()); | |||
| exe.setAntRun(project); | |||
| exe.setWorkingDirectory(dir); | |||
| @@ -265,7 +265,7 @@ public class ExecTask extends Task { | |||
| } | |||
| } | |||
| if (baos != null) { | |||
| BufferedReader in = | |||
| BufferedReader in = | |||
| new BufferedReader(new StringReader(baos.toString())); | |||
| String line = null; | |||
| StringBuffer val = new StringBuffer(); | |||
| @@ -278,7 +278,7 @@ public class ExecTask extends Task { | |||
| project.setProperty(outputprop, val.toString()); | |||
| } | |||
| } | |||
| /** | |||
| * Run the command using the given Execute instance. This may be overidden by subclasses | |||
| */ | |||
| @@ -309,10 +309,10 @@ public class ExecTask extends Task { | |||
| throw new BuildException("Cannot write to "+out, ioe, location); | |||
| } | |||
| } else if (outputprop != null) { | |||
| // try { | |||
| baos = new ByteArrayOutputStream(); | |||
| log("Output redirected to ByteArray", Project.MSG_VERBOSE); | |||
| return new PumpStreamHandler(baos); | |||
| // try { | |||
| baos = new ByteArrayOutputStream(); | |||
| log("Output redirected to ByteArray", Project.MSG_VERBOSE); | |||
| return new PumpStreamHandler(baos); | |||
| } else { | |||
| return new LogStreamHandler(this, | |||
| Project.MSG_INFO, Project.MSG_WARN); | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -67,9 +67,9 @@ import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| /** | |||
| * Get a particular file from a URL source. | |||
| * Options include verbose reporting, timestamp based fetches and controlling | |||
| * actions on failures. NB: access through a firewall only works if the whole | |||
| * Get a particular file from a URL source. | |||
| * Options include verbose reporting, timestamp based fetches and controlling | |||
| * actions on failures. NB: access through a firewall only works if the whole | |||
| * Java runtime is correctly configured. | |||
| * | |||
| * @author costin@dnt.ro | |||
| @@ -84,7 +84,7 @@ public class Get extends Task { | |||
| private String uname = null; | |||
| private String pword = null; | |||
| /** | |||
| * Does the work. | |||
| * | |||
| @@ -99,12 +99,12 @@ public class Get extends Task { | |||
| throw new BuildException("dest attribute is required", location); | |||
| } | |||
| if (dest.exists() && dest.isDirectory()) { | |||
| if (dest.exists() && dest.isDirectory()) { | |||
| throw new BuildException("The specified destination is a directory", | |||
| location); | |||
| } | |||
| if (dest.exists() && !dest.canWrite()) { | |||
| if (dest.exists() && !dest.canWrite()) { | |||
| throw new BuildException("Can't write to " + dest.getAbsolutePath(), | |||
| location); | |||
| } | |||
| @@ -123,10 +123,10 @@ public class Get extends Task { | |||
| Date t=new Date(timestamp); | |||
| log("local file date : "+t.toString()); | |||
| } | |||
| hasTimestamp=true; | |||
| } | |||
| //set up the URL connection | |||
| URLConnection connection=source.openConnection(); | |||
| //modify the headers | |||
| @@ -134,24 +134,23 @@ public class Get extends Task { | |||
| if(useTimestamp && hasTimestamp) { | |||
| connection.setIfModifiedSince(timestamp); | |||
| } | |||
| // prepare Java 1.1 style credentials | |||
| if (uname != null || pword != null) { | |||
| String up = uname + ":" + pword; | |||
| String encoding; | |||
| // check to see if sun's Base64 encoder is available. | |||
| try { | |||
| sun.misc.BASE64Encoder encoder = | |||
| (sun.misc.BASE64Encoder) Class.forName("sun.misc.BASE64Encoder").newInstance(); | |||
| encoding = encoder.encode (up.getBytes()); | |||
| } | |||
| catch (Exception ex) { // sun's base64 encoder isn't available | |||
| Base64Converter encoder = new Base64Converter(); | |||
| encoding = encoder.encode(up.getBytes()); | |||
| } | |||
| connection.setRequestProperty ("Authorization", "Basic " + encoding); | |||
| } | |||
| // prepare Java 1.1 style credentials | |||
| if (uname != null || pword != null) { | |||
| String up = uname + ":" + pword; | |||
| String encoding; | |||
| // check to see if sun's Base64 encoder is available. | |||
| try { | |||
| sun.misc.BASE64Encoder encoder = | |||
| (sun.misc.BASE64Encoder) Class.forName("sun.misc.BASE64Encoder").newInstance(); | |||
| encoding = encoder.encode (up.getBytes()); | |||
| } | |||
| catch (Exception ex) { // sun's base64 encoder isn't available | |||
| Base64Converter encoder = new Base64Converter(); | |||
| encoding = encoder.encode(up.getBytes()); | |||
| } | |||
| connection.setRequestProperty ("Authorization", "Basic " + encoding); | |||
| } | |||
| //connect to the remote site (may take some time) | |||
| connection.connect(); | |||
| @@ -160,23 +159,23 @@ public class Get extends Task { | |||
| HttpURLConnection httpConnection=(HttpURLConnection)connection; | |||
| if(httpConnection.getResponseCode()==HttpURLConnection.HTTP_NOT_MODIFIED) { | |||
| //not modified so no file download. just return instead | |||
| //and trace out something so the user doesn't think that the | |||
| //and trace out something so the user doesn't think that the | |||
| //download happened when it didnt | |||
| log("Not modified - so not downloaded"); | |||
| return; | |||
| return; | |||
| } | |||
| // test for 401 result (HTTP only) | |||
| // test for 401 result (HTTP only) | |||
| if(httpConnection.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED) { | |||
| log("Not authorized - check " + dest + " for details"); | |||
| return; | |||
| return; | |||
| } | |||
| } | |||
| //REVISIT: at this point even non HTTP connections may support the if-modified-since | |||
| //behaviour -we just check the date of the content and skip the write if it is not | |||
| //newer. Some protocols (FTP) dont include dates, of course. | |||
| //newer. Some protocols (FTP) dont include dates, of course. | |||
| FileOutputStream fos = new FileOutputStream(dest); | |||
| InputStream is=null; | |||
| @@ -190,15 +189,15 @@ public class Get extends Task { | |||
| } | |||
| if( is==null ) { | |||
| log( "Can't get " + source + " to " + dest); | |||
| if(ignoreErrors) | |||
| if(ignoreErrors) | |||
| return; | |||
| throw new BuildException( "Can't get " + source + " to " + dest, | |||
| location); | |||
| } | |||
| byte[] buffer = new byte[100 * 1024]; | |||
| int length; | |||
| while ((length = is.read(buffer)) >= 0) { | |||
| fos.write(buffer, 0, length); | |||
| if (verbose) System.out.print("."); | |||
| @@ -206,8 +205,8 @@ public class Get extends Task { | |||
| if(verbose) System.out.println(); | |||
| fos.close(); | |||
| is.close(); | |||
| //if (and only if) the use file time option is set, then the | |||
| //if (and only if) the use file time option is set, then the | |||
| //saved file now has its timestamp set to that of the downloaded file | |||
| if(useTimestamp) { | |||
| long remoteTimestamp=connection.getLastModified(); | |||
| @@ -219,18 +218,15 @@ public class Get extends Task { | |||
| if(remoteTimestamp!=0) | |||
| touchFile(dest,remoteTimestamp); | |||
| } | |||
| } catch (IOException ioe) { | |||
| log("Error getting " + source + " to " + dest ); | |||
| if(ignoreErrors) | |||
| if(ignoreErrors) | |||
| return; | |||
| throw new BuildException(ioe, location); | |||
| } | |||
| } | |||
| /** | |||
| /** | |||
| * set the timestamp of a named file to a specified time. | |||
| * | |||
| * @param filename | |||
| @@ -240,7 +236,7 @@ public class Get extends Task { | |||
| *@exception BuildException Thrown in unrecoverable error. Likely | |||
| *this comes from file access failures. | |||
| */ | |||
| protected boolean touchFile(File file, long timemillis) | |||
| protected boolean touchFile(File file, long timemillis) | |||
| throws BuildException { | |||
| if (project.getJavaVersion() != Project.JAVA_1_1) { | |||
| @@ -252,11 +248,11 @@ public class Get extends Task { | |||
| touch.setMillis(timemillis); | |||
| touch.touch(); | |||
| return true; | |||
| } else { | |||
| return false; | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Set the URL. | |||
| @@ -300,13 +296,13 @@ public class Get extends Task { | |||
| * <p>In this situation, the if-modified-since header is set so that the file is | |||
| * only fetched if it is newer than the local file (or there is no local file) | |||
| * This flag is only valid on HTTP connections, it is ignored in other cases. | |||
| * When the flag is set, the local copy of the downloaded file will also | |||
| * have its timestamp set to the remote file time. | |||
| * When the flag is set, the local copy of the downloaded file will also | |||
| * have its timestamp set to the remote file time. | |||
| * <br> | |||
| * Note that remote files of date 1/1/1970 (GMT) are treated as 'no timestamp', and | |||
| * web servers often serve files with a timestamp in the future by replacing their timestamp | |||
| * with that of the current time. Also, inter-computer clock differences can cause no end of | |||
| * grief. | |||
| * with that of the current time. Also, inter-computer clock differences can cause no end of | |||
| * grief. | |||
| * @param v "true" to enable file time fetching | |||
| */ | |||
| public void setUseTimestamp(boolean v) { | |||
| @@ -334,95 +330,92 @@ public class Get extends Task { | |||
| this.pword = p; | |||
| } | |||
| /********************************************************************* | |||
| * BASE 64 encoding of a String or an array of bytes. | |||
| * | |||
| * Based on RFC 1421. | |||
| * | |||
| * @author | |||
| * Unknown | |||
| * @author | |||
| * <a HREF="gg@grtmail.com">Gautam Guliani</a> | |||
| *********************************************************************/ | |||
| class Base64Converter | |||
| { | |||
| public final char [ ] alphabet = { | |||
| 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7 | |||
| 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8 to 15 | |||
| 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16 to 23 | |||
| 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24 to 31 | |||
| 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32 to 39 | |||
| 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40 to 47 | |||
| 'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48 to 55 | |||
| '4', '5', '6', '7', '8', '9', '+', '/' }; // 56 to 63 | |||
| public String encode ( String s ) | |||
| { | |||
| return encode ( s.getBytes ( ) ); | |||
| } | |||
| public String encode ( byte [ ] octetString ) | |||
| { | |||
| int bits24; | |||
| int bits6; | |||
| char [ ] out | |||
| = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ]; | |||
| int outIndex = 0; | |||
| int i = 0; | |||
| while ( ( i + 3 ) <= octetString.length ) { | |||
| // store the octets | |||
| bits24=( octetString [ i++ ] & 0xFF ) << 16; | |||
| bits24 |=( octetString [ i++ ] & 0xFF ) << 8; | |||
| bits6=( bits24 & 0x00FC0000 )>> 18; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x0003F000 ) >> 12; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x00000FC0 ) >> 6; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x0000003F ); | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| } | |||
| if ( octetString.length - i == 2 ) | |||
| { | |||
| // store the octets | |||
| bits24 = ( octetString [ i ] & 0xFF ) << 16; | |||
| bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8; | |||
| bits6=( bits24 & 0x00FC0000 )>> 18; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x0003F000 ) >> 12; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x00000FC0 ) >> 6; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| // padding | |||
| out [ outIndex++ ] = '='; | |||
| } | |||
| else if ( octetString.length - i == 1 ) | |||
| { | |||
| // store the octets | |||
| bits24 = ( octetString [ i ] & 0xFF ) << 16; | |||
| bits6=( bits24 & 0x00FC0000 )>> 18; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x0003F000 ) >> 12; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| // padding | |||
| out [ outIndex++ ] = '='; | |||
| out [ outIndex++ ] = '='; | |||
| } | |||
| return new String ( out ); | |||
| } | |||
| /********************************************************************* | |||
| * BASE 64 encoding of a String or an array of bytes. | |||
| * | |||
| * Based on RFC 1421. | |||
| * | |||
| * @author | |||
| * Unknown | |||
| * @author | |||
| * <a HREF="gg@grtmail.com">Gautam Guliani</a> | |||
| *********************************************************************/ | |||
| class Base64Converter | |||
| { | |||
| public final char [ ] alphabet = { | |||
| 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7 | |||
| 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8 to 15 | |||
| 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16 to 23 | |||
| 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24 to 31 | |||
| 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32 to 39 | |||
| 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40 to 47 | |||
| 'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48 to 55 | |||
| '4', '5', '6', '7', '8', '9', '+', '/' }; // 56 to 63 | |||
| public String encode ( String s ) | |||
| { | |||
| return encode ( s.getBytes ( ) ); | |||
| } | |||
| } | |||
| public String encode ( byte [ ] octetString ) | |||
| { | |||
| int bits24; | |||
| int bits6; | |||
| char [ ] out | |||
| = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ]; | |||
| int outIndex = 0; | |||
| int i = 0; | |||
| while ( ( i + 3 ) <= octetString.length ) { | |||
| // store the octets | |||
| bits24=( octetString [ i++ ] & 0xFF ) << 16; | |||
| bits24 |=( octetString [ i++ ] & 0xFF ) << 8; | |||
| bits6=( bits24 & 0x00FC0000 )>> 18; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x0003F000 ) >> 12; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x00000FC0 ) >> 6; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x0000003F ); | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| } | |||
| if ( octetString.length - i == 2 ) | |||
| { | |||
| // store the octets | |||
| bits24 = ( octetString [ i ] & 0xFF ) << 16; | |||
| bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8; | |||
| bits6=( bits24 & 0x00FC0000 )>> 18; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x0003F000 ) >> 12; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x00000FC0 ) >> 6; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| // padding | |||
| out [ outIndex++ ] = '='; | |||
| } | |||
| else if ( octetString.length - i == 1 ) | |||
| { | |||
| // store the octets | |||
| bits24 = ( octetString [ i ] & 0xFF ) << 16; | |||
| bits6=( bits24 & 0x00FC0000 )>> 18; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| bits6 = ( bits24 & 0x0003F000 ) >> 12; | |||
| out [ outIndex++ ] = alphabet [ bits6 ]; | |||
| // padding | |||
| out [ outIndex++ ] = '='; | |||
| out [ outIndex++ ] = '='; | |||
| } | |||
| return new String ( out ); | |||
| } | |||
| } | |||
| } | |||
| @@ -134,7 +134,7 @@ public class Javac extends MatchingTask { | |||
| private String source; | |||
| private String debugLevel; | |||
| /** | |||
| * Get the value of debugLevel. | |||
| * @return value of debugLevel. | |||
| @@ -158,7 +158,7 @@ public class Javac extends MatchingTask { | |||
| public String getSource() { | |||
| return source; | |||
| } | |||
| /** | |||
| * Set the value of source. | |||
| * @param v Value to assign to source. | |||
| @@ -500,7 +500,7 @@ public class Javac extends MatchingTask { | |||
| * Is this a forked invocation of JDK's javac? | |||
| */ | |||
| public boolean isForkedJavac() { | |||
| return !"false".equals(fork) || | |||
| return !"false".equals(fork) || | |||
| "extJavac".equals(project.getProperty("build.compiler")); | |||
| } | |||
| @@ -534,7 +534,7 @@ public class Javac extends MatchingTask { | |||
| * Adds an implementation specific command line argument. | |||
| */ | |||
| public ImplementationSpecificArgument createCompilerArg() { | |||
| ImplementationSpecificArgument arg = | |||
| ImplementationSpecificArgument arg = | |||
| new ImplementationSpecificArgument(); | |||
| implementationSpecificArgs.addElement(arg); | |||
| return arg; | |||
| @@ -546,10 +546,10 @@ public class Javac extends MatchingTask { | |||
| */ | |||
| public String[] getCurrentCompilerArgs() { | |||
| Vector args = new Vector(); | |||
| for (Enumeration enum = implementationSpecificArgs.elements(); | |||
| for (Enumeration enum = implementationSpecificArgs.elements(); | |||
| enum.hasMoreElements(); | |||
| ) { | |||
| String[] curr = | |||
| String[] curr = | |||
| ((ImplementationSpecificArgument) enum.nextElement()).getParts(); | |||
| for (int i=0; i<curr.length; i++) { | |||
| args.addElement(curr[i]); | |||
| @@ -666,25 +666,25 @@ public class Javac extends MatchingTask { | |||
| } | |||
| protected String getSystemJavac() { | |||
| // This is the most common extension case - exe for windows and OS/2, | |||
| // This is the most common extension case - exe for windows and OS/2, | |||
| // nothing for *nix. | |||
| String extension = Os.isFamily("dos") ? ".exe" : ""; | |||
| String extension = Os.isFamily("dos") ? ".exe" : ""; | |||
| // Look for java in the java.home/../bin directory. Unfortunately | |||
| // on Windows java.home doesn't always refer to the correct location, | |||
| // so we need to fall back to assuming java is somewhere on the | |||
| // PATH. | |||
| java.io.File jExecutable = | |||
| // Look for java in the java.home/../bin directory. Unfortunately | |||
| // on Windows java.home doesn't always refer to the correct location, | |||
| // so we need to fall back to assuming java is somewhere on the | |||
| // PATH. | |||
| java.io.File jExecutable = | |||
| new java.io.File(System.getProperty("java.home") + | |||
| "/../bin/javac" + extension ); | |||
| if (jExecutable.exists() && !Os.isFamily("netware")) { | |||
| return jExecutable.getAbsolutePath(); | |||
| } else { | |||
| return "javac"; | |||
| } | |||
| if (jExecutable.exists() && !Os.isFamily("netware")) { | |||
| return jExecutable.getAbsolutePath(); | |||
| } else { | |||
| return "javac"; | |||
| } | |||
| } | |||
| private String determineCompiler() { | |||
| String compiler = project.getProperty("build.compiler"); | |||
| @@ -107,15 +107,15 @@ public class Javadoc extends Task { | |||
| public class DocletParam { | |||
| private String name; | |||
| private String value; | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setValue(String value) { | |||
| this.value = value; | |||
| } | |||
| @@ -128,17 +128,17 @@ public class Javadoc extends Task { | |||
| public class DocletInfo { | |||
| private String name; | |||
| private Path path; | |||
| private Vector params = new Vector(); | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setPath(Path path) { | |||
| if (this.path == null) { | |||
| this.path = path; | |||
| @@ -150,7 +150,7 @@ public class Javadoc extends Task { | |||
| public Path getPath() { | |||
| return path; | |||
| } | |||
| public Path createPath() { | |||
| if (path == null) { | |||
| path = new Path(getProject()); | |||
| @@ -168,10 +168,10 @@ public class Javadoc extends Task { | |||
| public DocletParam createParam() { | |||
| DocletParam param = new DocletParam(); | |||
| params.addElement(param); | |||
| return param; | |||
| } | |||
| public Enumeration getParams() { | |||
| return params.elements(); | |||
| } | |||
| @@ -219,7 +219,7 @@ public class Javadoc extends Task { | |||
| } | |||
| private Commandline cmd = new Commandline(); | |||
| private static boolean javadoc1 = | |||
| private static boolean javadoc1 = | |||
| (Project.getJavaVersion() == Project.JAVA_1_1); | |||
| @@ -235,11 +235,11 @@ public class Javadoc extends Task { | |||
| cmd.createArgument().setValue(key); | |||
| cmd.createArgument().setValue(value); | |||
| } else { | |||
| project.log(this, | |||
| "Warning: Leaving out empty argument '" + key + "'", | |||
| project.log(this, | |||
| "Warning: Leaving out empty argument '" + key + "'", | |||
| Project.MSG_WARN); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| private void add11ArgIf(boolean b, String arg) { | |||
| @@ -294,7 +294,7 @@ public class Javadoc extends Task { | |||
| /** | |||
| * Sets whether default exclusions should be used or not. | |||
| * | |||
| * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions | |||
| * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions | |||
| * should be used, "false"|"off"|"no" when they | |||
| * shouldn't be used. | |||
| */ | |||
| @@ -313,7 +313,7 @@ public class Javadoc extends Task { | |||
| public void setAdditionalparam(String add){ | |||
| cmd.createArgument().setLine(add); | |||
| } | |||
| public void setSourcepath(Path src) { | |||
| if (sourcePath == null) { | |||
| sourcePath = src; | |||
| @@ -405,7 +405,7 @@ public class Javadoc extends Task { | |||
| } | |||
| doclet.setName(src); | |||
| } | |||
| public void setDocletPath(Path src) { | |||
| if (doclet == null) { | |||
| doclet = new DocletInfo(); | |||
| @@ -551,17 +551,17 @@ public class Javadoc extends Task { | |||
| if (!javadoc1) { | |||
| LinkArgument le = createLink(); | |||
| le.setOffline(true); | |||
| String linkOfflineError = "The linkoffline attribute must include a URL and " + | |||
| String linkOfflineError = "The linkoffline attribute must include a URL and " + | |||
| "a package-list file location separated by a space"; | |||
| if (src.trim().length() == 0) { | |||
| throw new BuildException(linkOfflineError); | |||
| } | |||
| } | |||
| StringTokenizer tok = new StringTokenizer(src, " ", false); | |||
| le.setHref(tok.nextToken()); | |||
| if (!tok.hasMoreTokens()) { | |||
| throw new BuildException(linkOfflineError); | |||
| } | |||
| } | |||
| le.setPackagelistLoc(project.resolveFile(tok.nextToken())); | |||
| } | |||
| } | |||
| @@ -613,46 +613,46 @@ public class Javadoc extends Task { | |||
| public void setPackageList(String src) { | |||
| packageList = src; | |||
| } | |||
| public LinkArgument createLink() { | |||
| LinkArgument la = new LinkArgument(); | |||
| links.addElement(la); | |||
| return la; | |||
| } | |||
| public class LinkArgument { | |||
| private String href; | |||
| private boolean offline = false; | |||
| private File packagelistLoc; | |||
| public LinkArgument() { | |||
| } | |||
| public void setHref(String hr) { | |||
| href = hr; | |||
| } | |||
| public String getHref() { | |||
| return href; | |||
| } | |||
| public void setPackagelistLoc(File src) { | |||
| packagelistLoc = src; | |||
| } | |||
| public File getPackagelistLoc() { | |||
| return packagelistLoc; | |||
| } | |||
| public void setOffline(boolean offline) { | |||
| this.offline = offline; | |||
| } | |||
| public boolean isLinkOffline() { | |||
| return offline; | |||
| } | |||
| } | |||
| public GroupArgument createGroup() { | |||
| GroupArgument ga = new GroupArgument(); | |||
| groups.addElement(ga); | |||
| @@ -703,7 +703,7 @@ public class Javadoc extends Task { | |||
| return p.toString(); | |||
| } | |||
| } | |||
| public void setCharset(String src) { | |||
| this.add12ArgIfNotEmpty("-charset", src); | |||
| } | |||
| @@ -778,7 +778,7 @@ public class Javadoc extends Task { | |||
| throw new BuildException(msg); | |||
| } | |||
| } | |||
| // --------------------------------- javadoc2 arguments for default doclet | |||
| @@ -789,7 +789,7 @@ public class Javadoc extends Task { | |||
| if (doclet.getName() == null) { | |||
| throw new BuildException("The doclet name must be specified.", location); | |||
| } | |||
| else { | |||
| else { | |||
| toExecute.createArgument().setValue("-doclet"); | |||
| toExecute.createArgument().setValue(doclet.getName()); | |||
| if (doclet.getPath() != null) { | |||
| @@ -801,28 +801,28 @@ public class Javadoc extends Task { | |||
| if (param.getName() == null) { | |||
| throw new BuildException("Doclet parameters must have a name"); | |||
| } | |||
| toExecute.createArgument().setValue(param.getName()); | |||
| if (param.getValue() != null) { | |||
| toExecute.createArgument().setValue(param.getValue()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| if (bootclasspath != null) { | |||
| toExecute.createArgument().setValue("-bootclasspath"); | |||
| toExecute.createArgument().setPath(bootclasspath); | |||
| } | |||
| // add the links arguments | |||
| if (links.size() != 0) { | |||
| for (Enumeration e = links.elements(); e.hasMoreElements(); ) { | |||
| LinkArgument la = (LinkArgument)e.nextElement(); | |||
| if (la.getHref() == null) { | |||
| throw new BuildException("Links must provide the URL to the external class documentation."); | |||
| } | |||
| if (la.isLinkOffline()) { | |||
| File packageListLocation = la.getPackagelistLoc(); | |||
| if (packageListLocation == null) { | |||
| @@ -836,7 +836,7 @@ public class Javadoc extends Task { | |||
| toExecute.createArgument().setValue(packageListLocation.getAbsolutePath()); | |||
| } | |||
| else { | |||
| log("Warning: No package list was found at " + packageListLocation, | |||
| log("Warning: No package list was found at " + packageListLocation, | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| @@ -845,8 +845,8 @@ public class Javadoc extends Task { | |||
| toExecute.createArgument().setValue(la.getHref()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| // add the single group arguments | |||
| // Javadoc 1.2 rules: | |||
| // Multiple -group args allowed. | |||
| @@ -872,7 +872,7 @@ public class Javadoc extends Task { | |||
| } | |||
| } | |||
| } | |||
| // add the group arguments | |||
| if (groups.size() != 0) { | |||
| for (Enumeration e = groups.elements(); e.hasMoreElements(); ) { | |||
| @@ -929,10 +929,10 @@ public class Javadoc extends Task { | |||
| tmpList = fileUtils.createTempFile("javadoc", "", null); | |||
| toExecute.createArgument().setValue("@" + tmpList.getAbsolutePath()); | |||
| } | |||
| srcListWriter = new PrintWriter(new FileWriter(tmpList.getAbsolutePath(), | |||
| srcListWriter = new PrintWriter(new FileWriter(tmpList.getAbsolutePath(), | |||
| true)); | |||
| } | |||
| Enumeration enum = sourceFiles.elements(); | |||
| while (enum.hasMoreElements()) { | |||
| SourceFile sf = (SourceFile) enum.nextElement(); | |||
| @@ -945,7 +945,7 @@ public class Javadoc extends Task { | |||
| } | |||
| } catch (IOException e) { | |||
| throw new BuildException("Error creating temporary file", | |||
| throw new BuildException("Error creating temporary file", | |||
| e, location); | |||
| } finally { | |||
| if (srcListWriter != null) { | |||
| @@ -965,7 +965,7 @@ public class Javadoc extends Task { | |||
| JavadocOutputStream err = new JavadocOutputStream(Project.MSG_WARN); | |||
| Execute exe = new Execute(new PumpStreamHandler(out, err)); | |||
| exe.setAntRun(project); | |||
| /* | |||
| * No reason to change the working directory as all filenames and | |||
| * path components have been resolved already. | |||
| @@ -987,7 +987,7 @@ public class Javadoc extends Task { | |||
| tmpList.delete(); | |||
| tmpList = null; | |||
| } | |||
| out.logFlush(); | |||
| err.logFlush(); | |||
| try { | |||
| @@ -1002,7 +1002,7 @@ public class Javadoc extends Task { | |||
| * with the packages found in that path subdirs matching one of the given | |||
| * patterns. | |||
| */ | |||
| private void evaluatePackages(Commandline toExecute, Path sourcePath, | |||
| private void evaluatePackages(Commandline toExecute, Path sourcePath, | |||
| Vector packages, Vector excludePackages) { | |||
| log("Source path = " + sourcePath.toString(), Project.MSG_VERBOSE); | |||
| StringBuffer msg = new StringBuffer("Packages = "); | |||
| @@ -1050,10 +1050,10 @@ public class Javadoc extends Task { | |||
| if (pkg.endsWith("*")) { | |||
| pkg += "*"; | |||
| } | |||
| fs.createExclude().setName(pkg); | |||
| } | |||
| PrintWriter packageListWriter = null; | |||
| try { | |||
| if (useExternalFile) { | |||
| @@ -1066,10 +1066,10 @@ public class Javadoc extends Task { | |||
| for (int j=0; j<list.length; j++) { | |||
| File source = project.resolveFile(list[j]); | |||
| fs.setDir(source); | |||
| DirectoryScanner ds = fs.getDirectoryScanner(project); | |||
| String[] packageDirs = ds.getIncludedDirectories(); | |||
| for (int i=0; i<packageDirs.length; i++) { | |||
| File pd = new File(source, packageDirs[i]); | |||
| String[] files = pd.list(new FilenameFilter () { | |||
| @@ -1080,7 +1080,7 @@ public class Javadoc extends Task { | |||
| return false; // ignore dirs | |||
| } | |||
| }); | |||
| if (files.length > 0) { | |||
| String pkgDir = packageDirs[i].replace('/','.').replace('\\','.'); | |||
| if (!addedPackages.contains(pkgDir)) { | |||
| @@ -1095,7 +1095,7 @@ public class Javadoc extends Task { | |||
| } | |||
| } | |||
| } catch (IOException ioex) { | |||
| throw new BuildException("Error creating temporary file", | |||
| throw new BuildException("Error creating temporary file", | |||
| ioex, location); | |||
| } finally { | |||
| if (packageListWriter != null) { | |||
| @@ -1133,7 +1133,7 @@ public class Javadoc extends Task { | |||
| } | |||
| } | |||
| protected void logFlush() { | |||
| if (queuedLine != null) { | |||
| super.processLine(queuedLine, Project.MSG_VERBOSE); | |||
| @@ -1146,15 +1146,15 @@ public class Javadoc extends Task { | |||
| * Convenience method to expand properties. | |||
| */ | |||
| protected String expand(String content) { | |||
| return ProjectHelper.replaceProperties(project, content, | |||
| return ProjectHelper.replaceProperties(project, content, | |||
| project.getProperties()); | |||
| } | |||
| private String getJavadocExecutableName() | |||
| { | |||
| // This is the most common extension case - exe for windows and OS/2, | |||
| // This is the most common extension case - exe for windows and OS/2, | |||
| // nothing for *nix. | |||
| String extension = Os.isFamily("dos") ? ".exe" : ""; | |||
| String extension = Os.isFamily("dos") ? ".exe" : ""; | |||
| // Look for javadoc in the java.home/../bin directory. Unfortunately | |||
| // on Windows java.home doesn't always refer to the correct location, | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -50,7 +50,7 @@ | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| */ | |||
| package org.apache.tools.ant.taskdefs; | |||
| @@ -68,7 +68,7 @@ import java.io.File; | |||
| public class Mkdir extends Task { | |||
| private File dir; | |||
| public void execute() throws BuildException { | |||
| if (dir == null) { | |||
| throw new BuildException("dir attribute is required", location); | |||
| @@ -77,19 +77,19 @@ public class Mkdir extends Task { | |||
| if (dir.isFile()) { | |||
| throw new BuildException("Unable to create directory as a file already exists with that name: " + dir.getAbsolutePath()); | |||
| } | |||
| if (!dir.exists()) { | |||
| boolean result = dir.mkdirs(); | |||
| if (result == false) { | |||
| String msg = "Directory " + dir.getAbsolutePath() + " creation was not " + | |||
| "successful for an unknown reason"; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| log("Created dir: " + dir.getAbsolutePath()); | |||
| } | |||
| boolean result = dir.mkdirs(); | |||
| if (result == false) { | |||
| String msg = "Directory " + dir.getAbsolutePath() + " creation was not " + | |||
| "successful for an unknown reason"; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| log("Created dir: " + dir.getAbsolutePath()); | |||
| } | |||
| } | |||
| public void setDir(File dir) { | |||
| this.dir = dir; | |||
| this.dir = dir; | |||
| } | |||
| } | |||
| @@ -80,9 +80,9 @@ public class Kjc extends DefaultCompilerAdapter { | |||
| Class c = Class.forName("at.dms.kjc.Main"); | |||
| // Call the compile() method | |||
| Method compile = c.getMethod("compile", | |||
| Method compile = c.getMethod("compile", | |||
| new Class [] { String [].class }); | |||
| Boolean ok = (Boolean)compile.invoke(null, | |||
| Boolean ok = (Boolean)compile.invoke(null, | |||
| new Object[] {cmd.getArguments()}); | |||
| return ok.booleanValue(); | |||
| } | |||
| @@ -105,8 +105,8 @@ public class Kjc extends DefaultCompilerAdapter { | |||
| */ | |||
| protected Commandline setupKjcCommand() { | |||
| Commandline cmd = new Commandline(); | |||
| // generate classpath, because kjc does't support sourcepath. | |||
| // generate classpath, because kjc does't support sourcepath. | |||
| Path classpath = getCompileClasspath(); | |||
| if (deprecation == true) { | |||
| @@ -118,26 +118,26 @@ public class Kjc extends DefaultCompilerAdapter { | |||
| cmd.createArgument().setFile(destDir); | |||
| } | |||
| // generate the clsspath | |||
| // generate the clsspath | |||
| cmd.createArgument().setValue("-classpath"); | |||
| Path cp = new Path(project); | |||
| Path cp = new Path(project); | |||
| // kjc don't have bootclasspath option. | |||
| if (bootclasspath != null) { | |||
| // kjc don't have bootclasspath option. | |||
| if (bootclasspath != null) { | |||
| cp.append(bootclasspath); | |||
| } | |||
| } | |||
| if (extdirs != null) { | |||
| if (extdirs != null) { | |||
| cp.addExtdirs(extdirs); | |||
| } | |||
| } | |||
| cp.append(classpath); | |||
| cp.append(src); | |||
| cp.append(classpath); | |||
| cp.append(src); | |||
| cmd.createArgument().setPath(cp); | |||
| cmd.createArgument().setPath(cp); | |||
| // kjc-1.5A doesn't support -encoding option now. | |||
| // kjc-1.5A doesn't support -encoding option now. | |||
| // but it will be supported near the feature. | |||
| if (encoding != null) { | |||
| cmd.createArgument().setValue("-encoding"); | |||
| @@ -89,7 +89,7 @@ import org.apache.tools.ant.types.FileSet; | |||
| * </p> | |||
| * | |||
| * <p>Functionality is currently provided for standard EJB1.1 jars and Weblogic | |||
| * 5.1 jars. The weblogic deployment descriptors, used in constructing the | |||
| * 5.1 jars. The weblogic deployment descriptors, used in constructing the | |||
| * Weblogic jar, are located based on a simple naming convention. The name of the | |||
| * standard deployment descriptor is taken upto the first instance of a String, | |||
| * specified by the attribute baseNameTerminator, and then the regular Weblogic | |||
| @@ -106,23 +106,23 @@ import org.apache.tools.ant.types.FileSet; | |||
| * @author <a href="mailto:tfennell@sapient.com">Tim Fennell</a> | |||
| */ | |||
| public class EjbJar extends MatchingTask { | |||
| public static class DTDLocation { | |||
| private String publicId = null; | |||
| private String location = null; | |||
| public void setPublicId(String publicId) { | |||
| this.publicId = publicId; | |||
| } | |||
| public void setLocation(String location) { | |||
| this.location = location; | |||
| } | |||
| public String getPublicId() { | |||
| return publicId; | |||
| } | |||
| public String getLocation() { | |||
| return location; | |||
| } | |||
| @@ -138,7 +138,7 @@ public class EjbJar extends MatchingTask { | |||
| /** Stores a handle to the directory under which to search for deployment descriptors */ | |||
| public File descriptorDir; | |||
| /** Instance variable that marks the end of the 'basename' */ | |||
| public String baseNameTerminator = "-"; | |||
| @@ -150,28 +150,28 @@ public class EjbJar extends MatchingTask { | |||
| * of a flat directory as the destination for the jar files. | |||
| */ | |||
| public boolean flatDestDir = false; | |||
| /** | |||
| * The classpath to use when loading classes | |||
| */ | |||
| public Path classpath; | |||
| /** | |||
| * A Fileset of support classes | |||
| */ | |||
| public List supportFileSets = new ArrayList(); | |||
| /** | |||
| * The list of configured DTD locations | |||
| */ | |||
| public ArrayList dtdLocations = new ArrayList(); | |||
| /** | |||
| * The naming scheme used to determine the generated jar name | |||
| * from the descriptor information | |||
| */ | |||
| public NamingScheme namingScheme; | |||
| /** | |||
| * The Manifest file | |||
| */ | |||
| @@ -196,7 +196,7 @@ public class EjbJar extends MatchingTask { | |||
| deployment descriptor tools are provided. Normally each deployment tool | |||
| will specify the desitination dir itself. */ | |||
| private File destDir; | |||
| /** Instance variable that stores the suffix for the generated jarfile. */ | |||
| private String genericJarSuffix = "-generic.jar"; | |||
| @@ -235,7 +235,7 @@ public class EjbJar extends MatchingTask { | |||
| /** | |||
| * Create a nested element used to configure a deployment tool for iPlanet | |||
| * Application Server. | |||
| * Application Server. | |||
| * | |||
| * @return the deployment tool instance to be configured. | |||
| */ | |||
| @@ -279,7 +279,7 @@ public class EjbJar extends MatchingTask { | |||
| * | |||
| * This classpath is used to locate the super classes and interfaces | |||
| * of the classes that will make up the EJB jar. | |||
| * | |||
| * | |||
| * @return the path to be configured. | |||
| */ | |||
| public Path createClasspath() { | |||
| @@ -296,7 +296,7 @@ public class EjbJar extends MatchingTask { | |||
| public DTDLocation createDTD() { | |||
| DTDLocation dtdLocation = new DTDLocation(); | |||
| config.dtdLocations.add(dtdLocation); | |||
| return dtdLocation; | |||
| } | |||
| @@ -310,7 +310,7 @@ public class EjbJar extends MatchingTask { | |||
| config.supportFileSets.add(supportFileSet); | |||
| return supportFileSet; | |||
| } | |||
| /** | |||
| * Set the Manifest file to use when jarring. | |||
| @@ -327,7 +327,7 @@ public class EjbJar extends MatchingTask { | |||
| /** | |||
| * Set the srcdir attribute. The source directory is the directory that contains | |||
| * the classes that will be added to the EJB jar. Typically this will include the | |||
| * the classes that will be added to the EJB jar. Typically this will include the | |||
| * home and remote interfaces and the bean class. | |||
| * | |||
| * @param inDir the source directory. | |||
| @@ -342,7 +342,7 @@ public class EjbJar extends MatchingTask { | |||
| * The descriptor directory contains the EJB deployment descriptors. These are XML | |||
| * files that declare the properties of a bean in a particular deployment scenario. Such | |||
| * properties include, for example, the transactional nature of the bean and the security | |||
| * access control to the bean's methods. | |||
| * access control to the bean's methods. | |||
| * | |||
| * @param inDir the directory containing the deployment descriptors. | |||
| */ | |||
| @@ -352,8 +352,8 @@ public class EjbJar extends MatchingTask { | |||
| /** | |||
| * Set the base name of the EJB jar that is to be created if it is not to be | |||
| * determined from the name of the deployment descriptor files. | |||
| * | |||
| * determined from the name of the deployment descriptor files. | |||
| * | |||
| * @param inValue the basename that will be used when writing the jar file containing | |||
| * the EJB | |||
| */ | |||
| @@ -364,9 +364,9 @@ public class EjbJar extends MatchingTask { | |||
| config.namingScheme.setValue(NamingScheme.BASEJARNAME); | |||
| } | |||
| else if (!config.namingScheme.getValue().equals(NamingScheme.BASEJARNAME)) { | |||
| throw new BuildException("The basejarname attribute is not compatible with the " + | |||
| throw new BuildException("The basejarname attribute is not compatible with the " + | |||
| config.namingScheme.getValue() + " naming scheme"); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| @@ -379,22 +379,22 @@ public class EjbJar extends MatchingTask { | |||
| config.namingScheme = namingScheme; | |||
| if (!config.namingScheme.getValue().equals(NamingScheme.BASEJARNAME) && | |||
| config.baseJarName != null) { | |||
| throw new BuildException("The basejarname attribute is not compatible with the " + | |||
| throw new BuildException("The basejarname attribute is not compatible with the " + | |||
| config.namingScheme.getValue() + " naming scheme"); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Set the destination directory. | |||
| * | |||
| * | |||
| * The EJB jar files will be written into this directory. The jar files that exist in | |||
| * this directory are also used when determining if the contents of the jar file | |||
| * this directory are also used when determining if the contents of the jar file | |||
| * have changed. | |||
| * | |||
| * Note that this parameter is only used if no deployment tools are specified. Typically | |||
| * each deployment tool will specify its own destination directory. | |||
| * | |||
| * | |||
| * @param inFile the destination directory. | |||
| */ | |||
| public void setDestdir(File inDir) { | |||
| @@ -402,7 +402,7 @@ public class EjbJar extends MatchingTask { | |||
| } | |||
| /** | |||
| * Set the classpath to use when resolving classes for inclusion in the jar. | |||
| * Set the classpath to use when resolving classes for inclusion in the jar. | |||
| * | |||
| * @param classpath the classpath to use. | |||
| */ | |||
| @@ -413,26 +413,26 @@ public class EjbJar extends MatchingTask { | |||
| /** | |||
| * Set the flat dest dir flag. | |||
| * | |||
| * This flag controls whether the destination jars are written out in the | |||
| * destination directory with the same hierarchal structure from which | |||
| * the deployment descriptors have been read. If this is set to true the | |||
| * This flag controls whether the destination jars are written out in the | |||
| * destination directory with the same hierarchal structure from which | |||
| * the deployment descriptors have been read. If this is set to true the | |||
| * generated EJB jars are written into the root of the destination directory, | |||
| * otherwise they are written out in the same relative position as the deployment | |||
| * descriptors in the descriptor directory. | |||
| * | |||
| * | |||
| * @param inValue the new value of the flatdestdir flag. | |||
| */ | |||
| public void setFlatdestdir(boolean inValue) { | |||
| config.flatDestDir = inValue; | |||
| } | |||
| /** | |||
| * Set the suffix for the generated jar file. | |||
| * When generic jars are generated, they have a suffix which is appended to the | |||
| * the bean name to create the name of the jar file. Note that this suffix includes | |||
| * the extension fo te jar file and should therefore end with an appropriate | |||
| * the extension fo te jar file and should therefore end with an appropriate | |||
| * extension such as .jar or .ear | |||
| * | |||
| * | |||
| * @param inString the string to use as the suffix. | |||
| */ | |||
| public void setGenericjarsuffix(String inString) { | |||
| @@ -443,7 +443,7 @@ public class EjbJar extends MatchingTask { | |||
| * Set the baseNameTerminator. | |||
| * | |||
| * The basename terminator is the string which terminates the bean name. The convention | |||
| * used by this task is that bean descriptors are named as the BeanName with some suffix. | |||
| * used by this task is that bean descriptors are named as the BeanName with some suffix. | |||
| * The baseNameTerminator string separates the bean name and the suffix and is used to | |||
| * determine the bean name. | |||
| * | |||
| @@ -468,19 +468,19 @@ public class EjbJar extends MatchingTask { | |||
| } | |||
| else if (config.namingScheme.getValue().equals(NamingScheme.BASEJARNAME) && | |||
| config.baseJarName == null) { | |||
| throw new BuildException("The basejarname attribute must be specified " + | |||
| throw new BuildException("The basejarname attribute must be specified " + | |||
| "with the basejarname naming scheme"); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Invoked by Ant after the task is prepared, when it is ready to execute | |||
| * this task. | |||
| * this task. | |||
| * | |||
| * This will configure all of the nested deployment tools to allow them to | |||
| * process the jar. If no deployment tools have been configured a generic | |||
| * This will configure all of the nested deployment tools to allow them to | |||
| * process the jar. If no deployment tools have been configured a generic | |||
| * tool is created to handle the jar. | |||
| * | |||
| * | |||
| * A parser is configured and then each descriptor found is passed to all | |||
| * the deployment tool elements for processing. | |||
| * | |||
| @@ -490,7 +490,7 @@ public class EjbJar extends MatchingTask { | |||
| */ | |||
| public void execute() throws BuildException { | |||
| validateConfig(); | |||
| if (deploymentTools.size() == 0) { | |||
| GenericDeploymentTool genericTool = new GenericDeploymentTool(); | |||
| genericTool.setTask(this); | |||
| @@ -498,27 +498,27 @@ public class EjbJar extends MatchingTask { | |||
| genericTool.setGenericJarSuffix(genericJarSuffix); | |||
| deploymentTools.add(genericTool); | |||
| } | |||
| for (Iterator i = deploymentTools.iterator(); i.hasNext(); ) { | |||
| EJBDeploymentTool tool = (EJBDeploymentTool)i.next(); | |||
| tool.configure(config); | |||
| tool.validateConfigured(); | |||
| } | |||
| try { | |||
| // Create the parser using whatever parser the system dictates | |||
| SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); | |||
| saxParserFactory.setValidating(true); | |||
| SAXParser saxParser = saxParserFactory.newSAXParser(); | |||
| DirectoryScanner ds = getDirectoryScanner(config.descriptorDir); | |||
| ds.scan(); | |||
| String[] files = ds.getIncludedFiles(); | |||
| log(files.length + " deployment descriptors located.", | |||
| Project.MSG_VERBOSE); | |||
| // Loop through the files. Each file represents one deployment | |||
| // descriptor, and hence one bean in our model. | |||
| for (int index = 0; index < files.length; ++index) { | |||
| @@ -527,7 +527,7 @@ public class EjbJar extends MatchingTask { | |||
| EJBDeploymentTool tool = (EJBDeploymentTool)i.next(); | |||
| tool.processDescriptor(files[index], saxParser); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| catch (SAXException se) { | |||
| String msg = "SAXException while creating parser." | |||
| @@ -67,34 +67,34 @@ import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.BuildException; | |||
| /** | |||
| * Task to compile EJB stubs and skeletons for the iPlanet Application Server. | |||
| * Task to compile EJB stubs and skeletons for the iPlanet Application Server. | |||
| * The EJBs to be processed are specified by the EJB 1.1 standard XML | |||
| * descriptor, and additional attributes are obtained from the iPlanet Application | |||
| * Server-specific XML descriptor. Since the XML descriptors can include | |||
| * multiple EJBs, this is a convenient way of specifying many EJBs in a single | |||
| * descriptor, and additional attributes are obtained from the iPlanet Application | |||
| * Server-specific XML descriptor. Since the XML descriptors can include | |||
| * multiple EJBs, this is a convenient way of specifying many EJBs in a single | |||
| * Ant task. The following attributes are allowed: | |||
| * <ul> | |||
| * <li><i>ejbdescriptor</i> -- Standard EJB 1.1 XML descriptor (typically | |||
| * titled "ejb-jar.xml"). This attribute is | |||
| * titled "ejb-jar.xml"). This attribute is | |||
| * required. | |||
| * <li><i>iasdescriptor</i> -- EJB XML descriptor for iPlanet Application | |||
| * Server (typically titled "ias-ejb-jar.xml). | |||
| * Server (typically titled "ias-ejb-jar.xml). | |||
| * This attribute is required. | |||
| * <li><i>dest</i> -- The is the base directory where the RMI stubs and | |||
| * <li><i>dest</i> -- The is the base directory where the RMI stubs and | |||
| * skeletons are written. In addition, the class files | |||
| * for each bean (home interface, remote interface, and | |||
| * EJB implementation) must be found in this directory. | |||
| * This attribute is required. | |||
| * <li><i>classpath</i> -- The classpath used when generating EJB stubs and | |||
| * skeletons. This is an optional attribute (if | |||
| * omitted, the classpath specified when Ant was | |||
| * started will be used). Nested "classpath" | |||
| * skeletons. This is an optional attribute (if | |||
| * omitted, the classpath specified when Ant was | |||
| * started will be used). Nested "classpath" | |||
| * elements may also be used. | |||
| * <li><i>keepgenerated</i> -- Indicates whether or not the Java source | |||
| * files which are generated by ejbc will be | |||
| * saved or automatically deleted. If "yes", | |||
| * the source files will be retained. This is | |||
| * an optional attribute (if omitted, it | |||
| * <li><i>keepgenerated</i> -- Indicates whether or not the Java source | |||
| * files which are generated by ejbc will be | |||
| * saved or automatically deleted. If "yes", | |||
| * the source files will be retained. This is | |||
| * an optional attribute (if omitted, it | |||
| * defaults to "no"). | |||
| * <li><i>debug</i> -- Indicates whether or not the ejbc utility should | |||
| * log additional debugging statements to the standard | |||
| @@ -102,18 +102,18 @@ import org.apache.tools.ant.BuildException; | |||
| * will be generated (if omitted, it defaults to "no"). | |||
| * <li><i>iashome</i> -- May be used to specify the "home" directory for | |||
| * this iPlanet Application Server installation. This | |||
| * is used to find the ejbc utility if it isn't | |||
| * included in the user's system path. This is an | |||
| * optional attribute (if specified, it should refer | |||
| * is used to find the ejbc utility if it isn't | |||
| * included in the user's system path. This is an | |||
| * optional attribute (if specified, it should refer | |||
| * to the <code>[install-location]/iplanet/ias6/ias | |||
| * </code> directory). If omitted, the ejbc utility | |||
| * </code> directory). If omitted, the ejbc utility | |||
| * must be on the user's system path. | |||
| * </ul> | |||
| * <p> | |||
| * For each EJB specified, this task will locate the three classes that comprise | |||
| * the EJB. If these class files cannot be located in the <code>dest</code> | |||
| * directory, the task will fail. The task will also attempt to locate the EJB | |||
| * stubs and skeletons in this directory. If found, the timestamps on the | |||
| * directory, the task will fail. The task will also attempt to locate the EJB | |||
| * stubs and skeletons in this directory. If found, the timestamps on the | |||
| * stubs and skeletons will be checked to ensure they are up to date. Only if | |||
| * these files cannot be found or if they are out of date will ejbc be called | |||
| * to generate new stubs and skeletons. | |||
| @@ -123,42 +123,42 @@ import org.apache.tools.ant.BuildException; | |||
| */ | |||
| public class IPlanetEjbcTask extends Task { | |||
| /* Attributes set by the Ant build file */ | |||
| private File ejbdescriptor; | |||
| private File iasdescriptor; | |||
| private File dest; | |||
| private Path classpath; | |||
| private boolean keepgenerated = false; | |||
| private boolean debug = false; | |||
| private File iashome; | |||
| /* Attributes set by the Ant build file */ | |||
| private File ejbdescriptor; | |||
| private File iasdescriptor; | |||
| private File dest; | |||
| private Path classpath; | |||
| private boolean keepgenerated = false; | |||
| private boolean debug = false; | |||
| private File iashome; | |||
| /** | |||
| * Sets the location of the standard XML EJB descriptor. Typically, this | |||
| * file is named "ejb-jar.xml". | |||
| * | |||
| * @param ejbdescriptor The name and location of the EJB descriptor. | |||
| * file is named "ejb-jar.xml". | |||
| * | |||
| * @param ejbdescriptor The name and location of the EJB descriptor. | |||
| */ | |||
| public void setEjbdescriptor(File ejbdescriptor) { | |||
| this.ejbdescriptor = ejbdescriptor; | |||
| } | |||
| public void setEjbdescriptor(File ejbdescriptor) { | |||
| this.ejbdescriptor = ejbdescriptor; | |||
| } | |||
| /** | |||
| * Sets the location of the iAS-specific XML EJB descriptor. Typically, | |||
| * this file is named "ias-ejb-jar.xml". | |||
| * | |||
| * @param iasdescriptor The name and location of the iAS-specific EJB | |||
| * descriptor. | |||
| * Sets the location of the iAS-specific XML EJB descriptor. Typically, | |||
| * this file is named "ias-ejb-jar.xml". | |||
| * | |||
| * @param iasdescriptor The name and location of the iAS-specific EJB | |||
| * descriptor. | |||
| */ | |||
| public void setIasdescriptor (File iasdescriptor) { | |||
| this.iasdescriptor = iasdescriptor; | |||
| } | |||
| public void setIasdescriptor (File iasdescriptor) { | |||
| this.iasdescriptor = iasdescriptor; | |||
| } | |||
| /** | |||
| * Sets the destination directory where the EJB "source" classes must exist | |||
| * and where the stubs and skeletons will be written. The destination | |||
| * directory must exist before this task is executed. | |||
| * | |||
| * @param dest The directory where the compiled classes will be written. | |||
| * and where the stubs and skeletons will be written. The destination | |||
| * directory must exist before this task is executed. | |||
| * | |||
| * @param dest The directory where the compiled classes will be written. | |||
| */ | |||
| public void setDest(File dest) { | |||
| this.dest = dest; | |||
| @@ -166,8 +166,8 @@ public class IPlanetEjbcTask extends Task { | |||
| /** | |||
| * Sets the classpath to be used when compiling the EJB stubs and skeletons. | |||
| * | |||
| * @param classpath The classpath to be used. | |||
| * | |||
| * @param classpath The classpath to be used. | |||
| */ | |||
| public void setClasspath(Path classpath) { | |||
| if (this.classpath == null) { | |||
| @@ -188,107 +188,107 @@ public class IPlanetEjbcTask extends Task { | |||
| } | |||
| /** | |||
| * Sets whether or not the Java source files which are generated by the | |||
| * ejbc process should be retained or automatically deleted. | |||
| * | |||
| * @param keepgenerated A boolean indicating if the Java source files for | |||
| * the stubs and skeletons should be retained. | |||
| * Sets whether or not the Java source files which are generated by the | |||
| * ejbc process should be retained or automatically deleted. | |||
| * | |||
| * @param keepgenerated A boolean indicating if the Java source files for | |||
| * the stubs and skeletons should be retained. | |||
| */ | |||
| public void setKeepgenerated(boolean keepgenerated) { | |||
| this.keepgenerated = keepgenerated; | |||
| } | |||
| public void setKeepgenerated(boolean keepgenerated) { | |||
| this.keepgenerated = keepgenerated; | |||
| } | |||
| /** | |||
| * Sets whether or not debugging output will be generated when ejbc is | |||
| * executed. | |||
| * | |||
| * @param debug A boolean indicating if debugging output should be generated | |||
| * executed. | |||
| * | |||
| * @param debug A boolean indicating if debugging output should be generated | |||
| */ | |||
| public void setDebug(boolean debug) { | |||
| this.debug = debug; | |||
| } | |||
| public void setDebug(boolean debug) { | |||
| this.debug = debug; | |||
| } | |||
| /** | |||
| * Setter method used to store the "home" directory of the user's iAS | |||
| * installation. The directory specified should typically be | |||
| * <code>[install-location]/iplanet/ias6/ias</code>. | |||
| * | |||
| * installation. The directory specified should typically be | |||
| * <code>[install-location]/iplanet/ias6/ias</code>. | |||
| * | |||
| * @param iashome The home directory for the user's iAS installation. | |||
| */ | |||
| public void setIashome(File iashome) { | |||
| this.iashome = iashome; | |||
| } | |||
| public void setIashome(File iashome) { | |||
| this.iashome = iashome; | |||
| } | |||
| /** | |||
| * Does the work. | |||
| */ | |||
| public void execute() throws BuildException { | |||
| checkConfiguration(); | |||
| checkConfiguration(); | |||
| executeEjbc(getParser()); | |||
| } | |||
| executeEjbc(getParser()); | |||
| } | |||
| /** | |||
| * Verifies that the user selections are valid. | |||
| * | |||
| * @throws BuildException If the user selections are invalid. | |||
| * | |||
| * @throws BuildException If the user selections are invalid. | |||
| */ | |||
| private void checkConfiguration() throws BuildException { | |||
| private void checkConfiguration() throws BuildException { | |||
| if (ejbdescriptor == null) { | |||
| String msg = "The standard EJB descriptor must be specified using " | |||
| + "the \"ejbdescriptor\" attribute."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if ((!ejbdescriptor.exists()) || (!ejbdescriptor.isFile())) { | |||
| String msg = "The standard EJB descriptor (" + ejbdescriptor | |||
| + ") was not found or isn't a file."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if (ejbdescriptor == null) { | |||
| String msg = "The standard EJB descriptor must be specified using " | |||
| + "the \"ejbdescriptor\" attribute."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if ((!ejbdescriptor.exists()) || (!ejbdescriptor.isFile())) { | |||
| String msg = "The standard EJB descriptor (" + ejbdescriptor | |||
| + ") was not found or isn't a file."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if (iasdescriptor == null) { | |||
| String msg = "The iAS-speific XML descriptor must be specified using" | |||
| + " the \"iasdescriptor\" attribute."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if ((!iasdescriptor.exists()) || (!iasdescriptor.isFile())) { | |||
| String msg = "The iAS-specific XML descriptor (" + iasdescriptor | |||
| + ") was not found or isn't a file."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if (iasdescriptor == null) { | |||
| String msg = "The iAS-speific XML descriptor must be specified using" | |||
| + " the \"iasdescriptor\" attribute."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if ((!iasdescriptor.exists()) || (!iasdescriptor.isFile())) { | |||
| String msg = "The iAS-specific XML descriptor (" + iasdescriptor | |||
| + ") was not found or isn't a file."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if (dest == null) { | |||
| String msg = "The destination directory must be specified using " | |||
| + "the \"dest\" attribute."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if ((!dest.exists()) || (!dest.isDirectory())) { | |||
| String msg = "The destination directory (" + dest + ") was not " | |||
| + "found or isn't a directory."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if (dest == null) { | |||
| String msg = "The destination directory must be specified using " | |||
| + "the \"dest\" attribute."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if ((!dest.exists()) || (!dest.isDirectory())) { | |||
| String msg = "The destination directory (" + dest + ") was not " | |||
| + "found or isn't a directory."; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if ((iashome != null) && (!iashome.isDirectory())) { | |||
| String msg = "If \"iashome\" is specified, it must be a valid " | |||
| + "directory (it was set to " + iashome + ")."; | |||
| throw new BuildException(msg, getLocation()); | |||
| } | |||
| } | |||
| if ((iashome != null) && (!iashome.isDirectory())) { | |||
| String msg = "If \"iashome\" is specified, it must be a valid " | |||
| + "directory (it was set to " + iashome + ")."; | |||
| throw new BuildException(msg, getLocation()); | |||
| } | |||
| } | |||
| /** | |||
| * Returns a SAXParser that may be used to process the XML descriptors. | |||
| * | |||
| * @return Parser which may be used to process the EJB descriptors. | |||
| * @throws BuildException If the parser cannot be created or configured. | |||
| * | |||
| * @return Parser which may be used to process the EJB descriptors. | |||
| * @throws BuildException If the parser cannot be created or configured. | |||
| */ | |||
| private SAXParser getParser() throws BuildException { | |||
| private SAXParser getParser() throws BuildException { | |||
| SAXParser saxParser = null; | |||
| try { | |||
| SAXParser saxParser = null; | |||
| try { | |||
| SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); | |||
| saxParserFactory.setValidating(true); | |||
| saxParser = saxParserFactory.newSAXParser(); | |||
| } catch (SAXException e) { | |||
| } catch (SAXException e) { | |||
| String msg = "Unable to create a SAXParser: " + e.getMessage(); | |||
| throw new BuildException(msg, e, location); | |||
| } | |||
| @@ -297,57 +297,57 @@ public class IPlanetEjbcTask extends Task { | |||
| throw new BuildException(msg, e, location); | |||
| } | |||
| return saxParser; | |||
| } | |||
| return saxParser; | |||
| } | |||
| /** | |||
| * Executes the EJBc utility using the SAXParser provided. | |||
| * | |||
| * @param saxParser SAXParser that may be used to process the EJB | |||
| * descriptors | |||
| * @throws BuildException If there is an error reading or parsing the XML | |||
| * descriptors | |||
| * | |||
| * @param saxParser SAXParser that may be used to process the EJB | |||
| * descriptors | |||
| * @throws BuildException If there is an error reading or parsing the XML | |||
| * descriptors | |||
| */ | |||
| private void executeEjbc(SAXParser saxParser) throws BuildException { | |||
| IPlanetEjbc ejbc = new IPlanetEjbc(ejbdescriptor, | |||
| iasdescriptor, | |||
| dest, | |||
| getClasspath().toString(), | |||
| saxParser); | |||
| ejbc.setRetainSource(keepgenerated); | |||
| ejbc.setDebugOutput(debug); | |||
| if (iashome != null) { | |||
| ejbc.setIasHomeDir(iashome); | |||
| } | |||
| private void executeEjbc(SAXParser saxParser) throws BuildException { | |||
| IPlanetEjbc ejbc = new IPlanetEjbc(ejbdescriptor, | |||
| iasdescriptor, | |||
| dest, | |||
| getClasspath().toString(), | |||
| saxParser); | |||
| ejbc.setRetainSource(keepgenerated); | |||
| ejbc.setDebugOutput(debug); | |||
| if (iashome != null) { | |||
| ejbc.setIasHomeDir(iashome); | |||
| } | |||
| try { | |||
| ejbc.execute(); | |||
| } catch (IOException e) { | |||
| try { | |||
| ejbc.execute(); | |||
| } catch (IOException e) { | |||
| String msg = "An IOException occurred while trying to read the XML " | |||
| + "descriptor file: " + e.getMessage(); | |||
| + "descriptor file: " + e.getMessage(); | |||
| throw new BuildException(msg, e, location); | |||
| } catch (SAXException e) { | |||
| String msg = "A SAXException occurred while trying to read the XML " | |||
| + "descriptor file: " + e.getMessage(); | |||
| + "descriptor file: " + e.getMessage(); | |||
| throw new BuildException(msg, e, location); | |||
| } catch (IPlanetEjbc.EjbcException e) { | |||
| String msg = "An exception occurred while trying to run the ejbc " | |||
| + "utility: " + e.getMessage(); | |||
| + "utility: " + e.getMessage(); | |||
| throw new BuildException(msg, e, location); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Returns the CLASSPATH to be used when calling EJBc. If no user CLASSPATH | |||
| * is specified, the System classpath is returned instead. | |||
| * | |||
| * @return Path The classpath to be used for EJBc. | |||
| */ | |||
| private Path getClasspath() { | |||
| if (classpath == null) { | |||
| classpath = Path.systemClasspath; | |||
| } | |||
| * is specified, the System classpath is returned instead. | |||
| * | |||
| * @return Path The classpath to be used for EJBc. | |||
| */ | |||
| private Path getClasspath() { | |||
| if (classpath == null) { | |||
| classpath = Path.systemClasspath; | |||
| } | |||
| return classpath; | |||
| } | |||
| return classpath; | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -73,20 +73,20 @@ import org.apache.tools.ant.BuildException; | |||
| public class VAJAntTool { | |||
| private final static String TOOL_DATA_KEY = "AntTool"; | |||
| /** | |||
| * Loads the BuildInfo for the specified VAJ project from the | |||
| * tool data for this project. | |||
| * If there is no build info stored for that project, a new | |||
| * default BuildInfo is returned | |||
| * | |||
| * | |||
| * @return BuildInfo buildInfo build info for the specified project | |||
| * @param projectName String project name | |||
| */ | |||
| public static VAJBuildInfo loadBuildData(String projectName) { | |||
| VAJBuildInfo result = null; | |||
| try { | |||
| Project project = | |||
| Project project = | |||
| VAJLocalUtil.getWorkspace().loadedProjectNamed( projectName ); | |||
| if ( project.testToolRepositoryData(TOOL_DATA_KEY) ) { | |||
| ToolData td = project.getToolRepositoryData(TOOL_DATA_KEY); | |||
| @@ -97,7 +97,7 @@ public class VAJAntTool { | |||
| } | |||
| result.setVAJProjectName( projectName ); | |||
| } catch (Throwable t) { | |||
| throw new BuildException("BuildInfo for Project " | |||
| throw new BuildException("BuildInfo for Project " | |||
| + projectName + " could not be loaded" + t); | |||
| } | |||
| return result; | |||
| @@ -108,7 +108,7 @@ public class VAJAntTool { | |||
| * Starts the application. | |||
| * | |||
| * @param args an array of command-line arguments. VAJ puts the | |||
| * VAJ project name into args[1] when starting the | |||
| * VAJ project name into args[1] when starting the | |||
| * tool from the project context menu | |||
| */ | |||
| public static void main(java.lang.String[] args) { | |||
| @@ -117,11 +117,11 @@ public class VAJAntTool { | |||
| if ( args.length >= 2 && args[1] instanceof String ) { | |||
| String projectName = (String)args[1]; | |||
| info = loadBuildData( projectName ); | |||
| } | |||
| } | |||
| else { | |||
| info = new VAJBuildInfo(); | |||
| } | |||
| VAJAntToolGUI mainFrame = new VAJAntToolGUI( info ); | |||
| mainFrame.show(); | |||
| } catch ( Throwable t ) { | |||
| @@ -141,10 +141,10 @@ public class VAJAntTool { | |||
| String data = info.asDataString(); | |||
| try { | |||
| ToolData td = new ToolData( TOOL_DATA_KEY, data ); | |||
| VAJLocalUtil.getWorkspace().loadedProjectNamed( | |||
| VAJLocalUtil.getWorkspace().loadedProjectNamed( | |||
| info.getVAJProjectName() ).setToolRepositoryData( td ); | |||
| } catch (Throwable t) { | |||
| throw new BuildException("BuildInfo for Project " | |||
| throw new BuildException("BuildInfo for Project " | |||
| + info.getVAJProjectName() + " could not be saved", t); | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -95,14 +95,14 @@ import org.apache.tools.ant.BuildEvent; | |||
| import org.apache.tools.ant.Project; | |||
| /** | |||
| * This is a simple grafical user interface to provide the information needed | |||
| * This is a simple grafical user interface to provide the information needed | |||
| * by ANT and to start the build-process within IBM VisualAge for Java. | |||
| * <p> | |||
| * I was using AWT to make it independent from the JDK-version. Please don't | |||
| * ask me for a Swing-version:I am very familiar with Swing and I really think | |||
| * I was using AWT to make it independent from the JDK-version. Please don't | |||
| * ask me for a Swing-version:I am very familiar with Swing and I really think | |||
| * that it's not necessary for such a simple gui! | |||
| * <p> | |||
| * It is completely developed in VAJ using the visual composition editor. | |||
| * It is completely developed in VAJ using the visual composition editor. | |||
| * About 90% of the code is generated by VAJ, | |||
| * but in fact I did a lot of <i>code-beautification</i> ;-). | |||
| * <p> | |||
| @@ -111,7 +111,7 @@ import org.apache.tools.ant.Project; | |||
| */ | |||
| public class VAJAntToolGUI extends Frame { | |||
| /** | |||
| * Members | |||
| * Members | |||
| */ | |||
| private VAJBuildLogger logger = new VAJBuildLogger(); | |||
| private String lineSeparator = "\r\n"; | |||
| @@ -138,7 +138,7 @@ public class VAJAntToolGUI extends Frame { | |||
| // Project name | |||
| private Label iProjectLabel = null; | |||
| private Label iProjectText = null; | |||
| // XML-file | |||
| // XML-file | |||
| private Label iBuildFileLabel = null; | |||
| private TextField iBuildFileTextField = null; | |||
| private boolean iConnPtoP2Aligning = false; | |||
| @@ -151,7 +151,7 @@ public class VAJAntToolGUI extends Frame { | |||
| private List iTargetList = null; | |||
| // Command-buttons | |||
| private Button iBuildButton = null; | |||
| private Button iReloadButton = null; | |||
| private Button iReloadButton = null; | |||
| private Button iCloseButton = null; | |||
| /** | |||
| * log-Window | |||
| @@ -180,7 +180,7 @@ public class VAJAntToolGUI extends Frame { | |||
| private Button iAboutOkButton = null; | |||
| /** | |||
| * This internal BuildLogger, to be honest, is just a BuildListener. | |||
| * This internal BuildLogger, to be honest, is just a BuildListener. | |||
| * It does nearly the same as the DefaultLogger, but uses the Loggin-Window for output. | |||
| */ | |||
| private class VAJBuildLogger implements BuildListener { | |||
| @@ -203,7 +203,7 @@ public class VAJAntToolGUI extends Frame { | |||
| getStopButton().setEnabled(false); | |||
| getBuildButton().setEnabled(true); | |||
| getBuildButton().requestFocus(); | |||
| Throwable error = event.getException(); | |||
| if (error == null) { | |||
| @@ -235,7 +235,7 @@ public class VAJAntToolGUI extends Frame { | |||
| error.printStackTrace(System.err); | |||
| } | |||
| } | |||
| /** | |||
| * Fired before any targets are started. | |||
| */ | |||
| @@ -300,7 +300,7 @@ public class VAJAntToolGUI extends Frame { | |||
| public void taskStarted(BuildEvent event) { | |||
| } | |||
| } | |||
| /** | |||
| * Eventhandler to handle all AWT-events | |||
| */ | |||
| @@ -320,7 +320,7 @@ public class VAJAntToolGUI extends Frame { | |||
| getBuildFileTextField().setText(getFileDialog().getDirectory() + getFileDialog().getFile()); | |||
| } | |||
| } | |||
| // dispose and exit application | |||
| // dispose and exit application | |||
| if (e.getSource() == VAJAntToolGUI.this.getCloseButton()) { | |||
| dispose(); | |||
| System.exit(0); | |||
| @@ -344,21 +344,21 @@ public class VAJAntToolGUI extends Frame { | |||
| } | |||
| } | |||
| // MenuItems | |||
| if (e.getSource() == VAJAntToolGUI.this.getSaveMenuItem()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getSaveMenuItem()) | |||
| saveBuildInfo(); | |||
| if (e.getSource() == VAJAntToolGUI.this.getAboutMenuItem()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getAboutMenuItem()) | |||
| getAboutDialog().show(); | |||
| if (e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem()) | |||
| getMessageFrame().show(); | |||
| /* #### About dialog #### */ | |||
| if (e.getSource() == VAJAntToolGUI.this.getAboutOkButton()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getAboutOkButton()) | |||
| getAboutDialog().dispose(); | |||
| /* #### Log frame #### */ | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) | |||
| getMessageFrame().dispose(); | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton()) | |||
| getMessageTextArea().setText(""); | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) | |||
| getMessageFrame().dispose(); | |||
| } | |||
| catch (Throwable exc) { | |||
| @@ -371,36 +371,36 @@ public class VAJAntToolGUI extends Frame { | |||
| */ | |||
| public void itemStateChanged(ItemEvent e) { | |||
| try { | |||
| if (e.getSource() == VAJAntToolGUI.this.getTargetList()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getTargetList()) | |||
| getBuildButton().setEnabled(true); | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice()) | |||
| getBuildInfo().setOutputMessageLevel(getMessageOutputLevelChoice().getSelectedIndex()); | |||
| if (e.getSource() == VAJAntToolGUI.this.getTargetList()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getTargetList()) | |||
| getBuildInfo().setTarget(getTargetList().getSelectedItem()); | |||
| } | |||
| catch (Throwable exc) { | |||
| handleException(exc); | |||
| } | |||
| } | |||
| /** | |||
| * PropertyChangeListener method | |||
| */ | |||
| public void propertyChange(java.beans.PropertyChangeEvent evt) { | |||
| if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("projectName"))) | |||
| if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("projectName"))) | |||
| connectProjectNameToLabel(); | |||
| if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("buildFileName"))) | |||
| if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("buildFileName"))) | |||
| connectBuildFileNameToTextField(); | |||
| } | |||
| /** | |||
| * TextListener method | |||
| */ | |||
| public void textValueChanged(TextEvent e) { | |||
| if (e.getSource() == VAJAntToolGUI.this.getBuildFileTextField()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getBuildFileTextField()) | |||
| connectTextFieldToBuildFileName(); | |||
| } | |||
| /** | |||
| * WindowListener methods | |||
| */ | |||
| @@ -410,9 +410,9 @@ public class VAJAntToolGUI extends Frame { | |||
| dispose(); | |||
| System.exit(0); | |||
| } | |||
| if (e.getSource() == VAJAntToolGUI.this.getAboutDialog()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getAboutDialog()) | |||
| getAboutDialog().dispose(); | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageFrame()) | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageFrame()) | |||
| getMessageFrame().dispose(); | |||
| } | |||
| catch (Throwable exc) { | |||
| @@ -426,7 +426,7 @@ public class VAJAntToolGUI extends Frame { | |||
| public void windowIconified(WindowEvent e) {}; | |||
| public void windowOpened(WindowEvent e) {}; | |||
| } | |||
| /** | |||
| * AntMake default-constructor. | |||
| */ | |||
| @@ -438,7 +438,7 @@ public class VAJAntToolGUI extends Frame { | |||
| * AntMake constructor called by VAJAntTool integration. | |||
| * @param buildInfo VAJBuildInfo | |||
| */ | |||
| public VAJAntToolGUI(VAJBuildInfo newBuildInfo) { | |||
| super(); | |||
| setBuildInfo(newBuildInfo); | |||
| @@ -503,12 +503,12 @@ public class VAJAntToolGUI extends Frame { | |||
| * external build of a .jar-file | |||
| */ | |||
| private void executeTarget() { | |||
| try { | |||
| try { | |||
| getMessageFrame().show(); | |||
| getBuildInfo().executeProject(logger); | |||
| } | |||
| catch (Throwable exc) { | |||
| logger.logException( exc ); | |||
| logger.logException( exc ); | |||
| } | |||
| return; | |||
| } | |||
| @@ -1293,7 +1293,7 @@ public class VAJAntToolGUI extends Frame { | |||
| getMessageTextArea().append(lineSeparator + lineSeparator + trace); | |||
| getMessageFrame().show(); | |||
| } | |||
| /** | |||
| * Initializes connections | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -54,7 +54,7 @@ | |||
| package org.apache.tools.ant.taskdefs.optional.ide; | |||
| import java.util.Vector; | |||
| import java.util.Enumeration; | |||
| import java.util.StringTokenizer; | |||
| @@ -80,7 +80,7 @@ import org.apache.tools.ant.BuildEvent; | |||
| * execute target) | |||
| * - manages a seperate thread for Ant project execution | |||
| * this allows interrupting a running build from a GUI | |||
| * | |||
| * | |||
| * @author Wolf Siberski, TUI Infotec GmbH | |||
| */ | |||
| @@ -102,7 +102,7 @@ class VAJBuildInfo implements Runnable { | |||
| private class InterruptedChecker implements BuildListener { | |||
| // the real listener | |||
| BuildListener wrappedListener; | |||
| /** | |||
| * Can only be constructed as wrapper around a real listener | |||
| * @param listener the real listener | |||
| @@ -182,11 +182,10 @@ class VAJBuildInfo implements Runnable { | |||
| checkInterrupted(); | |||
| } | |||
| } | |||
| // name of the VA project this BuildInfo belongs to | |||
| private String vajProjectName = ""; | |||
| // name of the Ant build file | |||
| private String buildFileName = ""; | |||
| @@ -208,30 +207,30 @@ class VAJBuildInfo implements Runnable { | |||
| // Support for bound properties | |||
| protected transient PropertyChangeSupport propertyChange; | |||
| // thread for Ant build execution | |||
| // thread for Ant build execution | |||
| private Thread buildThread; | |||
| // the listener used to log output. | |||
| private BuildListener projectLogger; | |||
| /** | |||
| * The addPropertyChangeListener method was generated to support the | |||
| * The addPropertyChangeListener method was generated to support the | |||
| * propertyChange field. | |||
| */ | |||
| public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { | |||
| getPropertyChange().addPropertyChangeListener(listener); | |||
| } | |||
| /** | |||
| * Returns the BuildInfo information as String. The BuildInfo can | |||
| * be rebuilt from that String by calling parse(). | |||
| * @return java.lang.String | |||
| */ | |||
| public String asDataString() { | |||
| String result = getOutputMessageLevel() + "|" + getBuildFileName() | |||
| String result = getOutputMessageLevel() + "|" + getBuildFileName() | |||
| + "|" + getTarget(); | |||
| for ( Enumeration e = getProjectTargets().elements(); | |||
| for ( Enumeration e = getProjectTargets().elements(); | |||
| e.hasMoreElements(); ) { | |||
| result = result + "|" + e.nextElement(); | |||
| } | |||
| @@ -286,14 +285,14 @@ class VAJBuildInfo implements Runnable { | |||
| } | |||
| return project; | |||
| } | |||
| /** | |||
| * return a list of all targets in the current buildfile | |||
| */ | |||
| public Vector getProjectTargets() { | |||
| return projectTargets; | |||
| } | |||
| /** | |||
| * Accessor for the propertyChange field. | |||
| */ | |||
| @@ -373,13 +372,13 @@ class VAJBuildInfo implements Runnable { | |||
| } | |||
| /** | |||
| * The removePropertyChangeListener method was generated | |||
| * The removePropertyChangeListener method was generated | |||
| * to support the propertyChange field. | |||
| */ | |||
| public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { | |||
| getPropertyChange().removePropertyChangeListener(listener); | |||
| } | |||
| /** | |||
| * Sets the build file name | |||
| * @param buildFileName build file name | |||
| @@ -390,7 +389,7 @@ class VAJBuildInfo implements Runnable { | |||
| setProjectInitialized(false); | |||
| firePropertyChange("buildFileName", oldValue, buildFileName); | |||
| } | |||
| /** | |||
| * Sets the log level (value must be one of the constants in Project) | |||
| * @param outputMessageLevel log level. | |||
| @@ -398,7 +397,7 @@ class VAJBuildInfo implements Runnable { | |||
| public void setOutputMessageLevel(int newOutputMessageLevel) { | |||
| int oldValue = outputMessageLevel; | |||
| outputMessageLevel = newOutputMessageLevel; | |||
| firePropertyChange("outputMessageLevel", | |||
| firePropertyChange("outputMessageLevel", | |||
| new Integer(oldValue), new Integer(outputMessageLevel)); | |||
| } | |||
| @@ -410,7 +409,7 @@ class VAJBuildInfo implements Runnable { | |||
| int level = Integer.parseInt( outputMessageLevel ); | |||
| setOutputMessageLevel( level ); | |||
| } | |||
| /** | |||
| * sets the initialized flag | |||
| */ | |||
| @@ -461,7 +460,7 @@ class VAJBuildInfo implements Runnable { | |||
| /** | |||
| * cancels a build. | |||
| * cancels a build. | |||
| */ | |||
| public void cancelBuild() { | |||
| buildThread.interrupt(); | |||
| @@ -484,7 +483,7 @@ class VAJBuildInfo implements Runnable { | |||
| } catch (Error err) { | |||
| error = err; | |||
| throw err; | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| @@ -501,7 +500,7 @@ class VAJBuildInfo implements Runnable { | |||
| if (!isProjectInitialized()) { | |||
| initProject(); | |||
| } | |||
| project.addBuildListener( ic ); | |||
| project.executeTarget(target); | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -51,7 +51,7 @@ | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional.ide; | |||
| @@ -61,21 +61,21 @@ import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| /** | |||
| * Export packages from the Visual Age for Java workspace. | |||
| * The packages are specified similar to all other MatchingTasks. | |||
| * Since the VA Workspace is not file based, this task is simulating | |||
| * Export packages from the Visual Age for Java workspace. | |||
| * The packages are specified similar to all other MatchingTasks. | |||
| * Since the VA Workspace is not file based, this task is simulating | |||
| * a directory hierarchy for the workspace: | |||
| * The 'root' contains all project 'dir's, and the projects contain | |||
| * The 'root' contains all project 'dir's, and the projects contain | |||
| * their respective package 'dir's. | |||
| * Example: | |||
| * <blockquote> | |||
| * Example: | |||
| * <blockquote> | |||
| * <vajexport destdir="C:/builddir/source"> | |||
| * <include name="/MyVAProject/org/foo/subsystem1/**" /> | |||
| * <exclude name="/MyVAProject/org/foo/subsystem1/test/**"/> | |||
| * </vajexport> | |||
| * </blockquote> | |||
| * exports all packages in the project MyVAProject which start with | |||
| * 'org.foo.subsystem1' except of these starting with | |||
| * 'org.foo.subsystem1' except of these starting with | |||
| * 'org.foo.subsystem1.test'. | |||
| * | |||
| * There are flags to choose which items to export: | |||
| @@ -89,124 +89,124 @@ import org.apache.tools.ant.types.PatternSet; | |||
| */ | |||
| public class VAJExport extends VAJTask { | |||
| //set set... method comments for description | |||
| protected File destDir; | |||
| protected boolean exportSources = true; | |||
| protected boolean exportResources = true; | |||
| protected boolean exportClasses = false; | |||
| protected boolean exportDebugInfo = false; | |||
| protected boolean useDefaultExcludes = true; | |||
| protected boolean overwrite = true; | |||
| protected PatternSet patternSet = new PatternSet(); | |||
| /** | |||
| * add a name entry on the exclude list | |||
| */ | |||
| public PatternSet.NameEntry createExclude() { | |||
| return patternSet.createExclude(); | |||
| } | |||
| /** | |||
| * add a name entry on the include list | |||
| */ | |||
| public PatternSet.NameEntry createInclude() { | |||
| return patternSet.createInclude(); | |||
| } | |||
| /** | |||
| * do the export | |||
| */ | |||
| public void execute() throws BuildException { | |||
| // first off, make sure that we've got a destdir | |||
| if (destDir == null) { | |||
| throw new BuildException("destdir attribute must be set!"); | |||
| } | |||
| // delegate the export to the VAJUtil object. | |||
| getUtil().exportPackages(destDir, | |||
| patternSet.getIncludePatterns(getProject()), | |||
| patternSet.getExcludePatterns(getProject()), | |||
| exportClasses, exportDebugInfo, | |||
| exportResources, exportSources, | |||
| useDefaultExcludes, overwrite); | |||
| } | |||
| /** | |||
| * Sets whether default exclusions should be used or not. | |||
| * | |||
| * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions | |||
| * should be used, "false"|"off"|"no" when they | |||
| * shouldn't be used. | |||
| */ | |||
| public void setDefaultexcludes(boolean useDefaultExcludes) { | |||
| this.useDefaultExcludes = useDefaultExcludes; | |||
| } | |||
| /** | |||
| * Set the destination directory into which the selected | |||
| * items should be exported | |||
| */ | |||
| public void setDestdir(File destDir) { | |||
| this.destDir = destDir; | |||
| } | |||
| /** | |||
| * Sets the set of exclude patterns. Patterns may be separated by a comma | |||
| * or a space. Currently only patterns denoting packages are | |||
| * supported | |||
| * | |||
| * @param excludes the string containing the exclude patterns | |||
| */ | |||
| public void setExcludes(String excludes) { | |||
| patternSet.setExcludes(excludes); | |||
| } | |||
| /** | |||
| * if exportClasses is set, class files are exported | |||
| */ | |||
| public void setExportClasses(boolean doExport) { | |||
| exportClasses = doExport; | |||
| } | |||
| /** | |||
| * if exportDebugInfo is set, the exported class files contain | |||
| * debug info | |||
| */ | |||
| public void setExportDebugInfo(boolean doExport) { | |||
| exportDebugInfo = doExport; | |||
| } | |||
| /** | |||
| * if exportResources is set, resource file will be exported | |||
| */ | |||
| public void setExportResources(boolean doExport) { | |||
| exportResources = doExport; | |||
| } | |||
| /** | |||
| * if exportSources is set, java files will be exported | |||
| */ | |||
| public void setExportSources(boolean doExport) { | |||
| exportSources = doExport; | |||
| } | |||
| /** | |||
| * Sets the set of include patterns. Patterns may be separated by a comma | |||
| * or a space.Currently only patterns denoting packages are | |||
| * supported | |||
| * | |||
| * @param includes the string containing the include patterns | |||
| */ | |||
| public void setIncludes(String includes) { | |||
| patternSet.setIncludes(includes); | |||
| } | |||
| /** | |||
| * if Overwrite is set, files will be overwritten during export | |||
| */ | |||
| public void setOverwrite(boolean doOverwrite) { | |||
| overwrite = doOverwrite; | |||
| } | |||
| //set set... method comments for description | |||
| protected File destDir; | |||
| protected boolean exportSources = true; | |||
| protected boolean exportResources = true; | |||
| protected boolean exportClasses = false; | |||
| protected boolean exportDebugInfo = false; | |||
| protected boolean useDefaultExcludes = true; | |||
| protected boolean overwrite = true; | |||
| protected PatternSet patternSet = new PatternSet(); | |||
| /** | |||
| * add a name entry on the exclude list | |||
| */ | |||
| public PatternSet.NameEntry createExclude() { | |||
| return patternSet.createExclude(); | |||
| } | |||
| /** | |||
| * add a name entry on the include list | |||
| */ | |||
| public PatternSet.NameEntry createInclude() { | |||
| return patternSet.createInclude(); | |||
| } | |||
| /** | |||
| * do the export | |||
| */ | |||
| public void execute() throws BuildException { | |||
| // first off, make sure that we've got a destdir | |||
| if (destDir == null) { | |||
| throw new BuildException("destdir attribute must be set!"); | |||
| } | |||
| // delegate the export to the VAJUtil object. | |||
| getUtil().exportPackages(destDir, | |||
| patternSet.getIncludePatterns(getProject()), | |||
| patternSet.getExcludePatterns(getProject()), | |||
| exportClasses, exportDebugInfo, | |||
| exportResources, exportSources, | |||
| useDefaultExcludes, overwrite); | |||
| } | |||
| /** | |||
| * Sets whether default exclusions should be used or not. | |||
| * | |||
| * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions | |||
| * should be used, "false"|"off"|"no" when they | |||
| * shouldn't be used. | |||
| */ | |||
| public void setDefaultexcludes(boolean useDefaultExcludes) { | |||
| this.useDefaultExcludes = useDefaultExcludes; | |||
| } | |||
| /** | |||
| * Set the destination directory into which the selected | |||
| * items should be exported | |||
| */ | |||
| public void setDestdir(File destDir) { | |||
| this.destDir = destDir; | |||
| } | |||
| /** | |||
| * Sets the set of exclude patterns. Patterns may be separated by a comma | |||
| * or a space. Currently only patterns denoting packages are | |||
| * supported | |||
| * | |||
| * @param excludes the string containing the exclude patterns | |||
| */ | |||
| public void setExcludes(String excludes) { | |||
| patternSet.setExcludes(excludes); | |||
| } | |||
| /** | |||
| * if exportClasses is set, class files are exported | |||
| */ | |||
| public void setExportClasses(boolean doExport) { | |||
| exportClasses = doExport; | |||
| } | |||
| /** | |||
| * if exportDebugInfo is set, the exported class files contain | |||
| * debug info | |||
| */ | |||
| public void setExportDebugInfo(boolean doExport) { | |||
| exportDebugInfo = doExport; | |||
| } | |||
| /** | |||
| * if exportResources is set, resource file will be exported | |||
| */ | |||
| public void setExportResources(boolean doExport) { | |||
| exportResources = doExport; | |||
| } | |||
| /** | |||
| * if exportSources is set, java files will be exported | |||
| */ | |||
| public void setExportSources(boolean doExport) { | |||
| exportSources = doExport; | |||
| } | |||
| /** | |||
| * Sets the set of include patterns. Patterns may be separated by a comma | |||
| * or a space.Currently only patterns denoting packages are | |||
| * supported | |||
| * | |||
| * @param includes the string containing the include patterns | |||
| */ | |||
| public void setIncludes(String includes) { | |||
| patternSet.setIncludes(includes); | |||
| } | |||
| /** | |||
| * if Overwrite is set, files will be overwritten during export | |||
| */ | |||
| public void setOverwrite(boolean doOverwrite) { | |||
| overwrite = doOverwrite; | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -64,11 +64,11 @@ import org.apache.tools.ant.types.FileSet; | |||
| import java.lang.reflect.Field; | |||
| /** | |||
| * Import source, class files, and resources to the Visual Age for Java | |||
| * Import source, class files, and resources to the Visual Age for Java | |||
| * workspace using FileSets. | |||
| * <p> | |||
| * Example: | |||
| * <pre> | |||
| * Example: | |||
| * <pre> | |||
| * <vajimport project="MyVAProject"> | |||
| * <fileset dir="src"> | |||
| * <include name="org/foo/subsystem1/**" /> | |||
| @@ -77,7 +77,7 @@ import java.lang.reflect.Field; | |||
| * </vajexport> | |||
| * </pre> | |||
| * import all source and resource files from the "src" directory | |||
| * which start with 'org.foo.subsystem1', except of these starting with | |||
| * which start with 'org.foo.subsystem1', except of these starting with | |||
| * 'org.foo.subsystem1.test' into the project MyVAProject. | |||
| * </p> | |||
| * <p>If MyVAProject isn't loaded into the Workspace, a new edition is | |||
| @@ -117,116 +117,116 @@ import java.lang.reflect.Field; | |||
| * @author: Glenn McAllister, inspired by a similar task written by Peter Kelley | |||
| */ | |||
| public class VAJImport extends VAJTask { | |||
| protected Vector filesets = new Vector(); | |||
| protected boolean importSources = true; | |||
| protected boolean importResources = true; | |||
| protected boolean importClasses = false; | |||
| protected String importProject = null; | |||
| protected boolean useDefaultExcludes = true; | |||
| /** | |||
| * The VisualAge for Java Project name to import into. | |||
| */ | |||
| public void setProject(String projectName) { | |||
| this.importProject = projectName; | |||
| } | |||
| /** | |||
| * Adds a set of files (nested fileset attribute). | |||
| */ | |||
| public void addFileset(FileSet set) { | |||
| filesets.addElement(set); | |||
| } | |||
| /** | |||
| * Import .class files. | |||
| */ | |||
| public void setImportClasses(boolean importClasses) { | |||
| this.importClasses = importClasses; | |||
| } | |||
| /** | |||
| * Import resource files (anything that doesn't end in | |||
| * .class or .java) | |||
| */ | |||
| public void setImportResources(boolean importResources) { | |||
| this.importResources = importResources; | |||
| } | |||
| /** | |||
| * Import .java files | |||
| */ | |||
| public void setImportSources(boolean importSources) { | |||
| this.importSources = importSources; | |||
| } | |||
| /** | |||
| * Sets whether default exclusions should be used or not. | |||
| * | |||
| * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions | |||
| * should be used, "false"|"off"|"no" when they | |||
| * shouldn't be used. | |||
| */ | |||
| public void setDefaultexcludes(boolean useDefaultExcludes) { | |||
| this.useDefaultExcludes = useDefaultExcludes; | |||
| } | |||
| /** | |||
| * Do the import. | |||
| */ | |||
| public void execute() throws BuildException { | |||
| if (filesets.size() == 0) { | |||
| throw new BuildException("At least one fileset is required!"); | |||
| } | |||
| if (importProject == null || "".equals(importProject)) { | |||
| throw new BuildException("The VisualAge for Java Project name is required!"); | |||
| } | |||
| for (Enumeration e = filesets.elements(); e.hasMoreElements();) { | |||
| importFileset((FileSet) e.nextElement()); | |||
| } | |||
| } | |||
| /** | |||
| * Import all files from the fileset into the Project in the | |||
| * Workspace. | |||
| */ | |||
| protected void importFileset(FileSet fileset) { | |||
| DirectoryScanner ds = fileset.getDirectoryScanner(this.project); | |||
| if (ds.getIncludedFiles().length == 0) { | |||
| return; | |||
| } | |||
| String[] includes = null; | |||
| String[] excludes = null; | |||
| // Hack to get includes and excludes. We could also use getIncludedFiles, | |||
| // but that would result in very long HTTP-requests. | |||
| // Therefore we want to send the patterns only to the remote tool server | |||
| // and let him figure out the files. | |||
| try { | |||
| Class directoryScanner = ds.getClass(); | |||
| Field includesField = directoryScanner.getDeclaredField("includes"); | |||
| includesField.setAccessible(true); | |||
| includes = (String[]) includesField.get(ds); | |||
| Field excludesField = directoryScanner.getDeclaredField("excludes"); | |||
| excludesField.setAccessible(true); | |||
| excludes = (String[]) excludesField.get(ds); | |||
| } catch (NoSuchFieldException nsfe) { | |||
| throw new BuildException( | |||
| "DirectoryScanner.includes or .excludes missing" + nsfe.getMessage()); | |||
| } catch (IllegalAccessException iae) { | |||
| throw new BuildException( | |||
| "Access to DirectoryScanner.includes or .excludes not allowed"); | |||
| } | |||
| getUtil().importFiles( importProject, ds.getBasedir(), | |||
| includes, excludes, | |||
| importClasses, importResources, importSources, | |||
| useDefaultExcludes); | |||
| } | |||
| protected Vector filesets = new Vector(); | |||
| protected boolean importSources = true; | |||
| protected boolean importResources = true; | |||
| protected boolean importClasses = false; | |||
| protected String importProject = null; | |||
| protected boolean useDefaultExcludes = true; | |||
| /** | |||
| * The VisualAge for Java Project name to import into. | |||
| */ | |||
| public void setProject(String projectName) { | |||
| this.importProject = projectName; | |||
| } | |||
| /** | |||
| * Adds a set of files (nested fileset attribute). | |||
| */ | |||
| public void addFileset(FileSet set) { | |||
| filesets.addElement(set); | |||
| } | |||
| /** | |||
| * Import .class files. | |||
| */ | |||
| public void setImportClasses(boolean importClasses) { | |||
| this.importClasses = importClasses; | |||
| } | |||
| /** | |||
| * Import resource files (anything that doesn't end in | |||
| * .class or .java) | |||
| */ | |||
| public void setImportResources(boolean importResources) { | |||
| this.importResources = importResources; | |||
| } | |||
| /** | |||
| * Import .java files | |||
| */ | |||
| public void setImportSources(boolean importSources) { | |||
| this.importSources = importSources; | |||
| } | |||
| /** | |||
| * Sets whether default exclusions should be used or not. | |||
| * | |||
| * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions | |||
| * should be used, "false"|"off"|"no" when they | |||
| * shouldn't be used. | |||
| */ | |||
| public void setDefaultexcludes(boolean useDefaultExcludes) { | |||
| this.useDefaultExcludes = useDefaultExcludes; | |||
| } | |||
| /** | |||
| * Do the import. | |||
| */ | |||
| public void execute() throws BuildException { | |||
| if (filesets.size() == 0) { | |||
| throw new BuildException("At least one fileset is required!"); | |||
| } | |||
| if (importProject == null || "".equals(importProject)) { | |||
| throw new BuildException("The VisualAge for Java Project name is required!"); | |||
| } | |||
| for (Enumeration e = filesets.elements(); e.hasMoreElements();) { | |||
| importFileset((FileSet) e.nextElement()); | |||
| } | |||
| } | |||
| /** | |||
| * Import all files from the fileset into the Project in the | |||
| * Workspace. | |||
| */ | |||
| protected void importFileset(FileSet fileset) { | |||
| DirectoryScanner ds = fileset.getDirectoryScanner(this.project); | |||
| if (ds.getIncludedFiles().length == 0) { | |||
| return; | |||
| } | |||
| String[] includes = null; | |||
| String[] excludes = null; | |||
| // Hack to get includes and excludes. We could also use getIncludedFiles, | |||
| // but that would result in very long HTTP-requests. | |||
| // Therefore we want to send the patterns only to the remote tool server | |||
| // and let him figure out the files. | |||
| try { | |||
| Class directoryScanner = ds.getClass(); | |||
| Field includesField = directoryScanner.getDeclaredField("includes"); | |||
| includesField.setAccessible(true); | |||
| includes = (String[]) includesField.get(ds); | |||
| Field excludesField = directoryScanner.getDeclaredField("excludes"); | |||
| excludesField.setAccessible(true); | |||
| excludes = (String[]) excludesField.get(ds); | |||
| } catch (NoSuchFieldException nsfe) { | |||
| throw new BuildException( | |||
| "DirectoryScanner.includes or .excludes missing" + nsfe.getMessage()); | |||
| } catch (IllegalAccessException iae) { | |||
| throw new BuildException( | |||
| "Access to DirectoryScanner.includes or .excludes not allowed"); | |||
| } | |||
| getUtil().importFiles( importProject, ds.getBasedir(), | |||
| includes, excludes, | |||
| importClasses, importResources, importSources, | |||
| useDefaultExcludes); | |||
| } | |||
| } | |||
| @@ -59,7 +59,7 @@ import java.io.File; | |||
| /** | |||
| * A Remote Access to Tools Servlet to import a Project | |||
| * from files into the Repository. The following | |||
| * from files into the Repository. The following | |||
| * table describes the servlet parameters. | |||
| * | |||
| * <table> | |||
| @@ -95,8 +95,8 @@ public class VAJImportServlet extends VAJToolsServlet { | |||
| getBooleanParam(RESOURCES_PARAM, true), | |||
| getBooleanParam(SOURCES_PARAM, true), | |||
| false // no default excludes, because they | |||
| // are already added on client side | |||
| // getBooleanParam(DEFAULT_EXCLUDES_PARAM, true) | |||
| // are already added on client side | |||
| // getBooleanParam(DEFAULT_EXCLUDES_PARAM, true) | |||
| ); | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -81,7 +81,7 @@ import org.apache.tools.ant.DirectoryScanner; | |||
| abstract class VAJLocalUtil implements VAJUtil{ | |||
| // singleton containing the VAJ workspace | |||
| private static Workspace workspace; | |||
| /** | |||
| * Wraps IvjException into a BuildException | |||
| * | |||
| @@ -100,7 +100,7 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| } | |||
| return new BuildException(errMsg, e); | |||
| } | |||
| /** | |||
| * returns the current VAJ workspace. | |||
| * @return com.ibm.ivj.util.base.Workspace | |||
| @@ -111,7 +111,7 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| if (workspace == null) { | |||
| throw new BuildException( | |||
| "Unable to connect to Workspace! " | |||
| + "Make sure you are running in VisualAge for Java."); | |||
| + "Make sure you are running in VisualAge for Java."); | |||
| } | |||
| } | |||
| @@ -122,7 +122,7 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| //----------------------------------------------------------- | |||
| // export | |||
| //----------------------------------------------------------- | |||
| /** | |||
| * export packages | |||
| */ | |||
| @@ -131,7 +131,7 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean exportClasses, boolean exportDebugInfo, | |||
| boolean exportResources, boolean exportSources, | |||
| boolean useDefaultExcludes, boolean overwrite) { | |||
| boolean useDefaultExcludes, boolean overwrite) { | |||
| if (includePatterns == null || includePatterns.length == 0) { | |||
| log( "You must specify at least one include attribute. " | |||
| + "Not exporting", MSG_ERR); | |||
| @@ -147,7 +147,7 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| Package[] packages = scanner.getIncludedPackages(); | |||
| log( "Exporting " + packages.length + " package(s) to " | |||
| log( "Exporting " + packages.length + " package(s) to " | |||
| + dest, MSG_INFO); | |||
| for (int i = 0; i < packages.length; i++) { | |||
| log(" " + packages[i].getName(), MSG_VERBOSE); | |||
| @@ -174,7 +174,7 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| //----------------------------------------------------------- | |||
| // load | |||
| //----------------------------------------------------------- | |||
| /** | |||
| * Load specified projects. | |||
| */ | |||
| @@ -188,26 +188,26 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| log("No Projects match the name " + d.getName(), MSG_WARN); | |||
| } | |||
| } | |||
| log( "Loading " + expandedDescs.size() | |||
| log( "Loading " + expandedDescs.size() | |||
| + " project(s) into workspace", MSG_INFO); | |||
| for (Enumeration e = expandedDescs.elements(); | |||
| for (Enumeration e = expandedDescs.elements(); | |||
| e.hasMoreElements(); ) { | |||
| VAJProjectDescription d = (VAJProjectDescription) e.nextElement(); | |||
| ProjectEdition pe = findProjectEdition(d.getName(), d.getVersion()); | |||
| try { | |||
| log( "Loading '" + d.getName() + "', Version '" + d.getVersion() | |||
| + "', into Workspace", MSG_VERBOSE ); | |||
| log( "Loading '" + d.getName() + "', Version '" + d.getVersion() | |||
| + "', into Workspace", MSG_VERBOSE ); | |||
| pe.loadIntoWorkspace(); | |||
| } catch (IvjException ex) { | |||
| throw createBuildException( "Project '" + d.getName() | |||
| + "' could not be loaded.", ex ); | |||
| throw createBuildException( "Project '" + d.getName() | |||
| + "' could not be loaded.", ex ); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * returns a list of project names matching the given pattern | |||
| */ | |||
| @@ -237,17 +237,17 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| private Vector getExpandedDescriptions(Vector projectDescs) { | |||
| Vector expandedDescs = new Vector(projectDescs.size()); | |||
| try { | |||
| String[] projectNames = | |||
| String[] projectNames = | |||
| getWorkspace().getRepository().getProjectNames(); | |||
| for (int i = 0; i < projectNames.length; i++) { | |||
| for (Enumeration e = projectDescs.elements(); | |||
| for (Enumeration e = projectDescs.elements(); | |||
| e.hasMoreElements();) { | |||
| VAJProjectDescription d = (VAJProjectDescription) e.nextElement(); | |||
| String pattern = d.getName(); | |||
| if (VAJWorkspaceScanner.match(pattern, projectNames[i])) { | |||
| d.setProjectFound(); | |||
| expandedDescs.addElement(new VAJProjectDescription( | |||
| projectNames[i], d.getVersion())); | |||
| projectNames[i], d.getVersion())); | |||
| break; | |||
| } | |||
| } | |||
| @@ -283,8 +283,8 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| } | |||
| } | |||
| if (pe == null) { | |||
| throw new BuildException( "Version " + versionName | |||
| + " of Project " + name + " doesn't exist" ); | |||
| throw new BuildException( "Version " + versionName | |||
| + " of Project " + name + " doesn't exist" ); | |||
| } | |||
| return pe; | |||
| @@ -299,18 +299,18 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| //----------------------------------------------------------- | |||
| // import | |||
| //----------------------------------------------------------- | |||
| /** | |||
| * Do the import. | |||
| */ | |||
| public void importFiles( | |||
| String importProject, File srcDir, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean importClasses, boolean importResources, | |||
| boolean importSources, boolean useDefaultExcludes) | |||
| String importProject, File srcDir, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean importClasses, boolean importResources, | |||
| boolean importSources, boolean useDefaultExcludes) | |||
| throws BuildException { | |||
| if (importProject == null || "".equals(importProject)) { | |||
| throw new BuildException("The VisualAge for Java project " | |||
| + "name is required!"); | |||
| @@ -332,20 +332,20 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| Vector sources = new Vector(); | |||
| Vector resources = new Vector(); | |||
| scanForImport( srcDir, ds.getIncludedFiles(), classes, sources, resources); | |||
| scanForImport( srcDir, ds.getIncludedFiles(), classes, sources, resources); | |||
| StringBuffer summaryLog = new StringBuffer("Importing "); | |||
| addFilesToImport( importSpec, importClasses, classes, "Class", summaryLog ); | |||
| addFilesToImport( importSpec, importSources, sources, "Java", summaryLog ); | |||
| addFilesToImport( importSpec, importResources, resources, "Resource", summaryLog ); | |||
| importSpec.setResourcePath(srcDir.getAbsolutePath()); | |||
| summaryLog.append( " into the project '" ); | |||
| summaryLog.append( importProject ); | |||
| summaryLog.append( "'." ); | |||
| log(summaryLog.toString(), MSG_INFO); | |||
| try { | |||
| Type[] importedTypes = getWorkspace().importData(importSpec); | |||
| if (importedTypes == null) { | |||
| @@ -354,9 +354,9 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| else { | |||
| log( importedTypes.length + " types imported", MSG_DEBUG); | |||
| for( int i = 0; i < importedTypes.length; i++ ) { | |||
| log( importedTypes[i].getPackage().getName() | |||
| + "." + importedTypes[i].getName() | |||
| + " into " + importedTypes[i].getProject().getName(), | |||
| log( importedTypes[i].getPackage().getName() | |||
| + "." + importedTypes[i].getName() | |||
| + " into " + importedTypes[i].getProject().getName(), | |||
| MSG_DEBUG); | |||
| } | |||
| } | |||
| @@ -387,10 +387,10 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| found = getWorkspace().createProject(importProject, true); | |||
| } catch (IvjException e) { | |||
| throw createBuildException( "Error while creating Project " | |||
| + importProject + ": ", e ); | |||
| + importProject + ": ", e ); | |||
| } | |||
| } | |||
| return found; | |||
| } | |||
| @@ -399,10 +399,10 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| * Sort the files into classes, sources, and resources. | |||
| */ | |||
| private void scanForImport( | |||
| File dir, | |||
| String[] files, | |||
| Vector classes, | |||
| Vector sources, | |||
| File dir, | |||
| String[] files, | |||
| Vector classes, | |||
| Vector sources, | |||
| Vector resources) { | |||
| for (int i = 0; i < files.length; i++) { | |||
| String file = (new File(dir, files[i])).getAbsolutePath(); | |||
| @@ -438,11 +438,11 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| String[] fileArr = new String[files.size()]; | |||
| files.copyInto(fileArr); | |||
| try { | |||
| // here it is assumed that fileType is one of the | |||
| // here it is assumed that fileType is one of the | |||
| // following strings: // "Java", "Class", "Resource" | |||
| String methodName = "set"+fileType+"Files"; | |||
| Class[] methodParams = new Class[]{fileArr.getClass()}; | |||
| java.lang.reflect.Method method = | |||
| java.lang.reflect.Method method = | |||
| spec.getClass().getDeclaredMethod( methodName, methodParams); | |||
| method.invoke(spec, new Object[]{fileArr}); | |||
| } catch( Exception e ) { | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -67,31 +67,31 @@ public class VAJProjectDescription { | |||
| public VAJProjectDescription() { | |||
| } | |||
| public VAJProjectDescription(String n, String v) { | |||
| name = n; | |||
| version = v; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public String getVersion() { | |||
| return version; | |||
| } | |||
| public boolean projectFound() { | |||
| return projectFound; | |||
| } | |||
| public void setName(String newName) { | |||
| if (newName == null || newName.equals("")) { | |||
| throw new BuildException("name attribute must be set"); | |||
| } | |||
| name = newName; | |||
| } | |||
| public void setVersion(String newVersion) { | |||
| if (newVersion == null || newVersion.equals("")) { | |||
| throw new BuildException("version attribute must be set"); | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -90,7 +90,7 @@ class VAJRemoteUtil implements VAJUtil{ | |||
| /** | |||
| * export the array of Packages | |||
| */ | |||
| public void exportPackages(File destDir, | |||
| public void exportPackages(File destDir, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean exportClasses, boolean exportDebugInfo, boolean exportResources, | |||
| boolean exportSources, boolean useDefaultExcludes, boolean overwrite ) { | |||
| @@ -112,13 +112,13 @@ class VAJRemoteUtil implements VAJUtil{ | |||
| * Do the import. | |||
| */ | |||
| public void importFiles( | |||
| String importProject, File srcDir, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean importClasses, boolean importResources, | |||
| String importProject, File srcDir, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean importClasses, boolean importResources, | |||
| boolean importSources, boolean useDefaultExcludes) { | |||
| try { | |||
| String request = "http://" + remoteServer + "/servlet/vajimport?" | |||
| + VAJImportServlet.PROJECT_NAME_PARAM + "=" | |||
| + VAJImportServlet.PROJECT_NAME_PARAM + "=" | |||
| + importProject + "&" | |||
| + assembleImportExportParams( srcDir, | |||
| includePatterns, excludePatterns, | |||
| @@ -128,7 +128,7 @@ class VAJRemoteUtil implements VAJUtil{ | |||
| } catch (Exception ex) { | |||
| throw new BuildException(ex); | |||
| } | |||
| } | |||
| /** | |||
| @@ -137,11 +137,11 @@ class VAJRemoteUtil implements VAJUtil{ | |||
| */ | |||
| private String assembleImportExportParams( | |||
| File dir, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean includeClasses, boolean includeResources, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean includeClasses, boolean includeResources, | |||
| boolean includeSources, boolean useDefaultExcludes) { | |||
| String result = | |||
| VAJToolsServlet.DIR_PARAM + "=" | |||
| VAJToolsServlet.DIR_PARAM + "=" | |||
| + dir.getAbsolutePath().replace('\\', '/') + "&" | |||
| + VAJToolsServlet.CLASSES_PARAM + "=" + includeClasses + "&" | |||
| + VAJToolsServlet.RESOURCES_PARAM + "=" + includeResources + "&" | |||
| @@ -156,14 +156,14 @@ class VAJRemoteUtil implements VAJUtil{ | |||
| } | |||
| if ( excludePatterns != null ) { | |||
| for ( int i = 0; i < excludePatterns.length; i++ ){ | |||
| result = result + "&" + VAJExportServlet.EXCLUDE_PARAM + "=" | |||
| result = result + "&" + VAJExportServlet.EXCLUDE_PARAM + "=" | |||
| + excludePatterns[i].replace(' ', '+').replace('\\', '/'); | |||
| } | |||
| } | |||
| return result; | |||
| } | |||
| /** | |||
| * Load specified projects. | |||
| */ | |||
| @@ -173,8 +173,8 @@ class VAJRemoteUtil implements VAJUtil{ | |||
| String delimiter = ""; | |||
| for ( Enumeration e = projectDescriptions.elements(); e.hasMoreElements(); ){ | |||
| VAJProjectDescription pd = (VAJProjectDescription)e.nextElement(); | |||
| request = request | |||
| + delimiter + VAJLoadServlet.PROJECT_NAME_PARAM | |||
| request = request | |||
| + delimiter + VAJLoadServlet.PROJECT_NAME_PARAM | |||
| + "=" + pd.getName().replace(' ', '+') | |||
| + "&" + VAJLoadServlet.VERSION_PARAM | |||
| + "=" + pd.getVersion().replace(' ', '+'); | |||
| @@ -201,10 +201,10 @@ class VAJRemoteUtil implements VAJUtil{ | |||
| boolean requestFailed = false; | |||
| try { | |||
| log("Request: " + request, MSG_DEBUG); | |||
| //must be HTTP connection | |||
| URL requestUrl = new URL( request ); | |||
| HttpURLConnection connection = | |||
| HttpURLConnection connection = | |||
| (HttpURLConnection) requestUrl.openConnection(); | |||
| InputStream is = null; | |||
| @@ -238,7 +238,7 @@ class VAJRemoteUtil implements VAJUtil{ | |||
| log( line.substring(2), level ); | |||
| line = br.readLine(); | |||
| } | |||
| } catch (IOException ex) { | |||
| log("Error sending tool request to VAJ" + ex, MSG_ERR); | |||
| throw new BuildException("Couldn't execute " + request ); | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -57,12 +57,12 @@ package org.apache.tools.ant.taskdefs.optional.ide; | |||
| /** | |||
| * Super class for all VAJ tasks. Contains common | |||
| * attributes (remoteServer) and util methods | |||
| * | |||
| * | |||
| * @author: Wolf Siberski | |||
| */ | |||
| import org.apache.tools.ant.Task; | |||
| public class VAJTask extends Task { | |||
| /** | |||
| * Adaption of VAJLocalUtil to Task context. | |||
| @@ -79,7 +79,7 @@ public class VAJTask extends Task { | |||
| // holds the appropriate VAJUtil implementation | |||
| private VAJUtil util = null; | |||
| /** | |||
| * returns the VAJUtil implementation | |||
| */ | |||
| @@ -93,7 +93,7 @@ public class VAJTask extends Task { | |||
| } | |||
| return util; | |||
| } | |||
| /** | |||
| * Set remote server attribute | |||
| */ | |||
| @@ -69,7 +69,7 @@ import org.apache.tools.ant.BuildException; | |||
| /** | |||
| * Abstract base class to provide common services for the | |||
| * VAJ tool API servlets | |||
| * VAJ tool API servlets | |||
| * | |||
| * @author Wolf Siberski, based on servlets written by Glenn McAllister | |||
| */ | |||
| @@ -88,7 +88,7 @@ public abstract class VAJToolsServlet extends HttpServlet { | |||
| if ( nlPos == -1 ) { | |||
| nlPos = msg.length(); | |||
| } | |||
| response.getWriter().println( Integer.toString(level) | |||
| response.getWriter().println( Integer.toString(level) | |||
| + " " + msg.substring( i, nlPos )); | |||
| i = nlPos + 1; | |||
| } | |||
| @@ -99,7 +99,7 @@ public abstract class VAJToolsServlet extends HttpServlet { | |||
| } | |||
| } | |||
| } | |||
| // constants for servlet param names | |||
| public final static String DIR_PARAM = "dir"; | |||
| public final static String INCLUDE_PARAM = "include"; | |||
| @@ -124,17 +124,17 @@ public abstract class VAJToolsServlet extends HttpServlet { | |||
| /** | |||
| * Execute the request by calling the appropriate | |||
| * VAJ tool API methods. This method must be implemented | |||
| * by the concrete servlets | |||
| * by the concrete servlets | |||
| */ | |||
| protected abstract void executeRequest(); | |||
| /** | |||
| * Respond to a HTTP request. This method initializes | |||
| * the servlet and handles errors. | |||
| * The real work is done in the abstract method executeRequest() | |||
| * the servlet and handles errors. | |||
| * The real work is done in the abstract method executeRequest() | |||
| */ | |||
| public void doGet(HttpServletRequest req, HttpServletResponse res) | |||
| throws ServletException, IOException { | |||
| throws ServletException, IOException { | |||
| try { | |||
| response = res; | |||
| request = req; | |||
| @@ -148,14 +148,14 @@ public abstract class VAJToolsServlet extends HttpServlet { | |||
| StringWriter sw = new StringWriter(); | |||
| e.printStackTrace(new PrintWriter(sw)); | |||
| String trace = new String( sw.getBuffer() ); | |||
| util.log("Program error in " + this.getClass().getName() | |||
| util.log("Program error in " + this.getClass().getName() | |||
| + ":\n" + trace, VAJUtil.MSG_ERR); | |||
| } | |||
| } catch( Throwable t ) { | |||
| t.printStackTrace(); | |||
| } finally { | |||
| if ( ! (e instanceof BuildException) ) | |||
| { | |||
| { | |||
| throw new ServletException( e.getMessage() ); | |||
| } | |||
| } | |||
| @@ -171,7 +171,7 @@ public abstract class VAJToolsServlet extends HttpServlet { | |||
| util = new VAJLocalServletUtil(); | |||
| } | |||
| } | |||
| /** | |||
| * Get the VAJUtil implementation | |||
| */ | |||
| @@ -224,5 +224,5 @@ public abstract class VAJToolsServlet extends HttpServlet { | |||
| protected boolean toBoolean(String string) { | |||
| String lower = string.toLowerCase(); | |||
| return (lower.equals("yes") || lower.equals("true") || lower.equals("ok")); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -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,15 +17,15 @@ | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * 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, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| @@ -64,39 +64,39 @@ import java.io.File; | |||
| * @author Wolf Siberski, TUI Infotec GmbH | |||
| */ | |||
| interface VAJUtil { | |||
| // log levels | |||
| public static final int MSG_DEBUG = 4; | |||
| public static final int MSG_ERR = 0; | |||
| public static final int MSG_INFO = 2; | |||
| public static final int MSG_VERBOSE = 3; | |||
| public static final int MSG_WARN = 1; | |||
| // log levels | |||
| public static final int MSG_DEBUG = 4; | |||
| public static final int MSG_ERR = 0; | |||
| public static final int MSG_INFO = 2; | |||
| public static final int MSG_VERBOSE = 3; | |||
| public static final int MSG_WARN = 1; | |||
| /** | |||
| * export the array of Packages | |||
| */ | |||
| void exportPackages( | |||
| File dest, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean exportClasses, boolean exportDebugInfo, | |||
| boolean exportResources, boolean exportSources, | |||
| boolean useDefaultExcludes, boolean overwrite); | |||
| /** | |||
| * export the array of Packages | |||
| */ | |||
| void exportPackages( | |||
| File dest, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean exportClasses, boolean exportDebugInfo, | |||
| boolean exportResources, boolean exportSources, | |||
| boolean useDefaultExcludes, boolean overwrite); | |||
| /** | |||
| * Do the import. | |||
| */ | |||
| void importFiles( | |||
| String importProject, File srcDir, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean importClasses, boolean importResources, | |||
| boolean importSources, boolean useDefaultExcludes); | |||
| /** | |||
| * Do the import. | |||
| */ | |||
| void importFiles( | |||
| String importProject, File srcDir, | |||
| String[] includePatterns, String[] excludePatterns, | |||
| boolean importClasses, boolean importResources, | |||
| boolean importSources, boolean useDefaultExcludes); | |||
| /** | |||
| * Load specified projects. | |||
| */ | |||
| void loadProjects(Vector projectDescriptions); | |||
| /** | |||
| * Load specified projects. | |||
| */ | |||
| void loadProjects(Vector projectDescriptions); | |||
| /** | |||
| * Logs a message with the specified log level. | |||
| */ | |||
| void log(String msg, int level); | |||
| /** | |||
| * Logs a message with the specified log level. | |||
| */ | |||
| void log(String msg, int level); | |||
| } | |||
| @@ -79,7 +79,7 @@ import org.apache.tools.ant.DirectoryScanner; | |||
| * <li>VisualAge*\**</li> | |||
| * </ul> | |||
| * <p> | |||
| * This class works like DirectoryScanner. | |||
| * This class works like DirectoryScanner. | |||
| * | |||
| * @see org.apache.tools.ant.DirectoryScanner | |||
| * | |||
| @@ -88,19 +88,19 @@ import org.apache.tools.ant.DirectoryScanner; | |||
| class VAJWorkspaceScanner extends DirectoryScanner { | |||
| // Patterns that should be excluded by default. | |||
| private final static String[] DEFAULTEXCLUDES = | |||
| private final static String[] DEFAULTEXCLUDES = | |||
| { | |||
| "IBM*/**", | |||
| "Java class libraries/**", | |||
| "Sun class libraries*/**", | |||
| "JSP Page Compile Generated Code/**", | |||
| "VisualAge*/**", | |||
| }; | |||
| "IBM*/**", | |||
| "Java class libraries/**", | |||
| "Sun class libraries*/**", | |||
| "JSP Page Compile Generated Code/**", | |||
| "VisualAge*/**", | |||
| }; | |||
| // The packages that where found and matched at least | |||
| // The packages that where found and matched at least | |||
| // one includes, and matched no excludes. | |||
| private Vector packagesIncluded = new Vector(); | |||
| /** | |||
| * Adds the array with default exclusions to the current exclusions set. | |||
| */ | |||
| @@ -114,11 +114,11 @@ class VAJWorkspaceScanner extends DirectoryScanner { | |||
| for (int i = 0; i < DEFAULTEXCLUDES.length; i++) { | |||
| newExcludes[i + excludesLength] = DEFAULTEXCLUDES[i]. | |||
| replace( '/', File.separatorChar ). | |||
| replace( '\\', File.separatorChar ); | |||
| replace( '\\', File.separatorChar ); | |||
| } | |||
| excludes = newExcludes; | |||
| } | |||
| /** | |||
| * Finds all Projects specified in include patterns. | |||
| * | |||
| @@ -133,11 +133,11 @@ class VAJWorkspaceScanner extends DirectoryScanner { | |||
| for (int i = 0; i < projects.length; i++) { | |||
| Project project = projects[i]; | |||
| for (int j = 0; j < includes.length && !allProjectsMatch; j++) { | |||
| StringTokenizer tok = | |||
| StringTokenizer tok = | |||
| new StringTokenizer(includes[j], File.separator); | |||
| String projectNamePattern = tok.nextToken(); | |||
| if (projectNamePattern.equals("**")) { | |||
| // if an include pattern starts with '**', | |||
| // if an include pattern starts with '**', | |||
| // all projects match | |||
| allProjectsMatch = true; | |||
| } else | |||
| @@ -157,7 +157,7 @@ class VAJWorkspaceScanner extends DirectoryScanner { | |||
| return matchingProjects; | |||
| } | |||
| /** | |||
| * Get the names of the packages that matched at least one of the include | |||
| * patterns, and didn't match one of the exclude patterns. | |||
| @@ -172,7 +172,7 @@ class VAJWorkspaceScanner extends DirectoryScanner { | |||
| } | |||
| return packages; | |||
| } | |||
| /** | |||
| * Matches a string against a pattern. The pattern contains two special | |||
| * characters: | |||
| @@ -212,7 +212,7 @@ class VAJWorkspaceScanner extends DirectoryScanner { | |||
| scanProject(project); | |||
| } | |||
| } | |||
| /** | |||
| * Scans a project for packages that match at least one include | |||
| * pattern, and don't match any exclude patterns. | |||
| @@ -227,10 +227,10 @@ class VAJWorkspaceScanner extends DirectoryScanner { | |||
| // replace '.' by file seperator because the patterns are | |||
| // using file seperator syntax (and we can use the match | |||
| // methods this way). | |||
| String name = | |||
| String name = | |||
| project.getName() | |||
| + File.separator | |||
| + item.getName().replace('.', File.separatorChar); | |||
| + item.getName().replace('.', File.separatorChar); | |||
| if (isIncluded(name) && !isExcluded(name)) { | |||
| packagesIncluded.addElement(item); | |||
| } | |||
| @@ -153,7 +153,7 @@ public class JDependTask extends Task { | |||
| * @see #setFork(boolean) | |||
| */ | |||
| public void setJvm(String value) { | |||
| _jvm = value; | |||
| _jvm = value; | |||
| } | |||
| @@ -230,18 +230,18 @@ public class JDependTask extends Task { | |||
| public void setFormat(FormatAttribute ea) | |||
| { | |||
| format = ea.getValue(); | |||
| } | |||
| format = ea.getValue(); | |||
| } | |||
| public static class FormatAttribute extends EnumeratedAttribute | |||
| { | |||
| private String [] formats = new String[]{"xml","text"}; | |||
| public static class FormatAttribute extends EnumeratedAttribute | |||
| { | |||
| private String [] formats = new String[]{"xml","text"}; | |||
| public String[] getValues() | |||
| { | |||
| return formats; | |||
| } | |||
| } | |||
| public String[] getValues() | |||
| { | |||
| return formats; | |||
| } | |||
| } | |||
| /** | |||
| @@ -255,16 +255,16 @@ public class JDependTask extends Task { | |||
| public void execute() throws BuildException { | |||
| CommandlineJava commandline = new CommandlineJava(); | |||
| CommandlineJava commandline = new CommandlineJava(); | |||
| if("text".equals(format)) | |||
| commandline.setClassname("jdepend.textui.JDepend"); | |||
| else | |||
| if("xml".equals(format)) | |||
| commandline.setClassname("jdepend.xmlui.JDepend"); | |||
| if("text".equals(format)) | |||
| commandline.setClassname("jdepend.textui.JDepend"); | |||
| else | |||
| if("xml".equals(format)) | |||
| commandline.setClassname("jdepend.xmlui.JDepend"); | |||
| if(_jvm!=null) | |||
| commandline.setVm(_jvm); | |||
| if(_jvm!=null) | |||
| commandline.setVm(_jvm); | |||
| if (getSourcespath() == null) | |||
| throw new BuildException("Missing Sourcepath required argument"); | |||
| @@ -311,9 +311,9 @@ public class JDependTask extends Task { | |||
| jdepend.textui.JDepend jdepend; | |||
| if("xml".equals(format)) | |||
| jdepend = new jdepend.xmlui.JDepend(); | |||
| jdepend = new jdepend.xmlui.JDepend(); | |||
| else | |||
| jdepend = new jdepend.textui.JDepend(); | |||
| jdepend = new jdepend.textui.JDepend(); | |||
| if (getOutputFile() != null) { | |||
| FileWriter fw; | |||
| @@ -96,10 +96,10 @@ public class AggregateTransformer { | |||
| public final static String NOFRAMES = "noframes"; | |||
| public static class Format extends EnumeratedAttribute { | |||
| public String[] getValues(){ | |||
| return new String[]{FRAMES, NOFRAMES}; | |||
| } | |||
| } | |||
| public String[] getValues(){ | |||
| return new String[]{FRAMES, NOFRAMES}; | |||
| } | |||
| } | |||
| /** Task */ | |||
| protected Task task; | |||
| @@ -60,7 +60,7 @@ import java.util.Vector; | |||
| /** | |||
| * Baseclass for BatchTest and JUnitTest. | |||
| * | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> | |||
| */ | |||
| public abstract class BaseTest { | |||
| @@ -116,12 +116,12 @@ public abstract class BaseTest { | |||
| * Sets the destination directory. | |||
| */ | |||
| public void setTodir(File destDir) { | |||
| this.destDir = destDir; | |||
| this.destDir = destDir; | |||
| } | |||
| /** | |||
| * @return the destination directory as an absolute path if it exists | |||
| * otherwise return <tt>null</tt> | |||
| * otherwise return <tt>null</tt> | |||
| */ | |||
| public String getTodir(){ | |||
| if (destDir != null){ | |||
| @@ -133,15 +133,15 @@ public abstract class BaseTest { | |||
| public java.lang.String getFailureProperty() { | |||
| return failureProperty; | |||
| } | |||
| public void setFailureProperty(String failureProperty) { | |||
| this.failureProperty = failureProperty; | |||
| } | |||
| public java.lang.String getErrorProperty() { | |||
| return errorProperty; | |||
| } | |||
| public void setErrorProperty(String errorProperty) { | |||
| this.errorProperty = errorProperty; | |||
| } | |||
| @@ -92,31 +92,31 @@ import org.apache.tools.ant.util.DOMElementWriter; | |||
| * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> | |||
| */ | |||
| public class XMLResultAggregator extends Task implements XMLConstants { | |||
| /** the list of all filesets, that should contains the xml to aggregate */ | |||
| protected Vector filesets = new Vector(); | |||
| /** the name of the result file */ | |||
| protected String toFile; | |||
| /** the directory to write the file to */ | |||
| protected File toDir; | |||
| protected Vector transformers = new Vector(); | |||
| /** the default directory: <tt>.</tt>. It is resolved from the project directory */ | |||
| public final static String DEFAULT_DIR = "."; | |||
| /** the default file name: <tt>TESTS-TestSuites.xml</tt> */ | |||
| public final static String DEFAULT_FILENAME = "TESTS-TestSuites.xml"; | |||
| public AggregateTransformer createReport(){ | |||
| AggregateTransformer transformer = new AggregateTransformer(this); | |||
| transformers.addElement(transformer); | |||
| return transformer; | |||
| } | |||
| /** | |||
| * Set the name of the file aggregating the results. It must be relative | |||
| * from the <tt>todir</tt> attribute. If not set it will use {@link #DEFAULT_FILENAME} | |||
| @@ -126,7 +126,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| public void setTofile(String value){ | |||
| toFile = value; | |||
| } | |||
| /** | |||
| * Set the destination directory where the results should be written. If not | |||
| * set if will use {@link #DEFAULT_DIR}. When given a relative directory | |||
| @@ -137,7 +137,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| public void setTodir(File value){ | |||
| toDir = value; | |||
| } | |||
| /** | |||
| * Add a new fileset containing the xml results to aggregate | |||
| * @param fs the new fileset of xml results. | |||
| @@ -145,12 +145,12 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| public void addFileSet(FileSet fs) { | |||
| filesets.addElement(fs); | |||
| } | |||
| /** | |||
| * Aggregate all testsuites into a single document and write it to the | |||
| * specified directory and file. | |||
| * @throws BuildException thrown if there is a serious error while writing | |||
| * the document. | |||
| * @throws BuildException thrown if there is a serious error while writing | |||
| * the document. | |||
| */ | |||
| public void execute() throws BuildException { | |||
| Element rootElement = createDocument(); | |||
| @@ -170,7 +170,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| transformer.transform(); | |||
| } | |||
| } | |||
| /** | |||
| * Get the full destination file where to write the result. It is made of | |||
| * the <tt>todir</tt> and <tt>tofile</tt> attributes. | |||
| @@ -185,7 +185,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| } | |||
| return new File(toDir, toFile); | |||
| } | |||
| /** | |||
| * Get all <code>.xml</code> files in the fileset. | |||
| * | |||
| @@ -208,14 +208,14 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| } | |||
| } | |||
| } | |||
| File[] files = new File[v.size()]; | |||
| v.copyInto(files); | |||
| return files; | |||
| } | |||
| //----- from now, the methods are all related to DOM tree manipulation | |||
| /** | |||
| * Write the DOM tree to a file. | |||
| * @param doc the XML document to dump to disk. | |||
| @@ -234,12 +234,12 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| throw new IOException("Error while writing DOM content"); | |||
| } | |||
| } | |||
| /** | |||
| * <p> Create a DOM tree. | |||
| * <p> Create a DOM tree. | |||
| * Has 'testsuites' as firstchild and aggregates all | |||
| * testsuite results that exists in the base directory. | |||
| * @return the root element of DOM tree that aggregates all testsuites. | |||
| * @return the root element of DOM tree that aggregates all testsuites. | |||
| */ | |||
| protected Element createDocument() { | |||
| // create the dom tree | |||
| @@ -247,7 +247,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| Document doc = builder.newDocument(); | |||
| Element rootElement = doc.createElement(TESTSUITES); | |||
| doc.appendChild(rootElement); | |||
| // get all files and add them to the document | |||
| File[] files = getFiles(); | |||
| for (int i = 0; i < files.length; i++) { | |||
| @@ -278,7 +278,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| } | |||
| return rootElement; | |||
| } | |||
| /** | |||
| * <p> Add a new testsuite node to the document. | |||
| * The main difference is that it | |||
| @@ -294,17 +294,17 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| protected void addTestSuite(Element root, Element testsuite){ | |||
| String fullclassname = testsuite.getAttribute(ATTR_NAME); | |||
| int pos = fullclassname.lastIndexOf('.'); | |||
| // a missing . might imply no package at all. Don't get fooled. | |||
| String pkgName = (pos == -1) ? "" : fullclassname.substring(0, pos); | |||
| String classname = (pos == -1) ? fullclassname : fullclassname.substring(pos + 1); | |||
| Element copy = (Element)DOMUtil.importNode(root, testsuite); | |||
| // modify the name attribute and set the package | |||
| copy.setAttribute(ATTR_NAME, classname); | |||
| copy.setAttribute(ATTR_PACKAGE, pkgName); | |||
| } | |||
| /** | |||
| * Create a new document builder. Will issue an <tt>ExceptionInitializerError</tt> | |||
| * if something is going wrong. It is fatal anyway. | |||
| @@ -318,5 +318,5 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| throw new ExceptionInInitializerError(exc); | |||
| } | |||
| } | |||
| } | |||
| @@ -85,7 +85,7 @@ import org.apache.tools.ant.Project; | |||
| * A handy metrics handler. Most of this code was done only with the | |||
| * screenshots on the documentation since the evaluation version as | |||
| * of this writing does not allow to save metrics or to run it via | |||
| * command line. | |||
| * command line. | |||
| * <p> | |||
| * This class can be used to transform a text file or to process the | |||
| * output stream directly. | |||
| @@ -96,23 +96,23 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| /** CLASS construct, it should be named something like 'MyClass' */ | |||
| protected final static String CLASS = "class"; | |||
| /** package construct, it should be look like 'com.mycompany.something' */ | |||
| protected final static String PACKAGE = "package"; | |||
| /** FILE construct, it should look like something 'MyClass.java' or 'MyClass.class' */ | |||
| protected final static String FILE = "file"; | |||
| /** METHOD construct, it should looke like something 'doSomething(...)' or 'doSomething()' */ | |||
| protected final static String METHOD = "method"; | |||
| protected final static String[] ATTRIBUTES = { "name", "vg", "loc", | |||
| "dit", "noa", "nrm", "nlm", "wmc", "rfc", "dac", "fanout", "cbo", "lcom", "nocl" | |||
| }; | |||
| /** reader for stdout */ | |||
| protected InputStream metricsOutput; | |||
| /** | |||
| * this is where the XML output will go, should mostly be a file | |||
| * the caller is responsible for flushing and closing this stream | |||
| @@ -121,7 +121,7 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| /** metrics handler */ | |||
| protected TransformerHandler metricsHandler; | |||
| /** the task */ | |||
| protected Task task; | |||
| @@ -130,7 +130,7 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| * know if we have to close an element or not. | |||
| */ | |||
| protected Stack stack = new Stack(); | |||
| /** initialize this handler */ | |||
| MMetricsStreamHandler(Task task, OutputStream xmlOut){ | |||
| this.task = task; | |||
| @@ -162,7 +162,7 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| metricsHandler.setResult( new StreamResult( new OutputStreamWriter(xmlOutputStream, "UTF-8")) ); | |||
| Transformer transformer = metricsHandler.getTransformer(); | |||
| transformer.setOutputProperty(OutputKeys.INDENT, "yes"); | |||
| // start the document with a 'metrics' root | |||
| metricsHandler.startDocument(); | |||
| AttributesImpl attr = new AttributesImpl(); | |||
| @@ -179,7 +179,7 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| } | |||
| /** | |||
| * Pretty dangerous business here. | |||
| * Pretty dangerous business here. | |||
| */ | |||
| public void stop() { | |||
| try { | |||
| @@ -197,7 +197,7 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| e.printStackTrace(); | |||
| throw new IllegalStateException(e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| /** read each line and process it */ | |||
| protected void parseOutput() throws IOException, SAXException { | |||
| @@ -221,12 +221,12 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| MetricsElement elem = MetricsElement.parse(line); | |||
| startElement(elem); | |||
| } catch (ParseException e) { | |||
| e.printStackTrace(); | |||
| e.printStackTrace(); | |||
| // invalid lines are sent to the output as information, it might be anything, | |||
| task.log(line, Project.MSG_INFO); | |||
| } | |||
| } | |||
| /** | |||
| * Start a new construct. Elements are popped until we are on the same | |||
| * parent node, then the element type is guessed and pushed on the | |||
| @@ -249,7 +249,7 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| } | |||
| } catch (EmptyStackException ignored){} | |||
| } | |||
| // ok, now start the new construct | |||
| String type = getConstructType(elem); | |||
| Attributes attrs = createAttributes(elem); | |||
| @@ -272,7 +272,7 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| if ( elem.isCompilationUnit() ){ | |||
| return FILE; | |||
| } | |||
| // same, we're sure it's a method | |||
| if ( elem.isMethod() ){ | |||
| return METHOD; | |||
| @@ -282,7 +282,7 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| if ( stack.size() == 0 ){ | |||
| return PACKAGE; | |||
| } | |||
| // ok, this is now black magic time, we will guess the type based on | |||
| // the previous type and its indent... | |||
| final ElementEntry previous = (ElementEntry)stack.peek(); | |||
| @@ -299,16 +299,16 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| if ( prevType.equals(CLASS) && indent >= prevIndent ){ | |||
| return CLASS; | |||
| } | |||
| // we assume the other are package | |||
| return PACKAGE; | |||
| } | |||
| } | |||
| /** | |||
| * Create all attributes of a MetricsElement skipping those who have an | |||
| * empty string | |||
| * @param elem | |||
| * @param elem | |||
| */ | |||
| protected Attributes createAttributes(MetricsElement elem){ | |||
| AttributesImpl impl = new AttributesImpl(); | |||
| @@ -325,7 +325,7 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| } | |||
| return impl; | |||
| } | |||
| /** | |||
| * helper class to keep track of elements via its type and indent | |||
| * that's all we need to guess a type. | |||
| @@ -348,35 +348,35 @@ public class MMetricsStreamHandler implements ExecuteStreamHandler { | |||
| class MetricsElement { | |||
| private final static NumberFormat METAMATA_NF; | |||
| private final static NumberFormat NEUTRAL_NF; | |||
| static { | |||
| private final static NumberFormat METAMATA_NF; | |||
| private final static NumberFormat NEUTRAL_NF; | |||
| static { | |||
| METAMATA_NF = NumberFormat.getInstance(); | |||
| METAMATA_NF.setMaximumFractionDigits(1); | |||
| NEUTRAL_NF = NumberFormat.getInstance(); | |||
| if (NEUTRAL_NF instanceof DecimalFormat) { | |||
| ((DecimalFormat) NEUTRAL_NF).applyPattern("###0.###;-###0.###"); | |||
| } | |||
| if (NEUTRAL_NF instanceof DecimalFormat) { | |||
| ((DecimalFormat) NEUTRAL_NF).applyPattern("###0.###;-###0.###"); | |||
| } | |||
| NEUTRAL_NF.setMaximumFractionDigits(1); | |||
| } | |||
| } | |||
| private int indent; | |||
| private String construct; | |||
| private Vector metrics; | |||
| MetricsElement(int indent, String construct, Vector metrics){ | |||
| this.indent = indent; | |||
| this.construct = construct; | |||
| this.metrics = metrics; | |||
| } | |||
| public int getIndent(){ | |||
| return indent; | |||
| } | |||
| public String getName(){ | |||
| return construct; | |||
| } | |||
| @@ -384,38 +384,38 @@ class MetricsElement { | |||
| public Enumeration getMetrics(){ | |||
| return metrics.elements(); | |||
| } | |||
| public boolean isCompilationUnit(){ | |||
| return ( construct.endsWith(".java") || construct.endsWith(".class") ); | |||
| } | |||
| public boolean isMethod(){ | |||
| return ( construct.endsWith("(...)") || construct.endsWith("()") ); | |||
| } | |||
| public static MetricsElement parse(String line) throws ParseException { | |||
| final Vector metrics = new Vector(); | |||
| int pos; | |||
| // i'm using indexOf since I need to know if there are empty strings | |||
| // between tabs and I find it easier than with StringTokenizer | |||
| while ( (pos = line.indexOf('\t')) != -1 ){ | |||
| String token = line.substring(0, pos); | |||
| // only parse what coudl be a valid number. ie not constructs nor no value | |||
| /*if (metrics.size() != 0 || token.length() != 0){ | |||
| Number num = METAMATA_NF.parse(token); // parse with Metamata NF | |||
| token = NEUTRAL_NF.format(num.doubleValue()); // and format with a neutral NF | |||
| }*/ | |||
| Number num = METAMATA_NF.parse(token); // parse with Metamata NF | |||
| token = NEUTRAL_NF.format(num.doubleValue()); // and format with a neutral NF | |||
| }*/ | |||
| metrics.addElement( token ); | |||
| line = line.substring(pos + 1); | |||
| } | |||
| metrics.addElement( line ); | |||
| // there should be exactly 14 tokens (1 name + 13 metrics), if not, there is a problem ! | |||
| if ( metrics.size() != 14 ){ | |||
| throw new ParseException("Could not parse the following line as a metrics: -->" + line +"<--", -1); | |||
| } | |||
| // remove the first token it's made of the indentation string and the | |||
| // construct name, we'll need all this to figure out what type of | |||
| // construct it is since we lost all semantics :( | |||
| @@ -68,18 +68,18 @@ import org.apache.tools.ant.BuildException; | |||
| * | |||
| * ToDo: Should call reopen if file is already open in one of our changelists perhaps? | |||
| */ | |||
| public class P4Edit extends P4Base { | |||
| public String change = null; | |||
| public void setChange(String change) { | |||
| this.change = change; | |||
| } | |||
| public void execute() throws BuildException { | |||
| if(change != null ) P4CmdOpts = "-c "+change; | |||
| if(P4View == null) throw new BuildException("No view specified to edit"); | |||
| execP4Command("-s edit "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this)); | |||
| } | |||
| public String change = null; | |||
| public void setChange(String change) { | |||
| this.change = change; | |||
| } | |||
| public void execute() throws BuildException { | |||
| if(change != null ) P4CmdOpts = "-c "+change; | |||
| if(P4View == null) throw new BuildException("No view specified to edit"); | |||
| execP4Command("-s edit "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this)); | |||
| } | |||
| } | |||
| @@ -78,7 +78,7 @@ public abstract class P4HandlerAdapter implements P4Handler { | |||
| public void start() throws BuildException { | |||
| try{ | |||
| //First write any output to P4 | |||
| //First write any output to P4 | |||
| if(p4input != null && p4input.length() >0 && os != null) { | |||
| os.write(p4input.getBytes()); | |||
| os.flush(); | |||
| @@ -86,17 +86,17 @@ public abstract class P4HandlerAdapter implements P4Handler { | |||
| } | |||
| //Now read any input and process | |||
| BufferedReader input = new BufferedReader( | |||
| new InputStreamReader( | |||
| new SequenceInputStream(is,es))); | |||
| String line; | |||
| while((line = input.readLine()) != null) { | |||
| process(line); | |||
| } | |||
| input.close(); | |||
| while((line = input.readLine()) != null) { | |||
| process(line); | |||
| } | |||
| input.close(); | |||
| }catch(Exception e) { | |||
| @@ -72,7 +72,7 @@ import java.text.SimpleDateFormat; | |||
| * | |||
| * Label name defaults to AntLabel if none set. | |||
| * | |||
| * Example Usage: | |||
| * Example Usage: | |||
| * <pre> | |||
| * <P4Label name="MyLabel-${TSTAMP}-${DSTAMP}" desc="Auto Build Label" /> | |||
| * </pre> | |||
| @@ -84,46 +84,46 @@ public class P4Label extends P4Base { | |||
| protected String name; | |||
| protected String desc; | |||
| protected String lock; | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| public void setDesc(String desc) { | |||
| this.desc = desc; | |||
| } | |||
| public void setLock(String lock) { | |||
| this.lock = lock; | |||
| } | |||
| public void setLock(String lock) { | |||
| this.lock = lock; | |||
| } | |||
| public void execute() throws BuildException { | |||
| log("P4Label exec:",Project.MSG_INFO); | |||
| if(P4View == null || P4View.length() < 1) { | |||
| log("View not set, assuming //depot/...", Project.MSG_WARN); | |||
| P4View = "//depot/..."; | |||
| } | |||
| if(desc == null || desc.length() < 1) { | |||
| log("Label Description not set, assuming 'AntLabel'", Project.MSG_WARN); | |||
| desc = "AntLabel"; | |||
| } | |||
| if(lock != null && !lock.equalsIgnoreCase("locked")) { | |||
| log("lock attribute invalid - ignoring",Project.MSG_WARN); | |||
| } | |||
| if(lock != null && !lock.equalsIgnoreCase("locked")) { | |||
| log("lock attribute invalid - ignoring",Project.MSG_WARN); | |||
| } | |||
| if(name == null || name.length() < 1) { | |||
| SimpleDateFormat formatter = new SimpleDateFormat ("yyyy.MM.dd-hh:mm"); | |||
| Date now = new Date(); | |||
| name = "AntLabel-"+formatter.format(now); | |||
| log("name not set, assuming '"+name+"'", Project.MSG_WARN); | |||
| } | |||
| //We have to create a unlocked label first | |||
| String newLabel = | |||
| String newLabel = | |||
| "Label: "+name+"\n"+ | |||
| "Description: "+desc+"\n"+ | |||
| "Options: unlocked\n"+ | |||
| @@ -138,56 +138,56 @@ public class P4Label extends P4Base { | |||
| handler.setOutput(newLabel); | |||
| execP4Command("label -i", handler); | |||
| execP4Command("labelsync -l "+name, new P4HandlerAdapter() { | |||
| public void process(String line) { | |||
| log(line, Project.MSG_VERBOSE); | |||
| } | |||
| }); | |||
| log("Created Label "+name+" ("+desc+")", Project.MSG_INFO); | |||
| //Now lock if required | |||
| if (lock != null && lock.equalsIgnoreCase("locked")) { | |||
| log("Modifying lock status to 'locked'",Project.MSG_INFO); | |||
| final StringBuffer labelSpec = new StringBuffer(); | |||
| //Read back the label spec from perforce, | |||
| log("Modifying lock status to 'locked'",Project.MSG_INFO); | |||
| final StringBuffer labelSpec = new StringBuffer(); | |||
| //Read back the label spec from perforce, | |||
| //Replace Options | |||
| //Submit back to Perforce | |||
| handler = new P4HandlerAdapter() { | |||
| public void process(String line) { | |||
| log(line, Project.MSG_VERBOSE); | |||
| if(util.match("/^Options:/",line)) { | |||
| line = "Options: "+lock; | |||
| } | |||
| handler = new P4HandlerAdapter() { | |||
| public void process(String line) { | |||
| log(line, Project.MSG_VERBOSE); | |||
| if(util.match("/^Options:/",line)) { | |||
| line = "Options: "+lock; | |||
| } | |||
| labelSpec.append(line+"\n"); | |||
| } | |||
| }; | |||
| execP4Command("label -o "+name, handler); | |||
| } | |||
| }; | |||
| execP4Command("label -o "+name, handler); | |||
| log(labelSpec.toString(),Project.MSG_DEBUG); | |||
| log("Now locking label...",Project.MSG_VERBOSE); | |||
| handler = new P4HandlerAdapter() { | |||
| public void process(String line) { | |||
| log(line, Project.MSG_VERBOSE); | |||
| } | |||
| }; | |||
| handler = new P4HandlerAdapter() { | |||
| public void process(String line) { | |||
| log(line, Project.MSG_VERBOSE); | |||
| } | |||
| }; | |||
| handler.setOutput(labelSpec.toString()); | |||
| execP4Command("label -i", handler); | |||
| execP4Command("label -i", handler); | |||
| } | |||
| } | |||
| } | |||
| @@ -63,8 +63,8 @@ import org.apache.tools.ant.Project; | |||
| /** P4Submit - submit a numbered changelist to Perforce. | |||
| * | |||
| * <B>Note:</B> P4Submit cannot (yet) submit the default changelist. | |||
| * This shouldn't be a problem with the ANT API as the usual flow is | |||
| * <B>Note:</B> P4Submit cannot (yet) submit the default changelist. | |||
| * This shouldn't be a problem with the ANT API as the usual flow is | |||
| * P4Change to create a new numbered change followed by P4Edit then P4Submit. | |||
| * | |||
| * Example Usage:-<br> | |||
| @@ -75,25 +75,27 @@ import org.apache.tools.ant.Project; | |||
| */ | |||
| public class P4Submit extends P4Base { | |||
| //ToDo: If dealing with default cl need to parse out <enter description here> | |||
| //ToDo: If dealing with default cl need to parse out <enter description here> | |||
| public String change; | |||
| public void setChange(String change) { | |||
| this.change = change; | |||
| } | |||
| } | |||
| public void execute() throws BuildException { | |||
| if(change != null) { | |||
| execP4Command("submit -c "+change, new P4HandlerAdapter(){ | |||
| public void process(String line) { | |||
| log(line, Project.MSG_VERBOSE); | |||
| } | |||
| }); | |||
| } else { | |||
| //here we'd parse the output from change -o into submit -i | |||
| //in order to support default change. | |||
| throw new BuildException("No change specified (no support for default change yet...."); | |||
| } | |||
| } | |||
| execP4Command("submit -c "+change, | |||
| new P4HandlerAdapter() { | |||
| public void process(String line) { | |||
| log(line, Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| ); | |||
| } else { | |||
| //here we'd parse the output from change -o into submit -i | |||
| //in order to support default change. | |||
| throw new BuildException("No change specified (no support for default change yet...."); | |||
| } | |||
| } | |||
| } | |||
| @@ -63,30 +63,30 @@ import org.apache.tools.ant.Project; | |||
| public class SimpleP4OutputHandler extends P4HandlerAdapter { | |||
| P4Base parent; | |||
| public SimpleP4OutputHandler(P4Base parent) { | |||
| this.parent = parent; | |||
| } | |||
| public void process(String line) throws BuildException { | |||
| if(parent.util.match("/^exit/",line)) return; | |||
| P4Base parent; | |||
| public SimpleP4OutputHandler(P4Base parent) { | |||
| this.parent = parent; | |||
| } | |||
| //Throw exception on errors (except up-to-date) | |||
| //p4 -s is unpredicatable. For example a server down | |||
| //does not return error: markup | |||
| // | |||
| //Some forms producing commands (p4 -s change -o) do tag the output | |||
| //others don't..... | |||
| //Others mark errors as info, for example edit a file | |||
| //which is already open for edit..... | |||
| //Just look for error: - catches most things.... | |||
| public void process(String line) throws BuildException { | |||
| if(parent.util.match("/^exit/",line)) return; | |||
| if(parent.util.match("/error:/", line) && !parent.util.match("/up-to-date/", line)) { | |||
| throw new BuildException(line); | |||
| } | |||
| //Throw exception on errors (except up-to-date) | |||
| //p4 -s is unpredicatable. For example a server down | |||
| //does not return error: markup | |||
| // | |||
| //Some forms producing commands (p4 -s change -o) do tag the output | |||
| //others don't..... | |||
| //Others mark errors as info, for example edit a file | |||
| //which is already open for edit..... | |||
| //Just look for error: - catches most things.... | |||
| parent.log(parent.util.substitute("s/^.*: //",line), Project.MSG_INFO); | |||
| } | |||
| if(parent.util.match("/error:/", line) && !parent.util.match("/up-to-date/", line)) { | |||
| throw new BuildException(line); | |||
| } | |||
| parent.log(parent.util.substitute("s/^.*: //",line), Project.MSG_INFO); | |||
| } | |||
| } | |||
| @@ -409,7 +409,7 @@ public class XMLReport { | |||
| methods.addElement(method); | |||
| log("keeping " + signature); | |||
| } else { | |||
| // log("discarding " + signature); | |||
| // log("discarding " + signature); | |||
| } | |||
| } | |||
| return methods; | |||
| @@ -75,155 +75,155 @@ import java.util.zip.ZipEntry; | |||
| * @author <a href="sbailliez@imediation.com">Stephane Bailliez</a> | |||
| */ | |||
| public class ClassPathLoader { | |||
| public final static FileLoader NULL_LOADER = new NullLoader(); | |||
| /** the list of files to look for */ | |||
| protected File[] files; | |||
| /** | |||
| * create a new instance with a given classpath. It must be urls | |||
| * separated by the platform specific path separator. | |||
| * @param classPath the classpath to load all the classes from. | |||
| */ | |||
| public ClassPathLoader(String classPath){ | |||
| StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator); | |||
| Vector entries = new Vector(); | |||
| while (st.hasMoreTokens()){ | |||
| File file = new File(st.nextToken()); | |||
| entries.addElement(file); | |||
| } | |||
| files = new File[entries.size()]; | |||
| entries.copyInto(files); | |||
| } | |||
| /** | |||
| * create a new instance with a given set of urls. | |||
| * @param entries valid file urls (either .jar, .zip or directory) | |||
| */ | |||
| public ClassPathLoader(String[] entries){ | |||
| files = new File[entries.length]; | |||
| for (int i = 0; i < entries.length; i++){ | |||
| files[i] = new File(entries[i]); | |||
| } | |||
| } | |||
| /** | |||
| * create a new instance with a given set of urls | |||
| * @param entries file urls to look for classes (.jar, .zip or directory) | |||
| */ | |||
| public ClassPathLoader(File[] entries){ | |||
| files = entries; | |||
| } | |||
| /** the interface to implement to look up for specific resources */ | |||
| public interface FileLoader { | |||
| /** the file url that is looked for .class files */ | |||
| public File getFile(); | |||
| /** return the set of classes found in the file */ | |||
| public ClassFile[] getClasses() throws IOException; | |||
| } | |||
| /** | |||
| * @return the set of <tt>FileLoader</tt> loaders matching the given classpath. | |||
| */ | |||
| public Enumeration loaders(){ | |||
| return new LoaderEnumeration(); | |||
| } | |||
| /** | |||
| * return the whole set of classes in the classpath. Note that this method | |||
| * can be very resource demanding since it must load all bytecode from | |||
| * all classes in all resources in the classpath at a time. | |||
| * To process it in a less resource demanding way, it is maybe better to | |||
| * use the <tt>loaders()</tt> that will return loader one by one. | |||
| * | |||
| * @return the hashtable containing ALL classes that are found in the given | |||
| * classpath. Note that the first entry of a given classname will shadow | |||
| * classes with the same name (as a classloader does) | |||
| */ | |||
| public Hashtable getClasses() throws IOException { | |||
| Hashtable map = new Hashtable(); | |||
| Enumeration enum = loaders(); | |||
| while ( enum.hasMoreElements() ){ | |||
| FileLoader loader = (FileLoader)enum.nextElement(); | |||
| System.out.println("Processing " + loader.getFile()); | |||
| long t0 = System.currentTimeMillis(); | |||
| ClassFile[] classes = loader.getClasses(); | |||
| long dt = System.currentTimeMillis() - t0; | |||
| System.out.println("" + classes.length + " classes loaded in " + dt + "ms"); | |||
| for (int j = 0; j < classes.length; j++){ | |||
| String name = classes[j].getFullName(); | |||
| // do not allow duplicates entries to preserve 'classpath' behavior | |||
| // first class in wins | |||
| if ( !map.containsKey(name) ){ | |||
| map.put(name, classes[j]); | |||
| } | |||
| } | |||
| } | |||
| return map; | |||
| } | |||
| /** the loader enumeration that will return loaders */ | |||
| protected class LoaderEnumeration implements Enumeration { | |||
| protected int index = 0; | |||
| public boolean hasMoreElements(){ | |||
| return index < files.length; | |||
| } | |||
| public Object nextElement(){ | |||
| if (index >= files.length){ | |||
| throw new NoSuchElementException(); | |||
| } | |||
| File file = files[index++]; | |||
| if ( !file.exists() ){ | |||
| return new NullLoader(file); | |||
| } | |||
| if ( file.isDirectory() ){ | |||
| // it's a directory | |||
| return new DirectoryLoader(file); | |||
| } else if ( file.getName().endsWith(".zip") || file.getName().endsWith(".jar") ){ | |||
| // it's a jar/zip file | |||
| return new JarLoader(file); | |||
| } | |||
| return new NullLoader(file); | |||
| } | |||
| } | |||
| /** | |||
| * useful methods to read the whole input stream in memory so that | |||
| * it can be accessed faster. Processing rt.jar and tools.jar from JDK 1.3.1 | |||
| * brings time from 50s to 7s. | |||
| */ | |||
| public final static FileLoader NULL_LOADER = new NullLoader(); | |||
| /** the list of files to look for */ | |||
| protected File[] files; | |||
| /** | |||
| * create a new instance with a given classpath. It must be urls | |||
| * separated by the platform specific path separator. | |||
| * @param classPath the classpath to load all the classes from. | |||
| */ | |||
| public ClassPathLoader(String classPath){ | |||
| StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator); | |||
| Vector entries = new Vector(); | |||
| while (st.hasMoreTokens()){ | |||
| File file = new File(st.nextToken()); | |||
| entries.addElement(file); | |||
| } | |||
| files = new File[entries.size()]; | |||
| entries.copyInto(files); | |||
| } | |||
| /** | |||
| * create a new instance with a given set of urls. | |||
| * @param entries valid file urls (either .jar, .zip or directory) | |||
| */ | |||
| public ClassPathLoader(String[] entries){ | |||
| files = new File[entries.length]; | |||
| for (int i = 0; i < entries.length; i++){ | |||
| files[i] = new File(entries[i]); | |||
| } | |||
| } | |||
| /** | |||
| * create a new instance with a given set of urls | |||
| * @param entries file urls to look for classes (.jar, .zip or directory) | |||
| */ | |||
| public ClassPathLoader(File[] entries){ | |||
| files = entries; | |||
| } | |||
| /** the interface to implement to look up for specific resources */ | |||
| public interface FileLoader { | |||
| /** the file url that is looked for .class files */ | |||
| public File getFile(); | |||
| /** return the set of classes found in the file */ | |||
| public ClassFile[] getClasses() throws IOException; | |||
| } | |||
| /** | |||
| * @return the set of <tt>FileLoader</tt> loaders matching the given classpath. | |||
| */ | |||
| public Enumeration loaders(){ | |||
| return new LoaderEnumeration(); | |||
| } | |||
| /** | |||
| * return the whole set of classes in the classpath. Note that this method | |||
| * can be very resource demanding since it must load all bytecode from | |||
| * all classes in all resources in the classpath at a time. | |||
| * To process it in a less resource demanding way, it is maybe better to | |||
| * use the <tt>loaders()</tt> that will return loader one by one. | |||
| * | |||
| * @return the hashtable containing ALL classes that are found in the given | |||
| * classpath. Note that the first entry of a given classname will shadow | |||
| * classes with the same name (as a classloader does) | |||
| */ | |||
| public Hashtable getClasses() throws IOException { | |||
| Hashtable map = new Hashtable(); | |||
| Enumeration enum = loaders(); | |||
| while ( enum.hasMoreElements() ){ | |||
| FileLoader loader = (FileLoader)enum.nextElement(); | |||
| System.out.println("Processing " + loader.getFile()); | |||
| long t0 = System.currentTimeMillis(); | |||
| ClassFile[] classes = loader.getClasses(); | |||
| long dt = System.currentTimeMillis() - t0; | |||
| System.out.println("" + classes.length + " classes loaded in " + dt + "ms"); | |||
| for (int j = 0; j < classes.length; j++){ | |||
| String name = classes[j].getFullName(); | |||
| // do not allow duplicates entries to preserve 'classpath' behavior | |||
| // first class in wins | |||
| if ( !map.containsKey(name) ){ | |||
| map.put(name, classes[j]); | |||
| } | |||
| } | |||
| } | |||
| return map; | |||
| } | |||
| /** the loader enumeration that will return loaders */ | |||
| protected class LoaderEnumeration implements Enumeration { | |||
| protected int index = 0; | |||
| public boolean hasMoreElements(){ | |||
| return index < files.length; | |||
| } | |||
| public Object nextElement(){ | |||
| if (index >= files.length){ | |||
| throw new NoSuchElementException(); | |||
| } | |||
| File file = files[index++]; | |||
| if ( !file.exists() ){ | |||
| return new NullLoader(file); | |||
| } | |||
| if ( file.isDirectory() ){ | |||
| // it's a directory | |||
| return new DirectoryLoader(file); | |||
| } else if ( file.getName().endsWith(".zip") || file.getName().endsWith(".jar") ){ | |||
| // it's a jar/zip file | |||
| return new JarLoader(file); | |||
| } | |||
| return new NullLoader(file); | |||
| } | |||
| } | |||
| /** | |||
| * useful methods to read the whole input stream in memory so that | |||
| * it can be accessed faster. Processing rt.jar and tools.jar from JDK 1.3.1 | |||
| * brings time from 50s to 7s. | |||
| */ | |||
| public static InputStream getCachedStream(InputStream is) throws IOException { | |||
| is = new BufferedInputStream(is); | |||
| byte[] buffer = new byte[8192]; | |||
| ByteArrayOutputStream baos = new ByteArrayOutputStream(2048); | |||
| int n; | |||
| baos.reset(); | |||
| while ((n = is.read(buffer, 0, buffer.length)) != -1) { | |||
| baos.write(buffer, 0, n); | |||
| } | |||
| is.close(); | |||
| return new ByteArrayInputStream(baos.toByteArray()); | |||
| is = new BufferedInputStream(is); | |||
| byte[] buffer = new byte[8192]; | |||
| ByteArrayOutputStream baos = new ByteArrayOutputStream(2048); | |||
| int n; | |||
| baos.reset(); | |||
| while ((n = is.read(buffer, 0, buffer.length)) != -1) { | |||
| baos.write(buffer, 0, n); | |||
| } | |||
| is.close(); | |||
| return new ByteArrayInputStream(baos.toByteArray()); | |||
| } | |||
| } | |||
| /** a null loader to return when the file is not valid */ | |||
| class NullLoader implements ClassPathLoader.FileLoader { | |||
| private File file; | |||
| NullLoader(){ | |||
| this(null); | |||
| } | |||
| NullLoader(File file){ | |||
| this.file = file; | |||
| } | |||
| public File getFile(){ | |||
| return file; | |||
| } | |||
| public ClassFile[] getClasses() throws IOException { | |||
| return new ClassFile[0]; | |||
| } | |||
| private File file; | |||
| NullLoader(){ | |||
| this(null); | |||
| } | |||
| NullLoader(File file){ | |||
| this.file = file; | |||
| } | |||
| public File getFile(){ | |||
| return file; | |||
| } | |||
| public ClassFile[] getClasses() throws IOException { | |||
| return new ClassFile[0]; | |||
| } | |||
| } | |||
| /** | |||
| @@ -232,30 +232,30 @@ class NullLoader implements ClassPathLoader.FileLoader { | |||
| * entry. | |||
| */ | |||
| class JarLoader implements ClassPathLoader.FileLoader { | |||
| private File file; | |||
| JarLoader(File file){ | |||
| this.file = file; | |||
| } | |||
| public File getFile(){ | |||
| return file; | |||
| } | |||
| public ClassFile[] getClasses() throws IOException { | |||
| ZipFile zipFile = new ZipFile(file); | |||
| Vector v = new Vector(); | |||
| Enumeration entries = zipFile.entries(); | |||
| while (entries.hasMoreElements()){ | |||
| ZipEntry entry = (ZipEntry)entries.nextElement(); | |||
| if (entry.getName().endsWith(".class")){ | |||
| InputStream is = ClassPathLoader.getCachedStream(zipFile.getInputStream(entry)); | |||
| ClassFile classFile = new ClassFile(is); | |||
| is.close(); | |||
| v.addElement(classFile); | |||
| } | |||
| } | |||
| ClassFile[] classes = new ClassFile[v.size()]; | |||
| v.copyInto(classes); | |||
| return classes; | |||
| } | |||
| private File file; | |||
| JarLoader(File file){ | |||
| this.file = file; | |||
| } | |||
| public File getFile(){ | |||
| return file; | |||
| } | |||
| public ClassFile[] getClasses() throws IOException { | |||
| ZipFile zipFile = new ZipFile(file); | |||
| Vector v = new Vector(); | |||
| Enumeration entries = zipFile.entries(); | |||
| while (entries.hasMoreElements()){ | |||
| ZipEntry entry = (ZipEntry)entries.nextElement(); | |||
| if (entry.getName().endsWith(".class")){ | |||
| InputStream is = ClassPathLoader.getCachedStream(zipFile.getInputStream(entry)); | |||
| ClassFile classFile = new ClassFile(is); | |||
| is.close(); | |||
| v.addElement(classFile); | |||
| } | |||
| } | |||
| ClassFile[] classes = new ClassFile[v.size()]; | |||
| v.copyInto(classes); | |||
| return classes; | |||
| } | |||
| } | |||
| /** | |||
| @@ -264,93 +264,93 @@ class JarLoader implements ClassPathLoader.FileLoader { | |||
| * match the directory ? | |||
| */ | |||
| class DirectoryLoader implements ClassPathLoader.FileLoader { | |||
| private File directory; | |||
| DirectoryLoader(File dir){ | |||
| directory = dir; | |||
| } | |||
| public File getFile(){ | |||
| return directory; | |||
| } | |||
| public ClassFile[] getClasses() throws IOException { | |||
| Vector v = new Vector(); | |||
| Vector files = listFiles( directory, new ClassFilter(), true); | |||
| for (int i = 0; i < files.size(); i++){ | |||
| File file = (File)files.elementAt(i); | |||
| InputStream is = null; | |||
| try { | |||
| is = ClassPathLoader.getCachedStream(new FileInputStream(file)); | |||
| ClassFile classFile = new ClassFile(is); | |||
| is.close(); | |||
| is = null; | |||
| v.addElement(classFile); | |||
| } finally { | |||
| if (is != null){ | |||
| try { | |||
| is.close(); | |||
| } catch (IOException ignored){} | |||
| } | |||
| } | |||
| } | |||
| ClassFile[] classes = new ClassFile[v.size()]; | |||
| v.copyInto(classes); | |||
| return classes; | |||
| } | |||
| private File directory; | |||
| /** | |||
| * List files that obeys to a specific filter recursively from a given base | |||
| * directory. | |||
| * @param directory the directory where to list the files from. | |||
| * @param filter the file filter to apply | |||
| * @param recurse tells whether or not the listing is recursive. | |||
| * @return the list of <tt>File</tt> objects that applies to the given | |||
| * filter. | |||
| */ | |||
| public static Vector listFiles(File directory, FilenameFilter filter, boolean recurse){ | |||
| if (!directory.isDirectory()){ | |||
| throw new IllegalArgumentException(directory + " is not a directory"); | |||
| } | |||
| Vector list = new Vector(); | |||
| listFilesTo(list, directory, filter, recurse); | |||
| return list; | |||
| } | |||
| DirectoryLoader(File dir){ | |||
| directory = dir; | |||
| } | |||
| public File getFile(){ | |||
| return directory; | |||
| } | |||
| public ClassFile[] getClasses() throws IOException { | |||
| Vector v = new Vector(); | |||
| Vector files = listFiles( directory, new ClassFilter(), true); | |||
| for (int i = 0; i < files.size(); i++){ | |||
| File file = (File)files.elementAt(i); | |||
| InputStream is = null; | |||
| try { | |||
| is = ClassPathLoader.getCachedStream(new FileInputStream(file)); | |||
| ClassFile classFile = new ClassFile(is); | |||
| is.close(); | |||
| is = null; | |||
| v.addElement(classFile); | |||
| } finally { | |||
| if (is != null){ | |||
| try { | |||
| is.close(); | |||
| } catch (IOException ignored){} | |||
| } | |||
| } | |||
| } | |||
| ClassFile[] classes = new ClassFile[v.size()]; | |||
| v.copyInto(classes); | |||
| return classes; | |||
| } | |||
| /** | |||
| * List files that obeys to a specific filter recursively from a given base | |||
| * directory. | |||
| * @param directory the directory where to list the files from. | |||
| * @param filter the file filter to apply | |||
| * @param recurse tells whether or not the listing is recursive. | |||
| * @return the list of <tt>File</tt> objects that applies to the given | |||
| * filter. | |||
| */ | |||
| public static Vector listFiles(File directory, FilenameFilter filter, boolean recurse){ | |||
| if (!directory.isDirectory()){ | |||
| throw new IllegalArgumentException(directory + " is not a directory"); | |||
| } | |||
| Vector list = new Vector(); | |||
| listFilesTo(list, directory, filter, recurse); | |||
| return list; | |||
| } | |||
| /** | |||
| * List and add files to a given list. As a convenience it sends back the | |||
| * instance of the list given as a parameter. | |||
| * @param list the list of files where the filtered files should be added | |||
| * @param directory the directory where to list the files from. | |||
| * @param filter the file filter to apply | |||
| * @param recurse tells whether or not the listing is recursive. | |||
| * @return the list instance that was passed as the <tt>list</tt> argument. | |||
| */ | |||
| private static Vector listFilesTo(Vector list, File directory, FilenameFilter filter, boolean recurse){ | |||
| String[] files = directory.list(filter); | |||
| for (int i = 0; i < files.length; i++){ | |||
| list.addElement( new File(directory, files[i]) ); | |||
| } | |||
| files = null; // we don't need it anymore | |||
| if (recurse){ | |||
| String[] subdirs = directory.list( new DirectoryFilter() ); | |||
| for (int i = 0; i < subdirs.length; i++){ | |||
| listFilesTo(list, new File(directory, subdirs[i]), filter, recurse); | |||
| } | |||
| } | |||
| return list; | |||
| } | |||
| /** | |||
| * List and add files to a given list. As a convenience it sends back the | |||
| * instance of the list given as a parameter. | |||
| * @param list the list of files where the filtered files should be added | |||
| * @param directory the directory where to list the files from. | |||
| * @param filter the file filter to apply | |||
| * @param recurse tells whether or not the listing is recursive. | |||
| * @return the list instance that was passed as the <tt>list</tt> argument. | |||
| */ | |||
| private static Vector listFilesTo(Vector list, File directory, FilenameFilter filter, boolean recurse){ | |||
| String[] files = directory.list(filter); | |||
| for (int i = 0; i < files.length; i++){ | |||
| list.addElement( new File(directory, files[i]) ); | |||
| } | |||
| files = null; // we don't need it anymore | |||
| if (recurse){ | |||
| String[] subdirs = directory.list( new DirectoryFilter() ); | |||
| for (int i = 0; i < subdirs.length; i++){ | |||
| listFilesTo(list, new File(directory, subdirs[i]), filter, recurse); | |||
| } | |||
| } | |||
| return list; | |||
| } | |||
| } | |||
| /** Convenient filter that accepts only directory <tt>File</tt> */ | |||
| class DirectoryFilter implements FilenameFilter { | |||
| public boolean accept(File directory, String name){ | |||
| File pathname = new File(directory, name); | |||
| return pathname.isDirectory(); | |||
| } | |||
| public boolean accept(File directory, String name){ | |||
| File pathname = new File(directory, name); | |||
| return pathname.isDirectory(); | |||
| } | |||
| } | |||
| /** convenient filter to accept only .class files */ | |||
| class ClassFilter implements FilenameFilter { | |||
| public boolean accept(File dir, String name){ | |||
| return name.endsWith(".class"); | |||
| } | |||
| public boolean accept(File dir, String name){ | |||
| return name.endsWith(".class"); | |||
| } | |||
| } | |||
| @@ -64,320 +64,320 @@ import java.util.Vector; | |||
| * @author <a href="sbailliez@imediation.com">Stephane Bailliez</a> | |||
| */ | |||
| public class Utils { | |||
| /** public access flag */ | |||
| /** public access flag */ | |||
| public final static short ACC_PUBLIC = 1; | |||
| /** private access flag */ | |||
| /** private access flag */ | |||
| public final static short ACC_PRIVATE = 2; | |||
| /** protected access flag */ | |||
| /** protected access flag */ | |||
| public final static short ACC_PROTECTED = 4; | |||
| /** static access flag */ | |||
| /** static access flag */ | |||
| public final static short ACC_STATIC = 8; | |||
| /** final access flag */ | |||
| /** final access flag */ | |||
| public final static short ACC_FINAL = 16; | |||
| /** super access flag */ | |||
| /** super access flag */ | |||
| public final static short ACC_SUPER = 32; | |||
| /** synchronized access flag */ | |||
| /** synchronized access flag */ | |||
| public final static short ACC_SYNCHRONIZED = 32; | |||
| /** volatile access flag */ | |||
| /** volatile access flag */ | |||
| public final static short ACC_VOLATILE = 64; | |||
| /** transient access flag */ | |||
| /** transient access flag */ | |||
| public final static short ACC_TRANSIENT = 128; | |||
| /** native access flag */ | |||
| /** native access flag */ | |||
| public final static short ACC_NATIVE = 256; | |||
| /** interface access flag */ | |||
| /** interface access flag */ | |||
| public final static short ACC_INTERFACE = 512; | |||
| /** abstract access flag */ | |||
| /** abstract access flag */ | |||
| public final static short ACC_ABSTRACT = 1024; | |||
| /** strict access flag */ | |||
| /** strict access flag */ | |||
| public final static short ACC_STRICT = 2048; | |||
| /** private constructor */ | |||
| private Utils(){ | |||
| } | |||
| /** | |||
| * return an UTF8 value from the pool located a a specific index. | |||
| * @param pool the constant pool to look at | |||
| * @param index index of the UTF8 value in the constant pool | |||
| * @return the value of the string if it exists | |||
| * @throws ClassCastException if the index is not an UTF8 constant. | |||
| */ | |||
| public static String getUTF8Value(ConstantPool pool, int index){ | |||
| return ((Utf8CPInfo)pool.getEntry(index)).getValue(); | |||
| } | |||
| /** | |||
| * parse all parameters from a descritor into fields of java name. | |||
| * @param descriptor of a method. | |||
| * @return the parameter list of a given method descriptor. Each string | |||
| * represent a java object with its fully qualified classname or the | |||
| * primitive name such as int, long, ... | |||
| */ | |||
| public static String[] getMethodParams(String descriptor){ | |||
| int i = 0; | |||
| if (descriptor.charAt(i) != '('){ | |||
| throw new IllegalArgumentException("Method descriptor should start with a '('"); | |||
| } | |||
| Vector params = new Vector(); | |||
| StringBuffer param = new StringBuffer(); | |||
| /** private constructor */ | |||
| private Utils(){ | |||
| } | |||
| /** | |||
| * return an UTF8 value from the pool located a a specific index. | |||
| * @param pool the constant pool to look at | |||
| * @param index index of the UTF8 value in the constant pool | |||
| * @return the value of the string if it exists | |||
| * @throws ClassCastException if the index is not an UTF8 constant. | |||
| */ | |||
| public static String getUTF8Value(ConstantPool pool, int index){ | |||
| return ((Utf8CPInfo)pool.getEntry(index)).getValue(); | |||
| } | |||
| /** | |||
| * parse all parameters from a descritor into fields of java name. | |||
| * @param descriptor of a method. | |||
| * @return the parameter list of a given method descriptor. Each string | |||
| * represent a java object with its fully qualified classname or the | |||
| * primitive name such as int, long, ... | |||
| */ | |||
| public static String[] getMethodParams(String descriptor){ | |||
| int i = 0; | |||
| if (descriptor.charAt(i) != '('){ | |||
| throw new IllegalArgumentException("Method descriptor should start with a '('"); | |||
| } | |||
| Vector params = new Vector(); | |||
| StringBuffer param = new StringBuffer(); | |||
| i++; | |||
| while ( (i = descriptor2java(descriptor, i, param)) < descriptor.length() ){ | |||
| params.add(param.toString()); | |||
| param.setLength(0); // reset | |||
| if (descriptor.charAt(i) == ')'){ | |||
| i++; | |||
| break; | |||
| } | |||
| } | |||
| String[] array = new String[params.size()]; | |||
| params.copyInto(array); | |||
| return array; | |||
| } | |||
| /** | |||
| * return the object type of a return type. | |||
| * @param descriptor | |||
| * @return get the return type objet of a given descriptor | |||
| */ | |||
| public static String getMethodReturnType(String descriptor){ | |||
| int pos = descriptor.indexOf(')'); | |||
| StringBuffer rettype = new StringBuffer(); | |||
| descriptor2java(descriptor, pos + 1, rettype); | |||
| return rettype.toString(); | |||
| params.add(param.toString()); | |||
| param.setLength(0); // reset | |||
| if (descriptor.charAt(i) == ')'){ | |||
| i++; | |||
| break; | |||
| } | |||
| } | |||
| String[] array = new String[params.size()]; | |||
| params.copyInto(array); | |||
| return array; | |||
| } | |||
| /** | |||
| * Parse a single descriptor symbol and returns it java equivalent. | |||
| * @param descriptor the descriptor symbol. | |||
| * @param i the index to look at the symbol in the descriptor string | |||
| * @param sb the stringbuffer to return the java equivalent of the symbol | |||
| * @return the index after the descriptor symbol | |||
| */ | |||
| public static int descriptor2java(String descriptor, int i, StringBuffer sb){ | |||
| // get the dimension | |||
| StringBuffer dim = new StringBuffer(); | |||
| for (;descriptor.charAt(i) == '['; i++){ | |||
| dim.append("[]"); | |||
| } | |||
| // now get the type | |||
| switch (descriptor.charAt(i)){ | |||
| case 'B': sb.append("byte"); break; | |||
| case 'C': sb.append("char"); break; | |||
| case 'D': sb.append("double"); break; | |||
| case 'F': sb.append("float"); break; | |||
| case 'I': sb.append("int"); break; | |||
| case 'J': sb.append("long"); break; | |||
| case 'S': sb.append("short"); break; | |||
| case 'Z': sb.append("boolean"); break; | |||
| case 'V': sb.append("void"); break; | |||
| case 'L': | |||
| // it is a class | |||
| int pos = descriptor.indexOf(';', i + 1); | |||
| String classname = descriptor.substring(i + 1, pos).replace('/', '.'); | |||
| sb.append(classname); | |||
| i = pos; | |||
| break; | |||
| default: | |||
| //@todo, yeah this happens because I got things like: | |||
| // ()Ljava/lang/Object; and it will return and ) will be here | |||
| // think about it. | |||
| //ooooops should never happen | |||
| //throw new IllegalArgumentException("Invalid descriptor symbol: '" + i + "' in '" + descriptor + "'"); | |||
| } | |||
| sb.append(dim.toString()); | |||
| return ++i; | |||
| } | |||
| /** | |||
| * check for abstract access | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * return the object type of a return type. | |||
| * @param descriptor | |||
| * @return get the return type objet of a given descriptor | |||
| */ | |||
| public static String getMethodReturnType(String descriptor){ | |||
| int pos = descriptor.indexOf(')'); | |||
| StringBuffer rettype = new StringBuffer(); | |||
| descriptor2java(descriptor, pos + 1, rettype); | |||
| return rettype.toString(); | |||
| } | |||
| /** | |||
| * Parse a single descriptor symbol and returns it java equivalent. | |||
| * @param descriptor the descriptor symbol. | |||
| * @param i the index to look at the symbol in the descriptor string | |||
| * @param sb the stringbuffer to return the java equivalent of the symbol | |||
| * @return the index after the descriptor symbol | |||
| */ | |||
| public static int descriptor2java(String descriptor, int i, StringBuffer sb){ | |||
| // get the dimension | |||
| StringBuffer dim = new StringBuffer(); | |||
| for (;descriptor.charAt(i) == '['; i++){ | |||
| dim.append("[]"); | |||
| } | |||
| // now get the type | |||
| switch (descriptor.charAt(i)){ | |||
| case 'B': sb.append("byte"); break; | |||
| case 'C': sb.append("char"); break; | |||
| case 'D': sb.append("double"); break; | |||
| case 'F': sb.append("float"); break; | |||
| case 'I': sb.append("int"); break; | |||
| case 'J': sb.append("long"); break; | |||
| case 'S': sb.append("short"); break; | |||
| case 'Z': sb.append("boolean"); break; | |||
| case 'V': sb.append("void"); break; | |||
| case 'L': | |||
| // it is a class | |||
| int pos = descriptor.indexOf(';', i + 1); | |||
| String classname = descriptor.substring(i + 1, pos).replace('/', '.'); | |||
| sb.append(classname); | |||
| i = pos; | |||
| break; | |||
| default: | |||
| //@todo, yeah this happens because I got things like: | |||
| // ()Ljava/lang/Object; and it will return and ) will be here | |||
| // think about it. | |||
| //ooooops should never happen | |||
| //throw new IllegalArgumentException("Invalid descriptor symbol: '" + i + "' in '" + descriptor + "'"); | |||
| } | |||
| sb.append(dim.toString()); | |||
| return ++i; | |||
| } | |||
| /** | |||
| * check for abstract access | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isAbstract(int access_flags) { | |||
| return (access_flags & ACC_ABSTRACT) != 0; | |||
| } | |||
| /** | |||
| * check for public access | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for public access | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isPublic(int access_flags) { | |||
| return (access_flags & ACC_PUBLIC) != 0; | |||
| } | |||
| /** | |||
| * check for a static access | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for a static access | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isStatic(int access_flags) { | |||
| return (access_flags & ACC_STATIC) != 0; | |||
| } | |||
| /** | |||
| * check for native access | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for native access | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isNative(int access_flags) { | |||
| return (access_flags & ACC_NATIVE) != 0; | |||
| } | |||
| /** | |||
| * check for class access | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for class access | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isClass(int access_flags) { | |||
| return !isInterface(access_flags); | |||
| } | |||
| /** | |||
| * check for strict access | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for strict access | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isStrict(int access_flags) { | |||
| return (access_flags & ACC_STRICT) != 0; | |||
| } | |||
| /** | |||
| * check for interface access | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for interface access | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isInterface(int access_flags) { | |||
| return (access_flags & ACC_INTERFACE) != 0; | |||
| } | |||
| /** | |||
| * check for private access | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for private access | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isPrivate(int access_flags) { | |||
| return (access_flags & ACC_PRIVATE) != 0; | |||
| } | |||
| /** | |||
| * check for transient flag | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for transient flag | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isTransient(int access_flags) { | |||
| return (access_flags & ACC_TRANSIENT) != 0; | |||
| } | |||
| /** | |||
| * check for volatile flag | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for volatile flag | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isVolatile(int access_flags){ | |||
| return (access_flags & ACC_VOLATILE) != 0; | |||
| } | |||
| /** | |||
| * check for super flag | |||
| * @param access_flags access flag | |||
| */ | |||
| /** | |||
| * check for super flag | |||
| * @param access_flags access flag | |||
| */ | |||
| public static boolean isSuper(int access_flags) { | |||
| return (access_flags & ACC_SUPER) != 0; | |||
| } | |||
| /** | |||
| * check for protected flag | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for protected flag | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isProtected(int access_flags) { | |||
| return (access_flags & ACC_PROTECTED) != 0; | |||
| } | |||
| /** | |||
| * chck for final flag | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * chck for final flag | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isFinal(int access_flags) { | |||
| return (access_flags & ACC_FINAL) != 0; | |||
| } | |||
| /** | |||
| * check for synchronized flag | |||
| * @param access_flags access flags | |||
| */ | |||
| /** | |||
| * check for synchronized flag | |||
| * @param access_flags access flags | |||
| */ | |||
| public static boolean isSynchronized(int access_flags) { | |||
| return (access_flags & ACC_SYNCHRONIZED) != 0; | |||
| } | |||
| /** | |||
| * return the method access flag as java modifiers | |||
| * @param access_flags access flags | |||
| * @return the access flags as modifier strings | |||
| */ | |||
| /** | |||
| * return the method access flag as java modifiers | |||
| * @param access_flags access flags | |||
| * @return the access flags as modifier strings | |||
| */ | |||
| public static String getMethodAccess(int access_flags) { | |||
| StringBuffer sb = new StringBuffer(); | |||
| if(isPublic(access_flags)){ | |||
| sb.append("public "); | |||
| } else if(isPrivate(access_flags)){ | |||
| } else if(isPrivate(access_flags)){ | |||
| sb.append("private "); | |||
| } else if(isProtected(access_flags)){ | |||
| } else if(isProtected(access_flags)){ | |||
| sb.append("protected "); | |||
| } | |||
| if(isFinal(access_flags)){ | |||
| } | |||
| if(isFinal(access_flags)){ | |||
| sb.append("final "); | |||
| } | |||
| } | |||
| if(isStatic(access_flags)){ | |||
| sb.append("static "); | |||
| } | |||
| } | |||
| if(isSynchronized(access_flags)){ | |||
| sb.append("synchronized "); | |||
| } | |||
| } | |||
| if(isNative(access_flags)){ | |||
| sb.append("native "); | |||
| } | |||
| } | |||
| if(isAbstract(access_flags)){ | |||
| sb.append("abstract "); | |||
| } | |||
| } | |||
| return sb.toString().trim(); | |||
| } | |||
| /** | |||
| * return the field access flag as java modifiers | |||
| * @param access_flags access flags | |||
| * @return the access flags as modifier strings | |||
| */ | |||
| /** | |||
| * return the field access flag as java modifiers | |||
| * @param access_flags access flags | |||
| * @return the access flags as modifier strings | |||
| */ | |||
| public static String getFieldAccess(int access_flags) { | |||
| StringBuffer sb = new StringBuffer(); | |||
| if(isPublic(access_flags)){ | |||
| sb.append("public "); | |||
| } else if(isPrivate(access_flags)){ | |||
| } else if(isPrivate(access_flags)){ | |||
| sb.append("private "); | |||
| } else if (isProtected(access_flags)){ | |||
| } else if (isProtected(access_flags)){ | |||
| sb.append("protected "); | |||
| } | |||
| } | |||
| if(isFinal(access_flags)){ | |||
| sb.append("final "); | |||
| } | |||
| } | |||
| if(isStatic(access_flags)){ | |||
| sb.append("static "); | |||
| } | |||
| } | |||
| if(isVolatile(access_flags)){ | |||
| sb.append("volatile "); | |||
| } | |||
| } | |||
| if(isTransient(access_flags)){ | |||
| sb.append("transient "); | |||
| } | |||
| } | |||
| return sb.toString().trim(); | |||
| } | |||
| /** | |||
| * return the class access flag as java modifiers | |||
| * @param access_flags access flags | |||
| * @return the access flags as modifier strings | |||
| */ | |||
| /** | |||
| * return the class access flag as java modifiers | |||
| * @param access_flags access flags | |||
| * @return the access flags as modifier strings | |||
| */ | |||
| public static String getClassAccess(int access_flags) { | |||
| StringBuffer sb = new StringBuffer(); | |||
| if(isPublic(access_flags)){ | |||
| sb.append("public "); | |||
| } else if (isProtected(access_flags)){ | |||
| sb.append("protected "); | |||
| } else if (isPrivate(access_flags)){ | |||
| sb.append("private "); | |||
| } | |||
| if(isFinal(access_flags)){ | |||
| } else if (isProtected(access_flags)){ | |||
| sb.append("protected "); | |||
| } else if (isPrivate(access_flags)){ | |||
| sb.append("private "); | |||
| } | |||
| if(isFinal(access_flags)){ | |||
| sb.append("final "); | |||
| } | |||
| } | |||
| if(isSuper(access_flags)){ | |||
| sb.append("/*super*/ "); | |||
| } | |||
| } | |||
| if(isInterface(access_flags)){ | |||
| sb.append("interface "); | |||
| } | |||
| } | |||
| if(isAbstract(access_flags)){ | |||
| sb.append("abstract "); | |||
| } | |||
| } | |||
| if(isClass(access_flags)){ | |||
| sb.append("class "); | |||
| } | |||
| } | |||
| return sb.toString().trim(); | |||
| } | |||
| } | |||
| @@ -137,32 +137,32 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| AudioInputStream audioInputStream = null; | |||
| try { | |||
| audioInputStream = AudioSystem.getAudioInputStream(file); | |||
| } | |||
| catch (UnsupportedAudioFileException uafe) { | |||
| project.log("Audio format is not yet supported: "+uafe.getMessage()); | |||
| } | |||
| try { | |||
| audioInputStream = AudioSystem.getAudioInputStream(file); | |||
| } | |||
| catch (UnsupportedAudioFileException uafe) { | |||
| project.log("Audio format is not yet supported: "+uafe.getMessage()); | |||
| } | |||
| catch (IOException ioe) { | |||
| ioe.printStackTrace(); | |||
| } | |||
| if (audioInputStream != null) { | |||
| AudioFormat format = audioInputStream.getFormat(); | |||
| DataLine.Info info = new DataLine.Info(Clip.class, format, | |||
| if (audioInputStream != null) { | |||
| AudioFormat format = audioInputStream.getFormat(); | |||
| DataLine.Info info = new DataLine.Info(Clip.class, format, | |||
| AudioSystem.NOT_SPECIFIED); | |||
| try { | |||
| audioClip = (Clip) AudioSystem.getLine(info); | |||
| audioClip.addLineListener(this); | |||
| try { | |||
| audioClip = (Clip) AudioSystem.getLine(info); | |||
| audioClip.addLineListener(this); | |||
| audioClip.open(audioInputStream); | |||
| } | |||
| catch (LineUnavailableException e) { | |||
| } | |||
| catch (LineUnavailableException e) { | |||
| project.log("The sound device is currently unavailable"); | |||
| return; | |||
| } | |||
| catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| if (duration != null) { | |||
| playClip(audioClip, duration.longValue()); | |||
| @@ -171,10 +171,10 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| } | |||
| audioClip.drain(); | |||
| audioClip.close(); | |||
| } | |||
| else { | |||
| project.log("Can't get data from file " + file.getName()); | |||
| } | |||
| } | |||
| else { | |||
| project.log("Can't get data from file " + file.getName()); | |||
| } | |||
| } | |||
| private void playClip(Clip clip, int loops) { | |||
| @@ -203,16 +203,16 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| if (event.getType().equals(LineEvent.Type.STOP)) { | |||
| Line line = event.getLine(); | |||
| line.close(); | |||
| } | |||
| else if (event.getType().equals(LineEvent.Type.CLOSE)) { | |||
| /* | |||
| * There is a bug in JavaSound 0.90 (jdk1.3beta). | |||
| * It prevents correct termination of the VM. | |||
| * So we have to exit ourselves. | |||
| */ | |||
| //System.exit(0); | |||
| } | |||
| } | |||
| } | |||
| else if (event.getType().equals(LineEvent.Type.CLOSE)) { | |||
| /* | |||
| * There is a bug in JavaSound 0.90 (jdk1.3beta). | |||
| * It prevents correct termination of the VM. | |||
| * So we have to exit ourselves. | |||
| */ | |||
| //System.exit(0); | |||
| } | |||
| } | |||
| /** | |||
| @@ -220,7 +220,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| */ | |||
| public void buildStarted(BuildEvent event){ | |||
| } | |||
| /** | |||
| * Fired after the last target has finished. This event | |||
| * will still be thrown if an error occured during the build. | |||