001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    
021    package org.apache.directory.server.dns.messages;
022    
023    
024    import org.apache.directory.server.dns.util.EnumConverter;
025    import org.apache.directory.server.dns.util.ReverseEnumMap;
026    
027    
028    /**
029     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
030     * @version $Rev: 547524 $, $Date: 2007-06-15 06:42:26 +0200 (Fri, 15 Jun 2007) $
031     */
032    public enum RecordType implements EnumConverter<Short>
033    {
034        /** Host address */
035        A(1),
036    
037        /** Authoritative name server */
038        NS(2),
039    
040        /** Mail destination */
041        MD(3),
042    
043        /** Mail forwarder */
044        MF(4),
045    
046        /** Canonical name for an alias */
047        CNAME(5),
048    
049        /** Start of a zone of authority */
050        SOA(6),
051    
052        /** Mailbox domain name */
053        MB(7),
054    
055        /** Mail group member */
056        MG(8),
057    
058        /** Mail rename domain name */
059        MR(9),
060    
061        /** Null resource record */
062        NULL(10),
063    
064        /** Well know service description */
065        WKS(11),
066    
067        /** Domain name pointer */
068        PTR(12),
069    
070        /** Host information */
071        HINFO(13),
072    
073        /** Mailbox or mail list information */
074        MINFO(14),
075    
076        /** Mail exchange */
077        MX(15),
078    
079        /** Text strings */
080        TXT(16),
081    
082        /** Responsible person */
083        RP(17),
084    
085        /** AFS cell database */
086        AFSDB(18),
087    
088        /** X.25 calling address */
089        X25(19),
090    
091        /** ISDN calling address */
092        ISDN(20),
093    
094        /** Router */
095        RT(21),
096    
097        /** NSAP address */
098        NSAP(22),
099    
100        /** Reverse NSAP address (deprecated) */
101        NSAP_PTR(23),
102    
103        /** Signature */
104        SIG(24),
105    
106        /** Key */
107        KEY(25),
108    
109        /** X.400 mail mapping */
110        PX(26),
111    
112        /** Geographical position (withdrawn) */
113        GPOS(27),
114    
115        /** IPv6 address */
116        AAAA(28),
117    
118        /** Location */
119        LOC(29),
120    
121        /** Next valid name in zone */
122        NXT(30),
123    
124        /** Endpoint identifier */
125        EID(31),
126    
127        /** Nimrod locator */
128        NIMLOC(32),
129    
130        /** Server selection */
131        SRV(33),
132    
133        /** ATM address */
134        ATMA(34),
135    
136        /** Naming authority pointer */
137        NAPTR(35),
138    
139        /** Key exchange */
140        KX(36),
141    
142        /** Certificate */
143        CERT(34),
144    
145        /** IPv6 address (experimental) */
146        A6(38),
147    
148        /** Non-terminal name redirection */
149        DNAME(39),
150    
151        /** Options - contains EDNS metadata */
152        OPT(41),
153    
154        /** Address Prefix List */
155        APL(42),
156    
157        /** Delegation Signer */
158        DS(43),
159    
160        /** SSH Key Fingerprint */
161        SSHFP(44),
162    
163        /** Resource Record Signature */
164        RRSIG(46),
165    
166        /** Next Secure Name */
167        NSEC(47),
168    
169        /** DNSSEC Key */
170        DNSKEY(48),
171    
172        /** Transaction key - used to compute a shared secret or exchange a key */
173        TKEY(249),
174    
175        /** Transaction signature */
176        TSIG(250),
177    
178        /** Incremental zone transfer */
179        IXFR(251),
180    
181        /** Request for transfer of an entire zone */
182        AXFR(252),
183    
184        /** Request for mailbox-related records */
185        MAILB(253),
186    
187        /** Request for mail agent resource records */
188        MAILA(254),
189    
190        /** Request for all records */
191        ANY(255);
192    
193        private static ReverseEnumMap<Short, RecordType> map = new ReverseEnumMap<Short, RecordType>( RecordType.class );
194    
195        private final short value;
196    
197    
198        private RecordType( int value )
199        {
200            this.value = ( short ) value;
201        }
202    
203    
204        public Short convert()
205        {
206            return this.value;
207        }
208    
209    
210        /**
211         * Converts an ordinal value into a {@link RecordType}.
212         *
213         * @param value
214         * @return The {@link RecordType}.
215         */
216        public static RecordType convert( short value )
217        {
218            return map.get( value );
219        }
220    
221    
222        /**
223         * Returns whether a given {@link RecordType} is a {@link ResourceRecord}.
224         *
225         * @param resourceType
226         * @return true of the {@link RecordType} is a {@link ResourceRecord}.
227         */
228        public static boolean isResourceRecord( RecordType resourceType )
229        {
230            switch ( resourceType )
231            {
232                case OPT:
233                case TKEY:
234                case TSIG:
235                case IXFR:
236                case AXFR:
237                case MAILB:
238                case MAILA:
239                case ANY:
240                    return false;
241                default:
242                    return true;
243            }
244        }
245    }