diff --git a/src/main/org/apache/tools/ant/types/Mapper.java b/src/main/org/apache/tools/ant/types/Mapper.java
index abb3e9c28..595b180ae 100644
--- a/src/main/org/apache/tools/ant/types/Mapper.java
+++ b/src/main/org/apache/tools/ant/types/Mapper.java
@@ -247,19 +247,7 @@ public class Mapper extends DataType implements Cloneable {
* @return the referenced Mapper
*/
protected Mapper getRef() {
- if (!isChecked()) {
- Stack stk = new Stack();
- stk.push(this);
- dieOnCircularReference(stk, getProject());
- }
-
- Object o = getRefid().getReferencedObject(getProject());
- if (!(o instanceof Mapper)) {
- String msg = getRefid().getRefId() + " doesn\'t denote a mapper";
- throw new BuildException(msg);
- } else {
- return (Mapper) o;
- }
+ return (Mapper) getCheckedRef();
}
/**
diff --git a/src/main/org/apache/tools/ant/types/PatternSet.java b/src/main/org/apache/tools/ant/types/PatternSet.java
index 4c7538b89..2ffac2ef6 100644
--- a/src/main/org/apache/tools/ant/types/PatternSet.java
+++ b/src/main/org/apache/tools/ant/types/PatternSet.java
@@ -414,19 +414,7 @@ public class PatternSet extends DataType implements Cloneable {
* referenced PatternSet.
*/
private PatternSet getRef(Project p) {
- if (!isChecked()) {
- Stack stk = new Stack();
- stk.push(this);
- dieOnCircularReference(stk, p);
- }
-
- Object o = getRefid().getReferencedObject(p);
- if (!(o instanceof PatternSet)) {
- String msg = getRefid().getRefId() + " doesn\'t denote a patternset";
- throw new BuildException(msg);
- } else {
- return (PatternSet) o;
- }
+ return (PatternSet) getCheckedRef(p);
}
/**
diff --git a/src/main/org/apache/tools/ant/types/RedirectorElement.java b/src/main/org/apache/tools/ant/types/RedirectorElement.java
index 39ce1b45a..da7427e30 100755
--- a/src/main/org/apache/tools/ant/types/RedirectorElement.java
+++ b/src/main/org/apache/tools/ant/types/RedirectorElement.java
@@ -27,22 +27,23 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Redirector;
/**
- * Element representation of a Redirector
.
+ * Element representation of a Redirector
.
+ * @since Ant 1.6.2
*/
public class RedirectorElement extends DataType {
/**
- * Whether the input mapper was set via setOutput
.
+ * Whether the input mapper was set via setOutput
.
*/
private boolean usingInput = false;
/**
- * Whether the output mapper was set via setOutput
.
+ * Whether the output mapper was set via setOutput
.
*/
private boolean usingOutput = false;
/**
- * Whether the error mapper was set via setError
.
+ * Whether the error mapper was set via setError
.
*/
private boolean usingError = false;
@@ -103,7 +104,7 @@ public class RedirectorElement extends DataType {
/**
* Add the input file mapper.
- * @param inputMapper Mapper
.
+ * @param inputMapper Mapper
.
*/
public void addConfiguredInputMapper(Mapper inputMapper) {
if (isReference()) {
@@ -122,7 +123,7 @@ public class RedirectorElement extends DataType {
/**
* Add the output file mapper.
- * @param outputMapper Mapper
.
+ * @param outputMapper Mapper
.
*/
public void addConfiguredOutputMapper(Mapper outputMapper) {
if (isReference()) {
@@ -141,7 +142,7 @@ public class RedirectorElement extends DataType {
/**
* Add the error file mapper.
- * @param errorMapper Mapper
.
+ * @param errorMapper Mapper
.
*/
public void addConfiguredErrorMapper(Mapper errorMapper) {
if (isReference()) {
@@ -159,12 +160,12 @@ public class RedirectorElement extends DataType {
}
/**
- * Makes this instance in effect a reference to another instance.
+ * Make this instance in effect a reference to another instance.
*
*
You must not set another attribute or nest elements inside * this element if you make it a reference.
- * @param r the reference to use - * @throws BuildException on error + * @param r the reference to use. + * @throws BuildException on error. */ public void setRefid(Reference r) throws BuildException { if (usingInput @@ -178,14 +179,15 @@ public class RedirectorElement extends DataType { || outputEncoding != null || errorEncoding != null || outputProperty != null - || errorProperty != null) { + || errorProperty != null + || logInputString != null) { throw tooManyAttributes(); } super.setRefid(r); } /** - * Set the input to use for the task + * Set the input to use for the task. * @param input the file from which input is read. */ public void setInput(File input) { @@ -230,9 +232,9 @@ public class RedirectorElement extends DataType { /** * File the output of the process is redirected to. If error is not - * redirected, it too will appear in the output + * redirected, it too will appear in the output. * - * @param out the file to which output stream is written + * @param out the file to which output stream is written. */ public void setOutput(File out) { if (isReference()) { @@ -247,7 +249,7 @@ public class RedirectorElement extends DataType { /** * Set the output encoding. - * @param outputEncodingString
.
+ * @param outputEncoding String
.
*/
public void setOutputEncoding(String outputEncoding) {
if (isReference()) {
@@ -259,7 +261,7 @@ public class RedirectorElement extends DataType {
/**
* Set the error encoding.
*
- * @param errorEncoding String
.
+ * @param errorEncoding String
.
*/
public void setErrorEncoding(String errorEncoding) {
if (isReference()) {
@@ -270,7 +272,7 @@ public class RedirectorElement extends DataType {
/**
* Set the input encoding.
- * @param inputEncoding String
.
+ * @param inputEncoding String
.
*/
public void setInputEncoding(String inputEncoding) {
if (isReference()) {
@@ -282,7 +284,7 @@ public class RedirectorElement extends DataType {
/**
* Controls whether error output of exec is logged. This is only useful
* when output is being redirected and error output is desired in the
- * Ant log
+ * Ant log.
* @param logError if true the standard error is sent to the Ant log system
* and not sent to output.
*/
@@ -295,7 +297,7 @@ public class RedirectorElement extends DataType {
/**
* Set the file to which standard error is to be redirected.
- * @param error the file to which error is to be written
+ * @param error the file to which error is to be written.
*/
public void setError(File error) {
if (isReference()) {
@@ -351,7 +353,7 @@ public class RedirectorElement extends DataType {
/**
* Whether output and error files should be created even when empty.
* Defaults to true.
- * @param createEmptyFiles boolean
.
+ * @param createEmptyFiles boolean
.
*/
public void setCreateEmptyFiles(boolean createEmptyFiles) {
if (isReference()) {
@@ -375,8 +377,8 @@ public class RedirectorElement extends DataType {
}
/**
- * Create a nested input FilterChain
.
- * @return FilterChain
.
+ * Create a nested input FilterChain
.
+ * @return FilterChain
.
*/
public FilterChain createInputFilterChain() {
if (isReference()) {
@@ -389,8 +391,8 @@ public class RedirectorElement extends DataType {
}
/**
- * Create a nested output FilterChain
.
- * @return FilterChain
.
+ * Create a nested output FilterChain
.
+ * @return FilterChain
.
*/
public FilterChain createOutputFilterChain() {
if (isReference()) {
@@ -403,8 +405,8 @@ public class RedirectorElement extends DataType {
}
/**
- * Create a nested error FilterChain
.
- * @return FilterChain
.
+ * Create a nested error FilterChain
.
+ * @return FilterChain
.
*/
public FilterChain createErrorFilterChain() {
if (isReference()) {
@@ -417,18 +419,18 @@ public class RedirectorElement extends DataType {
}
/**
- * Configure the specified Redirector
.
- * @param redirector Redirector
.
+ * Configure the specified Redirector
.
+ * @param redirector Redirector
.
*/
public void configure(Redirector redirector) {
configure(redirector, null);
}
/**
- * Configure the specified Redirector
+ * Configure the specified Redirector
* for the specified sourcefile.
- * @param redirector Redirector
.
- * @param sourcefile String
.
+ * @param redirector Redirector
.
+ * @param sourcefile String
.
*/
public void configure(Redirector redirector, String sourcefile) {
if (isReference()) {
@@ -523,8 +525,8 @@ public class RedirectorElement extends DataType {
/**
* Create a merge mapper pointing to the specified destination file.
- * @param destfile File
- * @return Mapper
.
+ * @param destfile File
+ * @return Mapper
.
*/
protected Mapper createMergeMapper(File destfile) {
Mapper result = new Mapper(getProject());
@@ -535,9 +537,9 @@ public class RedirectorElement extends DataType {
}
/**
- * Return a File[]
from the specified set of filenames.
- * @param name String[]
- * @return File[]
.
+ * Return a File[]
from the specified set of filenames.
+ * @param name String[]
+ * @return File[]
.
*/
protected File[] toFileArray(String[] name) {
if (name == null) {
@@ -553,19 +555,6 @@ public class RedirectorElement extends DataType {
return (File[]) (list.toArray(new File[list.size()]));
}
- /**
- * Convenience method.
- * @throws BuildException on error.
- */
- protected void dieOnCircularReference() throws BuildException {
- if (isChecked()) {
- return;
- }
- Stack s = new Stack();
- s.push(this);
- dieOnCircularReference(s, getProject());
- }
-
/**
* Overrides the version of DataType to recurse on all DataType
* child elements that may have been added.
@@ -607,17 +596,11 @@ public class RedirectorElement extends DataType {
/**
* Perform the check for circular references, returning the
- * referenced RedirectorElement
+ * referenced RedirectorElement.
* @return the referenced RedirectorElement.
*/
private RedirectorElement getRef() {
- dieOnCircularReference();
- Object o = getRefid().getReferencedObject(getProject());
- if (!(o instanceof RedirectorElement)) {
- throw new BuildException(getRefid().getRefId()
- + " doesn\'t denote a RedirectorElement");
- }
- return (RedirectorElement) o;
+ return (RedirectorElement) getCheckedRef();
}
}
diff --git a/src/main/org/apache/tools/ant/types/RegularExpression.java b/src/main/org/apache/tools/ant/types/RegularExpression.java
index b4606a163..065721c72 100644
--- a/src/main/org/apache/tools/ant/types/RegularExpression.java
+++ b/src/main/org/apache/tools/ant/types/RegularExpression.java
@@ -138,20 +138,6 @@ public class RegularExpression extends DataType {
* @return resolved RegularExpression instance
*/
public RegularExpression getRef(Project p) {
- if (!isChecked()) {
- Stack stk = new Stack();
- stk.push(this);
- dieOnCircularReference(stk, p);
- }
-
-
- Object o = getRefid().getReferencedObject(p);
- if (!(o instanceof RegularExpression)) {
- String msg = getRefid().getRefId() + " doesn\'t denote a "
- + DATA_TYPE_NAME;
- throw new BuildException(msg);
- } else {
- return (RegularExpression) o;
- }
+ return (RegularExpression) getCheckedRef(p);
}
}
diff --git a/src/main/org/apache/tools/ant/types/Substitution.java b/src/main/org/apache/tools/ant/types/Substitution.java
index 28a92eb11..d5e3be512 100644
--- a/src/main/org/apache/tools/ant/types/Substitution.java
+++ b/src/main/org/apache/tools/ant/types/Substitution.java
@@ -73,19 +73,6 @@ public class Substitution extends DataType {
* @return the resolved reference
*/
public Substitution getRef(Project p) {
- if (!isChecked()) {
- Stack stk = new Stack();
- stk.push(this);
- dieOnCircularReference(stk, p);
- }
-
-
- Object o = getRefid().getReferencedObject(p);
- if (!(o instanceof Substitution)) {
- String msg = getRefid().getRefId() + " doesn\'t denote a substitution";
- throw new BuildException(msg);
- } else {
- return (Substitution) o;
- }
+ return (Substitution) getCheckedRef(p);
}
}
diff --git a/src/main/org/apache/tools/ant/types/XMLCatalog.java b/src/main/org/apache/tools/ant/types/XMLCatalog.java
index f38722094..509bdd012 100644
--- a/src/main/org/apache/tools/ant/types/XMLCatalog.java
+++ b/src/main/org/apache/tools/ant/types/XMLCatalog.java
@@ -394,12 +394,7 @@ public class XMLCatalog extends DataType
return getRef().resolveEntity(publicId, systemId);
}
- if (!isChecked()) {
- // make sure we don't have a circular reference here
- Stack stk = new Stack();
- stk.push(this);
- dieOnCircularReference(stk, getProject());
- }
+ dieOnCircularReference();
log("resolveEntity: '" + publicId + "': '" + systemId + "'",
Project.MSG_DEBUG);
@@ -427,12 +422,7 @@ public class XMLCatalog extends DataType
return getRef().resolve(href, base);
}
- if (!isChecked()) {
- // make sure we don't have a circular reference here
- Stack stk = new Stack();
- stk.push(this);
- dieOnCircularReference(stk, getProject());
- }
+ dieOnCircularReference();
SAXSource source = null;