Package de.measite.minidns.util
Class NameUtil
- java.lang.Object
-
- de.measite.minidns.util.NameUtil
-
public class NameUtil extends java.lang.ObjectUtilities related to internationalized domain names and dns name handling.
-
-
Constructor Summary
Constructors Constructor Description NameUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanidnEquals(java.lang.String name1, java.lang.String name2)Check if two internationalized domain names are equal, possibly causing a serialization of both domain names.static java.lang.Stringparse(byte[] data, int offset, java.util.HashSet<java.lang.Integer> jumps)Parse a domain name starting at the given offset.static java.lang.Stringparse(java.io.DataInputStream dis, byte[] data)Parse a domain name starting at the current offset and moving the input stream pointer past this domain name (even if cross references occure).static intsize(java.lang.String name)Retrieve the rough binary length of a string (length + 2 bytes length prefix).static byte[]toByteArray(java.lang.String name)Serialize a domain name under IDN rules.
-
-
-
Method Detail
-
size
public static int size(java.lang.String name)
Retrieve the rough binary length of a string (length + 2 bytes length prefix).- Parameters:
name- The name string.- Returns:
- The binary size of the string (length + 2).
-
idnEquals
public static boolean idnEquals(java.lang.String name1, java.lang.String name2)Check if two internationalized domain names are equal, possibly causing a serialization of both domain names.- Parameters:
name1- The first domain name.name2- The second domain name.- Returns:
- True if both domain names are the same.
-
toByteArray
public static byte[] toByteArray(java.lang.String name) throws java.io.IOExceptionSerialize a domain name under IDN rules.- Parameters:
name- The domain name.- Returns:
- The binary domain name representation.
- Throws:
java.io.IOException- Should never happen.
-
parse
public static java.lang.String parse(java.io.DataInputStream dis, byte[] data) throws java.io.IOExceptionParse a domain name starting at the current offset and moving the input stream pointer past this domain name (even if cross references occure).- Parameters:
dis- The input stream.data- The raw data (for cross references).- Returns:
- The domain name string.
- Throws:
java.io.IOException- Should never happen.
-
parse
public static java.lang.String parse(byte[] data, int offset, java.util.HashSet<java.lang.Integer> jumps)Parse a domain name starting at the given offset.- Parameters:
data- The raw data.offset- The offset.jumps- The list of jumps (by now).- Returns:
- The parsed domain name.
- Throws:
java.lang.IllegalStateException- on cycles.
-
-