diff --git a/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java b/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java index e74188849..5483df82b 100644 --- a/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java +++ b/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java @@ -35,13 +35,24 @@ import org.apache.tools.bzip2.CBZip2OutputStream; public class BZip2Resource extends CompressedResource { private static final char[] MAGIC = new char[] {'B', 'Z'}; + /** A no-arg constructor */ public BZip2Resource() { } + /** + * Constructor with another resource to wrap. + * @param other the resource to wrap. + */ public BZip2Resource(org.apache.tools.ant.types.ResourceCollection other) { super(other); } + /** + * Decompress on the fly using {@link CBZip2InputStream}. + * @param in the stream to wrap. + * @return the wrapped stream. + * @throws IOException if there is a problem. + */ protected InputStream wrapStream(InputStream in) throws IOException { for (int i = 0; i < MAGIC.length; i++) { if (in.read() != MAGIC[i]) { @@ -50,13 +61,25 @@ public class BZip2Resource extends CompressedResource { } return new CBZip2InputStream(in); } + + /** + * Compress on the fly using {@link CBZip2OuputStream}. + * @param out the stream to wrap. + * @return the wrapped stream. + * @throws IOException if there is a problem. + */ protected OutputStream wrapStream(OutputStream out) throws IOException { for (int i = 0; i < MAGIC.length; i++) { out.write(MAGIC[i]); } return new CBZip2OutputStream(out); } + + /** + * Get the name of the compression method. + * @return the string "Bzip2". + */ protected String getCompressionName() { return "Bzip2"; } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java b/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java index fd05b256e..2a7685e45 100644 --- a/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java +++ b/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java @@ -112,7 +112,7 @@ public abstract class BaseResourceCollectionContainer * are added to this container while the Iterator is in use. * @return a "fail-fast" Iterator. */ - public synchronized final Iterator iterator() { + public final synchronized Iterator iterator() { if (isReference()) { return ((BaseResourceCollectionContainer) getCheckedRef()).iterator(); } @@ -190,7 +190,7 @@ public abstract class BaseResourceCollectionContainer * Get the nested ResourceCollections. * @return List. */ - protected synchronized final List getResourceCollections() { + protected final synchronized List getResourceCollections() { dieOnCircularReference(); return Collections.unmodifiableList(rc); } diff --git a/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java b/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java index 51c20955f..d18c19669 100644 --- a/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java +++ b/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java @@ -80,7 +80,7 @@ public abstract class BaseResourceCollectionWrapper * Fulfill the ResourceCollection contract. * @return an Iterator of Resources. */ - public synchronized final Iterator iterator() { + public final synchronized Iterator iterator() { if (isReference()) { return ((BaseResourceCollectionWrapper) getCheckedRef()).iterator(); } @@ -152,7 +152,7 @@ public abstract class BaseResourceCollectionWrapper * @return a ResourceCollection. * @throws BuildException if no nested ResourceCollection has been provided. */ - protected synchronized final ResourceCollection getResourceCollection() { + protected final synchronized ResourceCollection getResourceCollection() { dieOnCircularReference(); if (rc == null) { throw oneNested(); diff --git a/src/main/org/apache/tools/ant/types/resources/FailFast.java b/src/main/org/apache/tools/ant/types/resources/FailFast.java index 222ff7443..5c1ff0a9a 100644 --- a/src/main/org/apache/tools/ant/types/resources/FailFast.java +++ b/src/main/org/apache/tools/ant/types/resources/FailFast.java @@ -30,30 +30,30 @@ import java.util.ConcurrentModificationException; * @since Ant 1.7 */ /*package-private*/ class FailFast implements Iterator { - private static final WeakHashMap map = new WeakHashMap(); + private static final WeakHashMap MAP = new WeakHashMap(); /** * Invalidate any in-use Iterators from the specified Object. * @param o the parent Object. */ static synchronized void invalidate(Object o) { - Set s = (Set) (map.get(o)); + Set s = (Set) (MAP.get(o)); if (s != null) { s.clear(); } } private static synchronized void add(FailFast f) { - Set s = (Set) (map.get(f.parent)); + Set s = (Set) (MAP.get(f.parent)); if (s == null) { s = new HashSet(); - map.put(f.parent, s); + MAP.put(f.parent, s); } s.add(f); } private static synchronized void remove(FailFast f) { - Set s = (Set) (map.get(f.parent)); + Set s = (Set) (MAP.get(f.parent)); if (s != null) { s.remove(f); } diff --git a/src/main/org/apache/tools/ant/types/resources/Files.java b/src/main/org/apache/tools/ant/types/resources/Files.java index b34066811..810a259fc 100644 --- a/src/main/org/apache/tools/ant/types/resources/Files.java +++ b/src/main/org/apache/tools/ant/types/resources/Files.java @@ -81,6 +81,7 @@ public class Files extends AbstractSelectorContainer *
You must not set another attribute or nest elements inside * this element if you make it a reference.
* @param r theReference to use.
+ * @throws BuildException if there is a problem.
*/
public void setRefid(Reference r) throws BuildException {
if (hasPatterns(defaultPatterns)) {
@@ -221,6 +222,7 @@ public class Files extends AbstractSelectorContainer
* Set the File containing the includes patterns.
*
* @param incl File instance.
+ * @throws BuildException if there is a problem.
*/
public synchronized void setIncludesfile(File incl) throws BuildException {
checkAttributesAllowed();
@@ -232,6 +234,7 @@ public class Files extends AbstractSelectorContainer
* Set the File containing the excludes patterns.
*
* @param excl File instance.
+ * @throws BuildException if there is a problem.
*/
public synchronized void setExcludesfile(File excl) throws BuildException {
checkAttributesAllowed();
@@ -252,6 +255,7 @@ public class Files extends AbstractSelectorContainer
/**
* Get whether default exclusions should be used or not.
+ * @return the defaultexclusions value.
*/
public synchronized boolean getDefaultexcludes() {
return (isReference())
diff --git a/src/main/org/apache/tools/ant/types/resources/GZipResource.java b/src/main/org/apache/tools/ant/types/resources/GZipResource.java
index 0eddfc84a..c1fe879f3 100644
--- a/src/main/org/apache/tools/ant/types/resources/GZipResource.java
+++ b/src/main/org/apache/tools/ant/types/resources/GZipResource.java
@@ -33,20 +33,43 @@ import java.util.zip.GZIPOutputStream;
*/
public class GZipResource extends CompressedResource {
+ /** A no-arg constructor */
public GZipResource() {
}
+ /**
+ * Constructor with another resource to wrap.
+ * @param other the resource to wrap.
+ */
public GZipResource(org.apache.tools.ant.types.ResourceCollection other) {
super(other);
}
+ /**
+ * Decompress on the fly using java.util.zip.GZIPInputStream.
+ * @param in the stream to wrap.
+ * @return the wrapped stream.
+ * @throws IOException if there is a problem.
+ */
protected InputStream wrapStream(InputStream in) throws IOException {
return new GZIPInputStream(in);
}
- protected OutputStream wrapStream(OutputStream out) throws IOException {
+
+ /**
+ * Compress on the fly using java.util.zip.GZIPOutStream.
+ * @param out the stream to wrap.
+ * @return the wrapped stream.
+ * @throws IOException if there is a problem.
+ */
+ protected OutputStream wrapStream(OutputStream out) throws IOException {
return new GZIPOutputStream(out);
}
+
+ /**
+ * Get the name of the compression method.
+ * @return the string "GZip".
+ */
protected String getCompressionName() {
return "GZip";
}
-}
\ No newline at end of file
+}
diff --git a/src/main/org/apache/tools/ant/types/resources/Resources.java b/src/main/org/apache/tools/ant/types/resources/Resources.java
index a229bf7b6..252619b54 100644
--- a/src/main/org/apache/tools/ant/types/resources/Resources.java
+++ b/src/main/org/apache/tools/ant/types/resources/Resources.java
@@ -61,7 +61,7 @@ public class Resources extends DataType implements ResourceCollection {
};
private class MyCollection extends AbstractCollection {
- int size;
+ private int size;
MyCollection() {
size = 0;
@@ -76,8 +76,8 @@ public class Resources extends DataType implements ResourceCollection {
return new MyIterator();
}
private class MyIterator implements Iterator {
- Iterator rci = rc.iterator();
- Iterator ri = null;
+ private Iterator rci = rc.iterator();
+ private Iterator ri = null;
public boolean hasNext() {
boolean result = ri != null && ri.hasNext();
diff --git a/src/main/org/apache/tools/ant/types/resources/Sort.java b/src/main/org/apache/tools/ant/types/resources/Sort.java
index ee32c975a..c6cb015eb 100644
--- a/src/main/org/apache/tools/ant/types/resources/Sort.java
+++ b/src/main/org/apache/tools/ant/types/resources/Sort.java
@@ -42,7 +42,7 @@ public class Sort extends BaseResourceCollectionWrapper {
//sorted bag impl. borrowed from commons-collections TreeBag:
private static class SortedBag extends AbstractCollection {
private class MutableInt {
- int value = 0;
+ private int value = 0;
}
private class MyIterator implements Iterator {
private Iterator keyIter = t.keySet().iterator();
diff --git a/src/main/org/apache/tools/ant/types/resources/Tokens.java b/src/main/org/apache/tools/ant/types/resources/Tokens.java
index aa8e9c801..3d5176e02 100644
--- a/src/main/org/apache/tools/ant/types/resources/Tokens.java
+++ b/src/main/org/apache/tools/ant/types/resources/Tokens.java
@@ -29,7 +29,6 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.DataType;
import org.apache.tools.ant.types.ResourceCollection;
-import org.apache.tools.ant.types.resources.StringResource;
import org.apache.tools.ant.util.ConcatResourceInputStream;
import org.apache.tools.ant.util.LineTokenizer;
import org.apache.tools.ant.util.Tokenizer;
diff --git a/src/main/org/apache/tools/ant/types/resources/Touchable.java b/src/main/org/apache/tools/ant/types/resources/Touchable.java
index 6d86ad085..3a54a693a 100644
--- a/src/main/org/apache/tools/ant/types/resources/Touchable.java
+++ b/src/main/org/apache/tools/ant/types/resources/Touchable.java
@@ -23,5 +23,10 @@ package org.apache.tools.ant.types.resources;
* @since Ant 1.7
*/
public interface Touchable {
+ /**
+ * Method called to "touch" the resource.
+ * @param modTime the time to set the modified "field" of the resource,
+ * measured in milliseconds since the epoch.
+ */
void touch(long modTime);
}
diff --git a/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java b/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java
index 822586e70..425c5b1aa 100644
--- a/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java
+++ b/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java
@@ -21,11 +21,10 @@ import java.util.Stack;
import java.util.Vector;
import java.util.Iterator;
+import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.DataType;
import org.apache.tools.ant.types.Resource;
-import org.apache.tools.ant.types.ResourceCollection;
-import org.apache.tools.ant.types.resources.comparators.ResourceComparator;
/**
* Delegates to other ResourceComparators or, if none specified,
@@ -51,7 +50,12 @@ public class DelegatedResourceComparator extends ResourceComparator {
v.add(c);
}
- //inherit doc
+ /**
+ * Equality method based on the vector of resources,
+ * or if a reference, the referredto object.
+ * @param o the object to check against.
+ * @return true if there is equality.
+ */
public synchronized boolean equals(Object o) {
if (o == this) {
return true;
@@ -66,7 +70,18 @@ public class DelegatedResourceComparator extends ResourceComparator {
return v == null ? ov == null : v.equals(ov);
}
- //inherit doc
+ /**
+ * Hashcode based on the rules for equality.
+ * @return a hashcode.
+ */
+ public synchronized int hashCode() {
+ if (isReference()) {
+ return getCheckedRef().hashCode();
+ }
+ return v == null ? 0 : v.hashCode();
+ }
+
+ /** {@inheritDoc} */
protected synchronized int resourceCompare(Resource foo, Resource bar) {
//if no nested, natural order:
if (v == null || v.isEmpty()) {
@@ -86,7 +101,8 @@ s.
* @param p the Project to resolve against.
* @throws BuildException on error.
*/
- protected void dieOnCircularReference(Stack stk, Project p) {
+ protected void dieOnCircularReference(Stack stk, Project p)
+ throws BuildException {
if (isChecked()) {
return;
}
diff --git a/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java b/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
index 5575209f9..333c0856a 100755
--- a/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
+++ b/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
@@ -58,6 +58,17 @@ public abstract class ResourceComparator extends DataType implements Comparator
return o == this || o.getClass().equals(getClass());
}
+ /**
+ * Hashcode based on the rules for equality.
+ * @return a hashcode.
+ */
+ public synchronized int hashCode() {
+ if (isReference()) {
+ return getCheckedRef().hashCode();
+ }
+ return getClass().hashCode();
+ }
+
/**
* Compare two Resources.
* @param foo the first Resource.
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java b/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java
index de9d451a3..f1d7d0e72 100644
--- a/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java
@@ -99,6 +99,7 @@ public class Compare extends DataType implements ResourceSelector {
}
//implement ResourceSelector; inherit doc
+ /** {@inheritDoc} */
public synchronized boolean isSelected(Resource r) {
if (isReference()) {
return ((ResourceSelector) getCheckedRef()).isSelected(r);
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelector.java b/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelector.java
index 0e11647ff..37151ecda 100755
--- a/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelector.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelector.java
@@ -30,6 +30,6 @@ public interface ResourceSelector {
* @param r the Resource to check.
* @return whether the Resource was selected.
*/
- public boolean isSelected(Resource r);
+ boolean isSelected(Resource r);
}
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java b/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java
index 6bd656831..158fbc3cf 100755
--- a/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java
@@ -107,7 +107,8 @@ public class ResourceSelectorContainer extends DataType {
* @param p the Project to resolve against.
* @throws BuildException on error.
*/
- protected void dieOnCircularReference(Stack stk, Project p) {
+ protected void dieOnCircularReference(Stack stk, Project p)
+ throws BuildException {
if (isChecked()) {
return;
}