@Override public void write(ByteBuffer data) { this.hdos.write(data); }
private void writePRDestroy(String name) { try { int nameLength = estimateByteSize(name); HeapDataOutputStream hdos = new HeapDataOutputStream(1 + nameLength + 4 + 1, Version.CURRENT); hdos.write(IFREC_PR_DESTROY); hdos.writeUTF(name); hdos.write(END_OF_RECORD_ID); writeIFRecord(hdos, false); } catch (IOException ex) { DiskAccessException dae = new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent); if (!this.compactInProgress) { this.parent.handleDiskAccessException(dae); } throw dae; } }
public void write(byte[] source, int offset, int len) { this.hdos.write(source, offset, len); } }
public final void writeNoWrap(byte[] source, int offset, int len) { super.write(source, offset, len); }
public void write(ByteSource data) { this.hdos.write(data); }
public void write(byte b) { this.hdos.write(b); }
public void write(ByteBuffer data) { this.hdos.write(data); }
public void write(byte b) { this.hdos.write(b); }
public void write(byte[] source, int offset, int len) { this.hdos.write(source, offset, len); } }
public final void writeNoWrap(byte[] source, int offset, int len) { super.write(source, offset, len); }
/** write the low-order 8 bits of the given int */ @Override public final void write(int b) { // if (logger.isTraceEnabled()) logger.trace(" byte={}", b); ensureCapacity(1); if (this.overflowBuf != null) { this.overflowBuf.write(b); return; } this.buffer.put((byte)b); }
@Override public final void write(byte[] source, int offset, int len) { // if there is enough space in current byte buffer, then use that instead // of always wrapping to avoid one additional allocation if (this.wrapBytes && this.buffer.position() > 0 && this.buffer.remaining() < len) { this.writeWithByteArrayWrappedConditionally(source, offset, len); } else { super.write(source, offset, len); } }
@Override public final void write(byte[] source, int offset, int len) { // if there is enough space in current byte buffer, then use that instead // of always wrapping to avoid one additional allocation if (this.wrapBytes && this.buffer.remaining() < len) { this.writeWithByteArrayWrappedConditionally(source, offset, len); } else { super.write(source, offset, len); } }
/** write the low-order 8 bits of the given int */ @Override public final void write(int b) { if (DEBUG) debug(" byte=" + b); ensureCapacity(1); if (this.overflowBuf != null) { this.overflowBuf.write(b); return; } this.buffer.put((byte)b); }
@Override public final void write(byte[] source, int offset, int len) { // if there is enough space in current byte buffer, then use that instead // of always wrapping to avoid one additional allocation if (this.wrapBytes && this.buffer.remaining() < len) { this.writeWithByteArrayWrappedConditionally(source, offset, len); } else { super.write(source, offset, len); } }
public void testWriteByteBuffer() { HeapDataOutputStream out = new HeapDataOutputStream(32, Version.CURRENT); byte[] bytes = "1234567890qwertyuiopasdfghjklzxcvbnm,./;'".getBytes(); out.write(ByteBuffer.wrap(bytes, 0, 2)); out.write(ByteBuffer.wrap(bytes, 2, bytes.length - 2)); byte[] actual = out.toByteArray(); assertEquals(new String(bytes) , new String(actual)); }
/** * Write a byte buffer to this HeapDataOutputStream, * <p> * The contents of the buffer between the position and the limit * are copied to the output stream or the buffer kept as is (if wrapBytes * has been passed as true in constructor). */ @Override public final void write(ByteBuffer source) { if (this.wrapBytes) { this.writeWithByteBufferWrappedConditionally(source); } else { super.write(source); } }
@Override public void sendAsByteArray(DataOutput out) throws IOException { if (!isCompressed() && out instanceof HeapDataOutputStream) { ByteBuffer bb = createDirectByteBuffer(); if (bb != null) { HeapDataOutputStream hdos = (HeapDataOutputStream) out; InternalDataSerializer.writeArrayLength(bb.remaining(), hdos); hdos.write(bb); return; } } super.sendAsByteArray(out); }
private void writeRevokedMember(PersistentMemberPattern revoked) { try { HeapDataOutputStream hdos = new HeapDataOutputStream(32, Version.CURRENT); hdos.write(IFREC_REVOKE_DISK_STORE_ID); InternalDataSerializer.invokeToData(revoked, hdos); hdos.write(END_OF_RECORD_ID); writeIFRecord(hdos, false); // don't do stats for these small records } catch (IOException ex) { DiskAccessException dae = new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent); if (!this.compactInProgress) { this.parent.handleDiskAccessException(dae, true); } throw dae; } }
private void writeRevokedMember(PersistentMemberPattern revoked) { try { HeapDataOutputStream hdos = new HeapDataOutputStream(32, Version.CURRENT); hdos.write(IFREC_REVOKE_DISK_STORE_ID); InternalDataSerializer.invokeToData(revoked, hdos); hdos.write(END_OF_RECORD_ID); writeIFRecord(hdos, false); // don't do stats for these small records } catch (IOException ex) { DiskAccessException dae = new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent); if (!this.compactInProgress) { this.parent.handleDiskAccessException(dae); } throw dae; } }