|
|
@@ -319,96 +319,6 @@ public class MacroDef extends AntlibDefinition { |
|
|
|
log("creating macro " + name, Project.MSG_VERBOSE); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Base class for a macro's attributes, elements, and text element. |
|
|
|
* |
|
|
|
* @since ant 1.7 |
|
|
|
*/ |
|
|
|
public static class Member { |
|
|
|
|
|
|
|
private String name; |
|
|
|
private String description; |
|
|
|
|
|
|
|
/** |
|
|
|
* Sets the name of this member. |
|
|
|
* |
|
|
|
* @param name the name of the attribute |
|
|
|
*/ |
|
|
|
public void setName(String name) { |
|
|
|
if (!isValidName(name)) { |
|
|
|
throw new BuildException( |
|
|
|
"Illegal name [" + name + "] for macro member"); |
|
|
|
} |
|
|
|
this.name = name.toLowerCase(Locale.US); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Gets the name of this macro member. |
|
|
|
* |
|
|
|
* @return the name of the member. |
|
|
|
*/ |
|
|
|
public String getName() { |
|
|
|
return name; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Sets a textual description of this member, |
|
|
|
* 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 member. |
|
|
|
* |
|
|
|
* @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; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 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 equals((Member) obj); |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Equality method once it has been ascertain the object |
|
|
|
* to compare to is not ourselves and is of the same type. |
|
|
|
* |
|
|
|
* @param m macro member guaranteed to be of the same type as this. |
|
|
|
* @return a <code>boolean</code> value |
|
|
|
*/ |
|
|
|
protected boolean equals(Member m) { |
|
|
|
return (name == null) ? m.name == null : name.equals(m.name); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Gets the hash code of this member, consistent with equals. |
|
|
|
* @return a hash code value for this object. |
|
|
|
*/ |
|
|
|
public int hashCode() { |
|
|
|
return objectHashCode(name); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* An attribute for the MacroDef task. |
|
|
@@ -631,11 +541,57 @@ public class MacroDef extends AntlibDefinition { |
|
|
|
/** |
|
|
|
* A nested element for the MacroDef task. |
|
|
|
*/ |
|
|
|
public static class TemplateElement extends Member { |
|
|
|
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. |
|
|
|
* |
|
|
@@ -674,18 +630,32 @@ public class MacroDef extends AntlibDefinition { |
|
|
|
return implicit; |
|
|
|
} |
|
|
|
|
|
|
|
/** {@inheritDoc}. */ |
|
|
|
protected boolean equals(Member m) { |
|
|
|
TemplateElement t = (TemplateElement) m; |
|
|
|
return super.equals(m) |
|
|
|
&& optional == t.optional && implicit == t.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 super.hashCode() + (optional ? 1 : 0) + (implicit ? 1 : 0); |
|
|
|
return objectHashCode(name) |
|
|
|
+ (optional ? 1 : 0) + (implicit ? 1 : 0); |
|
|
|
} |
|
|
|
|
|
|
|
} // END static class TemplateElement |
|
|
|