All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kendamasoft.dns.records.ARecord Maven / Gradle / Ivy

Go to download

Compact DNS client library intended primary for network utilities and testing applications

There is a newer version: 1.1.0
Show newest version
package com.kendamasoft.dns.records;

import com.kendamasoft.dns.Buffer;
import com.kendamasoft.dns.Record;

/**
 * IPv4 address record
 */
public class ARecord extends Record {

    final byte[] address = new byte[4];

    @Override
    public void parseData(short dataLength, Buffer buffer) {
        for(int i=0; i<4; i++) {
            address[i] = buffer.readByte();
        }
    }

    public byte[] getAddress() {
        return address;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for(byte b : address) {
            sb.append(b & 0xff).append(".");
        }
        sb.delete(sb.length() - 1, sb.length());
        return "A " + sb.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy