Browse Source

Small cleanup

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274355 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
6540a295cd
2 changed files with 27 additions and 24 deletions
  1. +26
    -23
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  2. +1
    -1
      src/main/org/apache/tools/ant/types/DataType.java

+ 26
- 23
src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -61,9 +61,7 @@ import java.util.Hashtable;
import java.io.Serializable; import java.io.Serializable;


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
@@ -76,15 +74,19 @@ public class RuntimeConfigurable implements Serializable {


/** Name of the element to configure. */ /** Name of the element to configure. */
private String elementTag = null; private String elementTag = null;
/** List of child element wrappers. */ /** List of child element wrappers. */
private Vector children = new Vector(); private Vector children = new Vector();
/** The element to configure. It is only used during /** The element to configure. It is only used during
* maybeConfigure. * maybeConfigure.
*/ */
private transient Object wrappedObject = null; private transient Object wrappedObject = null;


/** @@deprecated
* XML attributes for the element. */
/**
* @deprecated
* XML attributes for the element.
*/
private transient AttributeList attributes; private transient AttributeList attributes;


/** Attribute names and values. While the XML spec doesn't require /** Attribute names and values. While the XML spec doesn't require
@@ -93,12 +95,14 @@ public class RuntimeConfigurable implements Serializable {
* We could also just use SAX2 Attributes and convert to SAX1 ( DOM * We could also just use SAX2 Attributes and convert to SAX1 ( DOM
* attribute Nodes can also be stored in SAX2 Attributges ) * attribute Nodes can also be stored in SAX2 Attributges )
*/ */
private Vector attNames=new Vector();
private Vector attValues=new Vector();
private Hashtable attMap=new Hashtable();
private Vector attributeNames = new Vector();
/** Map of attribute names to values */
private Hashtable attributeMap = new Hashtable();


/** 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 */
private boolean proxyConfigured = false; private boolean proxyConfigured = false;


@@ -114,8 +118,9 @@ public class RuntimeConfigurable implements Serializable {
this.elementTag = elementTag; this.elementTag = elementTag;
proxyConfigured = false; proxyConfigured = false;
// Most likely an UnknownElement // Most likely an UnknownElement
if( proxy instanceof Task )
((Task)proxy).setRuntimeConfigurableWrapper( this );
if (proxy instanceof Task) {
((Task) proxy).setRuntimeConfigurableWrapper(this);
}
} }


/** /**
@@ -142,14 +147,13 @@ public class RuntimeConfigurable implements Serializable {
public void setAttributes(AttributeList attributes) { public void setAttributes(AttributeList attributes) {
this.attributes = new AttributeListImpl(attributes); this.attributes = new AttributeListImpl(attributes);
for (int i = 0; i < attributes.getLength(); i++) { for (int i = 0; i < attributes.getLength(); i++) {
this.setAttribute( attributes.getName(i), attributes.getValue(i));
setAttribute(attributes.getName(i), attributes.getValue(i));
} }
} }


public void setAttribute( String name, String value ) {
attNames.addElement( name );
attValues.addElement( value );
attMap.put( name, value );
public void setAttribute(String name, String value) {
attributeNames.addElement(name);
attributeMap.put(name, value);
} }


/** Return the attribute map. /** Return the attribute map.
@@ -157,7 +161,7 @@ public class RuntimeConfigurable implements Serializable {
* @return Attribute name to attribute value map * @return Attribute name to attribute value map
*/ */
public Hashtable getAttributeMap() { public Hashtable getAttributeMap() {
return attMap;
return attributeMap;
} }


/** /**
@@ -286,8 +290,7 @@ public class RuntimeConfigurable implements Serializable {
* 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) {
@@ -295,16 +298,16 @@ public class RuntimeConfigurable implements Serializable {
} }


// Configure the object // Configure the object
Object target=(wrappedObject instanceof TaskAdapter) ?
((TaskAdapter)wrappedObject).getProxy() : wrappedObject;
Object target = (wrappedObject instanceof TaskAdapter) ?
((TaskAdapter) wrappedObject).getProxy() : wrappedObject;


//PropertyHelper ph=PropertyHelper.getPropertyHelper(p); //PropertyHelper ph=PropertyHelper.getPropertyHelper(p);
IntrospectionHelper ih = IntrospectionHelper ih =
IntrospectionHelper.getHelper(p, target.getClass()); IntrospectionHelper.getHelper(p, target.getClass());


for( int i=0; i< attNames.size(); i++ ) {
String name=(String) attNames.elementAt(i);
String value=(String) attValues.elementAt(i);
for (int i = 0; i < attributeNames.size(); i++) {
String name = (String) attributeNames.elementAt(i);
String value = (String) attributeMap.get(name);


// reflect these into the target // reflect these into the target
value = p.replaceProperties(value); value = p.replaceProperties(value);
@@ -318,7 +321,7 @@ public class RuntimeConfigurable implements Serializable {
} }
} }
} }
id = (String)attMap.get("id");
id = (String) attributeMap.get("id");


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


+ 1
- 1
src/main/org/apache/tools/ant/types/DataType.java View File

@@ -74,7 +74,7 @@ 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 description the user has set.
* *
* @deprecated The user should not be directly referencing * @deprecated The user should not be directly referencing
* variable. Please use {@link #setDescription} or * variable. Please use {@link #setDescription} or


Loading…
Cancel
Save