A.java

 1package de.measite.minidns.record;
 2
 3import java.io.DataInputStream;
 4import java.io.IOException;
 5
 6import de.measite.minidns.Record.TYPE;
 7
 8/**
 9 * A record payload (ip pointer).
10 */
11public class A implements Data {
12
13    /**
14     * Target IP.
15     */
16    private byte[] ip;
17
18    @Override
19    public TYPE getType() {
20        return TYPE.A;
21    }
22
23    @Override
24    public byte[] toByteArray() {
25        return ip;
26    }
27
28    @Override
29    public void parse(DataInputStream dis, byte[] data, int length)
30            throws IOException {
31        ip = new byte[4];
32        dis.readFully(ip);
33    }
34
35    @Override
36    public String toString() {
37        return Integer.toString(ip[0] & 0xff) + "." +
38               Integer.toString(ip[1] & 0xff) + "." +
39               Integer.toString(ip[2] & 0xff) + "." +
40               Integer.toString(ip[3] & 0xff);
41    }
42
43}