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

📄 macrodef.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        /**         * @return a hash code value for this object.         */        public int hashCode() {            return objectHashCode(defaultValue) + objectHashCode(name);        }    }    /**     * A nested text element for the MacroDef task.     * @since ant 1.6.1     */    public static class Text {        private String  name;        private boolean optional;        private boolean trim;        private String  description;        private String  defaultString;        /**         * The name of the attribute.         *         * @param name the name of the attribute         */        public void setName(String name) {            if (!isValidName(name)) {                throw new BuildException(                    "Illegal name [" + name + "] for attribute");            }            this.name = name.toLowerCase(Locale.US);        }        /**         * @return the name of the attribute         */        public String getName() {            return name;        }        /**         * The optional attribute of the text element.         *         * @param optional if true this is optional         */        public void setOptional(boolean optional) {            this.optional = optional;        }        /**         * @return true if the text is optional         */        public boolean getOptional() {            return optional;        }        /**         * The trim attribute of the text element.         *         * @param trim if true this String.trim() is called on         *             the contents of the text element.         */        public void setTrim(boolean trim) {            this.trim = trim;        }        /**         * @return true if the text is trim         */        public boolean getTrim() {            return trim;        }        /**         * @param desc Description of the text.         */        public void setDescription(String desc) {            description = desc;        }        /**         * @return the description of the text, or <code>null</code> if         *         no description is available.         */        public String getDescription() {            return description;        }        /**         * @param defaultString default text for the string.         */        public void setDefault(String defaultString) {            this.defaultString = defaultString;        }        /**         * @return the default text if set, null otherwise.         */        public String getDefault() {            return defaultString;        }        /**         * equality method         *         * @param obj an <code>Object</code> value         * @return a <code>boolean</code> value         */        public boolean equals(Object obj) {            if (obj == null) {                return false;            }            if (obj.getClass() != getClass()) {                return false;            }            Text other = (Text) obj;            return safeCompare(name, other.name)                && optional == other.optional                && trim == other.trim                && safeCompare(defaultString, other.defaultString);        }        /**         * @return a hash code value for this object.         */        public int hashCode() {            return objectHashCode(name);        }    }    private static boolean safeCompare(Object a, Object b) {        return a == null ? b == null : a.equals(b);    }    /**     * A nested element for the MacroDef task.     */    public static class TemplateElement {        private String name;        private String description;        private boolean optional = false;        private boolean implicit = false;        /**         * Sets the name of this element.         *         * @param name the name of the element         */        public void setName(String name) {            if (!isValidName(name)) {                throw new BuildException(                    "Illegal name [" + name + "] for macro element");            }            this.name = name.toLowerCase(Locale.US);        }        /**         * Gets the name of this element.         *         * @return the name of the element.         */        public String getName() {            return name;        }        /**         * Sets a textual description of this element,         * for build documentation purposes only.         *         * @param desc Description of the element.         * @since ant 1.6.1         */        public void setDescription(String desc) {            description = desc;        }        /**         * Gets the description of this element.         *         * @return the description of the element, or <code>null</code> if         *         no description is available.         * @since ant 1.6.1         */        public String getDescription() {            return description;        }        /**         * Sets whether this element is optional.         *         * @param optional if true this element may be left out, default         *                 is false.         */        public void setOptional(boolean optional) {            this.optional = optional;        }        /**         * Gets whether this element is optional.         *         * @return the optional attribute         */        public boolean isOptional() {            return optional;        }        /**         * Sets whether this element is implicit.         *         * @param implicit if true this element may be left out, default         *                 is false.         */        public void setImplicit(boolean implicit) {            this.implicit = implicit;        }        /**         * Gets whether this element is implicit.         *         * @return the implicit attribute         */        public boolean isImplicit() {            return implicit;        }        /**         * equality method.         *         * @param obj an <code>Object</code> value         * @return a <code>boolean</code> value         */        public boolean equals(Object obj) {            if (obj == this) {              return true;            }            if (obj == null || !obj.getClass().equals(getClass())) {                return false;            }            TemplateElement t = (TemplateElement) obj;            return                (name == null ? t.name == null : name.equals(t.name))                && optional == t.optional                && implicit == t.implicit;        }        /**         * @return a hash code value for this object.         */        public int hashCode() {            return objectHashCode(name)                + (optional ? 1 : 0) + (implicit ? 1 : 0);        }    } // END static class TemplateElement    /**     * same or similar equality method for macrodef, ignores project and     * runtime info.     *     * @param obj an <code>Object</code> value     * @param same if true test for sameness, otherwise just similiar     * @return a <code>boolean</code> value     */    private boolean sameOrSimilar(Object obj, boolean same) {        if (obj == this) {            return true;        }        if (obj == null) {            return false;        }        if (!obj.getClass().equals(getClass())) {            return false;        }        MacroDef other = (MacroDef) obj;        if (name == null) {            return other.name == null;        }        if (!name.equals(other.name)) {            return false;        }        // Allow two macro definitions with the same location        // to be treated as similar - bugzilla 31215        if (other.getLocation() != null            && other.getLocation().equals(getLocation())            && !same) {            return true;        }        if (text == null) {            if (other.text != null) {                return false;            }        } else {            if (!text.equals(other.text)) {                return false;            }        }        if (getURI() == null || getURI().equals("")            || getURI().equals(ProjectHelper.ANT_CORE_URI)) {            if (!(other.getURI() == null || other.getURI().equals("")                  || other.getURI().equals(ProjectHelper.ANT_CORE_URI))) {                return false;            }        } else {            if (!getURI().equals(other.getURI())) {                return false;            }        }        if (!nestedSequential.similar(other.nestedSequential)) {            return false;        }        if (!attributes.equals(other.attributes)) {            return false;        }        if (!elements.equals(other.elements)) {            return false;        }        return true;    }    /**     * Similar method for this definition     *     * @param obj another definition     * @return true if the definitions are similar     */    public boolean similar(Object obj) {        return sameOrSimilar(obj, false);    }    /**     * Equality method for this definition     *     * @param obj another definition     * @return true if the definitions are the same     */    public boolean sameDefinition(Object obj) {        return sameOrSimilar(obj, true);    }    /**     * extends AntTypeDefinition, on create     * of the object, the template macro definition     * is given.     */    private static class MyAntTypeDefinition extends AntTypeDefinition {        private MacroDef macroDef;        /**         * Creates a new <code>MyAntTypeDefinition</code> instance.         *         * @param macroDef a <code>MacroDef</code> value         */        public MyAntTypeDefinition(MacroDef macroDef) {            this.macroDef = macroDef;        }        /**         * Create an instance of the definition.         * The instance may be wrapped in a proxy class.         * @param project the current project         * @return the created object         */        public Object create(Project project) {            Object o = super.create(project);            if (o == null) {                return null;            }            ((MacroInstance) o).setMacroDef(macroDef);            return o;        }        /**         * Equality method for this definition         *         * @param other another definition         * @param project the current project         * @return true if the definitions are the same         */        public boolean sameDefinition(AntTypeDefinition other, Project project) {            if (!super.sameDefinition(other, project)) {                return false;            }            MyAntTypeDefinition otherDef = (MyAntTypeDefinition) other;            return macroDef.sameDefinition(otherDef.macroDef);        }        /**         * Similar method for this definition         *         * @param other another definition         * @param project the current project         * @return true if the definitions are the same         */        public boolean similarDefinition(            AntTypeDefinition other, Project project) {            if (!super.similarDefinition(other, project)) {                return false;            }            MyAntTypeDefinition otherDef = (MyAntTypeDefinition) other;            return macroDef.similar(otherDef.macroDef);        }    }    private static int objectHashCode(Object o) {        if (o == null) {            return 0;        } else {            return o.hashCode();        }    }}

⌨️ 快捷键说明

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