1 23 package org.archive.util.ms; 24 25 26 import java.nio.ByteBuffer ; 27 import java.nio.ByteOrder ; 28 29 30 class HeaderBlock { 31 32 33 private ByteBuffer buffer; 34 35 36 public HeaderBlock(ByteBuffer buffer) { 37 this.buffer = buffer; 39 buffer.order(ByteOrder.LITTLE_ENDIAN); 40 } 41 42 43 public long getFileType() { 44 return buffer.getLong(0); 45 } 46 47 48 public int getBATCount() { 49 return buffer.getInt(0x2C); 50 } 51 52 53 public int getEntriesStart() { 54 return buffer.getInt(0x30); 55 } 56 57 58 public int getSmallBATStart() { 59 return buffer.getInt(0x3C); 60 } 61 62 63 public int getSmallBATCount() { 64 return buffer.getInt(0x40); 65 } 66 67 68 public int getExtendedBATStart() { 69 return buffer.getInt(0x44); 70 } 71 72 73 public int getExtendedBATCount() { 74 return buffer.getInt(0x48); 75 } 76 77 78 public int getBATBlockNumber(int block) { 79 assert block < 110; 80 return buffer.getInt(0x4C + block * 4); 81 } 82 83 84 public String toString() { 85 StringBuilder sb = new StringBuilder ("HeaderBlock{"); 86 sb.append("fileType=" + getFileType()); 87 sb.append(" propertiesStart=" + getEntriesStart()); 88 sb.append(" batCount=" + getBATCount()); 89 sb.append(" extendedBATStart=" + getExtendedBATStart()); 90 sb.append(" extendedBATCount=" + getExtendedBATCount()); 91 sb.append(" smallBATStart=" + getSmallBATStart()); 92 sb.append(" smallBATCount=" + getSmallBATCount()); 93 sb.append("}"); 94 return sb.toString(); 95 } 96 97 } 98 | Popular Tags |