Browse Source

checkstyle

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@475973 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 19 years ago
parent
commit
e661544ab0
15 changed files with 107 additions and 24 deletions
  1. +24
    -1
      src/main/org/apache/tools/ant/types/resources/BZip2Resource.java
  2. +2
    -2
      src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java
  3. +2
    -2
      src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java
  4. +5
    -5
      src/main/org/apache/tools/ant/types/resources/FailFast.java
  5. +4
    -0
      src/main/org/apache/tools/ant/types/resources/Files.java
  6. +25
    -2
      src/main/org/apache/tools/ant/types/resources/GZipResource.java
  7. +3
    -3
      src/main/org/apache/tools/ant/types/resources/Resources.java
  8. +1
    -1
      src/main/org/apache/tools/ant/types/resources/Sort.java
  9. +0
    -1
      src/main/org/apache/tools/ant/types/resources/Tokens.java
  10. +5
    -0
      src/main/org/apache/tools/ant/types/resources/Touchable.java
  11. +21
    -5
      src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java
  12. +11
    -0
      src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
  13. +1
    -0
      src/main/org/apache/tools/ant/types/resources/selectors/Compare.java
  14. +1
    -1
      src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelector.java
  15. +2
    -1
      src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java

+ 24
- 1
src/main/org/apache/tools/ant/types/resources/BZip2Resource.java View File

