Package org.apache.poi.util

Examples of org.apache.poi.util.LittleEndianByteArrayOutputStream


  /**
   * @deprecated use {@link #serialize(LittleEndianOutput)}
   */
  public int serialize(int offset, byte[] data) {
    serialize(new LittleEndianByteArrayOutputStream(data, offset, ENCODED_SIZE));
    return ENCODED_SIZE;
  }
View Full Code Here


      _out = out;
    } else {
      // otherwise temporarily write all subsequent data to a buffer
      _dataSizeOutput = out;
      _byteBuffer = new byte[RecordInputStream.MAX_RECORD_DATA_SIZE];
      _out = new LittleEndianByteArrayOutputStream(_byteBuffer, 0);
    }
  }
View Full Code Here

  }
  @Override
  public final int serialize(int offset, byte[] data) {
    int dataSize = getDataSize();
    int recSize = 4 + dataSize;
    LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(data, offset, recSize);
    out.writeShort(getSid());
    out.writeShort(dataSize);
    serialize(out);
    if (out.getWriteIndex() - offset != recSize) {
      throw new IllegalStateException("Error in serialization of (" + getClass().getName() + "): "
          + "Incorrect number of bytes written - expected "
          + recSize + " but got " + (out.getWriteIndex() - offset));
    }
    return recSize;
  }
View Full Code Here

   * @return number of bytes written
   */
  public static int serializePtgs(Ptg[] ptgs, byte[] array, int offset) {
    int nTokens = ptgs.length;
   
    LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(array, offset);

    List arrayPtgs = null;

    for (int k = 0; k < nTokens; k++) {
      Ptg ptg = ptgs[k];

      ptg.write(out);
      if (ptg instanceof ArrayPtg) {
        if (arrayPtgs == null) {
          arrayPtgs = new ArrayList(5);
        }
        arrayPtgs.add(ptg);
      }
    }
    if (arrayPtgs != null) {
      for (int i=0;i<arrayPtgs.size();i++) {
        ArrayPtg p = (ArrayPtg)arrayPtgs.get(i);
        p.writeTokenValueBytes(out);
      }
    }
    return out.getWriteIndex() - offset;
  }
View Full Code Here

  }
  public void testEncode() {
    int size = ConstantValueParser.getEncodedSize(SAMPLE_VALUES);
    byte[] data = new byte[size];
   
    ConstantValueParser.encode(new LittleEndianByteArrayOutputStream(data, 0), SAMPLE_VALUES);
   
    if (!Arrays.equals(data, SAMPLE_ENCODING)) {
      fail("Encoding differs");
    }
  }
View Full Code Here

  }

  public int serialize(int offset, byte[] data) {
    int recSize = getRecordSize();
    int dataSize = recSize - 4;
    LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(data, offset, recSize);

    out.writeShort(sid);
    out.writeShort(dataSize);

    if (_uninterpretedData == null) {

      for (int i = 0; i < subrecords.size(); i++) {
        SubRecord record = subrecords.get(i);
        record.serialize(out);
      }
      int expectedEndIx = offset+dataSize;
      // padding
      while (out.getWriteIndex() < expectedEndIx) {
        out.writeByte(0);
      }
    } else {
      out.write(_uninterpretedData);
    }
    return recSize;
  }
View Full Code Here

  /**
   * @deprecated use {@link #serialize(LittleEndianOutput)}
   */
  public int serialize(int offset, byte[] data) {
    serialize(new LittleEndianByteArrayOutputStream(data, offset, ENCODED_SIZE));
    return ENCODED_SIZE;
  }
View Full Code Here

    assertEquals(new Double(0), values[1][0]);
    assertEquals(Boolean.FALSE, values[1][1]);
    assertEquals("FG", values[1][2]);

    byte[] outBuf = new byte[ENCODED_CONSTANT_DATA.length];
    ptg.writeTokenValueBytes(new LittleEndianByteArrayOutputStream(outBuf, 0));

    if(outBuf[0] == 4) {
      throw new AssertionFailedError("Identified bug 42564b");
    }
    assertTrue(Arrays.equals(ENCODED_CONSTANT_DATA, outBuf));
View Full Code Here

    return out.getTotalSize();
  }

  public final int serialize(int offset, byte[] data) {

    LittleEndianOutput leo = new LittleEndianByteArrayOutputStream(data, offset);
    ContinuableRecordOutput out = new ContinuableRecordOutput(leo, getSid());
    serialize(out);
    out.terminate();
    return out.getTotalSize();
  }
View Full Code Here

      _out = out;
    } else {
      // otherwise temporarily write all subsequent data to a buffer
      _dataSizeOutput = out;
      _byteBuffer = new byte[RecordInputStream.MAX_RECORD_DATA_SIZE];
      _out = new LittleEndianByteArrayOutputStream(_byteBuffer, 0);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.util.LittleEndianByteArrayOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.