costin 2002/12/12 16:47:59
Modified: src/main/org/apache/tools/ant RuntimeConfigurable.java
Log:
Added support for SAX2 attributes.
This is merged from RuntimeConfigurable2 ( sorry for the indentation
changes ).
Revision Changes Path
1.18 +38 -6
jakarta-ant/src/main/org/apache/tools/ant/RuntimeConfigurable.java
Index: RuntimeConfigurable.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/RuntimeConfigurable.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- RuntimeConfigurable.java 22 Jul 2002 12:39:33 -0000 1.17
+++ RuntimeConfigurable.java 13 Dec 2002 00:47:59 -0000 1.18
@@ -58,7 +58,9 @@
import java.util.Locale;
import java.util.Vector;
import org.xml.sax.AttributeList;
+import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributeListImpl;
+import org.xml.sax.helpers.AttributesImpl;
/**
* Wrapper class that holds the attributes of an element, its children, and
@@ -75,8 +77,11 @@
private Vector children = new Vector();
/** The element to configure. */
private Object wrappedObject = null;
- /** XML attributes for the element. */
+ /** @@deprecated
+ * XML attributes for the element. */
private AttributeList attributes;
+ /** XML attributes for the element. */
+ private Attributes attributes2;
/** Text appearing within the element. */
private StringBuffer characters = new StringBuffer();
/** Indicates if the wrapped object has been configured */
@@ -93,6 +98,8 @@
wrappedObject = proxy;
this.elementTag = elementTag;
proxyConfigured = false;
+ if( proxy instanceof Task )
+ ((Task)proxy).setRuntimeConfigurableWrapper( this );
}
/**
@@ -106,6 +113,10 @@
proxyConfigured = false;
}
+ public Object getProxy() {
+ return wrappedObject;
+ }
+
/**
* Sets the attributes for the wrapped element.
*
@@ -116,6 +127,14 @@
this.attributes = new AttributeListImpl(attributes);
}
+ public void setAttributes2(Attributes attributes) {
+ this.attributes2=new AttributesImpl( attributes );
+ }
+
+ public Attributes getAttributes2() {
+ return attributes2;
+ }
+
/**
* Returns the list of attributes for the wrapped element.
*
@@ -231,24 +250,37 @@
* an element which doesn't accept it.
*/
public void maybeConfigure(Project p, boolean configureChildren)
- throws BuildException {
+ throws BuildException
+ {
String id = null;
if (proxyConfigured) {
return;
}
+ //PropertyHelper ph=PropertyHelper.getPropertyHelper(p);
+
+ if (attributes2 != null) {
+ ProjectHelper.configure(wrappedObject, attributes2, p);
+ //ph.configure(wrappedObject, attributes2, p);
+ id = attributes2.getValue("id");
+ // No way - this will be used on future calls ( if the task is
used
+ // multiple times: attributes = null;
+ }
if (attributes != null) {
ProjectHelper.configure(wrappedObject, attributes, p);
+ //ph.configure(wrappedObject, attributes, p);
id = attributes.getValue("id");
}
+
if (characters.length() != 0) {
ProjectHelper.addText(p, wrappedObject, characters.toString());
}
+
Enumeration enum = children.elements();
while (enum.hasMoreElements()) {
RuntimeConfigurable child
- = (RuntimeConfigurable) enum.nextElement();
+ = (RuntimeConfigurable) enum.nextElement();
if (child.wrappedObject instanceof Task) {
Task childTask = (Task) child.wrappedObject;
childTask.setRuntimeConfigurableWrapper(child);
@@ -262,14 +294,14 @@
child.maybeConfigure(p);
}
ProjectHelper.storeChild(p, wrappedObject,
child.wrappedObject,
- child.getElementTag()
- .toLowerCase(Locale.US));
+ child.getElementTag()
+ .toLowerCase(Locale.US));
}
}
+
if (id != null) {
p.addReference(id, wrappedObject);
}
proxyConfigured = true;
}
-
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>