Browse Source

Added support for SAX2 attributes.

This is merged from RuntimeConfigurable2 ( sorry for the indentation
changes ).

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273654 13f79535-47bb-0310-9956-ffa450edef68
master
Costin Manolache 22 years ago
parent
commit
34bf2cc218
1 changed files with 38 additions and 6 deletions
  1. +38
    -6
      src/main/org/apache/tools/ant/RuntimeConfigurable.java

+ 38
- 6
src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -58,7 +58,9 @@ import java.util.Enumeration;
import java.util.Locale; import java.util.Locale;
import java.util.Vector; import java.util.Vector;
import org.xml.sax.AttributeList; import org.xml.sax.AttributeList;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributeListImpl; import org.xml.sax.helpers.AttributeListImpl;
import org.xml.sax.helpers.AttributesImpl;


/** /**
* Wrapper class that holds the attributes of an element, its children, and * Wrapper class that holds the attributes of an element, its children, and
@@ -75,8 +77,11 @@ public class RuntimeConfigurable {
private Vector children = new Vector(); private Vector children = new Vector();
/** The element to configure. */ /** The element to configure. */
private Object wrappedObject = null; private Object wrappedObject = null;
/** XML attributes for the element. */
/** @@deprecated
* XML attributes for the element. */
private AttributeList attributes; private AttributeList attributes;
/** XML attributes for the element. */
private Attributes attributes2;
/** Text appearing within the element. */ /** Text appearing within the element. */
private StringBuffer characters = new StringBuffer(); private StringBuffer characters = new StringBuffer();
/** Indicates if the wrapped object has been configured */ /** Indicates if the wrapped object has been configured */
@@ -93,6 +98,8 @@ public class RuntimeConfigurable {
wrappedObject = proxy; wrappedObject = proxy;
this.elementTag = elementTag; this.elementTag = elementTag;
proxyConfigured = false; proxyConfigured = false;
if( proxy instanceof Task )
((Task)proxy).setRuntimeConfigurableWrapper( this );
} }


/** /**
@@ -106,6 +113,10 @@ public class RuntimeConfigurable {
proxyConfigured = false; proxyConfigured = false;
} }


public Object getProxy() {
return wrappedObject;
}

/** /**
* Sets the attributes for the wrapped element. * Sets the attributes for the wrapped element.
* *
@@ -116,6 +127,14 @@ public class RuntimeConfigurable {
this.attributes = new AttributeListImpl(attributes); 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. * Returns the list of attributes for the wrapped element.
* *
@@ -231,24 +250,37 @@ public class RuntimeConfigurable {
* an element which doesn't accept it. * an element which doesn't accept it.
*/ */
public void maybeConfigure(Project p, boolean configureChildren) public void maybeConfigure(Project p, boolean configureChildren)
throws BuildException {
throws BuildException
{
String id = null; String id = null;


if (proxyConfigured) { if (proxyConfigured) {
return; 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) { if (attributes != null) {
ProjectHelper.configure(wrappedObject, attributes, p); ProjectHelper.configure(wrappedObject, attributes, p);
//ph.configure(wrappedObject, attributes, p);
id = attributes.getValue("id"); id = attributes.getValue("id");
} }

if (characters.length() != 0) { if (characters.length() != 0) {
ProjectHelper.addText(p, wrappedObject, characters.toString()); ProjectHelper.addText(p, wrappedObject, characters.toString());
} }

Enumeration enum = children.elements(); Enumeration enum = children.elements();
while (enum.hasMoreElements()) { while (enum.hasMoreElements()) {
RuntimeConfigurable child RuntimeConfigurable child
= (RuntimeConfigurable) enum.nextElement();
= (RuntimeConfigurable) enum.nextElement();
if (child.wrappedObject instanceof Task) { if (child.wrappedObject instanceof Task) {
Task childTask = (Task) child.wrappedObject; Task childTask = (Task) child.wrappedObject;
childTask.setRuntimeConfigurableWrapper(child); childTask.setRuntimeConfigurableWrapper(child);
@@ -262,14 +294,14 @@ public class RuntimeConfigurable {
child.maybeConfigure(p); child.maybeConfigure(p);
} }
ProjectHelper.storeChild(p, wrappedObject, child.wrappedObject, ProjectHelper.storeChild(p, wrappedObject, child.wrappedObject,
child.getElementTag()
.toLowerCase(Locale.US));
child.getElementTag()
.toLowerCase(Locale.US));
} }
} }

if (id != null) { if (id != null) {
p.addReference(id, wrappedObject); p.addReference(id, wrappedObject);
} }
proxyConfigured = true; proxyConfigured = true;
} }

} }

Loading…
Cancel
Save