Skip navigation links 
 
oracle.ide.util
Class Enum
java.lang.Object
  
oracle.ide.util.Enum
- All Implemented Interfaces:
 
- java.lang.Comparable
 
- Direct Known Subclasses:
 
- ContentType
 
- 
public abstract class Enum
 
- extends java.lang.Object
 
- implements java.lang.Comparable
 
Enum superclass to assist with the declaration of type-safe enumerations following the enums-as-objects pattern, pending enumerated types in the "Tiger" release of Java (J2SE 1.5).
Example:
public final class Animal extends Enum
{
  public static final Animal CAT = new Animal( "CAT" );
  public static final Animal DOG = new Animal( "DOG" );
  public static final Animal MAN = new Animal( "MAN" );
  private static final Animal[] PRIVATE_VALUES = { CAT, DOG, MAN };
  private static int _nextOrdinal = 0;
  private Animal( String name ) {
    super( name, _nextOrdinal++ );
  }
  public static final Animal valueOf( String name ) {
    return (Animal)Enum.valueOf( PRIVATE_VALUES, name );
  }
  public static final Animal[] values() {
    return (Animal[])PRIVATE_VALUES.clone();
  }
}
 
| Field Summary | 
protected  java.lang.String | 
_name 
            | 
protected  int | 
_ordinal 
            | 
  
 
| Constructor Summary | 
protected | 
Enum(java.lang.String name, int ordinal) 
            | 
  
 
 
| Methods inherited from class java.lang.Object | 
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
 
 
_name
protected final java.lang.String _name
_ordinal
protected final int _ordinal
Enum
protected Enum(java.lang.String name,
               int ordinal)
compareTo
public int compareTo(java.lang.Object o)
- 
- Specified by:
 
compareTo in interface java.lang.Comparable 
 
toString
public java.lang.String toString()
- 
- Overrides:
 
toString in class java.lang.Object 
 
clone
protected final java.lang.Object clone()
                                throws java.lang.CloneNotSupportedException
- 
- Overrides:
 
clone in class java.lang.Object 
 
- 
- Throws:
 
java.lang.CloneNotSupportedException 
 
name
public java.lang.String name()
ordinal
public int ordinal()
valueOf
protected static final Enum valueOf(Enum[] enums,
                                    java.lang.String name)
Skip navigation links 
 
Copyright © 1997, 2011, Oracle. All rights reserved.