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

📄 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 页
字号:
     *     * @param child The child element wrapper to add to this one.     *              Must not be <code>null</code>.     */    public synchronized void addChild(RuntimeConfigurable child) {        children = (children == null) ? new ArrayList() : children;        children.add(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 <code>index</code> within the     *         list.     */    synchronized RuntimeConfigurable getChild(int index) {        return (RuntimeConfigurable) children.get(index);    }    /**     * Returns an enumeration of all child wrappers.     * @return an enumeration of the child wrappers.     * @since Ant 1.6     */    public synchronized Enumeration getChildren() {        return (children == null) ? new CollectionUtils.EmptyEnumeration()            : Collections.enumeration(children);    }    /**     * Adds characters from #PCDATA areas to the wrapped element.     *     * @param data Text to add to the wrapped element.     *        Should not be <code>null</code>.     */    public synchronized void addText(String data) {        if (data.length() == 0) {            return;        }        characters = (characters == null)            ? new StringBuffer(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 <code>null</code>.     * @param start The start element in the array.     * @param count The number of characters to read from the array.     *     */    public synchronized void addText(char[] buf, int start, int count) {        if (count == 0) {            return;        }        characters = ((characters == null)            ? new StringBuffer(count) : characters).append(buf, start, count);    }    /**     * Get the text content of this element. Various text chunks are     * concatenated, there is no way ( currently ) of keeping track of     * multiple fragments.     *     * @return the text content of this element.     * @since Ant 1.6     */    public synchronized StringBuffer getText() {        return (characters == null) ? new StringBuffer(0) : characters;    }    /**     * Set the element tag.     * @param elementTag The tag name generating this element.     */    public synchronized void setElementTag(String elementTag) {        this.elementTag = elementTag;    }    /**     * Returns the tag name of the wrapped element.     *     * @return The tag name of the wrapped element. This is unlikely     *         to be <code>null</code>, but may be.     */    public synchronized String getElementTag() {        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 <code>id</code> attribute, a reference     * is added to the project as well.     *     * @param p The project containing the wrapped element.     *          Must not be <code>null</code>.     *     * @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 <code>id</code> attribute, a reference     * is added to the project as well.     *     * @param p The project containing the wrapped element.     *          Must not be <code>null</code>.     *     * @param configureChildren ignored.     *     * @exception BuildException if the configuration fails, for instance due     *            to invalid attributes , or text being added to     *            an element which doesn't accept it.     */    public synchronized void maybeConfigure(Project p, boolean configureChildren)        throws BuildException {        if (proxyConfigured) {            return;        }        // Configure the object        Object target = (wrappedObject instanceof TypeAdapter)            ? ((TypeAdapter) wrappedObject).getProxy() : wrappedObject;        IntrospectionHelper ih =            IntrospectionHelper.getHelper(p, target.getClass());        if (attributeNames != null) {            for (int i = 0; i < attributeNames.size(); i++) {                String name = (String) attributeNames.get(i);                String value = (String) attributeMap.get(name);                // reflect these into the target                value = p.replaceProperties(value);                try {                    ih.setAttribute(p, target, name, value);                } catch (UnsupportedAttributeException be) {                    // id attribute must be set externally                    if (name.equals("id")) {                        // Do nothing                    } else  if (getElementTag() == null) {                        throw be;                    } else {                        throw new BuildException(                            getElementTag() +  " doesn't support the \""                            + be.getAttribute() + "\" attribute", be);                    }                } catch (BuildException be) {                    if (name.equals("id")) {                        // Assume that this is an not supported attribute type                        // thrown for example by a dymanic attribute task                        // Do nothing                    } else {                        throw be;                    }                }            }        }        if (characters != null) {            ProjectHelper.addText(p, wrappedObject, characters.substring(0));        }        if (id != null) {            p.addReference(id, wrappedObject);        }        proxyConfigured = true;    }    /**     * Reconfigure the element, even if it has already been configured.     *     * @param p the project instance for this configuration.     */    public void reconfigure(Project p) {        proxyConfigured = false;        maybeConfigure(p);    }    /**     * Apply presets, attributes and text are set if not currently set.     * Nested elements are prepended.     *     * @param r a <code>RuntimeConfigurable</code> value.     */    public void applyPreSet(RuntimeConfigurable r) {        // Attributes        if (r.attributeMap != null) {            for (Iterator i = r.attributeMap.keySet().iterator(); i.hasNext();) {                String name = (String) i.next();                if (attributeMap == null || attributeMap.get(name) == null) {                    setAttribute(name, (String) r.attributeMap.get(name));                }            }        }        // poly type        polyType = (polyType == null) ? r.polyType : polyType;        // Children (this is a shadow of UnknownElement#children)        if (r.children != null) {            List newChildren = new ArrayList();            newChildren.addAll(r.children);            if (children != null) {                newChildren.addAll(children);            }            children = newChildren;        }        // Text        if (r.characters != null) {            if (characters == null                || characters.toString().trim().length() == 0) {                characters = new StringBuffer(r.characters.toString());            }        }    }}

⌨️ 快捷键说明

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