Browse Source

More coding standard fixes

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272433 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
6154080061
100 changed files with 2088 additions and 2120 deletions
  1. +12
    -8
      src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
  2. +73
    -96
      src/main/org/apache/tools/ant/taskdefs/BuildNumber.java
  3. +6
    -14
      src/main/org/apache/tools/ant/taskdefs/Concat.java
  4. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
  5. +21
    -21
      src/main/org/apache/tools/ant/taskdefs/Manifest.java
  6. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Parallel.java
  7. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Patch.java
  8. +147
    -139
      src/main/org/apache/tools/ant/taskdefs/PathConvert.java
  9. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java
  10. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
  11. +13
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
  12. +36
    -30
      src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  13. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java
  14. +202
    -178
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
  15. +43
    -43
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
  16. +32
    -30
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
  17. +6
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java
  18. +13
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
  19. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapter.java
  20. +9
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java
  21. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
  22. +6
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
  23. +9
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java
  24. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java
  25. +3
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
  26. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitResultFormatter.java
  27. +26
    -27
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  28. +21
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java
  29. +19
    -19
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  30. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java
  31. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java
  32. +8
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
  33. +9
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
  34. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan1Executor.java
  35. +8
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java
  36. +329
    -368
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  37. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java
  38. +13
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java
  39. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Submit.java
  40. +79
    -62
      src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
  41. +338
    -386
      src/main/org/apache/tools/ant/taskdefs/optional/scm/AntStarTeamCheckOut.java
  42. +3
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
  43. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java
  44. +9
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashScreen.java
  45. +13
    -11
      src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
  46. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamTask.java
  47. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
  48. +10
    -10
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSADD.java
  49. +15
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java
  50. +12
    -12
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java
  51. +6
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCP.java
  52. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java
  53. +14
    -15
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java
  54. +18
    -18
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java
  55. +12
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java
  56. +18
    -19
      src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
  57. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java
  58. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java
  59. +12
    -12
      src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
  60. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
  61. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
  62. +6
    -6
      src/main/org/apache/tools/ant/types/AbstractFileSet.java
  63. +16
    -16
      src/main/org/apache/tools/ant/types/Commandline.java
  64. +6
    -4
      src/main/org/apache/tools/ant/types/CommandlineJava.java
  65. +10
    -8
      src/main/org/apache/tools/ant/types/DataType.java
  66. +2
    -2
      src/main/org/apache/tools/ant/types/Environment.java
  67. +1
    -1
      src/main/org/apache/tools/ant/types/FileList.java
  68. +21
    -15
      src/main/org/apache/tools/ant/types/FilterSet.java
  69. +2
    -2
      src/main/org/apache/tools/ant/types/FilterSetCollection.java
  70. +2
    -2
      src/main/org/apache/tools/ant/types/Mapper.java
  71. +21
    -18
      src/main/org/apache/tools/ant/types/Path.java
  72. +11
    -11
      src/main/org/apache/tools/ant/types/PatternSet.java
  73. +1
    -1
      src/main/org/apache/tools/ant/types/Reference.java
  74. +2
    -1
      src/main/org/apache/tools/ant/types/RegularExpression.java
  75. +2
    -2
      src/main/org/apache/tools/ant/types/XMLCatalog.java
  76. +1
    -1
      src/main/org/apache/tools/ant/types/ZipFileSet.java
  77. +3
    -3
      src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java
  78. +4
    -4
      src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java
  79. +10
    -9
      src/main/org/apache/tools/ant/util/DOMElementWriter.java
  80. +1
    -1
      src/main/org/apache/tools/ant/util/DateUtils.java
  81. +16
    -24
      src/main/org/apache/tools/ant/util/FileUtils.java
  82. +3
    -3
      src/main/org/apache/tools/ant/util/GlobPatternMapper.java
  83. +1
    -1
      src/main/org/apache/tools/ant/util/LoaderUtils.java
  84. +2
    -2
      src/main/org/apache/tools/ant/util/RegexpPatternMapper.java
  85. +11
    -11
      src/main/org/apache/tools/ant/util/SourceFileScanner.java
  86. +8
    -8
      src/main/org/apache/tools/ant/util/StringUtils.java
  87. +8
    -8
      src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
  88. +9
    -10
      src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
  89. +1
    -1
      src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java
  90. +1
    -1
      src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java
  91. +1
    -1
      src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java
  92. +1
    -1
      src/main/org/apache/tools/ant/util/regexp/JakartaRegexpRegexp.java
  93. +1
    -1
      src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java
  94. +1
    -1
      src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java
  95. +61
    -61
      src/main/org/apache/tools/bzip2/CBZip2InputStream.java
  96. +113
    -113
      src/main/org/apache/tools/bzip2/CBZip2OutputStream.java
  97. +2
    -2
      src/main/org/apache/tools/bzip2/CRC.java
  98. +3
    -3
      src/main/org/apache/tools/tar/TarEntry.java
  99. +9
    -9
      src/main/org/apache/tools/zip/AsiExtraField.java
  100. +22
    -20
      src/main/org/apache/tools/zip/ExtraFieldUtils.java

+ 12
- 8
src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java View File

@@ -128,9 +128,9 @@ public class ProjectHelperImpl extends ProjectHelper {
*/ */
public void parse(Project project, Object source) throws BuildException { public void parse(Project project, Object source) throws BuildException {
if (!(source instanceof File)) { 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; FileInputStream inputStream = null;
InputSource inputSource = null; InputSource inputSource = null;


@@ -193,7 +193,7 @@ public class ProjectHelperImpl extends ProjectHelper {
exc); exc);
} catch (IOException exc) { } catch (IOException exc) {
throw new BuildException("Error reading project file: " throw new BuildException("Error reading project file: "
+exc.getMessage(), exc);
+ exc.getMessage(), exc);
} finally { } finally {
if (inputStream != null) { if (inputStream != null) {
try { try {
@@ -321,7 +321,7 @@ public class ProjectHelperImpl extends ProjectHelper {
static class RootHandler extends HandlerBase { static class RootHandler extends HandlerBase {
ProjectHelperImpl helperImpl; ProjectHelperImpl helperImpl;
public RootHandler( ProjectHelperImpl helperImpl ) {
public RootHandler(ProjectHelperImpl helperImpl) {
this.helperImpl = helperImpl; this.helperImpl = helperImpl;
} }
@@ -876,9 +876,11 @@ public class ProjectHelperImpl extends ProjectHelper {
public void startElement(String name, AttributeList attrs) throws SAXParseException { public void startElement(String name, AttributeList attrs) throws SAXParseException {
if (task instanceof TaskContainer) { if (task instanceof TaskContainer) {
// task can contain other tasks - no other nested elements possible // 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 { } 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) { if (child instanceof TaskContainer) {
// taskcontainer nested element can contain other tasks - no other // taskcontainer nested element can contain other tasks - no other
// nested elements possible // 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 { } else {
new NestedElementHandler(helperImpl, this, child, childWrapper, target).init(name, attrs);
new NestedElementHandler(helperImpl, this, child,
childWrapper, target).init(name, attrs);
} }
} }
} }


+ 73
- 96
src/main/org/apache/tools/ant/taskdefs/BuildNumber.java View File

@@ -63,12 +63,11 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.util.FileUtils; 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> * @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @version $Revision$ $Date$ * @version $Revision$ $Date$
@@ -76,85 +75,76 @@ import org.apache.tools.ant.util.FileUtils;
* @ant.task name="buildnumber" * @ant.task name="buildnumber"
*/ */
public class BuildNumber public class BuildNumber
extends Task
{
extends Task {
/** /**
* The name of the property in which the build number is stored. * The name of the property in which the build number is stored.
*/ */
private static final String DEFAULT_PROPERTY_NAME = "build.number"; 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; 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; 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. * @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; m_file = file;
} }



/** /**
* Run task. * Run task.
* *
* @exception BuildException if an error occurs * @exception BuildException if an error occurs
*/ */
public void execute() 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(); validate();


final Properties properties = loadProperties(); 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 // Write the properties file back out
FileOutputStream output = null; 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!"; 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; 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(); output.close();
}
catch( final IOException ioe )
{
} catch (final IOException ioe) {
} }
} }
m_file = savedFile; m_file = savedFile;
} }


//Finally set the property //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. * 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 * @return the build number or if no number in properties object
* @throws BuildException if build.number property is not an integer * @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 = 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 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; 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. * Utility method to load properties from file.
* *
@@ -188,72 +176,61 @@ public class BuildNumber
* @throws BuildException * @throws BuildException
*/ */
private Properties loadProperties() private Properties loadProperties()
throws BuildException
{
throws BuildException {
FileInputStream input = null; FileInputStream input = null;
try
{
try {
final Properties properties = new Properties(); final Properties properties = new Properties();
input = new FileInputStream( m_file );
properties.load( input );

input = new FileInputStream(m_file);
properties.load(input);
return properties; 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(); input.close();
}
catch( final IOException ioe )
{
} catch (final IOException ioe) {
} }
} }
} }
} }



/** /**
* Validate that the task parameters are valid. * Validate that the task parameters are valid.
* *
* @throws BuildException if parameters are invalid * @throws BuildException if parameters are invalid
*/ */
private void validate() 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); 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."; 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 + "."; 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 + "."; final String message = "Unable to write to " + m_file + ".";
throw new BuildException( message );

throw new BuildException(message);
} }
} }
} }


+ 6
- 14
src/main/org/apache/tools/ant/taskdefs/Concat.java View File

