Coverage Report - org.jscsi.target.scsi.ISerializable
 
Classes in this File Line Coverage Branch Coverage Complexity
ISerializable
N/A
N/A
1
 
 1  
 package org.jscsi.target.scsi;
 2  
 
 3  
 
 4  
 import java.nio.ByteBuffer;
 5  
 
 6  
 
 7  
 /**
 8  
  * This interface specifies methods for serializing an object. The serialized object can be inserted into an existing
 9  
  * {@link ByteBuffer} of sufficient size at an arbitrary position.
 10  
  * <p>
 11  
  * This interface is implemented by the classes representing sense and response data (as well as components thereof) to
 12  
  * SCSI requests, which are returned to the iSCSI initiator in the SCSI Response PDU's data segment.
 13  
  * <p>
 14  
  * Additional care must be taken when implementing objects consisting of several {@link ISerializable} components, not
 15  
  * to overwrite the fields of another component. The advantage of this strategy, however, will be higher speed, since
 16  
  * unnecessary buffer-to-buffer copying is avoided.
 17  
  * 
 18  
  * @author Andreas Ergenzinger
 19  
  */
 20  
 public interface ISerializable {
 21  
 
 22  
     /**
 23  
      * Inserts a serialized representation of the object into the specified {@link ByteBuffer}. The serialized object
 24  
      * will occupy the byte positions from <i>index</i> to <i>index + {@link #size()} - 1</i>.
 25  
      * 
 26  
      * @param byteBuffer where to insert the serialized object representation
 27  
      * @param index the position of the first byte of the serialized object in the {@link ByteBuffer}
 28  
      */
 29  
     public void serialize (ByteBuffer byteBuffer, int index);
 30  
 
 31  
     /**
 32  
      * Returns the size in bytes of the object's serialized representation.
 33  
      * 
 34  
      * @return the size in bytes of the object's serialized representation
 35  
      */
 36  
     public int size ();
 37  
 
 38  
 }