@@ -35,13 +35,24 @@ import org.apache.tools.bzip2.CBZip2OutputStream;
public class BZip2Resource extends CompressedResource { public class BZip2Resource extends CompressedResource {
private static final char[] MAGIC = new char[] {'B', 'Z'}; private static final char[] MAGIC = new char[] {'B', 'Z'};


/** A no-arg constructor */
public BZip2Resource() { public BZip2Resource() {
} }


/**
* Constructor with another resource to wrap.
* @param other the resource to wrap.
*/
public BZip2Resource(org.apache.tools.ant.types.ResourceCollection other) { public BZip2Resource(org.apache.tools.ant.types.ResourceCollection other) {
super(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 { protected InputStream wrapStream(InputStream in) throws IOException {
for (int i = 0; i < MAGIC.length; i++) { for (int i = 0; i < MAGIC.length; i++) {
if (in.read() != MAGIC[i]) { if (in.read() != MAGIC[i]) {
@@ -50,13 +61,25 @@ public class BZip2Resource extends CompressedResource {
} }
return new CBZip2InputStream(in); 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 { protected OutputStream wrapStream(OutputStream out) throws IOException {
for (int i = 0; i < MAGIC.length; i++) { for (int i = 0; i < MAGIC.length; i++) {
out.write(MAGIC[i]); out.write(MAGIC[i]);
} }
return new CBZip2OutputStream(out); return new CBZip2OutputStream(out);
} }

/**
* Get the name of the compression method.
* @return the string "Bzip2".
*/
protected String getCompressionName() { protected String getCompressionName() {
return "Bzip2"; return "Bzip2";
} }
}
}

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

@@ -112,7 +112,7 @@ public abstract class BaseResourceCollectionContainer
* are added to this container while the Iterator is in use. * are added to this container while the Iterator is in use.
* @return a "fail-fast" Iterator. * @return a "fail-fast" Iterator.
*/ */
public synchronized final Iterator iterator() {
public final synchronized Iterator iterator() {
if (isReference()) { if (isReference()) {
return ((BaseResourceCollectionContainer) getCheckedRef()).iterator(); return ((BaseResourceCollectionContainer) getCheckedRef()).iterator();
} }
@@ -190,7 +190,7 @@ public abstract class BaseResourceCollectionContainer
* Get the nested ResourceCollections. * Get the nested ResourceCollections.
* @return List. * @return List.
*/ */
protected synchronized final List getResourceCollections() {
protected final synchronized List getResourceCollections() {
dieOnCircularReference(); dieOnCircularReference();
return Collections.unmodifiableList(rc); return Collections.unmodifiableList(rc);
} }


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

@@ -80,7 +80,7 @@ public abstract class BaseResourceCollectionWrapper
* Fulfill the ResourceCollection contract. * Fulfill the ResourceCollection contract.
* @return an Iterator of Resources. * @return an Iterator of Resources.
*/ */
public synchronized final Iterator iterator() {
public final synchronized Iterator iterator() {
if (isReference()) { if (isReference()) {
return ((BaseResourceCollectionWrapper) getCheckedRef()).iterator(); return ((BaseResourceCollectionWrapper) getCheckedRef()).iterator();
} }
@@ -152,7 +152,7 @@ public abstract class BaseResourceCollectionWrapper
* @return a ResourceCollection. * @return a ResourceCollection.
* @throws BuildException if no nested ResourceCollection has been provided. * @throws BuildException if no nested ResourceCollection has been provided.
*/ */
protected synchronized final ResourceCollection getResourceCollection() {
protected final synchronized ResourceCollection getResourceCollection() {
dieOnCircularReference(); dieOnCircularReference();
if (rc == null) { if (rc == null) {
throw oneNested(); throw oneNested();


+ 5
- 5
src/main/org/apache/tools/ant/types/resources/FailFast.java View File

@@ -30,30 +30,30 @@ import java.util.ConcurrentModificationException;
* @since Ant 1.7 * @since Ant 1.7
*/ */
/*package-private*/ class FailFast implements Iterator { /*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. * Invalidate any in-use Iterators from the specified Object.
* @param o the parent Object. * @param o the parent Object.
*/ */
static synchronized void invalidate(Object o) { static synchronized void invalidate(Object o) {
Set s = (Set) (map.get(o));
Set s = (Set) (MAP.get(o));
if (s != null) { if (s != null) {
s.clear(); s.clear();
} }
} }


private static synchronized void add(FailFast f) { private static synchronized void add(FailFast f) {
Set s = (Set) (map.get(f.parent));
Set s = (Set) (MAP.get(f.parent));
if (s == null) { if (s == null) {
s = new HashSet(); s = new HashSet();
map.put(f.parent, s);
MAP.put(f.parent, s);
} }
s.add(f); s.add(f);
} }


private static synchronized void remove(FailFast 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) { if (s != null) {
s.remove(f); s.remove(f);
} }


+ 4
- 0
src/main/org/apache/tools/ant/types/resources/Files.java View File

@@ -81,6 +81,7 @@ public class Files extends AbstractSelectorContainer
* <p>You must not set another attribute or nest elements inside * <p>You must not set another attribute or nest elements inside
* this element if you make it a reference.</p> * this element if you make it a reference.</p>
* @param r the <code>Reference</code> to use. * @param r the <code>Reference</code> to use.
* @throws BuildException if there is a problem.
*/ */
public void setRefid(Reference r) throws BuildException { public void setRefid(Reference r) throws BuildException {
if (hasPatterns(defaultPatterns)) { if (hasPatterns(defaultPatterns)) {
@@ -221,6 +222,7 @@ public class Files extends AbstractSelectorContainer
* Set the <code>File</code> containing the includes patterns. * Set the <code>File</code> containing the includes patterns.
* *
* @param incl <code>File</code> instance. * @param incl <code>File</code> instance.
* @throws BuildException if there is a problem.
*/ */
public synchronized void setIncludesfile(File incl) throws BuildException { public synchronized void setIncludesfile(File incl) throws BuildException {
checkAttributesAllowed(); checkAttributesAllowed();
@@ -232,6 +234,7 @@ public class Files extends AbstractSelectorContainer
* Set the <code>File</code> containing the excludes patterns. * Set the <code>File</code> containing the excludes patterns.
* *
* @param excl <code>File</code> instance. * @param excl <code>File</code> instance.
* @throws BuildException if there is a problem.
*/ */
public synchronized void setExcludesfile(File excl) throws BuildException { public synchronized void setExcludesfile(File excl) throws BuildException {
checkAttributesAllowed(); checkAttributesAllowed();
@@ -252,6 +255,7 @@ public class Files extends AbstractSelectorContainer


/** /**
* Get whether default exclusions should be used or not. * Get whether default exclusions should be used or not.
* @return the defaultexclusions value.
*/ */
public synchronized boolean getDefaultexcludes() { public synchronized boolean getDefaultexcludes() {
return (isReference()) return (isReference())


+ 25
- 2
src/main/org/apache/tools/ant/types/resources/GZipResource.java View File

@@ -33,20 +33,43 @@ import java.util.zip.GZIPOutputStream;
*/ */
public class GZipResource extends CompressedResource { public class GZipResource extends CompressedResource {


/** A no-arg constructor */
public GZipResource() { public GZipResource() {
} }


/**
* Constructor with another resource to wrap.
* @param other the resource to wrap.
*/
public GZipResource(org.apache.tools.ant.types.ResourceCollection other) { public GZipResource(org.apache.tools.ant.types.ResourceCollection other) {
super(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 { protected InputStream wrapStream(InputStream in) throws IOException {
return new GZIPInputStream(in); 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); return new GZIPOutputStream(out);
} }

/**
* Get the name of the compression method.
* @return the string "GZip".
*/
protected String getCompressionName() { protected String getCompressionName() {
return "GZip"; return "GZip";
} }
}
}

+ 3
- 3
src/main/org/apache/tools/ant/types/resources/Resources.java View File

@@ -61,7 +61,7 @@ public class Resources extends DataType implements ResourceCollection {
}; };


private class MyCollection extends AbstractCollection { private class MyCollection extends AbstractCollection {
int size;
private int size;


MyCollection() { MyCollection() {
size = 0; size = 0;
@@ -76,8 +76,8 @@ public class Resources extends DataType implements ResourceCollection {
return new MyIterator(); return new MyIterator();
} }
private class MyIterator implements Iterator { private class MyIterator implements Iterator {
Iterator rci = rc.iterator();
Iterator ri = null;
private Iterator rci = rc.iterator();
private Iterator ri = null;


public boolean hasNext() { public boolean hasNext() {
boolean result = ri != null && ri.hasNext(); boolean result = ri != null && ri.hasNext();


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

@@ -42,7 +42,7 @@ public class Sort extends BaseResourceCollectionWrapper {
//sorted bag impl. borrowed from commons-collections TreeBag: //sorted bag impl. borrowed from commons-collections TreeBag:
private static class SortedBag extends AbstractCollection { private static class SortedBag extends AbstractCollection {
private class MutableInt { private class MutableInt {
int value = 0;
private int value = 0;
} }
private class MyIterator implements Iterator { private class MyIterator implements Iterator {
private Iterator keyIter = t.keySet().iterator(); private Iterator keyIter = t.keySet().iterator();


+ 0
- 1
src/main/org/apache/tools/ant/types/resources/Tokens.java View File

@@ -29,7 +29,6 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.DataType; import org.apache.tools.ant.types.DataType;
import org.apache.tools.ant.types.ResourceCollection; 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.ConcatResourceInputStream;
import org.apache.tools.ant.util.LineTokenizer; import org.apache.tools.ant.util.LineTokenizer;
import org.apache.tools.ant.util.Tokenizer; import org.apache.tools.ant.util.Tokenizer;


+ 5
- 0
src/main/org/apache/tools/ant/types/resources/Touchable.java View File

@@ -23,5 +23,10 @@ package org.apache.tools.ant.types.resources;
* @since Ant 1.7 * @since Ant 1.7
*/ */
public interface Touchable { 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); void touch(long modTime);
} }

+ 21
- 5
src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java View File

@@ -21,11 +21,10 @@ import java.util.Stack;
import java.util.Vector; import java.util.Vector;
import java.util.Iterator; import java.util.Iterator;


import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.DataType; import org.apache.tools.ant.types.DataType;
import org.apache.tools.ant.types.Resource; 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, * Delegates to other ResourceComparators or, if none specified,
@@ -51,7 +50,12 @@ public class DelegatedResourceComparator extends ResourceComparator {
v.add(c); 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) { public synchronized boolean equals(Object o) {
if (o == this) { if (o == this) {
return true; return true;
@@ -66,7 +70,18 @@ public class DelegatedResourceComparator extends ResourceComparator {
return v == null ? ov == null : v.equals(ov); 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) { protected synchronized int resourceCompare(Resource foo, Resource bar) {
//if no nested, natural order: //if no nested, natural order:
if (v == null || v.isEmpty()) { if (v == null || v.isEmpty()) {
@@ -86,7 +101,8 @@ s.
* @param p the Project to resolve against. * @param p the Project to resolve against.
* @throws BuildException on error. * @throws BuildException on error.
*/ */
protected void dieOnCircularReference(Stack stk, Project p) {
protected void dieOnCircularReference(Stack stk, Project p)
throws BuildException {
if (isChecked()) { if (isChecked()) {
return; return;
} }


+ 11
- 0
src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java View File

@@ -58,6 +58,17 @@ public abstract class ResourceComparator extends DataType implements Comparator
return o == this || o.getClass().equals(getClass()); 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. * Compare two Resources.
* @param foo the first Resource. * @param foo the first Resource.


+ 1
- 0
src/main/org/apache/tools/ant/types/resources/selectors/Compare.java View File

@@ -99,6 +99,7 @@ public class Compare extends DataType implements ResourceSelector {
} }


//implement ResourceSelector; inherit doc //implement ResourceSelector; inherit doc
/** {@inheritDoc} */
public synchronized boolean isSelected(Resource r) { public synchronized boolean isSelected(Resource r) {
if (isReference()) { if (isReference()) {
return ((ResourceSelector) getCheckedRef()).isSelected(r); return ((ResourceSelector) getCheckedRef()).isSelected(r);


+ 1
- 1
src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelector.java View File

@@ -30,6 +30,6 @@ public interface ResourceSelector {
* @param r the Resource to check. * @param r the Resource to check.
* @return whether the Resource was selected. * @return whether the Resource was selected.
*/ */
public boolean isSelected(Resource r);
boolean isSelected(Resource r);


} }

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

@@ -107,7 +107,8 @@ public class ResourceSelectorContainer extends DataType {
* @param p the Project to resolve against. * @param p the Project to resolve against.
* @throws BuildException on error. * @throws BuildException on error.
*/ */
protected void dieOnCircularReference(Stack stk, Project p) {
protected void dieOnCircularReference(Stack stk, Project p)
throws BuildException {
if (isChecked()) { if (isChecked()) {
return; return;
} }


Loading…
Cancel
Save