public final class Buffer extends Object
The buffer can begin initially as a wrapped LuaValue
and only when concatenation actually occurs are the bytes first copied.
To convert back to a LuaValue again,
the function value() is used.
LuaValue,
LuaValue.buffer(),
LuaString| 构造器和说明 |
|---|
Buffer()
Create buffer with default capacity
|
Buffer(int initialCapacity)
Create buffer with specified initial capacity
|
Buffer(LuaValue value)
Create buffer with specified initial value
|
| 限定符和类型 | 方法和说明 |
|---|---|
Buffer |
append(byte b)
Append a single byte to the buffer.
|
Buffer |
append(char c) |
Buffer |
append(LuaString str)
Append a
LuaString to the buffer. |
Buffer |
append(LuaValue val)
Append a
LuaValue to the buffer. |
Buffer |
append(String str)
Append a Java String to the buffer.
|
Buffer |
concatTo(LuaNumber lhs)
|
Buffer |
concatTo(LuaString lhs)
Concatenate this buffer onto a
LuaString |
Buffer |
concatTo(LuaValue lhs)
Concatenate this buffer onto a
LuaValue |
void |
makeroom(int nbefore,
int nafter)
Ensure there is enough room before and after the bytes.
|
Buffer |
prepend(LuaString s)
Concatenate bytes from a
LuaString onto the front of this buffer |
Buffer |
setvalue(LuaValue value)
Set buffer contents as a
LuaValue |
String |
tojstring()
Convert the buffer to a Java String
|
LuaString |
tostring()
Convert the buffer to a
LuaString |
String |
toString()
Convert the buffer to a Java String
|
LuaValue |
value()
Get buffer contents as a
LuaValue |
public Buffer()
DEFAULT_CAPACITYpublic Buffer(int initialCapacity)
initialCapacity - the initial capacitypublic Buffer(LuaValue value)
value - the initial valuepublic LuaValue value()
LuaValueLuaValue, converting as necessarypublic Buffer setvalue(LuaValue value)
LuaValuevalue - value to setpublic final LuaString tostring()
LuaStringLuaStringpublic String tojstring()
public String toString()
public final Buffer append(byte b)
this to allow call chainingpublic final Buffer append(char c)
public final Buffer append(LuaValue val)
LuaValue to the buffer.this to allow call chainingpublic final Buffer append(LuaString str)
LuaString to the buffer.this to allow call chainingpublic final Buffer append(String str)
this to allow call chainingLuaString.encodeToUtf8(char[], int, byte[], int)public Buffer concatTo(LuaValue lhs)
LuaValuelhs - the left-hand-side value onto which we are concatenating thisBuffer for use in call chaining.public Buffer concatTo(LuaString lhs)
LuaStringlhs - the left-hand-side value onto which we are concatenating thisBuffer for use in call chaining.public Buffer concatTo(LuaNumber lhs)
LuaNumber
The LuaNumber will be converted to a string before concatenating.
lhs - the left-hand-side value onto which we are concatenating thisBuffer for use in call chaining.public Buffer prepend(LuaString s)
LuaString onto the front of this buffers - the left-hand-side value which we will concatenate onto the front of thisBuffer for use in call chaining.public final void makeroom(int nbefore,
int nafter)
nbefore - number of unused bytes which must precede the data after this completesnafter - number of unused bytes which must follow the data after this completesCopyright © 2020. All rights reserved.