diff --git a/proposal/embed/README b/proposal/embed/README
deleted file mode 100644
index 35782ee72..000000000
--- a/proposal/embed/README
+++ /dev/null
@@ -1,2 +0,0 @@
-Copy the files in o.a.t.ant, recompile.
-
diff --git a/proposal/embed/build.xml b/proposal/embed/build.xml
deleted file mode 100644
index 70e8651ce..000000000
--- a/proposal/embed/build.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-null.
- * @param value The new value of the property.
- * Must not be null.
- * @return true if this helper has stored the property, false if it
- * couldn't. Each helper should delegate to the next one ( unless it
- * has a good reason not to ).
- */
- public boolean setPropertyHook(String ns, String name,
- Object value,
- boolean inherited, boolean user,
- boolean isNew)
- {
- if( getNext()!=null ) {
- boolean subst=getNext().setPropertyHook(ns, name, value,
- inherited, user, isNew);
- // If next has handled the property
- if( subst ) {
- return true;
- }
- }
-
- return false;
- }
-
- /** Get a property. If all hooks return null, the default
- * tables will be used.
- *
- * @param ns
- * @param name
- * @return
- */
- public Object getPropertyHook(String ns, String name, boolean user) {
- if( getNext() != null ) {
- Object o=getNext().getPropertyHook(ns, name, user);
- if( o!= null ) return o;
- }
- // Experimental/Testing, will be removed
- if( name.startsWith( "toString:" )) {
- name=name.substring( "toString:".length());
- Object v=project.getReference( name );
- if( v==null ) return null;
- return v.toString();
- }
-
-
- return null;
- }
-
- // -------------------- Optional methods --------------------
- // You can override those methods if you want to optimize or
- // do advanced things ( like support a special syntax ).
- // The methods do not chain - you should use them when embedding ant
- // ( by replacing the main helper )
-
- /**
- * Parses a string containing ${xxx} style property
- * references into two lists. The first list is a collection
- * of text fragments, while the other is a set of string property names.
- * null entries in the first list indicate a property
- * reference from the second list.
- *
- * It can be overriden with a more efficient or customized version.
- *
- * @param value Text to parse. Must not be null.
- * @param fragments List to add text fragments to.
- * Must not be null.
- * @param propertyRefs List to add property names to.
- * Must not be null.
- *
- * @exception BuildException if the string contains an opening
- * ${ without a closing
- * }
- */
- public void parsePropertyString(String value, Vector fragments,
- Vector propertyRefs)
- throws BuildException
- {
- parsePropertyStringDefault(value, fragments, propertyRefs);
- }
-
- /**
- * Replaces ${xxx} style constructions in the given value
- * with the string value of the corresponding data types.
- *
- * @param value The string to be scanned for property references.
- * May be null, in which case this
- * method returns immediately with no effect.
- * @param keys Mapping (String to String) of property names to their
- * values. If null, only project properties will
- * be used.
- *
- * @exception BuildException if the string contains an opening
- * ${ without a closing
- * }
- * @return the original string with the properties replaced, or
- * null if the original string is null.
- */
- public String replaceProperties(String ns, String value,
- Hashtable keys)
- throws BuildException
- {
- if (value == null) {
- return null;
- }
-
- Vector fragments = new Vector();
- Vector propertyRefs = new Vector();
- parsePropertyString(value, fragments, propertyRefs);
-
- StringBuffer sb = new StringBuffer();
- Enumeration i = fragments.elements();
- Enumeration j = propertyRefs.elements();
-
- while (i.hasMoreElements()) {
- String fragment = (String) i.nextElement();
- if (fragment == null) {
- String propertyName = (String) j.nextElement();
- Object replacement=null;
-
- // try to get it from the project or keys
- // Backward compatibility
- if( keys!=null ) {
- replacement=keys.get(propertyName);
- }
- if( replacement==null ) {
- replacement=getProperty(ns, propertyName);
- }
-
- if (replacement == null ) {
- project.log("Property ${" + propertyName
- + "} has not been set", Project.MSG_VERBOSE);
- }
- fragment = (replacement!=null)
- ? replacement.toString()
- : "${" + propertyName + "}";
- }
- sb.append(fragment);
- }
-
- return sb.toString();
- }
-
- // -------------------- Default implementation --------------------
- // Methods used to support the default behavior and provide backward
- // compatibility. Some will be deprecated, you should avoid calling them.
-
-
- /** Default implementation of setProperty. Will be called from Project.
- * This is the original 1.5 implementation, with calls to the hook
- * added.
- */
- public synchronized boolean setProperty(String ns, String name,
- Object value, boolean verbose)
- {
- // user ( CLI ) properties take precedence
- if (null != userProperties.get(name)) {
- if( verbose ) {
- project.log("Override ignored for user property " + name,
- Project.MSG_VERBOSE);
- }
- return false;
- }
-
- boolean done=this.setPropertyHook(ns, name, value, false, false, false);
- if( done ) {
- return true;
- }
-
- if (null != properties.get(name) && verbose) {
- project.log("Overriding previous definition of property " + name,
- Project.MSG_VERBOSE);
- }
-
- if( verbose ) {
- project.log("Setting project property: " + name + " -> " +
- value, Project.MSG_DEBUG);
- }
- properties.put(name, value);
- return true;
- }
-
- /**
- * Sets a property if no value currently exists. If the property
- * exists already, a message is logged and the method returns with
- * no other effect.
- *
- * @param name The name of property to set.
- * Must not be null.
- * @param value The new value of the property.
- * Must not be null.
- * @since Ant 1.6
- */
- public synchronized void setNewProperty(String ns, String name,
- Object value)
- {
- if (null != properties.get(name)) {
- project.log("Override ignored for property " + name,
- Project.MSG_VERBOSE);
- return;
- }
-
- boolean done=this.setPropertyHook(ns, name, value, false, true, false);
- if( done ) {
- return;
- }
-
- project.log("Setting project property: " + name + " -> " +
- value, Project.MSG_DEBUG);
- properties.put(name, value);
- }
-
- /**
- * Sets a user property, which cannot be overwritten by
- * set/unset property calls. Any previous value is overwritten.
- * @param name The name of property to set.
- * Must not be null.
- * @param value The new value of the property.
- * Must not be null.
- */
- public synchronized void setUserProperty(String ns, String name,
- Object value)
- {
- project.log("Setting ro project property: " + name + " -> " +
- value, Project.MSG_DEBUG);
- userProperties.put(name, value);
-
- boolean done=this.setPropertyHook(ns, name, value, false, false, true);
- if( done ) {
- return;
- }
- properties.put(name, value);
- }
-
- /**
- * Sets a user property, which cannot be overwritten by set/unset
- * property calls. Any previous value is overwritten. Also marks
- * these properties as properties that have not come from the
- * command line.
- *
- * @param name The name of property to set.
- * Must not be null.
- * @param value The new value of the property.
- * Must not be null.
- */
- public synchronized void setInheritedProperty(String ns, String name,
- Object value)
- {
- inheritedProperties.put(name, value);
-
- project.log("Setting ro project property: " + name + " -> " +
- value, Project.MSG_DEBUG);
- userProperties.put(name, value);
-
- boolean done=this.setPropertyHook(ns, name, value, true, false, false);
- if( done ) {
- return;
- }
- properties.put(name, value);
- }
-
- // -------------------- Getting properties --------------------
-
- /**
- * Returns the value of a property, if it is set. You can override
- * this method in order to plug your own storage.
- *
- * @param name The name of the property.
- * May be null, in which case
- * the return value is also null.
- * @return the property value, or null for no match
- * or if a null name is provided.
- */
- public Object getProperty(String ns, String name) {
- if (name == null) {
- return null;
- }
-
- Object o=getPropertyHook(ns, name, false);
- if( o!= null ) {
- return o;
- }
-
- return properties.get(name);
- }
- /**
- * Returns the value of a user property, if it is set.
- *
- * @param name The name of the property.
- * May be null, in which case
- * the return value is also null.
- * @return the property value, or null for no match
- * or if a null name is provided.
- */
- public Object getUserProperty(String ns, String name) {
- if (name == null) {
- return null;
- }
- Object o=getPropertyHook(ns, name, true);
- if( o!= null ) {
- return o;
- }
- return userProperties.get(name);
- }
-
-
- // -------------------- Access to property tables --------------------
- // This is used to support ant call and similar tasks. It should be
- // deprecated, it is possible to use a better ( more efficient )
- // mechanism to preserve the context.
-
- // TODO: do we need to delegate ?
-
- /**
- * Returns a copy of the properties table.
- * @return a hashtable containing all properties
- * (including user properties).
- */
- public Hashtable getProperties() {
- Hashtable propertiesCopy = new Hashtable();
-
- Enumeration e = properties.keys();
- while (e.hasMoreElements()) {
- Object name = e.nextElement();
- Object value = properties.get(name);
- propertiesCopy.put(name, value);
- }
-
- // There is a better way to save the context. This shouldn't
- // delegate to next, it's for backward compat only.
-
- return propertiesCopy;
- }
-
- /**
- * Returns a copy of the user property hashtable
- * @return a hashtable containing just the user properties
- */
- public Hashtable getUserProperties() {
- Hashtable propertiesCopy = new Hashtable();
-
- Enumeration e = userProperties.keys();
- while (e.hasMoreElements()) {
- Object name = e.nextElement();
- Object value = properties.get(name);
- propertiesCopy.put(name, value);
- }
-
- return propertiesCopy;
- }
-
- /**
- * Copies all user properties that have not been set on the
- * command line or a GUI tool from this instance to the Project
- * instance given as the argument.
- *
- *
To copy all "user" properties, you will also have to call - * {@link #copyUserProperties copyUserProperties}.
- * - * @param other the project to copy the properties to. Must not be null. - * - * @since Ant 1.6 - */ - public void copyInheritedProperties(Project other) { - Enumeration e = inheritedProperties.keys(); - while (e.hasMoreElements()) { - String arg = e.nextElement().toString(); - if (other.getUserProperty(arg) != null) { - continue; - } - Object value = inheritedProperties.get(arg); - other.setInheritedProperty(arg, value.toString()); - } - } - - /** - * Copies all user properties that have been set on the command - * line or a GUI tool from this instance to the Project instance - * given as the argument. - * - *To copy all "user" properties, you will also have to call - * {@link #copyInheritedProperties copyInheritedProperties}.
- * - * @param other the project to copy the properties to. Must not be null. - * - * @since Ant 1.6 - */ - public void copyUserProperties(Project other) { - Enumeration e = userProperties.keys(); - while (e.hasMoreElements()) { - Object arg = e.nextElement(); - if (inheritedProperties.containsKey(arg)) { - continue; - } - Object value = userProperties.get(arg); - other.setUserProperty(arg.toString(), value.toString()); - } - } - - // -------------------- Property parsing -------------------- - // Moved from ProjectHelper. You can override the static method - - // this is used for backward compatibility ( for code that calls - // the parse method in ProjectHelper ). - - /** Default parsing method. It is here only to support backward compat - * for the static ProjectHelper.parsePropertyString(). - */ - static void parsePropertyStringDefault(String value, Vector fragments, - Vector propertyRefs) - throws BuildException - { - int prev = 0; - int pos; - //search for the next instance of $ from the 'prev' position - while ((pos = value.indexOf("$", prev)) >= 0) { - - //if there was any text before this, add it as a fragment - //TODO, this check could be modified to go if pos>prev; - //seems like this current version could stick empty strings - //into the list - if (pos > 0) { - fragments.addElement(value.substring(prev, pos)); - } - //if we are at the end of the string, we tack on a $ - //then move past it - if (pos == (value.length() - 1)) { - fragments.addElement("$"); - prev = pos + 1; - } else if (value.charAt(pos + 1) != '{') { - //peek ahead to see if the next char is a property or not - //not a property: insert the char as a literal - /* - fragments.addElement(value.substring(pos + 1, pos + 2)); - prev = pos + 2; - */ - if (value.charAt(pos + 1) == '$') { - //backwards compatibility two $ map to one mode - fragments.addElement("$"); - prev = pos + 2; - } else { - //new behaviour: $X maps to $X for all values of X!='$' - fragments.addElement(value.substring(pos, pos + 2)); - prev = pos + 2; - } - - } else { - //property found, extract its name or bail on a typo - int endName = value.indexOf('}', pos); - if (endName < 0) { - throw new BuildException("Syntax error in property: " - + value); - } - String propertyName = value.substring(pos + 2, endName); - fragments.addElement(null); - propertyRefs.addElement(propertyName); - prev = endName + 1; - } - } - //no more $ signs found - //if there is any tail to the file, append it - if (prev < value.length()) { - fragments.addElement(value.substring(prev)); - } - } - -} diff --git a/proposal/embed/src/java/org/apache/tools/ant/RuntimeConfigurable2.java b/proposal/embed/src/java/org/apache/tools/ant/RuntimeConfigurable2.java deleted file mode 100644 index 7422ae39f..000000000 --- a/proposal/embed/src/java/org/apache/tools/ant/RuntimeConfigurable2.java +++ /dev/null @@ -1,348 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, if - * any, must include the following acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * - * 4. The names "The Jakarta Project", "Ant", and "Apache Software - * Foundation" must not be used to endorse or promote products derived - * from this software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *null.
- * @param elementTag The tag name generating this element.
- * Should not be null.
- */
- public RuntimeConfigurable2(Project project, Location location, Object proxy, String elementTag) {
- super( proxy, elementTag );
- wrappedObject = proxy;
- this.elementTag = elementTag;
- // This should never happen - all objects are lazy
- if( proxy instanceof Task )
- ((Task)proxy).setRuntimeConfigurableWrapper( this );
- proxyConfigured=false;
- }
-
- Project getProject() {
- return project;
- }
-
- Location getLocation() {
- return location;
- }
- /**
- * Sets the element to configure. This is used when the real type of
- * an element isn't known at the time of wrapper creation.
- *
- * @param proxy The element to configure. Must not be null.
- */
- public void setProxy(Object proxy) {
- wrappedObject = proxy;
- proxyConfigured=false;
- }
-
- public Object getProxy() {
- return wrappedObject;
- }
-
- /**
- * Sets the attributes for the wrapped element.
- *
- * @param attributes List of attributes defined in the XML for this
- * element. May be null.
- * @deprecated It shouldn't be called by anyone except ProjectHelper
- */
- public void setAttributes(AttributeList attributes) {
- // this.attributes = new AttributeListImpl(attributes);
- }
-
- public void setAttributes2(Attributes attributes) {
- this.attributes=new AttributesImpl( attributes );
- }
-
- /**
- * Returns the list of attributes for the wrapped element.
- *
- * @return An AttributeList representing the attributes defined in the
- * XML for this element. May be null.
- * @deprecated only for bkwd compatibility
- */
- public AttributeList getAttributes() {
- return sax1Attributes( attributes );
- }
-
- public Attributes getAttributes2() {
- return attributes;
- }
-
- public static AttributeList sax1Attributes( Attributes sax2Att ) {
- AttributeListImpl sax1Att=new AttributeListImpl();
- int length = sax2Att.getLength();
- if (length > 0) {
- for (int i = 0; i < length; i++) {
- // System.out.println("Attributes: " + sax2Att.getQName(i) + " " +
- // sax2Att.getValue(i));
- sax1Att.addAttribute( sax2Att.getQName(i),
- sax2Att.getType(i),
- sax2Att.getValue(i));
- }
- }
- return sax1Att;
- }
-
- /**
- * Adds a child element to the wrapped element.
- *
- * @param child The child element wrapper to add to this one.
- * Must not be null.
- */
- public void addChild(RuntimeConfigurable child) {
- // addChild( UnknownElement ) in UE
- children.addElement(child);
- }
-
- /**
- * Returns the child wrapper at the specified position within the list.
- *
- * @param index The index of the child to return.
- *
- * @return The child wrapper at position index within the
- * list.
- */
- public RuntimeConfigurable getChild(int index) {
- return (RuntimeConfigurable) children.elementAt(index);
- }
-
- /**
- * Adds characters from #PCDATA areas to the wrapped element.
- *
- * @param data Text to add to the wrapped element.
- * Should not be null.
- */
- public void addText(String data) {
- characters.append(data);
- }
-
- /**
- * Adds characters from #PCDATA areas to the wrapped element.
- *
- * @param buf A character array of the text within the element.
- * Must not be null.
- * @param start The start element in the array.
- * @param count The number of characters to read from the array.
- *
- */
- public void addText(char[] buf, int start, int count) {
- addText(new String(buf, start, count));
- }
-
- /**
- * Returns the tag name of the wrapped element.
- *
- * @return The tag name of the wrapped element. This is unlikely
- * to be null, but may be.
- */
- public String getElementTag() {
- // getTag in UE
- return elementTag;
- }
-
- /**
- * Configures the wrapped element and all its children.
- * The attributes and text for the wrapped element are configured,
- * and then each child is configured and added. Each time the
- * wrapper is configured, the attributes and text for it are
- * reset.
- *
- * If the element has an id attribute, a reference
- * is added to the project as well.
- *
- * @param p The project containing the wrapped element.
- * Must not be null.
- *
- * @exception BuildException if the configuration fails, for instance due
- * to invalid attributes or children, or text being added to
- * an element which doesn't accept it.
- */
- public void maybeConfigure(Project p) throws BuildException {
- maybeConfigure(p, true);
- }
-
- /**
- * Configures the wrapped element. The attributes and text for
- * the wrapped element are configured. Each time the wrapper is
- * configured, the attributes and text for it are reset.
- *
- * If the element has an id attribute, a reference
- * is added to the project as well.
- *
- * @param p The project containing the wrapped element.
- * Must not be null.
- *
- * @param configureChildren Whether to configure child elements as
- * well. if true, child elements will be configured after the
- * wrapped element.
- *
- * @exception BuildException if the configuration fails, for instance due
- * to invalid attributes or children, or text being added to
- * an element which doesn't accept it.
- */
- public void maybeConfigure(Project p, boolean configureChildren)
- throws BuildException {
- String id = null;
-
- if( proxyConfigured ) {
- return;
- }
- PropertyHelper ph=PropertyHelper.getPropertyHelper(p);
-
- Object target=(wrappedObject instanceof TaskAdapter) ?
- ((TaskAdapter)wrappedObject).getProxy() : wrappedObject;
-
- if (attributes != null) {
- IntrospectionHelper ih =
- IntrospectionHelper.getHelper(target.getClass());
- p.addBuildListener( ih );
-
- for (int i = 0; i < attributes.getLength(); i++) {
- String name= attributes.getQName(i);
- String value= attributes.getValue(i);
-
- // reflect these into the target
- value = ph.replaceProperties(null, value, p.getProperties());
- try {
- ih.setAttribute(p, target,
- name.toLowerCase(Locale.US), value);
- } catch (BuildException be) {
- // id attribute must be set externally
- if (!name.equals("id")) {
- throw be;
- }
- }
- }
- id = attributes.getValue("id");
- // No way - this will be used on future calls ( if the task is used
- // multiple times: attributes = null;
- }
- if (characters.length() != 0) {
- ProjectHelper.addText(p, wrappedObject, characters.toString());
- }
- Enumeration enum = children.elements();
- while (enum.hasMoreElements()) {
- RuntimeConfigurable2 child
- = (RuntimeConfigurable2) enum.nextElement();
- if (child.wrappedObject instanceof Task) {
- Task childTask = (Task) child.wrappedObject;
- childTask.setRuntimeConfigurableWrapper(child);
- }
-
- if (configureChildren) {
- if (child.wrappedObject instanceof Task) {
- Task childTask = (Task) child.wrappedObject;
- childTask.maybeConfigure();
- } else {
- child.maybeConfigure(p);
- }
- ProjectHelper.storeChild(p, wrappedObject, child.wrappedObject,
- child.getElementTag()
- .toLowerCase(Locale.US));
- }
- }
-
- if (id != null) {
- // p.addReference(id, wrappedObject);
- p.getReferences().put( id, wrappedObject );
- //System.out.println("XXX updating reference " + this + " " + id + " " + wrappedObject );
- }
-
- proxyConfigured = true;
- }
-
-
-
-}
diff --git a/proposal/embed/src/java/org/apache/tools/ant/UnknownElement2.java b/proposal/embed/src/java/org/apache/tools/ant/UnknownElement2.java
deleted file mode 100644
index 6f273deb2..000000000
--- a/proposal/embed/src/java/org/apache/tools/ant/UnknownElement2.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Ant", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * null.
- */
- public UnknownElement2(String elementName) {
- super( elementName );
- this.elementName = elementName;
- }
-
- /**
- * Returns the name of the XML element which generated this unknown
- * element.
- *
- * @return the name of the XML element which generated this unknown
- * element.
- */
- public String getTag() {
- return elementName;
- }
-
- public RuntimeConfigurable getWrapper() {
- return wrapper;
- }
-
- protected RuntimeConfigurable2 getWrapper2() {
- return (RuntimeConfigurable2)wrapper;
- }
-
-
- /**
- * Creates the real object instance and child elements, then configures
- * the attributes and text of the real object. This unknown element
- * is then replaced with the real object in the containing target's list
- * of children.
- *
- * @exception BuildException if the configuration fails
- */
- public void maybeConfigure() throws BuildException {
- ProjectComponentHelper helper=ProjectComponentHelper.getProjectComponentHelper();
- // Used to be: makeObject(this, getWrapper2());
- realThing = helper.createProjectComponent( this, getProject(), null,
- this.getTag());
- if (realThing == null) {
- throw getNotFoundException("task or type", this.getTag());
- }
-
- getWrapper2().setProxy(realThing);
-
- if (realThing instanceof Task) {
- Task task=(Task)realThing;
- task.setLocation(this.getLocation());
- // UnknownElement always has an associated target
- task.setOwningTarget(this.getOwningTarget());
- task.init();
- task.setRuntimeConfigurableWrapper(getWrapper2());
-
- // For Script to work. Ugly
- // The reference is replaced by RuntimeConfigurable
- this.getOwningTarget().replaceChild(this, (Task)realThing);
- }
-
- handleChildren(realThing, getWrapper2());
-
- getWrapper2().maybeConfigure(getProject());
-
-
- }
-
- /**
- * Handles output sent to System.out by this task or its real task.
- *
- * @param line The line of output to log. Should not be null.
- */
- protected void handleOutput(String line) {
- if (realThing instanceof Task) {
- ((Task) realThing).handleOutput(line);
- } else {
- super.handleOutput(line);
- }
- }
-
- /**
- * Handles error output sent to System.err by this task or its real task.
- *
- * @param line The error line to log. Should not be null.
- */
- protected void handleErrorOutput(String line) {
- if (realThing instanceof Task) {
- ((Task) realThing).handleErrorOutput(line);
- } else {
- super.handleErrorOutput(line);
- }
- }
-
- /**
- * Executes the real object if it's a task. If it's not a task
- * (e.g. a data type) then this method does nothing.
- */
- public void execute() {
- if (realThing == null) {
- // plain impossible to get here, maybeConfigure should
- // have thrown an exception.
- throw new BuildException("Could not create task of type: "
- + elementName, getLocation());
- }
-
- if (realThing instanceof Task) {
- ((Task) realThing).execute();
- }
- // the task will not be reused ( a new init() will be called )
- // Let GC do its job
- realThing=null;
- }
-
- /**
- * Adds a child element to this element.
- *
- * @param child The child element to add. Must not be null.
- */
- public void addChild(UnknownElement child) {
- children.addElement(child);
- }
-
- /**
- * Creates child elements, creates children of the children
- * (recursively), and sets attributes of the child elements.
- *
- * @param parent The configured object for the parent.
- * Must not be null.
- *
- * @param parentWrapper The wrapper containing child wrappers
- * to be configured. Must not be null
- * if there are any children.
- *
- * @exception BuildException if the children cannot be configured.
- */
- protected void handleChildren(Object parent,
- RuntimeConfigurable parentWrapper)
- throws BuildException {
-
- if (parent instanceof TaskAdapter) {
- parent = ((TaskAdapter) parent).getProxy();
- }
-
- Class parentClass = parent.getClass();
- IntrospectionHelper ih = IntrospectionHelper.getHelper(parentClass);
-
- for (int i = 0; i < children.size(); i++) {
- RuntimeConfigurable childWrapper = parentWrapper.getChild(i);
- UnknownElement child = (UnknownElement) children.elementAt(i);
- Object realChild = null;
-
- if (parent instanceof TaskContainer) {
- ProjectComponentHelper helper=ProjectComponentHelper.getProjectComponentHelper();
- // Used to be: makeTask(child, childWrapper, false);
- realChild = helper.createProjectComponent( child, getProject(), null,
- child.getTag());
- if (realChild == null ) {
- throw getNotFoundException("task", child.getTag());
- }
-
- // XXX DataTypes will be wrapped or treated like normal components
- if( realChild instanceof Task ) {
- ((TaskContainer) parent).addTask((Task) realChild);
- Task task=(Task)realChild;
- task.setLocation(child.getLocation());
- // UnknownElement always has an associated target
- task.setOwningTarget(this.getOwningTarget());
- task.init();
- } else {
- // What ? Add data type ? createElement ?
- }
- } else {
- // Introspection-based task creation
- realChild = ih.createElement(getProject(), parent, child.getTag());
- }
-
- childWrapper.setProxy(realChild);
- if (parent instanceof TaskContainer) {
- ((Task) realChild).setRuntimeConfigurableWrapper(childWrapper);
- }
-
- child.handleChildren(realChild, childWrapper);
-
- if (parent instanceof TaskContainer) {
- ((Task) realChild).maybeConfigure();
- }
- }
- }
-
- /**
- * @deprecated no longer used
- */
- protected Object makeObject(UnknownElement ue, RuntimeConfigurable w) {
- /*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();}
- return null;
- }
-
- /**
- * @deprecated no longer used
- */
- protected Task makeTask(UnknownElement ue, RuntimeConfigurable w,
- boolean onTopLevel) {
- /*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();}
- return null;
- }
-
-
- /**
- * Returns the name to use in logging messages.
- *
- * @return the name to use in logging messages.
- */
- public String getTaskName() {
- return elementName; // cleaner, works for everything
- // return realThing == null || !(realThing instanceof Task) ?
- // super.getTaskName() : ((Task) realThing).getTaskName();
- }
-
- public Object getWrapped() {
- return realThing;
- }
-
- /**
- * returns the task instance after it has been created and if it is a task.
- *
- * @return a task instance or null if the real object is not
- * a task.
- */
- public Task getTask() {
- if (realThing instanceof Task) {
- return (Task) realThing;
- }
- return null;
- }
-
-}// UnknownElement
diff --git a/proposal/embed/src/java/org/apache/tools/ant/helper/ProjectHelperImpl2.java b/proposal/embed/src/java/org/apache/tools/ant/helper/ProjectHelperImpl2.java
deleted file mode 100644
index 7e6e13650..000000000
--- a/proposal/embed/src/java/org/apache/tools/ant/helper/ProjectHelperImpl2.java
+++ /dev/null
@@ -1,1192 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Ant", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * null.
- * @param attrs Attributes of the element being started.
- * Will not be null.
- *
- * @exception SAXParseException if this method is not overridden, or in
- * case of error in an overridden version
- */
- public void onStartElement(String uri, String tag, String qname,
- Attributes attrs,
- AntXmlContext context)
- throws SAXParseException
- {
- }
-
- /**
- * Handles the start of an element. This base implementation just
- * throws an exception - you must override this method if you expect
- * child elements.
- *
- * @param tag The name of the element being started.
- * Will not be null.
- * @param attrs Attributes of the element being started.
- * Will not be null.
- *
- * @exception SAXParseException if this method is not overridden, or in
- * case of error in an overridden version
- */
- public AntHandler onStartChild(String uri, String tag, String qname,
- Attributes attrs,
- AntXmlContext context)
- throws SAXParseException
- {
- throw new SAXParseException("Unexpected element \"" + qname + " \"", context.locator);
- }
-
- public void onEndChild(String uri, String tag, String qname,
- AntXmlContext context)
- throws SAXParseException
- {
- }
-
- /**
- * Called when this element and all elements nested into it have been
- * handled (i.e. at the ).
- */
- public void onEndElement(String uri, String tag, AntXmlContext context) {
- }
-
- /**
- * Handles text within an element. This base implementation just
- * throws an exception, you must override it if you expect content.
- *
- * @param buf A character array of the text within the element.
- * Will not be null.
- * @param start The start element in the array.
- * @param count The number of characters to read from the array.
- *
- * @exception SAXParseException if this method is not overridden, or in
- * case of error in an overridden version
- */
- public void characters(char[] buf, int start, int count, AntXmlContext context)
- throws SAXParseException
- {
- String s = new String(buf, start, count).trim();
-
- if (s.length() > 0) {
- throw new SAXParseException("Unexpected text \"" + s + "\"", context.locator);
- }
- }
-
- /** Will be called every time a namespace is reached.
- It'll verify if the ns was processed, and if not load the task definitions.
- */
- protected void checkNamespace( String uri ) {
-
- }
- }
-
- /** Context information for the ant processing.
- */
- public static class AntXmlContext {
- /** The project to configure. */
- private Project project;
-
- /** The configuration file to parse. */
- public File buildFile;
-
- /**
- * Parent directory of the build file. Used for resolving entities
- * and setting the project's base directory.
- */
- public File buildFileParent;
-
- /** Name of the current project */
- public String currentProjectName;
-
- /**
- * Locator for the configuration file parser.
- * Used for giving locations of errors etc.
- */
- Locator locator;
-
- // Do we need those ?
- public ProjectHelperImpl2 helper;
- org.xml.sax.XMLReader parser;
-
- /**
- * Target that all other targets will depend upon implicitly.
- *
- * This holds all tasks and data type definitions that have - * been placed outside of targets.
- */ - Target implicitTarget = new Target(); - - /** Current target ( no need for a stack as the processing model - allows only one level of target ) */ - public Target currentTarget=null; - - /** The stack of RuntimeConfigurable2 wrapping the - objects. - */ - Vector wStack=new Vector(); - - public Hashtable namespaces=new Hashtable(); - - // Import stuff - public boolean ignoreProjectTag=false; - public Hashtable importedFiles = new Hashtable(); - public int importlevel = 0; - - public AntXmlContext(Project project, ProjectHelperImpl2 helper) { - this.project=project; - implicitTarget.setName(""); - this.helper=helper; - } - - public Project getProject() { - return project; - } - - public RuntimeConfigurable2 currentWrapper() { - if( wStack.size() < 1 ) return null; - return (RuntimeConfigurable2)wStack.elementAt( wStack.size() - 1 ); - } - - public RuntimeConfigurable2 parentWrapper() { - if( wStack.size() < 2 ) return null; - return (RuntimeConfigurable2)wStack.elementAt( wStack.size() - 2 ); - } - - public void pushWrapper( RuntimeConfigurable2 wrapper ) { - wStack.addElement(wrapper); - } - - public void popWrapper() { - if( wStack.size() > 0 ) - wStack.removeElementAt( wStack.size() - 1 ); - } - - public Vector getWrapperStack() { - return wStack; - } - - /** - * Scans an attribute list for theid attribute and
- * stores a reference to the target object in the project if an
- * id is found.
- *
- * This method was moved out of the configure method to allow
- * it to be executed at parse time.
- *
- * @see #configure(Object,AttributeList,Project)
- */
- void configureId(Object element, Attributes attr) {
- String id = attr.getValue("id");
- if (id != null) {
- project.addReference(id, element);
- }
- }
-
- }
-
- /**
- * Handler for ant processing. Uses a stack of AntHandlers to
- * implement each element ( the original parser used a recursive behavior,
- * with the implicit execution stack )
- */
- public static class RootHandler extends DefaultHandler {
- Stack antHandlers=new Stack();
- AntHandler currentHandler=null;
- AntXmlContext context;
-
- public RootHandler(AntXmlContext context) {
- currentHandler=ProjectHelperImpl2.mainHandler;
- antHandlers.push( currentHandler );
- this.context=context;
- }
-
- /**
- * Resolves file: URIs relative to the build file.
- *
- * @param publicId The public identifer, or Will be an absolute URI if the given path is absolute. This code doesn't handle non-ASCII characters properly. Will be an absolute path if the given URI is absolute. Swallows '%' that are not followed by two characters,
- * doesn't deal with non-ASCII characters.null
- * if none is available. Ignored in this
- * implementation.
- * @param systemId The system identifier provided in the XML
- * document. Will not be null.
- */
- public InputSource resolveEntity(String publicId,
- String systemId) {
-
- context.getProject().log("resolving systemId: " + systemId, Project.MSG_VERBOSE);
-
- if (systemId.startsWith("file:")) {
- String path = ProjectHelperImpl2.fromURI(systemId);
-
- File file = new File(path);
- if (!file.isAbsolute()) {
- file = fu.resolveFile(context.buildFileParent, path);
- }
- try {
- InputSource inputSource = new InputSource(new FileInputStream(file));
- inputSource.setSystemId(ProjectHelperImpl2.toURI(file.getAbsolutePath()));
- return inputSource;
- } catch (FileNotFoundException fne) {
- context.project.log(file.getAbsolutePath() + " could not be found",
- Project.MSG_WARN);
- }
-
- }
- // use default if not file or file not found
- return null;
- }
-
- /**
- * Handles the start of a project element. A project handler is created
- * and initialised with the element name and attributes.
- *
- * @param tag The name of the element being started.
- * Will not be null.
- * @param attrs Attributes of the element being started.
- * Will not be null.
- *
- * @exception SAXParseException if the tag given is not
- * "project"
- */
- public void startElement(String uri, String tag, String qname, Attributes attrs)
- throws SAXParseException
- {
- AntHandler next=currentHandler.onStartChild(uri, tag, qname, attrs, context);
- antHandlers.push( currentHandler );
- currentHandler=next;
- currentHandler.onStartElement( uri, tag, qname, attrs, context );
- }
-
- /**
- * Sets the locator in the project helper for future reference.
- *
- * @param locator The locator used by the parser.
- * Will not be null.
- */
- public void setDocumentLocator(Locator locator) {
- context.locator = locator;
- }
-
- /**
- * Handles the end of an element. Any required clean-up is performed
- * by the onEndElement() method and then the original handler is restored to
- * the parser.
- *
- * @param name The name of the element which is ending.
- * Will not be null.
- *
- * @exception SAXException in case of error (not thrown in
- * this implementation)
- *
- */
- public void endElement(String uri, String name, String qName) throws SAXException {
- currentHandler.onEndElement(uri, name, context);
- AntHandler prev=(AntHandler)antHandlers.pop();
- currentHandler=prev;
- if( currentHandler!=null )
- currentHandler.onEndChild( uri, name, qName, context );
- }
-
- public void characters(char[] buf, int start, int count)
- throws SAXParseException
- {
- currentHandler.characters( buf, start, count, context );
- }
- }
-
- public static class MainHandler extends AntHandler {
-
- public AntHandler onStartChild(String uri, String name, String qname,
- Attributes attrs,
- AntXmlContext context)
- throws SAXParseException
- {
- if (qname.equals("project")) {
- return ProjectHelperImpl2.projectHandler;
- } else {
-// if( context.importlevel > 0 ) {
-// // we are in an imported file. Allow top-level "default",
- * "name", "id" and "basedir".
- *
- * @param tag Name of the element which caused this handler
- * to be created. Should not be null.
- * Ignored in this implementation.
- * @param attrs Attributes of the element which caused this
- * handler to be created. Must not be null.
- *
- * @exception SAXParseException if an unexpected attribute is
- * encountered or if the "default" attribute
- * is missing.
- */
- public void onStartElement(String uri, String tag, String qname,
- Attributes attrs,
- AntXmlContext context)
- throws SAXParseException
- {
- String id = null;
- String baseDir = null;
-
- Project project=context.getProject();
-
- for (int i = 0; i < attrs.getLength(); i++) {
- String key = attrs.getQName(i);
- String value = attrs.getValue(i);
-
- if (key.equals("default")) {
- if ( value != null && !value.equals("")) {
- if( !context.ignoreProjectTag )
- project.setDefaultTarget(value);
- }
- } else if (key.equals("name")) {
- if (value != null) {
- context.currentProjectName=value;
-
- if( !context.ignoreProjectTag ) {
- project.setName(value);
- project.addReference(value, project);
- }
- }
- } else if (key.equals("id")) {
- if (value != null) {
- // What's the difference between id and name ?
- if( !context.ignoreProjectTag ) {
- project.addReference(value, project);
- }
- }
- } else if (key.equals("basedir")) {
- if( !context.ignoreProjectTag )
- baseDir = value;
- } else {
- // XXX ignore attributes in a different NS ( maybe store them ? )
- throw new SAXParseException("Unexpected attribute \"" + attrs.getQName(i) + "\"", context.locator);
- }
- }
-
- project.setUserProperty("ant.file."+context.currentProjectName,
- context.buildFile.toString());
-
- if( context.ignoreProjectTag ) {
- // no further processing
- return;
- }
- // set explicitely before starting ?
- if (project.getProperty("basedir") != null) {
- project.setBasedir(project.getProperty("basedir"));
- } else {
- // Default for baseDir is the location of the build file.
- if (baseDir == null) {
- project.setBasedir(context.buildFileParent.getAbsolutePath());
- } else {
- // check whether the user has specified an absolute path
- if ((new File(baseDir)).isAbsolute()) {
- project.setBasedir(baseDir);
- } else {
- project.setBaseDir(project.resolveFile(baseDir,
- context.buildFileParent));
- }
- }
- }
-
- project.addTarget("", context.implicitTarget);
- context.currentTarget=context.implicitTarget;
- }
-
- /**
- * Handles the start of a top-level element within the project. An
- * appropriate handler is created and initialised with the details
- * of the element.
- *
- * @param tag The name of the element being started.
- * Will not be null.
- * @param attrs Attributes of the element being started.
- * Will not be null.
- *
- * @exception SAXParseException if the tag given is not
- * "taskdef", "typedef",
- * "property", "target"
- * or a data type definition
- */
- public AntHandler onStartChild(String uri, String name, String qname,
- Attributes attrs,
- AntXmlContext context)
- throws SAXParseException
- {
- if (qname.equals("target")) {
- return ProjectHelperImpl2.targetHandler;
- } else {
- return ProjectHelperImpl2.elementHandler;
- }
- }
-
- }
-
- /**
- * Handler for "target" elements.
- */
- public static class TargetHandler extends AntHandler {
-
- /**
- * Initialisation routine called after handler creation
- * with the element name and attributes. The attributes which
- * this handler can deal with are: "name",
- * "depends", "if",
- * "unless", "id" and
- * "description".
- *
- * @param tag Name of the element which caused this handler
- * to be created. Should not be null.
- * Ignored in this implementation.
- * @param attrs Attributes of the element which caused this
- * handler to be created. Must not be null.
- *
- * @exception SAXParseException if an unexpected attribute is encountered
- * or if the "name" attribute is missing.
- */
- public void onStartElement(String uri, String tag, String qname,
- Attributes attrs,
- AntXmlContext context)
- throws SAXParseException
- {
- String name = null;
- String depends = "";
-
- Project project=context.getProject();
- Target target = new Target();
- context.currentTarget=target;
-
- for (int i = 0; i < attrs.getLength(); i++) {
- String key = attrs.getQName(i);
- String value = attrs.getValue(i);
-
- if (key.equals("name")) {
- name = value;
- if( "".equals( name ) )
- throw new BuildException("name attribute must not be empty");
- } else if (key.equals("depends")) {
- depends = value;
- } else if (key.equals("if")) {
- target.setIf(value);
- } else if (key.equals("unless")) {
- target.setUnless(value);
- } else if (key.equals("id")) {
- if (value != null && !value.equals("")) {
- context.getProject().addReference(value, target);
- }
- } else if (key.equals("description")) {
- target.setDescription(value);
- } else {
- throw new SAXParseException("Unexpected attribute \"" + key + "\"", context.locator);
- }
- }
-
- if (name == null) {
- throw new SAXParseException("target element appears without a name attribute",
- context.locator);
- }
-
- Hashtable currentTargets = project.getTargets();
-
- // If the name has already beend defined ( import for example )
- if(currentTargets.containsKey(name)) {
- // Alter the name.
- if( context.currentProjectName != null ) {
- String newName=context.currentProjectName + "." + name;
- project.log("Already defined in main or a previous import, define "
- + name + " as " + newName,
- Project.MSG_VERBOSE);
- name=newName;
- } else {
- project.log("Already defined in main or a previous import, ignore "
- + name,
- Project.MSG_VERBOSE);
- name=null;
- }
- }
-
- if( name != null ) {
- target.setName(name);
- project.addOrReplaceTarget(name, target);
- }
-
-
- project.log("Targets are now: "+ currentTargets ,
- Project.MSG_VERBOSE);
-
- // take care of dependencies
- if (depends.length() > 0) {
- target.setDepends(depends);
- }
- }
-
- /**
- * Handles the start of an element within a target.
- *
- * @param tag The name of the element being started.
- * Will not be null.
- * @param attrs Attributes of the element being started.
- * Will not be null.
- *
- * @exception SAXParseException if an error occurs when initialising
- * the appropriate child handler
- */
- public AntHandler onStartChild(String uri, String name, String qname,
- Attributes attrs,
- AntXmlContext context)
- throws SAXParseException
- {
- return ProjectHelperImpl2.elementHandler;
- }
- public void onEndElement(String uri, String tag, AntXmlContext context) {
- context.currentTarget=context.implicitTarget;
- }
- }
-
- /**
- * Handler for all project elements ( tasks, data types )
- */
- public static class ElementHandler extends AntHandler {
-
- /**
- * Constructor.
- */
- public ElementHandler() {
- }
-
- /**
- * Initialisation routine called after handler creation
- * with the element name and attributes. This configures
- * the element with its attributes and sets it up with
- * its parent container (if any). Nested elements are then
- * added later as the parser encounters them.
- *
- * @param tag Name of the element which caused this handler
- * to be created. Must not be null.
- *
- * @param attrs Attributes of the element which caused this
- * handler to be created. Must not be null.
- *
- * @exception SAXParseException in case of error (not thrown in
- * this implementation)
- */
- public void onStartElement(String uri, String tag, String qname,
- Attributes attrs,
- AntXmlContext context)
- throws SAXParseException
- {
- RuntimeConfigurable2 parentWrapper=context.currentWrapper();
- RuntimeConfigurable2 wrapper=null;
-
- if (false && context.getProject().getDataTypeDefinitions().get(qname) != null) {
-/*
- UnknownElement should work for data types as well.
- // We should eliminate the special treatement of data type.
- try {
- Object element = context.getProject().createDataType(qname);
- if (element == null) {
- // can it happen ? We just checked that the type exists
- throw new BuildException("Unknown data type "+qname);
- }
-
- wrapper = new RuntimeConfigurable2(context.getProject(), null, element, qname);
- wrapper.setAttributes2(attrs);
- context.currentTarget.addDataType(wrapper);
- } catch (BuildException exc) {
- throw new SAXParseException(exc.getMessage(), context.locator, exc);
- }
-*/
- } else {
- Task task=null;
- /*
- // Don't try to create the task now - for consistency and to
- // simplify the model it is better to keep everything lazy
-
- try {
- task = context.getProject().createTask(qname);
- } catch (BuildException e) {
- // swallow here, will be thrown again in
- // UnknownElement.maybeConfigure if the problem persists.
- }
-
- // The consequence of lazy eval - UnknownElement must deal with
- // TaskContainer case.
- */
-
- if (task == null) {
- task = new UnknownElement2(qname);
- task.setProject(context.getProject());
- //XXX task.setTaskType(qname);
- task.setTaskName(qname);
- }
-
- Location location=new Location(context.locator.getSystemId(),
- context.locator.getLineNumber(),
- context.locator.getColumnNumber());
- task.setLocation(location);
- context.configureId(task, attrs);
-
- task.setOwningTarget(context.currentTarget);
-
- Object parent=null;
- if( parentWrapper!=null ) {
- parent=parentWrapper.getProxy();
- }
-
- // With lazy eval, parent will also be UnknwonElement ( even if the task
- // is a TaskContainer ). It is UnknownElement who must check this.
- if( parent instanceof TaskContainer ) {
- // Task included in a TaskContainer
- System.err.println("Shouldn't happen ");
- /*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();}
- ((TaskContainer)parent).addTask( task );
- } else {
- // Task included in a target ( including the default one ).
- context.currentTarget.addTask( task );
- }
- // container.addTask(task);
- task.init();
-
- wrapper=new RuntimeConfigurable2(context.getProject(), location, task, task.getTaskName());
- wrapper.setAttributes2(attrs);
-
- if (parentWrapper != null) {
- parentWrapper.addChild(wrapper);
- }
- }
-
- context.pushWrapper( wrapper );
- }
-
-
- /**
- * Adds text to the task, using the wrapper
- *
- * @param buf A character array of the text within the element.
- * Will not be null.
- * @param start The start element in the array.
- * @param count The number of characters to read from the array.
- *
- * @exception SAXParseException if the element doesn't support text
- *
- * @see ProjectHelper#addText(Project,Object,char[],int,int)
- */
- public void characters(char[] buf, int start, int count,
- AntXmlContext context)
- throws SAXParseException
- {
- RuntimeConfigurable2 wrapper=context.currentWrapper();
- wrapper.addText(buf, start, count);
- }
-
- /**
- * Handles the start of an element within a target. Task containers
- * will always use another task handler, and all other tasks
- * will always use a nested element handler.
- *
- * @param tag The name of the element being started.
- * Will not be null.
- * @param attrs Attributes of the element being started.
- * Will not be null.
- *
- * @exception SAXParseException if an error occurs when initialising
- * the appropriate child handler
- */
- public AntHandler onStartChild(String uri, String tag, String qname,
- Attributes attrs,
- AntXmlContext context)
- throws SAXParseException
- {
- // this element
- RuntimeConfigurable2 wrapper=context.currentWrapper();
-
- Object element=wrapper.getProxy();
- if (element instanceof TaskContainer) {
- // task can contain other tasks - no other nested elements possible
- // This will be handled inside UE
- System.err.println("Shouldn't happen - UE");
- /*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();}
- return ProjectHelperImpl2.elementHandler;
- }
- else {
- return ProjectHelperImpl2.nestedElementHandler;
- }
- }
-
- public void onEndElement(String uri, String tag, AntXmlContext context) {
- context.popWrapper();
- }
-
- public void onEndChild(String uri, String tag, String qname,
- AntXmlContext context)
- throws SAXParseException
- {
- }
- }
-
- /**
- * Handler for all nested properties. Same as ElementHandler, except that
- * it doesn't deal with DataTypes and doesn't support TaskContainer.
- *
- * This is the original behavior - I just made few changes to avoid duplicated
- * code.
- */
- public static class NestedElementHandler extends ElementHandler {
- /**
- * Constructor.
- */
- public NestedElementHandler() {
- }
-
- /**
- * Initialisation routine called after handler creation
- * with the element name and attributes. This configures
- * the element with its attributes and sets it up with
- * its parent container (if any). Nested elements are then
- * added later as the parser encounters them.
- *
- * @param tag Name of the element which caused this handler
- * to be created. Must not be null.
- *
- * @param attrs Attributes of the element which caused this
- * handler to be created. Must not be null.
- *
- * @exception SAXParseException in case of error, such as a
- * BuildException being thrown during configuration.
- */
- public void onStartElement(String uri, String propType, String qname,
- Attributes attrs,
- AntXmlContext context)
- throws SAXParseException
- {
- RuntimeConfigurable2 parentWrapper=context.currentWrapper();
- RuntimeConfigurable2 wrapper=null;
- try {
- Object element;
- Object parent=parentWrapper.getProxy();
-
- // Parent will allways be UnknownElement.
- if (parent instanceof TaskAdapter) {
- System.err.println("Shouldn't happen ");
- /*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();}
- parent = ((TaskAdapter) parent).getProxy();
- }
-
- String elementName = qname.toLowerCase(Locale.US);
- if (parent instanceof UnknownElement) {
- UnknownElement uc = new UnknownElement2(elementName);
- uc.setProject(context.getProject());
- ((UnknownElement) parent).addChild(uc);
- element = uc;
- } else {
- // It may be a data type. Will be removed when we consolidate UE/RC
- Class parentClass = parent.getClass();
- IntrospectionHelper ih =
- IntrospectionHelper.getHelper(parentClass);
- element = ih.createElement(context.getProject(), parent, elementName);
- }
-
- context.configureId(element, attrs);
-
- wrapper = new RuntimeConfigurable2(context.getProject(), null, element, qname);
- wrapper.setAttributes2(attrs);
- parentWrapper.addChild(wrapper);
- } catch (BuildException exc) {
- throw new SAXParseException(exc.getMessage(), context.locator, exc);
- }
- context.pushWrapper( wrapper );
- }
- }
-
- // -------------------- Backward compatibility with 1.5 --------------------
-
- /**
- * Constructs a file: URI that represents the
- * external form of the given pathname.
- *
- * file: URI.
- *
- * null.
- */
- public void setProxy(Object o) {
- this.proxy = o;
- }
-
- /**
- * Returns the target object being proxied.
- *
- * @return the target proxy object
- */
- public Object getProxy() {
- return this.proxy ;
- }
-
-}
diff --git a/proposal/embed/src/java/org/apache/tools/ant/taskdefs/Description.java b/proposal/embed/src/java/org/apache/tools/ant/taskdefs/Description.java
deleted file mode 100644
index 4c1e8187a..000000000
--- a/proposal/embed/src/java/org/apache/tools/ant/taskdefs/Description.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Ant", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * "default",
- * "name", "id" and "basedir".
- *
- * @param tag Name of the element which caused this handler
- * to be created. Should not be null.
- * Ignored in this implementation.
- * @param attrs Attributes of the element which caused this
- * handler to be created. Must not be null.
- *
- * @exception SAXParseException if an unexpected attribute is
- * encountered or if the "default" attribute
- * is missing.
- */
- public void execute() throws BuildException
- {
- if (file == null) {
- throw new BuildException("import element appears without a file attribute");
- }
-
- ProjectHelperImpl2.AntXmlContext context;
- context=(ProjectHelperImpl2.AntXmlContext)project.getReference("ant.parsing.context");
-
- context.importlevel++;
-
- project.log("importlevel: "+(context.importlevel-1)+" -> "+(context.importlevel),
- Project.MSG_DEBUG);
- project.log("Importing file "+file+" from "+
- context.buildFile.getAbsolutePath(),
- Project.MSG_VERBOSE);
-
- // Paths are relative to the build file they're imported from,
- // *not* the current directory (same as entity includes).
- File importedFile = new File(file);
- if (!importedFile.isAbsolute()) {
- importedFile = new File(context.buildFileParent, file);
- }
- if (!importedFile.exists()) {
- throw new BuildException("Cannot find "+file+" imported from "+
- context.buildFile.getAbsolutePath());
- }
-
- // Add parent build file to the map to avoid cycles...
- String parentFilename = getPath(context.buildFile);
- if (!context.importedFiles.containsKey(parentFilename)) {
- context.importedFiles.put(parentFilename, context.buildFile);
- }
-
- // Make sure we import the file only once
- String importedFilename = getPath(importedFile);
- if (context.importedFiles.containsKey(importedFilename)) {
- project.log("\nSkipped already imported file:\n "+importedFilename+"\n",
- Project.MSG_WARN);
- context.importlevel--;
- project.log("importlevel: "+context.importlevel+" <- "+
- (context.importlevel+1) ,Project.MSG_DEBUG);
- return;
- } else {
- context.importedFiles.put(importedFilename, importedFile);
- }
-
- context.ignoreProjectTag=true;
- context.helper.parse(project, importedFile, new ProjectHelperImpl2.RootHandler(context));
-
- context.importlevel--;
- project.log("importlevel: "+context.importlevel+" <- "+
- (context.importlevel+1) ,Project.MSG_DEBUG);
- }
-
- private static String getPath(File file) {
- try {
- return file.getCanonicalPath();
- }
- catch (IOException e) {
- return file.getAbsolutePath();
- }
- }
-}
diff --git a/proposal/embed/src/java/org/apache/tools/ant/taskdefs/SystemPath.java b/proposal/embed/src/java/org/apache/tools/ant/taskdefs/SystemPath.java
deleted file mode 100644
index 916b85bb2..000000000
--- a/proposal/embed/src/java/org/apache/tools/ant/taskdefs/SystemPath.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Ant", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- *
- * <path id="ant.deps" >
- * <fileset ... />
- * </path>
- *
- * <systemPath pathRef="ant.deps" />
- *
- * <junit ... />
- *
- *
- * This requires that ant-sax2.jar is included in ant/lib.
- *
- * It has a single property, a reference to a <path> containing all
- * the jars that you need. It'll automatically reload optional.jar
- * tasks in a different (non-delegating) loader.
- *
- */
-public class SystemPath extends Task {
- public static final String SYSTEM_LOADER_REF="ant.system.loader";
-
- public SystemPath() {
- }
-
- public void setPathRef( Reference pathRef ) throws BuildException {
- setClasspathRef( pathRef );
- }
-
- /** Specify which path will be used.
- */
- public void setClasspathRef( Reference pathRef ) throws BuildException {
- Path path=(Path)pathRef.getReferencedObject(project);
-
- initSystemLoader(path);
-
- }
-
- /** Will prepare the class loader to allow dynamic modifications
- * of the classpath. Optional tasks are loaded in a different loader.
- */
- private void initSystemLoader(Path path) {
- try {
- //if( project.getReference( SYSTEM_LOADER_REF ) != null )
- // return; // already done that.
-
- // reverse loader
- AntClassLoader acl=(AntClassLoader)project.getReference(SYSTEM_LOADER_REF);
- if( acl==null ) {
- acl=new AntClassLoader( this.getClass().getClassLoader(), true );
- acl.addLoaderPackageRoot( "org.apache.tools.ant.taskdefs.optional");
- project.addReference( SYSTEM_LOADER_REF, acl );
- }
-
-
- String list[]=path.list();
- for( int i=0; inull.
- */
- public String getClassname() {
- return value;
- }
-
- /**
- * The full class name of the object being defined.
- * Required, unless file or resource have
- * been specified.
- */
- public void setClassname(String v) {
- value = v;
- }
-
- /**
- * subclassed handler for definitions; called by parent during
- * execution.
- */
- protected void addDefinition(String name, Class c) throws BuildException {
- getProject().addTaskDefinition(name, c);
- }
-}
diff --git a/proposal/embed/src/java/org/apache/tools/ant/taskdefs/XMLDOM.java b/proposal/embed/src/java/org/apache/tools/ant/taskdefs/XMLDOM.java
deleted file mode 100644
index 0283b1b14..000000000
--- a/proposal/embed/src/java/org/apache/tools/ant/taskdefs/XMLDOM.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Ant", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- *