git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273167 13f79535-47bb-0310-9956-ffa450edef68master
@@ -378,15 +378,15 @@ public abstract class AbstractFileSet extends DataType implements Cloneable, | |||||
* referenced FileSet. | * referenced FileSet. | ||||
*/ | */ | ||||
protected AbstractFileSet getRef(Project p) { | protected AbstractFileSet getRef(Project p) { | ||||
if (!checked) { | |||||
if (!isChecked()) { | |||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
dieOnCircularReference(stk, p); | dieOnCircularReference(stk, p); | ||||
} | } | ||||
Object o = ref.getReferencedObject(p); | |||||
Object o = getRefid().getReferencedObject(p); | |||||
if (!getClass().isAssignableFrom(o.getClass())) { | if (!getClass().isAssignableFrom(o.getClass())) { | ||||
String msg = ref.getRefId() + " doesn\'t denote a " | |||||
String msg = getRefid().getRefId() + " doesn\'t denote a " | |||||
+ getDataTypeName(); | + getDataTypeName(); | ||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} else { | } else { | ||||
@@ -75,19 +75,32 @@ import org.apache.tools.ant.ProjectComponent; | |||||
public abstract class DataType extends ProjectComponent { | public abstract class DataType extends ProjectComponent { | ||||
/** | /** | ||||
* The descriptin the user has set. | * The descriptin the user has set. | ||||
* | |||||
* @deprecated The user should not be directly referencing | |||||
* variable. Please use {@link #setDescription} or | |||||
* {@link #getDescription} instead. | |||||
*/ | */ | ||||
protected String description; | protected String description; | ||||
/** | /** | ||||
* Value to the refid attribute. | * Value to the refid attribute. | ||||
* | |||||
* @deprecated The user should not be directly referencing | |||||
* variable. Please use {@link #getRefid} instead. | |||||
*/ | */ | ||||
protected Reference ref; | protected Reference ref; | ||||
/** | /** | ||||
* Are we sure we don't hold circular references? | * Are we sure we don't hold circular references? | ||||
* | * | ||||
* <p>Subclasses are responsible for setting this value to false | * <p>Subclasses are responsible for setting this value to false | ||||
* if we'd need to investigate this condition (usually because a | * if we'd need to investigate this condition (usually because a | ||||
* child element has been added that is a subclass of | * child element has been added that is a subclass of | ||||
* DataType).</p> | |||||
* DataType).</p> | |||||
* | |||||
* @deprecated The user should not be directly referencing | |||||
* variable. Please use {@link #setChecked} or | |||||
* {@link #isChecked} instead. | |||||
*/ | */ | ||||
protected boolean checked = true; | protected boolean checked = true; | ||||
@@ -95,7 +108,7 @@ public abstract class DataType extends ProjectComponent { | |||||
* Sets a description of the current data type. It will be useful | * Sets a description of the current data type. It will be useful | ||||
* in commenting what we are doing. | * in commenting what we are doing. | ||||
*/ | */ | ||||
public void setDescription(String desc) { | |||||
public void setDescription( final String desc ) { | |||||
description = desc; | description = desc; | ||||
} | } | ||||
@@ -121,7 +134,7 @@ public abstract class DataType extends ProjectComponent { | |||||
* thus override this method. if they do the must call | * thus override this method. if they do the must call | ||||
* <code>super.setRefid</code>.</p> | * <code>super.setRefid</code>.</p> | ||||
*/ | */ | ||||
public void setRefid(Reference ref) { | |||||
public void setRefid( final Reference ref ) { | |||||
this.ref = ref; | this.ref = ref; | ||||
checked = false; | checked = false; | ||||
} | } | ||||
@@ -142,21 +155,22 @@ public abstract class DataType extends ProjectComponent { | |||||
* anything if {@link #checked <code>checked</code>} is true and | * anything if {@link #checked <code>checked</code>} is true and | ||||
* set it to true on exit.</p> | * set it to true on exit.</p> | ||||
*/ | */ | ||||
protected void dieOnCircularReference(Stack stk, Project p) | |||||
protected void dieOnCircularReference( final Stack stack, | |||||
final Project project ) | |||||
throws BuildException { | throws BuildException { | ||||
if (checked || !isReference()) { | if (checked || !isReference()) { | ||||
return; | return; | ||||
} | } | ||||
Object o = ref.getReferencedObject(p); | |||||
Object o = ref.getReferencedObject(project); | |||||
if (o instanceof DataType) { | if (o instanceof DataType) { | ||||
if (stk.contains(o)) { | |||||
if (stack.contains(o)) { | |||||
throw circularReference(); | throw circularReference(); | ||||
} else { | } else { | ||||
stk.push(o); | |||||
((DataType) o).dieOnCircularReference(stk, p); | |||||
stk.pop(); | |||||
stack.push(o); | |||||
((DataType) o).dieOnCircularReference(stack, project); | |||||
stack.pop(); | |||||
} | } | ||||
} | } | ||||
checked = true; | checked = true; | ||||
@@ -166,7 +180,8 @@ public abstract class DataType extends ProjectComponent { | |||||
* Performs the check for circular references and returns the | * Performs the check for circular references and returns the | ||||
* referenced object. | * referenced object. | ||||
*/ | */ | ||||
protected Object getCheckedRef(Class requiredClass, String dataTypeName) { | |||||
protected Object getCheckedRef( final Class requiredClass, | |||||
final String dataTypeName ) { | |||||
if (!checked) { | if (!checked) { | ||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
@@ -208,4 +223,17 @@ public abstract class DataType extends ProjectComponent { | |||||
return new BuildException("This data type contains a circular " | return new BuildException("This data type contains a circular " | ||||
+ "reference."); | + "reference."); | ||||
} | } | ||||
protected boolean isChecked() { | |||||
return checked; | |||||
} | |||||
protected void setChecked( final boolean checked ) { | |||||
this.checked = checked; | |||||
} | |||||
protected Reference getRefid() | |||||
{ | |||||
return ref; | |||||
} | |||||
} | } |
@@ -155,15 +155,15 @@ public class FileList extends DataType { | |||||
* referenced FileList. | * referenced FileList. | ||||
*/ | */ | ||||
protected FileList getRef(Project p) { | protected FileList getRef(Project p) { | ||||
if (!checked) { | |||||
if (!isChecked()) { | |||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
dieOnCircularReference(stk, p); | dieOnCircularReference(stk, p); | ||||
} | } | ||||
Object o = ref.getReferencedObject(p); | |||||
Object o = getRefid().getReferencedObject(p); | |||||
if (!(o instanceof FileList)) { | if (!(o instanceof FileList)) { | ||||
String msg = ref.getRefId() + " doesn\'t denote a filelist"; | |||||
String msg = getRefid().getRefId() + " doesn\'t denote a filelist"; | |||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} else { | } else { | ||||
return (FileList) o; | return (FileList) o; | ||||
@@ -225,15 +225,15 @@ public class Mapper extends DataType implements Cloneable { | |||||
* referenced Mapper. | * referenced Mapper. | ||||
*/ | */ | ||||
protected Mapper getRef() { | protected Mapper getRef() { | ||||
if (!checked) { | |||||
if (!isChecked()) { | |||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
dieOnCircularReference(stk, getProject()); | dieOnCircularReference(stk, getProject()); | ||||
} | } | ||||
Object o = ref.getReferencedObject(getProject()); | |||||
Object o = getRefid().getReferencedObject(getProject()); | |||||
if (!(o instanceof Mapper)) { | if (!(o instanceof Mapper)) { | ||||
String msg = ref.getRefId() + " doesn\'t denote a mapper"; | |||||
String msg = getRefid().getRefId() + " doesn\'t denote a mapper"; | |||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} else { | } else { | ||||
return (Mapper) o; | return (Mapper) o; | ||||
@@ -197,7 +197,7 @@ public class Path extends DataType implements Cloneable { | |||||
throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
} | } | ||||
elements.addElement(fs); | elements.addElement(fs); | ||||
checked = false; | |||||
setChecked( false ); | |||||
} | } | ||||
/** | /** | ||||
@@ -208,7 +208,7 @@ public class Path extends DataType implements Cloneable { | |||||
throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
} | } | ||||
elements.addElement(fl); | elements.addElement(fl); | ||||
checked = false; | |||||
setChecked( false ); | |||||
} | } | ||||
/** | /** | ||||
@@ -219,7 +219,7 @@ public class Path extends DataType implements Cloneable { | |||||
throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
} | } | ||||
elements.addElement(dset); | elements.addElement(dset); | ||||
checked = false; | |||||
setChecked( false ); | |||||
} | } | ||||
/** | /** | ||||
@@ -231,7 +231,7 @@ public class Path extends DataType implements Cloneable { | |||||
} | } | ||||
Path p = new Path(getProject()); | Path p = new Path(getProject()); | ||||
elements.addElement(p); | elements.addElement(p); | ||||
checked = false; | |||||
setChecked( false ); | |||||
return p; | return p; | ||||
} | } | ||||
@@ -280,7 +280,7 @@ public class Path extends DataType implements Cloneable { | |||||
* @return list of path elements. | * @return list of path elements. | ||||
*/ | */ | ||||
public String[] list() { | public String[] list() { | ||||
if (!checked) { | |||||
if (!isChecked()) { | |||||
// make sure we don't have a circular reference here | // make sure we don't have a circular reference here | ||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
@@ -453,7 +453,7 @@ public class Path extends DataType implements Cloneable { | |||||
protected void dieOnCircularReference(Stack stk, Project p) | protected void dieOnCircularReference(Stack stk, Project p) | ||||
throws BuildException { | throws BuildException { | ||||
if (checked) { | |||||
if (isChecked()) { | |||||
return; | return; | ||||
} | } | ||||
@@ -474,7 +474,7 @@ public class Path extends DataType implements Cloneable { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
checked = true; | |||||
setChecked( true ); | |||||
} | } | ||||
/** | /** | ||||
@@ -396,15 +396,15 @@ public class PatternSet extends DataType { | |||||
* referenced PatternSet. | * referenced PatternSet. | ||||
*/ | */ | ||||
private PatternSet getRef(Project p) { | private PatternSet getRef(Project p) { | ||||
if (!checked) { | |||||
if (!isChecked()) { | |||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
dieOnCircularReference(stk, p); | dieOnCircularReference(stk, p); | ||||
} | } | ||||
Object o = ref.getReferencedObject(p); | |||||
Object o = getRefid().getReferencedObject(p); | |||||
if (!(o instanceof PatternSet)) { | if (!(o instanceof PatternSet)) { | ||||
String msg = ref.getRefId() + " doesn\'t denote a patternset"; | |||||
String msg = getRefid().getRefId() + " doesn\'t denote a patternset"; | |||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} else { | } else { | ||||
return (PatternSet) o; | return (PatternSet) o; | ||||
@@ -137,16 +137,16 @@ public class RegularExpression extends DataType { | |||||
* the given project. Check for circular references too | * the given project. Check for circular references too | ||||
*/ | */ | ||||
public RegularExpression getRef(Project p) { | public RegularExpression getRef(Project p) { | ||||
if (!checked) { | |||||
if (!isChecked()) { | |||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
dieOnCircularReference(stk, p); | dieOnCircularReference(stk, p); | ||||
} | } | ||||
Object o = ref.getReferencedObject(p); | |||||
Object o = getRefid().getReferencedObject(p); | |||||
if (!(o instanceof RegularExpression)) { | if (!(o instanceof RegularExpression)) { | ||||
String msg = ref.getRefId() + " doesn\'t denote a " | |||||
String msg = getRefid().getRefId() + " doesn\'t denote a " | |||||
+ DATA_TYPE_NAME; | + DATA_TYPE_NAME; | ||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} else { | } else { | ||||
@@ -101,16 +101,16 @@ public class Substitution extends DataType { | |||||
* the given project. Check for circular references too | * the given project. Check for circular references too | ||||
*/ | */ | ||||
public Substitution getRef(Project p) { | public Substitution getRef(Project p) { | ||||
if (!checked) { | |||||
if (!isChecked()) { | |||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
dieOnCircularReference(stk, p); | dieOnCircularReference(stk, p); | ||||
} | } | ||||
Object o = ref.getReferencedObject(p); | |||||
Object o = getRefid().getReferencedObject(p); | |||||
if (!(o instanceof Substitution)) { | if (!(o instanceof Substitution)) { | ||||
String msg = ref.getRefId() + " doesn\'t denote a substitution"; | |||||
String msg = getRefid().getRefId() + " doesn\'t denote a substitution"; | |||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} else { | } else { | ||||
return (Substitution) o; | return (Substitution) o; | ||||
@@ -157,7 +157,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver, U | |||||
//-- Methods --------------------------------------------------------------- | //-- Methods --------------------------------------------------------------- | ||||
public XMLCatalog() { | public XMLCatalog() { | ||||
checked = false; | |||||
setChecked( false ); | |||||
} | } | ||||
/** | /** | ||||
@@ -203,7 +203,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver, U | |||||
if (this.classpath == null) { | if (this.classpath == null) { | ||||
this.classpath = new Path(getProject()); | this.classpath = new Path(getProject()); | ||||
} | } | ||||
checked = false; | |||||
setChecked( false ); | |||||
return this.classpath.createPath(); | return this.classpath.createPath(); | ||||
} | } | ||||
@@ -222,7 +222,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver, U | |||||
} else { | } else { | ||||
this.classpath.append(classpath); | this.classpath.append(classpath); | ||||
} | } | ||||
checked = false; | |||||
setChecked( false ); | |||||
} | } | ||||
/** | /** | ||||
@@ -236,7 +236,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver, U | |||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
createClasspath().setRefid(r); | createClasspath().setRefid(r); | ||||
checked = false; | |||||
setChecked( false ); | |||||
} | } | ||||
/** | /** | ||||
@@ -256,7 +256,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver, U | |||||
} | } | ||||
getElements().addElement(dtd); | getElements().addElement(dtd); | ||||
checked = false; | |||||
setChecked( false ); | |||||
} | } | ||||
/** | /** | ||||
@@ -298,7 +298,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver, U | |||||
// Append the classpath of the nested catalog | // Append the classpath of the nested catalog | ||||
Path nestedClasspath = catalog.getClasspath(); | Path nestedClasspath = catalog.getClasspath(); | ||||
createClasspath().append(nestedClasspath); | createClasspath().append(nestedClasspath); | ||||
checked = false; | |||||
setChecked( false ); | |||||
} | } | ||||
/** | /** | ||||
@@ -339,7 +339,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver, U | |||||
public InputSource resolveEntity(String publicId, String systemId) | public InputSource resolveEntity(String publicId, String systemId) | ||||
throws SAXException, IOException { | throws SAXException, IOException { | ||||
if (!checked) { | |||||
if (!isChecked()) { | |||||
// make sure we don't have a circular reference here | // make sure we don't have a circular reference here | ||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
@@ -367,7 +367,7 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver, U | |||||
public Source resolve(String href, String base) | public Source resolve(String href, String base) | ||||
throws TransformerException { | throws TransformerException { | ||||
if (!checked) { | |||||
if (!isChecked()) { | |||||
// make sure we don't have a circular reference here | // make sure we don't have a circular reference here | ||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
@@ -188,15 +188,15 @@ public class ZipFileSet extends FileSet { | |||||
* standard directory scanner. | * standard directory scanner. | ||||
*/ | */ | ||||
protected AbstractFileSet getRef(Project p) { | protected AbstractFileSet getRef(Project p) { | ||||
if (!checked) { | |||||
if (!isChecked()) { | |||||
Stack stk = new Stack(); | Stack stk = new Stack(); | ||||
stk.push(this); | stk.push(this); | ||||
dieOnCircularReference(stk, p); | dieOnCircularReference(stk, p); | ||||
} | } | ||||
Object o = ref.getReferencedObject(p); | |||||
Object o = getRefid().getReferencedObject(p); | |||||
if (!(o instanceof FileSet)) { | if (!(o instanceof FileSet)) { | ||||
String msg = ref.getRefId() + " doesn\'t denote a fileset"; | |||||
String msg = getRefid().getRefId() + " doesn\'t denote a fileset"; | |||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} else { | } else { | ||||
return (AbstractFileSet) o; | return (AbstractFileSet) o; | ||||