-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDNSRecordClassParserDecorator.java
More file actions
77 lines (69 loc) · 2.02 KB
/
DNSRecordClassParserDecorator.java
File metadata and controls
77 lines (69 loc) · 2.02 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* A decorator for DNSRecordClass that parses a byte buffer to create a
* DNSRecordClass.
*
* @author Chris Blades
* @version 20/3/10
*/
public class DNSRecordClassParserDecorator implements DNSRecordClass {
/** The DNSRecordClass object this object wraps */
private DNSRecordClass recClass;
/** byte buffer to parse and pass to other objects */
private IndexedArrayList<Byte> bytes;
/**
* Creates a new DNSRecordClassParserDecorator with the given byte
* buffer.
*
* @param bytes the byte buffer to parse.
*/
public DNSRecordClassParserDecorator(IndexedArrayList<Byte> bytes) {
this.bytes = bytes;
// cheating a bit, this will always be true
recClass = DNSRecordClassEnum.IN;
}
/**
* Parses the byte buffer to form a DNSRecordClass object.
*
*/
public void parse() {
// don't do anything but advance buffer so it will be in the right
// position
bytes.getNext();
bytes.getNext();
}
/**
* Returns a string represention of this record class.
*
* @return a string representation of this record class.
*/
public String getName() {
return recClass.getName();
}
/**
* Returns the length of the parsed DNSRecordClass object.
*
* @return the length of the parsed DNSRecordClass object.
*/
public int getLength() {
return recClass.getLength();
}
/**
* returns the serialized version of the parsed DNSRecordClass object.
* can't just return the byte buffer because we don't know what else is in
* it.
*
* @return the serialized version of the parsed DNSRecordClass object.
*/
public byte[] serialize() {
return recClass.serialize();
}
/**
* Returns a mapping of the state values of the parsed DNSRecordClass
* object.
*
* @return the state values of the parsed DNSRecordClass object.
*/
public Map stateValues() {
return recClass.stateValues();
}
}