| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| SubPageFormatModePage |
|
| 1.0;1 |
| 1 | package org.jscsi.target.scsi.modeSense; | |
| 2 | ||
| 3 | ||
| 4 | import java.nio.ByteBuffer; | |
| 5 | ||
| 6 | import org.jscsi.target.util.ReadWrite; | |
| 7 | ||
| 8 | ||
| 9 | /** | |
| 10 | * Instances of this class represent MODE PAGEs using the SUB-PAGE format. | |
| 11 | * | |
| 12 | * @author Andreas Ergenzinger | |
| 13 | */ | |
| 14 | public abstract class SubPageFormatModePage extends ModePage { | |
| 15 | ||
| 16 | /** | |
| 17 | * The index of the SUB-PAGE CODE field in the serialized representation of a MODE PAGE using the SUB-PAGE format. | |
| 18 | */ | |
| 19 | private static final int SUB_PAGE_CODE_INDEX = 1; | |
| 20 | ||
| 21 | /** | |
| 22 | * The index of the PAGE LENGTH field in the serialized representation of a MODE PAGE using the SUB-PAGE format. | |
| 23 | */ | |
| 24 | private static final int PAGE_LENGTH_INDEX = 2; | |
| 25 | ||
| 26 | /** | |
| 27 | * Together with {@link ModePage#pageCode} this value determines the kind of information contained in the MODE PAGE. | |
| 28 | */ | |
| 29 | private final int subPageCode; | |
| 30 | ||
| 31 | /** | |
| 32 | * The abstract constructor. | |
| 33 | * | |
| 34 | * @param parametersSaveable value of the PARAMETERS SAVEABLE bit | |
| 35 | * @param pageCode general description of the contained information | |
| 36 | * @param subPageCode more specific description of the contained information | |
| 37 | * @param pageLength the value of the PAGE LENGTH field | |
| 38 | */ | |
| 39 | public SubPageFormatModePage (boolean parametersSaveable, int pageCode, final int subPageCode, int pageLength) { | |
| 40 | 0 | super(parametersSaveable, true,// subPageFormat |
| 41 | pageCode, pageLength); | |
| 42 | 0 | this.subPageCode = subPageCode; |
| 43 | 0 | } |
| 44 | ||
| 45 | @Override | |
| 46 | protected final void serializeSubPageCode (final ByteBuffer buffer, final int index) { | |
| 47 | 0 | buffer.position(index + SUB_PAGE_CODE_INDEX); |
| 48 | 0 | buffer.put((byte) subPageCode); |
| 49 | 0 | } |
| 50 | ||
| 51 | @Override | |
| 52 | protected final void serializePageLength (ByteBuffer buffer, int index) { | |
| 53 | 0 | buffer.position(index + PAGE_LENGTH_INDEX); |
| 54 | 0 | ReadWrite.writeTwoByteInt(buffer,// buffer |
| 55 | pageLength,// value | |
| 56 | index + PAGE_LENGTH_INDEX);// index | |
| 57 | 0 | } |
| 58 | ||
| 59 | } |