Subversion Repositories Code-Repo

Rev

Rev 96 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
96 Kevin 1
 
2
public class BufferBlock {
3
	private long startAddress;
4
	private byte[] bytes;
5
	private int size;
6
	private BufferBlock prev;
7
	private BufferBlock next;
8
	private boolean dirtyBit;
9
 
10
	public BufferBlock(int sz) {
11
		setStartAddress(-1);
12
		bytes = new byte[sz];
13
		this.size = sz;
14
		prev = null;
15
		next = null;
16
		setDirtyBit(false);
17
	}
18
 
19
	/** Copies size bytes starting from address to out + offset
20
	 * 
21
	 * @param out Destination array to copy bytes to
22
	 * @param offset Offset of position to write to in the destination array
23
	 * @param address Starting address in block to copy bytes from
24
	 * @param length Number of bytes to copy from the block
25
	 */
26
	public void getBytes(byte[] out, int offset, int address, int length) {
27
		for (int i = 0; i < length; i++) {
28
			out[i + offset] = bytes[address + i];
29
		}
30
	}
31
 
32
	/** Puts size bytes starting to address from in
33
	 * 
34
	 * @param in Source array to copy bytes from
35
	 * @param offset Offset position in the source array to copy from
36
	 * @param address Starting address in the block to copy bytes to
37
	 * @param length Number of bytes to copy into the block
38
	 */
39
	public void setBytes(byte[] in, int offset, int address, int length) {
40
		for (int i = 0; i < length; i++) {
41
			bytes[address + i] = in[i + offset]; 
42
		}
43
	}
44
 
45
	public BufferBlock getPrev() {
46
		return prev;
47
	}
48
	public void setPrev(BufferBlock prev) {
49
		this.prev = prev;
50
	}
51
	public BufferBlock getNext() {
52
		return next;
53
	}
54
	public void setNext(BufferBlock next) {
55
		this.next = next;
56
	}
57
	public int getSize() {
58
		return size;
59
	}
60
	public boolean isDirtyBit() {
61
		return dirtyBit;
62
	}
63
	public void setDirtyBit(boolean dirtyBit) {
64
		this.dirtyBit = dirtyBit;
65
	}
66
	public long getStartAddress() {
67
		return startAddress;
68
	}
69
	public void setStartAddress(long startAddress) {
70
		this.startAddress = startAddress;
71
	}
72
}