Go to the documentation of this file.00001 
00004 package javax.jmdns.impl.constants;
00005 
00011 public enum DNSResultCode {
00015     Unknown("Unknown", 65535),
00019     NoError("No Error", 0),
00023     FormErr("Format Error", 1),
00027     ServFail("Server Failure", 2),
00031     NXDomain("Non-Existent Domain", 3),
00035     NotImp("Not Implemented", 4),
00039     Refused("Query Refused", 5),
00043     YXDomain("Name Exists when it should not", 6),
00047     YXRRSet("RR Set Exists when it should not", 7),
00051     NXRRSet("RR Set that should exist does not", 8),
00055     NotAuth("Server Not Authoritative for zone", 9),
00059     NotZone("NotZone Name not contained in zone", 10),
00060 
00061     ;
00062 
00063     
00064     
00065     
00066     
00067     
00068     
00069     
00070     
00071     
00072     
00073     
00074     
00075     
00076     
00077     
00078     
00079     
00080     
00081     
00082     
00083     
00084     
00085     
00086     
00087 
00091     final static int     RCode_MASK         = 0x0F;
00095     final static int     ExtendedRCode_MASK = 0xFF;
00096 
00097     private final String _externalName;
00098 
00099     private final int    _index;
00100 
00101     DNSResultCode(String name, int index) {
00102         _externalName = name;
00103         _index = index;
00104     }
00105 
00111     public String externalName() {
00112         return _externalName;
00113     }
00114 
00120     public int indexValue() {
00121         return _index;
00122     }
00123 
00128     public static DNSResultCode resultCodeForFlags(int flags) {
00129         int maskedIndex = flags & RCode_MASK;
00130         for (DNSResultCode aCode : DNSResultCode.values()) {
00131             if (aCode._index == maskedIndex) return aCode;
00132         }
00133         return Unknown;
00134     }
00135 
00136     public static DNSResultCode resultCodeForFlags(int flags, int extendedRCode) {
00137         int maskedIndex = ((extendedRCode >> 28) & ExtendedRCode_MASK) | (flags & RCode_MASK);
00138         for (DNSResultCode aCode : DNSResultCode.values()) {
00139             if (aCode._index == maskedIndex) return aCode;
00140         }
00141         return Unknown;
00142     }
00143 
00144     @Override
00145     public String toString() {
00146         return this.name() + " index " + this.indexValue();
00147     }
00148 
00149 }