1 package fr.in2p3.jsaga.impl.buffer;
2
3 import fr.in2p3.jsaga.impl.AbstractSagaObjectImpl;
4 import org.ogf.saga.SagaObject;
5 import org.ogf.saga.buffer.Buffer;
6 import org.ogf.saga.error.*;
7
8
9
10
11
12
13
14
15
16
17
18
19
20 public abstract class AbstractBufferImpl extends AbstractSagaObjectImpl implements Buffer {
21 protected byte[] m_buffer;
22
23
24 public AbstractBufferImpl() {
25 m_buffer = null;
26 }
27
28
29 public SagaObject clone() throws CloneNotSupportedException {
30
31 return super.clone();
32 }
33
34 public int getSize() throws IncorrectStateException {
35 if (m_buffer != null) {
36 return m_buffer.length;
37 } else {
38 return -1;
39 }
40 }
41
42 public byte[] getData() throws DoesNotExistException, IncorrectStateException {
43 if (m_buffer != null) {
44 return m_buffer;
45 } else {
46 throw new DoesNotExistException("No I/O operation has been done on this buffer yet");
47 }
48 }
49
50 public void close() {
51 m_buffer = null;
52 }
53
54 public void close(float timeoutInSeconds) {
55 this.close();
56 }
57 }