public abstract class AbstractBytes extends Object implements Bytes
| Modifier and Type | Field and Description |
|---|---|
static long |
BUSY_LOCK_LIMIT |
static int |
INT_LOCK_MASK |
static int |
UNSIGNED_BYTE_MASK |
static long |
UNSIGNED_INT_MASK |
static int |
UNSIGNED_SHORT_MASK |
| 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) |
short |
addShort(long offset,
short s) |
int |
addUnsignedByte(long offset,
int i) |
long |
addUnsignedInt(long offset,
long i) |
int |
addUnsignedShort(long offset,
int i) |
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) |
<E> ByteStringAppender |
append(List<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) |
int |
available() |
void |
busyLockInt(long offset)
Lock which uses 4 bytes.
|
void |
busyLockLong(long offset)
Lock across processes
Lock which uses 8 bytes.
|
BytesMarshallerFactory |
bytesMarshallerFactory() |
char |
charAt(int index) |
void |
close()
Finishes the excerpt entry if not finished()
|
Thread |
currentThread() |
void |
finish()
Mark the end of the message if writing and check we are at the end of the message if reading.
|
void |
flush()
Check the end of the stream has not overflowed.
|
int |
getAndAdd(long offset,
int delta)
Atomically adds the given value to the current value.
|
InputStream |
inputStream() |
boolean |
isFinished() |
int |
length() |
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 |
parseUTF(StopCharTester tester) |
void |
parseUTF(StringBuilder builder,
StopCharTester tester)
Populate a StringBuilder with the UTF encoded text until the end.
|
int |
read()
Reads a byte of data.
|
int |
read(byte[] bytes)
Reads into an array of bytes.
|
abstract 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. |
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. |
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. |
<E> E |
readEnum(Class<E> eClass)
Read a String with
readUTFΔ which is converted to an enumerable type. |
void |
readFully(byte[] bytes)
Reads some bytes from an input stream and stores them into the buffer array
b. |
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 clear()ing it.
|
<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 clear()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.
|
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. |
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 and maximum length 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.
|
void |
reset()
Start again, unfinished, position() == 0
|
void |
setCurrentThread() |
int |
shortThreadId() |
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
|
boolean |
stepBackAndSkipTo(StopCharTester tester)
Make sure we just read a stop character
|
CharSequence |
subSequence(int start,
int end) |
boolean |
tryLockInt(long offset)
Lock which uses 4 bytes.
|
boolean |
tryLockLong(long offset)
Lock across processes
Lock which uses 8 bytes.
|
boolean |
tryLockNanosInt(long offset,
long nanos)
Lock which uses 4 bytes.
|
boolean |
tryLockNanosLong(long offset,
long nanos)
Lock across processes
Lock which uses 8 bytes.
|
long |
uniqueTid() |
void |
unlockInt(long offset)
Lock which uses 4 bytes.
|
void |
unlockLong(long offset)
Lock across processes
Lock which uses 8 bytes.
|
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(ByteBuffer bb)
Copies the contents of a ByteBuffer from the potision ot the limit.
|
void |
write(BytesCommon bytes,
long position,
long length)
Copy from one Bytes to another, moves the position by length
|
void |
write(long offset,
byte[] bytes)
Writes to the output stream all the bytes in array
bytes. |
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 |
writeBytes(String s)
Writes a string to the output stream.
|
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)
The bytes written by this method may be read by the
readCompactInt method of interface
RandomDataInput , which will then return a int equal to v. |
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)
The bytes written by this method may be read by the
readCompactLong method of interface
RandomDataInput , which will then return a long equal to v. |
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)
The 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. |
void |
writeCompactUnsignedInt(long v)
Writes two or six bytes as follows; 0 to (1 << 16) - 2 => writeInt(x), otherwise writeShort(-1);
writeInt(x)
The 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. |
void |
writeCompactUnsignedShort(int v)
Writes one or three bytes as follows; 0 to 254 => writeByte(x); otherwise writeByte(255); writeByteShort(x);
The 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. |
<E> void |
writeEnum(E e)
Write the object in a form which can be uniquely recreated by readEnum.
|
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).
|
<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 |
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 |
writeStartToPosition(Bytes bb)
Deprecated.
|
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. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadByte, readByte, readChar, readChar, readDouble, readDouble, readFloat, readFloat, readFully, readInt, readInt, readLong, readLong, readObject, readShort, readShort, readVolatileInt, readVolatileInt, readVolatileLong, readVolatileLongcompareAndSwapInt, compareAndSwapLong, write, writeByte, writeChar, writeChar, writeDouble, writeDouble, writeFloat, writeFloat, writeInt, writeInt, writeLong, writeLong, writeObject, writeOrderedInt, writeOrderedInt, writeOrderedLong, writeOrderedLong, writeShort, writeShortbyteOrder, capacity, checkEndOfBuffer, position, position, remainingtoStringpublic static final long BUSY_LOCK_LIMIT
public static final int INT_LOCK_MASK
public static final int UNSIGNED_BYTE_MASK
public static final int UNSIGNED_SHORT_MASK
public static final long UNSIGNED_INT_MASK
public Boolean parseBoolean(@NotNull StopCharTester tester)
ByteStringParserparseBoolean in interface ByteStringParsertester - to detect the end of the text.public void readFully(@NotNull
byte[] bytes)
RandomDataInputb. 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. b is null, a NullPointerException is thrown. If b.length
is zero, then no bytes are read. Otherwise, the first byte read is stored into element b[0], the
next one into b[1], and so on. If an exception is thrown from this method, then it may be that some
but not all bytes of b 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 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 RandomDataInputtrue if there was a String, or false if it was null@NotNull public String parseUTF(@NotNull StopCharTester tester)
parseUTF in interface ByteStringParserpublic void parseUTF(@NotNull
StringBuilder builder,
@NotNull
StopCharTester tester)
ByteStringParserparseUTF in interface ByteStringParserbuilder - to clear 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 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.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)
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.public 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.@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(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 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)
RandomDataOutputreadCompactShort 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)
RandomDataOutputreadCompactUnsignedShort 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)
RandomDataOutputreadCompactInt 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)
RandomDataOutputreadCompactUnsignedInt 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)
RandomDataOutputreadCompactLong 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 RandomDataOutputpublic void writeCompactDouble(double v)
RandomDataOutput
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)
RandomDataOutputwrite in interface RandomDataOutputbb - to copy.@Deprecated public void writeStartToPosition(@NotNull Bytes bb)
RandomDataOutputwriteStartToPosition in interface RandomDataOutputbb - to copy from@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 <E> ByteStringAppender append(@NotNull List<E> list, @NotNull CharSequence separator)
@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 BytesMarshallerFactory bytesMarshallerFactory()
bytesMarshallerFactory in interface BytesCommonpublic <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
interfacereadEnum in interface RandomDataInputeClass - to decode the String asnull with be return if null was written.public <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 classwriteList in interface RandomDataOutputlist - 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 RandomDataOutputmap - to write outpublic <E> void readList(@NotNull
Collection<E> list,
@NotNull
Class<E> eClass)
RandomDataInputwriteList() in the RandomDataOutput
interfacereadList in interface RandomDataInputlist - to populate@NotNull public <K,V> Map<K,V> readMap(@NotNull Map<K,V> map, @NotNull Class<K> kClass, @NotNull Class<V> vClass)
RandomDataInputwriteMap() in the RandomDataOutput
interfacereadMap in interface RandomDataInputmap - to populatepublic 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 abstract 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 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 void reset()
BytesCommonreset 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 RandomDataInputIllegalStateException - the class of a serialized object cannot be found or any of the usual Input/Output
related exceptions occur.public void writeObject(@Nullable
Object obj)
RandomDataOutputwriteObject in interface ObjectOutputwriteObject in interface RandomDataOutputobj - 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 int shortThreadId()
public void setCurrentThread()
public Thread currentThread()
public boolean tryLockLong(long offset)
RandomDataUpdatetryLockLong in interface RandomDataUpdateoffset - of the start of the 8-byte lockpublic long uniqueTid()
public boolean tryLockNanosLong(long offset,
long nanos)
RandomDataUpdatetryLockNanosLong in interface RandomDataUpdateoffset - of the start of the 8-byte locknanos - to try to lock forpublic void busyLockLong(long offset)
throws InterruptedException,
IllegalStateException
RandomDataUpdatebusyLockLong 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
RandomDataUpdateunlockLong in interface RandomDataUpdateoffset - of the start of the 8-byte lockIllegalMonitorStateException - if this thread doesn't hold the 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.
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.
writeOrderedFloat method of interface RandomDataOutput.readVolatileDouble in interface RandomDataInputoffset - to read fromint value read.public void writeOrderedFloat(long offset,
float v)
RandomDataOutputwriteOrderedFloat in interface RandomDataOutputv - value to writepublic void writeOrderedDouble(long offset,
double v)
RandomDataOutputwriteOrderedDouble in interface RandomDataOutputv - value to writepublic int length()
length in interface CharSequencepublic char charAt(int index)
charAt in interface CharSequencepublic CharSequence subSequence(int start, int end)
subSequence 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(BytesCommon bytes, long position, long length)
BytesCommonwrite in interface BytesCommonbytes - to copyposition - to copy fromlength - to copyCopyright © 2014. All Rights Reserved.