Methods Summary |
---|
public final boolean | containsValue(java.lang.String value)Is this value included in the enumeration?
return (indexOfValue(value) != -1);
|
public final int | getIndex()
return index;
|
public static org.apache.tools.ant.types.EnumeratedAttribute | getInstance(java.lang.Class clazz, java.lang.String value)Factory method for instantiating EAs via API in a more
developer friendly way.
if (!EnumeratedAttribute.class.isAssignableFrom(clazz)) {
throw new BuildException(
"You have to provide a subclass from EnumeratedAttribut as clazz-parameter.");
}
EnumeratedAttribute ea = null;
try {
ea = (EnumeratedAttribute) clazz.newInstance();
} catch (Exception e) {
throw new BuildException(e);
}
ea.setValue(value);
return ea;
|
public final java.lang.String | getValue()
return value;
|
public abstract java.lang.String[] | getValues()This is the only method a subclass needs to implement.
|
public final int | indexOfValue(java.lang.String value)get the index of a value in this enumeration.
String[] values = getValues();
if (values == null || value == null) {
return -1;
}
for (int i = 0; i < values.length; i++) {
if (value.equals(values[i])) {
return i;
}
}
return -1;
|
public final void | setValue(java.lang.String value)Invoked by {@link org.apache.tools.ant.IntrospectionHelper IntrospectionHelper}.
int idx = indexOfValue(value);
if (idx == -1) {
throw new BuildException(value + " is not a legal value for this attribute");
}
this.index = idx;
this.value = value;
|
public java.lang.String | toString()Convert the value to its string form.
return getValue();
|