Author: erodriguez
Date: Tue Nov  9 19:35:50 2004
New Revision: 57123

Modified:
   
incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/crypto/checksum/ChecksumType.java
Log:
Updated checksum types to use explicit ordinals.  I expect to want to use this 
later for checksum selection.

Modified: 
incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/crypto/checksum/ChecksumType.java
==============================================================================
--- 
incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/crypto/checksum/ChecksumType.java
  (original)
+++ 
incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/crypto/checksum/ChecksumType.java
  Tue Nov  9 19:35:50 2004
@@ -16,57 +16,64 @@
  */
 package org.apache.kerberos.crypto.checksum;
 
-import java.util.*;
-
-public final class ChecksumType implements Comparable {
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
 
+public final class ChecksumType implements Comparable
+{
        /**
         * Enumeration elements are constructed once upon class loading.
         * Order of appearance here determines the order of compareTo.
         */
-       public static final ChecksumType NULL           = new 
ChecksumType("null");
-       public static final ChecksumType CRC32          = new 
ChecksumType("CRC32");
-       public static final ChecksumType RSA_MD4        = new ChecksumType("RSA 
MD4");
-       public static final ChecksumType RSA_MD4_DES    = new ChecksumType("RSA 
MD4 DES");
-       public static final ChecksumType DES_MAC        = new ChecksumType("DES 
MAC");
-       public static final ChecksumType DES_MAC_K      = new ChecksumType("DES 
MAC K");
-       public static final ChecksumType RSA_MD4_DES_K  = new ChecksumType("RSA 
MD4 DES K");
-       public static final ChecksumType RSA_MD5        = new ChecksumType("RSA 
MD5");
-       public static final ChecksumType RSA_MD5_DES    = new ChecksumType("RSA 
MD5 DES");
-       public static final ChecksumType RSA_MD5_DES3   = new ChecksumType("RSA 
MD5 DES3");
-       public static final ChecksumType SHA1           = new 
ChecksumType("SHA1");
-       public static final ChecksumType UNKNOWN11      = new 
ChecksumType("UNKNOWN 11");
-       public static final ChecksumType HMAC_SHA1_DES3 = new 
ChecksumType("HMAC SHA1 DES3");
+       public static final ChecksumType NULL           = new ChecksumType(0, 
"null");
+       public static final ChecksumType CRC32          = new ChecksumType(1, 
"CRC32");
+       public static final ChecksumType RSA_MD4        = new ChecksumType(2, 
"RSA MD4");
+       public static final ChecksumType RSA_MD4_DES    = new ChecksumType(3, 
"RSA MD4 DES");
+       public static final ChecksumType DES_MAC        = new ChecksumType(4, 
"DES MAC");
+       public static final ChecksumType DES_MAC_K      = new ChecksumType(5, 
"DES MAC K");
+       public static final ChecksumType RSA_MD4_DES_K  = new ChecksumType(6, 
"RSA MD4 DES K");
+       public static final ChecksumType RSA_MD5        = new ChecksumType(7, 
"RSA MD5");
+       public static final ChecksumType RSA_MD5_DES    = new ChecksumType(8, 
"RSA MD5 DES");
+       public static final ChecksumType RSA_MD5_DES3   = new ChecksumType(9, 
"RSA MD5 DES3");
+       public static final ChecksumType SHA1           = new ChecksumType(10, 
"SHA1");
+       public static final ChecksumType UNKNOWN11      = new ChecksumType(11, 
"UNKNOWN 11");
+       public static final ChecksumType HMAC_SHA1_DES3 = new ChecksumType(12, 
"HMAC SHA1 DES3");
 
-       public String toString() {
+       public String toString()
+    {
                return _fName;
        }
 
-       public int compareTo(Object that) {
+       public int compareTo( Object that )
+    {
                return _fOrdinal - ((ChecksumType) that)._fOrdinal;
        }
 
-       public static ChecksumType getTypeByOrdinal(int type) {
+       public static ChecksumType getTypeByOrdinal( int type )
+    {
                for (int i = 0; i < fValues.length; i++)
                        if (fValues[i]._fOrdinal == type)
                                return fValues[i];
                return NULL;
        }
        
-       public int getOrdinal() {
+       public int getOrdinal()
+    {
                return _fOrdinal;
        }
 
        /// PRIVATE /////
        private final String _fName;
-       private static int fNextOrdinal = 0;
-       private final int _fOrdinal = fNextOrdinal++;
+       private final int    _fOrdinal;
 
        /**
         * Private constructor prevents construction outside of this class.
         */
-       private ChecksumType(String aName) {
-               _fName = aName;
+       private ChecksumType( int ordinal, String name )
+    {
+        _fOrdinal = ordinal;
+               _fName    = name;
        }
 
        /**
@@ -76,7 +83,6 @@
                        DES_MAC, DES_MAC_K, RSA_MD4_DES_K, RSA_MD5, 
RSA_MD5_DES, RSA_MD5_DES3,
                        SHA1, UNKNOWN11, HMAC_SHA1_DES3};
        // VALUES needs to be located here, otherwise illegal forward reference
-       public static final List VALUES = 
Collections.unmodifiableList(Arrays.asList(fValues));
-
+       public static final List VALUES = Collections.unmodifiableList( 
Arrays.asList(fValues) );
 }
 

Reply via email to