diff options
author | Rene Treffer <treffer@measite.de> | 2014-04-02 22:00:32 +0200 |
---|---|---|
committer | Rene Treffer <treffer@measite.de> | 2014-04-02 22:00:32 +0200 |
commit | 32b27c53e03d3e1f25230efc48610efeab31f9a2 (patch) | |
tree | 89b60b17670b098cbb476b855c8fbe430a2edb80 /src/de/measite/minidns/record/AAAA.java |
Initial commit
Diffstat (limited to 'src/de/measite/minidns/record/AAAA.java')
-rw-r--r-- | src/de/measite/minidns/record/AAAA.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/de/measite/minidns/record/AAAA.java b/src/de/measite/minidns/record/AAAA.java new file mode 100644 index 00000000..d89147b2 --- /dev/null +++ b/src/de/measite/minidns/record/AAAA.java @@ -0,0 +1,43 @@ +package de.measite.minidns.record; + +import java.io.DataInputStream; +import java.io.IOException; + +import de.measite.minidns.Record.TYPE; + +public class AAAA implements Data { + + private byte[] ip; + + @Override + public TYPE getType() { + return TYPE.AAAA; + } + + @Override + public byte[] toByteArray() { + return ip; + } + + @Override + public void parse(DataInputStream dis, byte[] data, int length) + throws IOException { + ip = new byte[16]; + dis.readFully(ip); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < ip.length; i += 2) { + if (i != 0) { + sb.append(':'); + } + sb.append(Integer.toHexString( + ((ip[i] & 0xff) << 8) + (ip[i + 1] & 0xff) + )); + } + return sb.toString(); + } + +} |