View Javadoc

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   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
10  * ***             http://cc.in2p3.fr/             ***
11  * ***************************************************
12  * File:   AbstractBufferImpl
13  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
14  * Date:   16 sept. 2007
15  * ***************************************************
16  * Description:                                      */
17  /**
18   *
19   */
20  public abstract class AbstractBufferImpl extends AbstractSagaObjectImpl implements Buffer {
21      protected byte[] m_buffer;
22  
23      /** constructor */
24      public AbstractBufferImpl() {
25          m_buffer = null;
26      }
27  
28      /** clone */
29      public SagaObject clone() throws CloneNotSupportedException {
30          // do not assign m_buffer here (see inherited classes)
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  }