directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r289687 - in /directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records: ProtocolType.java RecordClass.java RecordType.java ServiceType.java
Date Sat, 17 Sep 2005 02:31:41 GMT
Author: erodriguez
Date: Fri Sep 16 19:31:33 2005
New Revision: 289687

URL: http://svn.apache.org/viewcvs?rev=289687&view=rev
Log:
Added methods to type-safe enumerators to allow for encoding and decoding of the two octet
codes that specify type or class.

Modified:
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ProtocolType.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordClass.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordType.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ServiceType.java

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ProtocolType.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ProtocolType.java?rev=289687&r1=289686&r2=289687&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ProtocolType.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ProtocolType.java
Fri Sep 16 19:31:33 2005
@@ -78,7 +78,7 @@
             PUP, ARGUS, EMCON, XNET, CHAOS, UDP, MUX, DCN_MEAS, HMP, PRM, XNS_IDP, TRUNK_1,
TRUNK_2, LEAF_1, LEAF_2,
             RDP, IRTP, ISO_TP4, NETBLT, MFE_NSP, MERIT_INP, SEP, CFTP, SAT_EXPAK, MIT_SUBNET,
RVD, IPPC, SAT_MON, IPCV,
             BR_SAT_MON, WB_MON, WB_EXPAK };
-    // VALUES needs to be located here, otherwise illegal forward reference
+
     public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values
) );
 
     private final String name;

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordClass.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordClass.java?rev=289687&r1=289686&r2=289687&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordClass.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordClass.java
Fri Sep 16 19:31:33 2005
@@ -27,29 +27,31 @@
      * Enumeration elements are constructed once upon class loading.
      * Order of appearance here determines the order of compareTo.
      */
-    public static final RecordClass IN = new RecordClass( 1, "Internet" );
-    public static final RecordClass CS = new RecordClass( 2, "CSNET class" );
-    public static final RecordClass CH = new RecordClass( 3, "CHAOS class" );
-    public static final RecordClass HS = new RecordClass( 4, "Hesiod [Dyer 87]" );
-    public static final RecordClass NONE = new RecordClass( 254, "Special value used in dynamic
update messages" );
-    public static final RecordClass ANY = new RecordClass( 255, "Any class" );
+    public static final RecordClass IN = new RecordClass( 1, "IN", "Internet" );
+    public static final RecordClass CS = new RecordClass( 2, "CS", "CSNET class" );
+    public static final RecordClass CH = new RecordClass( 3, "CH", "CHAOS class" );
+    public static final RecordClass HS = new RecordClass( 4, "HS", "Hesiod [Dyer 87]" );
+    public static final RecordClass NONE = new RecordClass( 254, "NONE", "Special value used
in dynamic update messages" );
+    public static final RecordClass ANY = new RecordClass( 255, "ANY", "Any class" );
 
     /**
      * These two lines are all that's necessary to export a List of VALUES.
      */
     private static final RecordClass[] values = { IN, CS, CH, HS, NONE, ANY };
-    // VALUES needs to be located here, otherwise illegal forward reference
+
     public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values
) );
 
     private final String name;
+    private final String code;
     private final int ordinal;
 
     /**
      * Private constructor prevents construction outside of this class.
      */
-    private RecordClass( int ordinal, String name )
+    private RecordClass( int ordinal, String code, String name )
     {
         this.ordinal = ordinal;
+        this.code = code;
         this.name = name;
     }
 
@@ -76,8 +78,26 @@
         return IN;
     }
 
+    public static RecordClass getTypeByName( String type )
+    {
+        for ( int ii = 0; ii < values.length; ii++ )
+        {
+            if ( values[ ii ].code.equalsIgnoreCase( type ) )
+            {
+                return values[ ii ];
+            }
+        }
+
+        return IN;
+    }
+
     public int getOrdinal()
     {
         return ordinal;
+    }
+
+    public String getCode()
+    {
+        return code;
     }
 }

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordType.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordType.java?rev=289687&r1=289686&r2=289687&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordType.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordType.java
Fri Sep 16 19:31:33 2005
@@ -89,7 +89,7 @@
             MX, TXT, RP, AFSDB, X25, ISDN, RT, NSAP, NSAP_PTR, SIG, KEY, PX, GPOS, AAAA,
LOC, NXT, EID, NIMLOC, SRV,
             ATMA, NAPTR, KX, CERT, A6, DNAME, OPT, APL, DS, SSHFP, RRSIG, NSEC, DNSKEY, TKEY,
TSIG, IXFR, AXFR, MAILB,
             MAILA, ANY };
-    // VALUES needs to be located here, otherwise illegal forward reference
+
     public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values
) );
 
     private final String name;
@@ -145,6 +145,11 @@
     public int getOrdinal()
     {
         return ordinal;
+    }
+
+    public String getCode()
+    {
+        return code;
     }
 
     public static boolean isResourceRecord( RecordType resourceType )

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ServiceType.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ServiceType.java?rev=289687&r1=289686&r2=289687&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ServiceType.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ServiceType.java
Fri Sep 16 19:31:33 2005
@@ -119,7 +119,7 @@
             UUCP_PATH, NNTP, ERPC, NTP, LOCUS_MAP, LOCUS_CON, PWDGEN, CISCO_FNA, CISCO_TNA,
CISCO_SYS, STATSRV,
             INGRES_NET, LOC_SRV, PROFILE, NETBIOS_NS, NETBIOS_DGM, NETBIOS_SSN, EMFIS_DATA,
EMFIS_CNTL, BL_IDM,
             SUR_MEAS, LINK };
-    // VALUES needs to be located here, otherwise illegal forward reference
+
     public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values
) );
 
     private final String name;



Mime
View raw message