Coverage Report - org.jscsi.target.scsi.modeSense.ModeParameterListBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
ModeParameterListBuilder
0%
0/23
0%
0/6
1.714
 
 1  
 package org.jscsi.target.scsi.modeSense;
 2  
 
 3  
 /**
 4  
  * A builder object used during the initialization of new {@link ModeParameterList} objects.
 5  
  * 
 6  
  * @author Andreas Ergenzinger
 7  
  */
 8  
 public final class ModeParameterListBuilder {
 9  
 
 10  
     /**
 11  
      * The {@link HeaderType} to be used by the {@link ModeParameterList}.
 12  
      */
 13  
     final HeaderType headerType;
 14  
 
 15  
     /**
 16  
      * Contains all elements to be included in the list of {@link LogicalBlockDescriptor} objects of the
 17  
      * {@link ModeParameterList}.
 18  
      */
 19  
     LogicalBlockDescriptor[] logicalBlockDescriptors;
 20  
 
 21  
     /**
 22  
      * If the {@link ModeParameterList} uses a {@link HeaderType#MODE_PARAMETER_HEADER_10} and this value is
 23  
      * <code>true</code>, then all contained MODE PARAMETER BLOCK DESCRIPTORs will have the LONG LBA (LOGICAL BLOCK
 24  
      * ADDRESS) format.
 25  
      * <p>
 26  
      * The jSCSI Target supports only the short format.
 27  
      */
 28  0
     boolean longLba = false;
 29  
 
 30  
     /**
 31  
      * Contains all elements to be included in the list of {@link ModePage} objects of the {@link ModeParameterList}.
 32  
      */
 33  
     ModePage[] modePages;
 34  
 
 35  0
     public ModeParameterListBuilder (final HeaderType headerType) {
 36  0
         this.headerType = headerType;
 37  0
     }
 38  
 
 39  
     public void setLogicalBlockDescriptors (final ShortLogicalBlockDescriptor logicalBlockDescriptor) {
 40  0
         final ShortLogicalBlockDescriptor[] array = new ShortLogicalBlockDescriptor[1];
 41  0
         array[0] = logicalBlockDescriptor;
 42  0
         setLogicalBlockDescriptors(array);
 43  0
     }
 44  
 
 45  
     public void setLogicalBlockDescriptors (final ShortLogicalBlockDescriptor[] logicalBlockDescriptors) {
 46  0
         this.logicalBlockDescriptors = logicalBlockDescriptors;
 47  0
         longLba = false;
 48  0
     }
 49  
 
 50  
     public void setLogicalBlockDescriptors (final LongLogicalBlockDescriptor[] logicalBlockDescriptors) {
 51  0
         this.logicalBlockDescriptors = logicalBlockDescriptors;
 52  0
         longLba = true;
 53  0
     }
 54  
 
 55  
     public void setModePages (final ModePage modePage) {
 56  0
         final ModePage[] array = new ModePage[1];
 57  0
         array[0] = modePage;
 58  0
         setModePages(array);
 59  0
     }
 60  
 
 61  
     public void setModePages (final ModePage[] modePages) {
 62  0
         this.modePages = modePages;
 63  0
     }
 64  
 
 65  
     /**
 66  
      * This method is used for checking that all required members are initialized and their respective values compatible
 67  
      * with each other.
 68  
      * 
 69  
      * @return <code>true</code> if everything is fine, <code>false</code> if not
 70  
      */
 71  
     boolean checkIntegrity () {
 72  0
         if (headerType == null) return false;
 73  0
         if (headerType == HeaderType.MODE_PARAMETER_HEADER_6 && longLba) return false;
 74  0
         return true;
 75  
     }
 76  
 }