Coverage Report - org.jscsi.target.scsi.sense.senseDataDescriptor.InformationSenseDataDescriptor
 
Classes in this File Line Coverage Branch Coverage Complexity
InformationSenseDataDescriptor
0%
0/9
N/A
1.5
 
 1  
 package org.jscsi.target.scsi.sense.senseDataDescriptor;
 2  
 
 3  
 
 4  
 import java.nio.ByteBuffer;
 5  
 
 6  
 import org.jscsi.target.scsi.sense.information.EightByteInformation;
 7  
 import org.jscsi.target.util.BitManip;
 8  
 
 9  
 
 10  
 /**
 11  
  * The information sense data descriptor provides information that is device-type or command specific and is defined in
 12  
  * a command standard.
 13  
  * 
 14  
  * @author Andreas Ergenzinger
 15  
  */
 16  
 public final class InformationSenseDataDescriptor extends SenseDataDescriptor {
 17  
 
 18  
     /**
 19  
      * The position of the byte containing the VALID bit.
 20  
      */
 21  
     private static final int VALID_FLAG_BYTE_INDEX = 2;
 22  
 
 23  
     /**
 24  
      * The position of the INFORMATION field.
 25  
      */
 26  
     private static final int INFORMATION_INDEX = 4;
 27  
 
 28  
     /**
 29  
      * The VALID bit shall be set to one.
 30  
      * <p>
 31  
      * In previous versions of this standard and in the fixed format sense data, the VALID bit indicates whether the
 32  
      * contents of the INFORMATION field is valid as defined by a command standard. Since the contents of the
 33  
      * INFORMATION field are valid whenever an information sense data descriptor is included in the sense data, the only
 34  
      * legal value for the VALID bit is set to one.
 35  
      */
 36  0
     private final boolean valid = true;
 37  
 
 38  
     /**
 39  
      * This field may contain additional information (but doesn't).
 40  
      */
 41  
     private final EightByteInformation information;
 42  
 
 43  
     /**
 44  
      * The constructor.
 45  
      * 
 46  
      * @param information {@link EightByteInformation} that may contain useful information
 47  
      */
 48  
     public InformationSenseDataDescriptor (final EightByteInformation information) {
 49  0
         super(SenseDataDescriptorType.INFORMATION, // descriptor type
 50  
         0x0a); // additional length
 51  0
         this.information = information;
 52  0
     }
 53  
 
 54  
     @Override
 55  
     protected final void serializeSpecificFields (final ByteBuffer byteBuffer, final int index) {
 56  
 
 57  0
         byte b = 0;
 58  
 
 59  
         // valid bit
 60  0
         if (valid) b = BitManip.getByteWithBitSet(b, 7, true);
 61  0
         byteBuffer.put(index + VALID_FLAG_BYTE_INDEX, b);
 62  
 
 63  
         // information
 64  0
         information.serialize(byteBuffer, index + INFORMATION_INDEX);
 65  0
     }
 66  
 
 67  
 }