git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272433 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -128,9 +128,9 @@ public class ProjectHelperImpl extends ProjectHelper { | |||
| */ | |||
| public void parse(Project project, Object source) throws BuildException { | |||
| if (!(source instanceof File)) { | |||
| throw new BuildException( "Only File source supported by default plugin" ); | |||
| throw new BuildException("Only File source supported by default plugin"); | |||
| } | |||
| File buildFile = (File)source; | |||
| File buildFile = (File) source; | |||
| FileInputStream inputStream = null; | |||
| InputSource inputSource = null; | |||
| @@ -193,7 +193,7 @@ public class ProjectHelperImpl extends ProjectHelper { | |||
| exc); | |||
| } catch (IOException exc) { | |||
| throw new BuildException("Error reading project file: " | |||
| +exc.getMessage(), exc); | |||
| + exc.getMessage(), exc); | |||
| } finally { | |||
| if (inputStream != null) { | |||
| try { | |||
| @@ -321,7 +321,7 @@ public class ProjectHelperImpl extends ProjectHelper { | |||
| static class RootHandler extends HandlerBase { | |||
| ProjectHelperImpl helperImpl; | |||
| public RootHandler( ProjectHelperImpl helperImpl ) { | |||
| public RootHandler(ProjectHelperImpl helperImpl) { | |||
| this.helperImpl = helperImpl; | |||
| } | |||
| @@ -876,9 +876,11 @@ public class ProjectHelperImpl extends ProjectHelper { | |||
| public void startElement(String name, AttributeList attrs) throws SAXParseException { | |||
| if (task instanceof TaskContainer) { | |||
| // task can contain other tasks - no other nested elements possible | |||
| new TaskHandler(helperImpl, this, (TaskContainer)task, wrapper, target).init(name, attrs); | |||
| new TaskHandler(helperImpl, this, (TaskContainer) task, | |||
| wrapper, target).init(name, attrs); | |||
| } else { | |||
| new NestedElementHandler(helperImpl, this, task, wrapper, target).init(name, attrs); | |||
| new NestedElementHandler(helperImpl, this, task, | |||
| wrapper, target).init(name, attrs); | |||
| } | |||
| } | |||
| } | |||
| @@ -1027,9 +1029,11 @@ public class ProjectHelperImpl extends ProjectHelper { | |||
| if (child instanceof TaskContainer) { | |||
| // taskcontainer nested element can contain other tasks - no other | |||
| // nested elements possible | |||
| new TaskHandler(helperImpl, this, (TaskContainer)child, childWrapper, target).init(name, attrs); | |||
| new TaskHandler(helperImpl, this, (TaskContainer) child, | |||
| childWrapper, target).init(name, attrs); | |||
| } else { | |||
| new NestedElementHandler(helperImpl, this, child, childWrapper, target).init(name, attrs); | |||
| new NestedElementHandler(helperImpl, this, child, | |||
| childWrapper, target).init(name, attrs); | |||
| } | |||
| } | |||
| } | |||
| @@ -63,12 +63,11 @@ import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * This is a basic task that can be used to track build numbers. | |||
| * | |||
| * It will first attempt to read a build number from a file, then | |||
| * set the property "build.number" to the value that was read in | |||
| * (or 0 if no such value). Then it will increment the build number | |||
| * by one and write it back out into the file. | |||
| * This is a basic task that can be used to track build numbers. It will first | |||
| * attempt to read a build number from a file, then set the property | |||
| * "build.number" to the value that was read in (or 0 if no such value). Then | |||
| * it will increment the build number by one and write it back out into the | |||
| * file. | |||
| * | |||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | |||
| * @version $Revision$ $Date$ | |||
| @@ -76,85 +75,76 @@ import org.apache.tools.ant.util.FileUtils; | |||
| * @ant.task name="buildnumber" | |||
| */ | |||
| public class BuildNumber | |||
| extends Task | |||
| { | |||
| extends Task { | |||
| /** | |||
| * The name of the property in which the build number is stored. | |||
| */ | |||
| private static final String DEFAULT_PROPERTY_NAME = "build.number"; | |||
| /** | |||
| * The default filename to use if no file specified. | |||
| */ | |||
| /** The default filename to use if no file specified. */ | |||
| private static final String DEFAULT_FILENAME = DEFAULT_PROPERTY_NAME; | |||
| /** | |||
| * The File in which the build number is stored. | |||
| */ | |||
| /** The File in which the build number is stored. */ | |||
| private File m_file; | |||
| /** | |||
| * Specify the file in which the build numberis stored. | |||
| * Defaults to "build.number" if not specified. | |||
| * Specify the file in which the build numberis stored. Defaults to | |||
| * "build.number" if not specified. | |||
| * | |||
| * @param file the file in which build number is stored. | |||
| */ | |||
| public void setFile( final File file ) | |||
| { | |||
| public void setFile(final File file) { | |||
| m_file = file; | |||
| } | |||
| /** | |||
| * Run task. | |||
| * | |||
| * @exception BuildException if an error occurs | |||
| */ | |||
| public void execute() | |||
| throws BuildException | |||
| { | |||
| File savedFile = m_file; // may be altered in validate | |||
| throws BuildException { | |||
| File savedFile = m_file;// may be altered in validate | |||
| validate(); | |||
| final Properties properties = loadProperties(); | |||
| final int buildNumber = getBuildNumber( properties ); | |||
| final int buildNumber = getBuildNumber(properties); | |||
| properties.put( DEFAULT_PROPERTY_NAME, | |||
| String.valueOf( buildNumber + 1 ) ); | |||
| properties.put(DEFAULT_PROPERTY_NAME, | |||
| String.valueOf(buildNumber + 1)); | |||
| // Write the properties file back out | |||
| FileOutputStream output = null; | |||
| try | |||
| { | |||
| output = new FileOutputStream( m_file ); | |||
| try { | |||
| output = new FileOutputStream(m_file); | |||
| final String header = "Build Number for ANT. Do not edit!"; | |||
| properties.save( output, header ); | |||
| } | |||
| catch( final IOException ioe ) | |||
| { | |||
| properties.save(output, header); | |||
| } catch (final IOException ioe) { | |||
| final String message = "Error while writing " + m_file; | |||
| throw new BuildException( message, ioe ); | |||
| } | |||
| finally | |||
| { | |||
| if( null != output ) | |||
| { | |||
| try | |||
| { | |||
| throw new BuildException(message, ioe); | |||
| } finally { | |||
| if (null != output) { | |||
| try { | |||
| output.close(); | |||
| } | |||
| catch( final IOException ioe ) | |||
| { | |||
| } catch (final IOException ioe) { | |||
| } | |||
| } | |||
| m_file = savedFile; | |||
| } | |||
| //Finally set the property | |||
| getProject().setNewProperty( DEFAULT_PROPERTY_NAME, | |||
| String.valueOf( buildNumber ) ); | |||
| getProject().setNewProperty(DEFAULT_PROPERTY_NAME, | |||
| String.valueOf(buildNumber)); | |||
| } | |||
| /** | |||
| * Utility method to retrieve build number from properties object. | |||
| * | |||
| @@ -162,25 +152,23 @@ public class BuildNumber | |||
| * @return the build number or if no number in properties object | |||
| * @throws BuildException if build.number property is not an integer | |||
| */ | |||
| private int getBuildNumber( final Properties properties ) | |||
| throws BuildException | |||
| { | |||
| private int getBuildNumber(final Properties properties) | |||
| throws BuildException { | |||
| final String buildNumber = | |||
| properties.getProperty( DEFAULT_PROPERTY_NAME, "0" ).trim(); | |||
| properties.getProperty(DEFAULT_PROPERTY_NAME, "0").trim(); | |||
| // Try parsing the line into an integer. | |||
| try | |||
| { | |||
| return Integer.parseInt( buildNumber ); | |||
| } | |||
| catch( final NumberFormatException nfe ) | |||
| { | |||
| final String message = | |||
| try { | |||
| return Integer.parseInt(buildNumber); | |||
| } catch (final NumberFormatException nfe) { | |||
| final String message = | |||
| m_file + " contains a non integer build number: " + buildNumber; | |||
| throw new BuildException( message , nfe ); | |||
| throw new BuildException(message, nfe); | |||
| } | |||
| } | |||
| /** | |||
| * Utility method to load properties from file. | |||
| * | |||
| @@ -188,72 +176,61 @@ public class BuildNumber | |||
| * @throws BuildException | |||
| */ | |||
| private Properties loadProperties() | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| FileInputStream input = null; | |||
| try | |||
| { | |||
| try { | |||
| final Properties properties = new Properties(); | |||
| input = new FileInputStream( m_file ); | |||
| properties.load( input ); | |||
| input = new FileInputStream(m_file); | |||
| properties.load(input); | |||
| return properties; | |||
| } | |||
| catch( final IOException ioe ) | |||
| { | |||
| throw new BuildException( ioe ); | |||
| } | |||
| finally | |||
| { | |||
| if( null != input ) | |||
| { | |||
| try | |||
| { | |||
| } catch (final IOException ioe) { | |||
| throw new BuildException(ioe); | |||
| } finally { | |||
| if (null != input) { | |||
| try { | |||
| input.close(); | |||
| } | |||
| catch( final IOException ioe ) | |||
| { | |||
| } catch (final IOException ioe) { | |||
| } | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Validate that the task parameters are valid. | |||
| * | |||
| * @throws BuildException if parameters are invalid | |||
| */ | |||
| private void validate() | |||
| throws BuildException | |||
| { | |||
| if( null == m_file ) | |||
| { | |||
| m_file = getProject().resolveFile( DEFAULT_FILENAME ); | |||
| throws BuildException { | |||
| if (null == m_file) { | |||
| m_file = getProject().resolveFile(DEFAULT_FILENAME); | |||
| } | |||
| if( !m_file.exists() ) | |||
| { | |||
| try | |||
| { | |||
| if (!m_file.exists()) { | |||
| try { | |||
| FileUtils.newFileUtils().createNewFile(m_file); | |||
| } | |||
| catch( final IOException ioe ) | |||
| { | |||
| final String message = | |||
| } catch (final IOException ioe) { | |||
| final String message = | |||
| m_file + " doesn't exist and new file can't be created."; | |||
| throw new BuildException( message, ioe ); | |||
| throw new BuildException(message, ioe); | |||
| } | |||
| } | |||
| if( !m_file.canRead() ) | |||
| { | |||
| if (!m_file.canRead()) { | |||
| final String message = "Unable to read from " + m_file + "."; | |||
| throw new BuildException( message ); | |||
| throw new BuildException(message); | |||
| } | |||
| if( !m_file.canWrite() ) | |||
| { | |||
| if (!m_file.canWrite()) { | |||
| final String message = "Unable to write to " + m_file + "."; | |||
| throw new BuildException( message ); | |||
| throw new BuildException(message); | |||
| } | |||
| } | |||
| } | |||
| @@ -227,7 +227,7 @@ public class Concat extends Task { | |||
| try { | |||
| // Iterate the FileSet collection, concatenating each file as | |||
| // it is encountered. | |||
| for (Enumeration e = fileSets.elements(); e.hasMoreElements(); ) { | |||
| for (Enumeration e = fileSets.elements(); e.hasMoreElements();) { | |||
| // Root directory for files. | |||
| File fileSetBase = null; | |||
| @@ -392,17 +392,14 @@ public class Concat extends Task { | |||
| // Log using WARN so it displays in 'quiet' mode. | |||
| out = new PrintWriter( | |||
| new OutputStreamWriter( | |||
| new LogOutputStream(this, Project.MSG_WARN) | |||
| ) | |||
| ); | |||
| new LogOutputStream(this, Project.MSG_WARN))); | |||
| } else { | |||
| out = new PrintWriter( | |||
| new OutputStreamWriter( | |||
| new FileOutputStream(destinationFile | |||
| .getAbsolutePath(), | |||
| append), | |||
| encoding) | |||
| ); | |||
| encoding)); | |||
| // This flag should only be recognized for the first | |||
| // file. In the context of a single 'cat', we always | |||
| @@ -412,11 +409,8 @@ public class Concat extends Task { | |||
| for (int i = 0; i < len; i++) { | |||
| in = new BufferedReader( | |||
| new InputStreamReader( | |||
| new FileInputStream(input[i]), | |||
| encoding | |||
| ) | |||
| ); | |||
| new InputStreamReader(new FileInputStream(input[i]), | |||
| encoding)); | |||
| String line; | |||
| while ((line = in.readLine()) != null) { | |||
| @@ -480,9 +474,7 @@ public class Concat extends Task { | |||
| // Reads the text, line by line. | |||
| BufferedReader reader = null; | |||
| try { | |||
| reader = new BufferedReader( | |||
| new StringReader(text) | |||
| ); | |||
| reader = new BufferedReader(new StringReader(text)); | |||
| String line; | |||
| while ((line = reader.readLine()) != null) { | |||
| @@ -122,7 +122,7 @@ public final class LoadProperties extends Task { | |||
| try { | |||
| final long len = srcFile.length(); | |||
| final int size=(int) len; | |||
| final int size = (int) len; | |||
| //open up the file | |||
| fis = new FileInputStream(srcFile); | |||
| @@ -184,7 +184,7 @@ public class Manifest extends Task { | |||
| return false; | |||
| } | |||
| Attribute rhsAttribute = (Attribute)rhs; | |||
| Attribute rhsAttribute = (Attribute) rhs; | |||
| return (name != null && rhsAttribute.name != null && | |||
| getKey().equals(rhsAttribute.getKey()) && | |||
| values != null && | |||
| @@ -266,7 +266,7 @@ public class Manifest extends Task { | |||
| String fullValue = ""; | |||
| for (Enumeration e = getValues(); e.hasMoreElements();) { | |||
| String value = (String)e.nextElement(); | |||
| String value = (String) e.nextElement(); | |||
| fullValue += value + " "; | |||
| } | |||
| return fullValue.trim(); | |||
| @@ -301,7 +301,7 @@ public class Manifest extends Task { | |||
| * @param line the continuation line. | |||
| */ | |||
| public void addContinuation(String line) { | |||
| String currentValue = (String)values.elementAt(currentIndex); | |||
| String currentValue = (String) values.elementAt(currentIndex); | |||
| setValue(currentValue + line.substring(1)); | |||
| } | |||
| @@ -314,7 +314,7 @@ public class Manifest extends Task { | |||
| */ | |||
| public void write(PrintWriter writer) throws IOException { | |||
| for (Enumeration e = getValues(); e.hasMoreElements();) { | |||
| writeValue(writer, (String)e.nextElement()); | |||
| writeValue(writer, (String) e.nextElement()); | |||
| } | |||
| } | |||
| @@ -451,14 +451,14 @@ public class Manifest extends Task { | |||
| Enumeration e = section.getAttributeKeys(); | |||
| while (e.hasMoreElements()) { | |||
| String attributeName = (String)e.nextElement(); | |||
| String attributeName = (String) e.nextElement(); | |||
| Attribute attribute = section.getAttribute(attributeName); | |||
| if (attributeName.equals(ATTRIBUTE_CLASSPATH) && | |||
| attributes.containsKey(attributeName)) { | |||
| Attribute ourClassPath = getAttribute(attributeName); | |||
| Enumeration cpe = attribute.getValues(); | |||
| while (cpe.hasMoreElements()) { | |||
| String value = (String)cpe.nextElement(); | |||
| String value = (String) cpe.nextElement(); | |||
| ourClassPath.addValue(value); | |||
| } | |||
| } else { | |||
| @@ -488,7 +488,7 @@ public class Manifest extends Task { | |||
| } | |||
| Enumeration e = getAttributeKeys(); | |||
| while (e.hasMoreElements()) { | |||
| String key = (String)e.nextElement(); | |||
| String key = (String) e.nextElement(); | |||
| Attribute attribute = getAttribute(key); | |||
| attribute.write(writer); | |||
| } | |||
| @@ -504,7 +504,7 @@ public class Manifest extends Task { | |||
| * instances. | |||
| */ | |||
| public Attribute getAttribute(String attributeName) { | |||
| return (Attribute)attributes.get(attributeName.toLowerCase()); | |||
| return (Attribute) attributes.get(attributeName.toLowerCase()); | |||
| } | |||
| /** | |||
| @@ -594,14 +594,14 @@ public class Manifest extends Task { | |||
| String attributeKey = attribute.getKey(); | |||
| if (attributeKey.equals(ATTRIBUTE_CLASSPATH)) { | |||
| Attribute classpathAttribute = | |||
| (Attribute)attributes.get(attributeKey); | |||
| (Attribute) attributes.get(attributeKey); | |||
| if (classpathAttribute == null) { | |||
| storeAttribute(attribute); | |||
| } else { | |||
| Enumeration e = attribute.getValues(); | |||
| while (e.hasMoreElements()) { | |||
| String value = (String)e.nextElement(); | |||
| String value = (String) e.nextElement(); | |||
| classpathAttribute.addValue(value); | |||
| } | |||
| } | |||
| @@ -649,13 +649,13 @@ public class Manifest extends Task { | |||
| return false; | |||
| } | |||
| Section rhsSection = (Section)rhs; | |||
| Section rhsSection = (Section) rhs; | |||
| if (attributes.size() != rhsSection.attributes.size()) { | |||
| return false; | |||
| } | |||
| for (Enumeration e = attributes.keys(); e.hasMoreElements();) { | |||
| String attributeName = (String)e.nextElement(); | |||
| String attributeName = (String) e.nextElement(); | |||
| Object attributeValue = attributes.get(attributeName); | |||
| Object rhsAttributeValue | |||
| = rhsSection.attributes.get(attributeName); | |||
| @@ -843,10 +843,10 @@ public class Manifest extends Task { | |||
| Enumeration e = other.getSectionNames(); | |||
| while (e.hasMoreElements()) { | |||
| String sectionName = (String)e.nextElement(); | |||
| Section ourSection = (Section)sections.get(sectionName); | |||
| String sectionName = (String) e.nextElement(); | |||
| Section ourSection = (Section) sections.get(sectionName); | |||
| Section otherSection | |||
| = (Section)other.sections.get(sectionName); | |||
| = (Section) other.sections.get(sectionName); | |||
| if (ourSection == null) { | |||
| if (otherSection != null) { | |||
| addConfiguredSection(otherSection); | |||
| @@ -889,7 +889,7 @@ public class Manifest extends Task { | |||
| Enumeration e = sectionIndex.elements(); | |||
| while (e.hasMoreElements()) { | |||
| String sectionName = (String)e.nextElement(); | |||
| String sectionName = (String) e.nextElement(); | |||
| Section section = getSection(sectionName); | |||
| section.write(writer); | |||
| } | |||
| @@ -927,7 +927,7 @@ public class Manifest extends Task { | |||
| // create a vector and add in the warnings for all the sections | |||
| Enumeration e = sections.elements(); | |||
| while (e.hasMoreElements()) { | |||
| Section section = (Section)e.nextElement(); | |||
| Section section = (Section) e.nextElement(); | |||
| Enumeration e2 = section.getWarnings(); | |||
| while (e2.hasMoreElements()) { | |||
| warnings.addElement(e2.nextElement()); | |||
| @@ -945,7 +945,7 @@ public class Manifest extends Task { | |||
| return false; | |||
| } | |||
| Manifest rhsManifest = (Manifest)rhs; | |||
| Manifest rhsManifest = (Manifest) rhs; | |||
| if (manifestVersion == null) { | |||
| if (rhsManifest.manifestVersion != null) { | |||
| return false; | |||
| @@ -963,9 +963,9 @@ public class Manifest extends Task { | |||
| Enumeration e = sections.elements(); | |||
| while (e.hasMoreElements()) { | |||
| Section section = (Section)e.nextElement(); | |||
| Section section = (Section) e.nextElement(); | |||
| Section rhsSection | |||
| = (Section)rhsManifest.sections.get(section.getName()); | |||
| = (Section) rhsManifest.sections.get(section.getName()); | |||
| if (!section.equals(rhsSection)) { | |||
| return false; | |||
| } | |||
| @@ -1018,7 +1018,7 @@ public class Manifest extends Task { | |||
| * does not exist in the manifest | |||
| */ | |||
| public Section getSection(String name) { | |||
| return (Section)sections.get(name); | |||
| return (Section) sections.get(name); | |||
| } | |||
| /** | |||
| @@ -99,7 +99,7 @@ public class Parallel extends Task | |||
| int threadNumber = 0; | |||
| for (Enumeration e = nestedTasks.elements(); e.hasMoreElements(); | |||
| threadNumber++) { | |||
| Task nestedTask = (Task)e.nextElement(); | |||
| Task nestedTask = (Task) e.nextElement(); | |||
| threads[threadNumber] = new TaskThread(threadNumber, nestedTask); | |||
| } | |||
| @@ -132,7 +132,7 @@ public class Parallel extends Task | |||
| } | |||
| if (t instanceof BuildException && | |||
| firstLocation == Location.UNKNOWN_LOCATION) { | |||
| firstLocation = ((BuildException)t).getLocation(); | |||
| firstLocation = ((BuildException) t).getLocation(); | |||
| } | |||
| exceptionMessage.append(StringUtils.LINE_SEP); | |||
| exceptionMessage.append(t.getMessage()); | |||
| @@ -141,7 +141,7 @@ public class Parallel extends Task | |||
| if (numExceptions == 1) { | |||
| if (firstException instanceof BuildException) { | |||
| throw (BuildException)firstException; | |||
| throw (BuildException) firstException; | |||
| } | |||
| else { | |||
| throw new BuildException(firstException); | |||
| @@ -88,7 +88,7 @@ public class Patch extends Task { | |||
| */ | |||
| public void setPatchfile(File file) { | |||
| if (!file.exists()) { | |||
| throw new BuildException("patchfile "+file+" doesn\'t exist", | |||
| throw new BuildException("patchfile " + file + " doesn\'t exist", | |||
| location); | |||
| } | |||
| cmd.createArgument().setValue("-i"); | |||
| @@ -124,7 +124,7 @@ public class Patch extends Task { | |||
| if (num < 0) { | |||
| throw new BuildException("strip has to be >= 0", location); | |||
| } | |||
| cmd.createArgument().setValue("-p"+num); | |||
| cmd.createArgument().setValue("-p" + num); | |||
| } | |||
| /** | |||
| @@ -151,7 +151,7 @@ public class Patch extends Task { | |||
| location); | |||
| } | |||
| Commandline toExecute = (Commandline)cmd.clone(); | |||
| Commandline toExecute = (Commandline) cmd.clone(); | |||
| toExecute.setExecutable("patch"); | |||
| if (originalFile != null) { | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -51,7 +51,6 @@ | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.BuildException; | |||
| @@ -70,53 +69,66 @@ import java.util.Vector; | |||
| import java.io.File; | |||
| /** | |||
| * This task converts path and classpath information to a specific | |||
| * target OS format. The resulting formatted path is placed into a | |||
| * specified property. | |||
| * | |||
| * @author Larry Streepy <a href="mailto:streepy@healthlanguage.com">streepy@healthlanguage.com</a> | |||
| * This task converts path and classpath information to a specific target OS | |||
| * format. The resulting formatted path is placed into a specified property. | |||
| * | |||
| * @author Larry Streepy <a href="mailto:streepy@healthlanguage.com"> | |||
| * streepy@healthlanguage.com</a> | |||
| * @since Ant 1.4 | |||
| * | |||
| * @ant.task category="utility" | |||
| */ | |||
| public class PathConvert extends Task { | |||
| // Members | |||
| private Path path = null;// Path to be converted | |||
| private Reference refid = null;// Reference to path/fileset to | |||
| // convert | |||
| private String targetOS = null;// The target OS type | |||
| private boolean targetWindows = false;// Set when targetOS is set | |||
| private boolean onWindows = false;// Set if we're running on windows | |||
| private String property = null;// The property to receive the | |||
| //results | |||
| private Vector prefixMap = new Vector();// Path prefix map | |||
| private String pathSep = null;// User override on path sep char | |||
| private String dirSep = null;// User override on directory sep | |||
| // char | |||
| public PathConvert() { | |||
| onWindows = Os.isFamily("dos"); | |||
| } | |||
| /** | |||
| * Helper class, holds the nested <map> values. Elements will | |||
| * look like this: <map from="d:" to="/foo"/> | |||
| * <p> | |||
| * When running on windows, the prefix comparison will be case insensitive. | |||
| * Helper class, holds the nested <map> values. Elements will look like | |||
| * this: <map from="d:" to="/foo"/> <p> | |||
| * | |||
| * When running on windows, the prefix comparison will be case | |||
| * insensitive. | |||
| */ | |||
| public class MapEntry { | |||
| /** | |||
| * Set the "from" attribute of the map entry | |||
| */ | |||
| public void setFrom( String from ) { | |||
| /** Set the "from" attribute of the map entry */ | |||
| public void setFrom(String from) { | |||
| this.from = from; | |||
| } | |||
| /** | |||
| * Set the "to" attribute of the map entry | |||
| */ | |||
| public void setTo( String to ) { | |||
| /** Set the "to" attribute of the map entry */ | |||
| public void setTo(String to) { | |||
| this.to = to; | |||
| } | |||
| /** | |||
| * Apply this map entry to a given path element | |||
| * | |||
| * @param elem Path element to process | |||
| * @return String Updated path element after mapping | |||
| */ | |||
| public String apply( String elem ) { | |||
| if( from == null || to == null ) { | |||
| throw new BuildException( "Both 'from' and 'to' must be set " | |||
| + "in a map entry" ); | |||
| public String apply(String elem) { | |||
| if (from == null || to == null) { | |||
| throw new BuildException("Both 'from' and 'to' must be set " | |||
| + "in a map entry"); | |||
| } | |||
| // If we're on windows, then do the comparison ignoring case | |||
| @@ -126,13 +138,13 @@ public class PathConvert extends Task { | |||
| // If the element starts with the configured prefix, then | |||
| // convert the prefix to the configured 'to' value. | |||
| if( cmpElem.startsWith( cmpFrom ) ) { | |||
| if (cmpElem.startsWith(cmpFrom)) { | |||
| int len = from.length(); | |||
| if( len >= elem.length() ) { | |||
| if (len >= elem.length()) { | |||
| elem = to; | |||
| } else { | |||
| elem = to + elem.substring( len ); | |||
| elem = to + elem.substring(len); | |||
| } | |||
| } | |||
| @@ -144,54 +156,58 @@ public class PathConvert extends Task { | |||
| private String to = null; | |||
| } | |||
| public static class TargetOs extends EnumeratedAttribute { | |||
| public String[] getValues() { | |||
| return new String[] {"windows", "unix", "netware", "os/2"}; | |||
| return new String[]{"windows", "unix", "netware", "os/2"}; | |||
| } | |||
| } | |||
| /** | |||
| * Create a nested PATH element | |||
| */ | |||
| /** Create a nested PATH element */ | |||
| public Path createPath() { | |||
| if( isReference() ) { | |||
| if (isReference()) { | |||
| throw noChildrenAllowed(); | |||
| } | |||
| if( path == null ) { | |||
| if (path == null) { | |||
| path = new Path(getProject()); | |||
| } | |||
| return path.createPath(); | |||
| } | |||
| /** | |||
| * Create a nested MAP element | |||
| */ | |||
| /** Create a nested MAP element */ | |||
| public MapEntry createMap() { | |||
| MapEntry entry = new MapEntry(); | |||
| prefixMap.addElement( entry ); | |||
| prefixMap.addElement(entry); | |||
| return entry; | |||
| } | |||
| /** | |||
| * Set the value of the targetos attribute | |||
| * | |||
| * @deprecated use the method taking a TargetOs argument instead | |||
| * @see #setTargetos(TargetOs) | |||
| */ | |||
| public void setTargetos( String target ) { | |||
| public void setTargetos(String target) { | |||
| TargetOs to = new TargetOs(); | |||
| to.setValue(target); | |||
| setTargetos(to); | |||
| } | |||
| /** | |||
| * Set the value of the targetos attribute | |||
| * | |||
| * @since Ant 1.5 | |||
| */ | |||
| public void setTargetos( TargetOs target ) { | |||
| public void setTargetos(TargetOs target) { | |||
| targetOS = target.getValue(); | |||
| @@ -205,134 +221,135 @@ public class PathConvert extends Task { | |||
| targetWindows = !targetOS.equals("unix"); | |||
| } | |||
| /** | |||
| * Set the value of the property attribute - this is the property | |||
| * into which our converted path will be placed. | |||
| * Set the value of the property attribute - this is the property into | |||
| * which our converted path will be placed. | |||
| */ | |||
| public void setProperty( String p ) { | |||
| public void setProperty(String p) { | |||
| property = p; | |||
| } | |||
| /** | |||
| * Adds a reference to a Path, FileSet, DirSet, or FileList defined | |||
| * elsewhere. | |||
| */ | |||
| public void setRefid(Reference r) { | |||
| if( path != null ) { | |||
| if (path != null) { | |||
| throw noChildrenAllowed(); | |||
| } | |||
| refid = r; | |||
| } | |||
| /** | |||
| * Override the default path separator string for the target os | |||
| */ | |||
| public void setPathSep( String sep ) { | |||
| /** Override the default path separator string for the target os */ | |||
| public void setPathSep(String sep) { | |||
| pathSep = sep; | |||
| } | |||
| /** | |||
| * Override the default directory separator string for the target os | |||
| */ | |||
| public void setDirSep( String sep ) { | |||
| public void setDirSep(String sep) { | |||
| dirSep = sep; | |||
| } | |||
| /** | |||
| * Has the refid attribute of this element been set? | |||
| */ | |||
| /** Has the refid attribute of this element been set? */ | |||
| public boolean isReference() { | |||
| return refid != null; | |||
| } | |||
| /** | |||
| * Do the execution. | |||
| */ | |||
| /** Do the execution. */ | |||
| public void execute() throws BuildException { | |||
| Path savedPath = path; | |||
| String savedPathSep = pathSep; // may be altered in validateSetup | |||
| String savedDirSep = dirSep; // may be altered in validateSetup | |||
| String savedPathSep = pathSep;// may be altered in validateSetup | |||
| String savedDirSep = dirSep;// may be altered in validateSetup | |||
| try { | |||
| // If we are a reference, create a Path from the reference | |||
| if( isReference() ) { | |||
| if (isReference()) { | |||
| path = new Path(getProject()).createPath(); | |||
| Object obj = refid.getReferencedObject(getProject()); | |||
| if( obj instanceof Path ) { | |||
| if (obj instanceof Path) { | |||
| path.setRefid(refid); | |||
| } else if( obj instanceof FileSet ) { | |||
| FileSet fs = (FileSet)obj; | |||
| path.addFileset( fs ); | |||
| } else if( obj instanceof DirSet ) { | |||
| DirSet ds = (DirSet)obj; | |||
| path.addDirset( ds ); | |||
| } else if( obj instanceof FileList ) { | |||
| FileList fl = (FileList)obj; | |||
| path.addFilelist( fl ); | |||
| } else if (obj instanceof FileSet) { | |||
| FileSet fs = (FileSet) obj; | |||
| path.addFileset(fs); | |||
| } else if (obj instanceof DirSet) { | |||
| DirSet ds = (DirSet) obj; | |||
| path.addDirset(ds); | |||
| } else if (obj instanceof FileList) { | |||
| FileList fl = (FileList) obj; | |||
| path.addFilelist(fl); | |||
| } else { | |||
| throw new BuildException( "'refid' does not refer to a " | |||
| + "path, fileset, dirset, or " | |||
| + "filelist." ); | |||
| throw new BuildException("'refid' does not refer to a " | |||
| + "path, fileset, dirset, or " | |||
| + "filelist."); | |||
| } | |||
| } | |||
| validateSetup(); // validate our setup | |||
| validateSetup();// validate our setup | |||
| // Currently, we deal with only two path formats: Unix and Windows | |||
| // And Unix is everything that is not Windows | |||
| // (with the exception for NetWare and OS/2 below) | |||
| // for NetWare and OS/2, piggy-back on Windows, since here and | |||
| // in the apply code, the same assumptions can be made as with | |||
| // windows - that \\ is an OK separator, and do comparisons | |||
| // case-insensitive. | |||
| String fromDirSep = onWindows ? "\\" : "/"; | |||
| StringBuffer rslt = new StringBuffer( 100 ); | |||
| StringBuffer rslt = new StringBuffer(100); | |||
| // Get the list of path components in canonical form | |||
| String[] elems = path.list(); | |||
| for( int i=0; i < elems.length; i++ ) { | |||
| for (int i = 0; i < elems.length; i++) { | |||
| String elem = elems[i]; | |||
| elem = mapElement( elem ); // Apply the path prefix map | |||
| elem = mapElement(elem);// Apply the path prefix map | |||
| // Now convert the path and file separator characters from the | |||
| // current os to the target os. | |||
| if( i != 0 ) { | |||
| rslt.append( pathSep ); | |||
| if (i != 0) { | |||
| rslt.append(pathSep); | |||
| } | |||
| StringTokenizer stDirectory = | |||
| StringTokenizer stDirectory = | |||
| new StringTokenizer(elem, fromDirSep, true); | |||
| String token = null; | |||
| while ( stDirectory.hasMoreTokens() ) { | |||
| while (stDirectory.hasMoreTokens()) { | |||
| token = stDirectory.nextToken(); | |||
| if (fromDirSep.equals(token)) { | |||
| rslt.append( dirSep ); | |||
| } | |||
| else { | |||
| rslt.append( token ); | |||
| rslt.append(dirSep); | |||
| } else { | |||
| rslt.append(token); | |||
| } | |||
| } | |||
| } | |||
| // Place the result into the specified property | |||
| String value = rslt.toString(); | |||
| log( "Set property " + property + " = " + value, | |||
| Project.MSG_VERBOSE ); | |||
| getProject().setNewProperty( property, value ); | |||
| log("Set property " + property + " = " + value, | |||
| Project.MSG_VERBOSE); | |||
| getProject().setNewProperty(property, value); | |||
| } finally { | |||
| path = savedPath; | |||
| dirSep = savedDirSep; | |||
| @@ -340,33 +357,34 @@ public class PathConvert extends Task { | |||
| } | |||
| } | |||
| /** | |||
| * Apply the configured map to a path element. The map is used to convert | |||
| * between Windows drive letters and Unix paths. If no map is configured, | |||
| * Apply the configured map to a path element. The map is used to convert | |||
| * between Windows drive letters and Unix paths. If no map is configured, | |||
| * then the input string is returned unchanged. | |||
| * | |||
| * @param elem The path element to apply the map to | |||
| * @return String Updated element | |||
| */ | |||
| private String mapElement( String elem ) { | |||
| private String mapElement(String elem) { | |||
| int size = prefixMap.size(); | |||
| if( size != 0 ) { | |||
| if (size != 0) { | |||
| // Iterate over the map entries and apply each one. | |||
| // Stop when one of the entries actually changes the element. | |||
| for( int i=0; i < size; i++ ) { | |||
| MapEntry entry = (MapEntry)prefixMap.elementAt(i); | |||
| String newElem = entry.apply( elem ); | |||
| for (int i = 0; i < size; i++) { | |||
| MapEntry entry = (MapEntry) prefixMap.elementAt(i); | |||
| String newElem = entry.apply(elem); | |||
| // Note I'm using "!=" to see if we got a new object back from | |||
| // the apply method. | |||
| if( newElem != elem ) { | |||
| if (newElem != elem) { | |||
| elem = newElem; | |||
| break; // We applied one, so we're done | |||
| break;// We applied one, so we're done | |||
| } | |||
| } | |||
| } | |||
| @@ -374,25 +392,27 @@ public class PathConvert extends Task { | |||
| return elem; | |||
| } | |||
| /** | |||
| * Validate that all our parameters have been properly initialized. | |||
| * | |||
| * @throws BuildException if something is not setup properly | |||
| */ | |||
| private void validateSetup() throws BuildException { | |||
| if( path == null ) { | |||
| throw new BuildException( "You must specify a path to convert" ); | |||
| if (path == null) { | |||
| throw new BuildException("You must specify a path to convert"); | |||
| } | |||
| if( property == null ) { | |||
| throw new BuildException( "You must specify a property" ); | |||
| if (property == null) { | |||
| throw new BuildException("You must specify a property"); | |||
| } | |||
| // Must either have a target OS or both a dirSep and pathSep | |||
| if( targetOS == null && pathSep == null && dirSep == null ) { | |||
| throw new BuildException( "You must specify at least one of " | |||
| + "targetOS, dirSep, or pathSep" ); | |||
| if (targetOS == null && pathSep == null && dirSep == null) { | |||
| throw new BuildException("You must specify at least one of " | |||
| + "targetOS, dirSep, or pathSep"); | |||
| } | |||
| // Determine the separator strings. The dirsep and pathsep attributes | |||
| @@ -400,16 +420,16 @@ public class PathConvert extends Task { | |||
| String dsep = File.separator; | |||
| String psep = File.pathSeparator; | |||
| if( targetOS != null ) { | |||
| if (targetOS != null) { | |||
| psep = targetWindows ? ";" : ":"; | |||
| dsep = targetWindows ? "\\" : "/"; | |||
| } | |||
| if( pathSep != null ) { // override with pathsep= | |||
| if (pathSep != null) {// override with pathsep= | |||
| psep = pathSep; | |||
| } | |||
| if( dirSep != null ) { // override with dirsep= | |||
| if (dirSep != null) {// override with dirsep= | |||
| dsep = dirSep; | |||
| } | |||
| @@ -417,27 +437,15 @@ public class PathConvert extends Task { | |||
| dirSep = dsep; | |||
| } | |||
| /** | |||
| * Creates an exception that indicates that this XML element must | |||
| * not have child elements if the refid attribute is set. | |||
| * Creates an exception that indicates that this XML element must not have | |||
| * child elements if the refid attribute is set. | |||
| */ | |||
| private BuildException noChildrenAllowed() { | |||
| return new BuildException("You must not specify nested <path> " | |||
| + "elements when using the refid attribute."); | |||
| + "elements when using the refid attribute."); | |||
| } | |||
| // Members | |||
| private Path path = null; // Path to be converted | |||
| private Reference refid = null; // Reference to path/fileset to | |||
| // convert | |||
| private String targetOS = null; // The target OS type | |||
| private boolean targetWindows = false; // Set when targetOS is set | |||
| private boolean onWindows = false; // Set if we're running on windows | |||
| private String property = null; // The property to receive the | |||
| //results | |||
| private Vector prefixMap = new Vector(); // Path prefix map | |||
| private String pathSep = null; // User override on path sep char | |||
| private String dirSep = null; // User override on directory sep | |||
| // char | |||
| } | |||
| @@ -159,7 +159,7 @@ class ChangeLogParser { | |||
| saveEntry(); | |||
| m_status = GET_FILE; | |||
| } | |||
| else if( line.startsWith( "----------------------------" ) ) { | |||
| else if (line.startsWith("----------------------------")) { | |||
| final int end = m_comment.length() - lineSeparator.length(); //was -1 | |||
| m_comment = m_comment.substring(0, end); | |||
| m_status = GET_PREVIOUS_REV; | |||
| @@ -168,7 +168,7 @@ public class CvsTagDiff extends Task { | |||
| * @exception BuildException if an error occurs | |||
| */ | |||
| public void init() throws BuildException { | |||
| m_cvs = (Cvs)getProject().createTask("cvs"); | |||
| m_cvs = (Cvs) getProject().createTask("cvs"); | |||
| } | |||
| /** | |||
| @@ -290,10 +290,10 @@ public class CvsTagDiff extends Task { | |||
| // build the rdiff command | |||
| String rdiff = "rdiff -s " + | |||
| (m_startTag!=null?("-r " + m_startTag):("-D " + m_startDate)) | |||
| + " " + | |||
| (m_endTag!=null?("-r " + m_endTag):("-D " + m_endDate)) + " " + | |||
| m_package; | |||
| (m_startTag != null ? ("-r " + m_startTag) : ("-D " + m_startDate)) | |||
| + " " | |||
| + (m_endTag != null ? ("-r " + m_endTag) : ("-D " + m_endDate)) | |||
| + " " + m_package; | |||
| log("Cvs command is " + rdiff, Project.MSG_VERBOSE); | |||
| m_cvs.setCommand(rdiff); | |||
| @@ -148,12 +148,12 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
| if (resolver != null) { | |||
| if (tfactory.getFeature(SAXSource.FEATURE)) { | |||
| SAXParserFactory spFactory = SAXParserFactory.newInstance(); | |||
| spFactory.setNamespaceAware( true ); | |||
| spFactory.setNamespaceAware(true); | |||
| XMLReader reader = spFactory.newSAXParser().getXMLReader(); | |||
| reader.setEntityResolver(resolver); | |||
| src = new SAXSource(reader, new InputSource(fis)); | |||
| } else { | |||
| throw new IllegalStateException("xcatalog specified, but "+ | |||
| throw new IllegalStateException("xcatalog specified, but " + | |||
| "parser doesn't support SAX"); | |||
| } | |||
| } else { | |||
| @@ -193,7 +193,7 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
| // making sure it is really a /'ed path | |||
| protected String getSystemId(File file){ | |||
| String path = file.getAbsolutePath(); | |||
| path = path.replace('\\','/'); | |||
| path = path.replace('\\', '/'); | |||
| // on Windows, use 'file:///' | |||
| if (File.separatorChar == '\\') { | |||
| @@ -234,27 +234,27 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
| } | |||
| StringBuffer msg = new StringBuffer(); | |||
| if(e.getLocator() != null) { | |||
| if(e.getLocator().getSystemId() != null) { | |||
| if (e.getLocator() != null) { | |||
| if (e.getLocator().getSystemId() != null) { | |||
| String url = e.getLocator().getSystemId(); | |||
| if(url.startsWith("file:///")) { | |||
| if (url.startsWith("file:///")) { | |||
| url = url.substring(8); | |||
| } | |||
| msg.append(url); | |||
| } else { | |||
| msg.append("Unknown file"); | |||
| } | |||
| if(e.getLocator().getLineNumber() != -1) { | |||
| msg.append(":"+e.getLocator().getLineNumber()); | |||
| if(e.getLocator().getColumnNumber() != -1) { | |||
| msg.append(":"+e.getLocator().getColumnNumber()); | |||
| if (e.getLocator().getLineNumber() != -1) { | |||
| msg.append(":" + e.getLocator().getLineNumber()); | |||
| if (e.getLocator().getColumnNumber() != -1) { | |||
| msg.append(":" + e.getLocator().getColumnNumber()); | |||
| } | |||
| } | |||
| } | |||
| msg.append(": "+type+"! "); | |||
| msg.append(": " + type + "! "); | |||
| msg.append(e.getMessage()); | |||
| if(e.getCause() != null) { | |||
| msg.append(" Cause: "+e.getCause()); | |||
| if (e.getCause() != null) { | |||
| msg.append(" Cause: " + e.getCause()); | |||
| } | |||
| logger.log(msg.toString()); | |||
| @@ -95,7 +95,8 @@ public class XMLValidateTask extends Task { | |||
| * validation. | |||
| */ | |||
| // The crimson implementation is shipped with ant. | |||
| public static String DEFAULT_XML_READER_CLASSNAME= "org.apache.crimson.parser.XMLReaderImpl"; | |||
| public static String DEFAULT_XML_READER_CLASSNAME | |||
| = "org.apache.crimson.parser.XMLReaderImpl"; | |||
| protected static String INIT_FAILED_MSG = "Could not start xml validation: "; | |||
| @@ -234,7 +235,7 @@ public class XMLValidateTask extends Task { | |||
| LocalResolver resolver = new LocalResolver(); | |||
| for (Enumeration i = dtdLocations.elements(); i.hasMoreElements();) { | |||
| DTDLocation location = (DTDLocation)i.nextElement(); | |||
| DTDLocation location = (DTDLocation) i.nextElement(); | |||
| resolver.registerDTD(location); | |||
| } | |||
| return resolver; | |||
| @@ -243,7 +244,7 @@ public class XMLValidateTask extends Task { | |||
| public void execute() throws BuildException { | |||
| int fileProcessed = 0; | |||
| if (file == null && (filesets.size()==0) ) { | |||
| if (file == null && (filesets.size() == 0)) { | |||
| throw new BuildException("Specify at least one source - a file or a fileset."); | |||
| } | |||
| @@ -264,13 +265,13 @@ public class XMLValidateTask extends Task { | |||
| } | |||
| } | |||
| for (int i=0; i<filesets.size(); i++) { | |||
| for (int i = 0; i < filesets.size(); i++) { | |||
| FileSet fs = (FileSet) filesets.elementAt(i); | |||
| DirectoryScanner ds = fs.getDirectoryScanner(project); | |||
| String[] files = ds.getIncludedFiles(); | |||
| for (int j=0; j < files.length ; j++) { | |||
| for (int j = 0; j < files.length ; j++) { | |||
| File srcFile = new File(fs.getDir(project), files[j]); | |||
| doValidate(srcFile); | |||
| fileProcessed++; | |||
| @@ -288,7 +289,7 @@ public class XMLValidateTask extends Task { | |||
| try { | |||
| // load the parser class | |||
| // with JAXP, we would use a SAXParser factory | |||
| Class readerClass= null; | |||
| Class readerClass = null; | |||
| //Class readerImpl = null; | |||
| //Class parserImpl = null; | |||
| if (classpath != null) { | |||
| @@ -313,9 +314,8 @@ public class XMLValidateTask extends Task { | |||
| xmlReader = new ParserAdapter(parser); | |||
| log("Using SAX1 parser " + readerClassName, Project.MSG_VERBOSE); | |||
| } else { | |||
| throw new BuildException(INIT_FAILED_MSG | |||
| + readerClassName | |||
| + " implements nor SAX1 Parser nor SAX2 XMLReader."); | |||
| throw new BuildException(INIT_FAILED_MSG + readerClassName | |||
| + " implements nor SAX1 Parser nor SAX2 XMLReader."); | |||
| } | |||
| } | |||
| } catch (ClassNotFoundException e) { | |||
| @@ -329,11 +329,11 @@ public class XMLValidateTask extends Task { | |||
| xmlReader.setEntityResolver(getEntityResolver()); | |||
| xmlReader.setErrorHandler(errorHandler); | |||
| if (! (xmlReader instanceof ParserAdapter)) { | |||
| if (!(xmlReader instanceof ParserAdapter)) { | |||
| // turn validation on | |||
| if (! lenient) { | |||
| boolean ok = setFeature("http://xml.org/sax/features/validation",true,true); | |||
| if (! ok) { | |||
| if (!lenient) { | |||
| boolean ok = setFeature("http://xml.org/sax/features/validation", true, true); | |||
| if (!ok) { | |||
| throw new BuildException(INIT_FAILED_MSG | |||
| + readerClassName | |||
| + " doesn't provide validation"); | |||
| @@ -341,7 +341,7 @@ public class XMLValidateTask extends Task { | |||
| } | |||
| // set other features | |||
| Enumeration enum = features.keys(); | |||
| while(enum.hasMoreElements()) { | |||
| while (enum.hasMoreElements()) { | |||
| String featureId = (String) enum.nextElement(); | |||
| setFeature(featureId, ((Boolean) features.get(featureId)).booleanValue(), true); | |||
| } | |||
| @@ -356,7 +356,7 @@ public class XMLValidateTask extends Task { | |||
| boolean toReturn = false; | |||
| try { | |||
| xmlReader.setFeature(feature,value); | |||
| xmlReader.setFeature(feature, value); | |||
| toReturn = true; | |||
| } catch (SAXNotRecognizedException e) { | |||
| if (warn) { | |||
| @@ -386,23 +386,26 @@ public class XMLValidateTask extends Task { | |||
| String uri = "file:" + afile.getAbsolutePath().replace('\\', '/'); | |||
| for (int index = uri.indexOf('#'); index != -1; | |||
| index = uri.indexOf('#')) { | |||
| uri = uri.substring(0, index) + "%23" + uri.substring(index+1); | |||
| uri = uri.substring(0, index) + "%23" | |||
| + uri.substring(index + 1); | |||
| } | |||
| is.setSystemId(uri); | |||
| xmlReader.parse(is); | |||
| } catch (SAXException ex) { | |||
| if (failOnError) { | |||
| throw new BuildException("Could not validate document " + afile); | |||
| throw new BuildException("Could not validate document " | |||
| + afile); | |||
| } | |||
| } catch (IOException ex) { | |||
| throw new BuildException("Could not validate document " + afile, ex); | |||
| throw new BuildException("Could not validate document " + afile, | |||
| ex); | |||
| } | |||
| if (errorHandler.getFailure()) { | |||
| if (failOnError) { | |||
| throw new BuildException(afile + " is not a valid XML document."); | |||
| } else { | |||
| log(afile + " is not a valid XML document",Project.MSG_ERR); | |||
| log(afile + " is not a valid XML document", Project.MSG_ERR); | |||
| } | |||
| } | |||
| } | |||
| @@ -433,19 +436,19 @@ public class XMLValidateTask extends Task { | |||
| public void fatalError(SAXParseException exception) { | |||
| failed = true; | |||
| doLog(exception,Project.MSG_ERR); | |||
| doLog(exception, Project.MSG_ERR); | |||
| } | |||
| public void error(SAXParseException exception) { | |||
| failed = true; | |||
| doLog(exception,Project.MSG_ERR); | |||
| doLog(exception, Project.MSG_ERR); | |||
| } | |||
| public void warning(SAXParseException exception) { | |||
| // depending on implementation, XMLReader can yield hips of warning, | |||
| // only output then if user explicitely asked for it | |||
| if (warn) { | |||
| doLog(exception,Project.MSG_WARN); | |||
| doLog(exception, Project.MSG_WARN); | |||
| } | |||
| } | |||
| @@ -493,7 +496,8 @@ public class XMLValidateTask extends Task { | |||
| if (fileDTD.exists()) { | |||
| if (publicId != null) { | |||
| fileDTDs.put(publicId, fileDTD); | |||
| log("Mapped publicId " + publicId + " to file " + fileDTD, Project.MSG_VERBOSE); | |||
| log("Mapped publicId " + publicId + " to file " + fileDTD, | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| return; | |||
| } | |||
| @@ -501,7 +505,8 @@ public class XMLValidateTask extends Task { | |||
| if (LocalResolver.this.getClass().getResource(location) != null) { | |||
| if (publicId != null) { | |||
| resourceDTDs.put(publicId, location); | |||
| log("Mapped publicId " + publicId + " to resource " + location, Project.MSG_VERBOSE); | |||
| log("Mapped publicId " + publicId + " to resource " | |||
| + location, Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| @@ -510,7 +515,7 @@ public class XMLValidateTask extends Task { | |||
| URL urldtd = new URL(location); | |||
| urlDTDs.put(publicId, urldtd); | |||
| } | |||
| } catch ( java.net.MalformedURLException e) { | |||
| } catch (MalformedURLException e) { | |||
| //ignored | |||
| } | |||
| } | |||
| @@ -523,27 +528,28 @@ public class XMLValidateTask extends Task { | |||
| try { | |||
| log("Resolved " + publicId + " to local file " + dtdFile, Project.MSG_VERBOSE); | |||
| return new InputSource(new FileInputStream(dtdFile)); | |||
| } catch( FileNotFoundException ex ) { | |||
| } catch (FileNotFoundException ex) { | |||
| // ignore | |||
| } | |||
| } | |||
| String dtdResourceName = (String)resourceDTDs.get(publicId); | |||
| String dtdResourceName = (String) resourceDTDs.get(publicId); | |||
| if (dtdResourceName != null) { | |||
| InputStream is = this.getClass().getResourceAsStream(dtdResourceName); | |||
| if (is != null) { | |||
| log("Resolved " + publicId + " to local resource " + dtdResourceName, Project.MSG_VERBOSE); | |||
| log("Resolved " + publicId + " to local resource " | |||
| + dtdResourceName, Project.MSG_VERBOSE); | |||
| return new InputSource(is); | |||
| } | |||
| } | |||
| URL dtdUrl = (URL) urlDTDs.get(publicId); | |||
| if ( dtdUrl != null ) { | |||
| if (dtdUrl != null) { | |||
| try { | |||
| InputStream is = dtdUrl.openStream(); | |||
| log("Resolved " + publicId + " to url " + dtdUrl, Project.MSG_VERBOSE); | |||
| return new InputSource(is); | |||
| } catch ( IOException ioe) { | |||
| } catch (IOException ioe) { | |||
| //ignore | |||
| } | |||
| } | |||
| @@ -114,7 +114,7 @@ public class JlinkTask extends MatchingTask { | |||
| this.mergefiles = mergefiles; | |||
| } | |||
| else { | |||
| this.mergefiles .append(mergefiles); | |||
| this.mergefiles.append(mergefiles); | |||
| } | |||
| } | |||
| @@ -167,16 +167,16 @@ public class JlinkTask extends MatchingTask { | |||
| linker.setOutfile(outfile.getPath()); | |||
| linker.setCompression(compress); | |||
| if (haveMergeFiles()) { | |||
| log("merge files: " + mergefiles.toString(), Project.MSG_VERBOSE ); | |||
| linker.addMergeFiles( mergefiles.list() ); | |||
| log("merge files: " + mergefiles.toString(), Project.MSG_VERBOSE); | |||
| linker.addMergeFiles(mergefiles.list()); | |||
| } | |||
| if (haveAddFiles()) { | |||
| log("add files: " + addfiles.toString(), Project .MSG_VERBOSE); | |||
| log("add files: " + addfiles.toString(), Project.MSG_VERBOSE); | |||
| linker.addAddFiles(addfiles.list()); | |||
| } | |||
| try { | |||
| linker.link(); | |||
| } catch(Exception ex) { | |||
| } catch (Exception ex) { | |||
| throw new BuildException(ex, location); | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000,2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -51,16 +51,13 @@ | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| /** | |||
| * jlink.java | |||
| * links together multiple .jar files | |||
| * | |||
| * Original code by Patrick Beard. Modifications to work | |||
| * with ANT by Matthew Kuperus Heun. | |||
| * jlink.java links together multiple .jar files Original code by Patrick | |||
| * Beard. Modifications to work with ANT by Matthew Kuperus Heun. | |||
| * | |||
| * @author <a href="mailto:beard@netscape.com>Patrick C. Beard</a>. | |||
| * @author <a href="mailto:matthew.k.heun@gaerospace.com>Matthew Kuperus Heun</a> | |||
| * @author <a href="mailto:beard@netscape.com>Patrick C. Beard</a> . | |||
| * @author <a href="mailto:matthew.k.heun@gaerospace.com>Matthew Kuperus Heun | |||
| * </a> | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional.jlink; | |||
| @@ -70,8 +67,8 @@ import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.FileInputStream; | |||
| import java.io.BufferedInputStream; | |||
| import java.util .Enumeration; | |||
| import java.util .Vector; | |||
| import java.util.Enumeration; | |||
| import java.util.Vector; | |||
| import java.util.zip.ZipOutputStream; | |||
| import java.util.zip.Deflater; | |||
| import java.util.zip.ZipFile; | |||
| @@ -79,167 +76,168 @@ import java.util.zip.ZipEntry; | |||
| import java.util.zip.ZipException; | |||
| import java.util.zip.CRC32; | |||
| public class jlink extends Object{ | |||
| public class jlink extends Object { | |||
| /** | |||
| * The file that will be created by this instance of jlink. | |||
| */ | |||
| public void setOutfile( String outfile ) { | |||
| if ( outfile == null ) { | |||
| return ; | |||
| /** The file that will be created by this instance of jlink. */ | |||
| public void setOutfile(String outfile) { | |||
| if (outfile == null) { | |||
| return; | |||
| } | |||
| this .outfile = outfile; | |||
| this.outfile = outfile; | |||
| } | |||
| /** | |||
| * Adds a file to be merged into the output. | |||
| */ | |||
| public void addMergeFile( String mergefile ) { | |||
| if ( mergefile == null ) { | |||
| return ; | |||
| /** Adds a file to be merged into the output. */ | |||
| public void addMergeFile(String mergefile) { | |||
| if (mergefile == null) { | |||
| return; | |||
| } | |||
| mergefiles .addElement( mergefile ); | |||
| mergefiles.addElement(mergefile); | |||
| } | |||
| /** | |||
| * Adds a file to be added into the output. | |||
| */ | |||
| public void addAddFile( String addfile ) { | |||
| if ( addfile == null ) { | |||
| return ; | |||
| /** Adds a file to be added into the output. */ | |||
| public void addAddFile(String addfile) { | |||
| if (addfile == null) { | |||
| return; | |||
| } | |||
| addfiles .addElement( addfile ); | |||
| addfiles.addElement(addfile); | |||
| } | |||
| /** | |||
| * Adds several files to be merged into the output. | |||
| */ | |||
| public void addMergeFiles( String[] mergefiles ) { | |||
| if ( mergefiles == null ) { | |||
| return ; | |||
| /** Adds several files to be merged into the output. */ | |||
| public void addMergeFiles(String[] mergefiles) { | |||
| if (mergefiles == null) { | |||
| return; | |||
| } | |||
| for ( int i = 0; i < mergefiles .length; i++ ) { | |||
| addMergeFile( mergefiles[i] ); | |||
| for (int i = 0; i < mergefiles.length; i++) { | |||
| addMergeFile(mergefiles[i]); | |||
| } | |||
| } | |||
| /** | |||
| * Adds several file to be added into the output. | |||
| */ | |||
| public void addAddFiles( String[] addfiles ) { | |||
| if ( addfiles == null ) { | |||
| return ; | |||
| /** Adds several file to be added into the output. */ | |||
| public void addAddFiles(String[] addfiles) { | |||
| if (addfiles == null) { | |||
| return; | |||
| } | |||
| for ( int i = 0; i < addfiles .length; i++ ) { | |||
| addAddFile( addfiles[i] ); | |||
| for (int i = 0; i < addfiles.length; i++) { | |||
| addAddFile(addfiles[i]); | |||
| } | |||
| } | |||
| /** | |||
| * Determines whether output will be compressed. | |||
| */ | |||
| public void setCompression( boolean compress ) { | |||
| this .compression = compress; | |||
| /** Determines whether output will be compressed. */ | |||
| public void setCompression(boolean compress) { | |||
| this.compression = compress; | |||
| } | |||
| /** | |||
| * Performs the linking of files. | |||
| * Addfiles are added to the output as-is. For example, a | |||
| * jar file is added to the output as a jar file. | |||
| * However, mergefiles are first examined for their type. | |||
| * If it is a jar or zip file, the contents will be extracted | |||
| * from the mergefile and entered into the output. | |||
| * If a zip or jar file is encountered in a subdirectory | |||
| * it will be added, not merged. | |||
| * If a directory is encountered, it becomes the root | |||
| * entry of all the files below it. Thus, you can | |||
| * provide multiple, disjoint directories, as | |||
| * addfiles: they will all be added in a rational | |||
| * manner to outfile. | |||
| * Performs the linking of files. Addfiles are added to the output as-is. | |||
| * For example, a jar file is added to the output as a jar file. However, | |||
| * mergefiles are first examined for their type. If it is a jar or zip | |||
| * file, the contents will be extracted from the mergefile and entered | |||
| * into the output. If a zip or jar file is encountered in a subdirectory | |||
| * it will be added, not merged. If a directory is encountered, it becomes | |||
| * the root entry of all the files below it. Thus, you can provide | |||
| * multiple, disjoint directories, as addfiles: they will all be added in | |||
| * a rational manner to outfile. | |||
| */ | |||
| public void link() throws Exception { | |||
| ZipOutputStream output = new ZipOutputStream( new FileOutputStream( outfile ) ); | |||
| if ( compression ) { | |||
| output .setMethod( ZipOutputStream .DEFLATED ); | |||
| output .setLevel( Deflater .DEFAULT_COMPRESSION ); | |||
| public void link() throws Exception { | |||
| ZipOutputStream output = new ZipOutputStream(new FileOutputStream(outfile)); | |||
| if (compression) { | |||
| output.setMethod(ZipOutputStream.DEFLATED); | |||
| output.setLevel(Deflater.DEFAULT_COMPRESSION); | |||
| } else { | |||
| output .setMethod( ZipOutputStream .STORED ); | |||
| output.setMethod(ZipOutputStream.STORED); | |||
| } | |||
| Enumeration merges = mergefiles .elements(); | |||
| while ( merges .hasMoreElements() ) { | |||
| String path = (String) merges .nextElement(); | |||
| File f = new File( path ); | |||
| if ( f.getName().endsWith( ".jar" ) || f.getName().endsWith( ".zip" ) ) { | |||
| //Do the merge | |||
| mergeZipJarContents( output, f ); | |||
| } | |||
| else { | |||
| //Add this file to the addfiles Vector and add it | |||
| Enumeration merges = mergefiles.elements(); | |||
| while (merges.hasMoreElements()) { | |||
| String path = (String) merges.nextElement(); | |||
| File f = new File(path); | |||
| if (f.getName().endsWith(".jar") || f.getName().endsWith(".zip")) { | |||
| //Do the merge | |||
| mergeZipJarContents(output, f); | |||
| } else { | |||
| //Add this file to the addfiles Vector and add it | |||
| //later at the top level of the output file. | |||
| addAddFile( path ); | |||
| addAddFile(path); | |||
| } | |||
| } | |||
| Enumeration adds = addfiles .elements(); | |||
| while ( adds .hasMoreElements() ) { | |||
| String name = (String) adds .nextElement(); | |||
| File f = new File( name ); | |||
| if ( f .isDirectory() ) { | |||
| Enumeration adds = addfiles.elements(); | |||
| while (adds.hasMoreElements()) { | |||
| String name = (String) adds.nextElement(); | |||
| File f = new File(name); | |||
| if (f.isDirectory()) { | |||
| //System.out.println("in jlink: adding directory contents of " + f.getPath()); | |||
| addDirContents( output, f, f.getName() + '/', compression ); | |||
| } | |||
| else { | |||
| addFile( output, f, "", compression ); | |||
| addDirContents(output, f, f.getName() + '/', compression); | |||
| } else { | |||
| addFile(output, f, "", compression); | |||
| } | |||
| } | |||
| if ( output != null ) { | |||
| try { | |||
| output .close(); | |||
| } catch( IOException ioe ) {} | |||
| if (output != null) { | |||
| try { | |||
| output.close(); | |||
| } catch (IOException ioe) { | |||
| } | |||
| } | |||
| } | |||
| public static void main( String[] args ) { | |||
| public static void main(String[] args) { | |||
| // jlink output input1 ... inputN | |||
| if ( args .length < 2 ) { | |||
| System .out .println( "usage: jlink output input1 ... inputN" ); | |||
| System .exit( 1 ); | |||
| if (args.length < 2) { | |||
| System.out.println("usage: jlink output input1 ... inputN"); | |||
| System.exit(1); | |||
| } | |||
| jlink linker = new jlink(); | |||
| linker .setOutfile( args[0] ); | |||
| linker.setOutfile(args[0]); | |||
| //To maintain compatibility with the command-line version, we will only add files to be merged. | |||
| for ( int i = 1; i < args .length; i++ ) { | |||
| linker .addMergeFile( args[i] ); | |||
| for (int i = 1; i < args.length; i++) { | |||
| linker.addMergeFile(args[i]); | |||
| } | |||
| try { | |||
| linker .link(); | |||
| } catch( Exception ex ) { | |||
| System .err .print( ex .getMessage() ); | |||
| try { | |||
| linker.link(); | |||
| } catch (Exception ex) { | |||
| System.err.print(ex.getMessage()); | |||
| } | |||
| } | |||
| /* | |||
| * Actually performs the merging of f into the output. | |||
| * f should be a zip or jar file. | |||
| */ | |||
| private void mergeZipJarContents( ZipOutputStream output, File f ) throws IOException { | |||
| private void mergeZipJarContents(ZipOutputStream output, File f) throws IOException { | |||
| //Check to see that the file with name "name" exists. | |||
| if ( ! f .exists() ) { | |||
| return ; | |||
| if (!f.exists()) { | |||
| return; | |||
| } | |||
| ZipFile zipf = new ZipFile( f ); | |||
| ZipFile zipf = new ZipFile(f); | |||
| Enumeration entries = zipf.entries(); | |||
| while (entries.hasMoreElements()){ | |||
| while (entries.hasMoreElements()) { | |||
| ZipEntry inputEntry = (ZipEntry) entries.nextElement(); | |||
| //Ignore manifest entries. They're bound to cause conflicts between | |||
| //files that are being merged. User should supply their own | |||
| //manifest file when doing the merge. | |||
| String inputEntryName = inputEntry.getName(); | |||
| int index = inputEntryName.indexOf("META-INF"); | |||
| if (index < 0){ | |||
| if (index < 0) { | |||
| //META-INF not found in the name of the entry. Go ahead and process it. | |||
| try { | |||
| output.putNextEntry(processEntry(zipf, inputEntry)); | |||
| } catch (ZipException ex){ | |||
| } catch (ZipException ex) { | |||
| //If we get here, it could be because we are trying to put a | |||
| //directory entry that already exists. | |||
| //For example, we're trying to write "com", but a previous | |||
| @@ -247,139 +245,160 @@ public class jlink extends Object{ | |||
| //In that case, just ignore the error and go on to the | |||
| //next entry. | |||
| String mess = ex.getMessage(); | |||
| if (mess.indexOf("duplicate") >= 0){ | |||
| //It was the duplicate entry. | |||
| if (mess.indexOf("duplicate") >= 0) { | |||
| //It was the duplicate entry. | |||
| continue; | |||
| } else { | |||
| //I hate to admit it, but we don't know what happened here. Throw the Exception. | |||
| //I hate to admit it, but we don't know what happened here. Throw the Exception. | |||
| throw ex; | |||
| } | |||
| } | |||
| InputStream in = zipf.getInputStream(inputEntry); | |||
| int len = buffer.length; | |||
| int count = -1; | |||
| while ((count = in.read(buffer, 0, len)) > 0){ | |||
| while ((count = in.read(buffer, 0, len)) > 0) { | |||
| output.write(buffer, 0, count); | |||
| } | |||
| in.close(); | |||
| output.closeEntry(); | |||
| } | |||
| } | |||
| zipf .close(); | |||
| zipf.close(); | |||
| } | |||
| /* | |||
| * Adds contents of a directory to the output. | |||
| */ | |||
| private void addDirContents( ZipOutputStream output, File dir, String prefix, boolean compress ) throws IOException { | |||
| String[] contents = dir .list(); | |||
| for ( int i = 0; i < contents .length; ++i ) { | |||
| private void addDirContents(ZipOutputStream output, File dir, String prefix, boolean compress) throws IOException { | |||
| String[] contents = dir.list(); | |||
| for (int i = 0; i < contents.length; ++i) { | |||
| String name = contents[i]; | |||
| File file = new File( dir, name ); | |||
| if ( file .isDirectory() ) { | |||
| addDirContents( output, file, prefix + name + '/', compress ); | |||
| } | |||
| else { | |||
| addFile( output, file, prefix, compress ); | |||
| File file = new File(dir, name); | |||
| if (file.isDirectory()) { | |||
| addDirContents(output, file, prefix + name + '/', compress); | |||
| } else { | |||
| addFile(output, file, prefix, compress); | |||
| } | |||
| } | |||
| } | |||
| /* | |||
| * Gets the name of an entry in the file. This is the real name | |||
| * which for a class is the name of the package with the class | |||
| * name appended. | |||
| */ | |||
| private String getEntryName( File file, String prefix ) { | |||
| String name = file .getName(); | |||
| if ( ! name .endsWith( ".class" ) ) { | |||
| private String getEntryName(File file, String prefix) { | |||
| String name = file.getName(); | |||
| if (!name.endsWith(".class")) { | |||
| // see if the file is in fact a .class file, and determine its actual name. | |||
| try { | |||
| InputStream input = new FileInputStream( file ); | |||
| String className = ClassNameReader .getClassName( input ); | |||
| input .close(); | |||
| if ( className != null ) { | |||
| return className .replace( '.', '/' ) + ".class"; | |||
| try { | |||
| InputStream input = new FileInputStream(file); | |||
| String className = ClassNameReader.getClassName(input); | |||
| input.close(); | |||
| if (className != null) { | |||
| return className.replace('.', '/') + ".class"; | |||
| } | |||
| } catch( IOException ioe ) {} | |||
| } catch (IOException ioe) { | |||
| } | |||
| } | |||
| System.out.println("From " + file.getPath() + " and prefix " + prefix + ", creating entry " + prefix+name); | |||
| System.out.println("From " + file.getPath() + " and prefix " + prefix + ", creating entry " + prefix + name); | |||
| return (prefix + name); | |||
| } | |||
| /* | |||
| * Adds a file to the output stream. | |||
| */ | |||
| private void addFile( ZipOutputStream output, File file, String prefix, boolean compress) throws IOException { | |||
| private void addFile(ZipOutputStream output, File file, String prefix, boolean compress) throws IOException { | |||
| //Make sure file exists | |||
| long checksum = 0; | |||
| if ( ! file .exists() ) { | |||
| return ; | |||
| if (!file.exists()) { | |||
| return; | |||
| } | |||
| ZipEntry entry = new ZipEntry( getEntryName( file, prefix ) ); | |||
| entry .setTime( file .lastModified() ); | |||
| entry .setSize( file .length() ); | |||
| if (! compress){ | |||
| ZipEntry entry = new ZipEntry(getEntryName(file, prefix)); | |||
| entry.setTime(file.lastModified()); | |||
| entry.setSize(file.length()); | |||
| if (!compress) { | |||
| entry.setCrc(calcChecksum(file)); | |||
| } | |||
| FileInputStream input = new FileInputStream( file ); | |||
| FileInputStream input = new FileInputStream(file); | |||
| addToOutputStream(output, input, entry); | |||
| } | |||
| /* | |||
| * A convenience method that several other methods might call. | |||
| */ | |||
| private void addToOutputStream(ZipOutputStream output, InputStream input, ZipEntry ze) throws IOException{ | |||
| private void addToOutputStream(ZipOutputStream output, InputStream input, ZipEntry ze) throws IOException { | |||
| try { | |||
| output.putNextEntry(ze); | |||
| output.putNextEntry(ze); | |||
| } catch (ZipException zipEx) { | |||
| //This entry already exists. So, go with the first one. | |||
| input.close(); | |||
| return; | |||
| } | |||
| int numBytes = -1; | |||
| while((numBytes = input.read(buffer)) > 0){ | |||
| while ((numBytes = input.read(buffer)) > 0) { | |||
| output.write(buffer, 0, numBytes); | |||
| } | |||
| output.closeEntry(); | |||
| input.close(); | |||
| } | |||
| /* | |||
| * A method that does the work on a given entry in a mergefile. | |||
| * The big deal is to set the right parameters in the ZipEntry | |||
| * The big deal is to set the right parameters in the ZipEntry | |||
| * on the output stream. | |||
| */ | |||
| private ZipEntry processEntry( ZipFile zip, ZipEntry inputEntry ) throws IOException{ | |||
| private ZipEntry processEntry(ZipFile zip, ZipEntry inputEntry) throws IOException { | |||
| /* | |||
| First, some notes. | |||
| On MRJ 2.2.2, getting the size, compressed size, and CRC32 from the | |||
| ZipInputStream does not work for compressed (deflated) files. Those calls return -1. | |||
| For uncompressed (stored) files, those calls do work. | |||
| However, using ZipFile.getEntries() works for both compressed and | |||
| However, using ZipFile.getEntries() works for both compressed and | |||
| uncompressed files. | |||
| Now, from some simple testing I did, it seems that the value of CRC-32 is | |||
| independent of the compression setting. So, it should be easy to pass this | |||
| independent of the compression setting. So, it should be easy to pass this | |||
| information on to the output entry. | |||
| */ | |||
| String name = inputEntry .getName(); | |||
| if ( ! (inputEntry .isDirectory() || name .endsWith( ".class" )) ) { | |||
| try { | |||
| InputStream input = zip.getInputStream( zip .getEntry( name ) ); | |||
| String className = ClassNameReader .getClassName( input ); | |||
| input .close(); | |||
| if ( className != null ) { | |||
| name = className .replace( '.', '/' ) + ".class"; | |||
| String name = inputEntry.getName(); | |||
| if (!(inputEntry.isDirectory() || name.endsWith(".class"))) { | |||
| try { | |||
| InputStream input = zip.getInputStream(zip.getEntry(name)); | |||
| String className = ClassNameReader.getClassName(input); | |||
| input.close(); | |||
| if (className != null) { | |||
| name = className.replace('.', '/') + ".class"; | |||
| } | |||
| } catch( IOException ioe ) {} | |||
| } catch (IOException ioe) { | |||
| } | |||
| } | |||
| ZipEntry outputEntry = new ZipEntry( name ); | |||
| outputEntry.setTime(inputEntry .getTime() ); | |||
| ZipEntry outputEntry = new ZipEntry(name); | |||
| outputEntry.setTime(inputEntry.getTime()); | |||
| outputEntry.setExtra(inputEntry.getExtra()); | |||
| outputEntry.setComment(inputEntry.getComment()); | |||
| outputEntry.setTime(inputEntry.getTime()); | |||
| if (compression){ | |||
| if (compression) { | |||
| outputEntry.setMethod(ZipEntry.DEFLATED); | |||
| //Note, don't need to specify size or crc for compressed files. | |||
| } else { | |||
| @@ -389,26 +408,30 @@ public class jlink extends Object{ | |||
| } | |||
| return outputEntry; | |||
| } | |||
| /* | |||
| * Necessary in the case where you add a entry that | |||
| * is not compressed. | |||
| */ | |||
| private long calcChecksum(File f) throws IOException { | |||
| BufferedInputStream in = new BufferedInputStream(new FileInputStream(f)); | |||
| return calcChecksum(in, f.length()); | |||
| } | |||
| /* | |||
| * Necessary in the case where you add a entry that | |||
| * is not compressed. | |||
| */ | |||
| private long calcChecksum(InputStream in, long size) throws IOException{ | |||
| private long calcChecksum(InputStream in, long size) throws IOException { | |||
| CRC32 crc = new CRC32(); | |||
| int len = buffer.length; | |||
| int count = -1; | |||
| int haveRead = 0; | |||
| while((count=in.read(buffer, 0, len)) > 0){ | |||
| int haveRead = 0; | |||
| while ((count = in.read(buffer, 0, len)) > 0) { | |||
| haveRead += count; | |||
| crc.update(buffer, 0, count); | |||
| } | |||
| @@ -416,14 +439,15 @@ public class jlink extends Object{ | |||
| return crc.getValue(); | |||
| } | |||
| private String outfile = null; | |||
| private Vector mergefiles = new Vector( 10 ); | |||
| private String outfile = null; | |||
| private Vector mergefiles = new Vector(10); | |||
| private Vector addfiles = new Vector(10); | |||
| private Vector addfiles = new Vector( 10 ); | |||
| private boolean compression = false; | |||
| private boolean compression = false; | |||
| byte[] buffer = new byte[8192]; | |||
| } | |||
| @@ -118,7 +118,7 @@ public class JspC extends MatchingTask | |||
| private File destDir; | |||
| private String packageName ; | |||
| /** name of the compiler to use */ | |||
| private String compilerName="jasper"; | |||
| private String compilerName = "jasper"; | |||
| /** | |||
| * -ieplugin <clsid>Java Plugin classid for Internet Explorer | |||
| @@ -127,7 +127,7 @@ public class JspC extends MatchingTask | |||
| private boolean mapped ; | |||
| private int verbose = 0; | |||
| protected Vector compileList = new Vector(); | |||
| Vector javaFiles=new Vector(); | |||
| Vector javaFiles = new Vector(); | |||
| /** | |||
| * flag to control action on execution trouble | |||
| @@ -336,7 +336,7 @@ public class JspC extends MatchingTask | |||
| public void addWebApp(WebAppParameter webappParam) | |||
| throws BuildException { | |||
| //demand create vector of filesets | |||
| if(webApp == null) { | |||
| if (webApp == null) { | |||
| webApp = webappParam; | |||
| } | |||
| else { | |||
| @@ -352,7 +352,7 @@ public class JspC extends MatchingTask | |||
| * Sets the compiler to use. Optional: default=jasper | |||
| */ | |||
| public void setCompiler(String compiler) { | |||
| this.compilerName=compiler; | |||
| this.compilerName = compiler; | |||
| } | |||
| /** | |||
| @@ -393,33 +393,33 @@ public class JspC extends MatchingTask | |||
| JspCompilerAdapterFactory.getCompiler(compilerName, this); | |||
| // if the compiler does its own dependency stuff, we just call it right now | |||
| if(compiler.implementsOwnDependencyChecking()) { | |||
| if (compiler.implementsOwnDependencyChecking()) { | |||
| doCompilation(compiler); | |||
| return; | |||
| } | |||
| //the remainder of this method is only for compilers that need their dependency work done | |||
| JspMangler mangler=compiler.createMangler(); | |||
| JspMangler mangler = compiler.createMangler(); | |||
| // scan source directories and dest directory to build up both copy | |||
| // lists and compile lists | |||
| resetFileLists(); | |||
| int filecount=0; | |||
| int filecount = 0; | |||
| for (int i = 0; i < list.length; i++) { | |||
| File srcDir = (File)project.resolveFile(list[i]); | |||
| File srcDir = (File) project.resolveFile(list[i]); | |||
| if (!srcDir.exists()) { | |||
| throw new BuildException("srcdir \"" + srcDir.getPath() + | |||
| "\" does not exist!", location); | |||
| } | |||
| DirectoryScanner ds = this.getDirectoryScanner(srcDir); | |||
| String[] files = ds.getIncludedFiles(); | |||
| filecount=files.length; | |||
| filecount = files.length; | |||
| scanDir(srcDir, dest, mangler, files); | |||
| } | |||
| // compile the source files | |||
| log("compiling "+compileList.size()+" files",Project.MSG_VERBOSE); | |||
| log("compiling " + compileList.size() + " files", Project.MSG_VERBOSE); | |||
| if (compileList.size() > 0) { | |||
| @@ -431,11 +431,11 @@ public class JspC extends MatchingTask | |||
| } | |||
| else { | |||
| if(filecount==0) { | |||
| log("there were no files to compile",Project.MSG_INFO); | |||
| if (filecount == 0) { | |||
| log("there were no files to compile", Project.MSG_INFO); | |||
| } | |||
| else { | |||
| log("all files are up to date",Project.MSG_VERBOSE); | |||
| log("all files are up to date", Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| } | |||
| @@ -462,7 +462,7 @@ public class JspC extends MatchingTask | |||
| private void doCompilation(JspCompilerAdapter compiler) | |||
| throws BuildException { | |||
| // now we need to populate the compiler adapter | |||
| compiler.setJspc( this ); | |||
| compiler.setJspc(this); | |||
| // finally, lets execute the compiler!! | |||
| if (!compiler.execute()) { | |||
| @@ -493,17 +493,17 @@ public class JspC extends MatchingTask | |||
| long now = (new Date()).getTime(); | |||
| for (int i = 0; i < files.length; i++) { | |||
| String filename=files[i]; | |||
| String filename = files[i]; | |||
| File srcFile = new File(srcDir, filename); | |||
| File javaFile=mapToJavaFile(mangler,srcFile, srcDir, dest); | |||
| File javaFile = mapToJavaFile(mangler, srcFile, srcDir, dest); | |||
| if (srcFile.lastModified() > now) { | |||
| log("Warning: file modified in the future: " +filename, | |||
| Project.MSG_WARN); | |||
| log("Warning: file modified in the future: " + filename, | |||
| Project.MSG_WARN); | |||
| } | |||
| boolean shouldCompile=false; | |||
| shouldCompile=isCompileNeeded(srcFile, javaFile); | |||
| if(shouldCompile) { | |||
| boolean shouldCompile = false; | |||
| shouldCompile = isCompileNeeded(srcFile, javaFile); | |||
| if (shouldCompile) { | |||
| compileList.addElement(srcFile.getAbsolutePath()); | |||
| javaFiles.addElement(javaFile); | |||
| } | |||
| @@ -527,25 +527,25 @@ public class JspC extends MatchingTask | |||
| * | |||
| */ | |||
| private boolean isCompileNeeded(File srcFile, File javaFile) { | |||
| boolean shouldCompile=false; | |||
| boolean shouldCompile = false; | |||
| if (!javaFile.exists()) { | |||
| shouldCompile=true; | |||
| log("Compiling " + srcFile.getPath() + | |||
| " because java file "+ javaFile.getPath() + " does not exist", | |||
| Project.MSG_VERBOSE); | |||
| shouldCompile = true; | |||
| log("Compiling " + srcFile.getPath() | |||
| + " because java file " + javaFile.getPath() | |||
| + " does not exist", Project.MSG_VERBOSE); | |||
| } else { | |||
| if( srcFile.lastModified() > javaFile.lastModified()) { | |||
| shouldCompile=true; | |||
| log("Compiling " + srcFile.getPath() + | |||
| " because it is out of date with respect to " + javaFile.getPath(), | |||
| if (srcFile.lastModified() > javaFile.lastModified()) { | |||
| shouldCompile = true; | |||
| log("Compiling " + srcFile.getPath() | |||
| + " because it is out of date with respect to " | |||
| + javaFile.getPath(), | |||
| Project.MSG_VERBOSE); | |||
| } else { | |||
| if( javaFile.length()==0) { | |||
| shouldCompile=true; | |||
| log("Compiling " + srcFile.getPath() + | |||
| " because java file "+ javaFile.getPath() | |||
| + " is empty", | |||
| Project.MSG_VERBOSE); | |||
| if (javaFile.length() == 0) { | |||
| shouldCompile = true; | |||
| log("Compiling " + srcFile.getPath() | |||
| + " because java file " + javaFile.getPath() | |||
| + " is empty", Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| } | |||
| @@ -561,9 +561,9 @@ public class JspC extends MatchingTask | |||
| if (!srcFile.getName().endsWith(".jsp")) { | |||
| return null; | |||
| } | |||
| String javaFileName=mangler.mapJspToJavaName(srcFile); | |||
| String javaFileName = mangler.mapJspToJavaName(srcFile); | |||
| // String srcFileDir=srcFile.getParent(); | |||
| String packageNameIn=srcFile.getAbsolutePath(); | |||
| String packageNameIn = srcFile.getAbsolutePath(); | |||
| return new File(dest, javaFileName); | |||
| } | |||
| @@ -573,12 +573,12 @@ public class JspC extends MatchingTask | |||
| * fails, it leaves incomplete files around. | |||
| */ | |||
| public void deleteEmptyJavaFiles() { | |||
| if(javaFiles!=null) { | |||
| if (javaFiles != null) { | |||
| Enumeration enum = javaFiles.elements(); | |||
| while (enum.hasMoreElements()) { | |||
| File file = (File )enum.nextElement(); | |||
| if(file.exists() && file.length()==0) { | |||
| log("deleting empty output file "+file); | |||
| File file = (File) enum.nextElement(); | |||
| if (file.exists() && file.length() == 0) { | |||
| log("deleting empty output file " + file); | |||
| file.delete(); | |||
| } | |||
| } | |||
| @@ -607,7 +607,7 @@ public class JspC extends MatchingTask | |||
| * set directory; alternate syntax | |||
| */ | |||
| public void setBaseDir(File directory) { | |||
| this.directory=directory; | |||
| this.directory = directory; | |||
| } | |||
| //end inner class | |||
| } | |||
| @@ -146,7 +146,8 @@ public class WLJspc extends MatchingTask | |||
| String systemClassPath = System.getProperty("java.class.path"); | |||
| pathToPackage = this.destinationPackage.replace('.',File.separatorChar); | |||
| pathToPackage | |||
| = this.destinationPackage.replace('.', File.separatorChar); | |||
| // get all the files in the sourceDirectory | |||
| DirectoryScanner ds = super.getDirectoryScanner(sourceDirectory); | |||
| @@ -162,7 +163,7 @@ public class WLJspc extends MatchingTask | |||
| // Therefore, takes loads of time | |||
| // Can pass directories at a time (*.jsp) but easily runs out of memory on hefty dirs | |||
| // (even on a Sun) | |||
| Java helperTask = (Java)project.createTask("java"); | |||
| Java helperTask = (Java) project.createTask("java"); | |||
| helperTask.setFork(true); | |||
| helperTask.setClassname("weblogic.jspc"); | |||
| helperTask.setTaskName(getTaskName()); | |||
| @@ -171,7 +172,7 @@ public class WLJspc extends MatchingTask | |||
| File jspFile = null; | |||
| String parents = ""; | |||
| String arg = ""; | |||
| int j=0; | |||
| int j = 0; | |||
| //XXX this array stuff is a remnant of prev trials.. gotta remove. | |||
| args[j++] = "-d"; | |||
| args[j++] = destinationDirectory.getAbsolutePath().trim(); | |||
| @@ -189,9 +190,9 @@ public class WLJspc extends MatchingTask | |||
| args[j++] = compileClasspath.toString(); | |||
| this.scanDir(files); | |||
| log("Compiling "+filesToDo.size() + " JSP files"); | |||
| log("Compiling " + filesToDo.size() + " JSP files"); | |||
| for (int i=0;i<filesToDo.size();i++) { | |||
| for (int i = 0; i < filesToDo.size(); i++) { | |||
| //XXX | |||
| // All this to get package according to weblogic standards | |||
| // Can be written better... this is too hacky! | |||
| @@ -200,18 +201,19 @@ public class WLJspc extends MatchingTask | |||
| args[j] = "-package"; | |||
| parents = jspFile.getParent(); | |||
| if ((parents != null) && (!("").equals(parents))) { | |||
| parents = this.replaceString(parents,File.separator,"_."); | |||
| args[j+1] = destinationPackage +"."+ "_"+parents; | |||
| }else { | |||
| args[j+1] = destinationPackage; | |||
| parents = this.replaceString(parents, File.separator, "_."); | |||
| args[j + 1] = destinationPackage + "." + "_" + parents; | |||
| } else { | |||
| args[j + 1] = destinationPackage; | |||
| } | |||
| args[j+2] = sourceDirectory+File.separator+(String) filesToDo.elementAt(i); | |||
| arg=""; | |||
| args[j + 2] = sourceDirectory + File.separator | |||
| + (String) filesToDo.elementAt(i); | |||
| arg = ""; | |||
| for (int x=0;x<12;x++) { | |||
| arg += " "+ args[x]; | |||
| for (int x = 0; x < 12; x++) { | |||
| arg += " " + args[x]; | |||
| } | |||
| System.out.println("arg = " + arg); | |||
| @@ -220,7 +222,7 @@ public class WLJspc extends MatchingTask | |||
| helperTask.setArgs(arg); | |||
| helperTask.setClasspath(compileClasspath); | |||
| if (helperTask.executeJava() != 0) { | |||
| log(files[i] + " failed to compile",Project.MSG_WARN) ; | |||
| log(files[i] + " failed to compile", Project.MSG_WARN); | |||
| } | |||
| } | |||
| } | |||
| @@ -278,7 +280,7 @@ public class WLJspc extends MatchingTask | |||
| */ | |||
| public void setPackage(String packageName) { | |||
| destinationPackage=packageName; | |||
| destinationPackage = packageName; | |||
| } | |||
| @@ -296,12 +298,12 @@ public class WLJspc extends MatchingTask | |||
| // Can be written better... this is too hacky! | |||
| jspFile = new File(files[i]); | |||
| parents = jspFile.getParent(); | |||
| int loc=0; | |||
| int loc = 0; | |||
| if ((parents != null) && (!("").equals(parents))) { | |||
| parents = this.replaceString(parents,File.separator,"_/"); | |||
| pack = pathToPackage +File.separator+ "_"+parents; | |||
| }else { | |||
| parents = this.replaceString(parents, File.separator, "_/"); | |||
| pack = pathToPackage + File.separator + "_" + parents; | |||
| } else { | |||
| pack = pathToPackage; | |||
| } | |||
| @@ -324,22 +326,22 @@ public class WLJspc extends MatchingTask | |||
| if (srcFile.lastModified() > classFile.lastModified()) { | |||
| //log("Files are" + srcFile.getAbsolutePath()+" " +classFile.getAbsolutePath()); | |||
| filesToDo.addElement(files[i]); | |||
| log("Recompiling File "+files[i],Project.MSG_VERBOSE); | |||
| log("Recompiling File " + files[i], Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| } | |||
| protected String replaceString(String inpString,String escapeChars,String replaceChars) { | |||
| String localString=""; | |||
| int numTokens=0; | |||
| StringTokenizer st=new StringTokenizer(inpString,escapeChars,true); | |||
| numTokens=st.countTokens(); | |||
| for(int i=0;i<numTokens;i++) | |||
| { | |||
| String test=st.nextToken(); | |||
| test=(test.equals(escapeChars)?replaceChars:test); | |||
| localString+=test; | |||
| protected String replaceString(String inpString, String escapeChars, | |||
| String replaceChars) { | |||
| String localString = ""; | |||
| int numTokens = 0; | |||
| StringTokenizer st = new StringTokenizer(inpString, escapeChars, true); | |||
| numTokens = st.countTokens(); | |||
| for (int i = 0; i < numTokens; i++) { | |||
| String test = st.nextToken(); | |||
| test = (test.equals(escapeChars) ? replaceChars : test); | |||
| localString += test; | |||
| } | |||
| return localString; | |||
| } | |||
| @@ -97,7 +97,7 @@ public abstract class DefaultJspCompilerAdapter | |||
| Enumeration enum = compileList.elements(); | |||
| while (enum.hasMoreElements()) { | |||
| String arg = (String)enum.nextElement(); | |||
| String arg = (String) enum.nextElement(); | |||
| cmd.createArgument().setValue(arg); | |||
| niceSourceList.append(" " + arg + lSep); | |||
| } | |||
| @@ -113,7 +113,7 @@ public abstract class DefaultJspCompilerAdapter | |||
| /** | |||
| * set the owner | |||
| */ | |||
| public void setJspc( JspC owner ) { | |||
| public void setJspc(JspC owner) { | |||
| this.owner = owner; | |||
| } | |||
| @@ -130,8 +130,8 @@ public abstract class DefaultJspCompilerAdapter | |||
| * | |||
| * @param argument The argument | |||
| */ | |||
| protected void addArg(Commandline cmd,String argument) { | |||
| if(argument != null && argument.length() != 0) { | |||
| protected void addArg(Commandline cmd, String argument) { | |||
| if (argument != null && argument.length() != 0) { | |||
| cmd.createArgument().setValue(argument); | |||
| } | |||
| } | |||
| @@ -144,7 +144,7 @@ public abstract class DefaultJspCompilerAdapter | |||
| * @param value the parameter | |||
| */ | |||
| protected void addArg(Commandline cmd, String argument, String value) { | |||
| if(value!= null) { | |||
| if (value != null) { | |||
| cmd.createArgument().setValue(argument); | |||
| cmd.createArgument().setValue(value); | |||
| } | |||
| @@ -157,7 +157,7 @@ public abstract class DefaultJspCompilerAdapter | |||
| * @param file the parameter | |||
| */ | |||
| protected void addArg(Commandline cmd, String argument, File file) { | |||
| if(file != null) { | |||
| if (file != null) { | |||
| cmd.createArgument().setValue(argument); | |||
| cmd.createArgument().setFile(file); | |||
| } | |||
| @@ -87,7 +87,7 @@ public class JasperC extends DefaultJspCompilerAdapter | |||
| // Create an instance of the compiler, redirecting output to | |||
| // the project log | |||
| // REVISIT. ugly. | |||
| Java java = (Java)(getJspc().getProject()).createTask("java"); | |||
| Java java = (Java) (getJspc().getProject()).createTask("java"); | |||
| if (getJspc().getClasspath() != null) { | |||
| java.setClasspath(getJspc().getClasspath()); | |||
| } | |||
| @@ -96,7 +96,7 @@ public class JasperC extends DefaultJspCompilerAdapter | |||
| } | |||
| java.setClassname("org.apache.jasper.JspC"); | |||
| String args[] = cmd.getArguments(); | |||
| for (int i =0; i < args.length; i++) { | |||
| for (int i = 0; i < args.length; i++) { | |||
| java.createArg().setValue(args[i]); | |||
| } | |||
| java.setFailonerror(getJspc().getFailonerror()); | |||
| @@ -129,20 +129,20 @@ public class JasperC extends DefaultJspCompilerAdapter | |||
| private Commandline setupJasperCommand() { | |||
| Commandline cmd = new Commandline(); | |||
| JspC jspc = getJspc(); | |||
| addArg(cmd,"-d",jspc.getDestdir()); | |||
| addArg(cmd,"-p",jspc.getPackage()); | |||
| addArg(cmd,"-v"+jspc.getVerbose()); | |||
| addArg(cmd,"-uriroot",jspc.getUriroot()); | |||
| addArg(cmd,"-uribase",jspc.getUribase()); | |||
| addArg(cmd,"-ieplugin",jspc.getIeplugin()); | |||
| addArg(cmd,"-die9"); | |||
| addArg(cmd, "-d", jspc.getDestdir()); | |||
| addArg(cmd, "-p", jspc.getPackage()); | |||
| addArg(cmd, "-v" + jspc.getVerbose()); | |||
| addArg(cmd, "-uriroot", jspc.getUriroot()); | |||
| addArg(cmd, "-uribase", jspc.getUribase()); | |||
| addArg(cmd, "-ieplugin", jspc.getIeplugin()); | |||
| addArg(cmd, "-die9"); | |||
| if (jspc.isMapped()){ | |||
| addArg(cmd,"-mapped"); | |||
| addArg(cmd, "-mapped"); | |||
| } | |||
| if(jspc.getWebApp()!=null) { | |||
| File dir=jspc.getWebApp().getDirectory(); | |||
| addArg(cmd,"-webapp",dir); | |||
| if (jspc.getWebApp() != null) { | |||
| File dir = jspc.getWebApp().getDirectory(); | |||
| addArg(cmd, "-webapp", dir); | |||
| } | |||
| logAndAddFilesToCompile(getJspc(), getJspc().getCompileList(), cmd); | |||
| return cmd; | |||
| @@ -76,7 +76,7 @@ public interface JspCompilerAdapter { | |||
| /** | |||
| * Sets the compiler attributes, which are stored in the Jspc task. | |||
| */ | |||
| void setJspc( JspC attributes ); | |||
| void setJspc(JspC attributes); | |||
| /** | |||
| * Executes the task. | |||
| @@ -85,15 +85,15 @@ public class JspCompilerAdapterFactory { | |||
| * @throws BuildException if the compiler type could not be resolved into | |||
| * a compiler adapter. | |||
| */ | |||
| public static JspCompilerAdapter getCompiler( String compilerType, Task task ) | |||
| public static JspCompilerAdapter getCompiler(String compilerType, Task task) | |||
| throws BuildException { | |||
| /* If I've done things right, this should be the extent of the | |||
| * conditional statements required. | |||
| */ | |||
| if ( compilerType.equalsIgnoreCase("jasper") ) { | |||
| if (compilerType.equalsIgnoreCase("jasper")) { | |||
| return new JasperC(); | |||
| } | |||
| return resolveClassName( compilerType ); | |||
| return resolveClassName(compilerType); | |||
| } | |||
| /** | |||
| @@ -104,18 +104,18 @@ public class JspCompilerAdapterFactory { | |||
| * @throws BuildException This is the fit that is thrown if className | |||
| * isn't an instance of JspCompilerAdapter. | |||
| */ | |||
| private static JspCompilerAdapter resolveClassName( String className ) | |||
| private static JspCompilerAdapter resolveClassName(String className) | |||
| throws BuildException { | |||
| try { | |||
| Class c = Class.forName( className ); | |||
| Class c = Class.forName(className); | |||
| Object o = c.newInstance(); | |||
| return (JspCompilerAdapter) o; | |||
| } catch ( ClassNotFoundException cnfe ) { | |||
| throw new BuildException( className + " can\'t be found.", cnfe ); | |||
| } catch ( ClassCastException cce ) { | |||
| } catch (ClassNotFoundException cnfe) { | |||
| throw new BuildException(className + " can\'t be found.", cnfe); | |||
| } catch (ClassCastException cce) { | |||
| throw new BuildException(className + " isn\'t the classname of " | |||
| + "a compiler adapter.", cce); | |||
| } catch ( Throwable t ) { | |||
| } catch (Throwable t) { | |||
| // for all other possibilities | |||
| throw new BuildException(className + " caused an interesting " | |||
| + "exception.", t); | |||
| @@ -199,7 +199,7 @@ public class AggregateTransformer { | |||
| // set the destination directory relative from the project if needed. | |||
| if (toDir == null) { | |||
| toDir = task.getProject().resolveFile("."); | |||
| } else if ( !toDir.isAbsolute() ) { | |||
| } else if (!toDir.isAbsolute()) { | |||
| toDir = task.getProject().resolveFile(toDir.getPath()); | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -122,7 +122,7 @@ public final class BatchTest extends BaseTest { | |||
| */ | |||
| final void addTestsTo(Vector v){ | |||
| JUnitTest[] tests = createAllJUnitTest(); | |||
| v.ensureCapacity( v.size() + tests.length); | |||
| v.ensureCapacity(v.size() + tests.length); | |||
| for (int i = 0; i < tests.length; i++) { | |||
| v.addElement(tests[i]); | |||
| } | |||
| @@ -156,7 +156,7 @@ public final class BatchTest extends BaseTest { | |||
| private String[] getFilenames(){ | |||
| Vector v = new Vector(); | |||
| final int size = this.filesets.size(); | |||
| for (int j=0; j<size; j++) { | |||
| for (int j = 0; j < size; j++) { | |||
| FileSet fs = (FileSet) filesets.elementAt(j); | |||
| DirectoryScanner ds = fs.getDirectoryScanner(project); | |||
| ds.scan(); | |||
| @@ -164,9 +164,9 @@ public final class BatchTest extends BaseTest { | |||
| for (int k = 0; k < f.length; k++) { | |||
| String pathname = f[k]; | |||
| if (pathname.endsWith(".java")) { | |||
| v.addElement(pathname.substring(0, pathname.length()-".java".length())); | |||
| v.addElement(pathname.substring(0, pathname.length() - ".java".length())); | |||
| } else if (pathname.endsWith(".class")) { | |||
| v.addElement(pathname.substring(0, pathname.length()-".class".length())); | |||
| v.addElement(pathname.substring(0, pathname.length() - ".class".length())); | |||
| } | |||
| } | |||
| } | |||
| @@ -208,7 +208,7 @@ public final class BatchTest extends BaseTest { | |||
| test.setErrorProperty(errorProperty); | |||
| Enumeration list = this.formatters.elements(); | |||
| while (list.hasMoreElements()) { | |||
| test.addFormatter((FormatterElement)list.nextElement()); | |||
| test.addFormatter((FormatterElement) list.nextElement()); | |||
| } | |||
| return test; | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -114,7 +114,7 @@ public final class DOMUtil { | |||
| NodeList recmatches = listChildNodes(child, filter, recurse); | |||
| final int reclength = matches.getLength(); | |||
| for (int j = 0; j < reclength; j++) { | |||
| matches.addElement( recmatches.item(i) ); | |||
| matches.addElement(recmatches.item(i)); | |||
| } | |||
| } | |||
| } | |||
| @@ -129,7 +129,7 @@ public final class DOMUtil { | |||
| } | |||
| public Node item(int i){ | |||
| try { | |||
| return (Node)elementAt(i); | |||
| return (Node) elementAt(i); | |||
| } catch (ArrayIndexOutOfBoundsException e){ | |||
| return null; // conforming to NodeList interface | |||
| } | |||
| @@ -145,7 +145,7 @@ public final class DOMUtil { | |||
| */ | |||
| public static String getNodeAttribute(Node node, String name) { | |||
| if (node instanceof Element) { | |||
| Element element = (Element)node; | |||
| Element element = (Element) node; | |||
| return element.getAttribute(name); | |||
| } | |||
| return null; | |||
| @@ -169,9 +169,9 @@ public final class DOMUtil { | |||
| final int len = childList.getLength(); | |||
| for (int i = 0; i < len; i++) { | |||
| Node child = childList.item(i); | |||
| if ( child != null && child.getNodeType() == Node.ELEMENT_NODE && | |||
| if (child != null && child.getNodeType() == Node.ELEMENT_NODE && | |||
| child.getNodeName().equals(tagname)) { | |||
| return (Element)child; | |||
| return (Element) child; | |||
| } | |||
| } | |||
| return null; | |||
| @@ -204,10 +204,10 @@ public final class DOMUtil { | |||
| copy = doc.createDocumentFragment(); | |||
| break; | |||
| case Node.ELEMENT_NODE: | |||
| final Element elem = doc.createElement(((Element)child).getTagName()); | |||
| final Element elem = doc.createElement(((Element) child).getTagName()); | |||
| copy = elem; | |||
| final NamedNodeMap attributes = child.getAttributes(); | |||
| if ( attributes != null) { | |||
| if (attributes != null) { | |||
| final int size = attributes.getLength(); | |||
| for (int i = 0; i < size; i++) { | |||
| final Attr attr = (Attr) attributes.item(i); | |||
| @@ -219,7 +219,7 @@ public final class DOMUtil { | |||
| copy = doc.createEntityReference(child.getNodeName()); | |||
| break; | |||
| case Node.PROCESSING_INSTRUCTION_NODE: | |||
| final ProcessingInstruction pi = (ProcessingInstruction)child; | |||
| final ProcessingInstruction pi = (ProcessingInstruction) child; | |||
| copy = doc.createProcessingInstruction(pi.getTarget(), pi.getData()); | |||
| break; | |||
| case Node.TEXT_NODE: | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -206,7 +206,7 @@ class ArrayEnumeration implements Enumeration { | |||
| * @throws NoSuchElementException if no more elements exist. | |||
| */ | |||
| public Object nextElement() throws NoSuchElementException { | |||
| if ( hasMoreElements() ) { | |||
| if (hasMoreElements()) { | |||
| return enumArray[index].nextElement(); | |||
| } | |||
| throw new NoSuchElementException(); | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -195,7 +195,8 @@ public class FormatterElement { | |||
| } | |||
| if (!(o instanceof JUnitResultFormatter)) { | |||
| throw new BuildException(classname+" is not a JUnitResultFormatter"); | |||
| throw new BuildException(classname | |||
| + " is not a JUnitResultFormatter"); | |||
| } | |||
| JUnitResultFormatter r = (JUnitResultFormatter) o; | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -78,15 +78,15 @@ public interface JUnitResultFormatter extends TestListener { | |||
| /** | |||
| * Sets the stream the formatter is supposed to write its results to. | |||
| */ | |||
| void setOutput( OutputStream out ); | |||
| void setOutput(OutputStream out); | |||
| /** | |||
| * This is what the test has written to System.out | |||
| */ | |||
| void setSystemOutput( String out ); | |||
| void setSystemOutput(String out); | |||
| /** | |||
| * This is what the test has written to System.err | |||
| */ | |||
| void setSystemError( String err ); | |||
| void setSystemError(String err); | |||
| } | |||
| @@ -499,8 +499,8 @@ public class JUnitTask extends Task { | |||
| public void execute() throws BuildException { | |||
| Enumeration list = getIndividualTests(); | |||
| while (list.hasMoreElements()) { | |||
| JUnitTest test = (JUnitTest)list.nextElement(); | |||
| if ( test.shouldRun(project)) { | |||
| JUnitTest test = (JUnitTest) list.nextElement(); | |||
| if (test.shouldRun(project)) { | |||
| execute(test); | |||
| } | |||
| } | |||
| @@ -518,7 +518,7 @@ public class JUnitTask extends Task { | |||
| } | |||
| if (test.getOutfile() == null) { | |||
| test.setOutfile( "TEST-" + test.getName() ); | |||
| test.setOutfile("TEST-" + test.getName()); | |||
| } | |||
| // execute the test and get the return code | |||
| @@ -542,11 +542,10 @@ public class JUnitTask extends Task { | |||
| if (errorOccurredHere || failureOccurredHere) { | |||
| if ((errorOccurredHere && test.getHaltonerror()) | |||
| || (failureOccurredHere && test.getHaltonfailure())) { | |||
| throw new BuildException("Test "+test.getName()+" failed" | |||
| +(wasKilled ? " (timeout)" : ""), | |||
| location); | |||
| throw new BuildException("Test " + test.getName() + " failed" | |||
| + (wasKilled ? " (timeout)" : ""), location); | |||
| } else { | |||
| log("TEST "+test.getName()+" FAILED" | |||
| log("TEST " + test.getName() + " FAILED" | |||
| + (wasKilled ? " (timeout)" : ""), Project.MSG_ERR); | |||
| if (errorOccurredHere && test.getErrorProperty() != null) { | |||
| project.setNewProperty(test.getErrorProperty(), "true"); | |||
| @@ -579,7 +578,7 @@ public class JUnitTask extends Task { | |||
| cmd.createArgument().setValue("haltOnFailure=" | |||
| + test.getHaltonfailure()); | |||
| if (includeAntRuntime) { | |||
| log("Implicitly adding "+antRuntimeClasses+" to CLASSPATH", | |||
| log("Implicitly adding " + antRuntimeClasses + " to CLASSPATH", | |||
| Project.MSG_VERBOSE); | |||
| cmd.createClasspath(getProject()).createPath() | |||
| .append(antRuntimeClasses); | |||
| @@ -597,10 +596,10 @@ public class JUnitTask extends Task { | |||
| FormatterElement fe = feArray[i]; | |||
| formatterArg.append("formatter="); | |||
| formatterArg.append(fe.getClassname()); | |||
| File outFile = getOutput(fe,test); | |||
| File outFile = getOutput(fe, test); | |||
| if (outFile != null) { | |||
| formatterArg.append(","); | |||
| formatterArg.append( outFile ); | |||
| formatterArg.append(outFile); | |||
| } | |||
| cmd.createArgument().setValue(formatterArg.toString()); | |||
| formatterArg.setLength(0); | |||
| @@ -615,13 +614,13 @@ public class JUnitTask extends Task { | |||
| + propsFile.getAbsolutePath()); | |||
| Hashtable p = project.getProperties(); | |||
| Properties props = new Properties(); | |||
| for (Enumeration enum = p.keys(); enum.hasMoreElements(); ) { | |||
| for (Enumeration enum = p.keys(); enum.hasMoreElements();) { | |||
| Object key = enum.nextElement(); | |||
| props.put(key, p.get(key)); | |||
| } | |||
| try { | |||
| FileOutputStream outstream = new FileOutputStream(propsFile); | |||
| props.save(outstream,"Ant JUnitTask generated properties file"); | |||
| props.save(outstream, "Ant JUnitTask generated properties file"); | |||
| outstream.close(); | |||
| } catch (java.io.IOException e) { | |||
| propsFile.delete(); | |||
| @@ -641,15 +640,15 @@ public class JUnitTask extends Task { | |||
| String[] environment = env.getVariables(); | |||
| if (environment != null) { | |||
| for (int i=0; i<environment.length; i++) { | |||
| log("Setting environment variable: "+environment[i], | |||
| for (int i = 0; i < environment.length; i++) { | |||
| log("Setting environment variable: " + environment[i], | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| execute.setNewenvironment(newEnvironment); | |||
| execute.setEnvironment(environment); | |||
| log("Executing: "+cmd.toString(), Project.MSG_VERBOSE); | |||
| log("Executing: " + cmd.toString(), Project.MSG_VERBOSE); | |||
| int retVal; | |||
| try { | |||
| retVal = execute.execute(); | |||
| @@ -725,7 +724,7 @@ public class JUnitTask extends Task { | |||
| Project.MSG_VERBOSE); | |||
| Path classpath = (Path) commandline.getClasspath().clone(); | |||
| if (includeAntRuntime) { | |||
| log("Implicitly adding "+antRuntimeClasses+" to CLASSPATH", | |||
| log("Implicitly adding " + antRuntimeClasses + " to CLASSPATH", | |||
| Project.MSG_VERBOSE); | |||
| classpath.append(antRuntimeClasses); | |||
| } | |||
| @@ -750,19 +749,19 @@ public class JUnitTask extends Task { | |||
| SummaryJUnitResultFormatter f = | |||
| new SummaryJUnitResultFormatter(); | |||
| f.setWithOutAndErr("withoutanderr" | |||
| .equalsIgnoreCase( summaryValue )); | |||
| f.setOutput( getDefaultOutput() ); | |||
| .equalsIgnoreCase(summaryValue)); | |||
| f.setOutput(getDefaultOutput()); | |||
| runner.addFormatter(f); | |||
| } | |||
| final FormatterElement[] feArray = mergeFormatters(test); | |||
| for (int i = 0; i < feArray.length; i++) { | |||
| FormatterElement fe = feArray[i]; | |||
| File outFile = getOutput(fe,test); | |||
| File outFile = getOutput(fe, test); | |||
| if (outFile != null) { | |||
| fe.setOutfile(outFile); | |||
| } else { | |||
| fe.setOutput( getDefaultOutput() ); | |||
| fe.setOutput(getDefaultOutput()); | |||
| } | |||
| runner.addFormatter(fe.createFormatter()); | |||
| } | |||
| @@ -809,7 +808,7 @@ public class JUnitTask extends Task { | |||
| final int count = batchTests.size(); | |||
| final Enumeration[] enums = new Enumeration[ count + 1]; | |||
| for (int i = 0; i < count; i++) { | |||
| BatchTest batchtest = (BatchTest)batchTests.elementAt(i); | |||
| BatchTest batchtest = (BatchTest) batchTests.elementAt(i); | |||
| enums[i] = batchtest.elements(); | |||
| } | |||
| enums[enums.length - 1] = tests.elements(); | |||
| @@ -828,7 +827,7 @@ public class JUnitTask extends Task { | |||
| * @since Ant 1.3 | |||
| */ | |||
| private FormatterElement[] mergeFormatters(JUnitTest test){ | |||
| Vector feVector = (Vector)formatters.clone(); | |||
| Vector feVector = (Vector) formatters.clone(); | |||
| test.addFormattersTo(feVector); | |||
| FormatterElement[] feArray = new FormatterElement[feVector.size()]; | |||
| feVector.copyInto(feArray); | |||
| @@ -844,7 +843,7 @@ public class JUnitTask extends Task { | |||
| protected File getOutput(FormatterElement fe, JUnitTest test){ | |||
| if (fe.getUseFile()) { | |||
| String filename = test.getOutfile() + fe.getExtension(); | |||
| File destFile = new File( test.getTodir(), filename ); | |||
| File destFile = new File(test.getTodir(), filename); | |||
| String absFilename = destFile.getAbsolutePath(); | |||
| return project.resolveFile(absFilename); | |||
| } | |||
| @@ -867,23 +866,23 @@ public class JUnitTask extends Task { | |||
| if (u.startsWith("jar:file:")) { | |||
| int pling = u.indexOf("!"); | |||
| String jarName = u.substring(9, pling); | |||
| log("Found "+jarName, Project.MSG_DEBUG); | |||
| log("Found " + jarName, Project.MSG_DEBUG); | |||
| antRuntimeClasses.createPath() | |||
| .setLocation(new File((new File(jarName)) | |||
| .getAbsolutePath())); | |||
| } else if (u.startsWith("file:")) { | |||
| int tail = u.indexOf(resource); | |||
| String dirName = u.substring(5, tail); | |||
| log("Found "+dirName, Project.MSG_DEBUG); | |||
| log("Found " + dirName, Project.MSG_DEBUG); | |||
| antRuntimeClasses.createPath() | |||
| .setLocation(new File((new File(dirName)) | |||
| .getAbsolutePath())); | |||
| } else { | |||
| log("Don\'t know how to handle resource URL "+u, | |||
| log("Don\'t know how to handle resource URL " + u, | |||
| Project.MSG_DEBUG); | |||
| } | |||
| } else { | |||
| log("Couldn\'t find "+resource, Project.MSG_DEBUG); | |||
| log("Couldn\'t find " + resource, Project.MSG_DEBUG); | |||
| } | |||
| } | |||
| @@ -148,15 +148,29 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| this.runTime = runTime; | |||
| } | |||
| public long runCount() {return runs;} | |||
| public long failureCount() {return failures;} | |||
| public long errorCount() {return errors;} | |||
| public long getRunTime() {return runTime;} | |||
| public long runCount() { | |||
| return runs; | |||
| } | |||
| public long failureCount() { | |||
| return failures; | |||
| } | |||
| public long errorCount() { | |||
| return errors; | |||
| } | |||
| public long getRunTime() { | |||
| return runTime; | |||
| } | |||
| public Properties getProperties() { return props;} | |||
| public Properties getProperties() { | |||
| return props; | |||
| } | |||
| public void setProperties(Hashtable p) { | |||
| props = new Properties(); | |||
| for (Enumeration enum = p.keys(); enum.hasMoreElements(); ) { | |||
| for (Enumeration enum = p.keys(); enum.hasMoreElements();) { | |||
| Object key = enum.nextElement(); | |||
| props.put(key, p.get(key)); | |||
| } | |||
| @@ -185,7 +199,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| void addFormattersTo(Vector v){ | |||
| final int count = formatters.size(); | |||
| for (int i = 0; i < count; i++){ | |||
| v.addElement( formatters.elementAt(i) ); | |||
| v.addElement(formatters.elementAt(i)); | |||
| } | |||
| } | |||
| @@ -214,8 +214,8 @@ public class JUnitTestRunner implements TestListener { | |||
| Method suiteMethod = null; | |||
| try { | |||
| // check if there is a suite method | |||
| suiteMethod= testClass.getMethod("suite", new Class[0]); | |||
| } catch(Exception e) { | |||
| suiteMethod = testClass.getMethod("suite", new Class[0]); | |||
| } catch (Exception e) { | |||
| // no appropriate suite method found. We don't report any | |||
| // error here since it might be perfectly normal. We don't | |||
| // know exactly what is the cause, but we're doing exactly | |||
| @@ -225,14 +225,14 @@ public class JUnitTestRunner implements TestListener { | |||
| // if there is a suite method available, then try | |||
| // to extract the suite from it. If there is an error | |||
| // here it will be caught below and reported. | |||
| suite = (Test)suiteMethod.invoke(null, new Class[0]); | |||
| suite = (Test) suiteMethod.invoke(null, new Class[0]); | |||
| } else { | |||
| // try to extract a test suite automatically | |||
| // this will generate warnings if the class is no suitable Test | |||
| suite= new TestSuite(testClass); | |||
| suite = new TestSuite(testClass); | |||
| } | |||
| } catch(Exception e) { | |||
| } catch (Exception e) { | |||
| retCode = ERRORS; | |||
| exception = e; | |||
| } | |||
| @@ -241,16 +241,16 @@ public class JUnitTestRunner implements TestListener { | |||
| public void run() { | |||
| res = new TestResult(); | |||
| res.addListener(this); | |||
| for (int i=0; i < formatters.size(); i++) { | |||
| res.addListener((TestListener)formatters.elementAt(i)); | |||
| for (int i = 0; i < formatters.size(); i++) { | |||
| res.addListener((TestListener) formatters.elementAt(i)); | |||
| } | |||
| long start = System.currentTimeMillis(); | |||
| fireStartTestSuite(); | |||
| if (exception != null) { // had an exception in the constructor | |||
| for (int i=0; i < formatters.size(); i++) { | |||
| ((TestListener)formatters.elementAt(i)).addError(null, | |||
| for (int i = 0; i < formatters.size(); i++) { | |||
| ((TestListener) formatters.elementAt(i)).addError(null, | |||
| exception); | |||
| } | |||
| junitTest.setCounts(1, 0, 1); | |||
| @@ -373,9 +373,9 @@ public class JUnitTestRunner implements TestListener { | |||
| } | |||
| private void sendOutAndErr(String out, String err) { | |||
| for (int i=0; i<formatters.size(); i++) { | |||
| for (int i = 0; i < formatters.size(); i++) { | |||
| JUnitResultFormatter formatter = | |||
| ((JUnitResultFormatter)formatters.elementAt(i)); | |||
| ((JUnitResultFormatter) formatters.elementAt(i)); | |||
| formatter.setSystemOutput(out); | |||
| formatter.setSystemError(err); | |||
| @@ -383,14 +383,14 @@ public class JUnitTestRunner implements TestListener { | |||
| } | |||
| private void fireStartTestSuite() { | |||
| for (int i=0; i<formatters.size(); i++) { | |||
| ((JUnitResultFormatter)formatters.elementAt(i)).startTestSuite(junitTest); | |||
| for (int i = 0; i < formatters.size(); i++) { | |||
| ((JUnitResultFormatter) formatters.elementAt(i)).startTestSuite(junitTest); | |||
| } | |||
| } | |||
| private void fireEndTestSuite() { | |||
| for (int i=0; i<formatters.size(); i++) { | |||
| ((JUnitResultFormatter)formatters.elementAt(i)).endTestSuite(junitTest); | |||
| for (int i = 0; i < formatters.size(); i++) { | |||
| ((JUnitResultFormatter) formatters.elementAt(i)).endTestSuite(junitTest); | |||
| } | |||
| } | |||
| @@ -431,7 +431,7 @@ public class JUnitTestRunner implements TestListener { | |||
| System.exit(ERRORS); | |||
| } | |||
| for (int i=1; i<args.length; i++) { | |||
| for (int i = 1; i < args.length; i++) { | |||
| if (args[i].startsWith("haltOnError=")) { | |||
| haltError = Project.toBoolean(args[i].substring(12)); | |||
| } else if (args[i].startsWith("haltOnFailure=")) { | |||
| @@ -456,7 +456,7 @@ public class JUnitTestRunner implements TestListener { | |||
| // Add/overlay system properties on the properties from the Ant project | |||
| Hashtable p = System.getProperties(); | |||
| for (Enumeration enum = p.keys(); enum.hasMoreElements(); ) { | |||
| for (Enumeration enum = p.keys(); enum.hasMoreElements();) { | |||
| Object key = enum.nextElement(); | |||
| props.put(key, p.get(key)); | |||
| } | |||
| @@ -472,7 +472,7 @@ public class JUnitTestRunner implements TestListener { | |||
| private static Vector fromCmdLine = new Vector(); | |||
| private static void transferFormatters(JUnitTestRunner runner) { | |||
| for (int i=0; i<fromCmdLine.size(); i++) { | |||
| for (int i = 0; i < fromCmdLine.size(); i++) { | |||
| runner.addFormatter((JUnitResultFormatter) fromCmdLine.elementAt(i)); | |||
| } | |||
| } | |||
| @@ -488,7 +488,7 @@ public class JUnitTestRunner implements TestListener { | |||
| fe.setClassname(line); | |||
| } else { | |||
| fe.setClassname(line.substring(0, pos)); | |||
| fe.setOutfile( new File(line.substring(pos + 1)) ); | |||
| fe.setOutfile(new File(line.substring(pos + 1))); | |||
| } | |||
| fromCmdLine.addElement(fe.createFormatter()); | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -141,24 +141,24 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { | |||
| sb.append(", Errors: "); | |||
| sb.append(suite.errorCount()); | |||
| sb.append(", Time elapsed: "); | |||
| sb.append(nf.format(suite.getRunTime()/1000.0)); | |||
| sb.append(nf.format(suite.getRunTime() / 1000.0)); | |||
| sb.append(" sec"); | |||
| sb.append(newLine); | |||
| // append the err and output streams to the log | |||
| if (systemOutput != null && systemOutput.length() > 0) { | |||
| sb.append("------------- Standard Output ---------------" ) | |||
| sb.append("------------- Standard Output ---------------") | |||
| .append(newLine) | |||
| .append(systemOutput) | |||
| .append("------------- ---------------- ---------------" ) | |||
| .append("------------- ---------------- ---------------") | |||
| .append(newLine); | |||
| } | |||
| if (systemError != null && systemError.length() > 0) { | |||
| sb.append("------------- Standard Error -----------------" ) | |||
| sb.append("------------- Standard Error -----------------") | |||
| .append(newLine) | |||
| .append(systemError) | |||
| .append("------------- ---------------- ---------------" ) | |||
| .append("------------- ---------------- ---------------") | |||
| .append(newLine); | |||
| } | |||
| @@ -206,7 +206,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { | |||
| } | |||
| Long l = (Long) testStarts.get(test); | |||
| wri.println(" took " | |||
| + nf.format((System.currentTimeMillis()-l.longValue()) | |||
| + nf.format((System.currentTimeMillis() - l.longValue()) | |||
| / 1000.0) | |||
| + " sec"); | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -120,11 +120,11 @@ public class SummaryJUnitResultFormatter implements JUnitResultFormatter { | |||
| this.out = out; | |||
| } | |||
| public void setSystemOutput( String out ) { | |||
| public void setSystemOutput(String out) { | |||
| systemOutput = out; | |||
| } | |||
| public void setSystemError( String err ) { | |||
| public void setSystemError(String err) { | |||
| systemError = err; | |||
| } | |||
| @@ -132,7 +132,7 @@ public class SummaryJUnitResultFormatter implements JUnitResultFormatter { | |||
| * Should the output to System.out and System.err be written to | |||
| * the summary. | |||
| */ | |||
| public void setWithOutAndErr( boolean value ) { | |||
| public void setWithOutAndErr(boolean value) { | |||
| withOutAndErr = value; | |||
| } | |||
| @@ -148,18 +148,18 @@ public class SummaryJUnitResultFormatter implements JUnitResultFormatter { | |||
| sb.append(", Errors: "); | |||
| sb.append(suite.errorCount()); | |||
| sb.append(", Time elapsed: "); | |||
| sb.append(nf.format(suite.getRunTime()/1000.0)); | |||
| sb.append(nf.format(suite.getRunTime() / 1000.0)); | |||
| sb.append(" sec"); | |||
| sb.append(newLine); | |||
| if (withOutAndErr) { | |||
| if (systemOutput != null && systemOutput.length() > 0) { | |||
| sb.append( "Output:" ).append(newLine).append(systemOutput) | |||
| sb.append("Output:").append(newLine).append(systemOutput) | |||
| .append(newLine); | |||
| } | |||
| if (systemError != null && systemError.length() > 0) { | |||
| sb.append( "Error: " ).append(newLine).append(systemError) | |||
| sb.append("Error: ").append(newLine).append(systemError) | |||
| .append(newLine); | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -92,7 +92,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
| try { | |||
| return DocumentBuilderFactory.newInstance().newDocumentBuilder(); | |||
| } | |||
| catch(Exception exc) { | |||
| catch (Exception exc) { | |||
| throw new ExceptionInInitializerError(exc); | |||
| } | |||
| } | |||
| @@ -160,10 +160,10 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
| * The whole testsuite ended. | |||
| */ | |||
| public void endTestSuite(JUnitTest suite) throws BuildException { | |||
| rootElement.setAttribute(ATTR_TESTS, ""+suite.runCount()); | |||
| rootElement.setAttribute(ATTR_FAILURES, ""+suite.failureCount()); | |||
| rootElement.setAttribute(ATTR_ERRORS, ""+suite.errorCount()); | |||
| rootElement.setAttribute(ATTR_TIME, ""+(suite.getRunTime()/1000.0)); | |||
| rootElement.setAttribute(ATTR_TESTS, "" + suite.runCount()); | |||
| rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); | |||
| rootElement.setAttribute(ATTR_ERRORS, "" + suite.errorCount()); | |||
| rootElement.setAttribute(ATTR_TIME, "" + (suite.getRunTime() / 1000.0)); | |||
| if (out != null) { | |||
| Writer wri = null; | |||
| try { | |||
| @@ -171,7 +171,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
| wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); | |||
| (new DOMElementWriter()).write(rootElement, wri, 0, " "); | |||
| wri.flush(); | |||
| } catch(IOException exc) { | |||
| } catch (IOException exc) { | |||
| throw new BuildException("Unable to write log file", exc); | |||
| } finally { | |||
| if (out != System.out && out != System.err) { | |||
| @@ -218,8 +218,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
| Long l = (Long) testStarts.get(test); | |||
| currentTest.setAttribute(ATTR_TIME, | |||
| ""+((System.currentTimeMillis()-l.longValue()) | |||
| / 1000.0)); | |||
| "" + ((System.currentTimeMillis() - l.longValue()) / 1000.0)); | |||
| } | |||
| /** | |||
| @@ -160,7 +160,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| File destFile = getDestinationFile(); | |||
| // write the document | |||
| try { | |||
| writeDOMTree(rootElement.getOwnerDocument(), destFile ); | |||
| writeDOMTree(rootElement.getOwnerDocument(), destFile); | |||
| } catch (IOException e){ | |||
| throw new BuildException("Unable to write test aggregate to '" + destFile + "'", e); | |||
| } | |||
| @@ -204,10 +204,10 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| String[] f = ds.getIncludedFiles(); | |||
| for (int j = 0; j < f.length; j++) { | |||
| String pathname = f[j]; | |||
| if ( pathname.endsWith(".xml") ) { | |||
| if (pathname.endsWith(".xml")) { | |||
| File file = new File(ds.getBasedir(), pathname); | |||
| file = project.resolveFile(file.getPath()); | |||
| v.addElement( file ); | |||
| v.addElement(file); | |||
| } | |||
| } | |||
| } | |||
| @@ -229,7 +229,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| OutputStream out = null; | |||
| PrintWriter wri = null; | |||
| try { | |||
| out = new FileOutputStream( file ); | |||
| out = new FileOutputStream(file); | |||
| wri = new PrintWriter(new OutputStreamWriter(out, "UTF8")); | |||
| wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); | |||
| (new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " "); | |||
| @@ -270,10 +270,11 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| //XXX there seems to be a bug in xerces 1.3.0 that doesn't like file object | |||
| // will investigate later. It does not use the given directory but | |||
| // the vm dir instead ? Works fine with crimson. | |||
| Document testsuiteDoc = builder.parse( "file:///" + files[i].getAbsolutePath() ); | |||
| Document testsuiteDoc | |||
| = builder.parse("file:///" + files[i].getAbsolutePath()); | |||
| Element elem = testsuiteDoc.getDocumentElement(); | |||
| // make sure that this is REALLY a testsuite. | |||
| if ( TESTSUITE.equals(elem.getNodeName()) ) { | |||
| if (TESTSUITE.equals(elem.getNodeName())) { | |||
| addTestSuite(rootElement, elem); | |||
| } else { | |||
| // issue a warning. | |||
| @@ -310,7 +311,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| // 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); | |||
| Element copy = (Element) DOMUtil.importNode(root, testsuite); | |||
| // modify the name attribute and set the package | |||
| copy.setAttribute(ATTR_NAME, classname); | |||
| @@ -326,7 +327,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| private static DocumentBuilder getDocumentBuilder() { | |||
| try { | |||
| return DocumentBuilderFactory.newInstance().newDocumentBuilder(); | |||
| } catch(Exception exc) { | |||
| } catch (Exception exc) { | |||
| throw new ExceptionInInitializerError(exc); | |||
| } | |||
| } | |||
| @@ -78,7 +78,7 @@ public class Xalan1Executor extends XalanExecutor { | |||
| OutputStream os = getOutputStream(); | |||
| try { | |||
| XSLTResultTarget target = new XSLTResultTarget(os); | |||
| processor.process( xml_src, xsl_src, target); | |||
| processor.process(xml_src, xsl_src, target); | |||
| } finally { | |||
| os.close(); | |||
| } | |||
| @@ -190,7 +190,7 @@ public class MParse extends Task { | |||
| // set the metamata.home property | |||
| final Commandline.Argument vmArgs = cmdl.createVmArgument(); | |||
| vmArgs.setValue("-Dmetamata.home=" + metahome.getAbsolutePath() ); | |||
| vmArgs.setValue("-Dmetamata.home=" + metahome.getAbsolutePath()); | |||
| // write all the options to a temp file and use it ro run the process | |||
| @@ -254,8 +254,8 @@ public class MParse extends Task { | |||
| */ | |||
| protected File[] getMetamataLibs(){ | |||
| Vector files = new Vector(); | |||
| files.addElement( new File(metahome, "lib/metamata.jar") ); | |||
| files.addElement( new File(metahome, "bin/lib/JavaCC.zip") ); | |||
| files.addElement(new File(metahome, "lib/metamata.jar")); | |||
| files.addElement(new File(metahome, "bin/lib/JavaCC.zip")); | |||
| File[] array = new File[ files.size() ]; | |||
| files.copyInto(array); | |||
| @@ -278,12 +278,14 @@ public class MParse extends Task { | |||
| File[] jars = getMetamataLibs(); | |||
| for (int i = 0; i < jars.length; i++){ | |||
| if (!jars[i].exists()){ | |||
| throw new BuildException( jars[i] + " does not exist. Check your metamata installation."); | |||
| throw new BuildException(jars[i] | |||
| + " does not exist. Check your metamata installation."); | |||
| } | |||
| } | |||
| // check that the target is ok and resolve it. | |||
| if (target == null || !target.isFile() || !target.getName().endsWith(".jj") ) { | |||
| if (target == null || !target.isFile() | |||
| || !target.getName().endsWith(".jj")) { | |||
| throw new BuildException("Invalid target: " + target); | |||
| } | |||
| target = project.resolveFile(target.getPath()); | |||
| @@ -332,7 +334,7 @@ public class MParse extends Task { | |||
| fw = new FileWriter(tofile); | |||
| PrintWriter pw = new PrintWriter(fw); | |||
| for (int i = 0; i < options.length; i++){ | |||
| pw.println( options[i] ); | |||
| pw.println(options[i]); | |||
| } | |||
| pw.flush(); | |||
| } catch (IOException e){ | |||
| @@ -79,7 +79,8 @@ public class MimeMail extends EmailTask | |||
| public void execute() | |||
| throws BuildException | |||
| { | |||
| log( "DEPRECATED - The " + getTaskName() + " task is deprecated. Use the mail task instead." ); | |||
| log("DEPRECATED - The " + getTaskName() + " task is deprecated. " | |||
| + "Use the mail task instead."); | |||
| super.execute(); | |||
| } | |||
| } | |||
| @@ -82,7 +82,7 @@ public class TelnetTask extends Task { | |||
| /** | |||
| * The password to login with, if automated login is used | |||
| */ | |||
| private String password= null; | |||
| private String password = null; | |||
| /** | |||
| * The server to connect to. | |||
| @@ -123,7 +123,7 @@ public class TelnetTask extends Task { | |||
| public void execute() throws BuildException | |||
| { | |||
| /** A server name is required to continue */ | |||
| if (server== null) { | |||
| if (server == null) { | |||
| throw new BuildException("No Server Specified"); | |||
| } | |||
| /** A userid and password must appear together | |||
| @@ -140,8 +140,8 @@ public class TelnetTask extends Task { | |||
| telnet = new AntTelnetClient(); | |||
| try { | |||
| telnet.connect(server, port); | |||
| } catch(IOException e) { | |||
| throw new BuildException("Can't connect to "+server); | |||
| } catch (IOException e) { | |||
| throw new BuildException("Can't connect to " + server); | |||
| } | |||
| /** Login if userid and password were specified */ | |||
| if (userid != null && password != null) { | |||
| @@ -149,11 +149,11 @@ public class TelnetTask extends Task { | |||
| } | |||
| /** Process each sub command */ | |||
| Enumeration tasksToRun = telnetTasks.elements(); | |||
| while (tasksToRun!=null && tasksToRun.hasMoreElements()) | |||
| while (tasksToRun != null && tasksToRun.hasMoreElements()) | |||
| { | |||
| TelnetSubTask task = (TelnetSubTask) tasksToRun.nextElement(); | |||
| if (task instanceof TelnetRead && defaultTimeout != null) { | |||
| ((TelnetRead)task).setDefaultTimeout(defaultTimeout); | |||
| ((TelnetRead) task).setDefaultTimeout(defaultTimeout); | |||
| } | |||
| task.execute(telnet); | |||
| } | |||
| @@ -218,7 +218,7 @@ public class TelnetTask extends Task { | |||
| public TelnetSubTask createRead() | |||
| { | |||
| TelnetSubTask task = (TelnetSubTask)new TelnetRead(); | |||
| TelnetSubTask task = (TelnetSubTask) new TelnetRead(); | |||
| telnetTasks.addElement(task); | |||
| return task; | |||
| } | |||
| @@ -229,7 +229,7 @@ public class TelnetTask extends Task { | |||
| */ | |||
| public TelnetSubTask createWrite() | |||
| { | |||
| TelnetSubTask task = (TelnetSubTask)new TelnetWrite(); | |||
| TelnetSubTask task = (TelnetSubTask) new TelnetWrite(); | |||
| telnetTasks.addElement(task); | |||
| return task; | |||
| } | |||
| @@ -240,7 +240,7 @@ public class TelnetTask extends Task { | |||
| */ | |||
| public class TelnetSubTask | |||
| { | |||
| protected String taskString= ""; | |||
| protected String taskString = ""; | |||
| public void execute(AntTelnetClient telnet) | |||
| throws BuildException | |||
| { | |||
| @@ -331,7 +331,7 @@ public class TelnetTask extends Task { | |||
| */ | |||
| public void waitForString(String s, Integer timeout) | |||
| { | |||
| InputStream is =this.getInputStream(); | |||
| InputStream is = this.getInputStream(); | |||
| try { | |||
| StringBuffer sb = new StringBuffer(); | |||
| if (timeout == null || timeout.intValue() == 0) | |||
| @@ -344,8 +344,8 @@ public class TelnetTask extends Task { | |||
| else | |||
| { | |||
| Calendar endTime = Calendar.getInstance(); | |||
| endTime.add(Calendar.SECOND,timeout.intValue()); | |||
| while ( sb.toString().indexOf(s) == -1) | |||
| endTime.add(Calendar.SECOND, timeout.intValue()); | |||
| while (sb.toString().indexOf(s) == -1) | |||
| { | |||
| while (Calendar.getInstance().before(endTime) && | |||
| is.available() == 0) { | |||
| @@ -374,7 +374,7 @@ public class TelnetTask extends Task { | |||
| */ | |||
| public void sendString(String s, boolean echoString) | |||
| { | |||
| OutputStream os =this.getOutputStream(); | |||
| OutputStream os = this.getOutputStream(); | |||
| try { | |||
| os.write((s + "\n").getBytes()); | |||
| if (echoString) { | |||
| @@ -90,9 +90,7 @@ public class P4Submit extends P4Base { | |||
| 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. | |||
| @@ -133,15 +133,16 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| return exe.execute(); | |||
| } | |||
| catch (java.io.IOException e) { | |||
| String msg = "Failed executing: " + cmd.toString() + ". Exception: "+e.getMessage(); | |||
| String msg = "Failed executing: " + cmd.toString() | |||
| + ". Exception: " + e.getMessage(); | |||
| throw new BuildException(msg, location); | |||
| } | |||
| } | |||
| private String getExecutable(String exe) { | |||
| StringBuffer correctedExe = new StringBuffer(); | |||
| if(getPvcsbin()!=null) { | |||
| if(pvcsbin.endsWith(File.separator)) { | |||
| if (getPvcsbin() != null) { | |||
| if (pvcsbin.endsWith(File.separator)) { | |||
| correctedExe.append(pvcsbin); | |||
| } else { | |||
| correctedExe.append(pvcsbin).append(File.separator); | |||
| @@ -157,7 +158,7 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| Project aProj = getProject(); | |||
| int result = 0; | |||
| if(repository == null || repository.trim().equals("")) { | |||
| if (repository == null || repository.trim().equals("")) { | |||
| throw new BuildException("Required argument repository not specified"); | |||
| } | |||
| @@ -171,10 +172,10 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| commandLine.createArgument().setValue("lvf"); | |||
| commandLine.createArgument().setValue("-z"); | |||
| commandLine.createArgument().setValue("-aw"); | |||
| if(getWorkspace()!=null) { | |||
| commandLine.createArgument().setValue("-sp"+getWorkspace()); | |||
| if (getWorkspace() != null) { | |||
| commandLine.createArgument().setValue("-sp" + getWorkspace()); | |||
| } | |||
| commandLine.createArgument().setValue("-pr"+getRepository()); | |||
| commandLine.createArgument().setValue("-pr" + getRepository()); | |||
| String uid = getUserId(); | |||
| @@ -183,19 +184,20 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| } | |||
| // default pvcs project is "/" | |||
| if(getPvcsproject() == null && getPvcsprojects().isEmpty()) { | |||
| if (getPvcsproject() == null && getPvcsprojects().isEmpty()) { | |||
| pvcsProject = "/"; | |||
| } | |||
| if(getPvcsproject()!=null) { | |||
| if (getPvcsproject() != null) { | |||
| commandLine.createArgument().setValue(getPvcsproject()); | |||
| } | |||
| if(!getPvcsprojects().isEmpty()) { | |||
| if (!getPvcsprojects().isEmpty()) { | |||
| Enumeration e = getPvcsprojects().elements(); | |||
| while (e.hasMoreElements()) { | |||
| String projectName = ((PvcsProject)e.nextElement()).getName(); | |||
| String projectName = ((PvcsProject) e.nextElement()).getName(); | |||
| if (projectName == null || (projectName.trim()).equals("")) { | |||
| throw new BuildException("name is a required attribute of pvcsproject"); | |||
| throw new BuildException("name is a required attribute " | |||
| + "of pvcsproject"); | |||
| } | |||
| commandLine.createArgument().setValue(projectName); | |||
| } | |||
| @@ -205,17 +207,21 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| File tmp2 = null; | |||
| try { | |||
| Random rand = new Random(System.currentTimeMillis()); | |||
| tmp = new File("pvcs_ant_"+rand.nextLong()+".log"); | |||
| tmp2 = new File("pvcs_ant_"+rand.nextLong()+".log"); | |||
| tmp = new File("pvcs_ant_" + rand.nextLong() + ".log"); | |||
| tmp2 = new File("pvcs_ant_" + rand.nextLong() + ".log"); | |||
| log("Executing " + commandLine.toString(), Project.MSG_VERBOSE); | |||
| result = runCmd(commandLine, new PumpStreamHandler(new FileOutputStream(tmp), new LogOutputStream(this,Project.MSG_WARN))); | |||
| if ( result != 0 && !ignorerc) { | |||
| result = runCmd(commandLine, | |||
| new PumpStreamHandler(new FileOutputStream(tmp), | |||
| new LogOutputStream(this, Project.MSG_WARN))); | |||
| if (result != 0 && !ignorerc) { | |||
| String msg = "Failed executing: " + commandLine.toString(); | |||
| throw new BuildException(msg, location); | |||
| } | |||
| if(!tmp.exists()) { | |||
| throw new BuildException("Communication between ant and pvcs failed. No output generated from executing PVCS commandline interface \"pcli\" and \"get\""); | |||
| if (!tmp.exists()) { | |||
| throw new BuildException("Communication between ant and pvcs " | |||
| + "failed. No output generated from executing PVCS " | |||
| + "commandline interface \"pcli\" and \"get\""); | |||
| } | |||
| // Create folders in workspace | |||
| @@ -229,17 +235,18 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| commandLine.clearArgs(); | |||
| commandLine.setExecutable(getExecutable(GET_EXE)); | |||
| if(getForce()!=null && getForce().equals("yes")) { | |||
| if (getForce() != null && getForce().equals("yes")) { | |||
| commandLine.createArgument().setValue("-Y"); | |||
| } else { | |||
| commandLine.createArgument().setValue("-N"); | |||
| } | |||
| if(getPromotiongroup()!=null) { | |||
| commandLine.createArgument().setValue("-G"+getPromotiongroup()); | |||
| if (getPromotiongroup() != null) { | |||
| commandLine.createArgument().setValue("-G" | |||
| + getPromotiongroup()); | |||
| } else { | |||
| if(getLabel()!=null) { | |||
| commandLine.createArgument().setValue("-r"+getLabel()); | |||
| if (getLabel() != null) { | |||
| commandLine.createArgument().setValue("-r" + getLabel()); | |||
| } | |||
| } | |||
| @@ -247,24 +254,29 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| commandLine.createArgument().setValue("-U"); | |||
| } | |||
| commandLine.createArgument().setValue("@"+tmp2.getAbsolutePath()); | |||
| commandLine.createArgument().setValue("@" + tmp2.getAbsolutePath()); | |||
| log("Getting files", Project.MSG_INFO); | |||
| log("Executing " + commandLine.toString(), Project.MSG_VERBOSE); | |||
| result = runCmd(commandLine, new LogStreamHandler(this,Project.MSG_INFO, Project.MSG_WARN)); | |||
| if ( result != 0 && !ignorerc) { | |||
| String msg = "Failed executing: " + commandLine.toString() + ". Return code was "+result; | |||
| result = runCmd(commandLine, | |||
| new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); | |||
| if (result != 0 && !ignorerc) { | |||
| String msg = "Failed executing: " + commandLine.toString() | |||
| + ". Return code was " + result; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| } catch(FileNotFoundException e) { | |||
| String msg = "Failed executing: " + commandLine.toString() + ". Exception: "+e.getMessage(); | |||
| throw new BuildException(msg,location); | |||
| } catch(IOException e) { | |||
| String msg = "Failed executing: " + commandLine.toString() + ". Exception: "+e.getMessage(); | |||
| throw new BuildException(msg,location); | |||
| } catch(ParseException e) { | |||
| String msg = "Failed executing: " + commandLine.toString() + ". Exception: "+e.getMessage(); | |||
| throw new BuildException(msg,location); | |||
| } catch (FileNotFoundException e) { | |||
| String msg = "Failed executing: " + commandLine.toString() | |||
| + ". Exception: " + e.getMessage(); | |||
| throw new BuildException(msg, location); | |||
| } catch (IOException e) { | |||
| String msg = "Failed executing: " + commandLine.toString() | |||
| + ". Exception: " + e.getMessage(); | |||
| throw new BuildException(msg, location); | |||
| } catch (ParseException e) { | |||
| String msg = "Failed executing: " + commandLine.toString() | |||
| + ". Exception: " + e.getMessage(); | |||
| throw new BuildException(msg, location); | |||
| } finally { | |||
| if (tmp != null) { | |||
| tmp.delete(); | |||
| @@ -280,45 +292,50 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| */ | |||
| private void createFolders(File file) throws IOException, ParseException { | |||
| BufferedReader in = new BufferedReader(new FileReader(file)); | |||
| MessageFormat mf = new MessageFormat( getFilenameFormat() ); | |||
| MessageFormat mf = new MessageFormat(getFilenameFormat()); | |||
| String line = in.readLine(); | |||
| while(line != null) { | |||
| log("Considering \""+line+"\"", Project.MSG_VERBOSE); | |||
| if(line.startsWith("\"\\") || | |||
| while (line != null) { | |||
| log("Considering \"" + line + "\"", Project.MSG_VERBOSE); | |||
| if (line.startsWith("\"\\") || | |||
| line.startsWith("\"/") || | |||
| line.startsWith(getLineStart()) ) { | |||
| line.startsWith(getLineStart())) { | |||
| Object[] objs = mf.parse(line); | |||
| String f = (String)objs[1]; | |||
| String f = (String) objs[1]; | |||
| // Extract the name of the directory from the filename | |||
| int index = f.lastIndexOf(File.separator); | |||
| if (index > -1) { | |||
| File dir = new File(f.substring(0, index)); | |||
| if(!dir.exists()) { | |||
| log("Creating "+dir.getAbsolutePath(), Project.MSG_VERBOSE); | |||
| if(dir.mkdirs()) { | |||
| log("Created "+dir.getAbsolutePath(), Project.MSG_INFO); | |||
| if (!dir.exists()) { | |||
| log("Creating " + dir.getAbsolutePath(), | |||
| Project.MSG_VERBOSE); | |||
| if (dir.mkdirs()) { | |||
| log("Created " + dir.getAbsolutePath(), | |||
| Project.MSG_INFO); | |||
| } else { | |||
| log("Failed to create "+dir.getAbsolutePath(), Project.MSG_INFO); | |||
| log("Failed to create " + dir.getAbsolutePath(), | |||
| Project.MSG_INFO); | |||
| } | |||
| } else { | |||
| log(dir.getAbsolutePath() + " exists. Skipping", Project.MSG_VERBOSE); | |||
| log(dir.getAbsolutePath() + " exists. Skipping", | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| } else { | |||
| log("File separator problem with " + line, | |||
| Project.MSG_WARN); | |||
| } | |||
| } else { | |||
| log("Skipped \""+line+"\"", Project.MSG_VERBOSE); | |||
| log("Skipped \"" + line + "\"", Project.MSG_VERBOSE); | |||
| } | |||
| line = in.readLine(); | |||
| } | |||
| } | |||
| /** | |||
| * Simple hack to handle the PVCS command-line tools botch when handling UNC notation. | |||
| * Simple hack to handle the PVCS command-line tools botch when | |||
| * handling UNC notation. | |||
| */ | |||
| private void massagePCLI(File in, File out) throws FileNotFoundException, IOException | |||
| { | |||
| private void massagePCLI(File in, File out) | |||
| throws FileNotFoundException, IOException { | |||
| BufferedReader inReader = new BufferedReader(new FileReader(in)); | |||
| BufferedWriter outWriter = new BufferedWriter(new FileWriter(out)); | |||
| String s = null; | |||
| @@ -432,8 +449,8 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| * @param repo String (yes/no) | |||
| */ | |||
| public void setForce(String f) { | |||
| if(f!=null && f.equalsIgnoreCase("yes")) { | |||
| force="yes"; | |||
| if (f != null && f.equalsIgnoreCase("yes")) { | |||
| force = "yes"; | |||
| } else { | |||
| force = "no"; | |||
| } | |||
| @@ -452,7 +469,7 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| * @param repo String | |||
| */ | |||
| public void setPromotiongroup(String w) { | |||
| promotiongroup=w; | |||
| promotiongroup = w; | |||
| } | |||
| /** | |||
| @@ -468,7 +485,7 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| * @param repo String | |||
| */ | |||
| public void setLabel(String l) { | |||
| label=l; | |||
| label = l; | |||
| } | |||
| /** | |||
| @@ -525,12 +542,12 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| workspace = null; | |||
| repository = null; | |||
| pvcsbin = null; | |||
| force=null; | |||
| promotiongroup=null; | |||
| label=null; | |||
| ignorerc=false; | |||
| force = null; | |||
| promotiongroup = null; | |||
| label = null; | |||
| ignorerc = false; | |||
| updateOnly = false; | |||
| lineStart="\"P:"; | |||
| filenameFormat="{0}_arc({1})"; | |||
| lineStart = "\"P:"; | |||
| filenameFormat = "{0}_arc({1})"; | |||
| } | |||
| } | |||
| @@ -141,7 +141,8 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| audioInputStream = AudioSystem.getAudioInputStream(file); | |||
| } | |||
| catch (UnsupportedAudioFileException uafe) { | |||
| project.log("Audio format is not yet supported: "+uafe.getMessage()); | |||
| project.log("Audio format is not yet supported: " | |||
| + uafe.getMessage()); | |||
| } | |||
| catch (IOException ioe) { | |||
| ioe.printStackTrace(); | |||
| @@ -229,7 +230,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| if (event.getException() == null && fileSuccess != null) { | |||
| // build successfull! | |||
| play(event.getProject(), fileSuccess, loopsSuccess, durationSuccess); | |||
| } else if ( event.getException() != null && fileFail != null) { | |||
| } else if (event.getException() != null && fileFail != null) { | |||
| play(event.getProject(), fileFail, loopsFail, durationFail); | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -107,7 +107,7 @@ public class SoundTask extends Task { | |||
| AntSoundPlayer soundPlayer = new AntSoundPlayer(); | |||
| if ( success == null ) { | |||
| if (success == null) { | |||
| log("No nested success element found.", Project.MSG_WARN); | |||
| } else { | |||
| soundPlayer.addBuildSuccessfulSound(success.getSource(), | |||
| @@ -165,18 +165,18 @@ public class SoundTask extends Task { | |||
| public File getSource() { | |||
| File nofile = null ; | |||
| // Check if source is a directory | |||
| if( source.exists() ) { | |||
| if( source.isDirectory() ) { | |||
| if (source.exists()) { | |||
| if (source.isDirectory()) { | |||
| // get the list of files in the dir | |||
| String[] entries = source.list() ; | |||
| Vector files = new Vector() ; | |||
| for (int i=0 ; i < entries.length ; i++) { | |||
| for (int i = 0 ; i < entries.length ; i++) { | |||
| File f = new File(source, entries[i]) ; | |||
| if (f.isFile()) { | |||
| files.addElement(f) ; | |||
| } | |||
| } | |||
| if ( files.size() < 1 ) { | |||
| if (files.size() < 1) { | |||
| throw new BuildException("No files found in directory " + source); | |||
| } | |||
| int numfiles = files.size() ; | |||
| @@ -184,7 +184,7 @@ public class SoundTask extends Task { | |||
| Random rn = new Random() ; | |||
| int x = rn.nextInt(numfiles) ; | |||
| // set the source to the file at that location | |||
| this.source = (File)files.elementAt(x) ; | |||
| this.source = (File) files.elementAt(x); | |||
| } | |||
| } else { | |||
| log(source + ": invalid path.", Project.MSG_WARN) ; | |||
| @@ -90,15 +90,15 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener { | |||
| protected void init(ImageIcon img) { | |||
| JPanel pan = (JPanel)getContentPane(); | |||
| JPanel pan = (JPanel) getContentPane(); | |||
| JLabel piccy; | |||
| if(img == null ) { | |||
| if (img == null) { | |||
| piccy = new JLabel(); | |||
| } else { | |||
| piccy = new JLabel(img); | |||
| } | |||
| piccy.setBorder(BorderFactory.createLineBorder(Color.black,1)); | |||
| piccy.setBorder(BorderFactory.createLineBorder(Color.black, 1)); | |||
| text = new JLabel("Building....", JLabel.CENTER); | |||
| text.setFont(new Font("Sans-Serif", Font.BOLD, 12)); | |||
| text.setBorder(BorderFactory.createEtchedBorder()); | |||
| @@ -108,8 +108,8 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener { | |||
| JPanel pan2 = new JPanel(); | |||
| pan2.setLayout(new BorderLayout()); | |||
| pan2.add(text,BorderLayout.NORTH); | |||
| pan2.add(pb,BorderLayout.SOUTH); | |||
| pan2.add(text, BorderLayout.NORTH); | |||
| pan2.add(pb, BorderLayout.SOUTH); | |||
| pan.setLayout(new BorderLayout()); | |||
| pan.add(piccy, BorderLayout.CENTER); | |||
| @@ -121,9 +121,9 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener { | |||
| Dimension size = getSize(); | |||
| Dimension scr = Toolkit.getDefaultToolkit().getScreenSize(); | |||
| int x = (scr.width - size.width) /2; | |||
| int y = (scr.height - size.height) /2; | |||
| setBounds(x,y,size.width, size.height); | |||
| int x = (scr.width - size.width) / 2; | |||
| int y = (scr.height - size.height) / 2; | |||
| setBounds(x, y, size.width, size.height); | |||
| } | |||
| public void setText(String txt) { | |||
| @@ -131,7 +131,7 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener { | |||
| } | |||
| public void actionPerformed(ActionEvent a) { | |||
| if(total < max) { | |||
| if (total < max) { | |||
| total++; | |||
| } else { | |||
| total = min; | |||
| @@ -101,7 +101,7 @@ public class SplashTask extends Task { | |||
| public void execute() throws BuildException { | |||
| if (splash != null ) { | |||
| if (splash != null) { | |||
| splash.setVisible(false); | |||
| getProject().removeBuildListener(splash); | |||
| splash.dispose(); | |||
| @@ -112,10 +112,10 @@ public class SplashTask extends Task { | |||
| InputStream in = null; | |||
| if (imgurl != null) { | |||
| try{ | |||
| try { | |||
| URLConnection conn = null; | |||
| if(useProxy && | |||
| if (useProxy && | |||
| (proxy != null && proxy.length() > 0) && | |||
| (port != null && port.length() > 0)) { | |||
| @@ -129,7 +129,7 @@ public class SplashTask extends Task { | |||
| conn = url.openConnection(); | |||
| if (user != null && user.length() > 0) { | |||
| String encodedcreds = | |||
| new sun.misc.BASE64Encoder().encode((new String(user+":"+password)).getBytes()); | |||
| new sun.misc.BASE64Encoder().encode((new String(user + ":" + password)).getBytes()); | |||
| conn.setRequestProperty("Proxy-Authorization", | |||
| encodedcreds); | |||
| } | |||
| @@ -150,9 +150,11 @@ public class SplashTask extends Task { | |||
| // Catch everything - some of the above return nulls, throw exceptions or generally misbehave | |||
| // in the event of a problem etc | |||
| } catch(Throwable ioe) { | |||
| log("Unable to download image, trying default Ant Logo", Project.MSG_DEBUG); | |||
| log("(Exception was \""+ioe.getMessage()+"\"", Project.MSG_DEBUG); | |||
| } catch (Throwable ioe) { | |||
| log("Unable to download image, trying default Ant Logo", | |||
| Project.MSG_DEBUG); | |||
| log("(Exception was \"" + ioe.getMessage() + "\"", | |||
| Project.MSG_DEBUG); | |||
| } | |||
| } | |||
| @@ -160,14 +162,14 @@ public class SplashTask extends Task { | |||
| in = SplashTask.class.getClassLoader().getResourceAsStream("images/ant_logo_large.gif"); | |||
| } | |||
| if(in != null) { | |||
| if (in != null) { | |||
| DataInputStream din = new DataInputStream(in); | |||
| boolean success = false; | |||
| try { | |||
| ByteArrayOutputStream bout = new ByteArrayOutputStream(); | |||
| int data; | |||
| while((data = din.read()) != -1) { | |||
| bout.write((byte)data); | |||
| while ((data = din.read()) != -1) { | |||
| bout.write((byte) data); | |||
| } | |||
| log("Got ByteArray, creating splash", Project.MSG_DEBUG); | |||
| @@ -175,7 +177,7 @@ public class SplashTask extends Task { | |||
| splash = new SplashScreen(img); | |||
| success = true; | |||
| } catch(Exception e) { | |||
| } catch (Exception e) { | |||
| throw new BuildException(e); | |||
| } finally { | |||
| try { | |||
| @@ -250,7 +250,7 @@ public abstract class StarTeamTask extends Task { | |||
| this.servername + ":" + | |||
| this.serverport + "/" + | |||
| this.projectname + "/" + | |||
| ((null == this.viewname)?"":this.viewname); | |||
| ((null == this.viewname) ? "" : this.viewname); | |||
| } | |||
| /** | |||
| @@ -99,7 +99,7 @@ public abstract class MSVSS extends Task { | |||
| */ | |||
| public final String getSSCommand() { | |||
| String toReturn = m_SSDir; | |||
| if ( !toReturn.equals("") && !toReturn.endsWith("\\") ) { | |||
| if (!toReturn.equals("") && !toReturn.endsWith("\\")) { | |||
| toReturn += "\\"; | |||
| } | |||
| toReturn += SS_EXE; | |||
| @@ -122,7 +122,7 @@ public abstract class MSVSS extends Task { | |||
| * @return the appropriate login command if the 'login' attribute was specified, otherwise an empty string | |||
| */ | |||
| public void getLoginCommand(Commandline cmd) { | |||
| if ( m_vssLogin == null ) { | |||
| if (m_vssLogin == null) { | |||
| return; | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_LOGIN + m_vssLogin); | |||
| @@ -138,8 +138,8 @@ public abstract class MSVSS extends Task { | |||
| * @param vssPath | |||
| */ | |||
| public final void setVsspath(String vssPath) { | |||
| if ( vssPath.startsWith("vss://") ) { | |||
| m_vssPath= PROJECT_PREFIX + vssPath.substring(5); | |||
| if (vssPath.startsWith("vss://")) { | |||
| m_vssPath = PROJECT_PREFIX + vssPath.substring(5); | |||
| } else { | |||
| m_vssPath = PROJECT_PREFIX + vssPath; | |||
| } | |||
| @@ -171,11 +171,11 @@ public abstract class MSVSS extends Task { | |||
| // environment-variable SSDIR to this value | |||
| if (m_serverPath != null) { | |||
| String[] env = exe.getEnvironment(); | |||
| if( env == null ) { | |||
| if (env == null) { | |||
| env = new String[0]; | |||
| } | |||
| String[] newEnv = new String[env.length+1]; | |||
| for( int i=0;i<env.length;i++ ) { | |||
| String[] newEnv = new String[env.length + 1]; | |||
| for (int i = 0; i < env.length ; i++) { | |||
| newEnv[i] = env[i]; | |||
| } | |||
| newEnv[env.length] = "SSDIR=" + m_serverPath; | |||
| @@ -107,10 +107,10 @@ public class MSVSSADD extends MSVSS { | |||
| // -Y | |||
| getLoginCommand(commandLine); | |||
| // -C | |||
| commandLine.createArgument().setValue("-C"+getComment()); | |||
| commandLine.createArgument().setValue("-C" + getComment()); | |||
| result = run(commandLine); | |||
| if ( result != 0 ) { | |||
| if (result != 0) { | |||
| String msg = "Failed executing: " + commandLine.toString(); | |||
| throw new BuildException(msg, location); | |||
| } | |||
| @@ -127,7 +127,7 @@ public class MSVSSADD extends MSVSS { | |||
| * @return the 'recursive' command if the attribute was 'true', otherwise an empty string | |||
| */ | |||
| public void getRecursiveCommand(Commandline cmd) { | |||
| if ( !m_Recursive ) { | |||
| if (!m_Recursive) { | |||
| return; | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_RECURSION); | |||
| @@ -145,7 +145,7 @@ public class MSVSSADD extends MSVSS { | |||
| * @return the 'make writable' command if the attribute was 'true', otherwise an empty string | |||
| */ | |||
| public void getWritableCommand(Commandline cmd) { | |||
| if ( !m_Writable ) { | |||
| if (!m_Writable) { | |||
| return; | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_WRITABLE); | |||
| @@ -153,7 +153,7 @@ public class MSVSSADD extends MSVSS { | |||
| } | |||
| public void setAutoresponse(String response){ | |||
| if ( response.equals("") || response.equals("null") ) { | |||
| if (response.equals("") || response.equals("null")) { | |||
| m_AutoResponse = null; | |||
| } else { | |||
| m_AutoResponse = response; | |||
| @@ -168,14 +168,14 @@ public class MSVSSADD extends MSVSS { | |||
| */ | |||
| public void getAutoresponse(Commandline cmd) { | |||
| if ( m_AutoResponse == null) { | |||
| if (m_AutoResponse == null) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("N")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("N")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); | |||
| }else { | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } // end of else | |||
| @@ -188,7 +188,7 @@ public class MSVSSADD extends MSVSS { | |||
| * is what SourceSafe uses for an empty comment. | |||
| */ | |||
| public void setComment(String comment) { | |||
| if ( comment.equals("") || comment.equals("null") ) { | |||
| if (comment.equals("") || comment.equals("null")) { | |||
| m_Comment = "-"; | |||
| } else { | |||
| m_Comment = comment; | |||
| @@ -112,10 +112,10 @@ public class MSVSSCHECKIN extends MSVSS { | |||
| // -Y | |||
| getLoginCommand(commandLine); | |||
| // -C | |||
| commandLine.createArgument().setValue("-C"+getComment()); | |||
| commandLine.createArgument().setValue("-C" + getComment()); | |||
| result = run(commandLine); | |||
| if ( result != 0 ) { | |||
| if (result != 0) { | |||
| String msg = "Failed executing: " + commandLine.toString(); | |||
| throw new BuildException(msg, location); | |||
| } | |||
| @@ -142,14 +142,16 @@ public class MSVSSCHECKIN extends MSVSS { | |||
| if (!dir.exists()) { | |||
| boolean done = dir.mkdirs(); | |||
| if (!done) { | |||
| String msg = "Directory " + m_LocalPath + " creation was not " + | |||
| "succesful for an unknown reason"; | |||
| String msg = "Directory " + m_LocalPath | |||
| + " creation was not " | |||
| + "succesful for an unknown reason"; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| project.log("Created dir: " + dir.getAbsolutePath()); | |||
| } | |||
| cmd.createArgument().setValue(FLAG_OVERRIDE_WORKING_DIR + m_LocalPath); | |||
| cmd.createArgument().setValue(FLAG_OVERRIDE_WORKING_DIR | |||
| + m_LocalPath); | |||
| } | |||
| } | |||
| @@ -164,7 +166,7 @@ public class MSVSSCHECKIN extends MSVSS { | |||
| * @return the 'recursive' command if the attribute was 'true', otherwise an empty string | |||
| */ | |||
| public void getRecursiveCommand(Commandline cmd) { | |||
| if ( !m_Recursive ) { | |||
| if (!m_Recursive) { | |||
| return; | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_RECURSION); | |||
| @@ -182,7 +184,7 @@ public class MSVSSCHECKIN extends MSVSS { | |||
| * @return the 'make writable' command if the attribute was 'true', otherwise an empty string | |||
| */ | |||
| public void getWritableCommand(Commandline cmd) { | |||
| if ( !m_Writable ) { | |||
| if (!m_Writable) { | |||
| return; | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_WRITABLE); | |||
| @@ -190,7 +192,7 @@ public class MSVSSCHECKIN extends MSVSS { | |||
| } | |||
| public void setAutoresponse(String response){ | |||
| if ( response.equals("") || response.equals("null") ) { | |||
| if (response.equals("") || response.equals("null")) { | |||
| m_AutoResponse = null; | |||
| } else { | |||
| m_AutoResponse = response; | |||
| @@ -205,14 +207,14 @@ public class MSVSSCHECKIN extends MSVSS { | |||
| */ | |||
| public void getAutoresponse(Commandline cmd) { | |||
| if ( m_AutoResponse == null) { | |||
| if (m_AutoResponse == null) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("N")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("N")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); | |||
| }else { | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } // end of else | |||
| @@ -225,7 +227,7 @@ public class MSVSSCHECKIN extends MSVSS { | |||
| * is what SourceSafe uses for an empty comment. | |||
| */ | |||
| public void setComment(String comment) { | |||
| if ( comment.equals("") || comment.equals("null") ) { | |||
| if (comment.equals("") || comment.equals("null")) { | |||
| m_Comment = "-"; | |||
| } else { | |||
| m_Comment = comment; | |||
| @@ -114,7 +114,7 @@ public class MSVSSCHECKOUT extends MSVSS { | |||
| getLoginCommand(commandLine); | |||
| result = run(commandLine); | |||
| if ( result != 0 ) { | |||
| if (result != 0) { | |||
| String msg = "Failed executing: " + commandLine.toString(); | |||
| throw new BuildException(msg, location); | |||
| } | |||
| @@ -163,7 +163,7 @@ public class MSVSSCHECKOUT extends MSVSS { | |||
| * @return the 'recursive' command if the attribute was 'true', otherwise an empty string | |||
| */ | |||
| public void getRecursiveCommand(Commandline cmd) { | |||
| if ( !m_Recursive ) { | |||
| if (!m_Recursive) { | |||
| return; | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_RECURSION); | |||
| @@ -179,7 +179,7 @@ public class MSVSSCHECKOUT extends MSVSS { | |||
| * has not been defined to ant! | |||
| */ | |||
| public void setVersion(String version) { | |||
| if (version.equals("") || version.equals("null") ) { | |||
| if (version.equals("") || version.equals("null")) { | |||
| m_Version = null; | |||
| } else { | |||
| m_Version = version; | |||
| @@ -195,7 +195,7 @@ public class MSVSSCHECKOUT extends MSVSS { | |||
| * has not been defined to ant! | |||
| */ | |||
| public void setDate(String date) { | |||
| if (date.equals("") || date.equals("null") ) { | |||
| if (date.equals("") || date.equals("null")) { | |||
| m_Date = null; | |||
| } else { | |||
| m_Date = date; | |||
| @@ -211,7 +211,7 @@ public class MSVSSCHECKOUT extends MSVSS { | |||
| * has not been defined to ant! | |||
| */ | |||
| public void setLabel(String label) { | |||
| if ( label.equals("") || label.equals("null") ) { | |||
| if (label.equals("") || label.equals("null")) { | |||
| m_Label = null; | |||
| } else { | |||
| m_Label = label; | |||
| @@ -224,9 +224,9 @@ public class MSVSSCHECKOUT extends MSVSS { | |||
| */ | |||
| public void getVersionCommand(Commandline cmd) { | |||
| if ( m_Version != null) { | |||
| if (m_Version != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION + m_Version); | |||
| } else if ( m_Date != null) { | |||
| } else if (m_Date != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION_DATE + m_Date); | |||
| } else if (m_Label != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_Label); | |||
| @@ -234,7 +234,7 @@ public class MSVSSCHECKOUT extends MSVSS { | |||
| } | |||
| public void setAutoresponse(String response){ | |||
| if ( response.equals("") || response.equals("null") ) { | |||
| if (response.equals("") || response.equals("null")) { | |||
| m_AutoResponse = null; | |||
| } else { | |||
| m_AutoResponse = response; | |||
| @@ -249,14 +249,14 @@ public class MSVSSCHECKOUT extends MSVSS { | |||
| */ | |||
| public void getAutoresponse(Commandline cmd) { | |||
| if ( m_AutoResponse == null) { | |||
| if (m_AutoResponse == null) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("N")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("N")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); | |||
| }else { | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } // end of else | |||
| @@ -101,14 +101,14 @@ public class MSVSSCP extends MSVSS { | |||
| getLoginCommand(commandLine); | |||
| result = run(commandLine); | |||
| if ( result != 0 ) { | |||
| if (result != 0) { | |||
| String msg = "Failed executing: " + commandLine.toString(); | |||
| throw new BuildException(msg, location); | |||
| } | |||
| } | |||
| public void setAutoresponse(String response) { | |||
| if ( response.equals("") || response.equals("null") ) { | |||
| if (response.equals("") || response.equals("null")) { | |||
| m_AutoResponse = null; | |||
| } else { | |||
| m_AutoResponse = response; | |||
| @@ -123,14 +123,14 @@ public class MSVSSCP extends MSVSS { | |||
| */ | |||
| public void getAutoresponse(Commandline cmd) { | |||
| if ( m_AutoResponse == null) { | |||
| if (m_AutoResponse == null) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("N")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("N")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); | |||
| }else { | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } // end of else | |||
| @@ -151,7 +151,7 @@ public class MSVSSCREATE extends MSVSS { | |||
| commandLine.createArgument().setValue(getVsspath()); | |||
| // -C | |||
| commandLine.createArgument().setValue("-C"+getComment()); | |||
| commandLine.createArgument().setValue("-C" + getComment()); | |||
| // -I- or -I-Y or -I-N | |||
| getAutoresponse(commandLine); | |||
| @@ -198,7 +198,7 @@ public class MSVSSCREATE extends MSVSS { | |||
| * @param quiet whether or not command should be run in "quiet mode". | |||
| */ | |||
| public final void setQuiet (boolean quiet) { | |||
| this.m_Quiet=quiet; | |||
| this.m_Quiet = quiet; | |||
| } | |||
| /** | |||
| @@ -217,7 +217,7 @@ public class MSVSSCREATE extends MSVSS { | |||
| * the project. | |||
| */ | |||
| public final void setFailOnError (boolean failOnError) { | |||
| this.m_FailOnError=failOnError; | |||
| this.m_FailOnError = failOnError; | |||
| } | |||
| /** | |||
| @@ -182,7 +182,7 @@ public class MSVSSGET extends MSVSS { | |||
| getLoginCommand(commandLine); | |||
| result = run(commandLine); | |||
| if ( result != 0 ) { | |||
| if (result != 0) { | |||
| String msg = "Failed executing: " + commandLine.toString(); | |||
| throw new BuildException(msg, location); | |||
| } | |||
| @@ -231,7 +231,7 @@ public class MSVSSGET extends MSVSS { | |||
| * @return the 'recursive' command if the attribute was 'true', otherwise an empty string | |||
| */ | |||
| public void getRecursiveCommand(Commandline cmd) { | |||
| if ( !m_Recursive ) { | |||
| if (!m_Recursive) { | |||
| return; | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_RECURSION); | |||
| @@ -242,7 +242,7 @@ public class MSVSSGET extends MSVSS { | |||
| * Sets/clears quiet mode | |||
| */ | |||
| public final void setQuiet (boolean quiet) { | |||
| this.m_Quiet=quiet; | |||
| this.m_Quiet = quiet; | |||
| } | |||
| public void getQuietCommand (Commandline cmd) { | |||
| @@ -262,7 +262,7 @@ public class MSVSSGET extends MSVSS { | |||
| * @return the 'make writable' command if the attribute was 'true', otherwise an empty string | |||
| */ | |||
| public void getWritableCommand(Commandline cmd) { | |||
| if ( !m_Writable ) { | |||
| if (!m_Writable) { | |||
| return; | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_WRITABLE); | |||
| @@ -278,7 +278,7 @@ public class MSVSSGET extends MSVSS { | |||
| * has not been defined to ant! | |||
| */ | |||
| public void setVersion(String version) { | |||
| if (version.equals("") || version.equals("null") ) { | |||
| if (version.equals("") || version.equals("null")) { | |||
| m_Version = null; | |||
| } else { | |||
| m_Version = version; | |||
| @@ -294,7 +294,7 @@ public class MSVSSGET extends MSVSS { | |||
| * has not been defined to ant! | |||
| */ | |||
| public void setDate(String date) { | |||
| if (date.equals("") || date.equals("null") ) { | |||
| if (date.equals("") || date.equals("null")) { | |||
| m_Date = null; | |||
| } else { | |||
| m_Date = date; | |||
| @@ -310,7 +310,7 @@ public class MSVSSGET extends MSVSS { | |||
| * has not been defined to ant! | |||
| */ | |||
| public void setLabel(String label) { | |||
| if ( label.equals("") || label.equals("null") ) { | |||
| if (label.equals("") || label.equals("null")) { | |||
| m_Label = null; | |||
| } else { | |||
| m_Label = label; | |||
| @@ -323,9 +323,9 @@ public class MSVSSGET extends MSVSS { | |||
| */ | |||
| public void getVersionCommand(Commandline cmd) { | |||
| if ( m_Version != null) { | |||
| if (m_Version != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION + m_Version); | |||
| } else if ( m_Date != null) { | |||
| } else if (m_Date != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION_DATE + m_Date); | |||
| } else if (m_Label != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_Label); | |||
| @@ -333,7 +333,7 @@ public class MSVSSGET extends MSVSS { | |||
| } | |||
| public void setAutoresponse(String response){ | |||
| if ( response.equals("") || response.equals("null") ) { | |||
| if (response.equals("") || response.equals("null")) { | |||
| m_AutoResponse = null; | |||
| } else { | |||
| m_AutoResponse = response; | |||
| @@ -348,18 +348,17 @@ public class MSVSSGET extends MSVSS { | |||
| */ | |||
| public void getAutoresponse(Commandline cmd) { | |||
| if ( m_AutoResponse == null) { | |||
| if (m_AutoResponse == null) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("N")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("N")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); | |||
| }else { | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } // end of else | |||
| } | |||
| } | |||
| @@ -148,7 +148,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| System.out.println("***: " + commandLine); | |||
| result = run(commandLine); | |||
| if ( result != 0 ) { | |||
| if (result != 0) { | |||
| String msg = "Failed executing: " + commandLine.toString(); | |||
| throw new BuildException(msg, location); | |||
| } | |||
| @@ -159,7 +159,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * Set the Start Date for the Comparison of two versions in SourceSafe History | |||
| */ | |||
| public void setFromDate(String fromDate) { | |||
| if ( fromDate.equals("") || fromDate == null ) { | |||
| if (fromDate.equals("") || fromDate == null) { | |||
| m_FromDate = null; | |||
| } else { | |||
| m_FromDate = fromDate; | |||
| @@ -170,7 +170,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * Set the Start Label | |||
| */ | |||
| public void setFromLabel(String fromLabel) { | |||
| if ( fromLabel.equals("") || fromLabel == null ) { | |||
| if (fromLabel.equals("") || fromLabel == null) { | |||
| m_FromLabel = null; | |||
| } else { | |||
| m_FromLabel = fromLabel; | |||
| @@ -181,7 +181,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * Set the End Label | |||
| */ | |||
| public void setToLabel(String toLabel) { | |||
| if ( toLabel.equals("") || toLabel == null ) { | |||
| if (toLabel.equals("") || toLabel == null) { | |||
| m_ToLabel = null; | |||
| } else { | |||
| m_ToLabel = toLabel; | |||
| @@ -192,7 +192,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * Set the End Date for the Comparison of two versions in SourceSafe History | |||
| */ | |||
| public void setToDate(String toDate) { | |||
| if ( toDate.equals("") || toDate == null ) { | |||
| if (toDate.equals("") || toDate == null) { | |||
| m_ToDate = null; | |||
| } else { | |||
| m_ToDate = toDate; | |||
| @@ -212,7 +212,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * Set the output file name for SourceSafe output. | |||
| */ | |||
| public void setOutput(File outfile) { | |||
| if ( outfile == null ) { | |||
| if (outfile == null) { | |||
| m_OutputFileName = null; | |||
| } else { | |||
| m_OutputFileName = outfile.getAbsolutePath(); | |||
| @@ -223,7 +223,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * Set the Start Date for the Comparison of two versions in SourceSafe History. | |||
| */ | |||
| public void setDateFormat(String dateFormat) { | |||
| if ( !(dateFormat.equals("") || dateFormat == null) ) { | |||
| if (!(dateFormat.equals("") || dateFormat == null)) { | |||
| m_DateFormat = new SimpleDateFormat(dateFormat); | |||
| } | |||
| } | |||
| @@ -233,12 +233,14 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * @param cmd the commandline the command is to be added to | |||
| */ | |||
| private void getVersionDateCommand(Commandline cmd) throws BuildException { | |||
| if ( m_FromDate == null && m_ToDate == null && m_NumDays == Integer.MIN_VALUE) { | |||
| if (m_FromDate == null && m_ToDate == null | |||
| && m_NumDays == Integer.MIN_VALUE) { | |||
| return; | |||
| } | |||
| if ( m_FromDate != null && m_ToDate != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION_DATE + m_ToDate + VALUE_FROMDATE + m_FromDate); | |||
| if (m_FromDate != null && m_ToDate != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION_DATE + m_ToDate | |||
| + VALUE_FROMDATE + m_FromDate); | |||
| } else if (m_ToDate != null && m_NumDays != Integer.MIN_VALUE) { | |||
| String startDate = null; | |||
| try { | |||
| @@ -271,11 +273,11 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * @param cmd the commandline the command is to be added to | |||
| */ | |||
| private void getVersionLabelCommand(Commandline cmd) throws BuildException { | |||
| if ( m_FromLabel == null && m_ToLabel == null ) { | |||
| if (m_FromLabel == null && m_ToLabel == null) { | |||
| return; | |||
| } | |||
| if ( m_FromLabel != null && m_ToLabel != null) { | |||
| if (m_FromLabel != null && m_ToLabel != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_ToLabel + VALUE_FROMLABEL + m_FromLabel); | |||
| } else if (m_FromLabel != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION + VALUE_FROMLABEL + m_FromLabel); | |||
| @@ -289,7 +291,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * @param cmd the commandline the command is to be added to | |||
| */ | |||
| private void getOutputCommand(Commandline cmd) { | |||
| if ( m_OutputFileName != null) { | |||
| if (m_OutputFileName != null) { | |||
| cmd.createArgument().setValue(FLAG_OUTPUT + m_OutputFileName); | |||
| } | |||
| } | |||
| @@ -299,7 +301,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * @param cmd the commandline the command is to be added to | |||
| */ | |||
| private void getUserCommand(Commandline cmd) { | |||
| if ( m_User != null) { | |||
| if (m_User != null) { | |||
| cmd.createArgument().setValue(FLAG_USER + m_User); | |||
| } | |||
| } | |||
| @@ -312,7 +314,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| private String calcDate(String fromDate, int numDays) throws ParseException { | |||
| String toDate = null; | |||
| Date currdate = new Date(); | |||
| Calendar calend= new GregorianCalendar(); | |||
| Calendar calend = new GregorianCalendar(); | |||
| currdate = m_DateFormat.parse(fromDate); | |||
| calend.setTime(currdate); | |||
| calend.add(Calendar.DATE, numDays); | |||
| @@ -338,7 +340,7 @@ public class MSVSSHISTORY extends MSVSS { | |||
| * @return the 'recursive' command if the attribute was 'true', otherwise an empty string | |||
| */ | |||
| private void getRecursiveCommand(Commandline cmd) { | |||
| if ( !m_Recursive ) { | |||
| if (!m_Recursive) { | |||
| return; | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_RECURSION); | |||
| @@ -376,6 +378,4 @@ public class MSVSSHISTORY extends MSVSS { | |||
| return new String[] {"brief", "codediff", "nofile", "default"}; | |||
| } | |||
| } | |||
| } | |||
| @@ -152,7 +152,7 @@ public class MSVSSLABEL extends MSVSS | |||
| commandLine.createArgument().setValue(getVsspath()); | |||
| // -C | |||
| commandLine.createArgument().setValue("-C"+getComment()); | |||
| commandLine.createArgument().setValue("-C" + getComment()); | |||
| // -I- or -I-Y or -I-N | |||
| getAutoresponse(commandLine); | |||
| @@ -169,7 +169,7 @@ public class MSVSSLABEL extends MSVSS | |||
| getLoginCommand(commandLine); | |||
| result = run(commandLine); | |||
| if ( result != 0 ) { | |||
| if (result != 0) { | |||
| String msg = "Failed executing: " + commandLine.toString(); | |||
| throw new BuildException(msg, location); | |||
| } | |||
| @@ -185,7 +185,7 @@ public class MSVSSLABEL extends MSVSS | |||
| * has not been defined to ant! | |||
| */ | |||
| public void setLabel(String label) { | |||
| if ( label.equals("") || label.equals("null") ) { | |||
| if (label.equals("") || label.equals("null")) { | |||
| m_Label = null; | |||
| } else { | |||
| m_Label = label; | |||
| @@ -197,7 +197,7 @@ public class MSVSSLABEL extends MSVSS | |||
| * @param cmd the commandline the command is to be added to | |||
| */ | |||
| public void getVersionCommand(Commandline cmd) { | |||
| if ( m_Version != null) { | |||
| if (m_Version != null) { | |||
| cmd.createArgument().setValue(FLAG_VERSION + m_Version); | |||
| } | |||
| } | |||
| @@ -207,7 +207,7 @@ public class MSVSSLABEL extends MSVSS | |||
| * @param cmd the commandline the command is to be added to | |||
| */ | |||
| public void getLabelCommand(Commandline cmd) { | |||
| if ( m_Label != null) { | |||
| if (m_Label != null) { | |||
| cmd.createArgument().setValue(FLAG_LABEL + m_Label); | |||
| } | |||
| } | |||
| @@ -221,7 +221,7 @@ public class MSVSSLABEL extends MSVSS | |||
| * has not been defined to ant! | |||
| */ | |||
| public void setVersion(String version) { | |||
| if (version.equals("") || version.equals("null") ) { | |||
| if (version.equals("") || version.equals("null")) { | |||
| m_Version = null; | |||
| } else { | |||
| m_Version = version; | |||
| @@ -243,7 +243,7 @@ public class MSVSSLABEL extends MSVSS | |||
| * is what SourceSafe uses for an empty comment. | |||
| */ | |||
| public void setComment(String comment) { | |||
| if ( comment.equals("") || comment.equals("null") ) { | |||
| if (comment.equals("") || comment.equals("null")) { | |||
| m_Comment = "-"; | |||
| } else { | |||
| m_Comment = comment; | |||
| @@ -259,7 +259,7 @@ public class MSVSSLABEL extends MSVSS | |||
| } | |||
| public void setAutoresponse(String response){ | |||
| if ( response.equals("") || response.equals("null") ) { | |||
| if (response.equals("") || response.equals("null")) { | |||
| m_AutoResponse = null; | |||
| } else { | |||
| m_AutoResponse = response; | |||
| @@ -274,16 +274,15 @@ public class MSVSSLABEL extends MSVSS | |||
| */ | |||
| public void getAutoresponse(Commandline cmd) { | |||
| if ( m_AutoResponse == null) { | |||
| if (m_AutoResponse == null) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("Y")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); | |||
| } else if ( m_AutoResponse.equalsIgnoreCase("N")) { | |||
| } else if (m_AutoResponse.equalsIgnoreCase("N")) { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); | |||
| }else { | |||
| } else { | |||
| cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); | |||
| } // end of else | |||
| } | |||
| } | |||
| @@ -86,7 +86,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
| public DefaultRmicAdapter() { | |||
| } | |||
| public void setRmic( Rmic attributes ) { | |||
| public void setRmic(Rmic attributes) { | |||
| this.attributes = attributes; | |||
| mapper = new RmicFileNameMapper(); | |||
| } | |||
| @@ -146,11 +146,11 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
| // Combine the build classpath with the system classpath, in an | |||
| // order determined by the value of build.sysclasspath | |||
| if (attributes.getClasspath() == null) { | |||
| if ( attributes.getIncludeantruntime() ) { | |||
| if (attributes.getIncludeantruntime()) { | |||
| classpath.addExisting(Path.systemClasspath); | |||
| } | |||
| } else { | |||
| if ( attributes.getIncludeantruntime() ) { | |||
| if (attributes.getIncludeantruntime()) { | |||
| classpath.addExisting(attributes.getClasspath() | |||
| .concatSystemClasspath("last")); | |||
| } else { | |||
| @@ -182,7 +182,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
| Commandline cmd = new Commandline(); | |||
| if (options != null) { | |||
| for (int i=0; i<options.length; i++) { | |||
| for (int i = 0; i < options.length; i++) { | |||
| cmd.createArgument().setValue(options[i]); | |||
| } | |||
| } | |||
| @@ -222,27 +222,27 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
| cmd.createArgument().setValue("-keepgenerated"); | |||
| } | |||
| if( attributes.getIiop() ) { | |||
| if (attributes.getIiop()) { | |||
| attributes.log("IIOP has been turned on.", Project.MSG_INFO); | |||
| cmd.createArgument().setValue("-iiop"); | |||
| if( attributes.getIiopopts() != null ) { | |||
| if (attributes.getIiopopts() != null) { | |||
| attributes.log("IIOP Options: " + attributes.getIiopopts(), | |||
| Project.MSG_INFO ); | |||
| Project.MSG_INFO); | |||
| cmd.createArgument().setValue(attributes.getIiopopts()); | |||
| } | |||
| } | |||
| if( attributes.getIdl() ) { | |||
| if (attributes.getIdl()) { | |||
| cmd.createArgument().setValue("-idl"); | |||
| attributes.log("IDL has been turned on.", Project.MSG_INFO); | |||
| if( attributes.getIdlopts() != null ) { | |||
| if (attributes.getIdlopts() != null) { | |||
| cmd.createArgument().setValue(attributes.getIdlopts()); | |||
| attributes.log("IDL Options: " + attributes.getIdlopts(), | |||
| Project.MSG_INFO ); | |||
| Project.MSG_INFO); | |||
| } | |||
| } | |||
| if( attributes.getDebug()) { | |||
| if (attributes.getDebug()) { | |||
| cmd.createArgument().setValue("-g"); | |||
| } | |||
| @@ -266,8 +266,8 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
| } | |||
| niceSourceList.append(" to be compiled:"); | |||
| for (int i=0; i < compileList.size(); i++) { | |||
| String arg = (String)compileList.elementAt(i); | |||
| for (int i = 0; i < compileList.size(); i++) { | |||
| String arg = (String) compileList.elementAt(i); | |||
| cmd.createArgument().setValue(arg); | |||
| niceSourceList.append(" " + arg); | |||
| } | |||
| @@ -306,15 +306,15 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
| public String[] mapFileName(String name) { | |||
| if (name == null | |||
| || !name.endsWith(".class") | |||
| || name.endsWith(getStubClassSuffix()+".class") | |||
| || name.endsWith(getSkelClassSuffix()+".class") | |||
| || name.endsWith(getTieClassSuffix()+".class")) { | |||
| || name.endsWith(getStubClassSuffix() + ".class") | |||
| || name.endsWith(getSkelClassSuffix() + ".class") | |||
| || name.endsWith(getTieClassSuffix() + ".class")) { | |||
| // Not a .class file or the one we'd generate | |||
| return null; | |||
| } | |||
| // we know that name.endsWith(".class") | |||
| String base = name.substring(0, name.length()-6); | |||
| String base = name.substring(0, name.length() - 6); | |||
| String classname = base.replace(File.separatorChar, '.'); | |||
| if (attributes.getVerify() && | |||
| @@ -330,7 +330,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
| * This is supposed to make Ant always recompile the | |||
| * class, as a file of that name should not exist. | |||
| */ | |||
| String[] target = new String[] {name+".tmp."+rand.nextLong()}; | |||
| String[] target = new String[] {name + ".tmp." + rand.nextLong()}; | |||
| if (!attributes.getIiop() && !attributes.getIdl()) { | |||
| // JRMP with simple naming convention | |||
| @@ -413,5 +413,4 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
| return target; | |||
| } | |||
| } | |||
| } | |||
| @@ -80,7 +80,7 @@ public class KaffeRmic extends DefaultRmicAdapter { | |||
| Constructor cons = c.getConstructor(new Class[] { String[].class }); | |||
| Object rmic = cons.newInstance(new Object[] { cmd.getArguments() }); | |||
| Method doRmic = c.getMethod("run", null); | |||
| Boolean ok = (Boolean)doRmic.invoke(rmic, null); | |||
| Boolean ok = (Boolean) doRmic.invoke(rmic, null); | |||
| return ok.booleanValue(); | |||
| } catch (ClassNotFoundException ex) { | |||
| @@ -88,7 +88,7 @@ public class KaffeRmic extends DefaultRmicAdapter { | |||
| + "available. A common solution is to " | |||
| + "set the environment variable " | |||
| + "JAVA_HOME or CLASSPATH.", | |||
| getRmic().getLocation() ); | |||
| getRmic().getLocation()); | |||
| } catch (Exception ex) { | |||
| if (ex instanceof BuildException) { | |||
| throw (BuildException) ex; | |||
| @@ -79,7 +79,7 @@ public interface RmicAdapter { | |||
| /** | |||
| * Sets the rmic attributes, which are stored in the Rmic task. | |||
| */ | |||
| void setRmic( Rmic attributes ); | |||
| void setRmic(Rmic attributes); | |||
| /** | |||
| * Executes the task. | |||
| @@ -88,9 +88,9 @@ public class RmicAdapterFactory { | |||
| * @throws BuildException if the rmic type could not be resolved into | |||
| * a rmic adapter. | |||
| */ | |||
| public static RmicAdapter getRmic( String rmicType, Task task ) | |||
| public static RmicAdapter getRmic(String rmicType, Task task) | |||
| throws BuildException { | |||
| if( rmicType == null){ | |||
| if (rmicType == null) { | |||
| /* | |||
| * When not specified rmicType, search SUN's rmic and | |||
| * Kaffe's rmic. | |||
| @@ -110,14 +110,14 @@ public class RmicAdapterFactory { | |||
| } | |||
| } | |||
| if ( rmicType.equalsIgnoreCase("sun") ) { | |||
| if (rmicType.equalsIgnoreCase("sun")) { | |||
| return new SunRmic(); | |||
| } else if ( rmicType.equalsIgnoreCase("kaffe") ) { | |||
| } else if (rmicType.equalsIgnoreCase("kaffe")) { | |||
| return new KaffeRmic(); | |||
| } else if ( rmicType.equalsIgnoreCase("weblogic") ) { | |||
| } else if (rmicType.equalsIgnoreCase("weblogic")) { | |||
| return new WLRmic(); | |||
| } | |||
| return resolveClassName( rmicType ); | |||
| return resolveClassName(rmicType); | |||
| } | |||
| /** | |||
| @@ -128,18 +128,18 @@ public class RmicAdapterFactory { | |||
| * @throws BuildException This is the fit that is thrown if className | |||
| * isn't an instance of RmicAdapter. | |||
| */ | |||
| private static RmicAdapter resolveClassName( String className ) | |||
| private static RmicAdapter resolveClassName(String className) | |||
| throws BuildException { | |||
| try { | |||
| Class c = Class.forName( className ); | |||
| Class c = Class.forName(className); | |||
| Object o = c.newInstance(); | |||
| return (RmicAdapter) o; | |||
| } catch ( ClassNotFoundException cnfe ) { | |||
| throw new BuildException( className + " can\'t be found.", cnfe ); | |||
| } catch ( ClassCastException cce ) { | |||
| } catch (ClassNotFoundException cnfe) { | |||
| throw new BuildException(className + " can\'t be found.", cnfe); | |||
| } catch (ClassCastException cce) { | |||
| throw new BuildException(className + " isn\'t the classname of " | |||
| + "a rmic adapter.", cce); | |||
| } catch ( Throwable t ) { | |||
| } catch (Throwable t) { | |||
| // for all other possibilities | |||
| throw new BuildException(className + " caused an interesting " | |||
| + "exception.", t); | |||
| @@ -90,15 +90,15 @@ public class SunRmic extends DefaultRmicAdapter { | |||
| Method doRmic = c.getMethod("compile", | |||
| new Class [] { String[].class }); | |||
| Boolean ok = | |||
| (Boolean)doRmic.invoke(rmic, | |||
| (new Object[] {cmd.getArguments()} )); | |||
| (Boolean) doRmic.invoke(rmic, | |||
| (new Object[] {cmd.getArguments()})); | |||
| return ok.booleanValue(); | |||
| } catch (ClassNotFoundException ex) { | |||
| throw new BuildException("Cannot use SUN rmic, as it is not " | |||
| + "available. A common solution is to " | |||
| + "set the environment variable " | |||
| + "JAVA_HOME or CLASSPATH.", | |||
| getRmic().getLocation() ); | |||
| getRmic().getLocation()); | |||
| } catch (Exception ex) { | |||
| if (ex instanceof BuildException) { | |||
| throw (BuildException) ex; | |||
| @@ -94,7 +94,7 @@ public class WLRmic extends DefaultRmicAdapter { | |||
| throw new BuildException("Cannot use WebLogic rmic, as it is not " | |||
| + "available. A common solution is to " | |||
| + "set the environment variable " | |||
| + "CLASSPATH.", getRmic().getLocation() ); | |||
| + "CLASSPATH.", getRmic().getLocation()); | |||
| } catch (Exception ex) { | |||
| if (ex instanceof BuildException) { | |||
| throw (BuildException) ex; | |||
| @@ -283,8 +283,8 @@ public abstract class AbstractFileSet extends DataType implements Cloneable { | |||
| if (project != null) { | |||
| Hashtable typedefs = project.getDataTypeDefinitions(); | |||
| for (Enumeration e = typedefs.keys(); e.hasMoreElements();) { | |||
| String typeName = (String)e.nextElement(); | |||
| Class typeClass = (Class)typedefs.get(typeName); | |||
| String typeName = (String) e.nextElement(); | |||
| Class typeClass = (Class) typedefs.get(typeName); | |||
| if (typeClass == getClass()) { | |||
| return typeName; | |||
| } | |||
| @@ -314,11 +314,11 @@ public abstract class AbstractFileSet extends DataType implements Cloneable { | |||
| } | |||
| if (!dir.exists()) { | |||
| throw new BuildException(dir.getAbsolutePath()+" not found."); | |||
| throw new BuildException(dir.getAbsolutePath() + " not found."); | |||
| } | |||
| if (!dir.isDirectory()) { | |||
| throw new BuildException(dir.getAbsolutePath() | |||
| +" is not a directory."); | |||
| + " is not a directory."); | |||
| } | |||
| DirectoryScanner ds = new DirectoryScanner(); | |||
| @@ -341,7 +341,7 @@ public abstract class AbstractFileSet extends DataType implements Cloneable { | |||
| } | |||
| p.log(getDataTypeName() + ": Setup scanner in dir " + dir + | |||
| " with " + defaultPatterns, Project.MSG_DEBUG ); | |||
| " with " + defaultPatterns, Project.MSG_DEBUG); | |||
| ds.setIncludes(defaultPatterns.getIncludePatterns(p)); | |||
| ds.setExcludes(defaultPatterns.getExcludePatterns(p)); | |||
| @@ -364,7 +364,7 @@ public abstract class AbstractFileSet extends DataType implements Cloneable { | |||
| Object o = ref.getReferencedObject(p); | |||
| if (!getClass().isAssignableFrom(o.getClass())) { | |||
| String msg = ref.getRefId()+" doesn\'t denote a " | |||
| String msg = ref.getRefId() + " doesn\'t denote a " | |||
| + getDataTypeName(); | |||
| throw new BuildException(msg); | |||
| } else { | |||
| @@ -92,7 +92,7 @@ public class Commandline implements Cloneable { | |||
| String[] tmp = translateCommandline(to_process); | |||
| if (tmp != null && tmp.length > 0) { | |||
| setExecutable(tmp[0]); | |||
| for (int i=1; i<tmp.length; i++) { | |||
| for (int i = 1; i < tmp.length; i++) { | |||
| createArgument().setValue(tmp[i]); | |||
| } | |||
| } | |||
| @@ -124,7 +124,7 @@ public class Commandline implements Cloneable { | |||
| * @param line line to split into several commandline arguments | |||
| */ | |||
| public void setLine(String line) { | |||
| if( line == null ) { | |||
| if (line == null) { | |||
| return; | |||
| } | |||
| parts = translateCommandline(line); | |||
| @@ -183,7 +183,7 @@ public class Commandline implements Cloneable { | |||
| public int getPosition() { | |||
| if (realPos == -1) { | |||
| realPos = (executable == null ? 0 : 1); | |||
| for (int i=0; i<position; i++) { | |||
| for (int i = 0; i < position; i++) { | |||
| Argument arg = (Argument) arguments.elementAt(i); | |||
| realPos += arg.getParts().length; | |||
| } | |||
| @@ -203,7 +203,7 @@ public class Commandline implements Cloneable { | |||
| * @return the argument object. | |||
| */ | |||
| public Argument createArgument() { | |||
| return this.createArgument( false ); | |||
| return this.createArgument(false); | |||
| } | |||
| /** | |||
| @@ -215,10 +215,10 @@ public class Commandline implements Cloneable { | |||
| * @param insertAtStart if true, the argument is inserted at the | |||
| * beginning of the list of args, otherwise it is appended. | |||
| */ | |||
| public Argument createArgument( boolean insertAtStart ) { | |||
| public Argument createArgument(boolean insertAtStart) { | |||
| Argument argument = new Argument(); | |||
| if(insertAtStart) { | |||
| arguments.insertElementAt(argument,0); | |||
| if (insertAtStart) { | |||
| arguments.insertElementAt(argument, 0); | |||
| } else { | |||
| arguments.addElement(argument); | |||
| } | |||
| @@ -243,7 +243,7 @@ public class Commandline implements Cloneable { | |||
| public void addArguments(String[] line) { | |||
| for (int i=0; i < line.length; i++) { | |||
| for (int i = 0; i < line.length; i++) { | |||
| createArgument().setValue(line[i]); | |||
| } | |||
| } | |||
| @@ -256,7 +256,7 @@ public class Commandline implements Cloneable { | |||
| if (executable == null) { | |||
| return args; | |||
| } | |||
| final String[] result = new String[args.length+1]; | |||
| final String[] result = new String[args.length + 1]; | |||
| result[0] = executable; | |||
| System.arraycopy(args, 0, result, 1, args.length); | |||
| return result; | |||
| @@ -268,12 +268,12 @@ public class Commandline implements Cloneable { | |||
| * <code>addValue</code> or the argument object. | |||
| */ | |||
| public String[] getArguments() { | |||
| Vector result = new Vector(arguments.size()*2); | |||
| for (int i=0; i<arguments.size(); i++) { | |||
| Vector result = new Vector(arguments.size() * 2); | |||
| for (int i = 0; i < arguments.size(); i++) { | |||
| Argument arg = (Argument) arguments.elementAt(i); | |||
| String[] s = arg.getParts(); | |||
| if( s != null ) { | |||
| for (int j=0; j<s.length; j++) { | |||
| if (s != null) { | |||
| for (int j = 0; j < s.length; j++) { | |||
| result.addElement(s[j]); | |||
| } | |||
| } | |||
| @@ -304,10 +304,10 @@ public class Commandline implements Cloneable { | |||
| if (argument.indexOf("\'") > -1) { | |||
| throw new BuildException("Can\'t handle single and double quotes in same argument"); | |||
| } else { | |||
| return '\''+argument+'\''; | |||
| return '\'' + argument + '\''; | |||
| } | |||
| } else if (argument.indexOf("\'") > -1 || argument.indexOf(" ") > -1) { | |||
| return '\"'+argument+'\"'; | |||
| return '\"' + argument + '\"'; | |||
| } else { | |||
| return argument; | |||
| } | |||
| @@ -321,7 +321,7 @@ public class Commandline implements Cloneable { | |||
| // path containing one or more elements | |||
| final StringBuffer result = new StringBuffer(); | |||
| for (int i=0; i < line.length; i++) { | |||
| for (int i = 0; i < line.length; i++) { | |||
| if (i > 0) { | |||
| result.append(' '); | |||
| } | |||
| @@ -112,11 +112,11 @@ public class CommandlineJava implements Cloneable { | |||
| try { | |||
| sys = System.getProperties(); | |||
| Properties p = new Properties(); | |||
| for (Enumeration e = sys.keys(); e.hasMoreElements(); ) { | |||
| for (Enumeration e = sys.keys(); e.hasMoreElements();) { | |||
| Object o = e.nextElement(); | |||
| p.put(o, sys.get(o)); | |||
| } | |||
| for (Enumeration e = variables.elements(); e.hasMoreElements(); ) { | |||
| for (Enumeration e = variables.elements(); e.hasMoreElements();) { | |||
| Environment.Variable v = (Environment.Variable) e.nextElement(); | |||
| p.put(v.getKey(), v.getValue()); | |||
| } | |||
| @@ -144,7 +144,9 @@ public class CommandlineJava implements Cloneable { | |||
| SysProperties c = (SysProperties) super.clone(); | |||
| c.variables = (Vector) variables.clone(); | |||
| return c; | |||
| } catch(CloneNotSupportedException e){return null;} | |||
| } catch (CloneNotSupportedException e) { | |||
| return null; | |||
| } | |||
| } | |||
| } | |||
| @@ -282,7 +284,7 @@ public class CommandlineJava implements Cloneable { | |||
| } | |||
| private Commandline getActualVMCommand() { | |||
| Commandline actualVMCommand = (Commandline)vmCommand.clone(); | |||
| Commandline actualVMCommand = (Commandline) vmCommand.clone(); | |||
| if (maxMemory != null) { | |||
| if (vmVersion.startsWith("1.1")) { | |||
| actualVMCommand.createArgument().setValue("-mx" + maxMemory); | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -95,8 +95,8 @@ public abstract class DataType extends ProjectComponent { | |||
| * Sets a description of the current data type. It will be useful | |||
| * in commenting what we are doing. | |||
| */ | |||
| public void setDescription( String desc ) { | |||
| description=desc; | |||
| public void setDescription(String desc) { | |||
| description = desc; | |||
| } | |||
| /** | |||
| @@ -175,7 +175,7 @@ public abstract class DataType extends ProjectComponent { | |||
| Object o = ref.getReferencedObject(getProject()); | |||
| if (!(requiredClass.isAssignableFrom(o.getClass()))) { | |||
| String msg = ref.getRefId()+" doesn\'t denote a " + dataTypeName; | |||
| String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName; | |||
| throw new BuildException(msg); | |||
| } else { | |||
| return o; | |||
| @@ -187,8 +187,8 @@ public abstract class DataType extends ProjectComponent { | |||
| * only attribute if it is set. | |||
| */ | |||
| protected BuildException tooManyAttributes() { | |||
| return new BuildException( "You must not specify more than one attribute" + | |||
| " when using refid" ); | |||
| return new BuildException("You must not specify more than one " | |||
| + "attribute when using refid"); | |||
| } | |||
| /** | |||
| @@ -196,7 +196,8 @@ public abstract class DataType extends ProjectComponent { | |||
| * not have child elements if the refid attribute is set. | |||
| */ | |||
| protected BuildException noChildrenAllowed() { | |||
| return new BuildException("You must not specify nested elements when using refid"); | |||
| return new BuildException("You must not specify nested elements " | |||
| + "when using refid"); | |||
| } | |||
| /** | |||
| @@ -204,6 +205,7 @@ public abstract class DataType extends ProjectComponent { | |||
| * loop of data types referencing each other. | |||
| */ | |||
| protected BuildException circularReference() { | |||
| return new BuildException("This data type contains a circular reference."); | |||
| return new BuildException("This data type contains a circular " | |||
| + "reference."); | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000,2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -120,7 +120,7 @@ public class Environment { | |||
| return null; | |||
| } | |||
| String[] result = new String[variables.size()]; | |||
| for (int i=0; i<result.length; i++) { | |||
| for (int i = 0; i < result.length; i++) { | |||
| result[i] = ((Variable) variables.elementAt(i)).getContent(); | |||
| } | |||
| return result; | |||
| @@ -163,7 +163,7 @@ public class FileList extends DataType { | |||
| Object o = ref.getReferencedObject(p); | |||
| if (!(o instanceof FileList)) { | |||
| String msg = ref.getRefId()+" doesn\'t denote a filelist"; | |||
| String msg = ref.getRefId() + " doesn\'t denote a filelist"; | |||
| throw new BuildException(msg); | |||
| } else { | |||
| return (FileList) o; | |||
| @@ -112,7 +112,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
| * | |||
| * @param token The new Token value | |||
| */ | |||
| public void setToken( String token ) { | |||
| public void setToken(String token) { | |||
| this.token = token; | |||
| } | |||
| @@ -121,7 +121,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
| * | |||
| * @param value The new Value value | |||
| */ | |||
| public void setValue( String value ) { | |||
| public void setValue(String value) { | |||
| this.value = value; | |||
| } | |||
| @@ -191,7 +191,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
| */ | |||
| protected FilterSet(FilterSet filterset) { | |||
| super(); | |||
| this.filters = (Vector)filterset.getFilters().clone(); | |||
| this.filters = (Vector) filterset.getFilters().clone(); | |||
| } | |||
| protected Vector getFilters() { | |||
| @@ -202,7 +202,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
| } | |||
| protected FilterSet getRef() { | |||
| return (FilterSet)getCheckedRef(FilterSet.class, "filterset"); | |||
| return (FilterSet) getCheckedRef(FilterSet.class, "filterset"); | |||
| } | |||
| /** | |||
| @@ -261,7 +261,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
| * | |||
| * @param endOfToken The new Endtoken value | |||
| */ | |||
| public void setEndToken( String endOfToken ) { | |||
| public void setEndToken(String endOfToken) { | |||
| if (isReference()) { | |||
| throw tooManyAttributes(); | |||
| } | |||
| @@ -292,7 +292,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
| } | |||
| if (filtersFile.isFile()) { | |||
| log("Reading filters from " + filtersFile, Project.MSG_VERBOSE ); | |||
| log("Reading filters from " + filtersFile, Project.MSG_VERBOSE); | |||
| FileInputStream in = null; | |||
| try { | |||
| Properties props = new Properties(); | |||
| @@ -308,10 +308,11 @@ public class FilterSet extends DataType implements Cloneable { | |||
| } | |||
| } | |||
| catch (Exception e) { | |||
| throw new BuildException( "Could not read filters from file: " + filtersFile ); | |||
| throw new BuildException("Could not read filters from file: " | |||
| + filtersFile); | |||
| } | |||
| finally { | |||
| if ( in != null ) { | |||
| if (in != null) { | |||
| try { | |||
| in.close(); | |||
| } | |||
| @@ -321,7 +322,8 @@ public class FilterSet extends DataType implements Cloneable { | |||
| } | |||
| } | |||
| else { | |||
| throw new BuildException( "Must specify a file not a directory in the filtersfile attribute:" + filtersFile ); | |||
| throw new BuildException("Must specify a file not a directory in " | |||
| + "the filtersfile attribute:" + filtersFile); | |||
| } | |||
| } | |||
| @@ -346,24 +348,28 @@ public class FilterSet extends DataType implements Cloneable { | |||
| String value = null; | |||
| do { | |||
| int endIndex = line.indexOf(endToken, index + beginToken.length() + 1 ); | |||
| int endIndex = line.indexOf(endToken, | |||
| index + beginToken.length() + 1); | |||
| if (endIndex == -1) { | |||
| break; | |||
| } | |||
| token = line.substring(index + beginToken.length(), endIndex ); | |||
| token | |||
| = line.substring(index + beginToken.length(), endIndex); | |||
| b.append(line.substring(i, index)); | |||
| if (tokens.containsKey(token)) { | |||
| value = (String)tokens.get(token); | |||
| log( "Replacing: " + beginToken + token + endToken + " -> " + value, Project.MSG_VERBOSE ); | |||
| value = (String) tokens.get(token); | |||
| log("Replacing: " + beginToken + token + endToken | |||
| + " -> " + value, Project.MSG_VERBOSE); | |||
| b.append(value); | |||
| i = index + beginToken.length() + token.length() + endToken.length(); | |||
| i = index + beginToken.length() + token.length() | |||
| + endToken.length(); | |||
| } | |||
| else { | |||
| // just append beginToken and search further | |||
| b.append(beginToken); | |||
| i = index + beginToken.length(); | |||
| } | |||
| } while ((index = line.indexOf( beginToken, i )) > -1 ); | |||
| } while ((index = line.indexOf(beginToken, i)) > -1); | |||
| b.append(line.substring(i)); | |||
| return b.toString(); | |||
| @@ -101,7 +101,7 @@ public class FilterSetCollection { | |||
| public String replaceTokens(String line) { | |||
| String replacedLine = line; | |||
| for (Enumeration e = filterSets.elements(); e.hasMoreElements();) { | |||
| FilterSet filterSet = (FilterSet)e.nextElement(); | |||
| FilterSet filterSet = (FilterSet) e.nextElement(); | |||
| replacedLine = filterSet.replaceTokens(replacedLine); | |||
| } | |||
| return replacedLine; | |||
| @@ -114,7 +114,7 @@ public class FilterSetCollection { | |||
| */ | |||
| public boolean hasFilters() { | |||
| for (Enumeration e = filterSets.elements(); e.hasMoreElements();) { | |||
| FilterSet filterSet = (FilterSet)e.nextElement(); | |||
| FilterSet filterSet = (FilterSet) e.nextElement(); | |||
| if (filterSet.hasFilters()) { | |||
| return true; | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -233,7 +233,7 @@ public class Mapper extends DataType implements Cloneable { | |||
| Object o = ref.getReferencedObject(getProject()); | |||
| if (!(o instanceof Mapper)) { | |||
| String msg = ref.getRefId()+" doesn\'t denote a mapper"; | |||
| String msg = ref.getRefId() + " doesn\'t denote a mapper"; | |||
| throw new BuildException(msg); | |||
| } else { | |||
| return (Mapper) o; | |||
| @@ -241,7 +241,7 @@ public class Path extends DataType implements Cloneable { | |||
| return; | |||
| } | |||
| String[] l = other.list(); | |||
| for (int i=0; i<l.length; i++) { | |||
| for (int i = 0; i < l.length; i++) { | |||
| if (elements.indexOf(l[i]) == -1) { | |||
| elements.addElement(l[i]); | |||
| } | |||
| @@ -256,7 +256,7 @@ public class Path extends DataType implements Cloneable { | |||
| */ | |||
| public void addExisting(Path source) { | |||
| String[] list = source.list(); | |||
| for (int i=0; i<list.length; i++) { | |||
| for (int i = 0; i < list.length; i++) { | |||
| File f = null; | |||
| if (getProject() != null) { | |||
| f = getProject().resolveFile(list[i]); | |||
| @@ -286,15 +286,15 @@ public class Path extends DataType implements Cloneable { | |||
| dieOnCircularReference(stk, getProject()); | |||
| } | |||
| Vector result = new Vector(2*elements.size()); | |||
| for (int i=0; i<elements.size(); i++) { | |||
| Vector result = new Vector(2 * elements.size()); | |||
| for (int i = 0; i < elements.size(); i++) { | |||
| Object o = elements.elementAt(i); | |||
| if (o instanceof Reference) { | |||
| Reference r = (Reference) o; | |||
| o = r.getReferencedObject(getProject()); | |||
| // we only support references to paths right now | |||
| if (!(o instanceof Path)) { | |||
| String msg = r.getRefId()+" doesn\'t denote a path"; | |||
| String msg = r.getRefId() + " doesn\'t denote a path"; | |||
| throw new BuildException(msg); | |||
| } | |||
| } | |||
| @@ -305,9 +305,10 @@ public class Path extends DataType implements Cloneable { | |||
| } else if (o instanceof PathElement) { | |||
| String[] parts = ((PathElement) o).getParts(); | |||
| if (parts == null) { | |||
| throw new BuildException("You must either set location or path on <pathelement>"); | |||
| throw new BuildException("You must either set location or" | |||
| + " path on <pathelement>"); | |||
| } | |||
| for (int j=0; j<parts.length; j++) { | |||
| for (int j = 0; j < parts.length; j++) { | |||
| addUnlessPresent(result, parts[j]); | |||
| } | |||
| } else if (o instanceof Path) { | |||
| @@ -316,7 +317,7 @@ public class Path extends DataType implements Cloneable { | |||
| p.setProject(getProject()); | |||
| } | |||
| String[] parts = p.list(); | |||
| for (int j=0; j<parts.length; j++) { | |||
| for (int j = 0; j < parts.length; j++) { | |||
| addUnlessPresent(result, parts[j]); | |||
| } | |||
| } else if (o instanceof DirSet) { | |||
| @@ -359,7 +360,7 @@ public class Path extends DataType implements Cloneable { | |||
| // path containing one or more elements | |||
| final StringBuffer result = new StringBuffer(list[0].toString()); | |||
| for (int i=1; i < list.length; i++) { | |||
| for (int i = 1; i < list.length; i++) { | |||
| result.append(File.pathSeparatorChar); | |||
| result.append(list[i]); | |||
| } | |||
| @@ -385,10 +386,11 @@ public class Path extends DataType implements Cloneable { | |||
| element.append(resolveFile(project, pathElement)); | |||
| } | |||
| catch (BuildException e) { | |||
| project.log("Dropping path element " + pathElement + " as it is not valid relative to the project", | |||
| Project.MSG_VERBOSE); | |||
| project.log("Dropping path element " + pathElement | |||
| + " as it is not valid relative to the project", | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| for (int i=0; i<element.length(); i++) { | |||
| for (int i = 0; i < element.length(); i++) { | |||
| translateFileSep(element, i); | |||
| } | |||
| result.addElement(element.toString()); | |||
| @@ -408,7 +410,7 @@ public class Path extends DataType implements Cloneable { | |||
| } | |||
| final StringBuffer result = new StringBuffer(source); | |||
| for (int i=0; i < result.length(); i++) { | |||
| for (int i = 0; i < result.length(); i++) { | |||
| translateFileSep(result, i); | |||
| } | |||
| @@ -502,7 +504,7 @@ public class Path extends DataType implements Cloneable { | |||
| * to the Vector if they are not already included. | |||
| */ | |||
| private static void addUnlessPresent(Vector v, File dir, String[] s) { | |||
| for (int j=0; j<s.length; j++) { | |||
| for (int j = 0; j < s.length; j++) { | |||
| File d = new File(dir, s[j]); | |||
| String absolutePath = d.getAbsolutePath(); | |||
| addUnlessPresent(v, translateFile(absolutePath)); | |||
| @@ -571,10 +573,11 @@ public class Path extends DataType implements Cloneable { | |||
| if (System.getProperty("java.vendor").toLowerCase(Locale.US).indexOf("microsoft") >= 0) { | |||
| // Pull in *.zip from packages directory | |||
| FileSet msZipFiles = new FileSet(); | |||
| msZipFiles.setDir(new File(System.getProperty("java.home") + File.separator + "Packages")); | |||
| msZipFiles.setDir(new File(System.getProperty("java.home") | |||
| + File.separator + "Packages")); | |||
| msZipFiles.setIncludes("*.ZIP"); | |||
| addFileset(msZipFiles); | |||
| } else if("Kaffe".equals(System.getProperty("java.vm.name"))) { | |||
| } else if ("Kaffe".equals(System.getProperty("java.vm.name"))) { | |||
| FileSet kaffeJarFiles = new FileSet(); | |||
| kaffeJarFiles.setDir(new File(System.getProperty("java.home") | |||
| + File.separator + "share" | |||
| @@ -599,7 +602,7 @@ public class Path extends DataType implements Cloneable { | |||
| // sort it out. | |||
| addExisting(new Path(null, | |||
| System.getProperty("java.home") | |||
| + File.separator +"jre" | |||
| + File.separator + "jre" | |||
| + File.separator + "lib" | |||
| + File.separator + "rt.jar")); | |||
| @@ -635,7 +638,7 @@ public class Path extends DataType implements Cloneable { | |||
| } | |||
| String[] dirs = extdirs.list(); | |||
| for (int i=0; i<dirs.length; i++) { | |||
| for (int i = 0; i < dirs.length; i++) { | |||
| File dir = getProject().resolveFile(dirs[i]); | |||
| if (dir.exists() && dir.isDirectory()) { | |||
| FileSet fs = new FileSet(); | |||
| @@ -173,13 +173,13 @@ public class PatternSet extends DataType { | |||
| String[] nestedExcludes = p.getExcludePatterns(getProject()); | |||
| if (nestedIncludes != null) { | |||
| for (int i=0; i < nestedIncludes.length; i++) { | |||
| for (int i = 0; i < nestedIncludes.length; i++) { | |||
| createInclude().setName(nestedIncludes[i]); | |||
| } | |||
| } | |||
| if (nestedExcludes != null) { | |||
| for (int i=0; i < nestedExcludes.length; i++) { | |||
| for (int i = 0; i < nestedExcludes.length; i++) { | |||
| createExclude().setName(nestedExcludes[i]); | |||
| } | |||
| } | |||
| @@ -317,15 +317,15 @@ public class PatternSet extends DataType { | |||
| } | |||
| line = patternReader.readLine(); | |||
| } | |||
| } catch(IOException ioe) { | |||
| } catch (IOException ioe) { | |||
| String msg = "An error occured while reading from pattern file: " | |||
| + patternfile; | |||
| throw new BuildException(msg, ioe); | |||
| } finally { | |||
| if( null != patternReader ) { | |||
| if (null != patternReader) { | |||
| try { | |||
| patternReader.close(); | |||
| } catch(IOException ioe) { | |||
| } catch (IOException ioe) { | |||
| //Ignore exception | |||
| } | |||
| } | |||
| @@ -342,14 +342,14 @@ public class PatternSet extends DataType { | |||
| String[] incl = other.getIncludePatterns(p); | |||
| if (incl != null) { | |||
| for (int i=0; i<incl.length; i++) { | |||
| for (int i = 0; i < incl.length; i++) { | |||
| createInclude().setName(incl[i]); | |||
| } | |||
| } | |||
| String[] excl = other.getExcludePatterns(p); | |||
| if (excl != null) { | |||
| for (int i=0; i<excl.length; i++) { | |||
| for (int i = 0; i < excl.length; i++) { | |||
| createExclude().setName(excl[i]); | |||
| } | |||
| } | |||
| @@ -400,7 +400,7 @@ public class PatternSet extends DataType { | |||
| Object o = ref.getReferencedObject(p); | |||
| if (!(o instanceof PatternSet)) { | |||
| String msg = ref.getRefId()+" doesn\'t denote a patternset"; | |||
| String msg = ref.getRefId() + " doesn\'t denote a patternset"; | |||
| throw new BuildException(msg); | |||
| } else { | |||
| return (PatternSet) o; | |||
| @@ -417,7 +417,7 @@ public class PatternSet extends DataType { | |||
| Vector tmpNames = new Vector(); | |||
| for (Enumeration e = list.elements() ; e.hasMoreElements() ;) { | |||
| NameEntry ne = (NameEntry)e.nextElement(); | |||
| NameEntry ne = (NameEntry) e.nextElement(); | |||
| String pattern = ne.evalName(p); | |||
| if (pattern != null && pattern.length() > 0) { | |||
| tmpNames.addElement(pattern); | |||
| @@ -436,7 +436,7 @@ public class PatternSet extends DataType { | |||
| if (includesFileList.size() > 0) { | |||
| Enumeration e = includesFileList.elements(); | |||
| while (e.hasMoreElements()) { | |||
| NameEntry ne = (NameEntry)e.nextElement(); | |||
| NameEntry ne = (NameEntry) e.nextElement(); | |||
| String fileName = ne.evalName(p); | |||
| if (fileName != null) { | |||
| File inclFile = p.resolveFile(fileName); | |||
| @@ -454,7 +454,7 @@ public class PatternSet extends DataType { | |||
| if (excludesFileList.size() > 0) { | |||
| Enumeration e = excludesFileList.elements(); | |||
| while (e.hasMoreElements()) { | |||
| NameEntry ne = (NameEntry)e.nextElement(); | |||
| NameEntry ne = (NameEntry) e.nextElement(); | |||
| String fileName = ne.evalName(p); | |||
| if (fileName != null) { | |||
| File exclFile = p.resolveFile(fileName); | |||
| @@ -90,7 +90,7 @@ public class Reference { | |||
| Object o = project.getReference(refid); | |||
| if (o == null) { | |||
| throw new BuildException("Reference "+refid+" not found."); | |||
| throw new BuildException("Reference " + refid + " not found."); | |||
| } | |||
| return o; | |||
| } | |||
| @@ -153,7 +153,8 @@ public class RegularExpression extends DataType | |||
| Object o = ref.getReferencedObject(p); | |||
| if (!(o instanceof RegularExpression)) | |||
| { | |||
| String msg = ref.getRefId() + " doesn\'t denote a "+DATA_TYPE_NAME; | |||
| String msg = ref.getRefId() + " doesn\'t denote a " | |||
| + DATA_TYPE_NAME; | |||
| throw new BuildException(msg); | |||
| } | |||
| else | |||
| @@ -228,7 +228,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver { | |||
| log("No match, parser will use: '" + systemId + "'", | |||
| Project.MSG_DEBUG); | |||
| } | |||
| } catch ( IOException ioe) { | |||
| } catch (IOException ioe) { | |||
| //ignore | |||
| } | |||
| } | |||
| @@ -254,7 +254,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver { | |||
| Enumeration elements = getElements().elements(); | |||
| DTDLocation element = null; | |||
| while (elements.hasMoreElements()) { | |||
| element = (DTDLocation)elements.nextElement(); | |||
| element = (DTDLocation) elements.nextElement(); | |||
| if (element.getPublicId().equals(publicId)) { | |||
| return element; | |||
| } | |||
| @@ -196,7 +196,7 @@ public class ZipFileSet extends FileSet { | |||
| Object o = ref.getReferencedObject(p); | |||
| if (!(o instanceof FileSet)) { | |||
| String msg = ref.getRefId()+" doesn\'t denote a fileset"; | |||
| String msg = ref.getRefId() + " doesn\'t denote a fileset"; | |||
| throw new BuildException(msg); | |||
| } else { | |||
| return (AbstractFileSet) o; | |||
| @@ -132,7 +132,7 @@ public class ClassfileSet extends FileSet { | |||
| */ | |||
| protected ClassfileSet(ClassfileSet s) { | |||
| super(s); | |||
| rootClasses = (Vector)s.rootClasses.clone(); | |||
| rootClasses = (Vector) s.rootClasses.clone(); | |||
| } | |||
| /** | |||
| @@ -156,9 +156,9 @@ public class ClassfileSet extends FileSet { | |||
| return getRef(p).getDirectoryScanner(p); | |||
| } | |||
| Vector allRootClasses = (Vector)rootClasses.clone(); | |||
| Vector allRootClasses = (Vector) rootClasses.clone(); | |||
| for (Enumeration e = rootFileSets.elements(); e.hasMoreElements();) { | |||
| FileSet additionalRootSet = (FileSet)e.nextElement(); | |||
| FileSet additionalRootSet = (FileSet) e.nextElement(); | |||
| DirectoryScanner additionalScanner | |||
| = additionalRootSet.getDirectoryScanner(p); | |||
| String[] files = additionalScanner.getIncludedFiles(); | |||
| @@ -145,7 +145,7 @@ public class DependScanner extends DirectoryScanner { | |||
| int count = included.size(); | |||
| String[] files = new String[count]; | |||
| for (int i = 0; i < count; i++) { | |||
| files[i] = (String)included.elementAt(i); | |||
| files[i] = (String) included.elementAt(i); | |||
| } | |||
| return files; | |||
| } | |||
| @@ -161,7 +161,7 @@ public class DependScanner extends DirectoryScanner { | |||
| DependencyAnalyzer analyzer = null; | |||
| try { | |||
| Class analyzerClass = Class.forName(analyzerClassName); | |||
| analyzer = (DependencyAnalyzer)analyzerClass.newInstance(); | |||
| analyzer = (DependencyAnalyzer) analyzerClass.newInstance(); | |||
| } catch (Exception e) { | |||
| throw new BuildException("Unable to load dependency analyzer: " | |||
| + analyzerClassName, e); | |||
| @@ -169,7 +169,7 @@ public class DependScanner extends DirectoryScanner { | |||
| analyzer.addClassPath(new Path(null, basedir.getPath())); | |||
| for (Enumeration e = rootClasses.elements(); e.hasMoreElements();) { | |||
| String rootClass = (String)e.nextElement(); | |||
| String rootClass = (String) e.nextElement(); | |||
| analyzer.addRootClass(rootClass); | |||
| } | |||
| @@ -182,7 +182,7 @@ public class DependScanner extends DirectoryScanner { | |||
| } | |||
| while (e.hasMoreElements()) { | |||
| String classname = (String)e.nextElement(); | |||
| String classname = (String) e.nextElement(); | |||
| String filename = classname.replace('.', File.separatorChar); | |||
| filename = filename + ".class"; | |||
| File depFile = new File(basedir, filename); | |||
| @@ -151,7 +151,7 @@ public class DOMElementWriter { | |||
| out.write(lSep); | |||
| hasChildren = true; | |||
| } | |||
| write((Element)child, out, indent + 1, indentWith); | |||
| write((Element) child, out, indent + 1, indentWith); | |||
| break; | |||
| case Node.TEXT_NODE: | |||
| @@ -160,7 +160,7 @@ public class DOMElementWriter { | |||
| case Node.CDATA_SECTION_NODE: | |||
| out.write("<![CDATA["); | |||
| out.write(encodedata(((Text)child).getData())); | |||
| out.write(encodedata(((Text) child).getData())); | |||
| out.write("]]>"); | |||
| break; | |||
| @@ -174,7 +174,7 @@ public class DOMElementWriter { | |||
| out.write("<?"); | |||
| out.write(child.getNodeName()); | |||
| String data = child.getNodeValue(); | |||
| if ( data != null && data.length() > 0 ) { | |||
| if (data != null && data.length() > 0) { | |||
| out.write(' '); | |||
| out.write(data); | |||
| } | |||
| @@ -206,7 +206,7 @@ public class DOMElementWriter { | |||
| */ | |||
| public String encode(String value) { | |||
| sb.setLength(0); | |||
| for (int i=0; i<value.length(); i++) { | |||
| for (int i = 0; i < value.length(); i++) { | |||
| char c = value.charAt(i); | |||
| switch (c) { | |||
| case '<': | |||
| @@ -224,7 +224,7 @@ public class DOMElementWriter { | |||
| case '&': | |||
| int nextSemi = value.indexOf(";", i); | |||
| if (nextSemi < 0 | |||
| || !isReference(value.substring(i, nextSemi+1))) { | |||
| || !isReference(value.substring(i, nextSemi + 1))) { | |||
| sb.append("&"); | |||
| } else { | |||
| sb.append('&'); | |||
| @@ -268,14 +268,14 @@ public class DOMElementWriter { | |||
| if (ent.charAt(1) == '#') { | |||
| if (ent.charAt(2) == 'x') { | |||
| try { | |||
| Integer.parseInt(ent.substring(3, ent.length()-1), 16); | |||
| Integer.parseInt(ent.substring(3, ent.length() - 1), 16); | |||
| return true; | |||
| } catch (NumberFormatException nfe) { | |||
| return false; | |||
| } | |||
| } else { | |||
| try { | |||
| Integer.parseInt(ent.substring(2, ent.length()-1)); | |||
| Integer.parseInt(ent.substring(2, ent.length() - 1)); | |||
| return true; | |||
| } catch (NumberFormatException nfe) { | |||
| return false; | |||
| @@ -284,7 +284,7 @@ public class DOMElementWriter { | |||
| } | |||
| String name = ent.substring(1, ent.length() - 1); | |||
| for (int i=0; i<knownEntities.length; i++) { | |||
| for (int i = 0; i < knownEntities.length; i++) { | |||
| if (name.equals(knownEntities[i])) { | |||
| return true; | |||
| } | |||
| @@ -296,7 +296,8 @@ public class DOMElementWriter { | |||
| * Is the given character allowed inside an XML document? | |||
| * | |||
| * <p>See XML 1.0 2.2 <a | |||
| * href="http://www.w3.org/TR/1998/REC-xml-19980210#charsets">http://www.w3.org/TR/1998/REC-xml-19980210#charsets</a>.</p> | |||
| * href="http://www.w3.org/TR/1998/REC-xml-19980210#charsets"> | |||
| * http://www.w3.org/TR/1998/REC-xml-19980210#charsets</a>.</p> | |||
| * | |||
| * @since 1.10, Ant 1.5 | |||
| */ | |||
| @@ -212,7 +212,7 @@ public final class DateUtils { | |||
| */ | |||
| public static int getPhaseOfMoon(Calendar cal) { | |||
| int dayOfTheYear = cal.get(Calendar.DAY_OF_YEAR); | |||
| int yearInMetonicCycle = ((cal.get(Calendar.YEAR)-1900) % 19) + 1; | |||
| int yearInMetonicCycle = ((cal.get(Calendar.YEAR) - 1900) % 19) + 1; | |||
| int epact = (11 * yearInMetonicCycle + 18) % 30; | |||
| if ((epact == 25 && yearInMetonicCycle > 11) || epact == 24) { | |||
| epact++; | |||
| @@ -489,13 +489,10 @@ public class FileUtils { | |||
| // deal with absolute files | |||
| if (!onNetWare) { | |||
| if (filename.startsWith(File.separator) || | |||
| (filename.length() >= 2 && | |||
| Character.isLetter(filename.charAt(0)) && | |||
| filename.charAt(1) == ':') | |||
| ) { | |||
| if (filename.startsWith(File.separator) | |||
| || (filename.length() >= 2 | |||
| && Character.isLetter(filename.charAt(0)) | |||
| && filename.charAt(1) == ':')) { | |||
| return normalize(filename); | |||
| } | |||
| } else { | |||
| @@ -503,9 +500,8 @@ public class FileUtils { | |||
| // the path name breaks down when NetWare is a supported platform. | |||
| // Netware volumes are of the pattern: "data:\" | |||
| int colon = filename.indexOf(":"); | |||
| if (filename.startsWith(File.separator) || | |||
| (colon > -1) | |||
| ) { | |||
| if (filename.startsWith(File.separator) | |||
| || (colon > -1)) { | |||
| return normalize(filename); | |||
| } | |||
| } | |||
| @@ -562,17 +558,15 @@ public class FileUtils { | |||
| if (!onNetWare) { | |||
| if (!path.startsWith(File.separator) && | |||
| ! (path.length() >= 2 && | |||
| !(path.length() >= 2 && | |||
| Character.isLetter(path.charAt(0)) && | |||
| colon == 1) | |||
| ) { | |||
| colon == 1)) { | |||
| String msg = path + " is not an absolute path"; | |||
| throw new BuildException(msg); | |||
| } | |||
| } else { | |||
| if (!path.startsWith(File.separator) && | |||
| (colon == -1) | |||
| ) { | |||
| if (!path.startsWith(File.separator) | |||
| && (colon == -1)) { | |||
| String msg = path + " is not an absolute path"; | |||
| throw new BuildException(msg); | |||
| } | |||
| @@ -585,8 +579,7 @@ public class FileUtils { | |||
| path.length() >= 2 && | |||
| Character.isLetter(path.charAt(0)) && | |||
| path.charAt(1) == ':') || | |||
| (onNetWare && colon > -1) | |||
| ) { | |||
| (onNetWare && colon > -1)) { | |||
| dosWithDrive = true; | |||
| @@ -603,10 +596,9 @@ public class FileUtils { | |||
| // Eliminate consecutive slashes after the drive spec | |||
| StringBuffer sbPath = new StringBuffer(); | |||
| for (int i = colon+1; i < ca.length; i++) { | |||
| for (int i = colon + 1; i < ca.length; i++) { | |||
| if ((ca[i] != '\\') || | |||
| (ca[i] == '\\' && ca[i - 1] != '\\') | |||
| ) { | |||
| (ca[i] == '\\' && ca[i - 1] != '\\')) { | |||
| sbPath.append(ca[i]); | |||
| } | |||
| } | |||
| @@ -618,7 +610,7 @@ public class FileUtils { | |||
| path = ""; | |||
| } else if (path.charAt(1) == File.separatorChar) { | |||
| // UNC drive | |||
| root = File.separator+File.separator; | |||
| root = File.separator + File.separator; | |||
| path = path.substring(2); | |||
| } else { | |||
| root = File.separator; | |||
| @@ -635,7 +627,7 @@ public class FileUtils { | |||
| continue; | |||
| } else if ("..".equals(thisToken)) { | |||
| if (s.size() < 2) { | |||
| throw new BuildException("Cannot resolve path "+orig); | |||
| throw new BuildException("Cannot resolve path " + orig); | |||
| } else { | |||
| s.pop(); | |||
| } | |||
| @@ -645,7 +637,7 @@ public class FileUtils { | |||
| } | |||
| StringBuffer sb = new StringBuffer(); | |||
| for (int i=0; i<s.size(); i++) { | |||
| for (int i = 0; i < s.size(); i++) { | |||
| if (i > 1) { | |||
| // not before the filesystem root and not after it, since root | |||
| // already contains one | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000,2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -109,7 +109,7 @@ public class GlobPatternMapper implements FileNameMapper { | |||
| fromPostfix = ""; | |||
| } else { | |||
| fromPrefix = from.substring(0, index); | |||
| fromPostfix = from.substring(index+1); | |||
| fromPostfix = from.substring(index + 1); | |||
| } | |||
| prefixLength = fromPrefix.length(); | |||
| postfixLength = fromPostfix.length(); | |||
| @@ -125,7 +125,7 @@ public class GlobPatternMapper implements FileNameMapper { | |||
| toPostfix = ""; | |||
| } else { | |||
| toPrefix = to.substring(0, index); | |||
| toPostfix = to.substring(index+1); | |||
| toPostfix = to.substring(index + 1); | |||
| } | |||
| } | |||
| @@ -124,7 +124,7 @@ public class LoaderUtils { | |||
| try { | |||
| Thread currentThread = Thread.currentThread(); | |||
| return (ClassLoader)getContextClassLoader.invoke(currentThread, | |||
| return (ClassLoader) getContextClassLoader.invoke(currentThread, | |||
| new Object[0]); | |||
| } catch (IllegalAccessException e) { | |||
| throw new BuildException | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000,2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -118,7 +118,7 @@ public class RegexpPatternMapper implements FileNameMapper { | |||
| Vector v = reg.getGroups(source); | |||
| result.setLength(0); | |||
| for (int i=0; i<to.length; i++) { | |||
| for (int i = 0; i < to.length; i++) { | |||
| if (to[i] == '\\') { | |||
| if (++i < to.length) { | |||
| int value = Character.digit(to[i], 10); | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -115,11 +115,11 @@ public class SourceFileScanner { | |||
| } | |||
| Vector v = new Vector(); | |||
| for (int i=0; i< files.length; i++) { | |||
| for (int i = 0; i < files.length; i++) { | |||
| String[] targets = mapper.mapFileName(files[i]); | |||
| if (targets == null || targets.length == 0) { | |||
| task.log(files[i]+" skipped - don\'t know how to handle it", | |||
| task.log(files[i] + " skipped - don\'t know how to handle it", | |||
| Project.MSG_VERBOSE); | |||
| continue; | |||
| } | |||
| @@ -127,23 +127,23 @@ public class SourceFileScanner { | |||
| File src = fileUtils.resolveFile(srcDir, files[i]); | |||
| if (src.lastModified() > now) { | |||
| task.log("Warning: "+files[i]+" modified in the future.", | |||
| task.log("Warning: " + files[i] + " modified in the future.", | |||
| Project.MSG_WARN); | |||
| } | |||
| boolean added = false; | |||
| targetList.setLength(0); | |||
| for (int j=0; !added && j<targets.length; j++) { | |||
| for (int j = 0; !added && j < targets.length; j++) { | |||
| File dest = fileUtils.resolveFile(destDir, targets[j]); | |||
| if (!dest.exists()) { | |||
| task.log(files[i]+" added as "+dest.getAbsolutePath()+" doesn\'t exist.", | |||
| Project.MSG_VERBOSE); | |||
| task.log(files[i] + " added as " + dest.getAbsolutePath() | |||
| + " doesn\'t exist.", Project.MSG_VERBOSE); | |||
| v.addElement(files[i]); | |||
| added = true; | |||
| } else if (src.lastModified() > dest.lastModified()) { | |||
| task.log(files[i]+" added as "+dest.getAbsolutePath()+" is outdated.", | |||
| Project.MSG_VERBOSE); | |||
| task.log(files[i] + " added as " + dest.getAbsolutePath() | |||
| + " is outdated.", Project.MSG_VERBOSE); | |||
| v.addElement(files[i]); | |||
| added = true; | |||
| } else { | |||
| @@ -155,7 +155,7 @@ public class SourceFileScanner { | |||
| } | |||
| if (!added) { | |||
| task.log(files[i]+" omitted as "+targetList.toString() | |||
| task.log(files[i] + " omitted as " + targetList.toString() | |||
| + (targets.length == 1 ? " is" : " are ") | |||
| + " up to date.", Project.MSG_VERBOSE); | |||
| } | |||
| @@ -175,7 +175,7 @@ public class SourceFileScanner { | |||
| FileNameMapper mapper) { | |||
| String[] res = restrict(files, srcDir, destDir, mapper); | |||
| File[] result = new File[res.length]; | |||
| for (int i=0; i<res.length; i++) { | |||
| for (int i = 0; i < res.length; i++) { | |||
| result[i] = new File(srcDir, res[i]); | |||
| } | |||
| return result; | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -88,12 +88,12 @@ public final class StringUtils { | |||
| Vector elems = new Vector(); | |||
| int pos = -1; | |||
| int i = 0; | |||
| while ( (pos = data.indexOf(ch, i) ) != -1 ){ | |||
| while ((pos = data.indexOf(ch, i)) != -1){ | |||
| String elem = data.substring(i, pos); | |||
| elems.addElement(elem); | |||
| i = pos + 1; | |||
| } | |||
| elems.addElement( data.substring(i) ); | |||
| elems.addElement(data.substring(i)); | |||
| return elems; | |||
| } | |||
| @@ -108,11 +108,11 @@ public final class StringUtils { | |||
| StringBuffer buf = new StringBuffer(data.length()); | |||
| int pos = -1; | |||
| int i = 0; | |||
| while ( (pos = data.indexOf(from, i)) != -1 ){ | |||
| buf.append( data.substring(i, pos) ).append(to); | |||
| while ((pos = data.indexOf(from, i)) != -1){ | |||
| buf.append(data.substring(i, pos)).append(to); | |||
| i = pos + from.length(); | |||
| } | |||
| buf.append( data.substring(i) ); | |||
| buf.append(data.substring(i)); | |||
| return buf.toString(); | |||
| } | |||
| @@ -121,9 +121,9 @@ public final class StringUtils { | |||
| * @param t the exception to get the stacktrace from. | |||
| * @return the stacktrace from the given exception. | |||
| */ | |||
| public static String getStackTrace(Throwable t){ | |||
| public static String getStackTrace(Throwable t) { | |||
| StringWriter sw = new StringWriter(); | |||
| PrintWriter pw = new PrintWriter(sw,true); | |||
| PrintWriter pw = new PrintWriter(sw, true); | |||
| t.printStackTrace(pw); | |||
| pw.flush(); | |||
| pw.close(); | |||
| @@ -93,8 +93,8 @@ public class AncestorAnalyzer extends AbstractAnalyzer { | |||
| Hashtable containers = new Hashtable(); | |||
| Hashtable toAnalyze = new Hashtable(); | |||
| Hashtable nextAnalyze = new Hashtable(); | |||
| for (Enumeration e = getRootClasses(); e.hasMoreElements(); ) { | |||
| String classname = (String)e.nextElement(); | |||
| for (Enumeration e = getRootClasses(); e.hasMoreElements();) { | |||
| String classname = (String) e.nextElement(); | |||
| toAnalyze.put(classname, classname); | |||
| } | |||
| @@ -102,8 +102,8 @@ public class AncestorAnalyzer extends AbstractAnalyzer { | |||
| int maxCount = isClosureRequired() ? MAX_LOOPS : 2; | |||
| while (toAnalyze.size() != 0 && count++ < maxCount) { | |||
| nextAnalyze.clear(); | |||
| for (Enumeration e = toAnalyze.keys(); e.hasMoreElements(); ) { | |||
| String classname = (String)e.nextElement(); | |||
| for (Enumeration e = toAnalyze.keys(); e.hasMoreElements();) { | |||
| String classname = (String) e.nextElement(); | |||
| dependencies.put(classname, classname); | |||
| try { | |||
| File container = getClassContainer(classname); | |||
| @@ -146,13 +146,13 @@ public class AncestorAnalyzer extends AbstractAnalyzer { | |||
| } | |||
| files.removeAllElements(); | |||
| for (Enumeration e = containers.keys(); e.hasMoreElements(); ) { | |||
| files.addElement((File)e.nextElement()); | |||
| for (Enumeration e = containers.keys(); e.hasMoreElements();) { | |||
| files.addElement((File) e.nextElement()); | |||
| } | |||
| classes.removeAllElements(); | |||
| for (Enumeration e = dependencies.keys(); e.hasMoreElements(); ) { | |||
| classes.addElement((String)e.nextElement()); | |||
| for (Enumeration e = dependencies.keys(); e.hasMoreElements();) { | |||
| classes.addElement((String) e.nextElement()); | |||
| } | |||
| } | |||
| @@ -92,8 +92,8 @@ public class FullAnalyzer extends AbstractAnalyzer { | |||
| Hashtable dependencies = new Hashtable(); | |||
| Hashtable containers = new Hashtable(); | |||
| Hashtable toAnalyze = new Hashtable(); | |||
| for (Enumeration e = getRootClasses(); e.hasMoreElements(); ) { | |||
| String classname = (String)e.nextElement(); | |||
| for (Enumeration e = getRootClasses(); e.hasMoreElements();) { | |||
| String classname = (String) e.nextElement(); | |||
| toAnalyze.put(classname, classname); | |||
| } | |||
| @@ -101,8 +101,8 @@ public class FullAnalyzer extends AbstractAnalyzer { | |||
| int maxCount = isClosureRequired() ? MAX_LOOPS : 2; | |||
| while (toAnalyze.size() != 0 && count++ < maxCount) { | |||
| DependencyVisitor dependencyVisitor = new DependencyVisitor(); | |||
| for (Enumeration e = toAnalyze.keys(); e.hasMoreElements(); ) { | |||
| String classname = (String)e.nextElement(); | |||
| for (Enumeration e = toAnalyze.keys(); e.hasMoreElements();) { | |||
| String classname = (String) e.nextElement(); | |||
| dependencies.put(classname, classname); | |||
| try { | |||
| File container = getClassContainer(classname); | |||
| @@ -133,7 +133,7 @@ public class FullAnalyzer extends AbstractAnalyzer { | |||
| // now recover all the dependencies collected and add to the list. | |||
| Enumeration depsEnum = dependencyVisitor.getDependencies(); | |||
| while (depsEnum.hasMoreElements()) { | |||
| String className = (String)depsEnum.nextElement(); | |||
| String className = (String) depsEnum.nextElement(); | |||
| if (!dependencies.containsKey(className)) { | |||
| toAnalyze.put(className, className); | |||
| } | |||
| @@ -141,13 +141,13 @@ public class FullAnalyzer extends AbstractAnalyzer { | |||
| } | |||
| files.removeAllElements(); | |||
| for (Enumeration e = containers.keys(); e.hasMoreElements(); ) { | |||
| files.addElement((File)e.nextElement()); | |||
| for (Enumeration e = containers.keys(); e.hasMoreElements();) { | |||
| files.addElement((File) e.nextElement()); | |||
| } | |||
| classes.removeAllElements(); | |||
| for (Enumeration e = dependencies.keys(); e.hasMoreElements(); ) { | |||
| classes.addElement((String)e.nextElement()); | |||
| for (Enumeration e = dependencies.keys(); e.hasMoreElements();) { | |||
| classes.addElement((String) e.nextElement()); | |||
| } | |||
| } | |||
| @@ -159,6 +159,5 @@ public class FullAnalyzer extends AbstractAnalyzer { | |||
| protected boolean supportsFileDependencies() { | |||
| return true; | |||
| } | |||
| } | |||
| @@ -152,7 +152,7 @@ public class JakartaOroMatcher implements RegexpMatcher { | |||
| Vector v = new Vector(); | |||
| MatchResult mr = matcher.getMatch(); | |||
| int cnt = mr.groups(); | |||
| for (int i=0; i<cnt; i++) { | |||
| for (int i = 0; i < cnt; i++) { | |||
| v.addElement(mr.group(i)); | |||
| } | |||
| return v; | |||
| @@ -77,7 +77,7 @@ public class JakartaOroRegexp extends JakartaOroMatcher implements Regexp | |||
| { | |||
| // translate \1 to $1 so that the Perl5Substitution will work | |||
| StringBuffer subst = new StringBuffer(); | |||
| for (int i=0; i<argument.length(); i++) { | |||
| for (int i = 0; i < argument.length(); i++) { | |||
| char c = argument.charAt(i); | |||
| if (c == '\\') { | |||
| if (++i < argument.length()) { | |||
| @@ -139,7 +139,7 @@ public class JakartaRegexpMatcher implements RegexpMatcher { | |||
| } | |||
| Vector v = new Vector(); | |||
| int cnt = reg.getParenCount(); | |||
| for (int i=0; i<cnt; i++) { | |||
| for (int i = 0; i < cnt; i++) { | |||
| v.addElement(reg.getParen(i)); | |||
| } | |||
| return v; | |||
| @@ -86,7 +86,7 @@ public class JakartaRegexpRegexp extends JakartaRegexpMatcher implements Regexp | |||
| // replace \1 with the corresponding group | |||
| StringBuffer result = new StringBuffer(); | |||
| for (int i=0; i<argument.length(); i++) { | |||
| for (int i = 0; i < argument.length(); i++) { | |||
| char c = argument.charAt(i); | |||
| if (c == '\\') { | |||
| if (++i < argument.length()) { | |||
| @@ -153,7 +153,7 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||
| } | |||
| Vector v = new Vector(); | |||
| int cnt = matcher.groupCount(); | |||
| for (int i=0; i<=cnt; i++) { | |||
| for (int i = 0; i <= cnt; i++) { | |||
| v.addElement(matcher.group(i)); | |||
| } | |||
| return v; | |||
| @@ -86,7 +86,7 @@ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp | |||
| { | |||
| // translate \1 to $(1) so that the Matcher will work | |||
| StringBuffer subst = new StringBuffer(); | |||
| for (int i=0; i<argument.length(); i++) { | |||
| for (int i = 0; i < argument.length(); i++) { | |||
| char c = argument.charAt(i); | |||
| if (c == '\\') { | |||
| if (++i < argument.length()) { | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -91,8 +91,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| nInUse = 0; | |||
| for (i = 0; i < 256; i++) { | |||
| if (inUse[i]) { | |||
| seqToUnseq[nInUse] = (char)i; | |||
| unseqToSeq[i] = (char)nInUse; | |||
| seqToUnseq[nInUse] = (char) i; | |||
| unseqToSeq[i] = (char) nInUse; | |||
| nInUse++; | |||
| } | |||
| } | |||
| @@ -182,7 +182,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| } | |||
| public int read() { | |||
| if(streamEnd) { | |||
| if (streamEnd) { | |||
| return -1; | |||
| } else { | |||
| int retChar = currentChar; | |||
| @@ -216,7 +216,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| char magic3, magic4; | |||
| magic3 = bsGetUChar(); | |||
| magic4 = bsGetUChar(); | |||
| if(magic3 != 'h' || magic4 < '1' || magic4 > '9') { | |||
| if (magic3 != 'h' || magic4 < '1' || magic4 > '9') { | |||
| bsFinishedWithStream(); | |||
| streamEnd = true; | |||
| return; | |||
| @@ -316,11 +316,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| int zzi; | |||
| char thech = 0; | |||
| try { | |||
| thech = (char)bsStream.read(); | |||
| } catch(IOException e) { | |||
| thech = (char) bsStream.read(); | |||
| } catch (IOException e) { | |||
| compressedStreamEOF(); | |||
| } | |||
| if(thech == -1) { | |||
| if (thech == -1) { | |||
| compressedStreamEOF(); | |||
| } | |||
| zzi = thech; | |||
| @@ -329,13 +329,13 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| } | |||
| } | |||
| v = (bsBuff >> (bsLive-n)) & ((1 << n)-1); | |||
| v = (bsBuff >> (bsLive - n)) & ((1 << n) - 1); | |||
| bsLive -= n; | |||
| return v; | |||
| } | |||
| private char bsGetUChar() { | |||
| return (char)bsR(8); | |||
| return (char) bsR(8); | |||
| } | |||
| private int bsGetint() { | |||
| @@ -348,11 +348,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| } | |||
| private int bsGetIntVS(int numBits) { | |||
| return (int)bsR(numBits); | |||
| return (int) bsR(numBits); | |||
| } | |||
| private int bsGetInt32() { | |||
| return (int)bsGetint(); | |||
| return (int) bsGetint(); | |||
| } | |||
| private void hbCreateDecodeTables(int[] limit, int[] base, | |||
| @@ -361,8 +361,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| int pp, i, j, vec; | |||
| pp = 0; | |||
| for(i = minLen; i <= maxLen; i++) { | |||
| for(j = 0; j < alphaSize; j++) { | |||
| for (i = minLen; i <= maxLen; i++) { | |||
| for (j = 0; j < alphaSize; j++) { | |||
| if (length[j] == i) { | |||
| perm[pp] = j; | |||
| pp++; | |||
| @@ -370,15 +370,15 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| } | |||
| }; | |||
| for(i = 0; i < MAX_CODE_LEN; i++) { | |||
| for (i = 0; i < MAX_CODE_LEN; i++) { | |||
| base[i] = 0; | |||
| } | |||
| for(i = 0; i < alphaSize; i++) { | |||
| base[length[i]+1]++; | |||
| for (i = 0; i < alphaSize; i++) { | |||
| base[length[i] + 1]++; | |||
| } | |||
| for(i = 1; i < MAX_CODE_LEN; i++) { | |||
| base[i] += base[i-1]; | |||
| for (i = 1; i < MAX_CODE_LEN; i++) { | |||
| base[i] += base[i - 1]; | |||
| } | |||
| for (i = 0; i < MAX_CODE_LEN; i++) { | |||
| @@ -387,12 +387,12 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| vec = 0; | |||
| for (i = minLen; i <= maxLen; i++) { | |||
| vec += (base[i+1] - base[i]); | |||
| limit[i] = vec-1; | |||
| vec += (base[i + 1] - base[i]); | |||
| limit[i] = vec - 1; | |||
| vec <<= 1; | |||
| } | |||
| for (i = minLen + 1; i <= maxLen; i++) { | |||
| base[i] = ((limit[i-1] + 1) << 1) - base[i]; | |||
| base[i] = ((limit[i - 1] + 1) << 1) - base[i]; | |||
| } | |||
| } | |||
| @@ -426,7 +426,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| } | |||
| makeMaps(); | |||
| alphaSize = nInUse+2; | |||
| alphaSize = nInUse + 2; | |||
| /* Now the selectors */ | |||
| nGroups = bsR(3); | |||
| @@ -436,7 +436,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| while (bsR(1) == 1) { | |||
| j++; | |||
| } | |||
| selectorMtf[i] = (char)j; | |||
| selectorMtf[i] = (char) j; | |||
| } | |||
| /* Undo the MTF values for the selectors. */ | |||
| @@ -451,7 +451,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| v = selectorMtf[i]; | |||
| tmp = pos[v]; | |||
| while (v > 0) { | |||
| pos[v] = pos[v-1]; | |||
| pos[v] = pos[v - 1]; | |||
| v--; | |||
| } | |||
| pos[0] = tmp; | |||
| @@ -461,7 +461,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| /* Now the coding tables */ | |||
| for (t = 0; t < nGroups; t++) { | |||
| int curr = bsR ( 5 ); | |||
| int curr = bsR(5); | |||
| for (i = 0; i < alphaSize; i++) { | |||
| while (bsR(1) == 1) { | |||
| if (bsR(1) == 0) { | |||
| @@ -470,7 +470,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| curr--; | |||
| } | |||
| } | |||
| len[t][i] = (char)curr; | |||
| len[t][i] = (char) curr; | |||
| } | |||
| } | |||
| @@ -501,7 +501,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| origPtr = bsGetIntVS(24); | |||
| recvDecodingTables(); | |||
| EOB = nInUse+1; | |||
| EOB = nInUse + 1; | |||
| groupNo = -1; | |||
| groupPos = 0; | |||
| @@ -539,11 +539,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| int zzi; | |||
| char thech = 0; | |||
| try { | |||
| thech = (char)bsStream.read(); | |||
| } catch(IOException e) { | |||
| thech = (char) bsStream.read(); | |||
| } catch (IOException e) { | |||
| compressedStreamEOF(); | |||
| } | |||
| if(thech == -1) { | |||
| if (thech == -1) { | |||
| compressedStreamEOF(); | |||
| } | |||
| zzi = thech; | |||
| @@ -551,7 +551,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| bsLive += 8; | |||
| } | |||
| } | |||
| zj = (bsBuff >> (bsLive-1)) & 1; | |||
| zj = (bsBuff >> (bsLive - 1)) & 1; | |||
| bsLive--; | |||
| } | |||
| zvec = (zvec << 1) | zj; | |||
| @@ -559,7 +559,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| nextSym = perm[zt][zvec - base[zt][zn]]; | |||
| } | |||
| while(true) { | |||
| while (true) { | |||
| if (nextSym == EOB) { | |||
| break; | |||
| @@ -571,9 +571,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| int N = 1; | |||
| do { | |||
| if (nextSym == RUNA) { | |||
| s = s + (0+1) * N; | |||
| s = s + (0 + 1) * N; | |||
| } else if (nextSym == RUNB) { | |||
| s = s + (1+1) * N; | |||
| s = s + (1 + 1) * N; | |||
| } | |||
| N = N * 2; | |||
| { | |||
| @@ -594,11 +594,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| int zzi; | |||
| char thech = 0; | |||
| try { | |||
| thech = (char)bsStream.read(); | |||
| } catch(IOException e) { | |||
| thech = (char) bsStream.read(); | |||
| } catch (IOException e) { | |||
| compressedStreamEOF(); | |||
| } | |||
| if(thech == -1) { | |||
| if (thech == -1) { | |||
| compressedStreamEOF(); | |||
| } | |||
| zzi = thech; | |||
| @@ -606,7 +606,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| bsLive += 8; | |||
| } | |||
| } | |||
| zj = (bsBuff >> (bsLive-1)) & 1; | |||
| zj = (bsBuff >> (bsLive - 1)) & 1; | |||
| bsLive--; | |||
| } | |||
| zvec = (zvec << 1) | zj; | |||
| @@ -636,7 +636,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| blockOverrun(); | |||
| } | |||
| tmp = yy[nextSym-1]; | |||
| tmp = yy[nextSym - 1]; | |||
| unzftab[seqToUnseq[tmp]]++; | |||
| ll8[last] = seqToUnseq[tmp]; | |||
| @@ -647,15 +647,15 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| for (j = nextSym-1; j > 0; j--) yy[j] = yy[j-1]; | |||
| */ | |||
| j = nextSym-1; | |||
| j = nextSym - 1; | |||
| for (; j > 3; j -= 4) { | |||
| yy[j] = yy[j-1]; | |||
| yy[j-1] = yy[j-2]; | |||
| yy[j-2] = yy[j-3]; | |||
| yy[j-3] = yy[j-4]; | |||
| yy[j] = yy[j - 1]; | |||
| yy[j - 1] = yy[j - 2]; | |||
| yy[j - 2] = yy[j - 3]; | |||
| yy[j - 3] = yy[j - 4]; | |||
| } | |||
| for (; j > 0; j--) { | |||
| yy[j] = yy[j-1]; | |||
| yy[j] = yy[j - 1]; | |||
| } | |||
| yy[0] = tmp; | |||
| @@ -677,8 +677,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| int zzi; | |||
| char thech = 0; | |||
| try { | |||
| thech = (char)bsStream.read(); | |||
| } catch(IOException e) { | |||
| thech = (char) bsStream.read(); | |||
| } catch (IOException e) { | |||
| compressedStreamEOF(); | |||
| } | |||
| zzi = thech; | |||
| @@ -686,7 +686,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| bsLive += 8; | |||
| } | |||
| } | |||
| zj = (bsBuff >> (bsLive-1)) & 1; | |||
| zj = (bsBuff >> (bsLive - 1)) & 1; | |||
| bsLive--; | |||
| } | |||
| zvec = (zvec << 1) | zj; | |||
| @@ -704,14 +704,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| cftab[0] = 0; | |||
| for (i = 1; i <= 256; i++) { | |||
| cftab[i] = unzftab[i-1]; | |||
| cftab[i] = unzftab[i - 1]; | |||
| } | |||
| for (i = 1; i <= 256; i++) { | |||
| cftab[i] += cftab[i-1]; | |||
| cftab[i] += cftab[i - 1]; | |||
| } | |||
| for (i = 0; i <= last; i++) { | |||
| ch = (char)ll8[i]; | |||
| ch = (char) ll8[i]; | |||
| tt[cftab[ch]] = i; | |||
| cftab[ch]++; | |||
| } | |||
| @@ -733,19 +733,19 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| } | |||
| private void setupRandPartA() { | |||
| if(i2 <= last) { | |||
| if (i2 <= last) { | |||
| chPrev = ch2; | |||
| ch2 = ll8[tPos]; | |||
| tPos = tt[tPos]; | |||
| if (rNToGo == 0) { | |||
| rNToGo = rNums[rTPos]; | |||
| rTPos++; | |||
| if(rTPos == 512) { | |||
| if (rTPos == 512) { | |||
| rTPos = 0; | |||
| } | |||
| } | |||
| rNToGo--; | |||
| ch2 ^= (int)((rNToGo == 1) ? 1 : 0); | |||
| ch2 ^= (int) ((rNToGo == 1) ? 1 : 0); | |||
| i2++; | |||
| currentChar = ch2; | |||
| @@ -759,7 +759,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| } | |||
| private void setupNoRandPartA() { | |||
| if(i2 <= last) { | |||
| if (i2 <= last) { | |||
| chPrev = ch2; | |||
| ch2 = ll8[tPos]; | |||
| tPos = tt[tPos]; | |||
| @@ -788,7 +788,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| if (rNToGo == 0) { | |||
| rNToGo = rNums[rTPos]; | |||
| rTPos++; | |||
| if(rTPos == 512) { | |||
| if (rTPos == 512) { | |||
| rTPos = 0; | |||
| } | |||
| } | |||
| @@ -805,7 +805,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| } | |||
| private void setupRandPartC() { | |||
| if(j2 < (int)z) { | |||
| if (j2 < (int) z) { | |||
| currentChar = ch2; | |||
| mCrc.updateCRC(ch2); | |||
| j2++; | |||
| @@ -838,7 +838,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| } | |||
| private void setupNoRandPartC() { | |||
| if(j2 < (int)z) { | |||
| if (j2 < (int) z) { | |||
| currentChar = ch2; | |||
| mCrc.updateCRC(ch2); | |||
| j2++; | |||
| @@ -851,14 +851,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| } | |||
| private void setDecompressStructureSizes(int newSize100k) { | |||
| if (! (0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k | |||
| if (!(0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k | |||
| && blockSize100k <= 9)) { | |||
| // throw new IOException("Invalid block size"); | |||
| } | |||
| blockSize100k = newSize100k; | |||
| if(newSize100k == 0) { | |||
| if (newSize100k == 0) { | |||
| return; | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -99,8 +99,8 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| nInUse = 0; | |||
| for (i = 0; i < 256; i++) { | |||
| if (inUse[i]) { | |||
| seqToUnseq[nInUse] = (char)i; | |||
| unseqToSeq[i] = (char)nInUse; | |||
| seqToUnseq[nInUse] = (char) i; | |||
| unseqToSeq[i] = (char) nInUse; | |||
| nInUse++; | |||
| } | |||
| } | |||
| @@ -120,7 +120,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| int[] parent = new int[MAX_ALPHA_SIZE * 2]; | |||
| for (i = 0; i < alphaSize; i++) { | |||
| weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; | |||
| weight[i + 1] = (freq[i] == 0 ? 1 : freq[i]) << 8; | |||
| } | |||
| while (true) { | |||
| @@ -146,7 +146,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| heap[zz] = tmp; | |||
| } | |||
| } | |||
| if (!(nHeap < (MAX_ALPHA_SIZE+2))) { | |||
| if (!(nHeap < (MAX_ALPHA_SIZE + 2))) { | |||
| panic(); | |||
| } | |||
| @@ -164,7 +164,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| break; | |||
| } | |||
| if (yy < nHeap && | |||
| weight[heap[yy+1]] < weight[heap[yy]]) { | |||
| weight[heap[yy + 1]] < weight[heap[yy]]) { | |||
| yy++; | |||
| } | |||
| if (weight[tmp] < weight[heap[yy]]) { | |||
| @@ -188,7 +188,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| break; | |||
| } | |||
| if (yy < nHeap && | |||
| weight[heap[yy+1]] < weight[heap[yy]]) { | |||
| weight[heap[yy + 1]] < weight[heap[yy]]) { | |||
| yy++; | |||
| } | |||
| if (weight[tmp] < weight[heap[yy]]) { | |||
| @@ -235,13 +235,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| k = parent[k]; | |||
| j++; | |||
| } | |||
| len[i-1] = (char)j; | |||
| len[i - 1] = (char) j; | |||
| if (j > maxLen) { | |||
| tooLong = true; | |||
| } | |||
| } | |||
| if (! tooLong) { | |||
| if (!tooLong) { | |||
| break; | |||
| } | |||
| @@ -325,10 +325,10 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| bsSetStream(inStream); | |||
| workFactor = 50; | |||
| if(inBlockSize > 9) { | |||
| if (inBlockSize > 9) { | |||
| inBlockSize = 9; | |||
| } | |||
| if(inBlockSize < 1) { | |||
| if (inBlockSize < 1) { | |||
| inBlockSize = 1; | |||
| } | |||
| blockSize100k = inBlockSize; | |||
| @@ -344,10 +344,10 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| */ | |||
| public void write(int bv) throws IOException { | |||
| int b = (256 + bv) % 256; | |||
| if(currentChar != -1) { | |||
| if(currentChar == b) { | |||
| if (currentChar != -1) { | |||
| if (currentChar == b) { | |||
| runLength++; | |||
| if(runLength > 254) { | |||
| if (runLength > 254) { | |||
| writeRun(); | |||
| currentChar = -1; | |||
| runLength = 0; | |||
| @@ -364,42 +364,42 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| private void writeRun() throws IOException { | |||
| if(last < allowableBlockSize) { | |||
| if (last < allowableBlockSize) { | |||
| inUse[currentChar] = true; | |||
| for(int i = 0; i < runLength; i++) { | |||
| mCrc.updateCRC((char)currentChar); | |||
| for (int i = 0; i < runLength; i++) { | |||
| mCrc.updateCRC((char) currentChar); | |||
| } | |||
| switch (runLength) { | |||
| case 1: | |||
| last++; | |||
| block[last + 1] = (char)currentChar; | |||
| block[last + 1] = (char) currentChar; | |||
| break; | |||
| case 2: | |||
| last++; | |||
| block[last + 1] = (char)currentChar; | |||
| block[last + 1] = (char) currentChar; | |||
| last++; | |||
| block[last + 1] = (char)currentChar; | |||
| block[last + 1] = (char) currentChar; | |||
| break; | |||
| case 3: | |||
| last++; | |||
| block[last + 1] = (char)currentChar; | |||
| block[last + 1] = (char) currentChar; | |||
| last++; | |||
| block[last + 1] = (char)currentChar; | |||
| block[last + 1] = (char) currentChar; | |||
| last++; | |||
| block[last + 1] = (char)currentChar; | |||
| block[last + 1] = (char) currentChar; | |||
| break; | |||
| default: | |||
| inUse[runLength - 4] = true; | |||
| last++; | |||
| block[last + 1] = (char)currentChar; | |||
| block[last + 1] = (char) currentChar; | |||
| last++; | |||
| block[last + 1] = (char)currentChar; | |||
| block[last + 1] = (char) currentChar; | |||
| last++; | |||
| block[last + 1] = (char)currentChar; | |||
| block[last + 1] = (char) currentChar; | |||
| last++; | |||
| block[last + 1] = (char)currentChar; | |||
| block[last + 1] = (char) currentChar; | |||
| last++; | |||
| block[last + 1] = (char)(runLength - 4); | |||
| block[last + 1] = (char) (runLength - 4); | |||
| break; | |||
| } | |||
| } else { | |||
| @@ -416,11 +416,11 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| public void close() throws IOException { | |||
| if(closed) { | |||
| if (closed) { | |||
| return; | |||
| } | |||
| if(runLength > 0) { | |||
| if (runLength > 0) { | |||
| writeRun(); | |||
| } | |||
| currentChar = -1; | |||
| @@ -460,7 +460,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| last = -1; | |||
| // ch = 0; | |||
| for(int i = 0; i < 256; i++) { | |||
| for (int i = 0; i < 256; i++) { | |||
| inUse[i] = false; | |||
| } | |||
| @@ -470,7 +470,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| private void endBlock() throws IOException { | |||
| blockCRC = mCrc.getFinalCRC(); | |||
| combinedCRC = (combinedCRC << 1)|(combinedCRC >>> 31); | |||
| combinedCRC = (combinedCRC << 1) | (combinedCRC >>> 31); | |||
| combinedCRC ^= blockCRC; | |||
| /* sort the block and establish posn of original string */ | |||
| @@ -501,10 +501,10 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| /* Now a single bit indicating randomisation. */ | |||
| if (blockRandomised) { | |||
| bsW(1,1); | |||
| bsW(1, 1); | |||
| nBlocksRandomised++; | |||
| } else { | |||
| bsW(1,0); | |||
| bsW(1, 0); | |||
| } | |||
| /* Finally, block's contents proper. */ | |||
| @@ -561,7 +561,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| try { | |||
| bsStream.write(ch); // write 8-bit | |||
| } | |||
| catch(IOException e) { | |||
| catch (IOException e) { | |||
| throw e; | |||
| } | |||
| bsBuff <<= 8; | |||
| @@ -576,7 +576,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| try { | |||
| bsStream.write(ch); // write 8-bit | |||
| } | |||
| catch(IOException e) { | |||
| catch (IOException e) { | |||
| throw e; | |||
| } | |||
| bsBuff <<= 8; | |||
| @@ -612,7 +612,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| alphaSize = nInUse + 2; | |||
| for (t = 0; t < N_GROUPS; t++) { | |||
| for (v = 0; v < alphaSize; v++) { | |||
| len[t][v] = (char)GREATER_ICOST; | |||
| len[t][v] = (char) GREATER_ICOST; | |||
| } | |||
| } | |||
| @@ -625,13 +625,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| nGroups = 2; | |||
| } else if (nMTF < 600) { | |||
| nGroups = 3; | |||
| } else if (nMTF < 1200) { | |||
| } else if (nMTF < 1200) { | |||
| nGroups = 4; | |||
| } else if (nMTF < 2400) { | |||
| } else if (nMTF < 2400) { | |||
| nGroups = 5; | |||
| } else { | |||
| } else { | |||
| nGroups = 6; | |||
| } | |||
| } | |||
| /* Generate an initial set of coding tables */ { | |||
| int nPart, remF, tFreq, aFreq; | |||
| @@ -641,29 +641,29 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| gs = 0; | |||
| while (nPart > 0) { | |||
| tFreq = remF / nPart; | |||
| ge = gs-1; | |||
| ge = gs - 1; | |||
| aFreq = 0; | |||
| while (aFreq < tFreq && ge < alphaSize-1) { | |||
| while (aFreq < tFreq && ge < alphaSize - 1) { | |||
| ge++; | |||
| aFreq += mtfFreq[ge]; | |||
| } | |||
| if (ge > gs && nPart != nGroups && nPart != 1 | |||
| && ((nGroups-nPart) % 2 == 1)) { | |||
| && ((nGroups - nPart) % 2 == 1)) { | |||
| aFreq -= mtfFreq[ge]; | |||
| ge--; | |||
| } | |||
| for (v = 0; v < alphaSize; v++) { | |||
| if (v >= gs && v <= ge) { | |||
| len[nPart-1][v] = (char)LESSER_ICOST; | |||
| len[nPart - 1][v] = (char) LESSER_ICOST; | |||
| } else { | |||
| len[nPart-1][v] = (char)GREATER_ICOST; | |||
| len[nPart - 1][v] = (char) GREATER_ICOST; | |||
| } | |||
| } | |||
| nPart--; | |||
| gs = ge+1; | |||
| gs = ge + 1; | |||
| remF -= aFreq; | |||
| } | |||
| } | |||
| @@ -696,7 +696,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| ge = gs + G_SIZE - 1; | |||
| if (ge >= nMTF) { | |||
| ge = nMTF-1; | |||
| ge = nMTF - 1; | |||
| } | |||
| /* | |||
| @@ -748,7 +748,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| }; | |||
| totc += bc; | |||
| fave[bt]++; | |||
| selector[nSelectors] = (char)bt; | |||
| selector[nSelectors] = (char) bt; | |||
| nSelectors++; | |||
| /* | |||
| @@ -758,7 +758,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| rfreq[bt][szptr[i]]++; | |||
| } | |||
| gs = ge+1; | |||
| gs = ge + 1; | |||
| } | |||
| /* | |||
| @@ -786,20 +786,20 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| char[] pos = new char[N_GROUPS]; | |||
| char ll_i, tmp2, tmp; | |||
| for (i = 0; i < nGroups; i++) { | |||
| pos[i] = (char)i; | |||
| pos[i] = (char) i; | |||
| } | |||
| for (i = 0; i < nSelectors; i++) { | |||
| ll_i = selector[i]; | |||
| j = 0; | |||
| tmp = pos[j]; | |||
| while ( ll_i != tmp ) { | |||
| while (ll_i != tmp) { | |||
| j++; | |||
| tmp2 = tmp; | |||
| tmp = pos[j]; | |||
| pos[j] = tmp2; | |||
| } | |||
| pos[0] = tmp; | |||
| selectorMtf[i] = (char)j; | |||
| selectorMtf[i] = (char) j; | |||
| } | |||
| } | |||
| @@ -841,9 +841,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| nBytes = bytesOut; | |||
| for (i = 0; i < 16; i++) { | |||
| if (inUse16[i]) { | |||
| bsW(1,1); | |||
| bsW(1, 1); | |||
| } else { | |||
| bsW(1,0); | |||
| bsW(1, 0); | |||
| } | |||
| } | |||
| @@ -851,9 +851,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| if (inUse16[i]) { | |||
| for (j = 0; j < 16; j++) { | |||
| if (inUse[i * 16 + j]) { | |||
| bsW(1,1); | |||
| bsW(1, 1); | |||
| } else { | |||
| bsW(1,0); | |||
| bsW(1, 0); | |||
| } | |||
| } | |||
| } | |||
| @@ -863,13 +863,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| /* Now the selectors. */ | |||
| nBytes = bytesOut; | |||
| bsW ( 3, nGroups ); | |||
| bsW ( 15, nSelectors ); | |||
| bsW (3, nGroups); | |||
| bsW (15, nSelectors); | |||
| for (i = 0; i < nSelectors; i++) { | |||
| for (j = 0; j < selectorMtf[i]; j++) { | |||
| bsW(1,1); | |||
| bsW(1, 1); | |||
| } | |||
| bsW(1,0); | |||
| bsW(1, 0); | |||
| } | |||
| /* Now the coding tables. */ | |||
| @@ -880,14 +880,14 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| bsW(5, curr); | |||
| for (i = 0; i < alphaSize; i++) { | |||
| while (curr < len[t][i]) { | |||
| bsW(2,2); | |||
| bsW(2, 2); | |||
| curr++; /* 10 */ | |||
| } | |||
| while (curr > len[t][i]) { | |||
| bsW(2,3); | |||
| bsW(2, 3); | |||
| curr--; /* 11 */ | |||
| } | |||
| bsW ( 1, 0 ); | |||
| bsW (1, 0); | |||
| } | |||
| } | |||
| @@ -901,14 +901,14 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| ge = gs + G_SIZE - 1; | |||
| if (ge >= nMTF) { | |||
| ge = nMTF-1; | |||
| ge = nMTF - 1; | |||
| } | |||
| for (i = gs; i <= ge; i++) { | |||
| bsW(len [selector[selCtr]] [szptr[i]], | |||
| code [selector[selCtr]] [szptr[i]] ); | |||
| bsW(len[selector[selCtr]][szptr[i]], | |||
| code[selector[selCtr]][szptr[i]]); | |||
| } | |||
| gs = ge+1; | |||
| gs = ge + 1; | |||
| selCtr++; | |||
| } | |||
| if (!(selCtr == nSelectors)) { | |||
| @@ -924,7 +924,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| private OutputStream bsStream; | |||
| private void simpleSort ( int lo, int hi, int d ) { | |||
| private void simpleSort(int lo, int hi, int d) { | |||
| int i, j, h, bigN, hp; | |||
| int v; | |||
| @@ -950,8 +950,8 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| v = zptr[i]; | |||
| j = i; | |||
| while ( fullGtU ( zptr[j-h]+d, v+d ) ) { | |||
| zptr[j] = zptr[j-h]; | |||
| while (fullGtU(zptr[j - h] + d, v + d)) { | |||
| zptr[j] = zptr[j - h]; | |||
| j = j - h; | |||
| if (j <= (lo + h - 1)) { | |||
| break; | |||
| @@ -966,8 +966,8 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| v = zptr[i]; | |||
| j = i; | |||
| while ( fullGtU ( zptr[j-h]+d, v+d ) ) { | |||
| zptr[j] = zptr[j-h]; | |||
| while (fullGtU(zptr[j - h] + d, v + d)) { | |||
| zptr[j] = zptr[j - h]; | |||
| j = j - h; | |||
| if (j <= (lo + h - 1)) { | |||
| break; | |||
| @@ -982,8 +982,8 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| v = zptr[i]; | |||
| j = i; | |||
| while ( fullGtU ( zptr[j-h]+d, v+d ) ) { | |||
| zptr[j] = zptr[j-h]; | |||
| while (fullGtU(zptr[j - h] + d, v + d)) { | |||
| zptr[j] = zptr[j - h]; | |||
| j = j - h; | |||
| if (j <= (lo + h - 1)) { | |||
| break; | |||
| @@ -999,7 +999,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| } | |||
| private void vswap ( int p1, int p2, int n ) { | |||
| private void vswap(int p1, int p2, int n) { | |||
| int temp = 0; | |||
| while (n > 0) { | |||
| temp = zptr[p1]; | |||
| @@ -1011,7 +1011,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| } | |||
| private char med3( char a, char b, char c ) { | |||
| private char med3(char a, char b, char c) { | |||
| char t; | |||
| if (a > b) { | |||
| t = a; | |||
| @@ -1035,11 +1035,11 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| int dd; | |||
| } | |||
| private void qSort3 ( int loSt, int hiSt, int dSt ) { | |||
| private void qSort3(int loSt, int hiSt, int dSt) { | |||
| int unLo, unHi, ltLo, gtHi, med, n, m; | |||
| int sp, lo, hi, d; | |||
| StackElem[] stack = new StackElem[QSORT_STACK_SIZE]; | |||
| for(int count = 0; count < QSORT_STACK_SIZE; count++) { | |||
| for (int count = 0; count < QSORT_STACK_SIZE; count++) { | |||
| stack[count] = new StackElem(); | |||
| } | |||
| @@ -1080,7 +1080,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| if (unLo > unHi) { | |||
| break; | |||
| } | |||
| n = ((int)block[zptr[unLo]+d + 1]) - med; | |||
| n = ((int) block[zptr[unLo] + d + 1]) - med; | |||
| if (n == 0) { | |||
| int temp = 0; | |||
| temp = zptr[unLo]; | |||
| @@ -1099,7 +1099,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| if (unLo > unHi) { | |||
| break; | |||
| } | |||
| n = ((int)block[zptr[unHi]+d + 1]) - med; | |||
| n = ((int) block[zptr[unHi] + d + 1]) - med; | |||
| if (n == 0) { | |||
| int temp = 0; | |||
| temp = zptr[unHi]; | |||
| @@ -1128,15 +1128,15 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| if (gtHi < ltLo) { | |||
| stack[sp].ll = lo; | |||
| stack[sp].hh = hi; | |||
| stack[sp].dd = d+1; | |||
| stack[sp].dd = d + 1; | |||
| sp++; | |||
| continue; | |||
| } | |||
| n = ((ltLo-lo) < (unLo-ltLo)) ? (ltLo-lo) : (unLo-ltLo); | |||
| vswap(lo, unLo-n, n); | |||
| m = ((hi-gtHi) < (gtHi-unHi)) ? (hi-gtHi) : (gtHi-unHi); | |||
| vswap(unLo, hi-m+1, m); | |||
| n = ((ltLo - lo) < (unLo - ltLo)) ? (ltLo - lo) : (unLo - ltLo); | |||
| vswap(lo, unLo - n, n); | |||
| m = ((hi - gtHi) < (gtHi - unHi)) ? (hi - gtHi) : (gtHi - unHi); | |||
| vswap(unLo, hi - m + 1, m); | |||
| n = lo + unLo - ltLo - 1; | |||
| m = hi - (gtHi - unHi) + 1; | |||
| @@ -1148,7 +1148,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| stack[sp].ll = n + 1; | |||
| stack[sp].hh = m - 1; | |||
| stack[sp].dd = d+1; | |||
| stack[sp].dd = d + 1; | |||
| sp++; | |||
| stack[sp].ll = m; | |||
| @@ -1172,7 +1172,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| set up the overshoot area for block. | |||
| */ | |||
| // if (verbosity >= 4) fprintf ( stderr, " sort initialise ...\n" ); | |||
| // if (verbosity >= 4) fprintf ( stderr, " sort initialise ...\n" ); | |||
| for (i = 0; i < NUM_OVERSHOOT_BYTES; i++) { | |||
| block[last + i + 2] = block[(i % (last + 1)) + 1]; | |||
| } | |||
| @@ -1180,7 +1180,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| quadrant[i] = 0; | |||
| } | |||
| block[0] = (char)(block[last + 1]); | |||
| block[0] = (char) (block[last + 1]); | |||
| if (last < 4000) { | |||
| /* | |||
| @@ -1192,7 +1192,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| firstAttempt = false; | |||
| workDone = workLimit = 0; | |||
| simpleSort ( 0, last, 0 ); | |||
| simpleSort(0, last, 0); | |||
| } else { | |||
| numQSorted = 0; | |||
| for (i = 0; i <= 255; i++) { | |||
| @@ -1249,10 +1249,10 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| for (i = h; i <= 255; i++) { | |||
| vv = runningOrder[i]; | |||
| j = i; | |||
| while ((ftab[((runningOrder[j-h])+1) << 8] | |||
| - ftab[(runningOrder[j-h]) << 8]) > | |||
| (ftab[((vv)+1) << 8] - ftab[(vv) << 8])) { | |||
| runningOrder[j] = runningOrder[j-h]; | |||
| while ((ftab[((runningOrder[j - h]) + 1) << 8] | |||
| - ftab[(runningOrder[j - h]) << 8]) > | |||
| (ftab[((vv) + 1) << 8] - ftab[(vv) << 8])) { | |||
| runningOrder[j] = runningOrder[j - h]; | |||
| j = j - h; | |||
| if (j <= (h - 1)) { | |||
| break; | |||
| @@ -1282,12 +1282,12 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| */ | |||
| for (j = 0; j <= 255; j++) { | |||
| sb = (ss << 8) + j; | |||
| if(!((ftab[sb] & SETMASK) == SETMASK) ) { | |||
| if (!((ftab[sb] & SETMASK) == SETMASK)) { | |||
| int lo = ftab[sb] & CLEARMASK; | |||
| int hi = (ftab[sb+1] & CLEARMASK) - 1; | |||
| int hi = (ftab[sb + 1] & CLEARMASK) - 1; | |||
| if (hi > lo) { | |||
| qSort3 ( lo, hi, 2 ); | |||
| numQSorted += ( hi - lo + 1 ); | |||
| qSort3(lo, hi, 2); | |||
| numQSorted += (hi - lo + 1); | |||
| if (workDone > workLimit && firstAttempt) { | |||
| return; | |||
| } | |||
| @@ -1308,7 +1308,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| if (i < 255) { | |||
| int bbStart = ftab[ss << 8] & CLEARMASK; | |||
| int bbSize = (ftab[(ss+1) << 8] & CLEARMASK) - bbStart; | |||
| int bbSize = (ftab[(ss + 1) << 8] & CLEARMASK) - bbStart; | |||
| int shifts = 0; | |||
| while ((bbSize >> shifts) > 65534) { | |||
| @@ -1324,7 +1324,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| } | |||
| if (! ( ((bbSize-1) >> shifts) <= 65535 )) { | |||
| if (!(((bbSize - 1) >> shifts) <= 65535)) { | |||
| panic(); | |||
| } | |||
| } | |||
| @@ -1338,11 +1338,11 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| for (j = ftab[ss << 8] & CLEARMASK; | |||
| j < (ftab[(ss+1) << 8] & CLEARMASK); j++) { | |||
| j < (ftab[(ss + 1) << 8] & CLEARMASK); j++) { | |||
| c1 = block[zptr[j]]; | |||
| if ( ! bigDone[c1] ) { | |||
| if (!bigDone[c1]) { | |||
| zptr[copy[c1]] = zptr[j] == 0 ? last : zptr[j] - 1; | |||
| copy[c1] ++; | |||
| copy[c1]++; | |||
| } | |||
| } | |||
| @@ -1363,9 +1363,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| for (i = 0; i <= last; i++) { | |||
| if (rNToGo == 0) { | |||
| rNToGo = (char)rNums[rTPos]; | |||
| rNToGo = (char) rNums[rTPos]; | |||
| rTPos++; | |||
| if(rTPos == 512) { | |||
| if (rTPos == 512) { | |||
| rTPos = 0; | |||
| } | |||
| } | |||
| @@ -1582,7 +1582,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| int EOB; | |||
| makeMaps(); | |||
| EOB = nInUse+1; | |||
| EOB = nInUse + 1; | |||
| for (i = 0; i <= EOB; i++) { | |||
| mtfFreq[i] = 0; | |||
| @@ -1602,7 +1602,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| j = 0; | |||
| tmp = yy[j]; | |||
| while ( ll_i != tmp ) { | |||
| while (ll_i != tmp) { | |||
| j++; | |||
| tmp2 = tmp; | |||
| tmp = yy[j]; | |||
| @@ -1618,12 +1618,12 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| while (true) { | |||
| switch (zPend % 2) { | |||
| case 0: | |||
| szptr[wr] = (short)RUNA; | |||
| szptr[wr] = (short) RUNA; | |||
| wr++; | |||
| mtfFreq[RUNA]++; | |||
| break; | |||
| case 1: | |||
| szptr[wr] = (short)RUNB; | |||
| szptr[wr] = (short) RUNB; | |||
| wr++; | |||
| mtfFreq[RUNB]++; | |||
| break; | |||
| @@ -1635,7 +1635,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| }; | |||
| zPend = 0; | |||
| } | |||
| szptr[wr] = (short)(j + 1); | |||
| szptr[wr] = (short) (j + 1); | |||
| wr++; | |||
| mtfFreq[j + 1]++; | |||
| } | |||
| @@ -1646,12 +1646,12 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| while (true) { | |||
| switch (zPend % 2) { | |||
| case 0: | |||
| szptr[wr] = (short)RUNA; | |||
| szptr[wr] = (short) RUNA; | |||
| wr++; | |||
| mtfFreq[RUNA]++; | |||
| break; | |||
| case 1: | |||
| szptr[wr] = (short)RUNB; | |||
| szptr[wr] = (short) RUNB; | |||
| wr++; | |||
| mtfFreq[RUNB]++; | |||
| break; | |||
| @@ -1663,7 +1663,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||
| } | |||
| } | |||
| szptr[wr] = (short)EOB; | |||
| szptr[wr] = (short) EOB; | |||
| wr++; | |||
| mtfFreq[EOB]++; | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -156,7 +156,7 @@ class CRC { | |||
| void updateCRC(int inCh) { | |||
| int temp = (globalCrc >> 24) ^ inCh; | |||
| if(temp < 0) { | |||
| if (temp < 0) { | |||
| temp = 256 + temp; | |||
| } | |||
| globalCrc = (globalCrc << 8) ^ CRC.crc32Table[temp]; | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -224,7 +224,7 @@ public class TarEntry implements TarConstants { | |||
| else if (osname.toLowerCase().indexOf("netware") > -1) { | |||
| int colon = name.indexOf(':'); | |||
| if (colon != -1) { | |||
| name=name.substring(colon+1); | |||
| name = name.substring(colon + 1); | |||
| } | |||
| } | |||
| } | |||
| @@ -517,7 +517,7 @@ public class TarEntry implements TarConstants { | |||
| * @return An array of TarEntry's for this entry's children. | |||
| */ | |||
| public TarEntry[] getDirectoryEntries() { | |||
| if (this.file == null ||!this.file.isDirectory()) { | |||
| if (this.file == null || !this.file.isDirectory()) { | |||
| return new TarEntry[0]; | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -147,12 +147,12 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable { | |||
| * @since 1.1 | |||
| */ | |||
| public ZipShort getLocalFileDataLength() { | |||
| return new ZipShort( 4 // CRC | |||
| + 2 // Mode | |||
| + 4 // SizDev | |||
| + 2 // UID | |||
| + 2 // GID | |||
| + getLinkedFile().getBytes().length); | |||
| return new ZipShort(4 // CRC | |||
| + 2 // Mode | |||
| + 4 // SizDev | |||
| + 2 // UID | |||
| + 2 // GID | |||
| + getLinkedFile().getBytes().length); | |||
| } | |||
| /** | |||
| @@ -321,8 +321,8 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable { | |||
| throws ZipException { | |||
| long givenChecksum = (new ZipLong(data, offset)).getValue(); | |||
| byte[] tmp = new byte[length-4]; | |||
| System.arraycopy(data, offset+4, tmp, 0, length-4); | |||
| byte[] tmp = new byte[length - 4]; | |||
| System.arraycopy(data, offset + 4, tmp, 0, length - 4); | |||
| crc.reset(); | |||
| crc.update(tmp); | |||
| long realChecksum = crc.getValue(); | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -127,25 +127,27 @@ public class ExtraFieldUtils { | |||
| public static ZipExtraField[] parse(byte[] data) throws ZipException { | |||
| Vector v = new Vector(); | |||
| int start = 0; | |||
| while (start <= data.length-4) { | |||
| while (start <= data.length - 4) { | |||
| ZipShort headerId = new ZipShort(data, start); | |||
| int length = (new ZipShort(data, start+2)).getValue(); | |||
| if (start+4+length > data.length) { | |||
| throw new ZipException("data starting at "+start+" is in unknown format"); | |||
| int length = (new ZipShort(data, start + 2)).getValue(); | |||
| if (start + 4 + length > data.length) { | |||
| throw new ZipException("data starting at " + start | |||
| + " is in unknown format"); | |||
| } | |||
| try { | |||
| ZipExtraField ze = createExtraField(headerId); | |||
| ze.parseFromLocalFileData(data, start+4, length); | |||
| ze.parseFromLocalFileData(data, start + 4, length); | |||
| v.addElement(ze); | |||
| } catch (InstantiationException ie) { | |||
| throw new ZipException(ie.getMessage()); | |||
| } catch (IllegalAccessException iae) { | |||
| throw new ZipException(iae.getMessage()); | |||
| } | |||
| start += (length+4); | |||
| start += (length + 4); | |||
| } | |||
| if (start != data.length) { // array not exhausted | |||
| throw new ZipException("data starting at "+start+" is in unknown format"); | |||
| throw new ZipException("data starting at " + start | |||
| + " is in unknown format"); | |||
| } | |||
| ZipExtraField[] result = new ZipExtraField[v.size()]; | |||
| @@ -159,20 +161,20 @@ public class ExtraFieldUtils { | |||
| * @since 1.1 | |||
| */ | |||
| public static byte[] mergeLocalFileDataData(ZipExtraField[] data) { | |||
| int sum = 4*data.length; | |||
| for (int i=0; i<data.length; i++) { | |||
| int sum = 4 * data.length; | |||
| for (int i = 0; i < data.length; i++) { | |||
| sum += data[i].getLocalFileDataLength().getValue(); | |||
| } | |||
| byte[] result = new byte[sum]; | |||
| int start = 0; | |||
| for (int i=0; i<data.length; i++) { | |||
| for (int i = 0; i < data.length; i++) { | |||
| System.arraycopy(data[i].getHeaderId().getBytes(), | |||
| 0, result, start, 2); | |||
| System.arraycopy(data[i].getLocalFileDataLength().getBytes(), | |||
| 0, result, start+2, 2); | |||
| 0, result, start + 2, 2); | |||
| byte[] local = data[i].getLocalFileDataData(); | |||
| System.arraycopy(local, 0, result, start+4, local.length); | |||
| start += (local.length+4); | |||
| System.arraycopy(local, 0, result, start + 4, local.length); | |||
| start += (local.length + 4); | |||
| } | |||
| return result; | |||
| } | |||
| @@ -183,20 +185,20 @@ public class ExtraFieldUtils { | |||
| * @since 1.1 | |||
| */ | |||
| public static byte[] mergeCentralDirectoryData(ZipExtraField[] data) { | |||
| int sum = 4*data.length; | |||
| for (int i=0; i<data.length; i++) { | |||
| int sum = 4 * data.length; | |||
| for (int i = 0; i < data.length; i++) { | |||
| sum += data[i].getCentralDirectoryLength().getValue(); | |||
| } | |||
| byte[] result = new byte[sum]; | |||
| int start = 0; | |||
| for (int i=0; i<data.length; i++) { | |||
| for (int i = 0; i < data.length; i++) { | |||
| System.arraycopy(data[i].getHeaderId().getBytes(), | |||
| 0, result, start, 2); | |||
| System.arraycopy(data[i].getCentralDirectoryLength().getBytes(), | |||
| 0, result, start+2, 2); | |||
| 0, result, start + 2, 2); | |||
| byte[] local = data[i].getCentralDirectoryData(); | |||
| System.arraycopy(local, 0, result, start+4, local.length); | |||
| start += (local.length+4); | |||
| System.arraycopy(local, 0, result, start + 4, local.length); | |||
| start += (local.length + 4); | |||
| } | |||
| return result; | |||
| } | |||