View Javadoc

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   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
9   * ***             http://cc.in2p3.fr/             ***
10  * ***************************************************
11  * File:   ApplicationAllocatedBufferImpl
12  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
13  * Date:   17 sept. 2007
14  * ***************************************************
15  * Description:                                      */
16  /**
17   *
18   */
19  public class ApplicationAllocatedBufferImpl extends AbstractBufferImpl implements Buffer {
20      /** constructor */
21      public ApplicationAllocatedBufferImpl(byte[] data) throws BadParameterException, NoSuccessException {
22          super();
23          this.setData(data);
24      }
25  
26      /** clone: copy buffer reference */
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  }