You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2005/02/25 10:51:33 UTC
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/extension Extension.java ExtensionSet.java ExtensionUtil.java JarLibManifestTask.java JarLibResolveTask.java Specification.java
bodewig 2005/02/25 01:51:33
Modified: src/main/org/apache/tools/ant/taskdefs/optional/extension
Extension.java ExtensionSet.java ExtensionUtil.java
JarLibManifestTask.java JarLibResolveTask.java
Specification.java
Log:
fix spelling, name hiding, javadocs and style
Submitted by: Kev Jackson
Revision Changes Path
1.15 +13 -16 ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java
Index: Extension.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Extension.java 12 Nov 2004 11:07:12 -0000 1.14
+++ Extension.java 25 Feb 2005 09:51:33 -0000 1.15
@@ -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");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,8 @@
import java.util.jar.Attributes;
import java.util.jar.Manifest;
+import org.apache.tools.ant.util.StringUtils;
+
/**
* <p>Utility class that represents either an available "Optional Package"
* (formerly known as "Standard Extension") as described in the manifest
@@ -489,54 +491,53 @@
* @return string representation of object.
*/
public String toString() {
- final String lineSeparator = System.getProperty("line.separator");
final String brace = ": ";
final StringBuffer sb = new StringBuffer(EXTENSION_NAME.toString());
sb.append(brace);
sb.append(extensionName);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
if (null != specificationVersion) {
sb.append(SPECIFICATION_VERSION);
sb.append(brace);
sb.append(specificationVersion);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
if (null != specificationVendor) {
sb.append(SPECIFICATION_VENDOR);
sb.append(brace);
sb.append(specificationVendor);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
if (null != implementationVersion) {
sb.append(IMPLEMENTATION_VERSION);
sb.append(brace);
sb.append(implementationVersion);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
if (null != implementationVendorID) {
sb.append(IMPLEMENTATION_VENDOR_ID);
sb.append(brace);
sb.append(implementationVendorID);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
if (null != implementationVendor) {
sb.append(IMPLEMENTATION_VENDOR);
sb.append(brace);
sb.append(implementationVendor);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
if (null != implementationURL) {
sb.append(IMPLEMENTATION_URL);
sb.append(brace);
sb.append(implementationURL);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
return sb.toString();
@@ -683,10 +684,6 @@
* @return the trimmed string or null
*/
private static String getTrimmedString(final String value) {
- if (null == value) {
- return null;
- } else {
- return value.trim();
- }
+ return null == value ? null : value.trim();
}
-}
+}
\ No newline at end of file
1.9 +5 -5 ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionSet.java
Index: ExtensionSet.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionSet.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ExtensionSet.java 9 Mar 2004 16:48:24 -0000 1.8
+++ ExtensionSet.java 25 Feb 2005 09:51:33 -0000 1.9
@@ -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");
* you may not use this file except in compliance with the License.
@@ -73,14 +73,14 @@
/**
* 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
* @throws BuildException if an error occurs
*/
- public Extension[] toExtensions(final Project project)
+ public Extension[] toExtensions(final Project proj)
throws BuildException {
final ArrayList extensionsList = ExtensionUtil.toExtensions(extensions);
- ExtensionUtil.extractExtensions(project, extensionsList, extensionsFilesets);
+ ExtensionUtil.extractExtensions(proj, extensionsList, extensionsFilesets);
return (Extension[]) extensionsList.toArray(new Extension[extensionsList.size()]);
}
1.12 +22 -19 ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java
Index: ExtensionUtil.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ExtensionUtil.java 9 Mar 2004 16:48:24 -0000 1.11
+++ ExtensionUtil.java 25 Feb 2005 09:51:33 -0000 1.12
@@ -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");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,10 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
@@ -37,6 +39,7 @@
* Class is not meant to be instantiated.
*/
private ExtensionUtil() {
+ //all methods static
}
/**
@@ -45,7 +48,7 @@
* @param adapters the list of ExtensionAdapterss to add to convert
* @throws BuildException if an error occurs
*/
- static ArrayList toExtensions(final ArrayList adapters)
+ static ArrayList toExtensions(final List adapters)
throws BuildException {
final ArrayList results = new ArrayList();
@@ -63,35 +66,35 @@
/**
* 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
* @throws BuildException if an error occurs
*/
static void extractExtensions(final Project project,
- final ArrayList librarys,
- final ArrayList fileset)
+ final List libraries,
+ final List fileset)
throws BuildException {
if (!fileset.isEmpty()) {
final Extension[] extensions = getExtensions(project,
fileset);
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,
- final ArrayList librarys)
+ final List libraries)
throws BuildException {
final ArrayList extensions = new ArrayList();
- final Iterator iterator = librarys.iterator();
+ final Iterator iterator = libraries.iterator();
while (iterator.hasNext()) {
final FileSet fileSet = (FileSet) iterator.next();
@@ -123,7 +126,7 @@
* @throws BuildException if there is an error
*/
private static void loadExtensions(final File file,
- final ArrayList extensionList,
+ final List extensionList,
final boolean includeImpl,
final boolean includeURL)
throws BuildException {
@@ -151,7 +154,7 @@
* @param includeImpl false to exclude implementation details
* @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 boolean includeImpl,
final boolean includeURL) {
@@ -189,12 +192,12 @@
}
/**
- * retrieve manifest for specified file.
+ * Retrieve manifest for specified file.
*
* @param file the file
* @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)
throws BuildException {
@@ -209,4 +212,4 @@
throw new BuildException(ioe.getMessage(), ioe);
}
}
-}
+}
\ No newline at end of file
1.11 +3 -4 ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java
Index: JarLibManifestTask.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- JarLibManifestTask.java 15 Nov 2004 14:52:27 -0000 1.10
+++ JarLibManifestTask.java 25 Feb 2005 09:51:33 -0000 1.11
@@ -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");
* you may not use this file except in compliance with the License.
@@ -104,9 +104,8 @@
final String message =
"Can not have multiple extensions defined in one library.";
throw new BuildException(message);
- } else {
- extension = extensionAdapter.toExtension();
}
+ extension = extensionAdapter.toExtension();
}
/**
@@ -309,4 +308,4 @@
return results;
}
-}
+}
\ No newline at end of file
1.12 +9 -11 ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java
Index: JarLibResolveTask.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- JarLibResolveTask.java 9 Mar 2004 16:48:24 -0000 1.11
+++ JarLibResolveTask.java 25 Feb 2005 09:51:33 -0000 1.12
@@ -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");
* you may not use this file except in compliance with the License.
@@ -98,10 +98,10 @@
* Adds location resolver to look for a library in a location
* 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 @@
final String message = "Property Already set to: " + candidate;
if (failOnError) {
throw new BuildException(message);
- } else {
- getProject().log(message, Project.MSG_ERR);
- return;
- }
+ }
+ getProject().log(message, Project.MSG_ERR);
+ return;
}
final int size = resolvers.size();
@@ -201,9 +200,8 @@
"Unable to resolve extension to a file";
if (failOnError) {
throw new BuildException(message);
- } else {
- getProject().log(message, Project.MSG_ERR);
}
+ getProject().log(message, Project.MSG_ERR);
}
/**
@@ -283,4 +281,4 @@
throw new BuildException(message);
}
}
-}
+}
\ No newline at end of file
1.13 +36 -38 ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/Specification.java
Index: Specification.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/Specification.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Specification.java 22 Nov 2004 09:23:33 -0000 1.12
+++ Specification.java 25 Feb 2005 09:51:33 -0000 1.13
@@ -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");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@
import java.util.jar.Attributes;
import java.util.jar.Manifest;
+import org.apache.tools.ant.util.StringUtils;
+
/**
* <p>Utility class that represents either an available "Optional Package"
* (formerly known as "Standard Extension") as described in the manifest
@@ -37,6 +39,9 @@
* @version $Revision$ $Date$
*/
public final class Specification {
+
+ private static final String MISSING = "Missing ";
+
/**
* Manifest Attribute Name object for SPECIFICATION_TITLE.
*/
@@ -320,11 +325,10 @@
public String[] getSections() {
if (null == sections) {
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 @@
* @return string representation of object.
*/
public String toString() {
- final String lineSeparator = System.getProperty("line.separator");
final String brace = ": ";
final StringBuffer sb
= new StringBuffer(SPECIFICATION_TITLE.toString());
sb.append(brace);
sb.append(specificationTitle);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
if (null != specificationVersion) {
sb.append(SPECIFICATION_VERSION);
sb.append(brace);
sb.append(specificationVersion);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
if (null != specificationVendor) {
sb.append(SPECIFICATION_VENDOR);
sb.append(brace);
sb.append(specificationVendor);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
if (null != implementationTitle) {
sb.append(IMPLEMENTATION_TITLE);
sb.append(brace);
sb.append(implementationTitle);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
if (null != implementationVersion) {
sb.append(IMPLEMENTATION_VERSION);
sb.append(brace);
sb.append(implementationVersion);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
if (null != implementationVendor) {
sb.append(IMPLEMENTATION_VENDOR);
sb.append(brace);
sb.append(implementationVendor);
- sb.append(lineSeparator);
+ sb.append(StringUtils.LINE_SEP);
}
return sb.toString();
@@ -521,20 +524,19 @@
final ArrayList sectionsToAdd) {
if (0 == sectionsToAdd.size()) {
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 @@
* @return the trimmed string or null
*/
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 @@
final String specVendor
= getTrimmedString(attributes.getValue(SPECIFICATION_VENDOR));
if (null == specVendor) {
- throw new ParseException("Missing " + SPECIFICATION_VENDOR, 0);
+ throw new ParseException(MISSING + SPECIFICATION_VENDOR, 0);
}
final String specVersion
= getTrimmedString(attributes.getValue(SPECIFICATION_VERSION));
if (null == specVersion) {
- throw new ParseException("Missing " + SPECIFICATION_VERSION, 0);
+ throw new ParseException(MISSING + SPECIFICATION_VERSION, 0);
}
final String impTitle
= getTrimmedString(attributes.getValue(IMPLEMENTATION_TITLE));
if (null == impTitle) {
- throw new ParseException("Missing " + IMPLEMENTATION_TITLE, 0);
+ throw new ParseException(MISSING + IMPLEMENTATION_TITLE, 0);
}
final String impVersion
= getTrimmedString(attributes.getValue(IMPLEMENTATION_VERSION));
if (null == impVersion) {
- throw new ParseException("Missing " + IMPLEMENTATION_VERSION, 0);
+ throw new ParseException(MISSING + IMPLEMENTATION_VERSION, 0);
}
final String impVendor
= getTrimmedString(attributes.getValue(IMPLEMENTATION_VENDOR));
if (null == impVendor) {
- throw new ParseException("Missing " + IMPLEMENTATION_VENDOR, 0);
+ throw new ParseException(MISSING + IMPLEMENTATION_VENDOR, 0);
}
return new Specification(name, specVersion, specVendor,
impTitle, impVersion, impVendor,
new String[]{section});
}
-}
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org