aboutsummaryrefslogtreecommitdiffstats
path: root/libs/minidns/src/main/java/de/measite/minidns/record/A.java
blob: 4311c651e3a516e293bbb626325c7d8eeaae999d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package de.measite.minidns.record;

import java.io.DataInputStream;
import java.io.IOException;

import de.measite.minidns.Record.TYPE;

/**
 * A record payload (ip pointer).
 */
public class A implements Data {

    /**
     * Target IP.
     */
    private byte[] ip;

    @Override
    public TYPE getType() {
        return TYPE.A;
    }

    @Override
    public byte[] toByteArray() {
        return ip;
    }

    @Override
    public void parse(DataInputStream dis, byte[] data, int length)
            throws IOException {
        ip = new byte[4];
        dis.readFully(ip);
    }

    @Override
    public String toString() {
        return Integer.toString(ip[0] & 0xff) + "." +
               Integer.toString(ip[1] & 0xff) + "." +
               Integer.toString(ip[2] & 0xff) + "." +
               Integer.toString(ip[3] & 0xff);
    }

}