@@ -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 (stac k.contains(o)) {
throw circularReference();
throw circularReference();
} else {
} else {
stk.push(o);
((DataType) o).dieOnCircularReference(stk, p);
stk.pop();
stac k.push(o);
((DataType) o).dieOnCircularReference(stac k, project );
stac k.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;
}
}
}