org.xbill.DNS.DClass Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ddns-dnsjava Show documentation
Show all versions of ddns-dnsjava Show documentation
DiscoveryDNS fork of DNSJava project
// Copyright (c) 1999-2004 Brian Wellington ([email protected])
package org.xbill.DNS;
/**
* Constants and functions relating to DNS classes. This is called DClass
* to avoid confusion with Class.
*
* @author Brian Wellington
*/
public final class DClass {
/** Internet */
public static final int IN = 1;
/** Chaos network (MIT) */
public static final int CH = 3;
/** Chaos network (MIT, alternate name) */
public static final int CHAOS = 3;
/** Hesiod name server (MIT) */
public static final int HS = 4;
/** Hesiod name server (MIT, alternate name) */
public static final int HESIOD = 4;
/** Special value used in dynamic update messages */
public static final int NONE = 254;
/** Matches any class */
public static final int ANY = 255;
private static class DClassMnemonic extends Mnemonic {
public
DClassMnemonic() {
super("DClass", CASE_UPPER);
setPrefix("CLASS");
}
public void
check(int val) {
DClass.check(val);
}
}
private static Mnemonic classes = new DClassMnemonic();
static {
classes.add(IN, "IN");
classes.add(CH, "CH");
classes.addAlias(CH, "CHAOS");
classes.add(HS, "HS");
classes.addAlias(HS, "HESIOD");
classes.add(NONE, "NONE");
classes.add(ANY, "ANY");
}
private
DClass() {}
/**
* Checks that a numeric DClass is valid.
* @param i the i to check
* @throws InvalidDClassException The class is out of range.
*/
public static void
check(int i) {
if (i < 0 || i > 0xFFFF)
throw new InvalidDClassException(i);
}
/**
* Converts a numeric DClass into a String
* @param i the i to check
* @return The canonical string representation of the class
* @throws InvalidDClassException The class is out of range.
*/
public static String
string(int i) {
return classes.getText(i);
}
/**
* Converts a String representation of a DClass into its numeric value
* @param s the s to value
* @return The class code, or -1 on error.
*/
public static int
value(String s) {
return classes.getValue(s);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy