1 package fr.in2p3.jsaga.impl.buffer;
2
3 import org.ogf.saga.SagaObject;
4 import org.ogf.saga.buffer.Buffer;
5 import org.ogf.saga.error.*;
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public class ApplicationAllocatedBufferImpl extends AbstractBufferImpl implements Buffer {
20
21 public ApplicationAllocatedBufferImpl(byte[] data) throws BadParameterException, NoSuccessException {
22 super();
23 this.setData(data);
24 }
25
26
27 public SagaObject clone() throws CloneNotSupportedException {
28 ApplicationAllocatedBufferImpl clone = (ApplicationAllocatedBufferImpl) super.clone();
29 clone.m_buffer = m_buffer;
30 return clone;
31 }
32
33 public void setSize(int size) throws BadParameterException, IncorrectStateException, NoSuccessException {
34 throw new IncorrectStateException("Not allowed to change the size of an application-allocated buffer", this);
35 }
36
37 public void setSize() throws BadParameterException, IncorrectStateException, NoSuccessException {
38 throw new IncorrectStateException("Not allowed to change the size of an application-allocated buffer", this);
39 }
40
41 public void setData(byte[] data) throws BadParameterException, NoSuccessException {
42 if (data != null) {
43 m_buffer = data;
44 } else {
45 throw new BadParameterException("You must specify either the buffer or its size");
46 }
47 }
48 }