Methods Summary |
---|
protected void | checkAttributesAllowed()check that it is ok to set attributes, i.e that no reference is defined
if (isReference()) {
throw tooManyAttributes();
}
|
protected void | checkChildrenAllowed()check that it is ok to add children, i.e that no reference is defined
if (isReference()) {
throw noChildrenAllowed();
}
|
protected org.apache.tools.ant.BuildException | circularReference()Creates an exception that indicates the user has generated a
loop of data types referencing each other.
return new BuildException("This data type contains a circular "
+ "reference.");
|
public java.lang.Object | clone()
DataType dt = (DataType) super.clone();
dt.setDescription(getDescription());
if (getRefid() != null) {
dt.setRefid(getRefid());
}
dt.setChecked(isChecked());
return dt;
|
protected void | dieOnCircularReference()Convenience method.
dieOnCircularReference(getProject());
|
protected void | dieOnCircularReference(org.apache.tools.ant.Project p)Convenience method.
if (checked || !isReference()) {
return;
}
dieOnCircularReference(new IdentityStack(this), p);
|
protected void | dieOnCircularReference(java.util.Stack stack, org.apache.tools.ant.Project project)Check to see whether any DataType we hold references to is
included in the Stack (which holds all DataType instances that
directly or indirectly reference this instance, including this
instance itself).
If one is included, throw a BuildException created by {@link
#circularReference circularReference}.
This implementation is appropriate only for a DataType that
cannot hold other DataTypes as children.
The general contract of this method is that it shouldn't do
anything if {@link #checked checked } is true and
set it to true on exit.
if (checked || !isReference()) {
return;
}
Object o = ref.getReferencedObject(project);
if (o instanceof DataType) {
IdentityStack id = IdentityStack.getInstance(stack);
if (id.contains(o)) {
throw circularReference();
} else {
id.push(o);
((DataType) o).dieOnCircularReference(id, project);
id.pop();
}
}
checked = true;
|
protected java.lang.Object | getCheckedRef(java.lang.Class requiredClass, java.lang.String dataTypeName)Performs the check for circular references and returns the
referenced object.
return getCheckedRef(requiredClass, dataTypeName, getProject());
|
protected java.lang.Object | getCheckedRef(java.lang.Class requiredClass, java.lang.String dataTypeName, org.apache.tools.ant.Project project)Performs the check for circular references and returns the
referenced object. This version allows the fallback Project instance to be specified.
if (project == null) {
throw new BuildException("No Project specified");
}
dieOnCircularReference(project);
Object o = ref.getReferencedObject(project);
if (!(requiredClass.isAssignableFrom(o.getClass()))) {
log("Class " + o.getClass() + " is not a subclass of " + requiredClass,
Project.MSG_VERBOSE);
String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName;
throw new BuildException(msg);
}
return o;
|
protected java.lang.Object | getCheckedRef()Performs the check for circular references and returns the
referenced object.
return getCheckedRef(getProject());
|
protected java.lang.Object | getCheckedRef(org.apache.tools.ant.Project p)Performs the check for circular references and returns the
referenced object.
return getCheckedRef(getClass(), getDataTypeName(), p);
|
protected java.lang.String | getDataTypeName()Gets as descriptive as possible a name used for this datatype instance.
return ComponentHelper.getElementName(getProject(), this, true);
|
public Reference | getRefid()get the reference set on this object
return ref;
|
public static void | invokeCircularReferenceCheck(org.apache.tools.ant.types.DataType dt, java.util.Stack stk, org.apache.tools.ant.Project p)Allow DataTypes outside org.apache.tools.ant.types to indirectly call
dieOnCircularReference on nested DataTypes.
dt.dieOnCircularReference(stk, p);
|
protected boolean | isChecked()The flag that is used to indicate that circular references have been checked.
return checked;
|
public boolean | isReference()Has the refid attribute of this element been set?
// CheckStyle:VisibilityModifier ON
return ref != null;
|
protected org.apache.tools.ant.BuildException | noChildrenAllowed()Creates an exception that indicates that this XML element must
not have child elements if the refid attribute is set.
return new BuildException("You must not specify nested elements "
+ "when using refid");
|
protected void | setChecked(boolean checked)Set the flag that is used to indicate that circular references have been checked.
this.checked = checked;
|
public void | setRefid(Reference ref)Set the value of the refid attribute.
Subclasses may need to check whether any other attributes
have been set as well or child elements have been created and
thus override this method. if they do the must call
super.setRefid .
this.ref = ref;
checked = false;
|
public java.lang.String | toString()Basic DataType toString().
String d = getDescription();
return d == null ? getDataTypeName() : getDataTypeName() + " " + d;
|
protected org.apache.tools.ant.BuildException | tooManyAttributes()Creates an exception that indicates that refid has to be the
only attribute if it is set.
return new BuildException("You must not specify more than one "
+ "attribute when using refid");
|