-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractDNSObject.java
More file actions
62 lines (57 loc) · 1.72 KB
/
AbstractDNSObject.java
File metadata and controls
62 lines (57 loc) · 1.72 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
/**
* Abstract implementation of DNSObject to define some common functionality
* that will be present in all implementations.
*
* @author Chris Blades
* @version 1/3/10
*/
public abstract class AbstractDNSObject implements DNSObject {
/**
* wether this DNSObject has been changed, if it has, serialized and
* values will have to be re-generated
*/
protected boolean changed;
/**
* Byte-version of this object in DNS format
*/
protected byte[] serialized;
/**
* A Map of the state of this DNSObject
*/
protected Map<Object, Object> values;
/**
* Performs operations that will be common to all DNSObjects construction.
*/
public AbstractDNSObject() {
this.changed = true;
this.values = new Map<Object, Object>();
}
/**
* Returns the length of the serialized version of this DNSObject,
* in bytes
*
* @return the length of the serialized version of this DNSObject.
*/
public int getLength() {
this.generateTransient();
return serialized.length;
}
/**
* Will generate a serialized version of this DNSObject that conforms
* to the DNS protocol.
*
* @return a serialized version of this DNSObject.
*/
public abstract byte[] serialize();
/**
* Returns a mapping of the state values of this DNSObject.
*
* @return a mapping of the state values of this DNSObject.
*/
public abstract Map stateValues();
/**
* Generates transient state. Should at least generate serialized and
* values. Should only re-generate when changed == true.
*/
protected abstract void generateTransient();
}