From 4cf2a60f945bc9d3a479672765bab3fdaadc0c78 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Wed, 13 Sep 2006 21:01:23 +0000 Subject: [PATCH] Fix regression: revert changes to MacroDef.Attribute and Macrodef.Text The class had been modified to derive from a new class MacroDef.Member, when ant-contrib is compiled with ant1.7 and used with ant1.6, the task stops working as it tries to load MacroDef.Member when it is loading MacroDef.Attribute. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@443120 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/MacroDef.java | 178 +++++++++++++++--- 1 file changed, 150 insertions(+), 28 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/MacroDef.java b/src/main/org/apache/tools/ant/taskdefs/MacroDef.java index 49cf30ce8..0d8719831 100644 --- a/src/main/org/apache/tools/ant/taskdefs/MacroDef.java +++ b/src/main/org/apache/tools/ant/taskdefs/MacroDef.java @@ -437,14 +437,36 @@ public class MacroDef extends AntlibDefinition { return objectHashCode(name); } - } // END static class Member + } /** * An attribute for the MacroDef task. + * */ - public static class Attribute extends Member { - + public static class Attribute { + private String name; private String defaultValue; + private String description; + + /** + * 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 default value to use if the parameter is not @@ -463,20 +485,61 @@ public class MacroDef extends AntlibDefinition { return defaultValue; } - /** {@inheritDoc}. */ - protected boolean equals(Member m) { - Attribute a = (Attribute) m; - return super.equals(m) && - (defaultValue == null)? a.defaultValue == null: - defaultValue.equals(a.defaultValue); + /** + * @param desc Description of the element. + * @since ant 1.6.1 + */ + public void setDescription(String desc) { + description = desc; } - /** {@inheritDoc}. */ - public int hashCode() { - return super.hashCode() + objectHashCode(defaultValue); + /** + * @return the description of the element, or null if + * no description is available. + * @since ant 1.6.1 + */ + public String getDescription() { + return description; } - } // END static class Attribute + /** + * equality method + * + * @param obj an Object value + * @return a boolean value + */ + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj.getClass() != getClass()) { + return false; + } + Attribute other = (Attribute) obj; + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (defaultValue == null) { + if (other.defaultValue != null) { + return false; + } + } else if (!defaultValue.equals(other.defaultValue)) { + return false; + } + return true; + } + + /** + * @return a hash code value for this object. + */ + public int hashCode() { + return objectHashCode(defaultValue) + objectHashCode(name); + } + } /** * A nested define element for the MacroDef task. @@ -533,17 +596,37 @@ public class MacroDef extends AntlibDefinition { } } - } // END static class DefineAttribute + } /** * A nested text element for the MacroDef task. - * * @since ant 1.6.1 */ - public static class Text extends Member { - + public static class Text { + private String name; private boolean optional; private boolean trim; + private String description; + + /** + * 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. @@ -555,8 +638,6 @@ public class MacroDef extends AntlibDefinition { } /** - * Gets whether this text element is optional or not. - * * @return true if the text is optional */ public boolean getOptional() { @@ -574,23 +655,64 @@ public class MacroDef extends AntlibDefinition { } /** - * Gets whether to trim the raw provided text. - * * @return true if the text is trim */ public boolean getTrim() { return trim; } - /** {@inheritDoc}. */ - protected boolean equals(Member m) { - Text t = (Text) m; - return super.equals(m) && - optional == t.optional && - trim == t.trim; + /** + * @param desc Description of the text. + */ + public void setDescription(String desc) { + description = desc; + } + + /** + * @return the description of the text, or null if + * no description is available. + */ + public String getDescription() { + return description; } - } // END static class Text + /** + * equality method + * + * @param obj an Object value + * @return a boolean value + */ + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj.getClass() != getClass()) { + return false; + } + Text other = (Text) obj; + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (optional != other.optional) { + return false; + } + if (trim != other.trim) { + return false; + } + return true; + } + + /** + * @return a hash code value for this object. + */ + public int hashCode() { + return objectHashCode(name); + } + } /** * A nested element for the MacroDef task.