Examples of LittleEndianOutputStream


Examples of org.apache.poi.util.LittleEndianOutputStream

    private void testReadWrite(byte[] data, String message) throws IOException
    {
        RecordInputStream is = TestcaseRecordInputStream.create(81, data);
        DConRefRecord d = new DConRefRecord(is);
        ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length);
        LittleEndianOutputStream o = new LittleEndianOutputStream(bos);
        d.serialize(o);
        o.flush();

        assertTrue(message, Arrays.equals(data,
                bos.toByteArray()));
    }
View Full Code Here

Examples of org.apache.poi.util.LittleEndianOutputStream

{
   CellRangeAddress ref = new CellRangeAddress(0,0,0,0);
 
  byte[] recordBytes;
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  LittleEndianOutputStream out = new LittleEndianOutputStream(baos);
 
  // With nothing set
  ref.serialize(out);
  recordBytes = baos.toByteArray();
    assertEquals(recordBytes.length, data.length);
View Full Code Here

Examples of org.apache.poi.util.LittleEndianOutputStream

        LittleEndianInputStream in = new LittleEndianInputStream(new ByteArrayInputStream(data));

        LbsDataSubRecord.LbsDropData lbs = new LbsDataSubRecord.LbsDropData(in);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        lbs.serialize(new LittleEndianOutputStream(baos));

        assertTrue(Arrays.equals(data, baos.toByteArray()));
    }
View Full Code Here

Examples of org.apache.poi.util.LittleEndianOutputStream

       FormatRun fr = new FormatRun((short)4, (short)0x15c);
       assertEquals(4, fr.getCharacterPos());
       assertEquals(0x15c, fr.getFontIndex());
      
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       LittleEndianOutputStream out = new LittleEndianOutputStream(baos);
      
       fr.serialize(out);
      
       byte[] b = baos.toByteArray();
       assertEquals(4, b.length);
View Full Code Here

Examples of org.apache.poi.util.LittleEndianOutputStream

       assertEquals("", ext.getPhoneticText());
       assertEquals(0, ext.getPhRuns().length);
       assertEquals(10, ext.getDataSize()); // Excludes 4 byte header
      
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       LittleEndianOutputStream out = new LittleEndianOutputStream(baos);
       ContinuableRecordOutput cout = new ContinuableRecordOutput(out, 0xffff);
      
       ext.serialize(cout);
       cout.writeContinue();
      
View Full Code Here

Examples of org.apache.poi.util.LittleEndianOutputStream

   */
  protected abstract int getDataSize();
  public byte[] serialize() {
    int size = getDataSize() + 4;
    ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
    serialize(new LittleEndianOutputStream(baos));
    if (baos.size() != size) {
      throw new RuntimeException("write size mismatch");
    }
    return baos.toByteArray();
  }
View Full Code Here

Examples of org.apache.poi.util.LittleEndianOutputStream

      throw new RuntimeException(e);
    }

    md5.update(_keyDigest);
    ByteArrayOutputStream baos = new ByteArrayOutputStream(4);
    new LittleEndianOutputStream(baos).writeInt(keyBlockNo);
    md5.update(baos.toByteArray());

    byte[] digest = md5.digest();
    return new RC4(digest);
  }
View Full Code Here

Examples of org.apache.poi.util.LittleEndianOutputStream

   */
  protected abstract int getDataSize();
  public byte[] serialize() {
    int size = getDataSize() + 4;
    ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
    serialize(new LittleEndianOutputStream(baos));
    if (baos.size() != size) {
      throw new RuntimeException("write size mismatch");
    }
    return baos.toByteArray();
  }
View Full Code Here

Examples of org.apache.poi.util.LittleEndianOutputStream

    private void testReadWrite(byte[] data, String message) throws IOException
    {
        RecordInputStream is = TestcaseRecordInputStream.create(81, data);
        DConRefRecord d = new DConRefRecord(is);
        ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length);
        LittleEndianOutputStream o = new LittleEndianOutputStream(bos);
        d.serialize(o);
        o.flush();

        assertTrue(message, Arrays.equals(data,
                bos.toByteArray()));
    }
View Full Code Here

Examples of org.apache.poi.util.LittleEndianOutputStream

    public void testStore() throws IOException {
        CellRangeAddress ref = new CellRangeAddress(0, 0, 0, 0);

        byte[] recordBytes;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        LittleEndianOutputStream out = new LittleEndianOutputStream(baos);
        try {
            // With nothing set
            ref.serialize(out);
            recordBytes = baos.toByteArray();
            assertEquals(recordBytes.length, data.length);
            for (int i = 0; i < data.length; i++) {
                assertEquals("At offset " + i, 0, recordBytes[i]);
            }

            // Now set the flags
            ref.setFirstRow((short) 2);
            ref.setLastRow((short) 4);
            ref.setFirstColumn((short) 0);
            ref.setLastColumn((short) 3);

            // Re-test
            baos.reset();
            ref.serialize(out);
            recordBytes = baos.toByteArray();

            assertEquals(recordBytes.length, data.length);
            for (int i = 0; i < data.length; i++) {
                assertEquals("At offset " + i, data[i], recordBytes[i]);
            }
        } finally {
            out.close();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.