donaldp 2002/07/25 07:59:03
Modified: src/main/org/apache/tools/ant/types AbstractFileSet.java
DataType.java FileList.java Mapper.java Path.java
PatternSet.java RegularExpression.java
Substitution.java XMLCatalog.java ZipFileSet.java
Log:
Encapsulate some fields of DataType.
Revision Changes Path
1.8 +3 -3
jakarta-ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java
Index: AbstractFileSet.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AbstractFileSet.java 9 Jul 2002 21:06:14 -0000 1.7
+++ AbstractFileSet.java 25 Jul 2002 14:59:02 -0000 1.8
@@ -378,15 +378,15 @@
* referenced FileSet.
*/
protected AbstractFileSet getRef(Project p) {
- if (!checked) {
+ if (!isChecked()) {
Stack stk = new Stack();
stk.push(this);
dieOnCircularReference(stk, p);
}
- Object o = ref.getReferencedObject(p);
+ Object o = getRefid().getReferencedObject(p);
if (!getClass().isAssignableFrom(o.getClass())) {
- String msg = ref.getRefId() + " doesn\'t denote a "
+ String msg = getRefid().getRefId() + " doesn\'t denote a "
+ getDataTypeName();
throw new BuildException(msg);
} else {
1.9 +38 -10
jakarta-ant/src/main/org/apache/tools/ant/types/DataType.java
Index: DataType.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/DataType.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DataType.java 25 Jul 2002 14:45:15 -0000 1.8
+++ DataType.java 25 Jul 2002 14:59:02 -0000 1.9
@@ -75,19 +75,32 @@
public abstract class DataType extends ProjectComponent {
/**
* The descriptin the user has set.
+ *
+ * @deprecated The user should not be directly referencing
+ * variable. Please use [EMAIL PROTECTED] #setDescription} or
+ * [EMAIL PROTECTED] #getDescription} instead.
*/
protected String description;
+
/**
* Value to the refid attribute.
+ *
+ * @deprecated The user should not be directly referencing
+ * variable. Please use [EMAIL PROTECTED] #getRefid} instead.
*/
protected Reference ref;
+
/**
* Are we sure we don't hold circular references?
*
* <p>Subclasses are responsible for setting this value to false
* if we'd need to investigate this condition (usually because a
* 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 [EMAIL PROTECTED] #setChecked} or
+ * [EMAIL PROTECTED] #isChecked} instead.
*/
protected boolean checked = true;
@@ -95,7 +108,7 @@
* Sets a description of the current data type. It will be useful
* in commenting what we are doing.
*/
- public void setDescription(String desc) {
+ public void setDescription( final String desc ) {
description = desc;
}
@@ -121,7 +134,7 @@
* thus override this method. if they do the must call
* <code>super.setRefid</code>.</p>
*/
- public void setRefid(Reference ref) {
+ public void setRefid( final Reference ref ) {
this.ref = ref;
checked = false;
}
@@ -142,21 +155,22 @@
* anything if [EMAIL PROTECTED] #checked <code>checked</code>} is true
and
* 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 {
if (checked || !isReference()) {
return;
}
- Object o = ref.getReferencedObject(p);
+ Object o = ref.getReferencedObject(project);
if (o instanceof DataType) {
- if (stk.contains(o)) {
+ if (stack.contains(o)) {
throw circularReference();
} else {
- stk.push(o);
- ((DataType) o).dieOnCircularReference(stk, p);
- stk.pop();
+ stack.push(o);
+ ((DataType) o).dieOnCircularReference(stack, project);
+ stack.pop();
}
}
checked = true;
@@ -166,7 +180,8 @@
* Performs the check for circular references and returns the
* referenced object.
*/
- protected Object getCheckedRef(Class requiredClass, String dataTypeName)
{
+ protected Object getCheckedRef( final Class requiredClass,
+ final String dataTypeName ) {
if (!checked) {
Stack stk = new Stack();
stk.push(this);
@@ -207,5 +222,18 @@
protected BuildException circularReference() {
return new BuildException("This data type contains a circular "
+ "reference.");
+ }
+
+ protected boolean isChecked() {
+ return checked;
+ }
+
+ protected void setChecked( final boolean checked ) {
+ this.checked = checked;
+ }
+
+ protected Reference getRefid()
+ {
+ return ref;
}
}
1.7 +4 -4
jakarta-ant/src/main/org/apache/tools/ant/types/FileList.java
Index: FileList.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/FileList.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FileList.java 15 Apr 2002 12:11:50 -0000 1.6
+++ FileList.java 25 Jul 2002 14:59:02 -0000 1.7
@@ -155,15 +155,15 @@
* referenced FileList.
*/
protected FileList getRef(Project p) {
- if (!checked) {
+ if (!isChecked()) {
Stack stk = new Stack();
stk.push(this);
dieOnCircularReference(stk, p);
}
- Object o = ref.getReferencedObject(p);
+ Object o = getRefid().getReferencedObject(p);
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);
} else {
return (FileList) o;
1.11 +3 -3
jakarta-ant/src/main/org/apache/tools/ant/types/Mapper.java
Index: Mapper.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/Mapper.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Mapper.java 15 Apr 2002 12:11:50 -0000 1.10
+++ Mapper.java 25 Jul 2002 14:59:02 -0000 1.11
@@ -225,15 +225,15 @@
* referenced Mapper.
*/
protected Mapper getRef() {
- if (!checked) {
+ if (!isChecked()) {
Stack stk = new Stack();
stk.push(this);
dieOnCircularReference(stk, getProject());
}
- Object o = ref.getReferencedObject(getProject());
+ Object o = getRefid().getReferencedObject(getProject());
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);
} else {
return (Mapper) o;
1.40 +7 -7 jakarta-ant/src/main/org/apache/tools/ant/types/Path.java
Index: Path.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/Path.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- Path.java 1 Jun 2002 12:26:41 -0000 1.39
+++ Path.java 25 Jul 2002 14:59:02 -0000 1.40
@@ -197,7 +197,7 @@
throw noChildrenAllowed();
}
elements.addElement(fs);
- checked = false;
+ setChecked( false );
}
/**
@@ -208,7 +208,7 @@
throw noChildrenAllowed();
}
elements.addElement(fl);
- checked = false;
+ setChecked( false );
}
/**
@@ -219,7 +219,7 @@
throw noChildrenAllowed();
}
elements.addElement(dset);
- checked = false;
+ setChecked( false );
}
/**
@@ -231,7 +231,7 @@
}
Path p = new Path(getProject());
elements.addElement(p);
- checked = false;
+ setChecked( false );
return p;
}
@@ -280,7 +280,7 @@
* @return list of path elements.
*/
public String[] list() {
- if (!checked) {
+ if (!isChecked()) {
// make sure we don't have a circular reference here
Stack stk = new Stack();
stk.push(this);
@@ -453,7 +453,7 @@
protected void dieOnCircularReference(Stack stk, Project p)
throws BuildException {
- if (checked) {
+ if (isChecked()) {
return;
}
@@ -474,7 +474,7 @@
}
}
}
- checked = true;
+ setChecked( true );
}
/**
1.26 +3 -3
jakarta-ant/src/main/org/apache/tools/ant/types/PatternSet.java
Index: PatternSet.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/PatternSet.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- PatternSet.java 1 Jun 2002 12:26:41 -0000 1.25
+++ PatternSet.java 25 Jul 2002 14:59:02 -0000 1.26
@@ -396,15 +396,15 @@
* referenced PatternSet.
*/
private PatternSet getRef(Project p) {
- if (!checked) {
+ if (!isChecked()) {
Stack stk = new Stack();
stk.push(this);
dieOnCircularReference(stk, p);
}
- Object o = ref.getReferencedObject(p);
+ Object o = getRefid().getReferencedObject(p);
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);
} else {
return (PatternSet) o;
1.13 +3 -3
jakarta-ant/src/main/org/apache/tools/ant/types/RegularExpression.java
Index: RegularExpression.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/RegularExpression.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- RegularExpression.java 16 Apr 2002 07:15:18 -0000 1.12
+++ RegularExpression.java 25 Jul 2002 14:59:02 -0000 1.13
@@ -137,16 +137,16 @@
* the given project. Check for circular references too
*/
public RegularExpression getRef(Project p) {
- if (!checked) {
+ if (!isChecked()) {
Stack stk = new Stack();
stk.push(this);
dieOnCircularReference(stk, p);
}
- Object o = ref.getReferencedObject(p);
+ Object o = getRefid().getReferencedObject(p);
if (!(o instanceof RegularExpression)) {
- String msg = ref.getRefId() + " doesn\'t denote a "
+ String msg = getRefid().getRefId() + " doesn\'t denote a "
+ DATA_TYPE_NAME;
throw new BuildException(msg);
} else {
1.12 +3 -3
jakarta-ant/src/main/org/apache/tools/ant/types/Substitution.java
Index: Substitution.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/Substitution.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Substitution.java 16 Apr 2002 07:15:18 -0000 1.11
+++ Substitution.java 25 Jul 2002 14:59:02 -0000 1.12
@@ -101,16 +101,16 @@
* the given project. Check for circular references too
*/
public Substitution getRef(Project p) {
- if (!checked) {
+ if (!isChecked()) {
Stack stk = new Stack();
stk.push(this);
dieOnCircularReference(stk, p);
}
- Object o = ref.getReferencedObject(p);
+ Object o = getRefid().getReferencedObject(p);
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);
} else {
return (Substitution) o;
1.14 +9 -9
jakarta-ant/src/main/org/apache/tools/ant/types/XMLCatalog.java
Index: XMLCatalog.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/XMLCatalog.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XMLCatalog.java 23 Jul 2002 07:54:56 -0000 1.13
+++ XMLCatalog.java 25 Jul 2002 14:59:02 -0000 1.14
@@ -157,7 +157,7 @@
//-- Methods
---------------------------------------------------------------
public XMLCatalog() {
- checked = false;
+ setChecked( false );
}
/**
@@ -203,7 +203,7 @@
if (this.classpath == null) {
this.classpath = new Path(getProject());
}
- checked = false;
+ setChecked( false );
return this.classpath.createPath();
}
@@ -222,7 +222,7 @@
} else {
this.classpath.append(classpath);
}
- checked = false;
+ setChecked( false );
}
/**
@@ -236,7 +236,7 @@
throw tooManyAttributes();
}
createClasspath().setRefid(r);
- checked = false;
+ setChecked( false );
}
/**
@@ -256,7 +256,7 @@
}
getElements().addElement(dtd);
- checked = false;
+ setChecked( false );
}
/**
@@ -298,7 +298,7 @@
// Append the classpath of the nested catalog
Path nestedClasspath = catalog.getClasspath();
createClasspath().append(nestedClasspath);
- checked = false;
+ setChecked( false );
}
/**
@@ -339,7 +339,7 @@
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
- if (!checked) {
+ if (!isChecked()) {
// make sure we don't have a circular reference here
Stack stk = new Stack();
stk.push(this);
@@ -367,7 +367,7 @@
public Source resolve(String href, String base)
throws TransformerException {
- if (!checked) {
+ if (!isChecked()) {
// make sure we don't have a circular reference here
Stack stk = new Stack();
stk.push(this);
1.10 +3 -3
jakarta-ant/src/main/org/apache/tools/ant/types/ZipFileSet.java
Index: ZipFileSet.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/ZipFileSet.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ZipFileSet.java 22 Apr 2002 13:35:36 -0000 1.9
+++ ZipFileSet.java 25 Jul 2002 14:59:02 -0000 1.10
@@ -188,15 +188,15 @@
* standard directory scanner.
*/
protected AbstractFileSet getRef(Project p) {
- if (!checked) {
+ if (!isChecked()) {
Stack stk = new Stack();
stk.push(this);
dieOnCircularReference(stk, p);
}
- Object o = ref.getReferencedObject(p);
+ Object o = getRefid().getReferencedObject(p);
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);
} else {
return (AbstractFileSet) o;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>