⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runtimeconfigurable.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *  Licensed to the Apache Software Foundation (ASF) under one or more *  contributor license agreements.  See the NOTICE file distributed with *  this work for additional information regarding copyright ownership. *  The ASF licenses this file to You under the Apache License, Version 2.0 *  (the "License"); you may not use this file except in compliance with *  the License.  You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * *  Unless required by applicable law or agreed to in writing, software *  distributed under the License is distributed on an "AS IS" BASIS, *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *  See the License for the specific language governing permissions and *  limitations under the License. * */package org.apache.tools.ant;import java.io.Serializable;import java.util.ArrayList;import java.util.Collections;import java.util.Enumeration;import java.util.HashMap;import java.util.Hashtable;import java.util.List;import java.util.Locale;import java.util.Map;import java.util.Iterator;import org.apache.tools.ant.util.CollectionUtils;import org.xml.sax.AttributeList;import org.xml.sax.helpers.AttributeListImpl;/** * Wrapper class that holds the attributes of an element, its children, and * any text within it. It then takes care of configuring that element at * runtime. * */public class RuntimeConfigurable implements Serializable {    /** Empty Hashtable. */    private static final Hashtable EMPTY_HASHTABLE = new Hashtable(0);    /** Name of the element to configure. */    private String elementTag = null;    /** List of child element wrappers. */    private List/*<RuntimeConfigurable>*/ children = null;    /** The element to configure. It is only used during     * maybeConfigure.     */    private transient Object wrappedObject = null;    /** the creator used to make the wrapped object */    private transient IntrospectionHelper.Creator creator;    /**     * XML attributes for the element.     * @deprecated since 1.6.x     */    private transient AttributeList attributes;    /** Attribute names and values. While the XML spec doesn't require     *  preserving the order ( AFAIK ), some ant tests do rely on the     *  exact order. The following code is copied from AttributeImpl.     *  We could also just use SAX2 Attributes and convert to SAX1 ( DOM     *  attribute Nodes can also be stored in SAX2 Attributes )     *  XXX under JDK 1.4 you can just use a LinkedHashMap for this purpose -jglick     * The only exception to this order is the treatment of     * refid. A number of datatypes check if refid is set     * when other attributes are set. This check will not     * work if the build script has the other attribute before     * the "refid" attribute, so now (ANT 1.7) the refid     * attribute will be processed first.     */    private List/*<String>*/ attributeNames = null;    /** Map of attribute names to values */    private Map/*<String,String>*/ attributeMap = null;    /** Text appearing within the element. */    private StringBuffer characters = null;    /** Indicates if the wrapped object has been configured */    private boolean proxyConfigured = false;    /** the polymorphic type */    private String polyType = null;    /** the "id" of this Element if it has one */    private String id = null;    /**     * Sole constructor creating a wrapper for the specified object.     *     * @param proxy The element to configure. Must not be <code>null</code>.     * @param elementTag The tag name generating this element.     */    public RuntimeConfigurable(Object proxy, String elementTag) {        setProxy(proxy);        setElementTag(elementTag);        // Most likely an UnknownElement        if (proxy instanceof Task) {            ((Task) proxy).setRuntimeConfigurableWrapper(this);        }    }    /**     * Sets the element to configure.     *     * @param proxy The element to configure. Must not be <code>null</code>.     */    public synchronized void setProxy(Object proxy) {        wrappedObject = proxy;        proxyConfigured = false;    }    /**     * Sets the creator of the element to be configured     * used to store the element in the parent.     *     * @param creator the creator object.     */    synchronized void setCreator(IntrospectionHelper.Creator creator) {        this.creator = creator;    }    /**     * Get the object for which this RuntimeConfigurable holds the configuration     * information.     *     * @return the object whose configure is held by this instance.     */    public synchronized Object getProxy() {        return wrappedObject;    }    /**     * Returns the id for this element.     * @return the id.     */    public synchronized String getId() {        return id;    }    /**     * Get the polymorphic type for this element.     * @return the ant component type name, null if not set.     */    public synchronized String getPolyType() {        return polyType;    }    /**     * Set the polymorphic type for this element.     * @param polyType the ant component type name, null if not set.     */    public synchronized void setPolyType(String polyType) {        this.polyType = polyType;    }    /**     * Sets the attributes for the wrapped element.     *     * @deprecated since 1.6.x.     * @param attributes List of attributes defined in the XML for this     *                   element. May be <code>null</code>.     */    public synchronized void setAttributes(AttributeList attributes) {        this.attributes = new AttributeListImpl(attributes);        for (int i = 0; i < attributes.getLength(); i++) {            setAttribute(attributes.getName(i), attributes.getValue(i));        }    }    /**     * Set an attribute to a given value.     *     * @param name the name of the attribute.     * @param value the attribute's value.     */    public synchronized void setAttribute(String name, String value) {        if (name.equalsIgnoreCase(ProjectHelper.ANT_TYPE)) {            this.polyType = value;        } else {            if (attributeNames == null) {                attributeNames = new ArrayList();                attributeMap = new HashMap();            }            if (name.toLowerCase(Locale.US).equals("refid")) {                attributeNames.add(0, name);            } else {                attributeNames.add(name);            }            attributeMap.put(name, value);            if (name.equals("id")) {                this.id = value;            }        }    }    /**     * Delete an attribute.  Not for the faint of heart.     * @param name the name of the attribute to be removed.     */    public synchronized void removeAttribute(String name) {        attributeNames.remove(name);        attributeMap.remove(name);    }    /**     * Return the attribute map.     *     * @return Attribute name to attribute value map.     * @since Ant 1.6     */    public synchronized Hashtable getAttributeMap() {        return (attributeMap == null)            ? EMPTY_HASHTABLE : new Hashtable(attributeMap);    }    /**     * Returns the list of attributes for the wrapped element.     *     * @deprecated Deprecated since Ant 1.6 in favor of {@link #getAttributeMap}.     * @return An AttributeList representing the attributes defined in the     *         XML for this element. May be <code>null</code>.     */    public synchronized AttributeList getAttributes() {        return attributes;    }    /**     * Adds a child element to the wrapped element.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -