Browse Source

fix spelling, name hiding, javadocs and style

Submitted by:	Kev Jackson


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277732 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
8c08f38c4f
6 changed files with 84 additions and 89 deletions
  1. +12
    -15
      src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java
  2. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionSet.java
  3. +21
    -18
      src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java
  4. +3
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java
  5. +9
    -11
      src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java
  6. +35
    -37
      src/main/org/apache/tools/ant/taskdefs/optional/extension/Specification.java

+ 12
- 15
src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2004 The Apache Software Foundation
* Copyright 2002-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -23,6 +23,8 @@ import java.util.StringTokenizer;
import java.util.jar.Attributes; import java.util.jar.Attributes;
import java.util.jar.Manifest; import java.util.jar.Manifest;


import org.apache.tools.ant.util.StringUtils;

/** /**
* <p>Utility class that represents either an available "Optional Package" * <p>Utility class that represents either an available "Optional Package"
* (formerly known as "Standard Extension") as described in the manifest * (formerly known as "Standard Extension") as described in the manifest
@@ -489,54 +491,53 @@ public final class Extension {
* @return string representation of object. * @return string representation of object.
*/ */
public String toString() { public String toString() {
final String lineSeparator = System.getProperty("line.separator");
final String brace = ": "; final String brace = ": ";


final StringBuffer sb = new StringBuffer(EXTENSION_NAME.toString()); final StringBuffer sb = new StringBuffer(EXTENSION_NAME.toString());
sb.append(brace); sb.append(brace);
sb.append(extensionName); sb.append(extensionName);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);


if (null != specificationVersion) { if (null != specificationVersion) {
sb.append(SPECIFICATION_VERSION); sb.append(SPECIFICATION_VERSION);
sb.append(brace); sb.append(brace);
sb.append(specificationVersion); sb.append(specificationVersion);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


if (null != specificationVendor) { if (null != specificationVendor) {
sb.append(SPECIFICATION_VENDOR); sb.append(SPECIFICATION_VENDOR);
sb.append(brace); sb.append(brace);
sb.append(specificationVendor); sb.append(specificationVendor);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


if (null != implementationVersion) { if (null != implementationVersion) {
sb.append(IMPLEMENTATION_VERSION); sb.append(IMPLEMENTATION_VERSION);
sb.append(brace); sb.append(brace);
sb.append(implementationVersion); sb.append(implementationVersion);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


if (null != implementationVendorID) { if (null != implementationVendorID) {
sb.append(IMPLEMENTATION_VENDOR_ID); sb.append(IMPLEMENTATION_VENDOR_ID);
sb.append(brace); sb.append(brace);
sb.append(implementationVendorID); sb.append(implementationVendorID);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


if (null != implementationVendor) { if (null != implementationVendor) {
sb.append(IMPLEMENTATION_VENDOR); sb.append(IMPLEMENTATION_VENDOR);
sb.append(brace); sb.append(brace);
sb.append(implementationVendor); sb.append(implementationVendor);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


if (null != implementationURL) { if (null != implementationURL) {
sb.append(IMPLEMENTATION_URL); sb.append(IMPLEMENTATION_URL);
sb.append(brace); sb.append(brace);
sb.append(implementationURL); sb.append(implementationURL);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


return sb.toString(); return sb.toString();
@@ -683,10 +684,6 @@ public final class Extension {
* @return the trimmed string or null * @return the trimmed string or null
*/ */
private static String getTrimmedString(final String value) { private static String getTrimmedString(final String value) {
if (null == value) {
return null;
} else {
return value.trim();
}
return null == value ? null : value.trim();
} }
}
}

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

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002,2004 The Apache Software Foundation
* Copyright 2002,2004-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -73,14 +73,14 @@ public class ExtensionSet
/** /**
* Extract a set of Extension objects from the ExtensionSet. * Extract a set of Extension objects from the ExtensionSet.
* *
* @param project the project instance.
* @param proj the project instance.
* @return an array containing the Extensions from this set * @return an array containing the Extensions from this set
* @throws BuildException if an error occurs * @throws BuildException if an error occurs
*/ */
public Extension[] toExtensions(final Project project)
public Extension[] toExtensions(final Project proj)
throws BuildException { throws BuildException {
final ArrayList extensionsList = ExtensionUtil.toExtensions(extensions); final ArrayList extensionsList = ExtensionUtil.toExtensions(extensions);
ExtensionUtil.extractExtensions(project, extensionsList, extensionsFilesets);
ExtensionUtil.extractExtensions(proj, extensionsList, extensionsFilesets);
return (Extension[]) extensionsList.toArray(new Extension[extensionsList.size()]); return (Extension[]) extensionsList.toArray(new Extension[extensionsList.size()]);
} }




+ 21
- 18
src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2004 The Apache Software Foundation
* Copyright 2002-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,8 +20,10 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.jar.Manifest; import java.util.jar.Manifest;

import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
@@ -37,6 +39,7 @@ public class ExtensionUtil {
* Class is not meant to be instantiated. * Class is not meant to be instantiated.
*/ */
private ExtensionUtil() { private ExtensionUtil() {
//all methods static
} }


/** /**
@@ -45,7 +48,7 @@ public class ExtensionUtil {
* @param adapters the list of ExtensionAdapterss to add to convert * @param adapters the list of ExtensionAdapterss to add to convert
* @throws BuildException if an error occurs * @throws BuildException if an error occurs
*/ */
static ArrayList toExtensions(final ArrayList adapters)
static ArrayList toExtensions(final List adapters)
throws BuildException { throws BuildException {
final ArrayList results = new ArrayList(); final ArrayList results = new ArrayList();


@@ -63,35 +66,35 @@ public class ExtensionUtil {
/** /**
* Generate a list of extensions from a specified fileset. * Generate a list of extensions from a specified fileset.
* *
* @param librarys the list to add extensions to
* @param libraries the list to add extensions to
* @param fileset the filesets containing librarys * @param fileset the filesets containing librarys
* @throws BuildException if an error occurs * @throws BuildException if an error occurs
*/ */
static void extractExtensions(final Project project, static void extractExtensions(final Project project,
final ArrayList librarys,
final ArrayList fileset)
final List libraries,
final List fileset)
throws BuildException { throws BuildException {
if (!fileset.isEmpty()) { if (!fileset.isEmpty()) {
final Extension[] extensions = getExtensions(project, final Extension[] extensions = getExtensions(project,
fileset); fileset);
for (int i = 0; i < extensions.length; i++) { for (int i = 0; i < extensions.length; i++) {
librarys.add(extensions[ i ]);
libraries.add(extensions[ i ]);
} }
} }
} }


/** /**
* Retrieve extensions from the specified librarys.
* Retrieve extensions from the specified libraries.
* *
* @param librarys the filesets for librarys
* @return the extensions contained in librarys
* @throws BuildException if failing to scan librarys
* @param libraries the filesets for libraries
* @return the extensions contained in libraries
* @throws BuildException if failing to scan libraries
*/ */
private static Extension[] getExtensions(final Project project, private static Extension[] getExtensions(final Project project,
final ArrayList librarys)
final List libraries)
throws BuildException { throws BuildException {
final ArrayList extensions = new ArrayList(); final ArrayList extensions = new ArrayList();
final Iterator iterator = librarys.iterator();
final Iterator iterator = libraries.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
final FileSet fileSet = (FileSet) iterator.next(); final FileSet fileSet = (FileSet) iterator.next();


@@ -123,7 +126,7 @@ public class ExtensionUtil {
* @throws BuildException if there is an error * @throws BuildException if there is an error
*/ */
private static void loadExtensions(final File file, private static void loadExtensions(final File file,
final ArrayList extensionList,
final List extensionList,
final boolean includeImpl, final boolean includeImpl,
final boolean includeURL) final boolean includeURL)
throws BuildException { throws BuildException {
@@ -151,7 +154,7 @@ public class ExtensionUtil {
* @param includeImpl false to exclude implementation details * @param includeImpl false to exclude implementation details
* @param includeURL false to exclude implementation URL * @param includeURL false to exclude implementation URL
*/ */
private static void addExtension(final ArrayList extensionList,
private static void addExtension(final List extensionList,
final Extension originalExtension, final Extension originalExtension,
final boolean includeImpl, final boolean includeImpl,
final boolean includeURL) { final boolean includeURL) {
@@ -189,12 +192,12 @@ public class ExtensionUtil {
} }


/** /**
* retrieve manifest for specified file.
* Retrieve manifest for specified file.
* *
* @param file the file * @param file the file
* @return the manifest * @return the manifest
* @throws BuildException if errror occurs (file not exist,
* file not a jar, manifest not exist in file)
* @throws BuildException if errror occurs (file doesn't exist,
* file not a jar, manifest doesn't exist in file)
*/ */
static Manifest getManifest(final File file) static Manifest getManifest(final File file)
throws BuildException { throws BuildException {
@@ -209,4 +212,4 @@ public class ExtensionUtil {
throw new BuildException(ioe.getMessage(), ioe); throw new BuildException(ioe.getMessage(), ioe);
} }
} }
}
}

+ 3
- 4
src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2004 The Apache Software Foundation
* Copyright 2002-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -104,9 +104,8 @@ public final class JarLibManifestTask extends Task {
final String message = final String message =
"Can not have multiple extensions defined in one library."; "Can not have multiple extensions defined in one library.";
throw new BuildException(message); throw new BuildException(message);
} else {
extension = extensionAdapter.toExtension();
} }
extension = extensionAdapter.toExtension();
} }


/** /**
@@ -309,4 +308,4 @@ public final class JarLibManifestTask extends Task {


return results; return results;
} }
}
}

+ 9
- 11
src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2004 The Apache Software Foundation
* Copyright 2002-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -98,10 +98,10 @@ public class JarLibResolveTask extends Task {
* Adds location resolver to look for a library in a location * Adds location resolver to look for a library in a location
* relative to project directory. * relative to project directory.
* *
* @param location the resolver location to search.
* @param loc the resolver location to search.
*/ */
public void addConfiguredLocation(final LocationResolver location) {
resolvers.add(location);
public void addConfiguredLocation(final LocationResolver loc) {
resolvers.add(loc);
} }


/** /**
@@ -155,10 +155,9 @@ public class JarLibResolveTask extends Task {
final String message = "Property Already set to: " + candidate; final String message = "Property Already set to: " + candidate;
if (failOnError) { if (failOnError) {
throw new BuildException(message); throw new BuildException(message);
} else {
getProject().log(message, Project.MSG_ERR);
return;
}
}
getProject().log(message, Project.MSG_ERR);
return;
} }


final int size = resolvers.size(); final int size = resolvers.size();
@@ -201,9 +200,8 @@ public class JarLibResolveTask extends Task {
"Unable to resolve extension to a file"; "Unable to resolve extension to a file";
if (failOnError) { if (failOnError) {
throw new BuildException(message); throw new BuildException(message);
} else {
getProject().log(message, Project.MSG_ERR);
} }
getProject().log(message, Project.MSG_ERR);
} }


/** /**
@@ -283,4 +281,4 @@ public class JarLibResolveTask extends Task {
throw new BuildException(message); throw new BuildException(message);
} }
} }
}
}

+ 35
- 37
src/main/org/apache/tools/ant/taskdefs/optional/extension/Specification.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002,2004 The Apache Software Foundation
* Copyright 2002,2004-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@ import java.util.Map;
import java.util.jar.Attributes; import java.util.jar.Attributes;
import java.util.jar.Manifest; import java.util.jar.Manifest;


import org.apache.tools.ant.util.StringUtils;

/** /**
* <p>Utility class that represents either an available "Optional Package" * <p>Utility class that represents either an available "Optional Package"
* (formerly known as "Standard Extension") as described in the manifest * (formerly known as "Standard Extension") as described in the manifest
@@ -37,6 +39,9 @@ import java.util.jar.Manifest;
* @version $Revision$ $Date$ * @version $Revision$ $Date$
*/ */
public final class Specification { public final class Specification {
private static final String MISSING = "Missing ";
/** /**
* Manifest Attribute Name object for SPECIFICATION_TITLE. * Manifest Attribute Name object for SPECIFICATION_TITLE.
*/ */
@@ -320,11 +325,10 @@ public final class Specification {
public String[] getSections() { public String[] getSections() {
if (null == sections) { if (null == sections) {
return null; return null;
} else {
final String[] newSections = new String[ sections.length ];
System.arraycopy(sections, 0, newSections, 0, sections.length);
return newSections;
}
}
final String[] newSections = new String[ sections.length ];
System.arraycopy(sections, 0, newSections, 0, sections.length);
return newSections;
} }


/** /**
@@ -394,48 +398,47 @@ public final class Specification {
* @return string representation of object. * @return string representation of object.
*/ */
public String toString() { public String toString() {
final String lineSeparator = System.getProperty("line.separator");
final String brace = ": "; final String brace = ": ";


final StringBuffer sb final StringBuffer sb
= new StringBuffer(SPECIFICATION_TITLE.toString()); = new StringBuffer(SPECIFICATION_TITLE.toString());
sb.append(brace); sb.append(brace);
sb.append(specificationTitle); sb.append(specificationTitle);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);


if (null != specificationVersion) { if (null != specificationVersion) {
sb.append(SPECIFICATION_VERSION); sb.append(SPECIFICATION_VERSION);
sb.append(brace); sb.append(brace);
sb.append(specificationVersion); sb.append(specificationVersion);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


if (null != specificationVendor) { if (null != specificationVendor) {
sb.append(SPECIFICATION_VENDOR); sb.append(SPECIFICATION_VENDOR);
sb.append(brace); sb.append(brace);
sb.append(specificationVendor); sb.append(specificationVendor);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


if (null != implementationTitle) { if (null != implementationTitle) {
sb.append(IMPLEMENTATION_TITLE); sb.append(IMPLEMENTATION_TITLE);
sb.append(brace); sb.append(brace);
sb.append(implementationTitle); sb.append(implementationTitle);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


if (null != implementationVersion) { if (null != implementationVersion) {
sb.append(IMPLEMENTATION_VERSION); sb.append(IMPLEMENTATION_VERSION);
sb.append(brace); sb.append(brace);
sb.append(implementationVersion); sb.append(implementationVersion);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


if (null != implementationVendor) { if (null != implementationVendor) {
sb.append(IMPLEMENTATION_VENDOR); sb.append(IMPLEMENTATION_VENDOR);
sb.append(brace); sb.append(brace);
sb.append(implementationVendor); sb.append(implementationVendor);
sb.append(lineSeparator);
sb.append(StringUtils.LINE_SEP);
} }


return sb.toString(); return sb.toString();
@@ -521,20 +524,19 @@ public final class Specification {
final ArrayList sectionsToAdd) { final ArrayList sectionsToAdd) {
if (0 == sectionsToAdd.size()) { if (0 == sectionsToAdd.size()) {
return specification; return specification;
} else {
sectionsToAdd.addAll(Arrays.asList(specification.getSections()));

final String[] sections =
(String[]) sectionsToAdd.toArray(new String[sectionsToAdd.size()]);

return new Specification(specification.getSpecificationTitle(),
specification.getSpecificationVersion().toString(),
specification.getSpecificationVendor(),
specification.getImplementationTitle(),
specification.getImplementationVersion(),
specification.getImplementationVendor(),
sections);
} }
sectionsToAdd.addAll(Arrays.asList(specification.getSections()));
final String[] sections =
(String[]) sectionsToAdd.toArray(new String[sectionsToAdd.size()]);
return new Specification(specification.getSpecificationTitle(),
specification.getSpecificationVersion().toString(),
specification.getSpecificationVendor(),
specification.getImplementationTitle(),
specification.getImplementationVersion(),
specification.getImplementationVendor(),
sections);
} }


/** /**
@@ -544,11 +546,7 @@ public final class Specification {
* @return the trimmed string or null * @return the trimmed string or null
*/ */
private static String getTrimmedString(final String value) { private static String getTrimmedString(final String value) {
if (null == value) {
return null;
} else {
return value.trim();
}
return value == null ? null : value.trim();
} }


/** /**
@@ -572,35 +570,35 @@ public final class Specification {
final String specVendor final String specVendor
= getTrimmedString(attributes.getValue(SPECIFICATION_VENDOR)); = getTrimmedString(attributes.getValue(SPECIFICATION_VENDOR));
if (null == specVendor) { if (null == specVendor) {
throw new ParseException("Missing " + SPECIFICATION_VENDOR, 0);
throw new ParseException(MISSING + SPECIFICATION_VENDOR, 0);
} }


final String specVersion final String specVersion
= getTrimmedString(attributes.getValue(SPECIFICATION_VERSION)); = getTrimmedString(attributes.getValue(SPECIFICATION_VERSION));
if (null == specVersion) { if (null == specVersion) {
throw new ParseException("Missing " + SPECIFICATION_VERSION, 0);
throw new ParseException(MISSING + SPECIFICATION_VERSION, 0);
} }


final String impTitle final String impTitle
= getTrimmedString(attributes.getValue(IMPLEMENTATION_TITLE)); = getTrimmedString(attributes.getValue(IMPLEMENTATION_TITLE));
if (null == impTitle) { if (null == impTitle) {
throw new ParseException("Missing " + IMPLEMENTATION_TITLE, 0);
throw new ParseException(MISSING + IMPLEMENTATION_TITLE, 0);
} }


final String impVersion final String impVersion
= getTrimmedString(attributes.getValue(IMPLEMENTATION_VERSION)); = getTrimmedString(attributes.getValue(IMPLEMENTATION_VERSION));
if (null == impVersion) { if (null == impVersion) {
throw new ParseException("Missing " + IMPLEMENTATION_VERSION, 0);
throw new ParseException(MISSING + IMPLEMENTATION_VERSION, 0);
} }


final String impVendor final String impVendor
= getTrimmedString(attributes.getValue(IMPLEMENTATION_VENDOR)); = getTrimmedString(attributes.getValue(IMPLEMENTATION_VENDOR));
if (null == impVendor) { if (null == impVendor) {
throw new ParseException("Missing " + IMPLEMENTATION_VENDOR, 0);
throw new ParseException(MISSING + IMPLEMENTATION_VENDOR, 0);
} }


return new Specification(name, specVersion, specVendor, return new Specification(name, specVersion, specVendor,
impTitle, impVersion, impVendor, impTitle, impVersion, impVendor,
new String[]{section}); new String[]{section});
} }
}
}

Loading…
Cancel
Save