public class CheckedBytes extends Object implements Bytes
| Constructor and Description |
|---|
CheckedBytes(Bytes bytes) |
| Modifier and Type | Method and Description |
|---|---|
int |
addAndGetInt(long offset,
int delta)
Atomically adds the given value to the current value.
|
double |
addAtomicDouble(long offset,
double delta) |
float |
addAtomicFloat(long offset,
float delta) |
int |
addAtomicInt(long offset,
int i) |
long |
addAtomicLong(long offset,
long delta) |
byte |
addByte(long offset,
byte b) |
double |
addDouble(long offset,
double d) |
float |
addFloat(long offset,
float f) |
int |
addInt(long offset,
int i) |
long |
addLong(long offset,
long i) |
long |
address() |
short |
addShort(long offset,
short s) |
int |
addUnsignedByte(long offset,
int i) |
long |
addUnsignedInt(long offset,
long i) |
int |
addUnsignedShort(long offset,
int i) |
void |
alignPositionAddr(int powerOf2)
Align the position address to a power of 2.
|
ByteStringAppender |
append(boolean b)
Writes "true" or "false".
|
ByteStringAppender |
append(char c) |
ByteStringAppender |
append(CharSequence str) |
ByteStringAppender |
append(CharSequence s,
int start,
int end) |
ByteStringAppender |
append(double d) |
ByteStringAppender |
append(double d,
int precision) |
ByteStringAppender |
append(Enum value) |
ByteStringAppender |
append(int num) |
<E> ByteStringAppender |
append(Iterable<E> list,
CharSequence separator) |
ByteStringAppender |
append(long num) |
ByteStringAppender |
append(long num,
int base) |
ByteStringAppender |
append(MutableDecimal md) |
ByteStringAppender |
appendDateMillis(long timeInMS) |
ByteStringAppender |
appendDateTimeMillis(long timeInMS) |
ByteStringAppender |
appendTimeMillis(long timeInMS) |
CharSequence |
asString()
Dump the contents of Bytes as a CharSequence
|
void |
asString(Appendable appendable)
Dump the contents of this Bytes as text in the Appendable.
|
int |
available() |
void |
busyLockInt(long offset)
Lock which uses 4 bytes.
|
void |
busyLockLong(long offset)
Lock across processes
|
ByteOrder |
byteOrder() |
Bytes |
bytes()
Create a bytes whose content is the whole bytes store.
|
Bytes |
bytes(long offset,
long length)
|
long |
capacity() |
char |
charAt(int index) |
void |
checkEndOfBuffer() |
Bytes |
clear()
Clears this buffer.
|
void |
clearThreadAssociation()
Needed if the buffer is created in one thread and used in another.
|
void |
close()
Finishes the excerpt entry if not finished()
|
boolean |
compare(long offset,
RandomDataInput input,
long inputOffset,
long len) |
boolean |
compareAndSwapDouble(long offset,
double expected,
double value)
Perform a compare and set operation.
|
boolean |
compareAndSwapInt(long offset,
int expected,
int x)
Perform a compare and set operation.
|
boolean |
compareAndSwapLong(long offset,
long expected,
long x)
Perform a compare and set operation.
|
File |
file() |
void |
finish()
Mark the end of the message if writing and check we are at the end of the message if reading.
|
Bytes |
flip()
Flips this buffer.
|
void |
flush()
Check the end of the stream has not overflowed.
|
void |
free() |
int |
getAndAdd(long offset,
int delta)
Atomically adds the given value to the current value.
|
InputStream |
inputStream() |
boolean |
isFinished() |
int |
length() |
long |
limit() |
Bytes |
limit(long limit) |
Bytes |
load()
Access every page to ensure those pages are in memory.
|
long |
nextSetBit(long fromIndex)
From a given bit index, find the next bit with is set.
|
ObjectSerializer |
objectSerializer() |
OutputStream |
outputStream() |
Boolean |
parseBoolean(StopCharTester tester)
Return true or false, or null if it could not be detected
as true or false.
|
MutableDecimal |
parseDecimal(MutableDecimal decimal) |
double |
parseDouble() |
<E extends Enum<E>> |
parseEnum(Class<E> eClass,
StopCharTester tester) |
long |
parseLong() |
long |
parseLong(int base) |
String |
parseUtf8(StopCharTester tester) |
void |
parseUtf8(StringBuilder builder,
StopCharTester tester)
Populate a StringBuilder with the UTF encoded text until the end.
|
long |
position() |
Bytes |
position(long position) |
int |
read()
Reads a byte of data.
|
int |
read(byte[] bytes)
Reads into an array of bytes.
|
int |
read(byte[] bytes,
int off,
int len)
Reads into an array of bytes.
|
void |
read(ByteBuffer bb)
Copy bytes into a ByteBuffer to the minimum of the length
remaining() in the ByteBuffer or the
Excerpt. |
void |
read(ByteBuffer bb,
int length)
Copy bytes into a ByteBuffer to the minimum of the length in the ByteBuffer or the
Excerpt.
|
boolean |
read8bitText(StringBuilder stringBuilder) |
boolean |
readBoolean()
Reads one input byte and returns
true if that byte is nonzero, false if that byte is
zero. |
boolean |
readBoolean(long offset)
Reads one input byte and returns
true if that byte is nonzero, false if that byte is
zero. |
byte |
readByte()
Reads and returns one input byte.
|
byte |
readByte(long offset)
Reads and returns one input byte.
|
char |
readChar()
Reads two input bytes and returns a
char value. |
char |
readChar(long offset)
Reads two input bytes and returns a
char value. |
double |
readCompactDouble()
Reads the first four bytes as readFloat().
|
int |
readCompactInt()
Reads two or six input bytes and returns an
int value. |
long |
readCompactLong()
Reads four or twelve input bytes and returns a
long value. |
short |
readCompactShort()
Reads one or three input bytes and returns a
short value. |
long |
readCompactUnsignedInt()
Reads two or six input bytes and returns an
int value. |
int |
readCompactUnsignedShort()
Reads one or three input bytes and returns a
short value. |
double |
readDouble()
Reads eight input bytes and returns a
double value. |
double |
readDouble(long offset)
Reads eight input bytes and returns a
double value. |
<E> E |
readEnum(Class<E> eClass)
Read a String with
readUTFΔ which is converted to an enumerable type. |
<E> E |
readEnum(long offset,
int maxSize,
Class<E> eClass) |
float |
readFloat()
Reads four input bytes and returns a
float value. |
float |
readFloat(long offset)
Reads four input bytes and returns a
float value. |
void |
readFully(byte[] bytes)
Reads some bytes from an input stream and stores them into the buffer array
b. |
void |
readFully(byte[] b,
int off,
int len)
Reads
len bytes from an input stream. |
void |
readFully(char[] data) |
void |
readFully(char[] data,
int off,
int len) |
void |
readFully(long offset,
byte[] bytes,
int off,
int len) |
long |
readIncompleteLong(long offset)
Same as readLong except the remaining() can be less than 8.
|
<T> T |
readInstance(Class<T> objClass,
T obj)
Read an instance of a class assuming objClass was provided when written.
|
int |
readInt()
Reads four input bytes and returns an
int value. |
int |
readInt(long offset)
Reads four input bytes and returns an
int value. |
int |
readInt24()
Reads three input bytes and returns a 24-bit
int value. |
int |
readInt24(long offset)
Reads three input bytes and returns a 24-bit
int value. |
long |
readInt48()
Reads six input bytes and returns a
long value. |
long |
readInt48(long offset)
Reads six input bytes and returns a
long value. |
String |
readLine()
Reads the next line of text from the input stream.
|
<E> void |
readList(Collection<E> list,
Class<E> eClass)
Read a stop bit encoded length and populates this Collection after zeroOut()ing it.
|
long |
readLong()
Reads eight input bytes and returns a
long value. |
long |
readLong(long offset)
Reads eight input bytes and returns a
long value. |
<K,V> Map<K,V> |
readMap(Map<K,V> map,
Class<K> kClass,
Class<V> vClass)
Read a stop bit encoded length and populates this Map after zeroOut()ing it.
|
void |
readMarshallable(Bytes in)
read an object from bytes
|
Object |
readObject()
Read and return an object.
|
<T> T |
readObject(Class<T> tClass)
Read and return an object.
|
void |
readObject(Object object,
int start,
int end)
Read the object from start to end bytes
|
short |
readShort()
Reads two input bytes and returns a
short value. |
short |
readShort(long offset)
Reads two input bytes and returns a
short value. |
long |
readStopBit()
Reads between one and ten bytes with are stop encoded with support for negative numbers
|
int |
readUnsignedByte()
Reads one input byte, zero-extends it to type
int, and returns the result, which is therefore in the
range 0 through 255. |
int |
readUnsignedByte(long offset)
Reads one input byte, zero-extends it to type
int, and returns the result, which is therefore in the
range 0 through 255. |
int |
readUnsignedByteOrThrow() |
long |
readUnsignedInt()
Reads four input bytes and returns an
int value. |
long |
readUnsignedInt(long offset)
Reads four input bytes and returns an
int value. |
int |
readUnsignedShort()
Reads two input bytes and returns an
int value in the range 0 through
65535. |
int |
readUnsignedShort(long offset)
Reads two input bytes and returns an
int value in the range 0 through
65535. |
String |
readUTF()
Reads in a string that has been encoded using a modified UTF-8 format.
|
String |
readUTFΔ()
The same as readUTF() except the length is stop bit encoded.
|
String |
readUTFΔ(long offset)
The same as readUTFΔ() except an offset is given.
|
boolean |
readUTFΔ(StringBuilder stringBuilder)
The same as readUTFΔ() except the chars are copied to a truncated StringBuilder.
|
double |
readVolatileDouble(long offset)
This is the same as readDouble() except a read barrier is performed first.
|
float |
readVolatileFloat(long offset)
This is the same as readFloat() except a read barrier is performed first.
|
int |
readVolatileInt()
This is the same as readInt() except a read barrier is performed first.
|
int |
readVolatileInt(long offset)
This is the same as readInt() except a read barrier is performed first.
|
long |
readVolatileLong()
This is the same readLong() except a dread barrier is performed first
|
long |
readVolatileLong(long offset)
This is the same readLong() except a dread barrier is performed first
|
int |
refCount() |
boolean |
release() |
long |
remaining() |
void |
reserve() |
void |
resetLockInt(long offset)
Lock which uses 4 bytes.
|
void |
resetLockLong(long offset)
Lock which uses 8 bytes.
|
boolean |
selfTerminating() |
void |
selfTerminating(boolean selfTerminating)
If set to true, the end of the Bytes will be the end of any consuming String, double or long.
|
long |
size() |
long |
skip(long n)
Skips n bytes of input.
|
int |
skipBytes(int n)
Makes an attempt to skip over
n bytes of data from the input stream, discarding the skipped bytes. |
boolean |
skipTo(StopCharTester tester)
Wind from this positionAddr to the end of the field
|
Bytes |
slice()
Creates a new bytes whose content is a shared subsequence of this bytes'
content.
|
Bytes |
slice(long offset,
long length)
Creates a new bytes whose content is a shared subsequence of this bytes'
content.
|
ByteBuffer |
sliceAsByteBuffer(ByteBuffer toReuse)
Returns a
ByteBuffer whose content is a shared subsequence of this bytes' content. |
boolean |
startsWith(RandomDataInput input) |
boolean |
stepBackAndSkipTo(StopCharTester tester)
Make sure we just read a stop character
|
CharSequence |
subSequence(int start,
int end) |
int |
threadIdForLockInt(long offset)
Lock which uses 4 bytes.
|
long |
threadIdForLockLong(long offset)
Lock which uses 8 bytes.
|
String |
toDebugString() |
String |
toDebugString(long limit) |
String |
toHexString(long limit) |
String |
toString() |
void |
toString(Appendable sb,
long start,
long position,
long end)
Write a portion of the Bytes to an Appendable for printing.
|
boolean |
tryLockInt(long offset)
Lock which uses 4 bytes.
|
boolean |
tryLockLong(long offset)
Lock across processes
|
boolean |
tryLockNanosInt(long offset,
long nanos)
Lock which uses 4 bytes.
|
boolean |
tryLockNanosLong(long offset,
long nanos)
Lock across processes
|
boolean |
tryRWReadLock(long offset,
long timeOutNS)
Uses the 64-bit long at the offset as a non-reentrant read/write lock.
|
boolean |
tryRWWriteLock(long offset,
long timeOutNS)
Uses the 64-bit long at the offset as a non-reentrant read/write lock.
|
void |
unlockInt(long offset)
Lock which uses 4 bytes.
|
void |
unlockLong(long offset)
Lock across processes
|
void |
unlockRWReadLock(long offset)
Uses the 64-bit long at the offset as a non-reentrant read/write lock.
|
void |
unlockRWWriteLock(long offset)
Uses the 64-bit long at the offset as a non-reentrant read/write lock.
|
void |
write(byte[] bytes)
Writes to the output stream all the bytes in array
bytes. |
void |
write(byte[] bytes,
int off,
int len)
Writes
len bytes from array bytes, in order, to the output stream. |
void |
write(Byteable byteable)
Copies the contents of a Byteable from the offset for maxSize bytes, moves the position of "this" RandomDataOutput by the maxSize
|
void |
write(ByteBuffer bb)
Copies the contents of a ByteBuffer from the position to the limit.
|
void |
write(char[] data) |
void |
write(char[] data,
int off,
int len) |
void |
write(int b)
Writes to the output stream the eight low-order bits of the argument
b. |
void |
write(long offset,
byte[] bytes)
Writes to the output stream all the bytes in array
bytes. |
void |
write(long offset,
byte[] bytes,
int off,
int len) |
void |
write(long offset,
Bytes bytes) |
void |
write(RandomDataInput bytes)
Copies the contents of a RandomDataInput from the position to the limit.
|
void |
write(RandomDataInput bytes,
long position,
long length)
Copy from one Bytes to another, moves the position of "this" RandomDataOutput by the length.
|
void |
write8bitText(CharSequence s) |
void |
writeBoolean(boolean v)
Writes a
boolean value to this output stream. |
void |
writeBoolean(long offset,
boolean v)
Writes a
boolean value to this output stream. |
void |
writeByte(int v)
Writes to the output stream the eight low- order bits of the argument
v. |
void |
writeByte(long offset,
int b)
Writes to the output stream the eight low-order bits of the argument
b. |
void |
writeBytes(String s)
Writes a string to the output stream.
|
void |
writeChar(int v)
Writes a
char value, which is comprised of two bytes, to the output stream. |
void |
writeChar(long offset,
int v)
Writes a
char value, which is comprised of two bytes, to the output stream. |
void |
writeChars(CharSequence cs)
Writes chars of the given
CharSequence to the bytes, without encoding. |
void |
writeChars(String s)
Writes every character in the string
s, to the output stream, in order, two bytes per character. |
void |
writeCompactDouble(double v)
Writes four or twelve bytes as follow;
|
void |
writeCompactInt(int v)
Writes two or six bytes as follows; Integer.MIN_VALUE => Short.MIN_VALUE, Integer.MAX_VALUE =>
Short.MAX_VALUE, Short.MIN_VALUE+2 to Short.MAX_VALUE-1 => writeShort(x), default =>
writeShort(Short.MIN_VALUE+1; writeInt(x)
|
void |
writeCompactLong(long v)
Writes four or twelve bytes as follows Long.MIN_VALUE => Integer.MIN_VALUE, Long.MAX_VALUE =>
Integer.MAX_VALUE, Integer.MIN_VALUE+2 to Integer.MAX_VALUE-1 => writeInt(x), default =>
writeInt(Integer.MIN_VALUE+1; writeLong(x)
|
void |
writeCompactShort(int v)
Writes one or three bytes as follows; Short.MIN_VALUE => Byte.MIN_VALUE, Short.MAX_VALUE => Byte.MAX_VALUE,
Short.MIN_VALUE+2 to Short.MAX_VALUE-1 => writeByte(x), default => writeByte(Byte.MIN_VALUE+1;
writeShort(x)
|
void |
writeCompactUnsignedInt(long v)
Writes two or six bytes as follows; 0 to (1 << 16) - 2 => writeInt(x), otherwise writeShort(-1);
writeInt(x)
|
void |
writeCompactUnsignedShort(int v)
Writes one or three bytes as follows; 0 to 254 => writeByte(x); otherwise writeByte(255); writeByteShort(x);
|
void |
writeDouble(double v)
Writes a
double value, which is comprised of eight bytes, to the output stream. |
void |
writeDouble(long offset,
double v)
Writes a
double value, which is comprised of eight bytes, to the output stream. |
<E> void |
writeEnum(E e)
Write the object in a form which can be uniquely recreated by readEnum.
|
void |
writeEnum(long offset,
int maxSize,
Object object) |
void |
writeFloat(float v)
Writes a
float value, which is comprised of four bytes, to the output stream. |
void |
writeFloat(long offset,
float v)
Writes a
float value, which is comprised of four bytes, to the output stream. |
<OBJ> void |
writeInstance(Class<OBJ> objClass,
OBJ obj)
Write an object with the assumption that the objClass will be provided when the class is read.
|
void |
writeInt(int v)
Writes an
int value, which is comprised of four bytes, to the output stream. |
void |
writeInt(long offset,
int v)
Writes an
int value, which is comprised of four bytes, to the output stream. |
void |
writeInt24(int v)
Writes an
int value, which is comprised of three bytes, to the output stream. |
void |
writeInt24(long offset,
int v)
Writes an
int value, which is comprised of three bytes, to the output stream. |
void |
writeInt48(long v)
Writes a
long value, which is comprised of eight bytes, to the output stream. |
void |
writeInt48(long offset,
long v)
Writes a
long value, which is comprised of eight bytes, to the output stream. |
<E> void |
writeList(Collection<E> list)
Write an ordered collection of "enumerable objects" (See writeEnum).
|
void |
writeLong(long v)
Writes a
long value, which is comprised of eight bytes, to the output stream. |
void |
writeLong(long offset,
long v)
Writes a
long value, which is comprised of eight bytes, to the output stream. |
<K,V> void |
writeMap(Map<K,V> map)
Write the keys and values of a Map of "enumerable objects" (See writeEnum).
|
void |
writeMarshallable(Bytes out)
write an object to bytes
|
void |
writeObject(Object obj)
Write an object as either an "enumerable object" or a Serializable/Externalizable object using Java
Serialization.
|
void |
writeObject(Object object,
int start,
int end)
Copy data from an Object from bytes start to end.
|
void |
writeOrderedDouble(long offset,
double v)
Same as writeDouble but include an ordered write barrier.
|
void |
writeOrderedFloat(long offset,
float v)
Same as writeFloat but include an ordered write barrier.
|
void |
writeOrderedInt(int v)
Same as writeInt but include an ordered write barrier.
|
void |
writeOrderedInt(long offset,
int v)
Same as writeInt but include an ordered write barrier.
|
void |
writeOrderedLong(long v)
Same as writeLong but include an ordered write barrier.
|
void |
writeOrderedLong(long offset,
long v)
Same as writeLong but include an ordered write barrier.
|
void |
writeShort(int v)
Writes two bytes to the output stream to represent the value of the argument.
|
void |
writeShort(long offset,
int v)
Writes two bytes to the output stream to represent the value of the argument.
|
void |
writeStopBit(long n)
Stop bit encoding numbers.
|
void |
writeUnsignedByte(int v)
Writes to the output stream the eight low- order bits of the argument
v. |
void |
writeUnsignedByte(long offset,
int v)
Writes to the output stream the eight low- order bits of the argument
v. |
void |
writeUnsignedInt(long v)
Writes an
int value, which is comprised of four bytes, to the output stream. |
void |
writeUnsignedInt(long offset,
long v)
Writes an
int value, which is comprised of four bytes, to the output stream. |
void |
writeUnsignedShort(int v)
Writes two bytes to the output stream to represent the value of the argument.
|
void |
writeUnsignedShort(long offset,
int v)
Writes two bytes to the output stream to represent the value of the argument.
|
void |
writeUTF(String str)
Writes two bytes of length information to the output stream, followed by the modified UTF-8 representation of every character in the string
s. |
void |
writeUTFΔ(CharSequence str)
Write the same encoding as
writeUTF with the following changes. |
void |
writeUTFΔ(long offset,
int maxSize,
CharSequence s)
Write the same encoding as
writeUTF with the following changes. |
Bytes |
zeroOut()
fill the Bytes with zeros, and clear the position.
|
Bytes |
zeroOut(long start,
long end)
fill the Bytes with zeros.
|
Bytes |
zeroOut(long start,
long end,
boolean ifNotZero)
fill the Bytes with zeros, and clear the position, avoiding touching pages unnecessarily
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitchars, codePointspublic CheckedBytes(Bytes bytes)
public void clearThreadAssociation()
BytesclearThreadAssociation in interface Bytespublic long size()
size in interface BytesStorepublic void free()
free in interface BytesStorepublic void reserve()
reserve in interface ReferenceCountedpublic boolean release()
release in interface ReferenceCountedpublic int refCount()
refCount in interface ReferenceCountedpublic void selfTerminating(boolean selfTerminating)
ByteStringParserselfTerminating in interface ByteStringParserselfTerminating - if true, the end of the Buffer is silent.public boolean selfTerminating()
selfTerminating in interface ByteStringParserpublic int readUnsignedByteOrThrow()
throws BufferUnderflowException
readUnsignedByteOrThrow in interface ByteStringParserBufferUnderflowException - if the end is reached and selfTerminating is false.public void write(long offset,
Bytes bytes)
write in interface RandomDataOutputpublic Boolean parseBoolean(@NotNull StopCharTester tester)
ByteStringParserfalse: f, false, n, no, 0
true: t, true, y, yes, 1
parseBoolean in interface ByteStringParsertester - to detect the end of the text.public void readFully(@NotNull
byte[] bytes)
RandomDataInputReads some bytes from an input stream and stores them into the buffer array b. The number of bytes
read is equal to the length of b.
This method blocks until one of the following conditions occurs:
b.length bytes of input data are available, in which case a normal return is made. EOFException is thrown.IOException other than EOFException is thrown.
If bytes is null, a NullPointerException is thrown. If bytes.length
is zero, then no bytes are read. Otherwise, the first byte read is stored into element bytes[0], the
next one into bytes[1], and so on. If an exception is thrown from this method, then it may be that some
but not all bytes of bytes have been updated with data from the input stream.
readFully in interface DataInputreadFully in interface RandomDataInputbytes - the buffer into which the data is read.public void readFully(@NotNull
char[] data)
readFully in interface RandomDataInputpublic int skipBytes(int n)
RandomDataInputn bytes of data from the input stream, discarding the skipped bytes.
However, it may skip over some smaller number of bytes, possibly zero. This may result from any of a number of
conditions; reaching end of file before n bytes have been skipped is only one possibility. This
method never throws an EOFException. The actual number of bytes skipped is returned.skipBytes in interface DataInputskipBytes in interface RandomDataInputn - the number of bytes to be skipped.public boolean readBoolean()
RandomDataInputtrue if that byte is nonzero, false if that byte is
zero. This method is suitable for reading the byte written by the writeBoolean method of interface
DataOutput.readBoolean in interface DataInputreadBoolean in interface RandomDataInputboolean value read.public boolean readBoolean(long offset)
RandomDataInputtrue if that byte is nonzero, false if that byte is
zero. This method is suitable for reading the byte written by the writeBoolean method of interface
RandomDataOutput.readBoolean in interface RandomDataInputoffset - to read byte translated into a booleanboolean value read.public int readUnsignedByte()
RandomDataInputint, and returns the result, which is therefore in the
range 0 through 255. This method is suitable for reading the byte written by the
writeByte method of interface DataOutput if the argument to writeByte was
intended to be a value in the range 0 through 255.readUnsignedByte in interface DataInputreadUnsignedByte in interface RandomDataInputpublic int readUnsignedByte(long offset)
RandomDataInputint, and returns the result, which is therefore in the
range 0 through 255. This method is suitable for reading the byte written by the
writeByte method of interface RandomDataOutput if the argument to
writeByte was intended to be a value in the range 0 through 255.readUnsignedByte in interface RandomDataInputoffset - of byte to readpublic int readUnsignedShort()
RandomDataInputint value in the range 0 through
65535. Let a be the first byte read and b be the second byte on big endian
machines, and the opposite on little endian machines. The value returned is:
(((a & 0xff) << 8) | (b & 0xff))
This method is suitable for reading the bytes written by the writeUnsignedShort method of interface
DataOutput if the argument to writeUnsignedShort was intended to be a value in the
range 0 through 65535.readUnsignedShort in interface DataInputreadUnsignedShort in interface RandomDataInputpublic int readUnsignedShort(long offset)
RandomDataInputint value in the range 0 through
65535. Let a be the first byte read and b be the second byte on big endian
machines, and the opposite on little endian machines. The value returned is:
(((a & 0xff) << 8) | (b & 0xff))
This method is suitable for reading the bytes written by the writeShort method of interface
RandomDataOutput if the argument to writeUnsignedShort was intended to be a value in
the range 0 through 65535.readUnsignedShort in interface RandomDataInputoffset - of short to read.@NotNull public String readLine()
RandomDataInputString. Note that because this method processes bytes, it does not support input of the full
Unicode character set.
If end of file is encountered before even one byte can be read, then null is returned. Otherwise,
each byte that is read is converted to type char by zero-extension. If the character
'\n' is encountered, it is discarded and reading ceases. If the character '\r' is
encountered, it is discarded and, if the following byte converts to the character '\n', then
that is discarded also; reading then ceases. If end of file is encountered before either of the characters
'\n' and '\r' is encountered, reading ceases. Once reading has ceased, a
String is returned that contains all the characters read and not discarded, taken in order. Note
that every character in this string will have a value less than \u0100, that is,
(char)256.
readLine in interface DataInputreadLine in interface RandomDataInputnull if the end of file is encountered
before a byte can be read.@Nullable public String readUTFΔ()
RandomDataInputnull values are also supportedreadUTFΔ in interface RandomDataInputnull if writeUTFΔ(null) was called@Nullable public String readUTFΔ(long offset) throws IllegalStateException
RandomDataInputreadUTFΔ in interface RandomDataInputoffset - to read fromnull if writeUTFΔ(null) was calledIllegalStateException - if the length to be read is out of range.public boolean readUTFΔ(@NotNull
StringBuilder stringBuilder)
RandomDataInputreadUTFΔ in interface RandomDataInputstringBuilder - to copy chars totrue if there was a String, or false if it was nullpublic boolean read8bitText(@NotNull
StringBuilder stringBuilder)
throws StreamCorruptedException
read8bitText in interface RandomDataInputStreamCorruptedException@NotNull public String parseUtf8(@NotNull StopCharTester tester)
parseUtf8 in interface ByteStringParserpublic void parseUtf8(@NotNull
StringBuilder builder,
@NotNull
StopCharTester tester)
ByteStringParserparseUtf8 in interface ByteStringParserbuilder - to zeroOut and append to.tester - to detect when to stop.public boolean stepBackAndSkipTo(@NotNull
StopCharTester tester)
ByteStringParserstepBackAndSkipTo in interface ByteStringParsertester - to stop atpublic boolean skipTo(@NotNull
StopCharTester tester)
ByteStringParserskipTo in interface ByteStringParsertester - to stop at@NotNull public String readUTF()
RandomDataInputreadUTF is that it reads a representation of a Unicode character string encoded in
modified UTF-8 format; this string of characters is then returned as a String.
First, two bytes are read and used to construct an unsigned 16-bit integer in exactly the manner of the
readUnsignedShort method . This integer value is called the UTF length and specifies the
number of additional bytes to be read. These bytes are then converted to characters by considering them in
groups. The length of each group is computed from the value of the first byte of the group. The byte following a
group, if any, is the first byte of the next group.
If the first byte of a group matches the bit pattern 0xxxxxxx (where x means "may be
0 or 1"), then the group consists of just that byte. The byte is zero-extended to form
a character.
If the first byte of a group matches the bit pattern 110xxxxx, then the group consists of that byte
a and a second byte b. If there is no byte b (because byte a
was the last of the bytes to be read), or if byte b does not match the bit pattern
10xxxxxx, then a UTFDataFormatException is thrown. Otherwise, the group is converted to
the character:
(char)(((a& 0x1F) << 6) | (b & 0x3F))
If the first byte of a group matches the bit pattern 1110xxxx, then the group consists of that byte
a and two more bytes b and c. If there is no byte c (because
byte a was one of the last two of the bytes to be read), or either byte b or byte
c does not match the bit pattern 10xxxxxx, then a UTFDataFormatException
is thrown. Otherwise, the group is converted to the character:
(char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F))
If the first byte of a group matches the pattern 1111xxxx or the pattern 10xxxxxx, then
a UTFDataFormatException is thrown.
If end of file is encountered at any time during this entire process, then an EOFException is
thrown.
After every group has been converted to a character by this process, the characters are gathered, in the same
order in which their corresponding groups were read from the input stream, to form a String, which
is returned.
The writeUTF method of interface DataOutput may be used to write data that is suitable
for reading by this method.
readUTF in interface DataInputreadUTF in interface RandomDataInputpublic short readCompactShort()
RandomDataInputshort value. Let a be the first byte read.
This mapped as follows; Byte.MIN_VALUE => Short.MIN_VALUE, Byte.MAX_VALUE => Short.MAX_VALUE, Byte.MIN_VALUE+2 to
Byte.MAX_VALUE-1 => same as short value, Byte.MIN_VALUE+1 => readShort().
This method is suitable for reading the bytes written by the writeCompactShort method of interface
RandomDataOutput.
readCompactShort in interface RandomDataInputpublic int readCompactUnsignedShort()
RandomDataInputshort value. Let a be the first byte read.
This mapped as follows; -1 => readUnsignedShort(), default => (a & 0xFF)
This method is suitable for reading the bytes written by the writeCompactUnsignedShort method of
interface RandomDataOutput.
readCompactUnsignedShort in interface RandomDataInputpublic int readInt24()
RandomDataInputint value. Let a-c be the first through
third bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
((((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8))) >> 8
This method is suitable for reading bytes written by the writeInt24 method of interface
RandomDataOutput.readInt24 in interface RandomDataInputint value read.public int readInt24(long offset)
RandomDataInputint value. Let a-c be the first through
third bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
((((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8))) >> 8
This method is suitable for reading bytes written by the writeInt24 method of interface
RandomDataOutput.readInt24 in interface RandomDataInputoffset - to read fromint value read.public long readUnsignedInt()
RandomDataInputint value. Let a-d be the first through fourth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
((((long) a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d &
0xff))
This method is suitable for reading bytes written by the writeUnsignedInt method of interface
RandomDataOutput.readUnsignedInt in interface RandomDataInputint value read.public long readUnsignedInt(long offset)
RandomDataInputint value. Let a-d be the first through fourth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
((((long) a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d &
0xff))
This method is suitable for reading bytes written by the writeUnsignedInt method of interface
RandomDataOutput.readUnsignedInt in interface RandomDataInputoffset - to read fromint value read.public int readCompactInt()
RandomDataInputint value. Let a be the first short read
with readShort(). This mapped as follows; Short.MIN_VALUE => Integer.MIN_VALUE, Short.MAX_VALUE =>
Integer.MAX_VALUE, Short.MIN_VALUE+2 to Short.MAX_VALUE-1 => same as short value, Short.MIN_VALUE+1 =>
readInt().
This method is suitable for reading the bytes written by the writeCompactInt method of interface
RandomDataOutput.
readCompactInt in interface RandomDataInputpublic long readCompactUnsignedInt()
RandomDataInputint value. Let a be the first short read
with readShort(). This mapped as follows; -1 => readUnsignedInt(), default => (a & 0xFFFF)
This method is suitable for reading the bytes written by the writeCompactUnsignedInt method of
interface RandomDataOutput.
readCompactUnsignedInt in interface RandomDataInputpublic long readInt48()
RandomDataInputlong value. Let a-f be the first through sixth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((long)(a & 0xff) << 56) |
((long)(b & 0xff) << 48) |
((long)(c & 0xff) << 40) |
((long)(d & 0xff) << 32) |
((long)(e & 0xff) << 24) |
((long)(f & 0xff) << 16)) >> 16
This method is suitable for reading bytes written by the writeInt48 method of interface
RandomDataOutput.
readInt48 in interface RandomDataInputlong value read.public long readInt48(long offset)
RandomDataInputlong value. Let a-f be the first through sixth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((long)(a & 0xff) << 56) |
((long)(b & 0xff) << 48) |
((long)(c & 0xff) << 40) |
((long)(d & 0xff) << 32) |
((long)(e & 0xff) << 24) |
((long)(f & 0xff) << 16)) >> 16
This method is suitable for reading bytes written by the writeInt48 method of interface
RandomDataOutput.
readInt48 in interface RandomDataInputoffset - of the long to readlong value read.public long readCompactLong()
RandomDataInputlong value. Let a be the first int read
with readInt(). This mapped as follows; Integer.MIN_VALUE => Long.MIN_VALUE, Integer.MAX_VALUE => Long.MAX_VALUE,
Integer.MIN_VALUE+2 to Integer.MAX_VALUE-1 => same as short value, Integer.MIN_VALUE+1 => readLong().
This method is suitable for reading the bytes written by the writeCompactLong method of interface
RandomDataOutput.
readCompactLong in interface RandomDataInputpublic long readStopBit()
RandomDataInput
long l = 0, b;
int count = 0;
while ((b = readByte()) < 0) {
l |= (b & 0x7FL) << count;
count += 7;
}
if (b == 0 && count > 0)
return ~l;
return l | (b << count);
readStopBit in interface RandomDataInputpublic double readCompactDouble()
RandomDataInputreadCompactDouble in interface RandomDataInputdouble value read.public void read(@NotNull
ByteBuffer bb)
RandomDataInputremaining() in the ByteBuffer or the
Excerpt.read in interface RandomDataInputbb - to copy intopublic void read(@NotNull
ByteBuffer bb,
int length)
RandomDataInputread in interface RandomDataInputbb - to copy intolength - number of bytes to copypublic void write(@NotNull
byte[] bytes)
RandomDataOutputbytes. If bytes is
null, a NullPointerException is thrown. If bytes.length is zero, then no
bytes are written. Otherwise, the byte bytes[0] is written first, then bytes[1], and so
on; the last byte written is bytes[bytes.length-1].write in interface DataOutputwrite in interface ObjectOutputwrite in interface RandomDataOutputbytes - the data.public void writeBoolean(boolean v)
RandomDataOutputboolean value to this output stream. If the argument v is true,
the value (byte)1 is written; if v is false, the value
(byte)0 is written. The byte written by this method may be read by the readBoolean
method of interface DataInput, which will then return a boolean equal to
v.writeBoolean in interface DataOutputwriteBoolean in interface RandomDataOutputv - the boolean to be written.public void writeBoolean(long offset,
boolean v)
RandomDataOutputboolean value to this output stream. If the argument v is true,
the value (byte)1 is written; if v is false, the value
(byte)0 is written. The byte written by this method may be read by the readBoolean
method of interface DataInput, which will then return a boolean equal to
v.writeBoolean in interface RandomDataOutputoffset - to write booleanv - the boolean to be written.public void writeBytes(@NotNull
String s)
RandomDataOutputs, taken in order, one byte
is written to the output stream. If s is null, a NullPointerException is
thrown. If s.length is zero, then no bytes are written. Otherwise, the character
s[0] is written first, then s[1], and so on; the last character written is
s[s.length-1]. For each character, one byte is written, the low-order byte, in exactly the manner of
the writeByte method . The high-order eight bits of each character in the string are ignored.
writeBytes in interface DataOutputwriteBytes in interface RandomDataOutputs - the string of bytes to be written. Cannot be null.public void writeChars(@NotNull
String s)
RandomDataOutputs, to the output stream, in order, two bytes per character. If
s is null, a NullPointerException is thrown. If s.length is
zero, then no characters are written. Otherwise, the character s[0] is written first, then
s[1], and so on; the last character written is s[s.length-1]. For each character, two
bytes are actually written, high-order byte first, in exactly the manner of the writeChar method.writeChars in interface DataOutputwriteChars in interface RandomDataOutputs - the string value to be written. Cannot be null.RandomDataOutput.writeChars(CharSequence)public void writeChars(@NotNull
CharSequence cs)
RandomDataOutputCharSequence to the bytes, without encoding.writeChars in interface RandomDataOutputcs - the CharSequence to be written. Cannot be null.RandomDataOutput.writeChars(String)public void writeUTF(@NotNull
String str)
RandomDataOutputs. If s is null, a NullPointerException is thrown. Each
character in the string s is converted to a group of one, two, or three bytes, depending on the
value of the character. If a character c is in the range \u0001 through
\u007f, it is represented by one byte:
(byte)c
If a character c is \u0000 or is in the range \u0080 through
\u07ff, then it is represented by two bytes, to be written
in the order shown:
(byte)(0xc0 | (0x1f & (c >> 6)))
(byte)(0x80 | (0x3f & c))
If a character
c is in the range \u0800 through uffff, then it is represented by
three bytes, to be written
in the order shown:
(byte)(0xe0 | (0x0f & (c >> 12)))
(byte)(0x80 | (0x3f & (c >> 6)))
(byte)(0x80 | (0x3f & c))
First,
the total number of bytes needed to represent all the characters of s is calculated. If this number
is larger than 65535, then a UTFDataFormatException is thrown. Otherwise, this length
is written to the output stream in exactly the manner of the writeShort method; after this, the
one-, two-, or three-byte representation of each character in the string s is written.
The bytes
written by this method may be read by the readUTF method of interface DataInput , which
will then return a String equal to s.
writeUTF in interface DataOutputwriteUTF in interface RandomDataOutputstr - the string value to be written. Cannot be nullpublic void writeUTFΔ(@Nullable
CharSequence str)
throws IllegalArgumentException
RandomDataOutputwriteUTF with the following changes. 1) The length is stop bit encoded
i.e. one byte longer for short strings, but is not limited in length. 2) The string can be null.writeUTFΔ in interface RandomDataOutputstr - the string value to be written. Can be null.IllegalArgumentException - if there is not enough space leftpublic void writeUTFΔ(long offset,
int maxSize,
@Nullable
CharSequence s)
throws IllegalStateException
RandomDataOutputwriteUTF with the following changes. 1) The length is stop bit encoded
i.e. one byte longer for short strings, but is not limited in length. 2) The string can be null.writeUTFΔ in interface RandomDataOutputoffset - to write tomaxSize - maximum number of bytes to uses - the string value to be written. Can be null.IllegalStateException - if the size is too large.public void write8bitText(@Nullable
CharSequence s)
write8bitText in interface RandomDataOutput@NotNull public ByteStringAppender append(@NotNull CharSequence str)
append in interface Appendableappend in interface ByteStringAppenderpublic void writeByte(int v)
RandomDataOutputv. The 24 high-order bits of
v are ignored. (This means that writeByte does exactly the same thing as
write for an integer argument.) The byte written by this method may be read by the
readByte method of interface DataInput, which will then return a byte
equal to (byte)v.writeByte in interface DataOutputwriteByte in interface RandomDataOutputv - the byte value to be written.public void writeUnsignedByte(int v)
RandomDataOutputv. The 24 high-order bits of
v are ignored. (This means that writeByte does exactly the same thing as
write for an integer argument.) The byte written by this method may be read by the
readUnsignedByte method of interface DataInput, which will then return a
byte equal to (byte)v.writeUnsignedByte in interface RandomDataOutputv - the byte value to be written.public void writeUnsignedByte(long offset,
int v)
RandomDataOutputv. The 24 high-order bits of
v are ignored. (This means that writeByte does exactly the same thing as
write for an integer argument.) The byte written by this method may be read by the
readUnsignedByte method of interface DataInput, which will then return a
byte equal to v & 0xFF.writeUnsignedByte in interface RandomDataOutputoffset - to write bytev - the unsigned byte value to be written.public void write(@NotNull
char[] data)
write in interface RandomDataOutputpublic void write(@NotNull
char[] data,
int off,
int len)
write in interface RandomDataOutputpublic void writeUnsignedShort(int v)
RandomDataOutput
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readUnsignedShort method of interface
RandomDataInput , which will then return a short equal to (short)v.
writeUnsignedShort in interface RandomDataOutputv - the unsigned short value to be written.public void writeUnsignedShort(long offset,
int v)
RandomDataOutput
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readShort method of interface
RandomDataInput , which will then return a short equal to (short)v.
writeUnsignedShort in interface RandomDataOutputoffset - to be written tov - the unsigned short value to be written.public void writeCompactShort(int v)
RandomDataOutputThe bytes written by this method may be read by the readCompactShort method of interface
RandomDataInput , which will then return a short equal to (short)v.
writeCompactShort in interface RandomDataOutputv - the short value to be written.public void writeCompactUnsignedShort(int v)
RandomDataOutputThe bytes written by this method may be read by the readCompactUnsignedShort method of interface
RandomDataInput , which will then return a short equal to v & 0xFFFF.
writeCompactUnsignedShort in interface RandomDataOutputv - the unsigned short value to be written.public void writeInt24(int v)
RandomDataOutputint value, which is comprised of three bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readInt24 method of interface
RandomDataInput , which will then return an int equal to v.
writeInt24 in interface RandomDataOutputv - the int value to be written.public void writeInt24(long offset,
int v)
RandomDataOutputint value, which is comprised of three bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readInt24 method of interface
RandomDataInput , which will then return an int equal to v.
writeInt24 in interface RandomDataOutputoffset - to be written tov - the int value to be written.public void writeUnsignedInt(long v)
RandomDataOutputint value, which is comprised of four bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readUnsignedInt method of interface
RandomDataInput , which will then return an long equal to v &
0xFFFFFFFF.
writeUnsignedInt in interface RandomDataOutputv - the int value to be written.public void writeUnsignedInt(long offset,
long v)
RandomDataOutputint value, which is comprised of four bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readUnsignedInt method of interface
RandomDataInput , which will then return an long equal to v &
0xFFFFFFFF.
writeUnsignedInt in interface RandomDataOutputoffset - to be written tov - the int value to be written.public void writeCompactInt(int v)
RandomDataOutputThe bytes written by this method may be read by the readCompactInt method of interface
RandomDataInput , which will then return a int equal to v.
writeCompactInt in interface RandomDataOutputv - the int value to be written.public void writeCompactUnsignedInt(long v)
RandomDataOutputThe bytes written by this method may be read by the readCompactUnsignedInt method of interface
RandomDataInput , which will then return a int equal to v &
0xFFFFFFFF.
writeCompactUnsignedInt in interface RandomDataOutputv - the short value to be written.public void writeInt48(long v)
RandomDataOutputlong value, which is comprised of eight bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 40))
(byte)(0xff & (v >> 32))
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readInt48 method of interface
RandomDataInput , which will then return a long equal to v & ((1L << 48)
- 1).
writeInt48 in interface RandomDataOutputv - the long value to be written.public void writeInt48(long offset,
long v)
RandomDataOutputlong value, which is comprised of eight bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 40))
(byte)(0xff & (v >> 32))
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readInt48 method of interface
RandomDataInput , which will then return a long equal to v & ((1L << 48)
- 1).
writeInt48 in interface RandomDataOutputoffset - to be written tov - the long value to be written.public void writeCompactLong(long v)
RandomDataOutputThe bytes written by this method may be read by the readCompactLong method of interface
RandomDataInput , which will then return a long equal to v.
writeCompactLong in interface RandomDataOutputv - the long value to be written.public void writeStopBit(long n)
RandomDataOutputwriteStopBit in interface RandomDataOutputn - the number to writepublic void writeCompactDouble(double v)
RandomDataOutputWrites four or twelve bytes as follow;
if ((float) d == d) {
writeFloat((float) d);
} else {
writeFloat(Float.NaN);
writeDouble(d);
}
The bytes written by this method may be read by the readCompactDouble method of interface
RandomDataInput , which will then return a double equal to v.writeCompactDouble in interface RandomDataOutputv - the double value to be written.public void write(@NotNull
ByteBuffer bb)
RandomDataOutput This method transfers the bytes remaining in the given source
buffer into this buffer. If there are more bytes remaining in the
source buffer than in this buffer, that is, if
src.remaining() > remaining(),
then no bytes are transferred and a BufferOverflowException is thrown.
Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.
In other words, an invocation of this method of the form dst.write(src) has exactly the same effect as the loop
while (src.hasRemaining())
dst.writeByte(src.get());
write in interface RandomDataOutputbb - to copy.@NotNull public ByteStringAppender append(@NotNull CharSequence s, int start, int end)
append in interface Appendableappend in interface ByteStringAppender@NotNull public ByteStringAppender append(@Nullable Enum value)
append in interface ByteStringAppender@NotNull public ByteStringAppender append(boolean b)
ByteStringAppenderappend in interface ByteStringAppenderb - to write.@NotNull public ByteStringAppender append(char c)
append in interface Appendableappend in interface ByteStringAppender@NotNull public ByteStringAppender append(int num)
append in interface ByteStringAppender@NotNull public ByteStringAppender append(long num)
append in interface ByteStringAppender@NotNull public ByteStringAppender append(long num, int base)
append in interface ByteStringAppender@NotNull public ByteStringAppender appendDateMillis(long timeInMS)
appendDateMillis in interface ByteStringAppender@NotNull public ByteStringAppender appendDateTimeMillis(long timeInMS)
appendDateTimeMillis in interface ByteStringAppender@NotNull public ByteStringAppender appendTimeMillis(long timeInMS)
appendTimeMillis in interface ByteStringAppender@NotNull public ByteStringAppender append(double d)
append in interface ByteStringAppenderpublic double parseDouble()
parseDouble in interface ByteStringParser@NotNull public <E> ByteStringAppender append(@NotNull Iterable<E> list, @NotNull CharSequence separator)
append in interface ByteStringAppender@NotNull public MutableDecimal parseDecimal(@NotNull MutableDecimal decimal)
parseDecimal in interface ByteStringParserpublic long parseLong()
parseLong in interface ByteStringParserpublic long parseLong(int base)
parseLong in interface ByteStringParserbase - to use.@NotNull public ByteStringAppender append(double d, int precision)
append in interface ByteStringAppender@NotNull public ByteStringAppender append(@NotNull MutableDecimal md)
append in interface ByteStringAppender@NotNull public InputStream inputStream()
inputStream in interface BytesCommon@NotNull public OutputStream outputStream()
outputStream in interface BytesCommon@NotNull public ObjectSerializer objectSerializer()
objectSerializer in interface BytesCommonobjectSerializer in interface BytesStorepublic <E> void writeEnum(@Nullable
E e)
RandomDataOutputvalueOf(String) method.writeEnum in interface RandomDataOutputE - element classe - to enumeratepublic <E> E readEnum(@NotNull
Class<E> eClass)
RandomDataInputreadUTFΔ which is converted to an enumerable type. i.e. where there is a one to
one mapping between an object and it's toString().
This is suitable to read an object written using writeEnum() in the RandomDataOutput
interface
readEnum in interface RandomDataInputE - the enum classeClass - to decode the String asnull with be return if null was written.public <E> E readEnum(long offset,
int maxSize,
Class<E> eClass)
readEnum in interface RandomDataInputpublic void writeEnum(long offset,
int maxSize,
Object object)
writeEnum in interface RandomDataOutputpublic <E extends Enum<E>> E parseEnum(@NotNull Class<E> eClass, @NotNull StopCharTester tester)
parseEnum in interface ByteStringParserpublic <E> void writeList(@NotNull
Collection<E> list)
RandomDataOutputwriteEnum All the elements must be of the same type.
This can be read by the readList method of RandomInputStream and the reader must know
the type of each element. You can send the class first by using writeEnum of the element class
writeList in interface RandomDataOutputE - the class of the list elementslist - to be writtenpublic <K,V> void writeMap(@NotNull
Map<K,V> map)
RandomDataOutputwriteEnum for each key and value. All the keys must be of the
same type. All values must be of the same type.writeMap in interface RandomDataOutputK - the class of the map keysV - the class of the map valuesmap - to write outpublic <E> void readList(@NotNull
Collection<E> list,
@NotNull
Class<E> eClass)
RandomDataInputThis is suitable to reading a list written using writeList() in the RandomDataOutput
interface
readList in interface RandomDataInputE - the list element classlist - to populateeClass - the list element class@NotNull public <K,V> Map<K,V> readMap(@NotNull Map<K,V> map, @NotNull Class<K> kClass, @NotNull Class<V> vClass)
RandomDataInputThis is suitable to reading a list written using writeMap() in the RandomDataOutput
interface
readMap in interface RandomDataInputK - the map key classV - the map value classmap - to populatekClass - the map key classvClass - the map value classpublic int available()
available in interface ObjectInputavailable in interface RandomDataInputpublic int read()
RandomDataInputread in interface ObjectInputread in interface RandomDataInputpublic int read(@NotNull
byte[] bytes)
RandomDataInputread in interface ObjectInputread in interface RandomDataInputbytes - the buffer into which the data is readpublic long skip(long n)
RandomDataInputskip in interface ObjectInputskip in interface RandomDataInputn - the number of bytes to be skippedpublic void close()
RandomDataInputclose in interface ObjectInputclose in interface ObjectOutputclose in interface AutoCloseableclose in interface RandomDataInputclose in interface RandomDataOutputpublic void finish()
throws IndexOutOfBoundsException
BytesCommonfinish in interface BytesCommonIndexOutOfBoundsException - if too much data was written.public boolean isFinished()
isFinished in interface BytesCommonpublic Bytes clear()
BytesCommonInvoke this method before using a sequence of channel-read or put operations to fill this buffer. For example:
buf.clear(); // Prepare buffer for reading
in.read(buf); // Read data
This method does not actually erase the data in the buffer, but it is named as if it did because it will most often be used in situations in which that might as well be the case.
clear in interface BytesCommonpublic Bytes flip()
BytesCommonAfter a sequence of channel-read or put operations, invoke this method to prepare for a sequence of channel-write or relative get operations. For example:
buf.put(magic); // Prepend header
in.read(buf); // Read data into rest of buffer
buf.flip(); // Flip buffer
out.write(buf); // Write header + data to channel
This method is often used in conjunction with the compact method when transferring data from
one place to another.
flip in interface BytesCommonpublic void flush()
RandomDataOutputflush in interface ObjectOutputflush in interface RandomDataOutput@Nullable public Object readObject()
RandomDataInputreadObject in interface ObjectInputreadObject in interface RandomDataInput@Nullable public <T> T readObject(Class<T> tClass) throws IllegalStateException
RandomDataInputreadObject in interface RandomDataInputT - the class of the object to readtClass - the class of the object to readIllegalStateException - the class of a serialized object cannot be found or any of the usual Input/Output
related exceptions occur.@Nullable
public <T> T readInstance(@NotNull
Class<T> objClass,
T obj)
RandomDataInputreadInstance in interface RandomDataInputT - the class of the object to readobjClass - class to writeobj - to reuse or null if a new object is neededpublic void writeObject(@Nullable
Object obj)
RandomDataOutputwriteObject in interface ObjectOutputwriteObject in interface RandomDataOutputobj - to writepublic <OBJ> void writeInstance(@NotNull
Class<OBJ> objClass,
@NotNull
OBJ obj)
RandomDataOutputwriteInstance in interface RandomDataOutputOBJ - the class of the object to writeobjClass - class to writeobj - to writepublic boolean tryLockInt(long offset)
RandomDataUpdatetryLockInt in interface RandomDataUpdateoffset - of the start of the 4-byte lockpublic boolean tryLockNanosInt(long offset,
long nanos)
RandomDataUpdatetryLockNanosInt in interface RandomDataUpdateoffset - of the start of the 4-byte locknanos - to try to lock forpublic void busyLockInt(long offset)
throws InterruptedException,
IllegalStateException
RandomDataUpdatebusyLockInt in interface RandomDataUpdateoffset - of the start of the 4-byte lockInterruptedException - if interruptedIllegalStateException - if the thread tries to lock it 255 nested time (without an unlock)public void unlockInt(long offset)
throws IllegalMonitorStateException
RandomDataUpdateunlockInt in interface RandomDataUpdateoffset - of the start of the 4-byte lockIllegalMonitorStateException - if this thread doesn't hold the lockpublic void resetLockInt(long offset)
RandomDataUpdateresetLockInt in interface RandomDataUpdateoffset - of the start of the 4-byte lockpublic int threadIdForLockInt(long offset)
RandomDataUpdatethreadIdForLockInt in interface RandomDataUpdateoffset - of the start of the 4-byte lockpublic boolean tryLockLong(long offset)
RandomDataUpdateLock which uses 8 bytes. It store the lower 32 bits of the Thread Id, 16 bits are the process id and the re-entrant count as 16 bit. This means if you create more than 16 million threads you can get a collision, and if you try to re-enter 65535 times you will get an ISE
tryLockLong in interface RandomDataUpdateoffset - of the start of the 8-byte lockpublic boolean tryLockNanosLong(long offset,
long nanos)
RandomDataUpdateLock which uses 8 bytes. It store the lower 32 bits of the Thread Id, 16 bits are the process id and the re-entrant count as 16 bit. This means if you create more than 16 million threads you can get a collision, and if you try to re-enter 65535 times you will get an ISE
tryLockNanosLong in interface RandomDataUpdateoffset - of the start of the 8-byte locknanos - to try to lock forpublic void busyLockLong(long offset)
throws InterruptedException,
IllegalStateException
RandomDataUpdateLock which uses 8 bytes. It store the lower 32 bits of the Thread Id, 16 bits are the process id and the re-entrant count as 16 bit. This means if you create more than 16 million threads you can get a collision, and if you try to re-enter 65535 times you will get an ISE
busyLockLong in interface RandomDataUpdateoffset - of the start of the 8-byte lockInterruptedException - if interruptedIllegalStateException - if the thread tries to lock it 65535 nested time (without an unlock)public void unlockLong(long offset)
throws IllegalMonitorStateException
RandomDataUpdateLock which uses 8 bytes. It store the lower 32 bits of the Thread Id, 16 bits are the process id and the re-entrant count as 16 bit. This means if you create more than 16 million threads you can get a collision, and if you try to re-enter 65535 times you will get an ISE
unlockLong in interface RandomDataUpdateoffset - of the start of the 8-byte lockIllegalMonitorStateException - if this thread doesn't hold the lockpublic void resetLockLong(long offset)
RandomDataUpdateresetLockLong in interface RandomDataUpdateoffset - of the start of the 8-byte lockpublic long threadIdForLockLong(long offset)
RandomDataUpdatethreadIdForLockLong in interface RandomDataUpdateoffset - of the start of the 8-byte lockpublic int getAndAdd(long offset,
int delta)
RandomDataOutputgetAndAdd in interface RandomDataOutputoffset - of the int value to use.delta - the value to addpublic int addAndGetInt(long offset,
int delta)
RandomDataOutputaddAndGetInt in interface RandomDataOutputoffset - of the int value to use.delta - the value to addpublic byte addByte(long offset,
byte b)
addByte in interface RandomDataUpdatepublic int addUnsignedByte(long offset,
int i)
addUnsignedByte in interface RandomDataUpdatepublic short addShort(long offset,
short s)
addShort in interface RandomDataUpdatepublic int addUnsignedShort(long offset,
int i)
addUnsignedShort in interface RandomDataUpdatepublic int addInt(long offset,
int i)
addInt in interface RandomDataUpdatepublic long addUnsignedInt(long offset,
long i)
addUnsignedInt in interface RandomDataUpdatepublic long addLong(long offset,
long i)
addLong in interface RandomDataUpdatepublic float addFloat(long offset,
float f)
addFloat in interface RandomDataUpdatepublic double addDouble(long offset,
double d)
addDouble in interface RandomDataUpdatepublic int addAtomicInt(long offset,
int i)
addAtomicInt in interface RandomDataUpdatepublic long addAtomicLong(long offset,
long delta)
addAtomicLong in interface RandomDataUpdatepublic float addAtomicFloat(long offset,
float delta)
addAtomicFloat in interface RandomDataUpdatepublic double addAtomicDouble(long offset,
double delta)
addAtomicDouble in interface RandomDataUpdatepublic float readVolatileFloat(long offset)
RandomDataInput Reads four input bytes and returns
a float value.
This method is suitable for reading bytes written by the writeOrderedFloat method of interface RandomDataOutput.
readVolatileFloat in interface RandomDataInputoffset - to read fromint value read.public double readVolatileDouble(long offset)
RandomDataInput Reads four input bytes and returns
a float value.
This method is suitable for reading bytes written by the writeOrderedFloat method of interface RandomDataOutput.
readVolatileDouble in interface RandomDataInputoffset - to read fromint value read.public void writeOrderedFloat(long offset,
float v)
RandomDataOutputThis is much faster than a volatile write which stalls the pipeline. The data is visible to other threads at the same time.
writeOrderedFloat in interface RandomDataOutputoffset - to write tov - value to writepublic void writeOrderedDouble(long offset,
double v)
RandomDataOutputThis is much faster than a volatile write which stalls the pipeline. The data is visible to other threads at the same time.
writeOrderedDouble in interface RandomDataOutputoffset - to write tov - value to writepublic int length()
length in interface CharSequencepublic char charAt(int index)
charAt in interface CharSequencepublic void readMarshallable(@NotNull
Bytes in)
throws IllegalStateException
BytesMarshallablereadMarshallable in interface BytesMarshallablein - to read fromIllegalStateException - if the object could not be read.public void writeMarshallable(@NotNull
Bytes out)
BytesMarshallablewriteMarshallable in interface BytesMarshallableout - to write topublic void write(RandomDataInput bytes)
RandomDataOutput This method transfers the bytes remaining in the given source
buffer into this buffer. If there are more bytes remaining in the
source buffer than in this buffer, that is, if
src.remaining() > remaining(),
then no bytes are transferred and a BufferOverflowException is thrown.
Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.
In other words, an invocation of this method of the form dst.write(src) has exactly the same effect as the loop
while (src.hasRemaining())
dst.writeByte(src.readByte());
write in interface RandomDataOutputbytes - to copypublic void write(Byteable byteable)
RandomDataOutputwrite in interface RandomDataOutputbyteable - to copypublic boolean startsWith(RandomDataInput input)
startsWith in interface RandomDataInput@NotNull public String toString()
toString in interface CharSequencetoString in class Object@NotNull public String toDebugString()
toDebugString in interface BytesCommon@NotNull public String toDebugString(long limit)
toDebugString in interface BytesCommonpublic String toHexString(long limit)
toHexString in interface BytesCommonpublic void toString(Appendable sb, long start, long position, long end)
BytesCommontoString in interface BytesCommonsb - to append tostart - first byteposition - where to place a cursor or 0 = none.end - last byte to append.public void asString(Appendable appendable)
ByteStringParserasString in interface ByteStringParserappendable - to append topublic CharSequence asString()
ByteStringParserasString in interface ByteStringParserpublic boolean compareAndSwapDouble(long offset,
double expected,
double value)
RandomDataOutputx provided the expected value
is set already. This operation is atomic.compareAndSwapDouble in interface RandomDataOutputoffset - to write to.expected - to expectvalue - to set if expected was foundpublic File file()
file in interface BytesStorepublic boolean tryRWReadLock(long offset,
long timeOutNS)
throws IllegalStateException,
InterruptedException
RandomDataUpdatetryRWReadLock in interface RandomDataUpdateoffset - of the long monitortimeOutNS - length of time to busy wait for the lock.IllegalStateException - if the monitor is in an illegal stateInterruptedExceptionpublic boolean tryRWWriteLock(long offset,
long timeOutNS)
throws IllegalStateException,
InterruptedException
RandomDataUpdatetryRWWriteLock in interface RandomDataUpdateoffset - of the long monitortimeOutNS - length of time to busy wait for the lock.IllegalStateException - if the monitor is in an illegal stateInterruptedExceptionpublic void unlockRWReadLock(long offset)
RandomDataUpdateunlockRWReadLock in interface RandomDataUpdateoffset - of the long monitorpublic void unlockRWWriteLock(long offset)
RandomDataUpdateunlockRWWriteLock in interface RandomDataUpdateoffset - of the long monitorpublic Bytes slice()
BytesCommonThe content of the new bytes will start at this bytes' current position. Changes to this bytes' content will be visible in the new bytes, and vice versa; the two bytes' position and limit values will be independent.
The new bytes' position will be zero, its capacity and its limit will be the number of bytes remaining in this bytes.
slice() is equivalent of slice(0, remaining()).
slice in interface BytesCommonBytesCommon.slice(long, long)public Bytes slice(long offset, long length)
BytesCommonThe content of the new bytes will start at this bytes' current
BytesCommon.position()+ offset. Changes to this bytes' content
will be visible in the new bytes, and vice versa; the two bytes'
position and limit values will be independent.
The new bytes' position will be zero, its capacity and its limit
will be equal to length.
offset can be negative (if current bytes' position is positive)
and length can run out of current bytes' limit, the restriction
is that new bytes' should be within this bytes' absolute bounds.
slice in interface BytesCommonoffset - relative offset of the new bytes from the current bytes'
positionlength - capacity of the new bytesBytesCommon.slice()public CharSequence subSequence(int start, int end)
subSequence in interface CharSequencepublic Bytes bytes()
BytesStorebytes(0, size()) call.bytes in interface BytesStoreBytesStore.bytes(long, long)public Bytes bytes(long offset, long length)
BytesStoreBytes object with start address of
address+ offset and capacity of length.
If this BytesStore is Bytes itself rather than natural
BytesStore object, this method will offset the new bytes from the
bytes' start, not from bytes' position like
BytesCommon.slice(long, long).
offset should be non-negative, length should be positive,
offset + length should be less or equal to size.
bytes in interface BytesStoreoffset - offset of the new bytes from the bytes store addresslength - capacity and limit of the new bytesBytesBytesStore.bytes()public long address()
address in interface BytesStorepublic Bytes zeroOut()
RandomDataOutputzeroOut in interface RandomDataOutputpublic Bytes zeroOut(long start, long end)
RandomDataOutputzeroOut in interface RandomDataOutputstart - first byte to zero outend - the first byte after the last to zero out (exclusive bound)public Bytes zeroOut(long start, long end, boolean ifNotZero)
RandomDataOutputzeroOut in interface RandomDataOutputstart - first byte to zero outend - the first byte after the last to zero out (exclusive bound)ifNotZero - only set to zero after checking the value is not zero.public int read(@NotNull
byte[] bytes,
int off,
int len)
RandomDataInputread in interface ObjectInputread in interface RandomDataInputbytes - the buffer into which the data is readoff - the start offset of the datalen - the maximum number of bytes readpublic byte readByte()
RandomDataInput-128 through
127, inclusive. This method is suitable for reading the byte written by the writeByte
method of interface DataOutput.readByte in interface DataInputreadByte in interface RandomDataInputpublic byte readByte(long offset)
RandomDataInput-128 through
127, inclusive. This method is suitable for reading the byte written by the writeByte
method of interface RandomDataOutput.readByte in interface RandomDataInputoffset - of byte to read.public void readFully(@NotNull
byte[] b,
int off,
int len)
RandomDataInputReads len bytes from an input stream.
This method blocks until one of the following conditions occurs:
len bytes of input data are available, in which case a normal return is made.EOFException is thrown.IOException other than EOFException is thrown.
If bytes is null, a NullPointerException is thrown. If off is
negative, or len is negative, or off+len is greater than the length of the array
bytes, then an IndexOutOfBoundsException is thrown. If len is zero, then no
bytes are read. Otherwise, the first byte read is stored into element bytes[off], the next one into
bytes[off+1], and so on. The number of bytes read is, at most, equal to len.
readFully in interface DataInputreadFully in interface RandomDataInputb - the buffer into which the data is read.off - an int specifying the offset into the data.len - an int specifying the number of bytes to read.public void readFully(long offset,
byte[] bytes,
int off,
int len)
readFully in interface RandomDataInputpublic void readFully(@NotNull
char[] data,
int off,
int len)
readFully in interface RandomDataInputpublic short readShort()
RandomDataInputshort value. Let a be the first byte read and
b be the second byte on big endian machines, and the opposite on little endian machines. The value
returned is:
(short)((a << 8) | (b & 0xff))
This method is suitable for reading the bytes written by the writeShort method of interface
DataOutput.readShort in interface DataInputreadShort in interface RandomDataInputpublic short readShort(long offset)
RandomDataInputshort value. Let a be the first byte read and
b be the second byte on big endian machines, and the opposite on little endian machines. The value
returned is:
(short)((a << 8) | (b & 0xff))
This method is suitable for reading the bytes written by the writeShort method of interface
RandomDataOutput.readShort in interface RandomDataInputoffset - of short to read.public char readChar()
RandomDataInputchar value. Let a be the first byte read and
b be the second byte on big endian machines, and the opposite on little endian machines. The value
returned is:
(char)((a << 8) | (b & 0xff))
This method is suitable for reading bytes written by the writeChar method of interface
DataOutput.readChar in interface DataInputreadChar in interface RandomDataInputchar value read.public char readChar(long offset)
RandomDataInputchar value. Let a be the first byte read and
b be the second byte on big endian machines, and the opposite on little endian machines. The value
returned is:
(char)((a << 8) | (b & 0xff))
This method is suitable for reading bytes written by the writeChar method of interface
RandomDataOutput.readChar in interface RandomDataInputoffset - of the char to read.char value read.public int readInt()
RandomDataInputint value. Let a-d be the first through fourth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the writeInt method of interface
DataOutput.readInt in interface DataInputreadInt in interface RandomDataInputint value read.public int readInt(long offset)
RandomDataInputint value. Let a-d be the first through fourth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the writeInt method of interface
RandomDataOutput.readInt in interface RandomDataInputoffset - to read fromint value read.public int readVolatileInt()
RandomDataInput Reads four input bytes and returns
an int value. Let a-d be the first through fourth bytes read on big endian machines,
and the opposite on little endian machines. The value returned is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the writeOrderedInt or
writeVolatileInt method of interface RandomDataOutput.readVolatileInt in interface RandomDataInputint value read.public int readVolatileInt(long offset)
RandomDataInput Reads four input bytes and returns
an int value. Let a-d be the first through fourth bytes read on big endian machines,
and the opposite on little endian machines. The value returned is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the writeOrderedInt or
writeVolatileInt method of interface RandomDataOutput.readVolatileInt in interface RandomDataInputoffset - to read fromint value read.public long readLong()
RandomDataInputlong value. Let a-h be the first through eighth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((long)(a & 0xff) << 56) |
((long)(b & 0xff) << 48) |
((long)(c & 0xff) << 40) |
((long)(d & 0xff) << 32) |
((long)(e & 0xff) << 24) |
((long)(f & 0xff) << 16) |
((long)(g & 0xff) << 8) |
((long)(h & 0xff)))
This method is suitable for reading bytes written by the writeLong method of interface
DataOutput.
readLong in interface DataInputreadLong in interface RandomDataInputlong value read.public long readIncompleteLong(long offset)
RandomDataInputreadIncompleteLong in interface RandomDataInputoffset - basepublic long readLong(long offset)
RandomDataInputlong value. Let a-h be the first through eighth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((long)(a & 0xff) << 56) |
((long)(b & 0xff) << 48) |
((long)(c & 0xff) << 40) |
((long)(d & 0xff) << 32) |
((long)(e & 0xff) << 24) |
((long)(f & 0xff) << 16) |
((long)(g & 0xff) << 8) |
((long)(h & 0xff)))
This method is suitable for reading bytes written by the writeLong method of interface
RandomDataOutput.
readLong in interface RandomDataInputoffset - of the long to readlong value read.public long readVolatileLong()
RandomDataInputReads eight input bytes and returns a long value. Let a-h be the first through eighth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((long)(a & 0xff) << 56) |
((long)(b & 0xff) << 48) |
((long)(c & 0xff) << 40) |
((long)(d & 0xff) << 32) |
((long)(e & 0xff) << 24) |
((long)(f & 0xff) << 16) |
((long)(g & 0xff) << 8) |
((long)(h & 0xff)))
This method is suitable for reading bytes written by the writeOrderedLong or
writeVolatileLong method of interface RandomDataOutput.
readVolatileLong in interface RandomDataInputlong value read.public long readVolatileLong(long offset)
RandomDataInputReads eight input bytes and returns a long value. Let a-h be the first through eighth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((long)(a & 0xff) << 56) |
((long)(b & 0xff) << 48) |
((long)(c & 0xff) << 40) |
((long)(d & 0xff) << 32) |
((long)(e & 0xff) << 24) |
((long)(f & 0xff) << 16) |
((long)(g & 0xff) << 8) |
((long)(h & 0xff)))
This method is suitable for reading bytes written by the writeOrderedLong or
writeVolatileLong method of interface RandomDataOutput.
readVolatileLong in interface RandomDataInputoffset - of the long to readlong value read.public float readFloat()
RandomDataInputfloat value. It does this by first constructing an
int value in exactly the manner of the readInt method, then converting this
int value to a float in exactly the manner of the method
Float.intBitsToFloat. This method is suitable for reading bytes written by the
writeFloat method of interface DataOutput.readFloat in interface DataInputreadFloat in interface RandomDataInputfloat value read.public float readFloat(long offset)
RandomDataInputfloat value. It does this by first constructing an
int value in exactly the manner of the readInt method, then converting this
int value to a float in exactly the manner of the method
Float.intBitsToFloat. This method is suitable for reading bytes written by the
writeFloat method of interface DataOutput.readFloat in interface RandomDataInputoffset - to read fromfloat value read.public double readDouble()
RandomDataInputdouble value. It does this by first constructing a
long value in exactly the manner of the readLong method, then converting this
long value to a double in exactly the manner of the method
Double.longBitsToDouble. This method is suitable for reading bytes written by the
writeDouble method of interface DataOutput.readDouble in interface DataInputreadDouble in interface RandomDataInputdouble value read.public double readDouble(long offset)
RandomDataInputdouble value. It does this by first constructing a
long value in exactly the manner of the readLong method, then converting this
long value to a double in exactly the manner of the method
Double.longBitsToDouble. This method is suitable for reading bytes written by the
writeDouble method of interface DataOutput.readDouble in interface RandomDataInputoffset - to read fromdouble value read.public void write(int b)
RandomDataOutputb. The 24 high-order bits of
b are ignored.write in interface DataOutputwrite in interface ObjectOutputwrite in interface RandomDataOutputb - the byte to be written.public void writeByte(long offset,
int b)
RandomDataOutputb. The 24 high-order bits of
b are ignored.writeByte in interface RandomDataOutputoffset - to write byteb - the byte to be written.public void write(long offset,
@NotNull
byte[] bytes)
RandomDataOutputbytes. If bytes is
null, a NullPointerException is thrown. If bytes.length is zero, then no
bytes are written. Otherwise, the byte bytes[0] is written first, then bytes[1], and so
on; the last byte written is bytes[bytes.length-1].write in interface RandomDataOutputoffset - to be writtenbytes - the data.public void write(byte[] bytes,
int off,
int len)
RandomDataOutputlen bytes from array bytes, in order, to the output stream. If
bytes is null, a NullPointerException is thrown. If off is
negative, or len is negative, or off+len is greater than the length of the array
bytes, then an IndexOutOfBoundsException is thrown. If len is zero, then
no bytes are written. Otherwise, the byte bytes[off] is written first, then
bytes[off+1], and so on; the last byte written is bytes[off+len-1].write in interface DataOutputwrite in interface ObjectOutputwrite in interface RandomDataOutputbytes - the data.off - the start offset in the data.len - the number of bytes to write.public void write(long offset,
byte[] bytes,
int off,
int len)
write in interface RandomDataOutputpublic void writeShort(int v)
RandomDataOutput
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readShort method of interface
DataInput , which will then return a short equal to (short)v.
writeShort in interface DataOutputwriteShort in interface RandomDataOutputv - the short value to be written.public void writeShort(long offset,
int v)
RandomDataOutput
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readShort method of interface
DataInput , which will then return a short equal to (short)v.
writeShort in interface RandomDataOutputoffset - to be written tov - the short value to be written.public void writeChar(int v)
RandomDataOutputchar value, which is comprised of two bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readChar method of interface
DataInput , which will then return a char equal to (char)v.
writeChar in interface DataOutputwriteChar in interface RandomDataOutputv - the char value to be written.public void writeChar(long offset,
int v)
RandomDataOutputchar value, which is comprised of two bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readChar method of interface
DataInput , which will then return a char equal to (char)v.
writeChar in interface RandomDataOutputoffset - to be written tov - the char value to be written.public void writeInt(int v)
RandomDataOutputint value, which is comprised of four bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readInt method of interface
DataInput , which will then return an int equal to v.
writeInt in interface DataOutputwriteInt in interface RandomDataOutputv - the int value to be written.public void writeInt(long offset,
int v)
RandomDataOutputint value, which is comprised of four bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readInt method of interface
DataInput , which will then return an int equal to v.
writeInt in interface RandomDataOutputoffset - to be written tov - the int value to be written.public void writeOrderedInt(int v)
RandomDataOutputThis is much faster than a volatile write which stalls the pipeline. The data is visible to other threads at the same time.
writeOrderedInt in interface RandomDataOutputv - value to writepublic void writeOrderedInt(long offset,
int v)
RandomDataOutputThis is much faster than writeVolatileInt as the volatile write stalls the pipeline. The data is
visible to other threads at the same time.
writeOrderedInt in interface RandomDataOutputoffset - to write tov - value to writepublic boolean compareAndSwapInt(long offset,
int expected,
int x)
RandomDataOutputx provided the expected value
is set already. This operation is atomic.compareAndSwapInt in interface RandomDataOutputoffset - to write to.expected - to expectx - to set if expected was foundpublic void writeLong(long v)
RandomDataOutputlong value, which is comprised of eight bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 56))
(byte)(0xff & (v >> 48))
(byte)(0xff & (v >> 40))
(byte)(0xff & (v >> 32))
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readLong method of interface
DataInput , which will then return a long equal to v.
writeLong in interface DataOutputwriteLong in interface RandomDataOutputv - the long value to be written.public void writeLong(long offset,
long v)
RandomDataOutputlong value, which is comprised of eight bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 56))
(byte)(0xff & (v >> 48))
(byte)(0xff & (v >> 40))
(byte)(0xff & (v >> 32))
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readLong method of interface
DataInput , which will then return a long equal to v.
writeLong in interface RandomDataOutputoffset - to be written tov - the long value to be written.public void writeOrderedLong(long v)
RandomDataOutputThis is much faster than a volatile write which stalls the pipeline. The data is visible to other threads at the same time.
writeOrderedLong in interface RandomDataOutputv - value to writepublic void writeOrderedLong(long offset,
long v)
RandomDataOutputThis is much faster than a volatile write which stalls the pipeline. The data is visible to other threads at the same time.
writeOrderedLong in interface RandomDataOutputoffset - to be written tov - value to writepublic boolean compareAndSwapLong(long offset,
long expected,
long x)
RandomDataOutputx provided the expected value
is set already. This operation is atomic.compareAndSwapLong in interface RandomDataOutputoffset - to write to.expected - to expectx - to set if expected was foundpublic void writeFloat(float v)
RandomDataOutputfloat value, which is comprised of four bytes, to the output stream. It does this as if it
first converts this float value to an int in exactly the manner of the
Float.floatToIntBits method and then writes the int value in exactly the manner of the
writeInt method. The bytes written by this method may be read by the readFloat method
of interface DataInput, which will then return a float equal to v.writeFloat in interface DataOutputwriteFloat in interface RandomDataOutputv - the float value to be written.public void writeFloat(long offset,
float v)
RandomDataOutputfloat value, which is comprised of four bytes, to the output stream. It does this as if it
first converts this float value to an int in exactly the manner of the
Float.floatToIntBits method and then writes the int value in exactly the manner of the
writeInt method. The bytes written by this method may be read by the readFloat method
of interface DataInput, which will then return a float equal to v.writeFloat in interface RandomDataOutputoffset - to write tov - the float value to be written.public void writeDouble(double v)
RandomDataOutputdouble value, which is comprised of eight bytes, to the output stream. It does this as if
it first converts this double value to a long in exactly the manner of the
Double.doubleToLongBits method and then writes the long value in exactly the manner of
the writeLong method. The bytes written by this method may be read by the readDouble
method of interface DataInput, which will then return a double equal to
v.writeDouble in interface DataOutputwriteDouble in interface RandomDataOutputv - the double value to be written.public void writeDouble(long offset,
double v)
RandomDataOutputdouble value, which is comprised of eight bytes, to the output stream. It does this as if
it first converts this double value to a long in exactly the manner of the
Double.doubleToLongBits method and then writes the long value in exactly the manner of
the writeLong method. The bytes written by this method may be read by the readDouble
method of interface DataInput, which will then return a double equal to
v.writeDouble in interface RandomDataOutputoffset - to write tov - the double value to be written.public void readObject(Object object, int start, int end)
RandomDataInputreadObject in interface RandomDataInputobject - to read intostart - byte inclusiveend - byte exclusivepublic void writeObject(Object object, int start, int end)
RandomDataOutputwriteObject in interface RandomDataOutputobject - to copy fromstart - first byte inclusiveend - last byte exclusive.public boolean compare(long offset,
RandomDataInput input,
long inputOffset,
long len)
compare in interface RandomDataInputpublic long position()
position in interface BytesCommonpublic Bytes position(long position)
position in interface BytesCommonposition - to skip topublic void write(RandomDataInput bytes, long position, long length)
RandomDataOutputwrite in interface RandomDataOutputbytes - to copyposition - to copy fromlength - to copypublic long capacity()
capacity in interface BytesCommonpublic long remaining()
remaining in interface BytesCommonpublic long limit()
limit in interface BytesCommonpublic Bytes limit(long limit)
limit in interface BytesCommonlimit - the new limit which must be >= capacity()@NotNull public ByteOrder byteOrder()
byteOrder in interface BytesCommonpublic void checkEndOfBuffer()
throws IndexOutOfBoundsException
checkEndOfBuffer in interface BytesCommonIndexOutOfBoundsException - if the bounds of the Bytes has been exceeded.public Bytes load()
BytesCommonload in interface BytesCommonpublic void alignPositionAddr(int powerOf2)
BytesCommonalignPositionAddr in interface BytesCommonpowerOf2 - power of 2 to align to.public ByteBuffer sliceAsByteBuffer(ByteBuffer toReuse)
BytesCommonByteBuffer whose content is a shared subsequence of this bytes' content.
The content of the returned ByteBuffer will start at this bytes' current
position. Changes to this bytes' content will be visible in the returned ByteBuffer,
and vice versa; this bytes' and the returned ByteBuffer's position and limit values
will be independent.
The returned ByteBuffer's position will be zero, its capacity and its limit
will be the number of bytes remaining in this bytes.
If this bytes object is able to reuse to given toReuse ByteBuffer, it will
be reused and returned back from this method, otherwise a new ByteBuffer instance
is created and returned.
sliceAsByteBuffer in interface BytesCommontoReuse - a ByteBuffer to reuseByteBuffer view of this BytesBytesCommon.slice(),
ByteBuffer.slice()public long nextSetBit(long fromIndex)
RandomDataInputnextSetBit in interface RandomDataInputfromIndex - first bit to scan.Copyright © 2019. All rights reserved.