org.codehaus.plexus.archiver.util
Class EnumeratedAttribute

java.lang.Object
  extended by org.codehaus.plexus.archiver.util.EnumeratedAttribute
Direct Known Subclasses:
JarArchiver.FilesetManifestConfig, TarArchiver.TarCompressionMethod, TarCompressionMethod, TarLongFileMode, TarUnArchiver.UntarCompressionMethod

public abstract class EnumeratedAttribute
extends 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
protected EnumeratedAttribute()
          bean constructor
 
Method Summary
 boolean containsValue(String value)
          Is this value included in the enumeration?
 int getIndex()
           
 String getValue()
           
abstract  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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected String value
The selected value in this enumeration.

Constructor Detail

EnumeratedAttribute

protected EnumeratedAttribute()
bean constructor

Method Detail

getValues

public abstract 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.

setValue

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

Throws:
ArchiverException

containsValue

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


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()

getValue

public final String getValue()
Returns:
the selected value.

getIndex

public final int getIndex()
Returns:
the index of the selected value in the array.
See Also:
getValues()

toString

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

Overrides:
toString in class Object
Returns:
the string form of the value.


Copyright © 2008-2012 Sonatype, Inc.. All Rights Reserved.