@@ -227,7 +227,7 @@ public class Concat extends Task {
try { try {
// Iterate the FileSet collection, concatenating each file as // Iterate the FileSet collection, concatenating each file as
// it is encountered. // it is encountered.
for (Enumeration e = fileSets.elements(); e.hasMoreElements(); ) {
for (Enumeration e = fileSets.elements(); e.hasMoreElements();) {
// Root directory for files. // Root directory for files.
File fileSetBase = null; File fileSetBase = null;
@@ -392,17 +392,14 @@ public class Concat extends Task {
// Log using WARN so it displays in 'quiet' mode. // Log using WARN so it displays in 'quiet' mode.
out = new PrintWriter( out = new PrintWriter(
new OutputStreamWriter( new OutputStreamWriter(
new LogOutputStream(this, Project.MSG_WARN)
)
);
new LogOutputStream(this, Project.MSG_WARN)));
} else { } else {
out = new PrintWriter( out = new PrintWriter(
new OutputStreamWriter( new OutputStreamWriter(
new FileOutputStream(destinationFile new FileOutputStream(destinationFile
.getAbsolutePath(), .getAbsolutePath(),
append), append),
encoding)
);
encoding));
// This flag should only be recognized for the first // This flag should only be recognized for the first
// file. In the context of a single 'cat', we always // 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++) { for (int i = 0; i < len; i++) {
in = new BufferedReader( in = new BufferedReader(
new InputStreamReader(
new FileInputStream(input[i]),
encoding
)
);
new InputStreamReader(new FileInputStream(input[i]),
encoding));


String line; String line;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
@@ -480,9 +474,7 @@ public class Concat extends Task {
// Reads the text, line by line. // Reads the text, line by line.
BufferedReader reader = null; BufferedReader reader = null;
try { try {
reader = new BufferedReader(
new StringReader(text)
);
reader = new BufferedReader(new StringReader(text));


String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/LoadProperties.java View File

@@ -122,7 +122,7 @@ public final class LoadProperties extends Task {


try { try {
final long len = srcFile.length(); final long len = srcFile.length();
final int size=(int) len;
final int size = (int) len;


//open up the file //open up the file
fis = new FileInputStream(srcFile); fis = new FileInputStream(srcFile);


+ 21
- 21
src/main/org/apache/tools/ant/taskdefs/Manifest.java View File

@@ -184,7 +184,7 @@ public class Manifest extends Task {
return false; return false;
} }


Attribute rhsAttribute = (Attribute)rhs;
Attribute rhsAttribute = (Attribute) rhs;
return (name != null && rhsAttribute.name != null && return (name != null && rhsAttribute.name != null &&
getKey().equals(rhsAttribute.getKey()) && getKey().equals(rhsAttribute.getKey()) &&
values != null && values != null &&
@@ -266,7 +266,7 @@ public class Manifest extends Task {
String fullValue = ""; String fullValue = "";
for (Enumeration e = getValues(); e.hasMoreElements();) { for (Enumeration e = getValues(); e.hasMoreElements();) {
String value = (String)e.nextElement();
String value = (String) e.nextElement();
fullValue += value + " "; fullValue += value + " ";
} }
return fullValue.trim(); return fullValue.trim();
@@ -301,7 +301,7 @@ public class Manifest extends Task {
* @param line the continuation line. * @param line the continuation line.
*/ */
public void addContinuation(String line) { public void addContinuation(String line) {
String currentValue = (String)values.elementAt(currentIndex);
String currentValue = (String) values.elementAt(currentIndex);
setValue(currentValue + line.substring(1)); setValue(currentValue + line.substring(1));
} }


@@ -314,7 +314,7 @@ public class Manifest extends Task {
*/ */
public void write(PrintWriter writer) throws IOException { public void write(PrintWriter writer) throws IOException {
for (Enumeration e = getValues(); e.hasMoreElements();) { 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(); Enumeration e = section.getAttributeKeys();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
String attributeName = (String)e.nextElement();
String attributeName = (String) e.nextElement();
Attribute attribute = section.getAttribute(attributeName); Attribute attribute = section.getAttribute(attributeName);
if (attributeName.equals(ATTRIBUTE_CLASSPATH) && if (attributeName.equals(ATTRIBUTE_CLASSPATH) &&
attributes.containsKey(attributeName)) { attributes.containsKey(attributeName)) {
Attribute ourClassPath = getAttribute(attributeName); Attribute ourClassPath = getAttribute(attributeName);
Enumeration cpe = attribute.getValues(); Enumeration cpe = attribute.getValues();
while (cpe.hasMoreElements()) { while (cpe.hasMoreElements()) {
String value = (String)cpe.nextElement();
String value = (String) cpe.nextElement();
ourClassPath.addValue(value); ourClassPath.addValue(value);
} }
} else { } else {
@@ -488,7 +488,7 @@ public class Manifest extends Task {
} }
Enumeration e = getAttributeKeys(); Enumeration e = getAttributeKeys();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
String key = (String)e.nextElement();
String key = (String) e.nextElement();
Attribute attribute = getAttribute(key); Attribute attribute = getAttribute(key);
attribute.write(writer); attribute.write(writer);
} }
@@ -504,7 +504,7 @@ public class Manifest extends Task {
* instances. * instances.
*/ */
public Attribute getAttribute(String attributeName) { 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(); String attributeKey = attribute.getKey();
if (attributeKey.equals(ATTRIBUTE_CLASSPATH)) { if (attributeKey.equals(ATTRIBUTE_CLASSPATH)) {
Attribute classpathAttribute = Attribute classpathAttribute =
(Attribute)attributes.get(attributeKey);
(Attribute) attributes.get(attributeKey);
if (classpathAttribute == null) { if (classpathAttribute == null) {
storeAttribute(attribute); storeAttribute(attribute);
} else { } else {
Enumeration e = attribute.getValues(); Enumeration e = attribute.getValues();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
String value = (String)e.nextElement();
String value = (String) e.nextElement();
classpathAttribute.addValue(value); classpathAttribute.addValue(value);
} }
} }
@@ -649,13 +649,13 @@ public class Manifest extends Task {
return false; return false;
} }


Section rhsSection = (Section)rhs;
Section rhsSection = (Section) rhs;
if (attributes.size() != rhsSection.attributes.size()) { if (attributes.size() != rhsSection.attributes.size()) {
return false; return false;
} }


for (Enumeration e = attributes.keys(); e.hasMoreElements();) { for (Enumeration e = attributes.keys(); e.hasMoreElements();) {
String attributeName = (String)e.nextElement();
String attributeName = (String) e.nextElement();
Object attributeValue = attributes.get(attributeName); Object attributeValue = attributes.get(attributeName);
Object rhsAttributeValue Object rhsAttributeValue
= rhsSection.attributes.get(attributeName); = rhsSection.attributes.get(attributeName);
@@ -843,10 +843,10 @@ public class Manifest extends Task {


Enumeration e = other.getSectionNames(); Enumeration e = other.getSectionNames();
while (e.hasMoreElements()) { 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 otherSection
= (Section)other.sections.get(sectionName);
= (Section) other.sections.get(sectionName);
if (ourSection == null) { if (ourSection == null) {
if (otherSection != null) { if (otherSection != null) {
addConfiguredSection(otherSection); addConfiguredSection(otherSection);
@@ -889,7 +889,7 @@ public class Manifest extends Task {


Enumeration e = sectionIndex.elements(); Enumeration e = sectionIndex.elements();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
String sectionName = (String)e.nextElement();
String sectionName = (String) e.nextElement();
Section section = getSection(sectionName); Section section = getSection(sectionName);
section.write(writer); section.write(writer);
} }
@@ -927,7 +927,7 @@ public class Manifest extends Task {
// create a vector and add in the warnings for all the sections // create a vector and add in the warnings for all the sections
Enumeration e = sections.elements(); Enumeration e = sections.elements();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
Section section = (Section)e.nextElement();
Section section = (Section) e.nextElement();
Enumeration e2 = section.getWarnings(); Enumeration e2 = section.getWarnings();
while (e2.hasMoreElements()) { while (e2.hasMoreElements()) {
warnings.addElement(e2.nextElement()); warnings.addElement(e2.nextElement());
@@ -945,7 +945,7 @@ public class Manifest extends Task {
return false; return false;
} }


Manifest rhsManifest = (Manifest)rhs;
Manifest rhsManifest = (Manifest) rhs;
if (manifestVersion == null) { if (manifestVersion == null) {
if (rhsManifest.manifestVersion != null) { if (rhsManifest.manifestVersion != null) {
return false; return false;
@@ -963,9 +963,9 @@ public class Manifest extends Task {


Enumeration e = sections.elements(); Enumeration e = sections.elements();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
Section section = (Section)e.nextElement();
Section section = (Section) e.nextElement();
Section rhsSection Section rhsSection
= (Section)rhsManifest.sections.get(section.getName());
= (Section) rhsManifest.sections.get(section.getName());
if (!section.equals(rhsSection)) { if (!section.equals(rhsSection)) {
return false; return false;
} }
@@ -1018,7 +1018,7 @@ public class Manifest extends Task {
* does not exist in the manifest * does not exist in the manifest
*/ */
public Section getSection(String name) { public Section getSection(String name) {
return (Section)sections.get(name);
return (Section) sections.get(name);
} }


/** /**


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/Parallel.java View File

@@ -99,7 +99,7 @@ public class Parallel extends Task
int threadNumber = 0; int threadNumber = 0;
for (Enumeration e = nestedTasks.elements(); e.hasMoreElements(); for (Enumeration e = nestedTasks.elements(); e.hasMoreElements();
threadNumber++) { threadNumber++) {
Task nestedTask = (Task)e.nextElement();
Task nestedTask = (Task) e.nextElement();
threads[threadNumber] = new TaskThread(threadNumber, nestedTask); threads[threadNumber] = new TaskThread(threadNumber, nestedTask);
} }


@@ -132,7 +132,7 @@ public class Parallel extends Task
} }
if (t instanceof BuildException && if (t instanceof BuildException &&
firstLocation == Location.UNKNOWN_LOCATION) { firstLocation == Location.UNKNOWN_LOCATION) {
firstLocation = ((BuildException)t).getLocation();
firstLocation = ((BuildException) t).getLocation();
} }
exceptionMessage.append(StringUtils.LINE_SEP); exceptionMessage.append(StringUtils.LINE_SEP);
exceptionMessage.append(t.getMessage()); exceptionMessage.append(t.getMessage());
@@ -141,7 +141,7 @@ public class Parallel extends Task
if (numExceptions == 1) { if (numExceptions == 1) {
if (firstException instanceof BuildException) { if (firstException instanceof BuildException) {
throw (BuildException)firstException;
throw (BuildException) firstException;
} }
else { else {
throw new BuildException(firstException); throw new BuildException(firstException);


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/Patch.java View File

@@ -88,7 +88,7 @@ public class Patch extends Task {
*/ */
public void setPatchfile(File file) { public void setPatchfile(File file) {
if (!file.exists()) { if (!file.exists()) {
throw new BuildException("patchfile "+file+" doesn\'t exist",
throw new BuildException("patchfile " + file + " doesn\'t exist",
location); location);
} }
cmd.createArgument().setValue("-i"); cmd.createArgument().setValue("-i");
@@ -124,7 +124,7 @@ public class Patch extends Task {
if (num < 0) { if (num < 0) {
throw new BuildException("strip has to be >= 0", location); 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); location);
} }
Commandline toExecute = (Commandline)cmd.clone();
Commandline toExecute = (Commandline) cmd.clone();
toExecute.setExecutable("patch"); toExecute.setExecutable("patch");


if (originalFile != null) { if (originalFile != null) {


+ 147
- 139
src/main/org/apache/tools/ant/taskdefs/PathConvert.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,6 @@
* information on the Apache Software Foundation, please see * information on the Apache Software Foundation, please see
* <http://www.apache.org/>. * <http://www.apache.org/>.
*/ */

package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
@@ -70,53 +69,66 @@ import java.util.Vector;
import java.io.File; 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 * @since Ant 1.4
*
* @ant.task category="utility" * @ant.task category="utility"
*/ */
public class PathConvert extends Task { 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() { public PathConvert() {
onWindows = Os.isFamily("dos"); onWindows = Os.isFamily("dos");
} }



/** /**
* Helper class, holds the nested <map> values. Elements will
* look like this: &lt;map from=&quot;d:&quot; to=&quot;/foo&quot;/&gt;
* <p>
* When running on windows, the prefix comparison will be case insensitive.
* Helper class, holds the nested <map> values. Elements will look like
* this: &lt;map from=&quot;d:&quot; to=&quot;/foo&quot;/&gt; <p>
*
* When running on windows, the prefix comparison will be case
* insensitive.
*/ */
public class MapEntry { public class MapEntry {


/**
* Set the &quot;from&quot; attribute of the map entry
*/
public void setFrom( String from ) {
/** Set the &quot;from&quot; attribute of the map entry */
public void setFrom(String from) {
this.from = from; this.from = from;
} }


/**
* Set the &quot;to&quot; attribute of the map entry
*/
public void setTo( String to ) {

/** Set the &quot;to&quot; attribute of the map entry */
public void setTo(String to) {
this.to = to; this.to = to;
} }



/** /**
* Apply this map entry to a given path element * Apply this map entry to a given path element
*
* @param elem Path element to process * @param elem Path element to process
* @return String Updated path element after mapping * @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 // 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 // If the element starts with the configured prefix, then
// convert the prefix to the configured 'to' value. // convert the prefix to the configured 'to' value.


if( cmpElem.startsWith( cmpFrom ) ) {
if (cmpElem.startsWith(cmpFrom)) {
int len = from.length(); int len = from.length();


if( len >= elem.length() ) {
if (len >= elem.length()) {
elem = to; elem = to;
} else { } else {
elem = to + elem.substring( len );
elem = to + elem.substring(len);
} }
} }


@@ -144,54 +156,58 @@ public class PathConvert extends Task {
private String to = null; private String to = null;
} }



public static class TargetOs extends EnumeratedAttribute { public static class TargetOs extends EnumeratedAttribute {
public String[] getValues() { 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() { public Path createPath() {


if( isReference() ) {
if (isReference()) {
throw noChildrenAllowed(); throw noChildrenAllowed();
} }


if( path == null ) {
if (path == null) {
path = new Path(getProject()); path = new Path(getProject());
} }
return path.createPath(); return path.createPath();
} }


/**
* Create a nested MAP element
*/

/** Create a nested MAP element */
public MapEntry createMap() { public MapEntry createMap() {


MapEntry entry = new MapEntry(); MapEntry entry = new MapEntry();
prefixMap.addElement( entry );

prefixMap.addElement(entry);
return entry; return entry;
} }




/** /**
* Set the value of the targetos attribute * Set the value of the targetos attribute
*
* @deprecated use the method taking a TargetOs argument instead * @deprecated use the method taking a TargetOs argument instead
* @see #setTargetos(TargetOs) * @see #setTargetos(TargetOs)
*/ */
public void setTargetos( String target ) {
public void setTargetos(String target) {
TargetOs to = new TargetOs(); TargetOs to = new TargetOs();

to.setValue(target); to.setValue(target);
setTargetos(to); setTargetos(to);
} }



/** /**
* Set the value of the targetos attribute * Set the value of the targetos attribute
*
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void setTargetos( TargetOs target ) {
public void setTargetos(TargetOs target) {


targetOS = target.getValue(); targetOS = target.getValue();


@@ -205,134 +221,135 @@ public class PathConvert extends Task {
targetWindows = !targetOS.equals("unix"); 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; property = p;
} }



/** /**
* Adds a reference to a Path, FileSet, DirSet, or FileList defined * Adds a reference to a Path, FileSet, DirSet, or FileList defined
* elsewhere. * elsewhere.
*/ */
public void setRefid(Reference r) { public void setRefid(Reference r) {
if( path != null ) {
if (path != null) {
throw noChildrenAllowed(); throw noChildrenAllowed();
} }


refid = r; 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; pathSep = sep;
} }



/** /**
* Override the default directory separator string for the target os * Override the default directory separator string for the target os
*/ */
public void setDirSep( String sep ) {
public void setDirSep(String sep) {
dirSep = sep; dirSep = sep;
} }


/**
* Has the refid attribute of this element been set?
*/

/** Has the refid attribute of this element been set? */
public boolean isReference() { public boolean isReference() {
return refid != null; return refid != null;
} }


/**
* Do the execution.
*/

/** Do the execution. */
public void execute() throws BuildException { public void execute() throws BuildException {
Path savedPath = path; 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 { try {
// If we are a reference, create a Path from the reference // If we are a reference, create a Path from the reference
if( isReference() ) {
if (isReference()) {
path = new Path(getProject()).createPath(); path = new Path(getProject()).createPath();
Object obj = refid.getReferencedObject(getProject()); Object obj = refid.getReferencedObject(getProject());
if( obj instanceof Path ) {
if (obj instanceof Path) {
path.setRefid(refid); 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 { } 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 // Currently, we deal with only two path formats: Unix and Windows
// And Unix is everything that is not Windows // And Unix is everything that is not Windows
// (with the exception for NetWare and OS/2 below) // (with the exception for NetWare and OS/2 below)
// for NetWare and OS/2, piggy-back on Windows, since here and // for NetWare and OS/2, piggy-back on Windows, since here and
// in the apply code, the same assumptions can be made as with // in the apply code, the same assumptions can be made as with
// windows - that \\ is an OK separator, and do comparisons // windows - that \\ is an OK separator, and do comparisons
// case-insensitive. // case-insensitive.
String fromDirSep = onWindows ? "\\" : "/"; String fromDirSep = onWindows ? "\\" : "/";
StringBuffer rslt = new StringBuffer( 100 );
StringBuffer rslt = new StringBuffer(100);
// Get the list of path components in canonical form // Get the list of path components in canonical form
String[] elems = path.list(); String[] elems = path.list();
for( int i=0; i < elems.length; i++ ) {
for (int i = 0; i < elems.length; i++) {
String elem = elems[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 // Now convert the path and file separator characters from the
// current os to the target os. // 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); new StringTokenizer(elem, fromDirSep, true);
String token = null; String token = null;
while ( stDirectory.hasMoreTokens() ) {
while (stDirectory.hasMoreTokens()) {
token = stDirectory.nextToken(); token = stDirectory.nextToken();
if (fromDirSep.equals(token)) { 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 // Place the result into the specified property
String value = rslt.toString(); 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 { } finally {
path = savedPath; path = savedPath;
dirSep = savedDirSep; 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. * then the input string is returned unchanged.
* *
* @param elem The path element to apply the map to * @param elem The path element to apply the map to
* @return String Updated element * @return String Updated element
*/ */
private String mapElement( String elem ) {
private String mapElement(String elem) {


int size = prefixMap.size(); int size = prefixMap.size();


if( size != 0 ) {
if (size != 0) {


// Iterate over the map entries and apply each one. // Iterate over the map entries and apply each one.
// Stop when one of the entries actually changes the element. // 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 // Note I'm using "!=" to see if we got a new object back from
// the apply method. // the apply method.


if( newElem != elem ) {
if (newElem != elem) {
elem = newElem; 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; return elem;
} }



/** /**
* Validate that all our parameters have been properly initialized. * Validate that all our parameters have been properly initialized.
*
* @throws BuildException if something is not setup properly * @throws BuildException if something is not setup properly
*/ */
private void validateSetup() throws BuildException { 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 // 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 // Determine the separator strings. The dirsep and pathsep attributes
@@ -400,16 +420,16 @@ public class PathConvert extends Task {
String dsep = File.separator; String dsep = File.separator;
String psep = File.pathSeparator; String psep = File.pathSeparator;


if( targetOS != null ) {
if (targetOS != null) {
psep = targetWindows ? ";" : ":"; psep = targetWindows ? ";" : ":";
dsep = targetWindows ? "\\" : "/"; dsep = targetWindows ? "\\" : "/";
} }


if( pathSep != null ) { // override with pathsep=
if (pathSep != null) {// override with pathsep=
psep = pathSep; psep = pathSep;
} }


if( dirSep != null ) { // override with dirsep=
if (dirSep != null) {// override with dirsep=
dsep = dirSep; dsep = dirSep;
} }


@@ -417,27 +437,15 @@ public class PathConvert extends Task {
dirSep = dsep; 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() { private BuildException noChildrenAllowed() {
return new BuildException("You must not specify nested <path> " 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

} }


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java View File

@@ -159,7 +159,7 @@ class ChangeLogParser {
saveEntry(); saveEntry();
m_status = GET_FILE; m_status = GET_FILE;
} }
else if( line.startsWith( "----------------------------" ) ) {
else if (line.startsWith("----------------------------")) {
final int end = m_comment.length() - lineSeparator.length(); //was -1 final int end = m_comment.length() - lineSeparator.length(); //was -1
m_comment = m_comment.substring(0, end); m_comment = m_comment.substring(0, end);
m_status = GET_PREVIOUS_REV; m_status = GET_PREVIOUS_REV;


+ 5
- 5
src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java View File

@@ -168,7 +168,7 @@ public class CvsTagDiff extends Task {
* @exception BuildException if an error occurs * @exception BuildException if an error occurs
*/ */
public void init() throws BuildException { 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 // build the rdiff command
String rdiff = "rdiff -s " + 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); log("Cvs command is " + rdiff, Project.MSG_VERBOSE);
m_cvs.setCommand(rdiff); m_cvs.setCommand(rdiff);




+ 13
- 13
src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java View File

@@ -148,12 +148,12 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware
if (resolver != null) { if (resolver != null) {
if (tfactory.getFeature(SAXSource.FEATURE)) { if (tfactory.getFeature(SAXSource.FEATURE)) {
SAXParserFactory spFactory = SAXParserFactory.newInstance(); SAXParserFactory spFactory = SAXParserFactory.newInstance();
spFactory.setNamespaceAware( true );
spFactory.setNamespaceAware(true);
XMLReader reader = spFactory.newSAXParser().getXMLReader(); XMLReader reader = spFactory.newSAXParser().getXMLReader();
reader.setEntityResolver(resolver); reader.setEntityResolver(resolver);
src = new SAXSource(reader, new InputSource(fis)); src = new SAXSource(reader, new InputSource(fis));
} else { } else {
throw new IllegalStateException("xcatalog specified, but "+
throw new IllegalStateException("xcatalog specified, but " +
"parser doesn't support SAX"); "parser doesn't support SAX");
} }
} else { } else {
@@ -193,7 +193,7 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware
// making sure it is really a /'ed path // making sure it is really a /'ed path
protected String getSystemId(File file){ protected String getSystemId(File file){
String path = file.getAbsolutePath(); String path = file.getAbsolutePath();
path = path.replace('\\','/');
path = path.replace('\\', '/');


// on Windows, use 'file:///' // on Windows, use 'file:///'
if (File.separatorChar == '\\') { if (File.separatorChar == '\\') {
@@ -234,27 +234,27 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware
} }
StringBuffer msg = new StringBuffer(); 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(); String url = e.getLocator().getSystemId();
if(url.startsWith("file:///")) {
if (url.startsWith("file:///")) {
url = url.substring(8); url = url.substring(8);
} }
msg.append(url); msg.append(url);
} else { } else {
msg.append("Unknown file"); 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()); 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()); logger.log(msg.toString());


+ 36
- 30
src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java View File

@@ -95,7 +95,8 @@ public class XMLValidateTask extends Task {
* validation. * validation.
*/ */
// The crimson implementation is shipped with ant. // 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: "; protected static String INIT_FAILED_MSG = "Could not start xml validation: ";


@@ -234,7 +235,7 @@ public class XMLValidateTask extends Task {
LocalResolver resolver = new LocalResolver(); LocalResolver resolver = new LocalResolver();


for (Enumeration i = dtdLocations.elements(); i.hasMoreElements();) { for (Enumeration i = dtdLocations.elements(); i.hasMoreElements();) {
DTDLocation location = (DTDLocation)i.nextElement();
DTDLocation location = (DTDLocation) i.nextElement();
resolver.registerDTD(location); resolver.registerDTD(location);
} }
return resolver; return resolver;
@@ -243,7 +244,7 @@ public class XMLValidateTask extends Task {
public void execute() throws BuildException { public void execute() throws BuildException {


int fileProcessed = 0; 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."); 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); FileSet fs = (FileSet) filesets.elementAt(i);
DirectoryScanner ds = fs.getDirectoryScanner(project); DirectoryScanner ds = fs.getDirectoryScanner(project);
String[] files = ds.getIncludedFiles(); 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]); File srcFile = new File(fs.getDir(project), files[j]);
doValidate(srcFile); doValidate(srcFile);
fileProcessed++; fileProcessed++;
@@ -288,7 +289,7 @@ public class XMLValidateTask extends Task {
try { try {
// load the parser class // load the parser class
// with JAXP, we would use a SAXParser factory // with JAXP, we would use a SAXParser factory
Class readerClass= null;
Class readerClass = null;
//Class readerImpl = null; //Class readerImpl = null;
//Class parserImpl = null; //Class parserImpl = null;
if (classpath != null) { if (classpath != null) {
@@ -313,9 +314,8 @@ public class XMLValidateTask extends Task {
xmlReader = new ParserAdapter(parser); xmlReader = new ParserAdapter(parser);
log("Using SAX1 parser " + readerClassName, Project.MSG_VERBOSE); log("Using SAX1 parser " + readerClassName, Project.MSG_VERBOSE);
} else { } 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) { } catch (ClassNotFoundException e) {
@@ -329,11 +329,11 @@ public class XMLValidateTask extends Task {
xmlReader.setEntityResolver(getEntityResolver()); xmlReader.setEntityResolver(getEntityResolver());
xmlReader.setErrorHandler(errorHandler); xmlReader.setErrorHandler(errorHandler);


if (! (xmlReader instanceof ParserAdapter)) {
if (!(xmlReader instanceof ParserAdapter)) {
// turn validation on // 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 throw new BuildException(INIT_FAILED_MSG
+ readerClassName + readerClassName
+ " doesn't provide validation"); + " doesn't provide validation");
@@ -341,7 +341,7 @@ public class XMLValidateTask extends Task {
} }
// set other features // set other features
Enumeration enum = features.keys(); Enumeration enum = features.keys();
while(enum.hasMoreElements()) {
while (enum.hasMoreElements()) {
String featureId = (String) enum.nextElement(); String featureId = (String) enum.nextElement();
setFeature(featureId, ((Boolean) features.get(featureId)).booleanValue(), true); setFeature(featureId, ((Boolean) features.get(featureId)).booleanValue(), true);
} }
@@ -356,7 +356,7 @@ public class XMLValidateTask extends Task {


boolean toReturn = false; boolean toReturn = false;
try { try {
xmlReader.setFeature(feature,value);
xmlReader.setFeature(feature, value);
toReturn = true; toReturn = true;
} catch (SAXNotRecognizedException e) { } catch (SAXNotRecognizedException e) {
if (warn) { if (warn) {
@@ -386,23 +386,26 @@ public class XMLValidateTask extends Task {
String uri = "file:" + afile.getAbsolutePath().replace('\\', '/'); String uri = "file:" + afile.getAbsolutePath().replace('\\', '/');
for (int index = uri.indexOf('#'); index != -1; for (int index = uri.indexOf('#'); index != -1;
index = uri.indexOf('#')) { 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); is.setSystemId(uri);
xmlReader.parse(is); xmlReader.parse(is);
} catch (SAXException ex) { } catch (SAXException ex) {
if (failOnError) { if (failOnError) {
throw new BuildException("Could not validate document " + afile);
throw new BuildException("Could not validate document "
+ afile);
} }
} catch (IOException ex) { } 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 (errorHandler.getFailure()) {
if (failOnError) { if (failOnError) {
throw new BuildException(afile + " is not a valid XML document."); throw new BuildException(afile + " is not a valid XML document.");
} else { } 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) { public void fatalError(SAXParseException exception) {
failed = true; failed = true;
doLog(exception,Project.MSG_ERR);
doLog(exception, Project.MSG_ERR);
} }


public void error(SAXParseException exception) { public void error(SAXParseException exception) {
failed = true; failed = true;
doLog(exception,Project.MSG_ERR);
doLog(exception, Project.MSG_ERR);
} }


public void warning(SAXParseException exception) { public void warning(SAXParseException exception) {
// depending on implementation, XMLReader can yield hips of warning, // depending on implementation, XMLReader can yield hips of warning,
// only output then if user explicitely asked for it // only output then if user explicitely asked for it
if (warn) { 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 (fileDTD.exists()) {
if (publicId != null) { if (publicId != null) {
fileDTDs.put(publicId, fileDTD); 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; return;
} }
@@ -501,7 +505,8 @@ public class XMLValidateTask extends Task {
if (LocalResolver.this.getClass().getResource(location) != null) { if (LocalResolver.this.getClass().getResource(location) != null) {
if (publicId != null) { if (publicId != null) {
resourceDTDs.put(publicId, location); 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); URL urldtd = new URL(location);
urlDTDs.put(publicId, urldtd); urlDTDs.put(publicId, urldtd);
} }
} catch ( java.net.MalformedURLException e) {
} catch (MalformedURLException e) {
//ignored //ignored
} }
} }
@@ -523,27 +528,28 @@ public class XMLValidateTask extends Task {
try { try {
log("Resolved " + publicId + " to local file " + dtdFile, Project.MSG_VERBOSE); log("Resolved " + publicId + " to local file " + dtdFile, Project.MSG_VERBOSE);
return new InputSource(new FileInputStream(dtdFile)); return new InputSource(new FileInputStream(dtdFile));
} catch( FileNotFoundException ex ) {
} catch (FileNotFoundException ex) {
// ignore // ignore
} }
} }


String dtdResourceName = (String)resourceDTDs.get(publicId);
String dtdResourceName = (String) resourceDTDs.get(publicId);
if (dtdResourceName != null) { if (dtdResourceName != null) {
InputStream is = this.getClass().getResourceAsStream(dtdResourceName); InputStream is = this.getClass().getResourceAsStream(dtdResourceName);
if (is != null) { 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); return new InputSource(is);
} }
} }


URL dtdUrl = (URL) urlDTDs.get(publicId); URL dtdUrl = (URL) urlDTDs.get(publicId);
if ( dtdUrl != null ) {
if (dtdUrl != null) {
try { try {
InputStream is = dtdUrl.openStream(); InputStream is = dtdUrl.openStream();
log("Resolved " + publicId + " to url " + dtdUrl, Project.MSG_VERBOSE); log("Resolved " + publicId + " to url " + dtdUrl, Project.MSG_VERBOSE);
return new InputSource(is); return new InputSource(is);
} catch ( IOException ioe) {
} catch (IOException ioe) {
//ignore //ignore
} }
} }


+ 5
- 5
src/main/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java View File

@@ -114,7 +114,7 @@ public class JlinkTask extends MatchingTask {
this.mergefiles = mergefiles; this.mergefiles = mergefiles;
} }
else { else {
this.mergefiles .append(mergefiles);
this.mergefiles.append(mergefiles);
} }
} }


@@ -167,16 +167,16 @@ public class JlinkTask extends MatchingTask {
linker.setOutfile(outfile.getPath()); linker.setOutfile(outfile.getPath());
linker.setCompression(compress); linker.setCompression(compress);
if (haveMergeFiles()) { 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()) { if (haveAddFiles()) {
log("add files: " + addfiles.toString(), Project .MSG_VERBOSE);
log("add files: " + addfiles.toString(), Project.MSG_VERBOSE);
linker.addAddFiles(addfiles.list()); linker.addAddFiles(addfiles.list());
} }
try { try {
linker.link(); linker.link();
} catch(Exception ex) {
} catch (Exception ex) {
throw new BuildException(ex, location); throw new BuildException(ex, location);
} }
} }


+ 202
- 178
src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -51,16 +51,13 @@
* information on the Apache Software Foundation, please see * information on the Apache Software Foundation, please see
* <http://www.apache.org/>. * <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; package org.apache.tools.ant.taskdefs.optional.jlink;


@@ -70,8 +67,8 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.BufferedInputStream; 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.ZipOutputStream;
import java.util.zip.Deflater; import java.util.zip.Deflater;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
@@ -79,167 +76,168 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipException; import java.util.zip.ZipException;
import java.util.zip.CRC32; 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 { } 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. //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()); //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 // 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(); 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. //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. * Actually performs the merging of f into the output.
* f should be a zip or jar file. * 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. //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(); Enumeration entries = zipf.entries();
while (entries.hasMoreElements()){

while (entries.hasMoreElements()) {
ZipEntry inputEntry = (ZipEntry) entries.nextElement(); ZipEntry inputEntry = (ZipEntry) entries.nextElement();
//Ignore manifest entries. They're bound to cause conflicts between //Ignore manifest entries. They're bound to cause conflicts between
//files that are being merged. User should supply their own //files that are being merged. User should supply their own
//manifest file when doing the merge. //manifest file when doing the merge.
String inputEntryName = inputEntry.getName(); String inputEntryName = inputEntry.getName();
int index = inputEntryName.indexOf("META-INF"); 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. //META-INF not found in the name of the entry. Go ahead and process it.
try { try {
output.putNextEntry(processEntry(zipf, inputEntry)); 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 //If we get here, it could be because we are trying to put a
//directory entry that already exists. //directory entry that already exists.
//For example, we're trying to write "com", but a previous //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 //In that case, just ignore the error and go on to the
//next entry. //next entry.
String mess = ex.getMessage(); 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; continue;
} else { } 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; throw ex;
} }
} }

InputStream in = zipf.getInputStream(inputEntry); InputStream in = zipf.getInputStream(inputEntry);
int len = buffer.length; int len = buffer.length;
int count = -1; int count = -1;
while ((count = in.read(buffer, 0, len)) > 0){

while ((count = in.read(buffer, 0, len)) > 0) {
output.write(buffer, 0, count); output.write(buffer, 0, count);
} }
in.close(); in.close();
output.closeEntry(); output.closeEntry();
} }
} }
zipf .close();
zipf.close();
} }



/* /*
* Adds contents of a directory to the output. * 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]; 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 * 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 * which for a class is the name of the package with the class
* name appended. * 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. // 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); return (prefix + name);
} }



/* /*
* Adds a file to the output stream. * 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 //Make sure file exists
long checksum = 0; 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)); entry.setCrc(calcChecksum(file));
} }
FileInputStream input = new FileInputStream( file );
FileInputStream input = new FileInputStream(file);

addToOutputStream(output, input, entry); addToOutputStream(output, input, entry);
} }


/* /*
* A convenience method that several other methods might call. * 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 { try {
output.putNextEntry(ze);
output.putNextEntry(ze);
} catch (ZipException zipEx) { } catch (ZipException zipEx) {
//This entry already exists. So, go with the first one. //This entry already exists. So, go with the first one.
input.close(); input.close();
return; return;
} }

int numBytes = -1; int numBytes = -1;
while((numBytes = input.read(buffer)) > 0){

while ((numBytes = input.read(buffer)) > 0) {
output.write(buffer, 0, numBytes); output.write(buffer, 0, numBytes);
} }
output.closeEntry(); output.closeEntry();
input.close(); input.close();
} }



/* /*
* A method that does the work on a given entry in a mergefile. * 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. * 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. First, some notes.
On MRJ 2.2.2, getting the size, compressed size, and CRC32 from the 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. ZipInputStream does not work for compressed (deflated) files. Those calls return -1.
For uncompressed (stored) files, those calls do work. 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. uncompressed files.
Now, from some simple testing I did, it seems that the value of CRC-32 is 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. 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.setExtra(inputEntry.getExtra());
outputEntry.setComment(inputEntry.getComment()); outputEntry.setComment(inputEntry.getComment());
outputEntry.setTime(inputEntry.getTime()); outputEntry.setTime(inputEntry.getTime());
if (compression){
if (compression) {
outputEntry.setMethod(ZipEntry.DEFLATED); outputEntry.setMethod(ZipEntry.DEFLATED);
//Note, don't need to specify size or crc for compressed files. //Note, don't need to specify size or crc for compressed files.
} else { } else {
@@ -389,26 +408,30 @@ public class jlink extends Object{
} }
return outputEntry; return outputEntry;
} }


/* /*
* Necessary in the case where you add a entry that * Necessary in the case where you add a entry that
* is not compressed. * is not compressed.
*/ */
private long calcChecksum(File f) throws IOException { private long calcChecksum(File f) throws IOException {
BufferedInputStream in = new BufferedInputStream(new FileInputStream(f)); BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));

return calcChecksum(in, f.length()); return calcChecksum(in, f.length());
} }



/* /*
* Necessary in the case where you add a entry that * Necessary in the case where you add a entry that
* is not compressed. * 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(); CRC32 crc = new CRC32();
int len = buffer.length; int len = buffer.length;
int count = -1; 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; haveRead += count;
crc.update(buffer, 0, count); crc.update(buffer, 0, count);
} }
@@ -416,14 +439,15 @@ public class jlink extends Object{
return crc.getValue(); 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]; byte[] buffer = new byte[8192];


} }


+ 43
- 43
src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java View File

@@ -118,7 +118,7 @@ public class JspC extends MatchingTask
private File destDir; private File destDir;
private String packageName ; private String packageName ;
/** name of the compiler to use */ /** name of the compiler to use */
private String compilerName="jasper";
private String compilerName = "jasper";


/** /**
* -ieplugin <clsid>Java Plugin classid for Internet Explorer * -ieplugin <clsid>Java Plugin classid for Internet Explorer
@@ -127,7 +127,7 @@ public class JspC extends MatchingTask
private boolean mapped ; private boolean mapped ;
private int verbose = 0; private int verbose = 0;
protected Vector compileList = new Vector(); protected Vector compileList = new Vector();
Vector javaFiles=new Vector();
Vector javaFiles = new Vector();


/** /**
* flag to control action on execution trouble * flag to control action on execution trouble
@@ -336,7 +336,7 @@ public class JspC extends MatchingTask
public void addWebApp(WebAppParameter webappParam) public void addWebApp(WebAppParameter webappParam)
throws BuildException { throws BuildException {
//demand create vector of filesets //demand create vector of filesets
if(webApp == null) {
if (webApp == null) {
webApp = webappParam; webApp = webappParam;
} }
else { else {
@@ -352,7 +352,7 @@ public class JspC extends MatchingTask
* Sets the compiler to use. Optional: default=jasper * Sets the compiler to use. Optional: default=jasper
*/ */
public void setCompiler(String compiler) { public void setCompiler(String compiler) {
this.compilerName=compiler;
this.compilerName = compiler;
} }


/** /**
@@ -393,33 +393,33 @@ public class JspC extends MatchingTask
JspCompilerAdapterFactory.getCompiler(compilerName, this); JspCompilerAdapterFactory.getCompiler(compilerName, this);


// if the compiler does its own dependency stuff, we just call it right now // if the compiler does its own dependency stuff, we just call it right now
if(compiler.implementsOwnDependencyChecking()) {
if (compiler.implementsOwnDependencyChecking()) {
doCompilation(compiler); doCompilation(compiler);
return; return;
} }


//the remainder of this method is only for compilers that need their dependency work done //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 // scan source directories and dest directory to build up both copy
// lists and compile lists // lists and compile lists
resetFileLists(); resetFileLists();
int filecount=0;
int filecount = 0;
for (int i = 0; i < list.length; i++) { 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()) { if (!srcDir.exists()) {
throw new BuildException("srcdir \"" + srcDir.getPath() + throw new BuildException("srcdir \"" + srcDir.getPath() +
"\" does not exist!", location); "\" does not exist!", location);
} }
DirectoryScanner ds = this.getDirectoryScanner(srcDir); DirectoryScanner ds = this.getDirectoryScanner(srcDir);
String[] files = ds.getIncludedFiles(); String[] files = ds.getIncludedFiles();
filecount=files.length;
filecount = files.length;
scanDir(srcDir, dest, mangler, files); scanDir(srcDir, dest, mangler, files);
} }


// compile the source 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) { if (compileList.size() > 0) {


@@ -431,11 +431,11 @@ public class JspC extends MatchingTask


} }
else { 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 { 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) private void doCompilation(JspCompilerAdapter compiler)
throws BuildException { throws BuildException {
// now we need to populate the compiler adapter // now we need to populate the compiler adapter
compiler.setJspc( this );
compiler.setJspc(this);


// finally, lets execute the compiler!! // finally, lets execute the compiler!!
if (!compiler.execute()) { if (!compiler.execute()) {
@@ -493,17 +493,17 @@ public class JspC extends MatchingTask
long now = (new Date()).getTime(); long now = (new Date()).getTime();


for (int i = 0; i < files.length; i++) { for (int i = 0; i < files.length; i++) {
String filename=files[i];
String filename = files[i];
File srcFile = new File(srcDir, filename); File srcFile = new File(srcDir, filename);
File javaFile=mapToJavaFile(mangler,srcFile, srcDir, dest);
File javaFile = mapToJavaFile(mangler, srcFile, srcDir, dest);


if (srcFile.lastModified() > now) { 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()); compileList.addElement(srcFile.getAbsolutePath());
javaFiles.addElement(javaFile); javaFiles.addElement(javaFile);
} }
@@ -527,25 +527,25 @@ public class JspC extends MatchingTask
* *
*/ */
private boolean isCompileNeeded(File srcFile, File javaFile) { private boolean isCompileNeeded(File srcFile, File javaFile) {
boolean shouldCompile=false;
boolean shouldCompile = false;
if (!javaFile.exists()) { 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 { } 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); Project.MSG_VERBOSE);
} else { } 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")) { if (!srcFile.getName().endsWith(".jsp")) {
return null; return null;
} }
String javaFileName=mangler.mapJspToJavaName(srcFile);
String javaFileName = mangler.mapJspToJavaName(srcFile);
// String srcFileDir=srcFile.getParent(); // String srcFileDir=srcFile.getParent();
String packageNameIn=srcFile.getAbsolutePath();
String packageNameIn = srcFile.getAbsolutePath();
return new File(dest, javaFileName); return new File(dest, javaFileName);
} }


@@ -573,12 +573,12 @@ public class JspC extends MatchingTask
* fails, it leaves incomplete files around. * fails, it leaves incomplete files around.
*/ */
public void deleteEmptyJavaFiles() { public void deleteEmptyJavaFiles() {
if(javaFiles!=null) {
if (javaFiles != null) {
Enumeration enum = javaFiles.elements(); Enumeration enum = javaFiles.elements();
while (enum.hasMoreElements()) { 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(); file.delete();
} }
} }
@@ -607,7 +607,7 @@ public class JspC extends MatchingTask
* set directory; alternate syntax * set directory; alternate syntax
*/ */
public void setBaseDir(File directory) { public void setBaseDir(File directory) {
this.directory=directory;
this.directory = directory;
} }
//end inner class //end inner class
} }


+ 32
- 30
src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java View File

@@ -146,7 +146,8 @@ public class WLJspc extends MatchingTask
String systemClassPath = System.getProperty("java.class.path"); 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 // get all the files in the sourceDirectory
DirectoryScanner ds = super.getDirectoryScanner(sourceDirectory); DirectoryScanner ds = super.getDirectoryScanner(sourceDirectory);


@@ -162,7 +163,7 @@ public class WLJspc extends MatchingTask
// Therefore, takes loads of time // Therefore, takes loads of time
// Can pass directories at a time (*.jsp) but easily runs out of memory on hefty dirs // Can pass directories at a time (*.jsp) but easily runs out of memory on hefty dirs
// (even on a Sun) // (even on a Sun)
Java helperTask = (Java)project.createTask("java");
Java helperTask = (Java) project.createTask("java");
helperTask.setFork(true); helperTask.setFork(true);
helperTask.setClassname("weblogic.jspc"); helperTask.setClassname("weblogic.jspc");
helperTask.setTaskName(getTaskName()); helperTask.setTaskName(getTaskName());
@@ -171,7 +172,7 @@ public class WLJspc extends MatchingTask
File jspFile = null; File jspFile = null;
String parents = ""; String parents = "";
String arg = ""; String arg = "";
int j=0;
int j = 0;
//XXX this array stuff is a remnant of prev trials.. gotta remove. //XXX this array stuff is a remnant of prev trials.. gotta remove.
args[j++] = "-d"; args[j++] = "-d";
args[j++] = destinationDirectory.getAbsolutePath().trim(); args[j++] = destinationDirectory.getAbsolutePath().trim();
@@ -189,9 +190,9 @@ public class WLJspc extends MatchingTask
args[j++] = compileClasspath.toString(); args[j++] = compileClasspath.toString();
this.scanDir(files); 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 //XXX
// All this to get package according to weblogic standards // All this to get package according to weblogic standards
// Can be written better... this is too hacky! // Can be written better... this is too hacky!
@@ -200,18 +201,19 @@ public class WLJspc extends MatchingTask
args[j] = "-package"; args[j] = "-package";
parents = jspFile.getParent(); parents = jspFile.getParent();
if ((parents != null) && (!("").equals(parents))) { 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); System.out.println("arg = " + arg);
@@ -220,7 +222,7 @@ public class WLJspc extends MatchingTask
helperTask.setArgs(arg); helperTask.setArgs(arg);
helperTask.setClasspath(compileClasspath); helperTask.setClasspath(compileClasspath);
if (helperTask.executeJava() != 0) { 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) { 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! // Can be written better... this is too hacky!
jspFile = new File(files[i]); jspFile = new File(files[i]);
parents = jspFile.getParent(); parents = jspFile.getParent();
int loc=0;
int loc = 0;
if ((parents != null) && (!("").equals(parents))) { 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; pack = pathToPackage;
} }
@@ -324,22 +326,22 @@ public class WLJspc extends MatchingTask
if (srcFile.lastModified() > classFile.lastModified()) { if (srcFile.lastModified() > classFile.lastModified()) {
//log("Files are" + srcFile.getAbsolutePath()+" " +classFile.getAbsolutePath()); //log("Files are" + srcFile.getAbsolutePath()+" " +classFile.getAbsolutePath());
filesToDo.addElement(files[i]); 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; return localString;
} }


+ 6
- 6
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java View File

@@ -97,7 +97,7 @@ public abstract class DefaultJspCompilerAdapter


Enumeration enum = compileList.elements(); Enumeration enum = compileList.elements();
while (enum.hasMoreElements()) { while (enum.hasMoreElements()) {
String arg = (String)enum.nextElement();
String arg = (String) enum.nextElement();
cmd.createArgument().setValue(arg); cmd.createArgument().setValue(arg);
niceSourceList.append(" " + arg + lSep); niceSourceList.append(" " + arg + lSep);
} }
@@ -113,7 +113,7 @@ public abstract class DefaultJspCompilerAdapter
/** /**
* set the owner * set the owner
*/ */
public void setJspc( JspC owner ) {
public void setJspc(JspC owner) {
this.owner = owner; this.owner = owner;
} }


@@ -130,8 +130,8 @@ public abstract class DefaultJspCompilerAdapter
* *
* @param argument The argument * @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); cmd.createArgument().setValue(argument);
} }
} }
@@ -144,7 +144,7 @@ public abstract class DefaultJspCompilerAdapter
* @param value the parameter * @param value the parameter
*/ */
protected void addArg(Commandline cmd, String argument, String value) { protected void addArg(Commandline cmd, String argument, String value) {
if(value!= null) {
if (value != null) {
cmd.createArgument().setValue(argument); cmd.createArgument().setValue(argument);
cmd.createArgument().setValue(value); cmd.createArgument().setValue(value);
} }
@@ -157,7 +157,7 @@ public abstract class DefaultJspCompilerAdapter
* @param file the parameter * @param file the parameter
*/ */
protected void addArg(Commandline cmd, String argument, File file) { protected void addArg(Commandline cmd, String argument, File file) {
if(file != null) {
if (file != null) {
cmd.createArgument().setValue(argument); cmd.createArgument().setValue(argument);
cmd.createArgument().setFile(file); cmd.createArgument().setFile(file);
} }


+ 13
- 13
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java View File

@@ -87,7 +87,7 @@ public class JasperC extends DefaultJspCompilerAdapter
// Create an instance of the compiler, redirecting output to // Create an instance of the compiler, redirecting output to
// the project log // the project log
// REVISIT. ugly. // REVISIT. ugly.
Java java = (Java)(getJspc().getProject()).createTask("java");
Java java = (Java) (getJspc().getProject()).createTask("java");
if (getJspc().getClasspath() != null) { if (getJspc().getClasspath() != null) {
java.setClasspath(getJspc().getClasspath()); java.setClasspath(getJspc().getClasspath());
} }
@@ -96,7 +96,7 @@ public class JasperC extends DefaultJspCompilerAdapter
} }
java.setClassname("org.apache.jasper.JspC"); java.setClassname("org.apache.jasper.JspC");
String args[] = cmd.getArguments(); 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.createArg().setValue(args[i]);
} }
java.setFailonerror(getJspc().getFailonerror()); java.setFailonerror(getJspc().getFailonerror());
@@ -129,20 +129,20 @@ public class JasperC extends DefaultJspCompilerAdapter
private Commandline setupJasperCommand() { private Commandline setupJasperCommand() {
Commandline cmd = new Commandline(); Commandline cmd = new Commandline();
JspC jspc = getJspc(); 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()){ 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); logAndAddFilesToCompile(getJspc(), getJspc().getCompileList(), cmd);
return cmd; return cmd;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapter.java View File

@@ -76,7 +76,7 @@ public interface JspCompilerAdapter {
/** /**
* Sets the compiler attributes, which are stored in the Jspc task. * Sets the compiler attributes, which are stored in the Jspc task.
*/ */
void setJspc( JspC attributes );
void setJspc(JspC attributes);


/** /**
* Executes the task. * Executes the task.


+ 9
- 9
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java View File

@@ -85,15 +85,15 @@ public class JspCompilerAdapterFactory {
* @throws BuildException if the compiler type could not be resolved into * @throws BuildException if the compiler type could not be resolved into
* a compiler adapter. * a compiler adapter.
*/ */
public static JspCompilerAdapter getCompiler( String compilerType, Task task )
public static JspCompilerAdapter getCompiler(String compilerType, Task task)
throws BuildException { throws BuildException {
/* If I've done things right, this should be the extent of the /* If I've done things right, this should be the extent of the
* conditional statements required. * conditional statements required.
*/ */
if ( compilerType.equalsIgnoreCase("jasper") ) {
if (compilerType.equalsIgnoreCase("jasper")) {
return new JasperC(); 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 * @throws BuildException This is the fit that is thrown if className
* isn't an instance of JspCompilerAdapter. * isn't an instance of JspCompilerAdapter.
*/ */
private static JspCompilerAdapter resolveClassName( String className )
private static JspCompilerAdapter resolveClassName(String className)
throws BuildException { throws BuildException {
try { try {
Class c = Class.forName( className );
Class c = Class.forName(className);
Object o = c.newInstance(); Object o = c.newInstance();
return (JspCompilerAdapter) o; 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 " throw new BuildException(className + " isn\'t the classname of "
+ "a compiler adapter.", cce); + "a compiler adapter.", cce);
} catch ( Throwable t ) {
} catch (Throwable t) {
// for all other possibilities // for all other possibilities
throw new BuildException(className + " caused an interesting " throw new BuildException(className + " caused an interesting "
+ "exception.", t); + "exception.", t);


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java View File

@@ -199,7 +199,7 @@ public class AggregateTransformer {
// set the destination directory relative from the project if needed. // set the destination directory relative from the project if needed.
if (toDir == null) { if (toDir == null) {
toDir = task.getProject().resolveFile("."); toDir = task.getProject().resolveFile(".");
} else if ( !toDir.isAbsolute() ) {
} else if (!toDir.isAbsolute()) {
toDir = task.getProject().resolveFile(toDir.getPath()); toDir = task.getProject().resolveFile(toDir.getPath());
} }
} }


+ 6
- 6
src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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){ final void addTestsTo(Vector v){
JUnitTest[] tests = createAllJUnitTest(); JUnitTest[] tests = createAllJUnitTest();
v.ensureCapacity( v.size() + tests.length);
v.ensureCapacity(v.size() + tests.length);
for (int i = 0; i < tests.length; i++) { for (int i = 0; i < tests.length; i++) {
v.addElement(tests[i]); v.addElement(tests[i]);
} }
@@ -156,7 +156,7 @@ public final class BatchTest extends BaseTest {
private String[] getFilenames(){ private String[] getFilenames(){
Vector v = new Vector(); Vector v = new Vector();
final int size = this.filesets.size(); 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); FileSet fs = (FileSet) filesets.elementAt(j);
DirectoryScanner ds = fs.getDirectoryScanner(project); DirectoryScanner ds = fs.getDirectoryScanner(project);
ds.scan(); ds.scan();
@@ -164,9 +164,9 @@ public final class BatchTest extends BaseTest {
for (int k = 0; k < f.length; k++) { for (int k = 0; k < f.length; k++) {
String pathname = f[k]; String pathname = f[k];
if (pathname.endsWith(".java")) { 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")) { } 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); test.setErrorProperty(errorProperty);
Enumeration list = this.formatters.elements(); Enumeration list = this.formatters.elements();
while (list.hasMoreElements()) { while (list.hasMoreElements()) {
test.addFormatter((FormatterElement)list.nextElement());
test.addFormatter((FormatterElement) list.nextElement());
} }
return test; return test;
} }


+ 9
- 9
src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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); NodeList recmatches = listChildNodes(child, filter, recurse);
final int reclength = matches.getLength(); final int reclength = matches.getLength();
for (int j = 0; j < reclength; j++) { 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){ public Node item(int i){
try { try {
return (Node)elementAt(i);
return (Node) elementAt(i);
} catch (ArrayIndexOutOfBoundsException e){ } catch (ArrayIndexOutOfBoundsException e){
return null; // conforming to NodeList interface return null; // conforming to NodeList interface
} }
@@ -145,7 +145,7 @@ public final class DOMUtil {
*/ */
public static String getNodeAttribute(Node node, String name) { public static String getNodeAttribute(Node node, String name) {
if (node instanceof Element) { if (node instanceof Element) {
Element element = (Element)node;
Element element = (Element) node;
return element.getAttribute(name); return element.getAttribute(name);
} }
return null; return null;
@@ -169,9 +169,9 @@ public final class DOMUtil {
final int len = childList.getLength(); final int len = childList.getLength();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
Node child = childList.item(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)) { child.getNodeName().equals(tagname)) {
return (Element)child;
return (Element) child;
} }
} }
return null; return null;
@@ -204,10 +204,10 @@ public final class DOMUtil {
copy = doc.createDocumentFragment(); copy = doc.createDocumentFragment();
break; break;
case Node.ELEMENT_NODE: case Node.ELEMENT_NODE:
final Element elem = doc.createElement(((Element)child).getTagName());
final Element elem = doc.createElement(((Element) child).getTagName());
copy = elem; copy = elem;
final NamedNodeMap attributes = child.getAttributes(); final NamedNodeMap attributes = child.getAttributes();
if ( attributes != null) {
if (attributes != null) {
final int size = attributes.getLength(); final int size = attributes.getLength();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
final Attr attr = (Attr) attributes.item(i); final Attr attr = (Attr) attributes.item(i);
@@ -219,7 +219,7 @@ public final class DOMUtil {
copy = doc.createEntityReference(child.getNodeName()); copy = doc.createEntityReference(child.getNodeName());
break; break;
case Node.PROCESSING_INSTRUCTION_NODE: case Node.PROCESSING_INSTRUCTION_NODE:
final ProcessingInstruction pi = (ProcessingInstruction)child;
final ProcessingInstruction pi = (ProcessingInstruction) child;
copy = doc.createProcessingInstruction(pi.getTarget(), pi.getData()); copy = doc.createProcessingInstruction(pi.getTarget(), pi.getData());
break; break;
case Node.TEXT_NODE: case Node.TEXT_NODE:


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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. * @throws NoSuchElementException if no more elements exist.
*/ */
public Object nextElement() throws NoSuchElementException { public Object nextElement() throws NoSuchElementException {
if ( hasMoreElements() ) {
if (hasMoreElements()) {
return enumArray[index].nextElement(); return enumArray[index].nextElement();
} }
throw new NoSuchElementException(); throw new NoSuchElementException();


+ 3
- 2
src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -195,7 +195,8 @@ public class FormatterElement {
} }


if (!(o instanceof JUnitResultFormatter)) { if (!(o instanceof JUnitResultFormatter)) {
throw new BuildException(classname+" is not a JUnitResultFormatter");
throw new BuildException(classname
+ " is not a JUnitResultFormatter");
} }


JUnitResultFormatter r = (JUnitResultFormatter) o; JUnitResultFormatter r = (JUnitResultFormatter) o;


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitResultFormatter.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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. * 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 * 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 * This is what the test has written to System.err
*/ */
void setSystemError( String err );
void setSystemError(String err);
} }

+ 26
- 27
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -499,8 +499,8 @@ public class JUnitTask extends Task {
public void execute() throws BuildException { public void execute() throws BuildException {
Enumeration list = getIndividualTests(); Enumeration list = getIndividualTests();
while (list.hasMoreElements()) { while (list.hasMoreElements()) {
JUnitTest test = (JUnitTest)list.nextElement();
if ( test.shouldRun(project)) {
JUnitTest test = (JUnitTest) list.nextElement();
if (test.shouldRun(project)) {
execute(test); execute(test);
} }
} }
@@ -518,7 +518,7 @@ public class JUnitTask extends Task {
} }


if (test.getOutfile() == null) { if (test.getOutfile() == null) {
test.setOutfile( "TEST-" + test.getName() );
test.setOutfile("TEST-" + test.getName());
} }


// execute the test and get the return code // execute the test and get the return code
@@ -542,11 +542,10 @@ public class JUnitTask extends Task {
if (errorOccurredHere || failureOccurredHere) { if (errorOccurredHere || failureOccurredHere) {
if ((errorOccurredHere && test.getHaltonerror()) if ((errorOccurredHere && test.getHaltonerror())
|| (failureOccurredHere && test.getHaltonfailure())) { || (failureOccurredHere && test.getHaltonfailure())) {
throw new BuildException("Test "+test.getName()+" failed"
+(wasKilled ? " (timeout)" : ""),
location);
throw new BuildException("Test " + test.getName() + " failed"
+ (wasKilled ? " (timeout)" : ""), location);
} else { } else {
log("TEST "+test.getName()+" FAILED"
log("TEST " + test.getName() + " FAILED"
+ (wasKilled ? " (timeout)" : ""), Project.MSG_ERR); + (wasKilled ? " (timeout)" : ""), Project.MSG_ERR);
if (errorOccurredHere && test.getErrorProperty() != null) { if (errorOccurredHere && test.getErrorProperty() != null) {
project.setNewProperty(test.getErrorProperty(), "true"); project.setNewProperty(test.getErrorProperty(), "true");
@@ -579,7 +578,7 @@ public class JUnitTask extends Task {
cmd.createArgument().setValue("haltOnFailure=" cmd.createArgument().setValue("haltOnFailure="
+ test.getHaltonfailure()); + test.getHaltonfailure());
if (includeAntRuntime) { if (includeAntRuntime) {
log("Implicitly adding "+antRuntimeClasses+" to CLASSPATH",
log("Implicitly adding " + antRuntimeClasses + " to CLASSPATH",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
cmd.createClasspath(getProject()).createPath() cmd.createClasspath(getProject()).createPath()
.append(antRuntimeClasses); .append(antRuntimeClasses);
@@ -597,10 +596,10 @@ public class JUnitTask extends Task {
FormatterElement fe = feArray[i]; FormatterElement fe = feArray[i];
formatterArg.append("formatter="); formatterArg.append("formatter=");
formatterArg.append(fe.getClassname()); formatterArg.append(fe.getClassname());
File outFile = getOutput(fe,test);
File outFile = getOutput(fe, test);
if (outFile != null) { if (outFile != null) {
formatterArg.append(","); formatterArg.append(",");
formatterArg.append( outFile );
formatterArg.append(outFile);
} }
cmd.createArgument().setValue(formatterArg.toString()); cmd.createArgument().setValue(formatterArg.toString());
formatterArg.setLength(0); formatterArg.setLength(0);
@@ -615,13 +614,13 @@ public class JUnitTask extends Task {
+ propsFile.getAbsolutePath()); + propsFile.getAbsolutePath());
Hashtable p = project.getProperties(); Hashtable p = project.getProperties();
Properties props = new Properties(); Properties props = new Properties();
for (Enumeration enum = p.keys(); enum.hasMoreElements(); ) {
for (Enumeration enum = p.keys(); enum.hasMoreElements();) {
Object key = enum.nextElement(); Object key = enum.nextElement();
props.put(key, p.get(key)); props.put(key, p.get(key));
} }
try { try {
FileOutputStream outstream = new FileOutputStream(propsFile); FileOutputStream outstream = new FileOutputStream(propsFile);
props.save(outstream,"Ant JUnitTask generated properties file");
props.save(outstream, "Ant JUnitTask generated properties file");
outstream.close(); outstream.close();
} catch (java.io.IOException e) { } catch (java.io.IOException e) {
propsFile.delete(); propsFile.delete();
@@ -641,15 +640,15 @@ public class JUnitTask extends Task {


String[] environment = env.getVariables(); String[] environment = env.getVariables();
if (environment != null) { 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); Project.MSG_VERBOSE);
} }
} }
execute.setNewenvironment(newEnvironment); execute.setNewenvironment(newEnvironment);
execute.setEnvironment(environment); execute.setEnvironment(environment);


log("Executing: "+cmd.toString(), Project.MSG_VERBOSE);
log("Executing: " + cmd.toString(), Project.MSG_VERBOSE);
int retVal; int retVal;
try { try {
retVal = execute.execute(); retVal = execute.execute();
@@ -725,7 +724,7 @@ public class JUnitTask extends Task {
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
Path classpath = (Path) commandline.getClasspath().clone(); Path classpath = (Path) commandline.getClasspath().clone();
if (includeAntRuntime) { if (includeAntRuntime) {
log("Implicitly adding "+antRuntimeClasses+" to CLASSPATH",
log("Implicitly adding " + antRuntimeClasses + " to CLASSPATH",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
classpath.append(antRuntimeClasses); classpath.append(antRuntimeClasses);
} }
@@ -750,19 +749,19 @@ public class JUnitTask extends Task {
SummaryJUnitResultFormatter f = SummaryJUnitResultFormatter f =
new SummaryJUnitResultFormatter(); new SummaryJUnitResultFormatter();
f.setWithOutAndErr("withoutanderr" f.setWithOutAndErr("withoutanderr"
.equalsIgnoreCase( summaryValue ));
f.setOutput( getDefaultOutput() );
.equalsIgnoreCase(summaryValue));
f.setOutput(getDefaultOutput());
runner.addFormatter(f); runner.addFormatter(f);
} }


final FormatterElement[] feArray = mergeFormatters(test); final FormatterElement[] feArray = mergeFormatters(test);
for (int i = 0; i < feArray.length; i++) { for (int i = 0; i < feArray.length; i++) {
FormatterElement fe = feArray[i]; FormatterElement fe = feArray[i];
File outFile = getOutput(fe,test);
File outFile = getOutput(fe, test);
if (outFile != null) { if (outFile != null) {
fe.setOutfile(outFile); fe.setOutfile(outFile);
} else { } else {
fe.setOutput( getDefaultOutput() );
fe.setOutput(getDefaultOutput());
} }
runner.addFormatter(fe.createFormatter()); runner.addFormatter(fe.createFormatter());
} }
@@ -809,7 +808,7 @@ public class JUnitTask extends Task {
final int count = batchTests.size(); final int count = batchTests.size();
final Enumeration[] enums = new Enumeration[ count + 1]; final Enumeration[] enums = new Enumeration[ count + 1];
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
BatchTest batchtest = (BatchTest)batchTests.elementAt(i);
BatchTest batchtest = (BatchTest) batchTests.elementAt(i);
enums[i] = batchtest.elements(); enums[i] = batchtest.elements();
} }
enums[enums.length - 1] = tests.elements(); enums[enums.length - 1] = tests.elements();
@@ -828,7 +827,7 @@ public class JUnitTask extends Task {
* @since Ant 1.3 * @since Ant 1.3
*/ */
private FormatterElement[] mergeFormatters(JUnitTest test){ private FormatterElement[] mergeFormatters(JUnitTest test){
Vector feVector = (Vector)formatters.clone();
Vector feVector = (Vector) formatters.clone();
test.addFormattersTo(feVector); test.addFormattersTo(feVector);
FormatterElement[] feArray = new FormatterElement[feVector.size()]; FormatterElement[] feArray = new FormatterElement[feVector.size()];
feVector.copyInto(feArray); feVector.copyInto(feArray);
@@ -844,7 +843,7 @@ public class JUnitTask extends Task {
protected File getOutput(FormatterElement fe, JUnitTest test){ protected File getOutput(FormatterElement fe, JUnitTest test){
if (fe.getUseFile()) { if (fe.getUseFile()) {
String filename = test.getOutfile() + fe.getExtension(); String filename = test.getOutfile() + fe.getExtension();
File destFile = new File( test.getTodir(), filename );
File destFile = new File(test.getTodir(), filename);
String absFilename = destFile.getAbsolutePath(); String absFilename = destFile.getAbsolutePath();
return project.resolveFile(absFilename); return project.resolveFile(absFilename);
} }
@@ -867,23 +866,23 @@ public class JUnitTask extends Task {
if (u.startsWith("jar:file:")) { if (u.startsWith("jar:file:")) {
int pling = u.indexOf("!"); int pling = u.indexOf("!");
String jarName = u.substring(9, pling); String jarName = u.substring(9, pling);
log("Found "+jarName, Project.MSG_DEBUG);
log("Found " + jarName, Project.MSG_DEBUG);
antRuntimeClasses.createPath() antRuntimeClasses.createPath()
.setLocation(new File((new File(jarName)) .setLocation(new File((new File(jarName))
.getAbsolutePath())); .getAbsolutePath()));
} else if (u.startsWith("file:")) { } else if (u.startsWith("file:")) {
int tail = u.indexOf(resource); int tail = u.indexOf(resource);
String dirName = u.substring(5, tail); String dirName = u.substring(5, tail);
log("Found "+dirName, Project.MSG_DEBUG);
log("Found " + dirName, Project.MSG_DEBUG);
antRuntimeClasses.createPath() antRuntimeClasses.createPath()
.setLocation(new File((new File(dirName)) .setLocation(new File((new File(dirName))
.getAbsolutePath())); .getAbsolutePath()));
} else { } else {
log("Don\'t know how to handle resource URL "+u,
log("Don\'t know how to handle resource URL " + u,
Project.MSG_DEBUG); Project.MSG_DEBUG);
} }
} else { } else {
log("Couldn\'t find "+resource, Project.MSG_DEBUG);
log("Couldn\'t find " + resource, Project.MSG_DEBUG);
} }
} }




+ 21
- 7
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java View File

@@ -148,15 +148,29 @@ public class JUnitTest extends BaseTest implements Cloneable {
this.runTime = runTime; 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) { public void setProperties(Hashtable p) {
props = new Properties(); props = new Properties();
for (Enumeration enum = p.keys(); enum.hasMoreElements(); ) {
for (Enumeration enum = p.keys(); enum.hasMoreElements();) {
Object key = enum.nextElement(); Object key = enum.nextElement();
props.put(key, p.get(key)); props.put(key, p.get(key));
} }
@@ -185,7 +199,7 @@ public class JUnitTest extends BaseTest implements Cloneable {
void addFormattersTo(Vector v){ void addFormattersTo(Vector v){
final int count = formatters.size(); final int count = formatters.size();
for (int i = 0; i < count; i++){ for (int i = 0; i < count; i++){
v.addElement( formatters.elementAt(i) );
v.addElement(formatters.elementAt(i));
} }
} }




+ 19
- 19
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java View File

@@ -214,8 +214,8 @@ public class JUnitTestRunner implements TestListener {
Method suiteMethod = null; Method suiteMethod = null;
try { try {
// check if there is a suite method // 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 // no appropriate suite method found. We don't report any
// error here since it might be perfectly normal. We don't // error here since it might be perfectly normal. We don't
// know exactly what is the cause, but we're doing exactly // 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 // if there is a suite method available, then try
// to extract the suite from it. If there is an error // to extract the suite from it. If there is an error
// here it will be caught below and reported. // 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 { } else {
// try to extract a test suite automatically // try to extract a test suite automatically
// this will generate warnings if the class is no suitable Test // 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; retCode = ERRORS;
exception = e; exception = e;
} }
@@ -241,16 +241,16 @@ public class JUnitTestRunner implements TestListener {
public void run() { public void run() {
res = new TestResult(); res = new TestResult();
res.addListener(this); 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(); long start = System.currentTimeMillis();


fireStartTestSuite(); fireStartTestSuite();
if (exception != null) { // had an exception in the constructor 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); exception);
} }
junitTest.setCounts(1, 0, 1); junitTest.setCounts(1, 0, 1);
@@ -373,9 +373,9 @@ public class JUnitTestRunner implements TestListener {
} }
private void sendOutAndErr(String out, String err) { 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 formatter =
((JUnitResultFormatter)formatters.elementAt(i));
((JUnitResultFormatter) formatters.elementAt(i));
formatter.setSystemOutput(out); formatter.setSystemOutput(out);
formatter.setSystemError(err); formatter.setSystemError(err);
@@ -383,14 +383,14 @@ public class JUnitTestRunner implements TestListener {
} }


private void fireStartTestSuite() { 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() { 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); System.exit(ERRORS);
} }


for (int i=1; i<args.length; i++) {
for (int i = 1; i < args.length; i++) {
if (args[i].startsWith("haltOnError=")) { if (args[i].startsWith("haltOnError=")) {
haltError = Project.toBoolean(args[i].substring(12)); haltError = Project.toBoolean(args[i].substring(12));
} else if (args[i].startsWith("haltOnFailure=")) { } 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 // Add/overlay system properties on the properties from the Ant project
Hashtable p = System.getProperties(); Hashtable p = System.getProperties();
for (Enumeration enum = p.keys(); enum.hasMoreElements(); ) {
for (Enumeration enum = p.keys(); enum.hasMoreElements();) {
Object key = enum.nextElement(); Object key = enum.nextElement();
props.put(key, p.get(key)); props.put(key, p.get(key));
} }
@@ -472,7 +472,7 @@ public class JUnitTestRunner implements TestListener {
private static Vector fromCmdLine = new Vector(); private static Vector fromCmdLine = new Vector();


private static void transferFormatters(JUnitTestRunner runner) { 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)); runner.addFormatter((JUnitResultFormatter) fromCmdLine.elementAt(i));
} }
} }
@@ -488,7 +488,7 @@ public class JUnitTestRunner implements TestListener {
fe.setClassname(line); fe.setClassname(line);
} else { } else {
fe.setClassname(line.substring(0, pos)); 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()); fromCmdLine.addElement(fe.createFormatter());
} }


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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(", Errors: ");
sb.append(suite.errorCount()); sb.append(suite.errorCount());
sb.append(", Time elapsed: "); 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(" sec");
sb.append(newLine); sb.append(newLine);
// append the err and output streams to the log // append the err and output streams to the log
if (systemOutput != null && systemOutput.length() > 0) { if (systemOutput != null && systemOutput.length() > 0) {
sb.append("------------- Standard Output ---------------" )
sb.append("------------- Standard Output ---------------")
.append(newLine) .append(newLine)
.append(systemOutput) .append(systemOutput)
.append("------------- ---------------- ---------------" )
.append("------------- ---------------- ---------------")
.append(newLine); .append(newLine);
} }
if (systemError != null && systemError.length() > 0) { if (systemError != null && systemError.length() > 0) {
sb.append("------------- Standard Error -----------------" )
sb.append("------------- Standard Error -----------------")
.append(newLine) .append(newLine)
.append(systemError) .append(systemError)
.append("------------- ---------------- ---------------" )
.append("------------- ---------------- ---------------")
.append(newLine); .append(newLine);
} }


@@ -206,7 +206,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter {
} }
Long l = (Long) testStarts.get(test); Long l = (Long) testStarts.get(test);
wri.println(" took " wri.println(" took "
+ nf.format((System.currentTimeMillis()-l.longValue())
+ nf.format((System.currentTimeMillis() - l.longValue())
/ 1000.0) / 1000.0)
+ " sec"); + " sec");
} }


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -120,11 +120,11 @@ public class SummaryJUnitResultFormatter implements JUnitResultFormatter {
this.out = out; this.out = out;
} }


public void setSystemOutput( String out ) {
public void setSystemOutput(String out) {
systemOutput = out; systemOutput = out;
} }


public void setSystemError( String err ) {
public void setSystemError(String err) {
systemError = err; systemError = err;
} }


@@ -132,7 +132,7 @@ public class SummaryJUnitResultFormatter implements JUnitResultFormatter {
* Should the output to System.out and System.err be written to * Should the output to System.out and System.err be written to
* the summary. * the summary.
*/ */
public void setWithOutAndErr( boolean value ) {
public void setWithOutAndErr(boolean value) {
withOutAndErr = value; withOutAndErr = value;
} }


@@ -148,18 +148,18 @@ public class SummaryJUnitResultFormatter implements JUnitResultFormatter {
sb.append(", Errors: "); sb.append(", Errors: ");
sb.append(suite.errorCount()); sb.append(suite.errorCount());
sb.append(", Time elapsed: "); 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(" sec");
sb.append(newLine); sb.append(newLine);


if (withOutAndErr) { if (withOutAndErr) {
if (systemOutput != null && systemOutput.length() > 0) { if (systemOutput != null && systemOutput.length() > 0) {
sb.append( "Output:" ).append(newLine).append(systemOutput)
sb.append("Output:").append(newLine).append(systemOutput)
.append(newLine); .append(newLine);
} }
if (systemError != null && systemError.length() > 0) { if (systemError != null && systemError.length() > 0) {
sb.append( "Error: " ).append(newLine).append(systemError)
sb.append("Error: ").append(newLine).append(systemError)
.append(newLine); .append(newLine);
} }
} }


+ 8
- 9
src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -92,7 +92,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan
try { try {
return DocumentBuilderFactory.newInstance().newDocumentBuilder(); return DocumentBuilderFactory.newInstance().newDocumentBuilder();
} }
catch(Exception exc) {
catch (Exception exc) {
throw new ExceptionInInitializerError(exc); throw new ExceptionInInitializerError(exc);
} }
} }
@@ -160,10 +160,10 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan
* The whole testsuite ended. * The whole testsuite ended.
*/ */
public void endTestSuite(JUnitTest suite) throws BuildException { 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) { if (out != null) {
Writer wri = null; Writer wri = null;
try { try {
@@ -171,7 +171,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan
wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
(new DOMElementWriter()).write(rootElement, wri, 0, " "); (new DOMElementWriter()).write(rootElement, wri, 0, " ");
wri.flush(); wri.flush();
} catch(IOException exc) {
} catch (IOException exc) {
throw new BuildException("Unable to write log file", exc); throw new BuildException("Unable to write log file", exc);
} finally { } finally {
if (out != System.out && out != System.err) { if (out != System.out && out != System.err) {
@@ -218,8 +218,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan
Long l = (Long) testStarts.get(test); Long l = (Long) testStarts.get(test);
currentTest.setAttribute(ATTR_TIME, currentTest.setAttribute(ATTR_TIME,
""+((System.currentTimeMillis()-l.longValue())
/ 1000.0));
"" + ((System.currentTimeMillis() - l.longValue()) / 1000.0));
} }


/** /**


+ 9
- 8
src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java View File

@@ -160,7 +160,7 @@ public class XMLResultAggregator extends Task implements XMLConstants {
File destFile = getDestinationFile(); File destFile = getDestinationFile();
// write the document // write the document
try { try {
writeDOMTree(rootElement.getOwnerDocument(), destFile );
writeDOMTree(rootElement.getOwnerDocument(), destFile);
} catch (IOException e){ } catch (IOException e){
throw new BuildException("Unable to write test aggregate to '" + destFile + "'", 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(); String[] f = ds.getIncludedFiles();
for (int j = 0; j < f.length; j++) { for (int j = 0; j < f.length; j++) {
String pathname = f[j]; String pathname = f[j];
if ( pathname.endsWith(".xml") ) {
if (pathname.endsWith(".xml")) {
File file = new File(ds.getBasedir(), pathname); File file = new File(ds.getBasedir(), pathname);
file = project.resolveFile(file.getPath()); 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; OutputStream out = null;
PrintWriter wri = null; PrintWriter wri = null;
try { try {
out = new FileOutputStream( file );
out = new FileOutputStream(file);
wri = new PrintWriter(new OutputStreamWriter(out, "UTF8")); wri = new PrintWriter(new OutputStreamWriter(out, "UTF8"));
wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
(new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " "); (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 //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 // will investigate later. It does not use the given directory but
// the vm dir instead ? Works fine with crimson. // 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(); Element elem = testsuiteDoc.getDocumentElement();
// make sure that this is REALLY a testsuite. // make sure that this is REALLY a testsuite.
if ( TESTSUITE.equals(elem.getNodeName()) ) {
if (TESTSUITE.equals(elem.getNodeName())) {
addTestSuite(rootElement, elem); addTestSuite(rootElement, elem);
} else { } else {
// issue a warning. // 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. // a missing . might imply no package at all. Don't get fooled.
String pkgName = (pos == -1) ? "" : fullclassname.substring(0, pos); String pkgName = (pos == -1) ? "" : fullclassname.substring(0, pos);
String classname = (pos == -1) ? fullclassname : fullclassname.substring(pos + 1); 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 // modify the name attribute and set the package
copy.setAttribute(ATTR_NAME, classname); copy.setAttribute(ATTR_NAME, classname);
@@ -326,7 +327,7 @@ public class XMLResultAggregator extends Task implements XMLConstants {
private static DocumentBuilder getDocumentBuilder() { private static DocumentBuilder getDocumentBuilder() {
try { try {
return DocumentBuilderFactory.newInstance().newDocumentBuilder(); return DocumentBuilderFactory.newInstance().newDocumentBuilder();
} catch(Exception exc) {
} catch (Exception exc) {
throw new ExceptionInInitializerError(exc); throw new ExceptionInInitializerError(exc);
} }
} }


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan1Executor.java View File

@@ -78,7 +78,7 @@ public class Xalan1Executor extends XalanExecutor {
OutputStream os = getOutputStream(); OutputStream os = getOutputStream();
try { try {
XSLTResultTarget target = new XSLTResultTarget(os); XSLTResultTarget target = new XSLTResultTarget(os);
processor.process( xml_src, xsl_src, target);
processor.process(xml_src, xsl_src, target);
} finally { } finally {
os.close(); os.close();
} }


+ 8
- 6
src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java View File

@@ -190,7 +190,7 @@ public class MParse extends Task {


// set the metamata.home property // set the metamata.home property
final Commandline.Argument vmArgs = cmdl.createVmArgument(); 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 // 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(){ protected File[] getMetamataLibs(){
Vector files = new Vector(); 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() ]; File[] array = new File[ files.size() ];
files.copyInto(array); files.copyInto(array);
@@ -278,12 +278,14 @@ public class MParse extends Task {
File[] jars = getMetamataLibs(); File[] jars = getMetamataLibs();
for (int i = 0; i < jars.length; i++){ for (int i = 0; i < jars.length; i++){
if (!jars[i].exists()){ 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. // 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); throw new BuildException("Invalid target: " + target);
} }
target = project.resolveFile(target.getPath()); target = project.resolveFile(target.getPath());
@@ -332,7 +334,7 @@ public class MParse extends Task {
fw = new FileWriter(tofile); fw = new FileWriter(tofile);
PrintWriter pw = new PrintWriter(fw); PrintWriter pw = new PrintWriter(fw);
for (int i = 0; i < options.length; i++){ for (int i = 0; i < options.length; i++){
pw.println( options[i] );
pw.println(options[i]);
} }
pw.flush(); pw.flush();
} catch (IOException e){ } catch (IOException e){


+ 329
- 368
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
File diff suppressed because it is too large
View File


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java View File

@@ -79,7 +79,8 @@ public class MimeMail extends EmailTask
public void execute() public void execute()
throws BuildException 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(); super.execute();
} }
} }

+ 13
- 13
src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java View File

@@ -82,7 +82,7 @@ public class TelnetTask extends Task {
/** /**
* The password to login with, if automated login is used * The password to login with, if automated login is used
*/ */
private String password= null;
private String password = null;


/** /**
* The server to connect to. * The server to connect to.
@@ -123,7 +123,7 @@ public class TelnetTask extends Task {
public void execute() throws BuildException public void execute() throws BuildException
{ {
/** A server name is required to continue */ /** A server name is required to continue */
if (server== null) {
if (server == null) {
throw new BuildException("No Server Specified"); throw new BuildException("No Server Specified");
} }
/** A userid and password must appear together /** A userid and password must appear together
@@ -140,8 +140,8 @@ public class TelnetTask extends Task {
telnet = new AntTelnetClient(); telnet = new AntTelnetClient();
try { try {
telnet.connect(server, port); 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 */ /** Login if userid and password were specified */
if (userid != null && password != null) { if (userid != null && password != null) {
@@ -149,11 +149,11 @@ public class TelnetTask extends Task {
} }
/** Process each sub command */ /** Process each sub command */
Enumeration tasksToRun = telnetTasks.elements(); Enumeration tasksToRun = telnetTasks.elements();
while (tasksToRun!=null && tasksToRun.hasMoreElements())
while (tasksToRun != null && tasksToRun.hasMoreElements())
{ {
TelnetSubTask task = (TelnetSubTask) tasksToRun.nextElement(); TelnetSubTask task = (TelnetSubTask) tasksToRun.nextElement();
if (task instanceof TelnetRead && defaultTimeout != null) { if (task instanceof TelnetRead && defaultTimeout != null) {
((TelnetRead)task).setDefaultTimeout(defaultTimeout);
((TelnetRead) task).setDefaultTimeout(defaultTimeout);
} }
task.execute(telnet); task.execute(telnet);
} }
@@ -218,7 +218,7 @@ public class TelnetTask extends Task {
public TelnetSubTask createRead() public TelnetSubTask createRead()
{ {
TelnetSubTask task = (TelnetSubTask)new TelnetRead();
TelnetSubTask task = (TelnetSubTask) new TelnetRead();
telnetTasks.addElement(task); telnetTasks.addElement(task);
return task; return task;
} }
@@ -229,7 +229,7 @@ public class TelnetTask extends Task {
*/ */
public TelnetSubTask createWrite() public TelnetSubTask createWrite()
{ {
TelnetSubTask task = (TelnetSubTask)new TelnetWrite();
TelnetSubTask task = (TelnetSubTask) new TelnetWrite();
telnetTasks.addElement(task); telnetTasks.addElement(task);
return task; return task;
} }
@@ -240,7 +240,7 @@ public class TelnetTask extends Task {
*/ */
public class TelnetSubTask public class TelnetSubTask
{ {
protected String taskString= "";
protected String taskString = "";
public void execute(AntTelnetClient telnet) public void execute(AntTelnetClient telnet)
throws BuildException throws BuildException
{ {
@@ -331,7 +331,7 @@ public class TelnetTask extends Task {
*/ */
public void waitForString(String s, Integer timeout) public void waitForString(String s, Integer timeout)
{ {
InputStream is =this.getInputStream();
InputStream is = this.getInputStream();
try { try {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if (timeout == null || timeout.intValue() == 0) if (timeout == null || timeout.intValue() == 0)
@@ -344,8 +344,8 @@ public class TelnetTask extends Task {
else else
{ {
Calendar endTime = Calendar.getInstance(); 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) && while (Calendar.getInstance().before(endTime) &&
is.available() == 0) { is.available() == 0) {
@@ -374,7 +374,7 @@ public class TelnetTask extends Task {
*/ */
public void sendString(String s, boolean echoString) public void sendString(String s, boolean echoString)
{ {
OutputStream os =this.getOutputStream();
OutputStream os = this.getOutputStream();
try { try {
os.write((s + "\n").getBytes()); os.write((s + "\n").getBytes());
if (echoString) { if (echoString) {


+ 1
- 3
src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Submit.java View File

@@ -90,9 +90,7 @@ public class P4Submit extends P4Base {
public void process(String line) { public void process(String line) {
log(line, Project.MSG_VERBOSE); log(line, Project.MSG_VERBOSE);
} }
}
);

});
} else { } else {
//here we'd parse the output from change -o into submit -i //here we'd parse the output from change -o into submit -i
//in order to support default change. //in order to support default change.


+ 79
- 62
src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java View File

@@ -133,15 +133,16 @@ public class Pvcs extends org.apache.tools.ant.Task {
return exe.execute(); return exe.execute();
} }
catch (java.io.IOException e) { 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); throw new BuildException(msg, location);
} }
} }


private String getExecutable(String exe) { private String getExecutable(String exe) {
StringBuffer correctedExe = new StringBuffer(); StringBuffer correctedExe = new StringBuffer();
if(getPvcsbin()!=null) {
if(pvcsbin.endsWith(File.separator)) {
if (getPvcsbin() != null) {
if (pvcsbin.endsWith(File.separator)) {
correctedExe.append(pvcsbin); correctedExe.append(pvcsbin);
} else { } else {
correctedExe.append(pvcsbin).append(File.separator); correctedExe.append(pvcsbin).append(File.separator);
@@ -157,7 +158,7 @@ public class Pvcs extends org.apache.tools.ant.Task {
Project aProj = getProject(); Project aProj = getProject();
int result = 0; int result = 0;


if(repository == null || repository.trim().equals("")) {
if (repository == null || repository.trim().equals("")) {
throw new BuildException("Required argument repository not specified"); 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("lvf");
commandLine.createArgument().setValue("-z"); commandLine.createArgument().setValue("-z");
commandLine.createArgument().setValue("-aw"); 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(); String uid = getUserId();


@@ -183,19 +184,20 @@ public class Pvcs extends org.apache.tools.ant.Task {
} }


// default pvcs project is "/" // default pvcs project is "/"
if(getPvcsproject() == null && getPvcsprojects().isEmpty()) {
if (getPvcsproject() == null && getPvcsprojects().isEmpty()) {
pvcsProject = "/"; pvcsProject = "/";
} }


if(getPvcsproject()!=null) {
if (getPvcsproject() != null) {
commandLine.createArgument().setValue(getPvcsproject()); commandLine.createArgument().setValue(getPvcsproject());
} }
if(!getPvcsprojects().isEmpty()) {
if (!getPvcsprojects().isEmpty()) {
Enumeration e = getPvcsprojects().elements(); Enumeration e = getPvcsprojects().elements();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
String projectName = ((PvcsProject)e.nextElement()).getName();
String projectName = ((PvcsProject) e.nextElement()).getName();
if (projectName == null || (projectName.trim()).equals("")) { 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); commandLine.createArgument().setValue(projectName);
} }
@@ -205,17 +207,21 @@ public class Pvcs extends org.apache.tools.ant.Task {
File tmp2 = null; File tmp2 = null;
try { try {
Random rand = new Random(System.currentTimeMillis()); 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); 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(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location); 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 // Create folders in workspace
@@ -229,17 +235,18 @@ public class Pvcs extends org.apache.tools.ant.Task {
commandLine.clearArgs(); commandLine.clearArgs();
commandLine.setExecutable(getExecutable(GET_EXE)); commandLine.setExecutable(getExecutable(GET_EXE));


if(getForce()!=null && getForce().equals("yes")) {
if (getForce() != null && getForce().equals("yes")) {
commandLine.createArgument().setValue("-Y"); commandLine.createArgument().setValue("-Y");
} else { } else {
commandLine.createArgument().setValue("-N"); commandLine.createArgument().setValue("-N");
} }


if(getPromotiongroup()!=null) {
commandLine.createArgument().setValue("-G"+getPromotiongroup());
if (getPromotiongroup() != null) {
commandLine.createArgument().setValue("-G"
+ getPromotiongroup());
} else { } 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("-U");
} }


commandLine.createArgument().setValue("@"+tmp2.getAbsolutePath());
commandLine.createArgument().setValue("@" + tmp2.getAbsolutePath());
log("Getting files", Project.MSG_INFO); log("Getting files", Project.MSG_INFO);
log("Executing " + commandLine.toString(), Project.MSG_VERBOSE); 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); 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 { } finally {
if (tmp != null) { if (tmp != null) {
tmp.delete(); tmp.delete();
@@ -280,45 +292,50 @@ public class Pvcs extends org.apache.tools.ant.Task {
*/ */
private void createFolders(File file) throws IOException, ParseException { private void createFolders(File file) throws IOException, ParseException {
BufferedReader in = new BufferedReader(new FileReader(file)); BufferedReader in = new BufferedReader(new FileReader(file));
MessageFormat mf = new MessageFormat( getFilenameFormat() );
MessageFormat mf = new MessageFormat(getFilenameFormat());
String line = in.readLine(); 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("\"/") ||
line.startsWith(getLineStart()) ) {
line.startsWith(getLineStart())) {
Object[] objs = mf.parse(line); Object[] objs = mf.parse(line);
String f = (String)objs[1];
String f = (String) objs[1];
// Extract the name of the directory from the filename // Extract the name of the directory from the filename
int index = f.lastIndexOf(File.separator); int index = f.lastIndexOf(File.separator);
if (index > -1) { if (index > -1) {
File dir = new File(f.substring(0, index)); 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 { } else {
log("Failed to create "+dir.getAbsolutePath(), Project.MSG_INFO);
log("Failed to create " + dir.getAbsolutePath(),
Project.MSG_INFO);
} }
} else { } else {
log(dir.getAbsolutePath() + " exists. Skipping", Project.MSG_VERBOSE);
log(dir.getAbsolutePath() + " exists. Skipping",
Project.MSG_VERBOSE);
} }
} else { } else {
log("File separator problem with " + line, log("File separator problem with " + line,
Project.MSG_WARN); Project.MSG_WARN);
} }
} else { } else {
log("Skipped \""+line+"\"", Project.MSG_VERBOSE);
log("Skipped \"" + line + "\"", Project.MSG_VERBOSE);
} }
line = in.readLine(); 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)); BufferedReader inReader = new BufferedReader(new FileReader(in));
BufferedWriter outWriter = new BufferedWriter(new FileWriter(out)); BufferedWriter outWriter = new BufferedWriter(new FileWriter(out));
String s = null; String s = null;
@@ -432,8 +449,8 @@ public class Pvcs extends org.apache.tools.ant.Task {
* @param repo String (yes/no) * @param repo String (yes/no)
*/ */
public void setForce(String f) { public void setForce(String f) {
if(f!=null && f.equalsIgnoreCase("yes")) {
force="yes";
if (f != null && f.equalsIgnoreCase("yes")) {
force = "yes";
} else { } else {
force = "no"; force = "no";
} }
@@ -452,7 +469,7 @@ public class Pvcs extends org.apache.tools.ant.Task {
* @param repo String * @param repo String
*/ */
public void setPromotiongroup(String w) { 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 * @param repo String
*/ */
public void setLabel(String l) { public void setLabel(String l) {
label=l;
label = l;
} }


/** /**
@@ -525,12 +542,12 @@ public class Pvcs extends org.apache.tools.ant.Task {
workspace = null; workspace = null;
repository = null; repository = null;
pvcsbin = null; pvcsbin = null;
force=null;
promotiongroup=null;
label=null;
ignorerc=false;
force = null;
promotiongroup = null;
label = null;
ignorerc = false;
updateOnly = false; updateOnly = false;
lineStart="\"P:";
filenameFormat="{0}_arc({1})";
lineStart = "\"P:";
filenameFormat = "{0}_arc({1})";
} }
} }

+ 338
- 386
src/main/org/apache/tools/ant/taskdefs/optional/scm/AntStarTeamCheckOut.java
File diff suppressed because it is too large
View File


+ 3
- 2
src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java View File

@@ -141,7 +141,8 @@ public class AntSoundPlayer implements LineListener, BuildListener {
audioInputStream = AudioSystem.getAudioInputStream(file); audioInputStream = AudioSystem.getAudioInputStream(file);
} }
catch (UnsupportedAudioFileException uafe) { 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) { catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
@@ -229,7 +230,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
if (event.getException() == null && fileSuccess != null) { if (event.getException() == null && fileSuccess != null) {
// build successfull! // build successfull!
play(event.getProject(), fileSuccess, loopsSuccess, durationSuccess); 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); play(event.getProject(), fileFail, loopsFail, durationFail);
} }
} }


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -107,7 +107,7 @@ public class SoundTask extends Task {


AntSoundPlayer soundPlayer = new AntSoundPlayer(); AntSoundPlayer soundPlayer = new AntSoundPlayer();


if ( success == null ) {
if (success == null) {
log("No nested success element found.", Project.MSG_WARN); log("No nested success element found.", Project.MSG_WARN);
} else { } else {
soundPlayer.addBuildSuccessfulSound(success.getSource(), soundPlayer.addBuildSuccessfulSound(success.getSource(),
@@ -165,18 +165,18 @@ public class SoundTask extends Task {
public File getSource() { public File getSource() {
File nofile = null ; File nofile = null ;
// Check if source is a directory // 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 // get the list of files in the dir
String[] entries = source.list() ; String[] entries = source.list() ;
Vector files = new Vector() ; 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]) ; File f = new File(source, entries[i]) ;
if (f.isFile()) { if (f.isFile()) {
files.addElement(f) ; files.addElement(f) ;
} }
} }
if ( files.size() < 1 ) {
if (files.size() < 1) {
throw new BuildException("No files found in directory " + source); throw new BuildException("No files found in directory " + source);
} }
int numfiles = files.size() ; int numfiles = files.size() ;
@@ -184,7 +184,7 @@ public class SoundTask extends Task {
Random rn = new Random() ; Random rn = new Random() ;
int x = rn.nextInt(numfiles) ; int x = rn.nextInt(numfiles) ;
// set the source to the file at that location // set the source to the file at that location
this.source = (File)files.elementAt(x) ;
this.source = (File) files.elementAt(x);
} }
} else { } else {
log(source + ": invalid path.", Project.MSG_WARN) ; log(source + ": invalid path.", Project.MSG_WARN) ;


+ 9
- 9
src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashScreen.java View File

@@ -90,15 +90,15 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener {


protected void init(ImageIcon img) { protected void init(ImageIcon img) {
JPanel pan = (JPanel)getContentPane();
JPanel pan = (JPanel) getContentPane();
JLabel piccy; JLabel piccy;
if(img == null ) {
if (img == null) {
piccy = new JLabel(); piccy = new JLabel();
} else { } else {
piccy = new JLabel(img); 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 = new JLabel("Building....", JLabel.CENTER);
text.setFont(new Font("Sans-Serif", Font.BOLD, 12)); text.setFont(new Font("Sans-Serif", Font.BOLD, 12));
text.setBorder(BorderFactory.createEtchedBorder()); text.setBorder(BorderFactory.createEtchedBorder());
@@ -108,8 +108,8 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener {
JPanel pan2 = new JPanel(); JPanel pan2 = new JPanel();
pan2.setLayout(new BorderLayout()); 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.setLayout(new BorderLayout());
pan.add(piccy, BorderLayout.CENTER); pan.add(piccy, BorderLayout.CENTER);
@@ -121,9 +121,9 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener {


Dimension size = getSize(); Dimension size = getSize();
Dimension scr = Toolkit.getDefaultToolkit().getScreenSize(); 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) { public void setText(String txt) {
@@ -131,7 +131,7 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener {
} }


public void actionPerformed(ActionEvent a) { public void actionPerformed(ActionEvent a) {
if(total < max) {
if (total < max) {
total++; total++;
} else { } else {
total = min; total = min;


+ 13
- 11
src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java View File

@@ -101,7 +101,7 @@ public class SplashTask extends Task {


public void execute() throws BuildException { public void execute() throws BuildException {
if (splash != null ) {
if (splash != null) {
splash.setVisible(false); splash.setVisible(false);
getProject().removeBuildListener(splash); getProject().removeBuildListener(splash);
splash.dispose(); splash.dispose();
@@ -112,10 +112,10 @@ public class SplashTask extends Task {
InputStream in = null; InputStream in = null;


if (imgurl != null) { if (imgurl != null) {
try{
try {
URLConnection conn = null; URLConnection conn = null;
if(useProxy &&
if (useProxy &&
(proxy != null && proxy.length() > 0) && (proxy != null && proxy.length() > 0) &&
(port != null && port.length() > 0)) { (port != null && port.length() > 0)) {
@@ -129,7 +129,7 @@ public class SplashTask extends Task {
conn = url.openConnection(); conn = url.openConnection();
if (user != null && user.length() > 0) { if (user != null && user.length() > 0) {
String encodedcreds = 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", conn.setRequestProperty("Proxy-Authorization",
encodedcreds); encodedcreds);
} }
@@ -150,9 +150,11 @@ public class SplashTask extends Task {
// Catch everything - some of the above return nulls, throw exceptions or generally misbehave // Catch everything - some of the above return nulls, throw exceptions or generally misbehave
// in the event of a problem etc // 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"); in = SplashTask.class.getClassLoader().getResourceAsStream("images/ant_logo_large.gif");
} }


if(in != null) {
if (in != null) {
DataInputStream din = new DataInputStream(in); DataInputStream din = new DataInputStream(in);
boolean success = false; boolean success = false;
try { try {
ByteArrayOutputStream bout = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
int data; 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); log("Got ByteArray, creating splash", Project.MSG_DEBUG);
@@ -175,7 +177,7 @@ public class SplashTask extends Task {
splash = new SplashScreen(img); splash = new SplashScreen(img);
success = true; success = true;
} catch(Exception e) {
} catch (Exception e) {
throw new BuildException(e); throw new BuildException(e);
} finally { } finally {
try { try {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamTask.java View File

@@ -250,7 +250,7 @@ public abstract class StarTeamTask extends Task {
this.servername + ":" + this.servername + ":" +
this.serverport + "/" + this.serverport + "/" +
this.projectname + "/" + this.projectname + "/" +
((null == this.viewname)?"":this.viewname);
((null == this.viewname) ? "" : this.viewname);
} }


/** /**


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java View File

@@ -99,7 +99,7 @@ public abstract class MSVSS extends Task {
*/ */
public final String getSSCommand() { public final String getSSCommand() {
String toReturn = m_SSDir; String toReturn = m_SSDir;
if ( !toReturn.equals("") && !toReturn.endsWith("\\") ) {
if (!toReturn.equals("") && !toReturn.endsWith("\\")) {
toReturn += "\\"; toReturn += "\\";
} }
toReturn += SS_EXE; 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 * @return the appropriate login command if the 'login' attribute was specified, otherwise an empty string
*/ */
public void getLoginCommand(Commandline cmd) { public void getLoginCommand(Commandline cmd) {
if ( m_vssLogin == null ) {
if (m_vssLogin == null) {
return; return;
} else { } else {
cmd.createArgument().setValue(FLAG_LOGIN + m_vssLogin); cmd.createArgument().setValue(FLAG_LOGIN + m_vssLogin);
@@ -138,8 +138,8 @@ public abstract class MSVSS extends Task {
* @param vssPath * @param vssPath
*/ */
public final void setVsspath(String 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 { } else {
m_vssPath = PROJECT_PREFIX + vssPath; m_vssPath = PROJECT_PREFIX + vssPath;
} }
@@ -171,11 +171,11 @@ public abstract class MSVSS extends Task {
// environment-variable SSDIR to this value // environment-variable SSDIR to this value
if (m_serverPath != null) { if (m_serverPath != null) {
String[] env = exe.getEnvironment(); String[] env = exe.getEnvironment();
if( env == null ) {
if (env == null) {
env = new String[0]; 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[i] = env[i];
} }
newEnv[env.length] = "SSDIR=" + m_serverPath; newEnv[env.length] = "SSDIR=" + m_serverPath;


+ 10
- 10
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSADD.java View File

@@ -107,10 +107,10 @@ public class MSVSSADD extends MSVSS {
// -Y // -Y
getLoginCommand(commandLine); getLoginCommand(commandLine);
// -C // -C
commandLine.createArgument().setValue("-C"+getComment());
commandLine.createArgument().setValue("-C" + getComment());


result = run(commandLine); result = run(commandLine);
if ( result != 0 ) {
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location); 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 * @return the 'recursive' command if the attribute was 'true', otherwise an empty string
*/ */
public void getRecursiveCommand(Commandline cmd) { public void getRecursiveCommand(Commandline cmd) {
if ( !m_Recursive ) {
if (!m_Recursive) {
return; return;
} else { } else {
cmd.createArgument().setValue(FLAG_RECURSION); 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 * @return the 'make writable' command if the attribute was 'true', otherwise an empty string
*/ */
public void getWritableCommand(Commandline cmd) { public void getWritableCommand(Commandline cmd) {
if ( !m_Writable ) {
if (!m_Writable) {
return; return;
} else { } else {
cmd.createArgument().setValue(FLAG_WRITABLE); cmd.createArgument().setValue(FLAG_WRITABLE);
@@ -153,7 +153,7 @@ public class MSVSSADD extends MSVSS {
} }


public void setAutoresponse(String response){ public void setAutoresponse(String response){
if ( response.equals("") || response.equals("null") ) {
if (response.equals("") || response.equals("null")) {
m_AutoResponse = null; m_AutoResponse = null;
} else { } else {
m_AutoResponse = response; m_AutoResponse = response;
@@ -168,14 +168,14 @@ public class MSVSSADD extends MSVSS {
*/ */
public void getAutoresponse(Commandline cmd) { public void getAutoresponse(Commandline cmd) {


if ( m_AutoResponse == null) {
if (m_AutoResponse == null) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} else if ( m_AutoResponse.equalsIgnoreCase("Y")) {
} else if (m_AutoResponse.equalsIgnoreCase("Y")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES);


} else if ( m_AutoResponse.equalsIgnoreCase("N")) {
} else if (m_AutoResponse.equalsIgnoreCase("N")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO);
}else {
} else {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} // end of else } // end of else


@@ -188,7 +188,7 @@ public class MSVSSADD extends MSVSS {
* is what SourceSafe uses for an empty comment. * is what SourceSafe uses for an empty comment.
*/ */
public void setComment(String comment) { public void setComment(String comment) {
if ( comment.equals("") || comment.equals("null") ) {
if (comment.equals("") || comment.equals("null")) {
m_Comment = "-"; m_Comment = "-";
} else { } else {
m_Comment = comment; m_Comment = comment;


+ 15
- 13
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java View File

@@ -112,10 +112,10 @@ public class MSVSSCHECKIN extends MSVSS {
// -Y // -Y
getLoginCommand(commandLine); getLoginCommand(commandLine);
// -C // -C
commandLine.createArgument().setValue("-C"+getComment());
commandLine.createArgument().setValue("-C" + getComment());


result = run(commandLine); result = run(commandLine);
if ( result != 0 ) {
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location); throw new BuildException(msg, location);
} }
@@ -142,14 +142,16 @@ public class MSVSSCHECKIN extends MSVSS {
if (!dir.exists()) { if (!dir.exists()) {
boolean done = dir.mkdirs(); boolean done = dir.mkdirs();
if (!done) { 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); throw new BuildException(msg, location);
} }
project.log("Created dir: " + dir.getAbsolutePath()); 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 * @return the 'recursive' command if the attribute was 'true', otherwise an empty string
*/ */
public void getRecursiveCommand(Commandline cmd) { public void getRecursiveCommand(Commandline cmd) {
if ( !m_Recursive ) {
if (!m_Recursive) {
return; return;
} else { } else {
cmd.createArgument().setValue(FLAG_RECURSION); 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 * @return the 'make writable' command if the attribute was 'true', otherwise an empty string
*/ */
public void getWritableCommand(Commandline cmd) { public void getWritableCommand(Commandline cmd) {
if ( !m_Writable ) {
if (!m_Writable) {
return; return;
} else { } else {
cmd.createArgument().setValue(FLAG_WRITABLE); cmd.createArgument().setValue(FLAG_WRITABLE);
@@ -190,7 +192,7 @@ public class MSVSSCHECKIN extends MSVSS {
} }


public void setAutoresponse(String response){ public void setAutoresponse(String response){
if ( response.equals("") || response.equals("null") ) {
if (response.equals("") || response.equals("null")) {
m_AutoResponse = null; m_AutoResponse = null;
} else { } else {
m_AutoResponse = response; m_AutoResponse = response;
@@ -205,14 +207,14 @@ public class MSVSSCHECKIN extends MSVSS {
*/ */
public void getAutoresponse(Commandline cmd) { public void getAutoresponse(Commandline cmd) {


if ( m_AutoResponse == null) {
if (m_AutoResponse == null) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} else if ( m_AutoResponse.equalsIgnoreCase("Y")) {
} else if (m_AutoResponse.equalsIgnoreCase("Y")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES);


} else if ( m_AutoResponse.equalsIgnoreCase("N")) {
} else if (m_AutoResponse.equalsIgnoreCase("N")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO);
}else {
} else {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} // end of else } // end of else


@@ -225,7 +227,7 @@ public class MSVSSCHECKIN extends MSVSS {
* is what SourceSafe uses for an empty comment. * is what SourceSafe uses for an empty comment.
*/ */
public void setComment(String comment) { public void setComment(String comment) {
if ( comment.equals("") || comment.equals("null") ) {
if (comment.equals("") || comment.equals("null")) {
m_Comment = "-"; m_Comment = "-";
} else { } else {
m_Comment = comment; m_Comment = comment;


+ 12
- 12
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java View File

@@ -114,7 +114,7 @@ public class MSVSSCHECKOUT extends MSVSS {
getLoginCommand(commandLine); getLoginCommand(commandLine);


result = run(commandLine); result = run(commandLine);
if ( result != 0 ) {
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location); 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 * @return the 'recursive' command if the attribute was 'true', otherwise an empty string
*/ */
public void getRecursiveCommand(Commandline cmd) { public void getRecursiveCommand(Commandline cmd) {
if ( !m_Recursive ) {
if (!m_Recursive) {
return; return;
} else { } else {
cmd.createArgument().setValue(FLAG_RECURSION); cmd.createArgument().setValue(FLAG_RECURSION);
@@ -179,7 +179,7 @@ public class MSVSSCHECKOUT extends MSVSS {
* has not been defined to ant! * has not been defined to ant!
*/ */
public void setVersion(String version) { public void setVersion(String version) {
if (version.equals("") || version.equals("null") ) {
if (version.equals("") || version.equals("null")) {
m_Version = null; m_Version = null;
} else { } else {
m_Version = version; m_Version = version;
@@ -195,7 +195,7 @@ public class MSVSSCHECKOUT extends MSVSS {
* has not been defined to ant! * has not been defined to ant!
*/ */
public void setDate(String date) { public void setDate(String date) {
if (date.equals("") || date.equals("null") ) {
if (date.equals("") || date.equals("null")) {
m_Date = null; m_Date = null;
} else { } else {
m_Date = date; m_Date = date;
@@ -211,7 +211,7 @@ public class MSVSSCHECKOUT extends MSVSS {
* has not been defined to ant! * has not been defined to ant!
*/ */
public void setLabel(String label) { public void setLabel(String label) {
if ( label.equals("") || label.equals("null") ) {
if (label.equals("") || label.equals("null")) {
m_Label = null; m_Label = null;
} else { } else {
m_Label = label; m_Label = label;
@@ -224,9 +224,9 @@ public class MSVSSCHECKOUT extends MSVSS {
*/ */
public void getVersionCommand(Commandline cmd) { public void getVersionCommand(Commandline cmd) {


if ( m_Version != null) {
if (m_Version != null) {
cmd.createArgument().setValue(FLAG_VERSION + m_Version); 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); cmd.createArgument().setValue(FLAG_VERSION_DATE + m_Date);
} else if (m_Label != null) { } else if (m_Label != null) {
cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_Label); cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_Label);
@@ -234,7 +234,7 @@ public class MSVSSCHECKOUT extends MSVSS {
} }


public void setAutoresponse(String response){ public void setAutoresponse(String response){
if ( response.equals("") || response.equals("null") ) {
if (response.equals("") || response.equals("null")) {
m_AutoResponse = null; m_AutoResponse = null;
} else { } else {
m_AutoResponse = response; m_AutoResponse = response;
@@ -249,14 +249,14 @@ public class MSVSSCHECKOUT extends MSVSS {
*/ */
public void getAutoresponse(Commandline cmd) { public void getAutoresponse(Commandline cmd) {


if ( m_AutoResponse == null) {
if (m_AutoResponse == null) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} else if ( m_AutoResponse.equalsIgnoreCase("Y")) {
} else if (m_AutoResponse.equalsIgnoreCase("Y")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES);


} else if ( m_AutoResponse.equalsIgnoreCase("N")) {
} else if (m_AutoResponse.equalsIgnoreCase("N")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO);
}else {
} else {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} // end of else } // end of else




+ 6
- 6
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCP.java View File

@@ -101,14 +101,14 @@ public class MSVSSCP extends MSVSS {
getLoginCommand(commandLine); getLoginCommand(commandLine);
result = run(commandLine); result = run(commandLine);
if ( result != 0 ) {
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location); throw new BuildException(msg, location);
} }
} }


public void setAutoresponse(String response) { public void setAutoresponse(String response) {
if ( response.equals("") || response.equals("null") ) {
if (response.equals("") || response.equals("null")) {
m_AutoResponse = null; m_AutoResponse = null;
} else { } else {
m_AutoResponse = response; m_AutoResponse = response;
@@ -123,14 +123,14 @@ public class MSVSSCP extends MSVSS {
*/ */
public void getAutoresponse(Commandline cmd) { public void getAutoresponse(Commandline cmd) {


if ( m_AutoResponse == null) {
if (m_AutoResponse == null) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} else if ( m_AutoResponse.equalsIgnoreCase("Y")) {
} else if (m_AutoResponse.equalsIgnoreCase("Y")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES);


} else if ( m_AutoResponse.equalsIgnoreCase("N")) {
} else if (m_AutoResponse.equalsIgnoreCase("N")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO);
}else {
} else {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} // end of else } // end of else




+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java View File

@@ -151,7 +151,7 @@ public class MSVSSCREATE extends MSVSS {
commandLine.createArgument().setValue(getVsspath()); commandLine.createArgument().setValue(getVsspath());


// -C // -C
commandLine.createArgument().setValue("-C"+getComment());
commandLine.createArgument().setValue("-C" + getComment());


// -I- or -I-Y or -I-N // -I- or -I-Y or -I-N
getAutoresponse(commandLine); getAutoresponse(commandLine);
@@ -198,7 +198,7 @@ public class MSVSSCREATE extends MSVSS {
* @param quiet whether or not command should be run in "quiet mode". * @param quiet whether or not command should be run in "quiet mode".
*/ */
public final void setQuiet (boolean quiet) { 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. * the project.
*/ */
public final void setFailOnError (boolean failOnError) { public final void setFailOnError (boolean failOnError) {
this.m_FailOnError=failOnError;
this.m_FailOnError = failOnError;
} }


/** /**


+ 14
- 15
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java View File

@@ -182,7 +182,7 @@ public class MSVSSGET extends MSVSS {
getLoginCommand(commandLine); getLoginCommand(commandLine);


result = run(commandLine); result = run(commandLine);
if ( result != 0 ) {
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location); 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 * @return the 'recursive' command if the attribute was 'true', otherwise an empty string
*/ */
public void getRecursiveCommand(Commandline cmd) { public void getRecursiveCommand(Commandline cmd) {
if ( !m_Recursive ) {
if (!m_Recursive) {
return; return;
} else { } else {
cmd.createArgument().setValue(FLAG_RECURSION); cmd.createArgument().setValue(FLAG_RECURSION);
@@ -242,7 +242,7 @@ public class MSVSSGET extends MSVSS {
* Sets/clears quiet mode * Sets/clears quiet mode
*/ */
public final void setQuiet (boolean quiet) { public final void setQuiet (boolean quiet) {
this.m_Quiet=quiet;
this.m_Quiet = quiet;
} }
public void getQuietCommand (Commandline cmd) { 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 * @return the 'make writable' command if the attribute was 'true', otherwise an empty string
*/ */
public void getWritableCommand(Commandline cmd) { public void getWritableCommand(Commandline cmd) {
if ( !m_Writable ) {
if (!m_Writable) {
return; return;
} else { } else {
cmd.createArgument().setValue(FLAG_WRITABLE); cmd.createArgument().setValue(FLAG_WRITABLE);
@@ -278,7 +278,7 @@ public class MSVSSGET extends MSVSS {
* has not been defined to ant! * has not been defined to ant!
*/ */
public void setVersion(String version) { public void setVersion(String version) {
if (version.equals("") || version.equals("null") ) {
if (version.equals("") || version.equals("null")) {
m_Version = null; m_Version = null;
} else { } else {
m_Version = version; m_Version = version;
@@ -294,7 +294,7 @@ public class MSVSSGET extends MSVSS {
* has not been defined to ant! * has not been defined to ant!
*/ */
public void setDate(String date) { public void setDate(String date) {
if (date.equals("") || date.equals("null") ) {
if (date.equals("") || date.equals("null")) {
m_Date = null; m_Date = null;
} else { } else {
m_Date = date; m_Date = date;
@@ -310,7 +310,7 @@ public class MSVSSGET extends MSVSS {
* has not been defined to ant! * has not been defined to ant!
*/ */
public void setLabel(String label) { public void setLabel(String label) {
if ( label.equals("") || label.equals("null") ) {
if (label.equals("") || label.equals("null")) {
m_Label = null; m_Label = null;
} else { } else {
m_Label = label; m_Label = label;
@@ -323,9 +323,9 @@ public class MSVSSGET extends MSVSS {
*/ */
public void getVersionCommand(Commandline cmd) { public void getVersionCommand(Commandline cmd) {


if ( m_Version != null) {
if (m_Version != null) {
cmd.createArgument().setValue(FLAG_VERSION + m_Version); 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); cmd.createArgument().setValue(FLAG_VERSION_DATE + m_Date);
} else if (m_Label != null) { } else if (m_Label != null) {
cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_Label); cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_Label);
@@ -333,7 +333,7 @@ public class MSVSSGET extends MSVSS {
} }


public void setAutoresponse(String response){ public void setAutoresponse(String response){
if ( response.equals("") || response.equals("null") ) {
if (response.equals("") || response.equals("null")) {
m_AutoResponse = null; m_AutoResponse = null;
} else { } else {
m_AutoResponse = response; m_AutoResponse = response;
@@ -348,18 +348,17 @@ public class MSVSSGET extends MSVSS {
*/ */
public void getAutoresponse(Commandline cmd) { public void getAutoresponse(Commandline cmd) {
if ( m_AutoResponse == null) {
if (m_AutoResponse == null) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} else if ( m_AutoResponse.equalsIgnoreCase("Y")) {
} else if (m_AutoResponse.equalsIgnoreCase("Y")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES);
} else if ( m_AutoResponse.equalsIgnoreCase("N")) {
} else if (m_AutoResponse.equalsIgnoreCase("N")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO);
}else {
} else {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} // end of else } // end of else


} }

} }



+ 18
- 18
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java View File

@@ -148,7 +148,7 @@ public class MSVSSHISTORY extends MSVSS {
System.out.println("***: " + commandLine); System.out.println("***: " + commandLine);
result = run(commandLine); result = run(commandLine);
if ( result != 0 ) {
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location); 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 * Set the Start Date for the Comparison of two versions in SourceSafe History
*/ */
public void setFromDate(String fromDate) { public void setFromDate(String fromDate) {
if ( fromDate.equals("") || fromDate == null ) {
if (fromDate.equals("") || fromDate == null) {
m_FromDate = null; m_FromDate = null;
} else { } else {
m_FromDate = fromDate; m_FromDate = fromDate;
@@ -170,7 +170,7 @@ public class MSVSSHISTORY extends MSVSS {
* Set the Start Label * Set the Start Label
*/ */
public void setFromLabel(String fromLabel) { public void setFromLabel(String fromLabel) {
if ( fromLabel.equals("") || fromLabel == null ) {
if (fromLabel.equals("") || fromLabel == null) {
m_FromLabel = null; m_FromLabel = null;
} else { } else {
m_FromLabel = fromLabel; m_FromLabel = fromLabel;
@@ -181,7 +181,7 @@ public class MSVSSHISTORY extends MSVSS {
* Set the End Label * Set the End Label
*/ */
public void setToLabel(String toLabel) { public void setToLabel(String toLabel) {
if ( toLabel.equals("") || toLabel == null ) {
if (toLabel.equals("") || toLabel == null) {
m_ToLabel = null; m_ToLabel = null;
} else { } else {
m_ToLabel = toLabel; 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 * Set the End Date for the Comparison of two versions in SourceSafe History
*/ */
public void setToDate(String toDate) { public void setToDate(String toDate) {
if ( toDate.equals("") || toDate == null ) {
if (toDate.equals("") || toDate == null) {
m_ToDate = null; m_ToDate = null;
} else { } else {
m_ToDate = toDate; m_ToDate = toDate;
@@ -212,7 +212,7 @@ public class MSVSSHISTORY extends MSVSS {
* Set the output file name for SourceSafe output. * Set the output file name for SourceSafe output.
*/ */
public void setOutput(File outfile) { public void setOutput(File outfile) {
if ( outfile == null ) {
if (outfile == null) {
m_OutputFileName = null; m_OutputFileName = null;
} else { } else {
m_OutputFileName = outfile.getAbsolutePath(); 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. * Set the Start Date for the Comparison of two versions in SourceSafe History.
*/ */
public void setDateFormat(String dateFormat) { public void setDateFormat(String dateFormat) {
if ( !(dateFormat.equals("") || dateFormat == null) ) {
if (!(dateFormat.equals("") || dateFormat == null)) {
m_DateFormat = new SimpleDateFormat(dateFormat); 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 * @param cmd the commandline the command is to be added to
*/ */
private void getVersionDateCommand(Commandline cmd) throws BuildException { 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; 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) { } else if (m_ToDate != null && m_NumDays != Integer.MIN_VALUE) {
String startDate = null; String startDate = null;
try { try {
@@ -271,11 +273,11 @@ public class MSVSSHISTORY extends MSVSS {
* @param cmd the commandline the command is to be added to * @param cmd the commandline the command is to be added to
*/ */
private void getVersionLabelCommand(Commandline cmd) throws BuildException { private void getVersionLabelCommand(Commandline cmd) throws BuildException {
if ( m_FromLabel == null && m_ToLabel == null ) {
if (m_FromLabel == null && m_ToLabel == null) {
return; 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); cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_ToLabel + VALUE_FROMLABEL + m_FromLabel);
} else if (m_FromLabel != null) { } else if (m_FromLabel != null) {
cmd.createArgument().setValue(FLAG_VERSION + VALUE_FROMLABEL + m_FromLabel); 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 * @param cmd the commandline the command is to be added to
*/ */
private void getOutputCommand(Commandline cmd) { private void getOutputCommand(Commandline cmd) {
if ( m_OutputFileName != null) {
if (m_OutputFileName != null) {
cmd.createArgument().setValue(FLAG_OUTPUT + m_OutputFileName); 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 * @param cmd the commandline the command is to be added to
*/ */
private void getUserCommand(Commandline cmd) { private void getUserCommand(Commandline cmd) {
if ( m_User != null) {
if (m_User != null) {
cmd.createArgument().setValue(FLAG_USER + m_User); 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 { private String calcDate(String fromDate, int numDays) throws ParseException {
String toDate = null; String toDate = null;
Date currdate = new Date(); Date currdate = new Date();
Calendar calend= new GregorianCalendar();
Calendar calend = new GregorianCalendar();
currdate = m_DateFormat.parse(fromDate); currdate = m_DateFormat.parse(fromDate);
calend.setTime(currdate); calend.setTime(currdate);
calend.add(Calendar.DATE, numDays); 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 * @return the 'recursive' command if the attribute was 'true', otherwise an empty string
*/ */
private void getRecursiveCommand(Commandline cmd) { private void getRecursiveCommand(Commandline cmd) {
if ( !m_Recursive ) {
if (!m_Recursive) {
return; return;
} else { } else {
cmd.createArgument().setValue(FLAG_RECURSION); cmd.createArgument().setValue(FLAG_RECURSION);
@@ -376,6 +378,4 @@ public class MSVSSHISTORY extends MSVSS {
return new String[] {"brief", "codediff", "nofile", "default"}; return new String[] {"brief", "codediff", "nofile", "default"};
} }
} }


} }

+ 12
- 13
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java View File

@@ -152,7 +152,7 @@ public class MSVSSLABEL extends MSVSS
commandLine.createArgument().setValue(getVsspath()); commandLine.createArgument().setValue(getVsspath());


// -C // -C
commandLine.createArgument().setValue("-C"+getComment());
commandLine.createArgument().setValue("-C" + getComment());


// -I- or -I-Y or -I-N // -I- or -I-Y or -I-N
getAutoresponse(commandLine); getAutoresponse(commandLine);
@@ -169,7 +169,7 @@ public class MSVSSLABEL extends MSVSS
getLoginCommand(commandLine); getLoginCommand(commandLine);


result = run(commandLine); result = run(commandLine);
if ( result != 0 ) {
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location); throw new BuildException(msg, location);
} }
@@ -185,7 +185,7 @@ public class MSVSSLABEL extends MSVSS
* has not been defined to ant! * has not been defined to ant!
*/ */
public void setLabel(String label) { public void setLabel(String label) {
if ( label.equals("") || label.equals("null") ) {
if (label.equals("") || label.equals("null")) {
m_Label = null; m_Label = null;
} else { } else {
m_Label = label; m_Label = label;
@@ -197,7 +197,7 @@ public class MSVSSLABEL extends MSVSS
* @param cmd the commandline the command is to be added to * @param cmd the commandline the command is to be added to
*/ */
public void getVersionCommand(Commandline cmd) { public void getVersionCommand(Commandline cmd) {
if ( m_Version != null) {
if (m_Version != null) {
cmd.createArgument().setValue(FLAG_VERSION + m_Version); 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 * @param cmd the commandline the command is to be added to
*/ */
public void getLabelCommand(Commandline cmd) { public void getLabelCommand(Commandline cmd) {
if ( m_Label != null) {
if (m_Label != null) {
cmd.createArgument().setValue(FLAG_LABEL + m_Label); cmd.createArgument().setValue(FLAG_LABEL + m_Label);
} }
} }
@@ -221,7 +221,7 @@ public class MSVSSLABEL extends MSVSS
* has not been defined to ant! * has not been defined to ant!
*/ */
public void setVersion(String version) { public void setVersion(String version) {
if (version.equals("") || version.equals("null") ) {
if (version.equals("") || version.equals("null")) {
m_Version = null; m_Version = null;
} else { } else {
m_Version = version; m_Version = version;
@@ -243,7 +243,7 @@ public class MSVSSLABEL extends MSVSS
* is what SourceSafe uses for an empty comment. * is what SourceSafe uses for an empty comment.
*/ */
public void setComment(String comment) { public void setComment(String comment) {
if ( comment.equals("") || comment.equals("null") ) {
if (comment.equals("") || comment.equals("null")) {
m_Comment = "-"; m_Comment = "-";
} else { } else {
m_Comment = comment; m_Comment = comment;
@@ -259,7 +259,7 @@ public class MSVSSLABEL extends MSVSS
} }
public void setAutoresponse(String response){ public void setAutoresponse(String response){
if ( response.equals("") || response.equals("null") ) {
if (response.equals("") || response.equals("null")) {
m_AutoResponse = null; m_AutoResponse = null;
} else { } else {
m_AutoResponse = response; m_AutoResponse = response;
@@ -274,16 +274,15 @@ public class MSVSSLABEL extends MSVSS
*/ */
public void getAutoresponse(Commandline cmd) { public void getAutoresponse(Commandline cmd) {
if ( m_AutoResponse == null) {
if (m_AutoResponse == null) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} else if ( m_AutoResponse.equalsIgnoreCase("Y")) {
} else if (m_AutoResponse.equalsIgnoreCase("Y")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES);
} else if ( m_AutoResponse.equalsIgnoreCase("N")) {
} else if (m_AutoResponse.equalsIgnoreCase("N")) {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO);
}else {
} else {
cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF);
} // end of else } // end of else

} }
} }

+ 18
- 19
src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java View File

@@ -86,7 +86,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
public DefaultRmicAdapter() { public DefaultRmicAdapter() {
} }


public void setRmic( Rmic attributes ) {
public void setRmic(Rmic attributes) {
this.attributes = attributes; this.attributes = attributes;
mapper = new RmicFileNameMapper(); mapper = new RmicFileNameMapper();
} }
@@ -146,11 +146,11 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
// Combine the build classpath with the system classpath, in an // Combine the build classpath with the system classpath, in an
// order determined by the value of build.sysclasspath // order determined by the value of build.sysclasspath
if (attributes.getClasspath() == null) { if (attributes.getClasspath() == null) {
if ( attributes.getIncludeantruntime() ) {
if (attributes.getIncludeantruntime()) {
classpath.addExisting(Path.systemClasspath); classpath.addExisting(Path.systemClasspath);
} }
} else { } else {
if ( attributes.getIncludeantruntime() ) {
if (attributes.getIncludeantruntime()) {
classpath.addExisting(attributes.getClasspath() classpath.addExisting(attributes.getClasspath()
.concatSystemClasspath("last")); .concatSystemClasspath("last"));
} else { } else {
@@ -182,7 +182,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
Commandline cmd = new Commandline(); Commandline cmd = new Commandline();


if (options != null) { if (options != null) {
for (int i=0; i<options.length; i++) {
for (int i = 0; i < options.length; i++) {
cmd.createArgument().setValue(options[i]); cmd.createArgument().setValue(options[i]);
} }
} }
@@ -222,27 +222,27 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
cmd.createArgument().setValue("-keepgenerated"); cmd.createArgument().setValue("-keepgenerated");
} }


if( attributes.getIiop() ) {
if (attributes.getIiop()) {
attributes.log("IIOP has been turned on.", Project.MSG_INFO); attributes.log("IIOP has been turned on.", Project.MSG_INFO);
cmd.createArgument().setValue("-iiop"); cmd.createArgument().setValue("-iiop");
if( attributes.getIiopopts() != null ) {
if (attributes.getIiopopts() != null) {
attributes.log("IIOP Options: " + attributes.getIiopopts(), attributes.log("IIOP Options: " + attributes.getIiopopts(),
Project.MSG_INFO );
Project.MSG_INFO);
cmd.createArgument().setValue(attributes.getIiopopts()); cmd.createArgument().setValue(attributes.getIiopopts());
} }
} }


if( attributes.getIdl() ) {
if (attributes.getIdl()) {
cmd.createArgument().setValue("-idl"); cmd.createArgument().setValue("-idl");
attributes.log("IDL has been turned on.", Project.MSG_INFO); attributes.log("IDL has been turned on.", Project.MSG_INFO);
if( attributes.getIdlopts() != null ) {
if (attributes.getIdlopts() != null) {
cmd.createArgument().setValue(attributes.getIdlopts()); cmd.createArgument().setValue(attributes.getIdlopts());
attributes.log("IDL Options: " + attributes.getIdlopts(), attributes.log("IDL Options: " + attributes.getIdlopts(),
Project.MSG_INFO );
Project.MSG_INFO);
} }
} }


if( attributes.getDebug()) {
if (attributes.getDebug()) {
cmd.createArgument().setValue("-g"); cmd.createArgument().setValue("-g");
} }


@@ -266,8 +266,8 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
} }
niceSourceList.append(" to be compiled:"); 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); cmd.createArgument().setValue(arg);
niceSourceList.append(" " + arg); niceSourceList.append(" " + arg);
} }
@@ -306,15 +306,15 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
public String[] mapFileName(String name) { public String[] mapFileName(String name) {
if (name == null if (name == null
|| !name.endsWith(".class") || !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 // Not a .class file or the one we'd generate
return null; return null;
} }


// we know that name.endsWith(".class") // 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, '.'); String classname = base.replace(File.separatorChar, '.');
if (attributes.getVerify() && if (attributes.getVerify() &&
@@ -330,7 +330,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
* This is supposed to make Ant always recompile the * This is supposed to make Ant always recompile the
* class, as a file of that name should not exist. * 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()) { if (!attributes.getIiop() && !attributes.getIdl()) {
// JRMP with simple naming convention // JRMP with simple naming convention
@@ -413,5 +413,4 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
return target; return target;
} }
} }

} }

+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java View File

@@ -80,7 +80,7 @@ public class KaffeRmic extends DefaultRmicAdapter {
Constructor cons = c.getConstructor(new Class[] { String[].class }); Constructor cons = c.getConstructor(new Class[] { String[].class });
Object rmic = cons.newInstance(new Object[] { cmd.getArguments() }); Object rmic = cons.newInstance(new Object[] { cmd.getArguments() });
Method doRmic = c.getMethod("run", null); Method doRmic = c.getMethod("run", null);
Boolean ok = (Boolean)doRmic.invoke(rmic, null);
Boolean ok = (Boolean) doRmic.invoke(rmic, null);


return ok.booleanValue(); return ok.booleanValue();
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
@@ -88,7 +88,7 @@ public class KaffeRmic extends DefaultRmicAdapter {
+ "available. A common solution is to " + "available. A common solution is to "
+ "set the environment variable " + "set the environment variable "
+ "JAVA_HOME or CLASSPATH.", + "JAVA_HOME or CLASSPATH.",
getRmic().getLocation() );
getRmic().getLocation());
} catch (Exception ex) { } catch (Exception ex) {
if (ex instanceof BuildException) { if (ex instanceof BuildException) {
throw (BuildException) ex; throw (BuildException) ex;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java View File

@@ -79,7 +79,7 @@ public interface RmicAdapter {
/** /**
* Sets the rmic attributes, which are stored in the Rmic task. * Sets the rmic attributes, which are stored in the Rmic task.
*/ */
void setRmic( Rmic attributes );
void setRmic(Rmic attributes);


/** /**
* Executes the task. * Executes the task.


+ 12
- 12
src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java View File

@@ -88,9 +88,9 @@ public class RmicAdapterFactory {
* @throws BuildException if the rmic type could not be resolved into * @throws BuildException if the rmic type could not be resolved into
* a rmic adapter. * a rmic adapter.
*/ */
public static RmicAdapter getRmic( String rmicType, Task task )
public static RmicAdapter getRmic(String rmicType, Task task)
throws BuildException { throws BuildException {
if( rmicType == null){
if (rmicType == null) {
/* /*
* When not specified rmicType, search SUN's rmic and * When not specified rmicType, search SUN's rmic and
* Kaffe's rmic. * Kaffe's rmic.
@@ -110,14 +110,14 @@ public class RmicAdapterFactory {
} }
} }


if ( rmicType.equalsIgnoreCase("sun") ) {
if (rmicType.equalsIgnoreCase("sun")) {
return new SunRmic(); return new SunRmic();
} else if ( rmicType.equalsIgnoreCase("kaffe") ) {
} else if (rmicType.equalsIgnoreCase("kaffe")) {
return new KaffeRmic(); return new KaffeRmic();
} else if ( rmicType.equalsIgnoreCase("weblogic") ) {
} else if (rmicType.equalsIgnoreCase("weblogic")) {
return new WLRmic(); 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 * @throws BuildException This is the fit that is thrown if className
* isn't an instance of RmicAdapter. * isn't an instance of RmicAdapter.
*/ */
private static RmicAdapter resolveClassName( String className )
private static RmicAdapter resolveClassName(String className)
throws BuildException { throws BuildException {
try { try {
Class c = Class.forName( className );
Class c = Class.forName(className);
Object o = c.newInstance(); Object o = c.newInstance();
return (RmicAdapter) o; 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 " throw new BuildException(className + " isn\'t the classname of "
+ "a rmic adapter.", cce); + "a rmic adapter.", cce);
} catch ( Throwable t ) {
} catch (Throwable t) {
// for all other possibilities // for all other possibilities
throw new BuildException(className + " caused an interesting " throw new BuildException(className + " caused an interesting "
+ "exception.", t); + "exception.", t);


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java View File

@@ -90,15 +90,15 @@ public class SunRmic extends DefaultRmicAdapter {
Method doRmic = c.getMethod("compile", Method doRmic = c.getMethod("compile",
new Class [] { String[].class }); new Class [] { String[].class });
Boolean ok = Boolean ok =
(Boolean)doRmic.invoke(rmic,
(new Object[] {cmd.getArguments()} ));
(Boolean) doRmic.invoke(rmic,
(new Object[] {cmd.getArguments()}));
return ok.booleanValue(); return ok.booleanValue();
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
throw new BuildException("Cannot use SUN rmic, as it is not " throw new BuildException("Cannot use SUN rmic, as it is not "
+ "available. A common solution is to " + "available. A common solution is to "
+ "set the environment variable " + "set the environment variable "
+ "JAVA_HOME or CLASSPATH.", + "JAVA_HOME or CLASSPATH.",
getRmic().getLocation() );
getRmic().getLocation());
} catch (Exception ex) { } catch (Exception ex) {
if (ex instanceof BuildException) { if (ex instanceof BuildException) {
throw (BuildException) ex; throw (BuildException) ex;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java View File

@@ -94,7 +94,7 @@ public class WLRmic extends DefaultRmicAdapter {
throw new BuildException("Cannot use WebLogic rmic, as it is not " throw new BuildException("Cannot use WebLogic rmic, as it is not "
+ "available. A common solution is to " + "available. A common solution is to "
+ "set the environment variable " + "set the environment variable "
+ "CLASSPATH.", getRmic().getLocation() );
+ "CLASSPATH.", getRmic().getLocation());
} catch (Exception ex) { } catch (Exception ex) {
if (ex instanceof BuildException) { if (ex instanceof BuildException) {
throw (BuildException) ex; throw (BuildException) ex;


+ 6
- 6
src/main/org/apache/tools/ant/types/AbstractFileSet.java View File

@@ -283,8 +283,8 @@ public abstract class AbstractFileSet extends DataType implements Cloneable {
if (project != null) { if (project != null) {
Hashtable typedefs = project.getDataTypeDefinitions(); Hashtable typedefs = project.getDataTypeDefinitions();
for (Enumeration e = typedefs.keys(); e.hasMoreElements();) { 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()) { if (typeClass == getClass()) {
return typeName; return typeName;
} }
@@ -314,11 +314,11 @@ public abstract class AbstractFileSet extends DataType implements Cloneable {
} }


if (!dir.exists()) { if (!dir.exists()) {
throw new BuildException(dir.getAbsolutePath()+" not found.");
throw new BuildException(dir.getAbsolutePath() + " not found.");
} }
if (!dir.isDirectory()) { if (!dir.isDirectory()) {
throw new BuildException(dir.getAbsolutePath() throw new BuildException(dir.getAbsolutePath()
+" is not a directory.");
+ " is not a directory.");
} }


DirectoryScanner ds = new DirectoryScanner(); DirectoryScanner ds = new DirectoryScanner();
@@ -341,7 +341,7 @@ public abstract class AbstractFileSet extends DataType implements Cloneable {
} }


p.log(getDataTypeName() + ": Setup scanner in dir " + dir + p.log(getDataTypeName() + ": Setup scanner in dir " + dir +
" with " + defaultPatterns, Project.MSG_DEBUG );
" with " + defaultPatterns, Project.MSG_DEBUG);
ds.setIncludes(defaultPatterns.getIncludePatterns(p)); ds.setIncludes(defaultPatterns.getIncludePatterns(p));
ds.setExcludes(defaultPatterns.getExcludePatterns(p)); ds.setExcludes(defaultPatterns.getExcludePatterns(p));
@@ -364,7 +364,7 @@ public abstract class AbstractFileSet extends DataType implements Cloneable {
Object o = ref.getReferencedObject(p); Object o = ref.getReferencedObject(p);
if (!getClass().isAssignableFrom(o.getClass())) { if (!getClass().isAssignableFrom(o.getClass())) {
String msg = ref.getRefId()+" doesn\'t denote a "
String msg = ref.getRefId() + " doesn\'t denote a "
+ getDataTypeName(); + getDataTypeName();
throw new BuildException(msg); throw new BuildException(msg);
} else { } else {


+ 16
- 16
src/main/org/apache/tools/ant/types/Commandline.java View File

@@ -92,7 +92,7 @@ public class Commandline implements Cloneable {
String[] tmp = translateCommandline(to_process); String[] tmp = translateCommandline(to_process);
if (tmp != null && tmp.length > 0) { if (tmp != null && tmp.length > 0) {
setExecutable(tmp[0]); setExecutable(tmp[0]);
for (int i=1; i<tmp.length; i++) {
for (int i = 1; i < tmp.length; i++) {
createArgument().setValue(tmp[i]); createArgument().setValue(tmp[i]);
} }
} }
@@ -124,7 +124,7 @@ public class Commandline implements Cloneable {
* @param line line to split into several commandline arguments * @param line line to split into several commandline arguments
*/ */
public void setLine(String line) { public void setLine(String line) {
if( line == null ) {
if (line == null) {
return; return;
} }
parts = translateCommandline(line); parts = translateCommandline(line);
@@ -183,7 +183,7 @@ public class Commandline implements Cloneable {
public int getPosition() { public int getPosition() {
if (realPos == -1) { if (realPos == -1) {
realPos = (executable == null ? 0 : 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); Argument arg = (Argument) arguments.elementAt(i);
realPos += arg.getParts().length; realPos += arg.getParts().length;
} }
@@ -203,7 +203,7 @@ public class Commandline implements Cloneable {
* @return the argument object. * @return the argument object.
*/ */
public Argument createArgument() { 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 * @param insertAtStart if true, the argument is inserted at the
* beginning of the list of args, otherwise it is appended. * beginning of the list of args, otherwise it is appended.
*/ */
public Argument createArgument( boolean insertAtStart ) {
public Argument createArgument(boolean insertAtStart) {
Argument argument = new Argument(); Argument argument = new Argument();
if(insertAtStart) {
arguments.insertElementAt(argument,0);
if (insertAtStart) {
arguments.insertElementAt(argument, 0);
} else { } else {
arguments.addElement(argument); arguments.addElement(argument);
} }
@@ -243,7 +243,7 @@ public class Commandline implements Cloneable {




public void addArguments(String[] line) { 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]); createArgument().setValue(line[i]);
} }
} }
@@ -256,7 +256,7 @@ public class Commandline implements Cloneable {
if (executable == null) { if (executable == null) {
return args; return args;
} }
final String[] result = new String[args.length+1];
final String[] result = new String[args.length + 1];
result[0] = executable; result[0] = executable;
System.arraycopy(args, 0, result, 1, args.length); System.arraycopy(args, 0, result, 1, args.length);
return result; return result;
@@ -268,12 +268,12 @@ public class Commandline implements Cloneable {
* <code>addValue</code> or the argument object. * <code>addValue</code> or the argument object.
*/ */
public String[] getArguments() { 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); Argument arg = (Argument) arguments.elementAt(i);
String[] s = arg.getParts(); 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]); result.addElement(s[j]);
} }
} }
@@ -304,10 +304,10 @@ public class Commandline implements Cloneable {
if (argument.indexOf("\'") > -1) { if (argument.indexOf("\'") > -1) {
throw new BuildException("Can\'t handle single and double quotes in same argument"); throw new BuildException("Can\'t handle single and double quotes in same argument");
} else { } else {
return '\''+argument+'\'';
return '\'' + argument + '\'';
} }
} else if (argument.indexOf("\'") > -1 || argument.indexOf(" ") > -1) { } else if (argument.indexOf("\'") > -1 || argument.indexOf(" ") > -1) {
return '\"'+argument+'\"';
return '\"' + argument + '\"';
} else { } else {
return argument; return argument;
} }
@@ -321,7 +321,7 @@ public class Commandline implements Cloneable {


// path containing one or more elements // path containing one or more elements
final StringBuffer result = new StringBuffer(); final StringBuffer result = new StringBuffer();
for (int i=0; i < line.length; i++) {
for (int i = 0; i < line.length; i++) {
if (i > 0) { if (i > 0) {
result.append(' '); result.append(' ');
} }


+ 6
- 4
src/main/org/apache/tools/ant/types/CommandlineJava.java View File

@@ -112,11 +112,11 @@ public class CommandlineJava implements Cloneable {
try { try {
sys = System.getProperties(); sys = System.getProperties();
Properties p = new Properties(); Properties p = new Properties();
for (Enumeration e = sys.keys(); e.hasMoreElements(); ) {
for (Enumeration e = sys.keys(); e.hasMoreElements();) {
Object o = e.nextElement(); Object o = e.nextElement();
p.put(o, sys.get(o)); 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(); Environment.Variable v = (Environment.Variable) e.nextElement();
p.put(v.getKey(), v.getValue()); p.put(v.getKey(), v.getValue());
} }
@@ -144,7 +144,9 @@ public class CommandlineJava implements Cloneable {
SysProperties c = (SysProperties) super.clone(); SysProperties c = (SysProperties) super.clone();
c.variables = (Vector) variables.clone(); c.variables = (Vector) variables.clone();
return c; return c;
} catch(CloneNotSupportedException e){return null;}
} catch (CloneNotSupportedException e) {
return null;
}
} }


} }
@@ -282,7 +284,7 @@ public class CommandlineJava implements Cloneable {
} }


private Commandline getActualVMCommand() { private Commandline getActualVMCommand() {
Commandline actualVMCommand = (Commandline)vmCommand.clone();
Commandline actualVMCommand = (Commandline) vmCommand.clone();
if (maxMemory != null) { if (maxMemory != null) {
if (vmVersion.startsWith("1.1")) { if (vmVersion.startsWith("1.1")) {
actualVMCommand.createArgument().setValue("-mx" + maxMemory); actualVMCommand.createArgument().setValue("-mx" + maxMemory);


+ 10
- 8
src/main/org/apache/tools/ant/types/DataType.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 * Sets a description of the current data type. It will be useful
* in commenting what we are doing. * 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()); Object o = ref.getReferencedObject(getProject());
if (!(requiredClass.isAssignableFrom(o.getClass()))) { 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); throw new BuildException(msg);
} else { } else {
return o; return o;
@@ -187,8 +187,8 @@ public abstract class DataType extends ProjectComponent {
* only attribute if it is set. * only attribute if it is set.
*/ */
protected BuildException tooManyAttributes() { 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. * not have child elements if the refid attribute is set.
*/ */
protected BuildException noChildrenAllowed() { 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. * loop of data types referencing each other.
*/ */
protected BuildException circularReference() { protected BuildException circularReference() {
return new BuildException("This data type contains a circular reference.");
return new BuildException("This data type contains a circular "
+ "reference.");
} }
} }

+ 2
- 2
src/main/org/apache/tools/ant/types/Environment.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -120,7 +120,7 @@ public class Environment {
return null; return null;
} }
String[] result = new String[variables.size()]; 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(); result[i] = ((Variable) variables.elementAt(i)).getContent();
} }
return result; return result;


+ 1
- 1
src/main/org/apache/tools/ant/types/FileList.java View File

@@ -163,7 +163,7 @@ public class FileList extends DataType {
Object o = ref.getReferencedObject(p); Object o = ref.getReferencedObject(p);
if (!(o instanceof FileList)) { 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); throw new BuildException(msg);
} else { } else {
return (FileList) o; return (FileList) o;


+ 21
- 15
src/main/org/apache/tools/ant/types/FilterSet.java View File

@@ -112,7 +112,7 @@ public class FilterSet extends DataType implements Cloneable {
* *
* @param token The new Token value * @param token The new Token value
*/ */
public void setToken( String token ) {
public void setToken(String token) {
this.token = token; this.token = token;
} }
@@ -121,7 +121,7 @@ public class FilterSet extends DataType implements Cloneable {
* *
* @param value The new Value value * @param value The new Value value
*/ */
public void setValue( String value ) {
public void setValue(String value) {
this.value = value; this.value = value;
} }
@@ -191,7 +191,7 @@ public class FilterSet extends DataType implements Cloneable {
*/ */
protected FilterSet(FilterSet filterset) { protected FilterSet(FilterSet filterset) {
super(); super();
this.filters = (Vector)filterset.getFilters().clone();
this.filters = (Vector) filterset.getFilters().clone();
} }


protected Vector getFilters() { protected Vector getFilters() {
@@ -202,7 +202,7 @@ public class FilterSet extends DataType implements Cloneable {
} }


protected FilterSet getRef() { 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 * @param endOfToken The new Endtoken value
*/ */
public void setEndToken( String endOfToken ) {
public void setEndToken(String endOfToken) {
if (isReference()) { if (isReference()) {
throw tooManyAttributes(); throw tooManyAttributes();
} }
@@ -292,7 +292,7 @@ public class FilterSet extends DataType implements Cloneable {
} }


if (filtersFile.isFile()) { if (filtersFile.isFile()) {
log("Reading filters from " + filtersFile, Project.MSG_VERBOSE );
log("Reading filters from " + filtersFile, Project.MSG_VERBOSE);
FileInputStream in = null; FileInputStream in = null;
try { try {
Properties props = new Properties(); Properties props = new Properties();
@@ -308,10 +308,11 @@ public class FilterSet extends DataType implements Cloneable {
} }
} }
catch (Exception e) { catch (Exception e) {
throw new BuildException( "Could not read filters from file: " + filtersFile );
throw new BuildException("Could not read filters from file: "
+ filtersFile);
} }
finally { finally {
if ( in != null ) {
if (in != null) {
try { try {
in.close(); in.close();
} }
@@ -321,7 +322,8 @@ public class FilterSet extends DataType implements Cloneable {
} }
} }
else { 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; String value = null;
do { do {
int endIndex = line.indexOf(endToken, index + beginToken.length() + 1 );
int endIndex = line.indexOf(endToken,
index + beginToken.length() + 1);
if (endIndex == -1) { if (endIndex == -1) {
break; break;
} }
token = line.substring(index + beginToken.length(), endIndex );
token
= line.substring(index + beginToken.length(), endIndex);
b.append(line.substring(i, index)); b.append(line.substring(i, index));
if (tokens.containsKey(token)) { 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); b.append(value);
i = index + beginToken.length() + token.length() + endToken.length();
i = index + beginToken.length() + token.length()
+ endToken.length();
} }
else { else {
// just append beginToken and search further // just append beginToken and search further
b.append(beginToken); b.append(beginToken);
i = index + beginToken.length(); i = index + beginToken.length();
} }
} while ((index = line.indexOf( beginToken, i )) > -1 );
} while ((index = line.indexOf(beginToken, i)) > -1);
b.append(line.substring(i)); b.append(line.substring(i));
return b.toString(); return b.toString();


+ 2
- 2
src/main/org/apache/tools/ant/types/FilterSetCollection.java View File

@@ -101,7 +101,7 @@ public class FilterSetCollection {
public String replaceTokens(String line) { public String replaceTokens(String line) {
String replacedLine = line; String replacedLine = line;
for (Enumeration e = filterSets.elements(); e.hasMoreElements();) { for (Enumeration e = filterSets.elements(); e.hasMoreElements();) {
FilterSet filterSet = (FilterSet)e.nextElement();
FilterSet filterSet = (FilterSet) e.nextElement();
replacedLine = filterSet.replaceTokens(replacedLine); replacedLine = filterSet.replaceTokens(replacedLine);
} }
return replacedLine; return replacedLine;
@@ -114,7 +114,7 @@ public class FilterSetCollection {
*/ */
public boolean hasFilters() { public boolean hasFilters() {
for (Enumeration e = filterSets.elements(); e.hasMoreElements();) { for (Enumeration e = filterSets.elements(); e.hasMoreElements();) {
FilterSet filterSet = (FilterSet)e.nextElement();
FilterSet filterSet = (FilterSet) e.nextElement();
if (filterSet.hasFilters()) { if (filterSet.hasFilters()) {
return true; return true;
} }


+ 2
- 2
src/main/org/apache/tools/ant/types/Mapper.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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()); Object o = ref.getReferencedObject(getProject());
if (!(o instanceof Mapper)) { 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); throw new BuildException(msg);
} else { } else {
return (Mapper) o; return (Mapper) o;


+ 21
- 18
src/main/org/apache/tools/ant/types/Path.java View File

@@ -241,7 +241,7 @@ public class Path extends DataType implements Cloneable {
return; return;
} }
String[] l = other.list(); 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) { if (elements.indexOf(l[i]) == -1) {
elements.addElement(l[i]); elements.addElement(l[i]);
} }
@@ -256,7 +256,7 @@ public class Path extends DataType implements Cloneable {
*/ */
public void addExisting(Path source) { public void addExisting(Path source) {
String[] list = source.list(); String[] list = source.list();
for (int i=0; i<list.length; i++) {
for (int i = 0; i < list.length; i++) {
File f = null; File f = null;
if (getProject() != null) { if (getProject() != null) {
f = getProject().resolveFile(list[i]); f = getProject().resolveFile(list[i]);
@@ -286,15 +286,15 @@ public class Path extends DataType implements Cloneable {
dieOnCircularReference(stk, getProject()); 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); Object o = elements.elementAt(i);
if (o instanceof Reference) { if (o instanceof Reference) {
Reference r = (Reference) o; Reference r = (Reference) o;
o = r.getReferencedObject(getProject()); o = r.getReferencedObject(getProject());
// we only support references to paths right now // we only support references to paths right now
if (!(o instanceof Path)) { 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); throw new BuildException(msg);
} }
} }
@@ -305,9 +305,10 @@ public class Path extends DataType implements Cloneable {
} else if (o instanceof PathElement) { } else if (o instanceof PathElement) {
String[] parts = ((PathElement) o).getParts(); String[] parts = ((PathElement) o).getParts();
if (parts == null) { 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]); addUnlessPresent(result, parts[j]);
} }
} else if (o instanceof Path) { } else if (o instanceof Path) {
@@ -316,7 +317,7 @@ public class Path extends DataType implements Cloneable {
p.setProject(getProject()); p.setProject(getProject());
} }
String[] parts = p.list(); String[] parts = p.list();
for (int j=0; j<parts.length; j++) {
for (int j = 0; j < parts.length; j++) {
addUnlessPresent(result, parts[j]); addUnlessPresent(result, parts[j]);
} }
} else if (o instanceof DirSet) { } else if (o instanceof DirSet) {
@@ -359,7 +360,7 @@ public class Path extends DataType implements Cloneable {


// path containing one or more elements // path containing one or more elements
final StringBuffer result = new StringBuffer(list[0].toString()); 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(File.pathSeparatorChar);
result.append(list[i]); result.append(list[i]);
} }
@@ -385,10 +386,11 @@ public class Path extends DataType implements Cloneable {
element.append(resolveFile(project, pathElement)); element.append(resolveFile(project, pathElement));
} }
catch (BuildException e) { 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); translateFileSep(element, i);
} }
result.addElement(element.toString()); result.addElement(element.toString());
@@ -408,7 +410,7 @@ public class Path extends DataType implements Cloneable {
} }


final StringBuffer result = new StringBuffer(source); 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); translateFileSep(result, i);
} }


@@ -502,7 +504,7 @@ public class Path extends DataType implements Cloneable {
* to the Vector if they are not already included. * to the Vector if they are not already included.
*/ */
private static void addUnlessPresent(Vector v, File dir, String[] s) { 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]); File d = new File(dir, s[j]);
String absolutePath = d.getAbsolutePath(); String absolutePath = d.getAbsolutePath();
addUnlessPresent(v, translateFile(absolutePath)); 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) { if (System.getProperty("java.vendor").toLowerCase(Locale.US).indexOf("microsoft") >= 0) {
// Pull in *.zip from packages directory // Pull in *.zip from packages directory
FileSet msZipFiles = new FileSet(); 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"); msZipFiles.setIncludes("*.ZIP");
addFileset(msZipFiles); addFileset(msZipFiles);
} else if("Kaffe".equals(System.getProperty("java.vm.name"))) {
} else if ("Kaffe".equals(System.getProperty("java.vm.name"))) {
FileSet kaffeJarFiles = new FileSet(); FileSet kaffeJarFiles = new FileSet();
kaffeJarFiles.setDir(new File(System.getProperty("java.home") kaffeJarFiles.setDir(new File(System.getProperty("java.home")
+ File.separator + "share" + File.separator + "share"
@@ -599,7 +602,7 @@ public class Path extends DataType implements Cloneable {
// sort it out. // sort it out.
addExisting(new Path(null, addExisting(new Path(null,
System.getProperty("java.home") System.getProperty("java.home")
+ File.separator +"jre"
+ File.separator + "jre"
+ File.separator + "lib" + File.separator + "lib"
+ File.separator + "rt.jar")); + File.separator + "rt.jar"));
@@ -635,7 +638,7 @@ public class Path extends DataType implements Cloneable {
} }


String[] dirs = extdirs.list(); 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]); File dir = getProject().resolveFile(dirs[i]);
if (dir.exists() && dir.isDirectory()) { if (dir.exists() && dir.isDirectory()) {
FileSet fs = new FileSet(); FileSet fs = new FileSet();


+ 11
- 11
src/main/org/apache/tools/ant/types/PatternSet.java View File

@@ -173,13 +173,13 @@ public class PatternSet extends DataType {
String[] nestedExcludes = p.getExcludePatterns(getProject()); String[] nestedExcludes = p.getExcludePatterns(getProject());


if (nestedIncludes != null) { if (nestedIncludes != null) {
for (int i=0; i < nestedIncludes.length; i++) {
for (int i = 0; i < nestedIncludes.length; i++) {
createInclude().setName(nestedIncludes[i]); createInclude().setName(nestedIncludes[i]);
} }
} }


if (nestedExcludes != null) { if (nestedExcludes != null) {
for (int i=0; i < nestedExcludes.length; i++) {
for (int i = 0; i < nestedExcludes.length; i++) {
createExclude().setName(nestedExcludes[i]); createExclude().setName(nestedExcludes[i]);
} }
} }
@@ -317,15 +317,15 @@ public class PatternSet extends DataType {
} }
line = patternReader.readLine(); line = patternReader.readLine();
} }
} catch(IOException ioe) {
} catch (IOException ioe) {
String msg = "An error occured while reading from pattern file: " String msg = "An error occured while reading from pattern file: "
+ patternfile; + patternfile;
throw new BuildException(msg, ioe); throw new BuildException(msg, ioe);
} finally { } finally {
if( null != patternReader ) {
if (null != patternReader) {
try { try {
patternReader.close(); patternReader.close();
} catch(IOException ioe) {
} catch (IOException ioe) {
//Ignore exception //Ignore exception
} }
} }
@@ -342,14 +342,14 @@ public class PatternSet extends DataType {


String[] incl = other.getIncludePatterns(p); String[] incl = other.getIncludePatterns(p);
if (incl != null) { if (incl != null) {
for (int i=0; i<incl.length; i++) {
for (int i = 0; i < incl.length; i++) {
createInclude().setName(incl[i]); createInclude().setName(incl[i]);
} }
} }
String[] excl = other.getExcludePatterns(p); String[] excl = other.getExcludePatterns(p);
if (excl != null) { if (excl != null) {
for (int i=0; i<excl.length; i++) {
for (int i = 0; i < excl.length; i++) {
createExclude().setName(excl[i]); createExclude().setName(excl[i]);
} }
} }
@@ -400,7 +400,7 @@ public class PatternSet extends DataType {
Object o = ref.getReferencedObject(p); Object o = ref.getReferencedObject(p);
if (!(o instanceof PatternSet)) { 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); throw new BuildException(msg);
} else { } else {
return (PatternSet) o; return (PatternSet) o;
@@ -417,7 +417,7 @@ public class PatternSet extends DataType {


Vector tmpNames = new Vector(); Vector tmpNames = new Vector();
for (Enumeration e = list.elements() ; e.hasMoreElements() ;) { for (Enumeration e = list.elements() ; e.hasMoreElements() ;) {
NameEntry ne = (NameEntry)e.nextElement();
NameEntry ne = (NameEntry) e.nextElement();
String pattern = ne.evalName(p); String pattern = ne.evalName(p);
if (pattern != null && pattern.length() > 0) { if (pattern != null && pattern.length() > 0) {
tmpNames.addElement(pattern); tmpNames.addElement(pattern);
@@ -436,7 +436,7 @@ public class PatternSet extends DataType {
if (includesFileList.size() > 0) { if (includesFileList.size() > 0) {
Enumeration e = includesFileList.elements(); Enumeration e = includesFileList.elements();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
NameEntry ne = (NameEntry)e.nextElement();
NameEntry ne = (NameEntry) e.nextElement();
String fileName = ne.evalName(p); String fileName = ne.evalName(p);
if (fileName != null) { if (fileName != null) {
File inclFile = p.resolveFile(fileName); File inclFile = p.resolveFile(fileName);
@@ -454,7 +454,7 @@ public class PatternSet extends DataType {
if (excludesFileList.size() > 0) { if (excludesFileList.size() > 0) {
Enumeration e = excludesFileList.elements(); Enumeration e = excludesFileList.elements();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
NameEntry ne = (NameEntry)e.nextElement();
NameEntry ne = (NameEntry) e.nextElement();
String fileName = ne.evalName(p); String fileName = ne.evalName(p);
if (fileName != null) { if (fileName != null) {
File exclFile = p.resolveFile(fileName); File exclFile = p.resolveFile(fileName);


+ 1
- 1
src/main/org/apache/tools/ant/types/Reference.java View File

@@ -90,7 +90,7 @@ public class Reference {
Object o = project.getReference(refid); Object o = project.getReference(refid);
if (o == null) { if (o == null) {
throw new BuildException("Reference "+refid+" not found.");
throw new BuildException("Reference " + refid + " not found.");
} }
return o; return o;
} }


+ 2
- 1
src/main/org/apache/tools/ant/types/RegularExpression.java View File

@@ -153,7 +153,8 @@ public class RegularExpression extends DataType
Object o = ref.getReferencedObject(p); Object o = ref.getReferencedObject(p);
if (!(o instanceof RegularExpression)) 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); throw new BuildException(msg);
} }
else else


+ 2
- 2
src/main/org/apache/tools/ant/types/XMLCatalog.java View File

@@ -228,7 +228,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver {
log("No match, parser will use: '" + systemId + "'", log("No match, parser will use: '" + systemId + "'",
Project.MSG_DEBUG); Project.MSG_DEBUG);
} }
} catch ( IOException ioe) {
} catch (IOException ioe) {
//ignore //ignore
} }
} }
@@ -254,7 +254,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver {
Enumeration elements = getElements().elements(); Enumeration elements = getElements().elements();
DTDLocation element = null; DTDLocation element = null;
while (elements.hasMoreElements()) { while (elements.hasMoreElements()) {
element = (DTDLocation)elements.nextElement();
element = (DTDLocation) elements.nextElement();
if (element.getPublicId().equals(publicId)) { if (element.getPublicId().equals(publicId)) {
return element; return element;
} }


+ 1
- 1
src/main/org/apache/tools/ant/types/ZipFileSet.java View File

@@ -196,7 +196,7 @@ public class ZipFileSet extends FileSet {
Object o = ref.getReferencedObject(p); Object o = ref.getReferencedObject(p);
if (!(o instanceof FileSet)) { 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); throw new BuildException(msg);
} else { } else {
return (AbstractFileSet) o; return (AbstractFileSet) o;


+ 3
- 3
src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java View File

@@ -132,7 +132,7 @@ public class ClassfileSet extends FileSet {
*/ */
protected ClassfileSet(ClassfileSet s) { protected ClassfileSet(ClassfileSet s) {
super(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); return getRef(p).getDirectoryScanner(p);
} }


Vector allRootClasses = (Vector)rootClasses.clone();
Vector allRootClasses = (Vector) rootClasses.clone();
for (Enumeration e = rootFileSets.elements(); e.hasMoreElements();) { for (Enumeration e = rootFileSets.elements(); e.hasMoreElements();) {
FileSet additionalRootSet = (FileSet)e.nextElement();
FileSet additionalRootSet = (FileSet) e.nextElement();
DirectoryScanner additionalScanner DirectoryScanner additionalScanner
= additionalRootSet.getDirectoryScanner(p); = additionalRootSet.getDirectoryScanner(p);
String[] files = additionalScanner.getIncludedFiles(); String[] files = additionalScanner.getIncludedFiles();


+ 4
- 4
src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java View File

@@ -145,7 +145,7 @@ public class DependScanner extends DirectoryScanner {
int count = included.size(); int count = included.size();
String[] files = new String[count]; String[] files = new String[count];
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
files[i] = (String)included.elementAt(i);
files[i] = (String) included.elementAt(i);
} }
return files; return files;
} }
@@ -161,7 +161,7 @@ public class DependScanner extends DirectoryScanner {
DependencyAnalyzer analyzer = null; DependencyAnalyzer analyzer = null;
try { try {
Class analyzerClass = Class.forName(analyzerClassName); Class analyzerClass = Class.forName(analyzerClassName);
analyzer = (DependencyAnalyzer)analyzerClass.newInstance();
analyzer = (DependencyAnalyzer) analyzerClass.newInstance();
} catch (Exception e) { } catch (Exception e) {
throw new BuildException("Unable to load dependency analyzer: " throw new BuildException("Unable to load dependency analyzer: "
+ analyzerClassName, e); + analyzerClassName, e);
@@ -169,7 +169,7 @@ public class DependScanner extends DirectoryScanner {
analyzer.addClassPath(new Path(null, basedir.getPath())); analyzer.addClassPath(new Path(null, basedir.getPath()));
for (Enumeration e = rootClasses.elements(); e.hasMoreElements();) { for (Enumeration e = rootClasses.elements(); e.hasMoreElements();) {
String rootClass = (String)e.nextElement();
String rootClass = (String) e.nextElement();
analyzer.addRootClass(rootClass); analyzer.addRootClass(rootClass);
} }


@@ -182,7 +182,7 @@ public class DependScanner extends DirectoryScanner {
} }


while (e.hasMoreElements()) { while (e.hasMoreElements()) {
String classname = (String)e.nextElement();
String classname = (String) e.nextElement();
String filename = classname.replace('.', File.separatorChar); String filename = classname.replace('.', File.separatorChar);
filename = filename + ".class"; filename = filename + ".class";
File depFile = new File(basedir, filename); File depFile = new File(basedir, filename);


+ 10
- 9
src/main/org/apache/tools/ant/util/DOMElementWriter.java View File

@@ -151,7 +151,7 @@ public class DOMElementWriter {
out.write(lSep); out.write(lSep);
hasChildren = true; hasChildren = true;
} }
write((Element)child, out, indent + 1, indentWith);
write((Element) child, out, indent + 1, indentWith);
break; break;
case Node.TEXT_NODE: case Node.TEXT_NODE:
@@ -160,7 +160,7 @@ public class DOMElementWriter {
case Node.CDATA_SECTION_NODE: case Node.CDATA_SECTION_NODE:
out.write("<![CDATA["); out.write("<![CDATA[");
out.write(encodedata(((Text)child).getData()));
out.write(encodedata(((Text) child).getData()));
out.write("]]>"); out.write("]]>");
break; break;


@@ -174,7 +174,7 @@ public class DOMElementWriter {
out.write("<?"); out.write("<?");
out.write(child.getNodeName()); out.write(child.getNodeName());
String data = child.getNodeValue(); String data = child.getNodeValue();
if ( data != null && data.length() > 0 ) {
if (data != null && data.length() > 0) {
out.write(' '); out.write(' ');
out.write(data); out.write(data);
} }
@@ -206,7 +206,7 @@ public class DOMElementWriter {
*/ */
public String encode(String value) { public String encode(String value) {
sb.setLength(0); sb.setLength(0);
for (int i=0; i<value.length(); i++) {
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i); char c = value.charAt(i);
switch (c) { switch (c) {
case '<': case '<':
@@ -224,7 +224,7 @@ public class DOMElementWriter {
case '&': case '&':
int nextSemi = value.indexOf(";", i); int nextSemi = value.indexOf(";", i);
if (nextSemi < 0 if (nextSemi < 0
|| !isReference(value.substring(i, nextSemi+1))) {
|| !isReference(value.substring(i, nextSemi + 1))) {
sb.append("&amp;"); sb.append("&amp;");
} else { } else {
sb.append('&'); sb.append('&');
@@ -268,14 +268,14 @@ public class DOMElementWriter {
if (ent.charAt(1) == '#') { if (ent.charAt(1) == '#') {
if (ent.charAt(2) == 'x') { if (ent.charAt(2) == 'x') {
try { try {
Integer.parseInt(ent.substring(3, ent.length()-1), 16);
Integer.parseInt(ent.substring(3, ent.length() - 1), 16);
return true; return true;
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
return false; return false;
} }
} else { } else {
try { try {
Integer.parseInt(ent.substring(2, ent.length()-1));
Integer.parseInt(ent.substring(2, ent.length() - 1));
return true; return true;
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
return false; return false;
@@ -284,7 +284,7 @@ public class DOMElementWriter {
} }


String name = ent.substring(1, ent.length() - 1); 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])) { if (name.equals(knownEntities[i])) {
return true; return true;
} }
@@ -296,7 +296,8 @@ public class DOMElementWriter {
* Is the given character allowed inside an XML document? * Is the given character allowed inside an XML document?
* *
* <p>See XML 1.0 2.2 <a * <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 * @since 1.10, Ant 1.5
*/ */


+ 1
- 1
src/main/org/apache/tools/ant/util/DateUtils.java View File

@@ -212,7 +212,7 @@ public final class DateUtils {
*/ */
public static int getPhaseOfMoon(Calendar cal) { public static int getPhaseOfMoon(Calendar cal) {
int dayOfTheYear = cal.get(Calendar.DAY_OF_YEAR); 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; int epact = (11 * yearInMetonicCycle + 18) % 30;
if ((epact == 25 && yearInMetonicCycle > 11) || epact == 24) { if ((epact == 25 && yearInMetonicCycle > 11) || epact == 24) {
epact++; epact++;


+ 16
- 24
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -489,13 +489,10 @@ public class FileUtils {


// deal with absolute files // deal with absolute files
if (!onNetWare) { 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); return normalize(filename);
} }
} else { } else {
@@ -503,9 +500,8 @@ public class FileUtils {
// the path name breaks down when NetWare is a supported platform. // the path name breaks down when NetWare is a supported platform.
// Netware volumes are of the pattern: "data:\" // Netware volumes are of the pattern: "data:\"
int colon = filename.indexOf(":"); int colon = filename.indexOf(":");
if (filename.startsWith(File.separator) ||
(colon > -1)
) {
if (filename.startsWith(File.separator)
|| (colon > -1)) {
return normalize(filename); return normalize(filename);
} }
} }
@@ -562,17 +558,15 @@ public class FileUtils {


if (!onNetWare) { if (!onNetWare) {
if (!path.startsWith(File.separator) && if (!path.startsWith(File.separator) &&
! (path.length() >= 2 &&
!(path.length() >= 2 &&
Character.isLetter(path.charAt(0)) && Character.isLetter(path.charAt(0)) &&
colon == 1)
) {
colon == 1)) {
String msg = path + " is not an absolute path"; String msg = path + " is not an absolute path";
throw new BuildException(msg); throw new BuildException(msg);
} }
} else { } else {
if (!path.startsWith(File.separator) &&
(colon == -1)
) {
if (!path.startsWith(File.separator)
&& (colon == -1)) {
String msg = path + " is not an absolute path"; String msg = path + " is not an absolute path";
throw new BuildException(msg); throw new BuildException(msg);
} }
@@ -585,8 +579,7 @@ public class FileUtils {
path.length() >= 2 && path.length() >= 2 &&
Character.isLetter(path.charAt(0)) && Character.isLetter(path.charAt(0)) &&
path.charAt(1) == ':') || path.charAt(1) == ':') ||
(onNetWare && colon > -1)
) {
(onNetWare && colon > -1)) {


dosWithDrive = true; dosWithDrive = true;


@@ -603,10 +596,9 @@ public class FileUtils {


// Eliminate consecutive slashes after the drive spec // Eliminate consecutive slashes after the drive spec
StringBuffer sbPath = new StringBuffer(); 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] != '\\') || if ((ca[i] != '\\') ||
(ca[i] == '\\' && ca[i - 1] != '\\')
) {
(ca[i] == '\\' && ca[i - 1] != '\\')) {
sbPath.append(ca[i]); sbPath.append(ca[i]);
} }
} }
@@ -618,7 +610,7 @@ public class FileUtils {
path = ""; path = "";
} else if (path.charAt(1) == File.separatorChar) { } else if (path.charAt(1) == File.separatorChar) {
// UNC drive // UNC drive
root = File.separator+File.separator;
root = File.separator + File.separator;
path = path.substring(2); path = path.substring(2);
} else { } else {
root = File.separator; root = File.separator;
@@ -635,7 +627,7 @@ public class FileUtils {
continue; continue;
} else if ("..".equals(thisToken)) { } else if ("..".equals(thisToken)) {
if (s.size() < 2) { if (s.size() < 2) {
throw new BuildException("Cannot resolve path "+orig);
throw new BuildException("Cannot resolve path " + orig);
} else { } else {
s.pop(); s.pop();
} }
@@ -645,7 +637,7 @@ public class FileUtils {
} }


StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (int i=0; i<s.size(); i++) {
for (int i = 0; i < s.size(); i++) {
if (i > 1) { if (i > 1) {
// not before the filesystem root and not after it, since root // not before the filesystem root and not after it, since root
// already contains one // already contains one


+ 3
- 3
src/main/org/apache/tools/ant/util/GlobPatternMapper.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -109,7 +109,7 @@ public class GlobPatternMapper implements FileNameMapper {
fromPostfix = ""; fromPostfix = "";
} else { } else {
fromPrefix = from.substring(0, index); fromPrefix = from.substring(0, index);
fromPostfix = from.substring(index+1);
fromPostfix = from.substring(index + 1);
} }
prefixLength = fromPrefix.length(); prefixLength = fromPrefix.length();
postfixLength = fromPostfix.length(); postfixLength = fromPostfix.length();
@@ -125,7 +125,7 @@ public class GlobPatternMapper implements FileNameMapper {
toPostfix = ""; toPostfix = "";
} else { } else {
toPrefix = to.substring(0, index); toPrefix = to.substring(0, index);
toPostfix = to.substring(index+1);
toPostfix = to.substring(index + 1);
} }
} }




+ 1
- 1
src/main/org/apache/tools/ant/util/LoaderUtils.java View File

@@ -124,7 +124,7 @@ public class LoaderUtils {


try { try {
Thread currentThread = Thread.currentThread(); Thread currentThread = Thread.currentThread();
return (ClassLoader)getContextClassLoader.invoke(currentThread,
return (ClassLoader) getContextClassLoader.invoke(currentThread,
new Object[0]); new Object[0]);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new BuildException throw new BuildException


+ 2
- 2
src/main/org/apache/tools/ant/util/RegexpPatternMapper.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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); Vector v = reg.getGroups(source);
result.setLength(0); result.setLength(0);
for (int i=0; i<to.length; i++) {
for (int i = 0; i < to.length; i++) {
if (to[i] == '\\') { if (to[i] == '\\') {
if (++i < to.length) { if (++i < to.length) {
int value = Character.digit(to[i], 10); int value = Character.digit(to[i], 10);


+ 11
- 11
src/main/org/apache/tools/ant/util/SourceFileScanner.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -115,11 +115,11 @@ public class SourceFileScanner {
} }


Vector v = new Vector(); 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]); String[] targets = mapper.mapFileName(files[i]);
if (targets == null || targets.length == 0) { 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); Project.MSG_VERBOSE);
continue; continue;
} }
@@ -127,23 +127,23 @@ public class SourceFileScanner {
File src = fileUtils.resolveFile(srcDir, files[i]); File src = fileUtils.resolveFile(srcDir, files[i]);


if (src.lastModified() > now) { 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); Project.MSG_WARN);
} }


boolean added = false; boolean added = false;
targetList.setLength(0); 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]); File dest = fileUtils.resolveFile(destDir, targets[j]);
if (!dest.exists()) { 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]); v.addElement(files[i]);
added = true; added = true;
} else if (src.lastModified() > dest.lastModified()) { } 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]); v.addElement(files[i]);
added = true; added = true;
} else { } else {
@@ -155,7 +155,7 @@ public class SourceFileScanner {
} }


if (!added) { if (!added) {
task.log(files[i]+" omitted as "+targetList.toString()
task.log(files[i] + " omitted as " + targetList.toString()
+ (targets.length == 1 ? " is" : " are ") + (targets.length == 1 ? " is" : " are ")
+ " up to date.", Project.MSG_VERBOSE); + " up to date.", Project.MSG_VERBOSE);
} }
@@ -175,7 +175,7 @@ public class SourceFileScanner {
FileNameMapper mapper) { FileNameMapper mapper) {
String[] res = restrict(files, srcDir, destDir, mapper); String[] res = restrict(files, srcDir, destDir, mapper);
File[] result = new File[res.length]; 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]); result[i] = new File(srcDir, res[i]);
} }
return result; return result;


+ 8
- 8
src/main/org/apache/tools/ant/util/StringUtils.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -88,12 +88,12 @@ public final class StringUtils {
Vector elems = new Vector(); Vector elems = new Vector();
int pos = -1; int pos = -1;
int i = 0; int i = 0;
while ( (pos = data.indexOf(ch, i) ) != -1 ){
while ((pos = data.indexOf(ch, i)) != -1){
String elem = data.substring(i, pos); String elem = data.substring(i, pos);
elems.addElement(elem); elems.addElement(elem);
i = pos + 1; i = pos + 1;
} }
elems.addElement( data.substring(i) );
elems.addElement(data.substring(i));
return elems; return elems;
} }


@@ -108,11 +108,11 @@ public final class StringUtils {
StringBuffer buf = new StringBuffer(data.length()); StringBuffer buf = new StringBuffer(data.length());
int pos = -1; int pos = -1;
int i = 0; 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(); i = pos + from.length();
} }
buf.append( data.substring(i) );
buf.append(data.substring(i));
return buf.toString(); return buf.toString();
} }


@@ -121,9 +121,9 @@ public final class StringUtils {
* @param t the exception to get the stacktrace from. * @param t the exception to get the stacktrace from.
* @return the stacktrace from the given exception. * @return the stacktrace from the given exception.
*/ */
public static String getStackTrace(Throwable t){
public static String getStackTrace(Throwable t) {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw,true);
PrintWriter pw = new PrintWriter(sw, true);
t.printStackTrace(pw); t.printStackTrace(pw);
pw.flush(); pw.flush();
pw.close(); pw.close();


+ 8
- 8
src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java View File

@@ -93,8 +93,8 @@ public class AncestorAnalyzer extends AbstractAnalyzer {
Hashtable containers = new Hashtable(); Hashtable containers = new Hashtable();
Hashtable toAnalyze = new Hashtable(); Hashtable toAnalyze = new Hashtable();
Hashtable nextAnalyze = 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); toAnalyze.put(classname, classname);
} }


@@ -102,8 +102,8 @@ public class AncestorAnalyzer extends AbstractAnalyzer {
int maxCount = isClosureRequired() ? MAX_LOOPS : 2; int maxCount = isClosureRequired() ? MAX_LOOPS : 2;
while (toAnalyze.size() != 0 && count++ < maxCount) { while (toAnalyze.size() != 0 && count++ < maxCount) {
nextAnalyze.clear(); 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); dependencies.put(classname, classname);
try { try {
File container = getClassContainer(classname); File container = getClassContainer(classname);
@@ -146,13 +146,13 @@ public class AncestorAnalyzer extends AbstractAnalyzer {
} }


files.removeAllElements(); 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(); 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());
} }
} }




+ 9
- 10
src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java View File

@@ -92,8 +92,8 @@ public class FullAnalyzer extends AbstractAnalyzer {
Hashtable dependencies = new Hashtable(); Hashtable dependencies = new Hashtable();
Hashtable containers = new Hashtable(); Hashtable containers = new Hashtable();
Hashtable toAnalyze = 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); toAnalyze.put(classname, classname);
} }


@@ -101,8 +101,8 @@ public class FullAnalyzer extends AbstractAnalyzer {
int maxCount = isClosureRequired() ? MAX_LOOPS : 2; int maxCount = isClosureRequired() ? MAX_LOOPS : 2;
while (toAnalyze.size() != 0 && count++ < maxCount) { while (toAnalyze.size() != 0 && count++ < maxCount) {
DependencyVisitor dependencyVisitor = new DependencyVisitor(); 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); dependencies.put(classname, classname);
try { try {
File container = getClassContainer(classname); File container = getClassContainer(classname);
@@ -133,7 +133,7 @@ public class FullAnalyzer extends AbstractAnalyzer {
// now recover all the dependencies collected and add to the list. // now recover all the dependencies collected and add to the list.
Enumeration depsEnum = dependencyVisitor.getDependencies(); Enumeration depsEnum = dependencyVisitor.getDependencies();
while (depsEnum.hasMoreElements()) { while (depsEnum.hasMoreElements()) {
String className = (String)depsEnum.nextElement();
String className = (String) depsEnum.nextElement();
if (!dependencies.containsKey(className)) { if (!dependencies.containsKey(className)) {
toAnalyze.put(className, className); toAnalyze.put(className, className);
} }
@@ -141,13 +141,13 @@ public class FullAnalyzer extends AbstractAnalyzer {
} }


files.removeAllElements(); 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(); 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() { protected boolean supportsFileDependencies() {
return true; return true;
} }

} }



+ 1
- 1
src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java View File

@@ -152,7 +152,7 @@ public class JakartaOroMatcher implements RegexpMatcher {
Vector v = new Vector(); Vector v = new Vector();
MatchResult mr = matcher.getMatch(); MatchResult mr = matcher.getMatch();
int cnt = mr.groups(); int cnt = mr.groups();
for (int i=0; i<cnt; i++) {
for (int i = 0; i < cnt; i++) {
v.addElement(mr.group(i)); v.addElement(mr.group(i));
} }
return v; return v;


+ 1
- 1
src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java View File

@@ -77,7 +77,7 @@ public class JakartaOroRegexp extends JakartaOroMatcher implements Regexp
{ {
// translate \1 to $1 so that the Perl5Substitution will work // translate \1 to $1 so that the Perl5Substitution will work
StringBuffer subst = new StringBuffer(); 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); char c = argument.charAt(i);
if (c == '\\') { if (c == '\\') {
if (++i < argument.length()) { if (++i < argument.length()) {


+ 1
- 1
src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java View File

@@ -139,7 +139,7 @@ public class JakartaRegexpMatcher implements RegexpMatcher {
} }
Vector v = new Vector(); Vector v = new Vector();
int cnt = reg.getParenCount(); int cnt = reg.getParenCount();
for (int i=0; i<cnt; i++) {
for (int i = 0; i < cnt; i++) {
v.addElement(reg.getParen(i)); v.addElement(reg.getParen(i));
} }
return v; return v;


+ 1
- 1
src/main/org/apache/tools/ant/util/regexp/JakartaRegexpRegexp.java View File

@@ -86,7 +86,7 @@ public class JakartaRegexpRegexp extends JakartaRegexpMatcher implements Regexp


// replace \1 with the corresponding group // replace \1 with the corresponding group
StringBuffer result = new StringBuffer(); 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); char c = argument.charAt(i);
if (c == '\\') { if (c == '\\') {
if (++i < argument.length()) { if (++i < argument.length()) {


+ 1
- 1
src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java View File

@@ -153,7 +153,7 @@ public class Jdk14RegexpMatcher implements RegexpMatcher {
} }
Vector v = new Vector(); Vector v = new Vector();
int cnt = matcher.groupCount(); int cnt = matcher.groupCount();
for (int i=0; i<=cnt; i++) {
for (int i = 0; i <= cnt; i++) {
v.addElement(matcher.group(i)); v.addElement(matcher.group(i));
} }
return v; return v;


+ 1
- 1
src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java View File

@@ -86,7 +86,7 @@ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp
{ {
// translate \1 to $(1) so that the Matcher will work // translate \1 to $(1) so that the Matcher will work
StringBuffer subst = new StringBuffer(); 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); char c = argument.charAt(i);
if (c == '\\') { if (c == '\\') {
if (++i < argument.length()) { if (++i < argument.length()) {


+ 61
- 61
src/main/org/apache/tools/bzip2/CBZip2InputStream.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -91,8 +91,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
nInUse = 0; nInUse = 0;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
if (inUse[i]) { if (inUse[i]) {
seqToUnseq[nInUse] = (char)i;
unseqToSeq[i] = (char)nInUse;
seqToUnseq[nInUse] = (char) i;
unseqToSeq[i] = (char) nInUse;
nInUse++; nInUse++;
} }
} }
@@ -182,7 +182,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
} }


public int read() { public int read() {
if(streamEnd) {
if (streamEnd) {
return -1; return -1;
} else { } else {
int retChar = currentChar; int retChar = currentChar;
@@ -216,7 +216,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
char magic3, magic4; char magic3, magic4;
magic3 = bsGetUChar(); magic3 = bsGetUChar();
magic4 = bsGetUChar(); magic4 = bsGetUChar();
if(magic3 != 'h' || magic4 < '1' || magic4 > '9') {
if (magic3 != 'h' || magic4 < '1' || magic4 > '9') {
bsFinishedWithStream(); bsFinishedWithStream();
streamEnd = true; streamEnd = true;
return; return;
@@ -316,11 +316,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
int zzi; int zzi;
char thech = 0; char thech = 0;
try { try {
thech = (char)bsStream.read();
} catch(IOException e) {
thech = (char) bsStream.read();
} catch (IOException e) {
compressedStreamEOF(); compressedStreamEOF();
} }
if(thech == -1) {
if (thech == -1) {
compressedStreamEOF(); compressedStreamEOF();
} }
zzi = thech; 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; bsLive -= n;
return v; return v;
} }


private char bsGetUChar() { private char bsGetUChar() {
return (char)bsR(8);
return (char) bsR(8);
} }


private int bsGetint() { private int bsGetint() {
@@ -348,11 +348,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
} }


private int bsGetIntVS(int numBits) { private int bsGetIntVS(int numBits) {
return (int)bsR(numBits);
return (int) bsR(numBits);
} }


private int bsGetInt32() { private int bsGetInt32() {
return (int)bsGetint();
return (int) bsGetint();
} }


private void hbCreateDecodeTables(int[] limit, int[] base, private void hbCreateDecodeTables(int[] limit, int[] base,
@@ -361,8 +361,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
int pp, i, j, vec; int pp, i, j, vec;


pp = 0; 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) { if (length[j] == i) {
perm[pp] = j; perm[pp] = j;
pp++; 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; 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++) { for (i = 0; i < MAX_CODE_LEN; i++) {
@@ -387,12 +387,12 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
vec = 0; vec = 0;


for (i = minLen; i <= maxLen; i++) { 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; vec <<= 1;
} }
for (i = minLen + 1; i <= maxLen; i++) { 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(); makeMaps();
alphaSize = nInUse+2;
alphaSize = nInUse + 2;


/* Now the selectors */ /* Now the selectors */
nGroups = bsR(3); nGroups = bsR(3);
@@ -436,7 +436,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
while (bsR(1) == 1) { while (bsR(1) == 1) {
j++; j++;
} }
selectorMtf[i] = (char)j;
selectorMtf[i] = (char) j;
} }


/* Undo the MTF values for the selectors. */ /* Undo the MTF values for the selectors. */
@@ -451,7 +451,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
v = selectorMtf[i]; v = selectorMtf[i];
tmp = pos[v]; tmp = pos[v];
while (v > 0) { while (v > 0) {
pos[v] = pos[v-1];
pos[v] = pos[v - 1];
v--; v--;
} }
pos[0] = tmp; pos[0] = tmp;
@@ -461,7 +461,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {


/* Now the coding tables */ /* Now the coding tables */
for (t = 0; t < nGroups; t++) { for (t = 0; t < nGroups; t++) {
int curr = bsR ( 5 );
int curr = bsR(5);
for (i = 0; i < alphaSize; i++) { for (i = 0; i < alphaSize; i++) {
while (bsR(1) == 1) { while (bsR(1) == 1) {
if (bsR(1) == 0) { if (bsR(1) == 0) {
@@ -470,7 +470,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
curr--; 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); origPtr = bsGetIntVS(24);


recvDecodingTables(); recvDecodingTables();
EOB = nInUse+1;
EOB = nInUse + 1;
groupNo = -1; groupNo = -1;
groupPos = 0; groupPos = 0;


@@ -539,11 +539,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
int zzi; int zzi;
char thech = 0; char thech = 0;
try { try {
thech = (char)bsStream.read();
} catch(IOException e) {
thech = (char) bsStream.read();
} catch (IOException e) {
compressedStreamEOF(); compressedStreamEOF();
} }
if(thech == -1) {
if (thech == -1) {
compressedStreamEOF(); compressedStreamEOF();
} }
zzi = thech; zzi = thech;
@@ -551,7 +551,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
bsLive += 8; bsLive += 8;
} }
} }
zj = (bsBuff >> (bsLive-1)) & 1;
zj = (bsBuff >> (bsLive - 1)) & 1;
bsLive--; bsLive--;
} }
zvec = (zvec << 1) | zj; zvec = (zvec << 1) | zj;
@@ -559,7 +559,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
nextSym = perm[zt][zvec - base[zt][zn]]; nextSym = perm[zt][zvec - base[zt][zn]];
} }


while(true) {
while (true) {


if (nextSym == EOB) { if (nextSym == EOB) {
break; break;
@@ -571,9 +571,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
int N = 1; int N = 1;
do { do {
if (nextSym == RUNA) { if (nextSym == RUNA) {
s = s + (0+1) * N;
s = s + (0 + 1) * N;
} else if (nextSym == RUNB) { } else if (nextSym == RUNB) {
s = s + (1+1) * N;
s = s + (1 + 1) * N;
} }
N = N * 2; N = N * 2;
{ {
@@ -594,11 +594,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
int zzi; int zzi;
char thech = 0; char thech = 0;
try { try {
thech = (char)bsStream.read();
} catch(IOException e) {
thech = (char) bsStream.read();
} catch (IOException e) {
compressedStreamEOF(); compressedStreamEOF();
} }
if(thech == -1) {
if (thech == -1) {
compressedStreamEOF(); compressedStreamEOF();
} }
zzi = thech; zzi = thech;
@@ -606,7 +606,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
bsLive += 8; bsLive += 8;
} }
} }
zj = (bsBuff >> (bsLive-1)) & 1;
zj = (bsBuff >> (bsLive - 1)) & 1;
bsLive--; bsLive--;
} }
zvec = (zvec << 1) | zj; zvec = (zvec << 1) | zj;
@@ -636,7 +636,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
blockOverrun(); blockOverrun();
} }


tmp = yy[nextSym-1];
tmp = yy[nextSym - 1];
unzftab[seqToUnseq[tmp]]++; unzftab[seqToUnseq[tmp]]++;
ll8[last] = 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]; for (j = nextSym-1; j > 0; j--) yy[j] = yy[j-1];
*/ */


j = nextSym-1;
j = nextSym - 1;
for (; j > 3; j -= 4) { 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--) { for (; j > 0; j--) {
yy[j] = yy[j-1];
yy[j] = yy[j - 1];
} }


yy[0] = tmp; yy[0] = tmp;
@@ -677,8 +677,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
int zzi; int zzi;
char thech = 0; char thech = 0;
try { try {
thech = (char)bsStream.read();
} catch(IOException e) {
thech = (char) bsStream.read();
} catch (IOException e) {
compressedStreamEOF(); compressedStreamEOF();
} }
zzi = thech; zzi = thech;
@@ -686,7 +686,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
bsLive += 8; bsLive += 8;
} }
} }
zj = (bsBuff >> (bsLive-1)) & 1;
zj = (bsBuff >> (bsLive - 1)) & 1;
bsLive--; bsLive--;
} }
zvec = (zvec << 1) | zj; zvec = (zvec << 1) | zj;
@@ -704,14 +704,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {


cftab[0] = 0; cftab[0] = 0;
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
cftab[i] = unzftab[i-1];
cftab[i] = unzftab[i - 1];
} }
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
cftab[i] += cftab[i-1];
cftab[i] += cftab[i - 1];
} }


for (i = 0; i <= last; i++) { for (i = 0; i <= last; i++) {
ch = (char)ll8[i];
ch = (char) ll8[i];
tt[cftab[ch]] = i; tt[cftab[ch]] = i;
cftab[ch]++; cftab[ch]++;
} }
@@ -733,19 +733,19 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
} }


private void setupRandPartA() { private void setupRandPartA() {
if(i2 <= last) {
if (i2 <= last) {
chPrev = ch2; chPrev = ch2;
ch2 = ll8[tPos]; ch2 = ll8[tPos];
tPos = tt[tPos]; tPos = tt[tPos];
if (rNToGo == 0) { if (rNToGo == 0) {
rNToGo = rNums[rTPos]; rNToGo = rNums[rTPos];
rTPos++; rTPos++;
if(rTPos == 512) {
if (rTPos == 512) {
rTPos = 0; rTPos = 0;
} }
} }
rNToGo--; rNToGo--;
ch2 ^= (int)((rNToGo == 1) ? 1 : 0);
ch2 ^= (int) ((rNToGo == 1) ? 1 : 0);
i2++; i2++;


currentChar = ch2; currentChar = ch2;
@@ -759,7 +759,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
} }


private void setupNoRandPartA() { private void setupNoRandPartA() {
if(i2 <= last) {
if (i2 <= last) {
chPrev = ch2; chPrev = ch2;
ch2 = ll8[tPos]; ch2 = ll8[tPos];
tPos = tt[tPos]; tPos = tt[tPos];
@@ -788,7 +788,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
if (rNToGo == 0) { if (rNToGo == 0) {
rNToGo = rNums[rTPos]; rNToGo = rNums[rTPos];
rTPos++; rTPos++;
if(rTPos == 512) {
if (rTPos == 512) {
rTPos = 0; rTPos = 0;
} }
} }
@@ -805,7 +805,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
} }


private void setupRandPartC() { private void setupRandPartC() {
if(j2 < (int)z) {
if (j2 < (int) z) {
currentChar = ch2; currentChar = ch2;
mCrc.updateCRC(ch2); mCrc.updateCRC(ch2);
j2++; j2++;
@@ -838,7 +838,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
} }


private void setupNoRandPartC() { private void setupNoRandPartC() {
if(j2 < (int)z) {
if (j2 < (int) z) {
currentChar = ch2; currentChar = ch2;
mCrc.updateCRC(ch2); mCrc.updateCRC(ch2);
j2++; j2++;
@@ -851,14 +851,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
} }


private void setDecompressStructureSizes(int newSize100k) { private void setDecompressStructureSizes(int newSize100k) {
if (! (0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k
if (!(0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k
&& blockSize100k <= 9)) { && blockSize100k <= 9)) {
// throw new IOException("Invalid block size"); // throw new IOException("Invalid block size");
} }


blockSize100k = newSize100k; blockSize100k = newSize100k;


if(newSize100k == 0) {
if (newSize100k == 0) {
return; return;
} }




+ 113
- 113
src/main/org/apache/tools/bzip2/CBZip2OutputStream.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -99,8 +99,8 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
nInUse = 0; nInUse = 0;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
if (inUse[i]) { if (inUse[i]) {
seqToUnseq[nInUse] = (char)i;
unseqToSeq[i] = (char)nInUse;
seqToUnseq[nInUse] = (char) i;
unseqToSeq[i] = (char) nInUse;
nInUse++; nInUse++;
} }
} }
@@ -120,7 +120,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
int[] parent = new int[MAX_ALPHA_SIZE * 2]; int[] parent = new int[MAX_ALPHA_SIZE * 2];


for (i = 0; i < alphaSize; i++) { 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) { while (true) {
@@ -146,7 +146,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
heap[zz] = tmp; heap[zz] = tmp;
} }
} }
if (!(nHeap < (MAX_ALPHA_SIZE+2))) {
if (!(nHeap < (MAX_ALPHA_SIZE + 2))) {
panic(); panic();
} }


@@ -164,7 +164,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
break; break;
} }
if (yy < nHeap && if (yy < nHeap &&
weight[heap[yy+1]] < weight[heap[yy]]) {
weight[heap[yy + 1]] < weight[heap[yy]]) {
yy++; yy++;
} }
if (weight[tmp] < weight[heap[yy]]) { if (weight[tmp] < weight[heap[yy]]) {
@@ -188,7 +188,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
break; break;
} }
if (yy < nHeap && if (yy < nHeap &&
weight[heap[yy+1]] < weight[heap[yy]]) {
weight[heap[yy + 1]] < weight[heap[yy]]) {
yy++; yy++;
} }
if (weight[tmp] < weight[heap[yy]]) { if (weight[tmp] < weight[heap[yy]]) {
@@ -235,13 +235,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
k = parent[k]; k = parent[k];
j++; j++;
} }
len[i-1] = (char)j;
len[i - 1] = (char) j;
if (j > maxLen) { if (j > maxLen) {
tooLong = true; tooLong = true;
} }
} }


if (! tooLong) {
if (!tooLong) {
break; break;
} }


@@ -325,10 +325,10 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
bsSetStream(inStream); bsSetStream(inStream);


workFactor = 50; workFactor = 50;
if(inBlockSize > 9) {
if (inBlockSize > 9) {
inBlockSize = 9; inBlockSize = 9;
} }
if(inBlockSize < 1) {
if (inBlockSize < 1) {
inBlockSize = 1; inBlockSize = 1;
} }
blockSize100k = inBlockSize; blockSize100k = inBlockSize;
@@ -344,10 +344,10 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
*/ */
public void write(int bv) throws IOException { public void write(int bv) throws IOException {
int b = (256 + bv) % 256; int b = (256 + bv) % 256;
if(currentChar != -1) {
if(currentChar == b) {
if (currentChar != -1) {
if (currentChar == b) {
runLength++; runLength++;
if(runLength > 254) {
if (runLength > 254) {
writeRun(); writeRun();
currentChar = -1; currentChar = -1;
runLength = 0; runLength = 0;
@@ -364,42 +364,42 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
} }


private void writeRun() throws IOException { private void writeRun() throws IOException {
if(last < allowableBlockSize) {
if (last < allowableBlockSize) {
inUse[currentChar] = true; 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) { switch (runLength) {
case 1: case 1:
last++; last++;
block[last + 1] = (char)currentChar;
block[last + 1] = (char) currentChar;
break; break;
case 2: case 2:
last++; last++;
block[last + 1] = (char)currentChar;
block[last + 1] = (char) currentChar;
last++; last++;
block[last + 1] = (char)currentChar;
block[last + 1] = (char) currentChar;
break; break;
case 3: case 3:
last++; last++;
block[last + 1] = (char)currentChar;
block[last + 1] = (char) currentChar;
last++; last++;
block[last + 1] = (char)currentChar;
block[last + 1] = (char) currentChar;
last++; last++;
block[last + 1] = (char)currentChar;
block[last + 1] = (char) currentChar;
break; break;
default: default:
inUse[runLength - 4] = true; inUse[runLength - 4] = true;
last++; last++;
block[last + 1] = (char)currentChar;
block[last + 1] = (char) currentChar;
last++; last++;
block[last + 1] = (char)currentChar;
block[last + 1] = (char) currentChar;
last++; last++;
block[last + 1] = (char)currentChar;
block[last + 1] = (char) currentChar;
last++; last++;
block[last + 1] = (char)currentChar;
block[last + 1] = (char) currentChar;
last++; last++;
block[last + 1] = (char)(runLength - 4);
block[last + 1] = (char) (runLength - 4);
break; break;
} }
} else { } else {
@@ -416,11 +416,11 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
} }


public void close() throws IOException { public void close() throws IOException {
if(closed) {
if (closed) {
return; return;
} }


if(runLength > 0) {
if (runLength > 0) {
writeRun(); writeRun();
} }
currentChar = -1; currentChar = -1;
@@ -460,7 +460,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
last = -1; last = -1;
// ch = 0; // ch = 0;


for(int i = 0; i < 256; i++) {
for (int i = 0; i < 256; i++) {
inUse[i] = false; inUse[i] = false;
} }


@@ -470,7 +470,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {


private void endBlock() throws IOException { private void endBlock() throws IOException {
blockCRC = mCrc.getFinalCRC(); blockCRC = mCrc.getFinalCRC();
combinedCRC = (combinedCRC << 1)|(combinedCRC >>> 31);
combinedCRC = (combinedCRC << 1) | (combinedCRC >>> 31);
combinedCRC ^= blockCRC; combinedCRC ^= blockCRC;


/* sort the block and establish posn of original string */ /* 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. */ /* Now a single bit indicating randomisation. */
if (blockRandomised) { if (blockRandomised) {
bsW(1,1);
bsW(1, 1);
nBlocksRandomised++; nBlocksRandomised++;
} else { } else {
bsW(1,0);
bsW(1, 0);
} }


/* Finally, block's contents proper. */ /* Finally, block's contents proper. */
@@ -561,7 +561,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
try { try {
bsStream.write(ch); // write 8-bit bsStream.write(ch); // write 8-bit
} }
catch(IOException e) {
catch (IOException e) {
throw e; throw e;
} }
bsBuff <<= 8; bsBuff <<= 8;
@@ -576,7 +576,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
try { try {
bsStream.write(ch); // write 8-bit bsStream.write(ch); // write 8-bit
} }
catch(IOException e) {
catch (IOException e) {
throw e; throw e;
} }
bsBuff <<= 8; bsBuff <<= 8;
@@ -612,7 +612,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
alphaSize = nInUse + 2; alphaSize = nInUse + 2;
for (t = 0; t < N_GROUPS; t++) { for (t = 0; t < N_GROUPS; t++) {
for (v = 0; v < alphaSize; v++) { 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; nGroups = 2;
} else if (nMTF < 600) { } else if (nMTF < 600) {
nGroups = 3; nGroups = 3;
} else if (nMTF < 1200) {
} else if (nMTF < 1200) {
nGroups = 4; nGroups = 4;
} else if (nMTF < 2400) {
} else if (nMTF < 2400) {
nGroups = 5; nGroups = 5;
} else {
} else {
nGroups = 6; nGroups = 6;
}
}


/* Generate an initial set of coding tables */ { /* Generate an initial set of coding tables */ {
int nPart, remF, tFreq, aFreq; int nPart, remF, tFreq, aFreq;
@@ -641,29 +641,29 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
gs = 0; gs = 0;
while (nPart > 0) { while (nPart > 0) {
tFreq = remF / nPart; tFreq = remF / nPart;
ge = gs-1;
ge = gs - 1;
aFreq = 0; aFreq = 0;
while (aFreq < tFreq && ge < alphaSize-1) {
while (aFreq < tFreq && ge < alphaSize - 1) {
ge++; ge++;
aFreq += mtfFreq[ge]; aFreq += mtfFreq[ge];
} }


if (ge > gs && nPart != nGroups && nPart != 1 if (ge > gs && nPart != nGroups && nPart != 1
&& ((nGroups-nPart) % 2 == 1)) {
&& ((nGroups - nPart) % 2 == 1)) {
aFreq -= mtfFreq[ge]; aFreq -= mtfFreq[ge];
ge--; ge--;
} }


for (v = 0; v < alphaSize; v++) { for (v = 0; v < alphaSize; v++) {
if (v >= gs && v <= ge) { if (v >= gs && v <= ge) {
len[nPart-1][v] = (char)LESSER_ICOST;
len[nPart - 1][v] = (char) LESSER_ICOST;
} else { } else {
len[nPart-1][v] = (char)GREATER_ICOST;
len[nPart - 1][v] = (char) GREATER_ICOST;
} }
} }


nPart--; nPart--;
gs = ge+1;
gs = ge + 1;
remF -= aFreq; remF -= aFreq;
} }
} }
@@ -696,7 +696,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
} }
ge = gs + G_SIZE - 1; ge = gs + G_SIZE - 1;
if (ge >= nMTF) { if (ge >= nMTF) {
ge = nMTF-1;
ge = nMTF - 1;
} }


/* /*
@@ -748,7 +748,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
}; };
totc += bc; totc += bc;
fave[bt]++; fave[bt]++;
selector[nSelectors] = (char)bt;
selector[nSelectors] = (char) bt;
nSelectors++; nSelectors++;


/* /*
@@ -758,7 +758,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
rfreq[bt][szptr[i]]++; 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[] pos = new char[N_GROUPS];
char ll_i, tmp2, tmp; char ll_i, tmp2, tmp;
for (i = 0; i < nGroups; i++) { for (i = 0; i < nGroups; i++) {
pos[i] = (char)i;
pos[i] = (char) i;
} }
for (i = 0; i < nSelectors; i++) { for (i = 0; i < nSelectors; i++) {
ll_i = selector[i]; ll_i = selector[i];
j = 0; j = 0;
tmp = pos[j]; tmp = pos[j];
while ( ll_i != tmp ) {
while (ll_i != tmp) {
j++; j++;
tmp2 = tmp; tmp2 = tmp;
tmp = pos[j]; tmp = pos[j];
pos[j] = tmp2; pos[j] = tmp2;
} }
pos[0] = tmp; pos[0] = tmp;
selectorMtf[i] = (char)j;
selectorMtf[i] = (char) j;
} }
} }


@@ -841,9 +841,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
nBytes = bytesOut; nBytes = bytesOut;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
if (inUse16[i]) { if (inUse16[i]) {
bsW(1,1);
bsW(1, 1);
} else { } else {
bsW(1,0);
bsW(1, 0);
} }
} }


@@ -851,9 +851,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
if (inUse16[i]) { if (inUse16[i]) {
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {
if (inUse[i * 16 + j]) { if (inUse[i * 16 + j]) {
bsW(1,1);
bsW(1, 1);
} else { } else {
bsW(1,0);
bsW(1, 0);
} }
} }
} }
@@ -863,13 +863,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {


/* Now the selectors. */ /* Now the selectors. */
nBytes = bytesOut; nBytes = bytesOut;
bsW ( 3, nGroups );
bsW ( 15, nSelectors );
bsW (3, nGroups);
bsW (15, nSelectors);
for (i = 0; i < nSelectors; i++) { for (i = 0; i < nSelectors; i++) {
for (j = 0; j < selectorMtf[i]; j++) { for (j = 0; j < selectorMtf[i]; j++) {
bsW(1,1);
bsW(1, 1);
} }
bsW(1,0);
bsW(1, 0);
} }


/* Now the coding tables. */ /* Now the coding tables. */
@@ -880,14 +880,14 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
bsW(5, curr); bsW(5, curr);
for (i = 0; i < alphaSize; i++) { for (i = 0; i < alphaSize; i++) {
while (curr < len[t][i]) { while (curr < len[t][i]) {
bsW(2,2);
bsW(2, 2);
curr++; /* 10 */ curr++; /* 10 */
} }
while (curr > len[t][i]) { while (curr > len[t][i]) {
bsW(2,3);
bsW(2, 3);
curr--; /* 11 */ curr--; /* 11 */
} }
bsW ( 1, 0 );
bsW (1, 0);
} }
} }


@@ -901,14 +901,14 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
} }
ge = gs + G_SIZE - 1; ge = gs + G_SIZE - 1;
if (ge >= nMTF) { if (ge >= nMTF) {
ge = nMTF-1;
ge = nMTF - 1;
} }
for (i = gs; i <= ge; i++) { 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++; selCtr++;
} }
if (!(selCtr == nSelectors)) { if (!(selCtr == nSelectors)) {
@@ -924,7 +924,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {


private OutputStream bsStream; 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 i, j, h, bigN, hp;
int v; int v;


@@ -950,8 +950,8 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
} }
v = zptr[i]; v = zptr[i];
j = 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; j = j - h;
if (j <= (lo + h - 1)) { if (j <= (lo + h - 1)) {
break; break;
@@ -966,8 +966,8 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
} }
v = zptr[i]; v = zptr[i];
j = 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; j = j - h;
if (j <= (lo + h - 1)) { if (j <= (lo + h - 1)) {
break; break;
@@ -982,8 +982,8 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
} }
v = zptr[i]; v = zptr[i];
j = 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; j = j - h;
if (j <= (lo + h - 1)) { if (j <= (lo + h - 1)) {
break; 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; int temp = 0;
while (n > 0) { while (n > 0) {
temp = zptr[p1]; 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; char t;
if (a > b) { if (a > b) {
t = a; t = a;
@@ -1035,11 +1035,11 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
int dd; 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 unLo, unHi, ltLo, gtHi, med, n, m;
int sp, lo, hi, d; int sp, lo, hi, d;
StackElem[] stack = new StackElem[QSORT_STACK_SIZE]; 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(); stack[count] = new StackElem();
} }


@@ -1080,7 +1080,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
if (unLo > unHi) { if (unLo > unHi) {
break; break;
} }
n = ((int)block[zptr[unLo]+d + 1]) - med;
n = ((int) block[zptr[unLo] + d + 1]) - med;
if (n == 0) { if (n == 0) {
int temp = 0; int temp = 0;
temp = zptr[unLo]; temp = zptr[unLo];
@@ -1099,7 +1099,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
if (unLo > unHi) { if (unLo > unHi) {
break; break;
} }
n = ((int)block[zptr[unHi]+d + 1]) - med;
n = ((int) block[zptr[unHi] + d + 1]) - med;
if (n == 0) { if (n == 0) {
int temp = 0; int temp = 0;
temp = zptr[unHi]; temp = zptr[unHi];
@@ -1128,15 +1128,15 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
if (gtHi < ltLo) { if (gtHi < ltLo) {
stack[sp].ll = lo; stack[sp].ll = lo;
stack[sp].hh = hi; stack[sp].hh = hi;
stack[sp].dd = d+1;
stack[sp].dd = d + 1;
sp++; sp++;
continue; 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; n = lo + unLo - ltLo - 1;
m = hi - (gtHi - unHi) + 1; m = hi - (gtHi - unHi) + 1;
@@ -1148,7 +1148,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {


stack[sp].ll = n + 1; stack[sp].ll = n + 1;
stack[sp].hh = m - 1; stack[sp].hh = m - 1;
stack[sp].dd = d+1;
stack[sp].dd = d + 1;
sp++; sp++;


stack[sp].ll = m; stack[sp].ll = m;
@@ -1172,7 +1172,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
set up the overshoot area for block. 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++) { for (i = 0; i < NUM_OVERSHOOT_BYTES; i++) {
block[last + i + 2] = block[(i % (last + 1)) + 1]; block[last + i + 2] = block[(i % (last + 1)) + 1];
} }
@@ -1180,7 +1180,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
quadrant[i] = 0; quadrant[i] = 0;
} }


block[0] = (char)(block[last + 1]);
block[0] = (char) (block[last + 1]);


if (last < 4000) { if (last < 4000) {
/* /*
@@ -1192,7 +1192,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
} }
firstAttempt = false; firstAttempt = false;
workDone = workLimit = 0; workDone = workLimit = 0;
simpleSort ( 0, last, 0 );
simpleSort(0, last, 0);
} else { } else {
numQSorted = 0; numQSorted = 0;
for (i = 0; i <= 255; i++) { for (i = 0; i <= 255; i++) {
@@ -1249,10 +1249,10 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
for (i = h; i <= 255; i++) { for (i = h; i <= 255; i++) {
vv = runningOrder[i]; vv = runningOrder[i];
j = 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; j = j - h;
if (j <= (h - 1)) { if (j <= (h - 1)) {
break; break;
@@ -1282,12 +1282,12 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
*/ */
for (j = 0; j <= 255; j++) { for (j = 0; j <= 255; j++) {
sb = (ss << 8) + j; sb = (ss << 8) + j;
if(!((ftab[sb] & SETMASK) == SETMASK) ) {
if (!((ftab[sb] & SETMASK) == SETMASK)) {
int lo = ftab[sb] & CLEARMASK; int lo = ftab[sb] & CLEARMASK;
int hi = (ftab[sb+1] & CLEARMASK) - 1;
int hi = (ftab[sb + 1] & CLEARMASK) - 1;
if (hi > lo) { if (hi > lo) {
qSort3 ( lo, hi, 2 );
numQSorted += ( hi - lo + 1 );
qSort3(lo, hi, 2);
numQSorted += (hi - lo + 1);
if (workDone > workLimit && firstAttempt) { if (workDone > workLimit && firstAttempt) {
return; return;
} }
@@ -1308,7 +1308,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {


if (i < 255) { if (i < 255) {
int bbStart = ftab[ss << 8] & CLEARMASK; 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; int shifts = 0;


while ((bbSize >> shifts) > 65534) { 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(); panic();
} }
} }
@@ -1338,11 +1338,11 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
} }


for (j = ftab[ss << 8] & CLEARMASK; for (j = ftab[ss << 8] & CLEARMASK;
j < (ftab[(ss+1) << 8] & CLEARMASK); j++) {
j < (ftab[(ss + 1) << 8] & CLEARMASK); j++) {
c1 = block[zptr[j]]; c1 = block[zptr[j]];
if ( ! bigDone[c1] ) {
if (!bigDone[c1]) {
zptr[copy[c1]] = zptr[j] == 0 ? last : zptr[j] - 1; 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++) { for (i = 0; i <= last; i++) {
if (rNToGo == 0) { if (rNToGo == 0) {
rNToGo = (char)rNums[rTPos];
rNToGo = (char) rNums[rTPos];
rTPos++; rTPos++;
if(rTPos == 512) {
if (rTPos == 512) {
rTPos = 0; rTPos = 0;
} }
} }
@@ -1582,7 +1582,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
int EOB; int EOB;


makeMaps(); makeMaps();
EOB = nInUse+1;
EOB = nInUse + 1;


for (i = 0; i <= EOB; i++) { for (i = 0; i <= EOB; i++) {
mtfFreq[i] = 0; mtfFreq[i] = 0;
@@ -1602,7 +1602,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {


j = 0; j = 0;
tmp = yy[j]; tmp = yy[j];
while ( ll_i != tmp ) {
while (ll_i != tmp) {
j++; j++;
tmp2 = tmp; tmp2 = tmp;
tmp = yy[j]; tmp = yy[j];
@@ -1618,12 +1618,12 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
while (true) { while (true) {
switch (zPend % 2) { switch (zPend % 2) {
case 0: case 0:
szptr[wr] = (short)RUNA;
szptr[wr] = (short) RUNA;
wr++; wr++;
mtfFreq[RUNA]++; mtfFreq[RUNA]++;
break; break;
case 1: case 1:
szptr[wr] = (short)RUNB;
szptr[wr] = (short) RUNB;
wr++; wr++;
mtfFreq[RUNB]++; mtfFreq[RUNB]++;
break; break;
@@ -1635,7 +1635,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
}; };
zPend = 0; zPend = 0;
} }
szptr[wr] = (short)(j + 1);
szptr[wr] = (short) (j + 1);
wr++; wr++;
mtfFreq[j + 1]++; mtfFreq[j + 1]++;
} }
@@ -1646,12 +1646,12 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
while (true) { while (true) {
switch (zPend % 2) { switch (zPend % 2) {
case 0: case 0:
szptr[wr] = (short)RUNA;
szptr[wr] = (short) RUNA;
wr++; wr++;
mtfFreq[RUNA]++; mtfFreq[RUNA]++;
break; break;
case 1: case 1:
szptr[wr] = (short)RUNB;
szptr[wr] = (short) RUNB;
wr++; wr++;
mtfFreq[RUNB]++; mtfFreq[RUNB]++;
break; break;
@@ -1663,7 +1663,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
} }
} }


szptr[wr] = (short)EOB;
szptr[wr] = (short) EOB;
wr++; wr++;
mtfFreq[EOB]++; mtfFreq[EOB]++;




+ 2
- 2
src/main/org/apache/tools/bzip2/CRC.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -156,7 +156,7 @@ class CRC {


void updateCRC(int inCh) { void updateCRC(int inCh) {
int temp = (globalCrc >> 24) ^ inCh; int temp = (globalCrc >> 24) ^ inCh;
if(temp < 0) {
if (temp < 0) {
temp = 256 + temp; temp = 256 + temp;
} }
globalCrc = (globalCrc << 8) ^ CRC.crc32Table[temp]; globalCrc = (globalCrc << 8) ^ CRC.crc32Table[temp];


+ 3
- 3
src/main/org/apache/tools/tar/TarEntry.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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) { else if (osname.toLowerCase().indexOf("netware") > -1) {
int colon = name.indexOf(':'); int colon = name.indexOf(':');
if (colon != -1) { 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. * @return An array of TarEntry's for this entry's children.
*/ */
public TarEntry[] getDirectoryEntries() { public TarEntry[] getDirectoryEntries() {
if (this.file == null ||!this.file.isDirectory()) {
if (this.file == null || !this.file.isDirectory()) {
return new TarEntry[0]; return new TarEntry[0];
} }


+ 9
- 9
src/main/org/apache/tools/zip/AsiExtraField.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 * @since 1.1
*/ */
public ZipShort getLocalFileDataLength() { 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 { throws ZipException {


long givenChecksum = (new ZipLong(data, offset)).getValue(); 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.reset();
crc.update(tmp); crc.update(tmp);
long realChecksum = crc.getValue(); long realChecksum = crc.getValue();


+ 22
- 20
src/main/org/apache/tools/zip/ExtraFieldUtils.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 { public static ZipExtraField[] parse(byte[] data) throws ZipException {
Vector v = new Vector(); Vector v = new Vector();
int start = 0; int start = 0;
while (start <= data.length-4) {
while (start <= data.length - 4) {
ZipShort headerId = new ZipShort(data, start); 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 { try {
ZipExtraField ze = createExtraField(headerId); ZipExtraField ze = createExtraField(headerId);
ze.parseFromLocalFileData(data, start+4, length);
ze.parseFromLocalFileData(data, start + 4, length);
v.addElement(ze); v.addElement(ze);
} catch (InstantiationException ie) { } catch (InstantiationException ie) {
throw new ZipException(ie.getMessage()); throw new ZipException(ie.getMessage());
} catch (IllegalAccessException iae) { } catch (IllegalAccessException iae) {
throw new ZipException(iae.getMessage()); throw new ZipException(iae.getMessage());
} }
start += (length+4);
start += (length + 4);
} }
if (start != data.length) { // array not exhausted 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()]; ZipExtraField[] result = new ZipExtraField[v.size()];
@@ -159,20 +161,20 @@ public class ExtraFieldUtils {
* @since 1.1 * @since 1.1
*/ */
public static byte[] mergeLocalFileDataData(ZipExtraField[] data) { 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(); sum += data[i].getLocalFileDataLength().getValue();
} }
byte[] result = new byte[sum]; byte[] result = new byte[sum];
int start = 0; 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(), System.arraycopy(data[i].getHeaderId().getBytes(),
0, result, start, 2); 0, result, start, 2);
System.arraycopy(data[i].getLocalFileDataLength().getBytes(), System.arraycopy(data[i].getLocalFileDataLength().getBytes(),
0, result, start+2, 2);
0, result, start + 2, 2);
byte[] local = data[i].getLocalFileDataData(); 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; return result;
} }
@@ -183,20 +185,20 @@ public class ExtraFieldUtils {
* @since 1.1 * @since 1.1
*/ */
public static byte[] mergeCentralDirectoryData(ZipExtraField[] data) { 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(); sum += data[i].getCentralDirectoryLength().getValue();
} }
byte[] result = new byte[sum]; byte[] result = new byte[sum];
int start = 0; 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(), System.arraycopy(data[i].getHeaderId().getBytes(),
0, result, start, 2); 0, result, start, 2);
System.arraycopy(data[i].getCentralDirectoryLength().getBytes(), System.arraycopy(data[i].getCentralDirectoryLength().getBytes(),
0, result, start+2, 2);
0, result, start + 2, 2);
byte[] local = data[i].getCentralDirectoryData(); 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; return result;
} }


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save