org.apache.tools.ant.types

Class EnumeratedAttribute

Known Direct Subclasses:
AggregateTransformer.Format, Available.FileDir, Coverage.Finalsnapshot, Coverage.Javavm, Coverage.Recordfromstart, CovReport.ReportFormat, CovReport.ReportType, DateSelector.TimeComparisons, Definer.Format, Definer.OnError, DotnetCompile.TargetTypes, Echo.EchoLevel, EchoProperties.FormatAttribute, EjbJar.CMPVersion, EjbJar.NamingScheme, EmailTask.Encoding, ExecuteOn.FileDirBoth, FixCRLF.AddAsisRemove, FixCRLF.CrLf, FormatterElement.TypeAttribute, FTP.Action, Ilasm.TargetTypes, Ildasm.EncodingTypes, Ildasm.VisibilityOptions, Jar.FilesetManifestConfig, Javadoc.AccessType, JDependTask.FormatAttribute, JUnitTask.ForkMode, JUnitTask.SummaryAttribute, ManifestTask.Mode, Mapper.MapperType, MMetrics.GranularityAttribute, ModifiedSelector.AlgorithmName, ModifiedSelector.CacheName, ModifiedSelector.ComparatorName, MSVSS.CurrentModUpdated, MSVSS.WritableFiles, MSVSSHISTORY.BriefCodediffNofile, NetRexxC.TraceAttr, NetRexxC.VerboseAttr, PathConvert.TargetOs, PresentSelector.FilePresence, PropertyFile.Unit, PropertyFile.Entry.Operation, PropertyFile.Entry.Type, PropertySet.BuiltinPropertySetName, Recorder.ActionChoices, Recorder.VerbosityLevelChoices, Scale.ProportionsAttribute, SizeSelector.ByteUnits, SizeSelector.SizeComparisons, SQLExec.DelimiterType, SQLExec.OnError, Tar.TarCompressionMethod, Tar.TarLongFileMode, Tstamp.Unit, TypeSelector.FileType, Untar.UntarCompressionMethod, WaitFor.Unit, WebsphereDeploymentTool.DBVendor, Zip.Duplicate, Zip.WhenEmpty

public abstract class EnumeratedAttribute
extends java.lang.Object

Helper class for attributes that can only take one of a fixed list of values.

See FixCRLF for an example.

Field Summary

protected String
value
The selected value in this enumeration.

Constructor Summary

EnumeratedAttribute()
bean constructor

Method Summary

boolean
containsValue(String value)
Is this value included in the enumeration?
int
getIndex()
String
getValue()
String[]
getValues()
This is the only method a subclass needs to implement.
int
indexOfValue(String value)
get the index of a value in this enumeration.
void
setValue(String value)
Invoked by IntrospectionHelper.
String
toString()
Convert the value to its string form.

Field Details

value

protected String value
The selected value in this enumeration.

Constructor Details

EnumeratedAttribute

protected EnumeratedAttribute()
bean constructor

Method Details

containsValue

public final boolean containsValue(String value)
Is this value included in the enumeration?


getIndex

public final int getIndex()

Returns:
the index of the selected value in the array.

See Also:
getValues()


getValue

public final String getValue()

Returns:
the selected value.


getValues

public String[] getValues()
This is the only method a subclass needs to implement.

Returns:
an array holding all possible values of the enumeration. The order of elements must be fixed so that indexOfValue(String) always return the same index for the same value.


indexOfValue

public final int indexOfValue(String value)
get the index of a value in this enumeration.

Parameters:
value - the string value to look for.

Returns:
the index of the value in the array of strings or -1 if it cannot be found.

See Also:
getValues()


setValue

public final void setValue(String value)
            throws BuildException
Invoked by IntrospectionHelper.


toString

public String toString()
Convert the value to its string form.

Returns:
the string form of the value.


Copyright B) 2000-2005 Apache Software Foundation. All Rights Reserved.