~ubuntu-branches/ubuntu/wily/dnsjava/wily-proposed

« back to all changes in this revision

Viewing changes to org/xbill/DNS/HINFORecord.java

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2009-07-21 15:17:03 UTC
  • Revision ID: james.westby@ubuntu.com-20090721151703-6v0107p1s3h7gv1c
Tags: upstream-2.0.6
ImportĀ upstreamĀ versionĀ 2.0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
 
2
 
 
3
package org.xbill.DNS;
 
4
 
 
5
import java.io.*;
 
6
 
 
7
/**
 
8
 * Host Information - describes the CPU and OS of a host
 
9
 *
 
10
 * @author Brian Wellington
 
11
 */
 
12
 
 
13
public class HINFORecord extends Record {
 
14
 
 
15
private byte [] cpu, os;
 
16
 
 
17
HINFORecord() {}
 
18
 
 
19
Record
 
20
getObject() {
 
21
        return new HINFORecord();
 
22
}
 
23
 
 
24
/**
 
25
 * Creates an HINFO Record from the given data
 
26
 * @param cpu A string describing the host's CPU
 
27
 * @param os A string describing the host's OS
 
28
 * @throws IllegalArgumentException One of the strings has invalid escapes
 
29
 */
 
30
public
 
31
HINFORecord(Name name, int dclass, long ttl, String cpu, String os) {
 
32
        super(name, Type.HINFO, dclass, ttl);
 
33
        try {
 
34
                this.cpu = byteArrayFromString(cpu);
 
35
                this.os = byteArrayFromString(os);
 
36
        }
 
37
        catch (TextParseException e) {
 
38
                throw new IllegalArgumentException(e.getMessage());
 
39
        }
 
40
}
 
41
 
 
42
void
 
43
rrFromWire(DNSInput in) throws IOException {
 
44
        cpu = in.readCountedString();
 
45
        os = in.readCountedString();
 
46
}
 
47
 
 
48
void
 
49
rdataFromString(Tokenizer st, Name origin) throws IOException {
 
50
        try {
 
51
                cpu = byteArrayFromString(st.getString());
 
52
                os = byteArrayFromString(st.getString());
 
53
        }
 
54
        catch (TextParseException e) {
 
55
                throw st.exception(e.getMessage());
 
56
        }
 
57
}
 
58
 
 
59
/**
 
60
 * Returns the host's CPU
 
61
 */
 
62
public String
 
63
getCPU() {
 
64
        return byteArrayToString(cpu, false);
 
65
}
 
66
 
 
67
/**
 
68
 * Returns the host's OS
 
69
 */
 
70
public String
 
71
getOS() {
 
72
        return byteArrayToString(os, false);
 
73
}
 
74
 
 
75
void
 
76
rrToWire(DNSOutput out, Compression c, boolean canonical) {
 
77
        out.writeCountedString(cpu);
 
78
        out.writeCountedString(os);
 
79
}
 
80
 
 
81
/**
 
82
 * Converts to a string
 
83
 */
 
84
String
 
85
rrToString() {
 
86
        StringBuffer sb = new StringBuffer();
 
87
        sb.append(byteArrayToString(cpu, true));
 
88
        sb.append(" ");
 
89
        sb.append(byteArrayToString(os, true));
 
90
        return sb.toString();
 
91
}
 
92
 
 
93
}