Example #1
0
  /** test the getInt() method */
  public void testGetInt() {
    // reading 4 byte data from a 5 byte buffer
    byte[] testdata = {
      (byte) 0x01, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x02,
    };

    assertEquals(0xFFFFFF01, LittleEndian.getInt(testdata));
    assertEquals(0x02FFFFFF, LittleEndian.getInt(testdata, 1));
  }
Example #2
0
 public FIBFieldHandler(
     byte mainStream[],
     int startOffset,
     byte tableStream[],
     HashSet offsetList,
     boolean areKnown) {
   _unknownMap = new HashMap();
   int numFields = LittleEndian.getShort(mainStream, startOffset);
   int offset = startOffset + 2;
   _fields = new int[numFields * 2];
   for (int x = 0; x < numFields; x++) {
     int fieldOffset = x * 8 + offset;
     int dsOffset = LittleEndian.getInt(mainStream, fieldOffset);
     fieldOffset += 4;
     int dsSize = LittleEndian.getInt(mainStream, fieldOffset);
     if (offsetList.contains(Integer.valueOf(x)) ^ areKnown && dsSize > 0)
       if (dsOffset + dsSize > tableStream.length) {
         log.log(
             POILogger.WARN,
             (new StringBuilder())
                 .append("Unhandled data structure points to outside the buffer. offset = ")
                 .append(dsOffset)
                 .append(", length = ")
                 .append(dsSize)
                 .append(", buffer length = ")
                 .append(tableStream.length)
                 .toString());
       } else {
         UnhandledDataStructure unhandled =
             new UnhandledDataStructure(tableStream, dsOffset, dsSize);
         _unknownMap.put(Integer.valueOf(x), unhandled);
       }
     _fields[x * 2] = dsOffset;
     _fields[x * 2 + 1] = dsSize;
   }
 }
Example #3
0
 /**
  * Reads the 8 byte header information and populates the <code>options</code> and <code>recordId
  * </code> records.
  *
  * @param data the byte array to read from
  * @param offset the offset to start reading from
  * @return the number of bytes remaining in this record. This may include the children if this is
  *     a container.
  */
 protected int readHeader(byte[] data, int offset) {
   _options = LittleEndian.getShort(data, offset);
   _recordId = LittleEndian.getShort(data, offset + 2);
   int remainingBytes = LittleEndian.getInt(data, offset + 4);
   return remainingBytes;
 }