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


    return 2 + CellRangeAddress.getEncodedSize(numberOfRanges);
  }

  public int serialize(int offset, byte[] data) {
    int totalSize = getSize();
    serialize(new LittleEndianByteArrayOutputStream(data, offset, totalSize));
    return totalSize;
  }
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

  /**
   * @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

  }
  @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

  }
  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

    g = GUID.parse("13579BDF-0246-8ACE-0123-456789ABCDEF");
    confirmGUID(g, 0x13579BDF, 0x0246, 0x8ACE, 0x0123456789ABCDEFL);
    assertEquals("13579BDF-0246-8ACE-0123-456789ABCDEF", g.formatAsString());

    byte[] buf = new byte[16];
    g.serialize(new LittleEndianByteArrayOutputStream(buf, 0));
    String expectedDump = "[DF, 9B, 57, 13, 46, 02, CE, 8A, 01, 23, 45, 67, 89, AB, CD, EF]";
    assertEquals(expectedDump, HexDump.toHex(buf));

    // STD Moniker
    g = createFromStreamDump("[D0, C9, EA, 79, F9, BA, CE, 11, 8C, 82, 00, AA, 00, 4B, A9, 0B]");
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 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<Ptg> 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<Ptg>(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

   * @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<Ptg> 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<Ptg>(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

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.