English | Site Directory

Android - An Open Handset Alliance Project

java.lang
public abstract class

java.lang.Enum

java.lang.Object
java.lang.Enum Serializable Comparable

The superclass of all enumerated types.

Known Direct Subclasses

Summary

Protected Constructors

          Enum(String name, int ordinal)
Constructor for enum subtypes.

Public Methods

    final    int  compareTo(E o)
Answers the comparative ordering of the receiver and the given argument.
    final    boolean  equals(Object other)
Answers true only if the receiver is equal to the argument.
    final    Class  getDeclaringClass()
Answers the enum constant's declaring class.
    final    int  hashCode()
Answers the hash of the receiver.
    final    String  name()
Answers the name of the enum constant.
    final    int  ordinal()
Answers the position of the enum constant in the declaration.
        String  toString()
Answer a string representation of the receiver suitable for display to a programmer.
      static  T  valueOf(Class enumType, String name)
Answers the named constant of the given enum type.

Protected Methods

    final    Object  clone()
Enums are singletons, they may not be cloned.
Methods inherited from class java.lang.Object
Methods inherited from interface java.lang.Comparable

Details

Protected Constructors

protected Enum(String name, int ordinal)

Constructor for enum subtypes.

Parameters

name the enum constant declared name.
ordinal the enum constant position ordinal.

Public Methods

public final int compareTo(E o)

Answers the comparative ordering of the receiver and the given argument. If the receiver is naturally ordered before the actual argument then the result is negative, if the receiver is naturally ordered in equal position to the actual argument then the result is zero, and if the receiver is naturally ordered after the actual argument then the result is positive.

Returns

  • negative, zero, or positive value depending upon before, equal, or after natural order respectively.

See Also

public final boolean equals(Object other)

Answers true only if the receiver is equal to the argument. Since enums are unique this is equivalent to an identity test.

Parameters

other Object the object to compare with this object.

Returns

  • true if the receiver and argument are equal, otherwise return false.

public final Class getDeclaringClass()

Answers the enum constant's declaring class.

Returns

  • the class object representing the constant's enum type.

public final int hashCode()

Answers the hash of the receiver.

Returns

  • the hash code.

public final String name()

Answers the name of the enum constant. The name is the field as it appears in the Enum declaration.

Returns

  • the precise enum constant name.

See Also

public final int ordinal()

Answers the position of the enum constant in the declaration. The first constant has and ordinal value of zero.

Returns

  • the constant's ordinal value.

public String toString()

Answer a string representation of the receiver suitable for display to a programmer.

Returns

  • the displayable string name.

public static T valueOf(Class enumType, String name)

Answers the named constant of the given enum type.

Parameters

enumType the class of the enumerated type to search for the constant value.
name the name of the constant value to find.

Returns

  • the enum constant

Throws

NullPointerException if either the enumType or name are null.
IllegalArgumentException if enumType is not an enumerated type or does not have a constant value called name.

Protected Methods

protected final Object clone()

Enums are singletons, they may not be cloned. This method always throws a CloneNotSupportedException.

Returns

  • does not return.
Build m5-rc15i - 10 Jun 2008 13:54