| 14 | public abstract class EDNSOption { |
| 15 | |
| 16 | public static class Code { |
| 17 | private Code() {} |
| 18 | |
| 19 | /** Name Server Identifier, RFC 5001 */ |
| 20 | public final static int NSID = 3; |
| 21 | |
| 22 | /** Client Subnet, defined in draft-vandergaast-edns-client-subnet-02 */ |
| 23 | public final static int CLIENT_SUBNET = 8; |
| 24 | |
| 25 | private static Mnemonic codes = new Mnemonic("EDNS Option Codes", |
| 26 | Mnemonic.CASE_UPPER); |
| 27 | |
| 28 | static { |
| 29 | codes.setMaximum(0xFFFF); |
| 30 | codes.setPrefix("CODE"); |
| 31 | codes.setNumericAllowed(true); |
| 32 | |
| 33 | codes.add(NSID, "NSID"); |
| 34 | codes.add(CLIENT_SUBNET, "CLIENT_SUBNET"); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Converts an EDNS Option Code into its textual representation |
| 39 | */ |
| 40 | public static String |
| 41 | string(int code) { |
| 42 | return codes.getText(code); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Converts a textual representation of an EDNS Option Code into its |
| 47 | * numeric value. |
| 48 | * @param s The textual representation of the option code |
| 49 | * @return The option code, or -1 on error. |
| 50 | */ |
| 51 | public static int |
| 52 | value(String s) { |
| 53 | return codes.getValue(s); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | private final int code; |
| 58 |
nothing calls this directly
no test coverage detected