public class LuaString extends LuaValue
LuaValue for representing lua strings.
Because lua string values are more nearly sequences of bytes than
sequences of characters or unicode code points, the LuaString
implementation holds the string value in an internal byte array.
LuaString values are not considered mutable once constructed,
so multiple LuaString values can chare a single byte array.
Currently LuaStrings are pooled via a centrally managed weak table.
To ensure that as many string values as possible take advantage of this,
Constructors are not exposed directly. As with number, booleans, and nil,
instance construction should be via LuaValue.valueOf(byte[]) or similar API.
Because of this pooling, users of LuaString must not directly alter the bytes in a LuaString, or undefined behavior will result.
When Java Strings are used to initialize LuaString data, the UTF8 encoding is assumed.
The functions
lengthAsUtf8(char[]),
encodeToUtf8(char[], int, byte[], int), and
decodeAsUtf8(byte[], int, int)
are used to convert back and forth between UTF8 byte arrays and character arrays.
| 限定符和类型 | 字段和说明 |
|---|---|
byte[] |
m_bytes
The bytes for the string.
|
int |
m_length
The number of bytes that comprise this string
|
int |
m_offset
The offset into the byte array, 0 means start at the first byte
|
static LuaValue |
s_metatable
The singleton instance for string metatables that forwards to the string functions.
|
ADD, BAND, BNOT, BOR, BXOR, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, IDIV, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, POW, SHL, SHR, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, uservalue, ZERO| 限定符和类型 | 方法和说明 |
|---|---|
LuaValue |
add(double rhs)
|
LuaValue |
add(int rhs) |
LuaValue |
add(LuaValue rhs)
Add: Perform numeric add operation with another value
including metatag processing.
|
int |
charAt(int index) |
double |
checkdouble()
|
int |
checkint()
|
LuaInteger |
checkinteger()
|
String |
checkjstring()
Convert this value to a Java String.
|
long |
checklong()
|
LuaNumber |
checknumber()
|
LuaNumber |
checknumber(String msg)
|
LuaString |
checkstring()
Check that this is a lua string, or throw
LuaError if it is not. |
Buffer |
concat(Buffer rhs)
Concatenate a
Buffer onto this value and return the result
using rules of lua string concatenation including metatag processing. |
LuaValue |
concat(LuaValue rhs)
Concatenate another value onto this value and return the result
using rules of lua string concatenation including metatag processing.
|
LuaValue |
concatTo(LuaNumber lhs)
Reverse-concatenation: concatenate this value onto another value
known to be a
LuaNumber
and return the result using rules of lua string concatenation including
metatag processing. |
LuaValue |
concatTo(LuaString lhs)
Reverse-concatenation: concatenate this value onto another value
known to be a
LuaString
and return the result using rules of lua string concatenation including
metatag processing. |
void |
copyInto(int strOffset,
byte[] bytes,
int arrayOffset,
int len)
Copy the bytes of the string into the given byte array.
|
static String |
decodeAsUtf8(byte[] bytes,
int offset,
int length)
Convert to Java String interpreting as utf8 characters.
|
LuaValue |
div(double rhs)
Divide: Perform numeric divide operation by another value
of double type without metatag processing
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
For metatag processing LuaValue.div(LuaValue) must be used |
LuaValue |
div(int rhs) |
LuaValue |
div(LuaValue rhs)
Divide: Perform numeric divide operation by another value
of unknown type,
including metatag processing.
|
LuaValue |
divInto(double lhs)
|
static int |
encodeToUtf8(char[] chars,
int nchars,
byte[] bytes,
int off)
Encode the given Java string as UTF-8 bytes, writing the result to bytes
starting at offset.
|
boolean |
eq_b(LuaValue val)
Equals: Perform equality comparison with another value
including metatag processing using
LuaValue.EQ,
and return java boolean |
LuaValue |
eq(LuaValue val)
Equals: Perform equality comparison with another value
including metatag processing using
LuaValue.EQ. |
static boolean |
equals(byte[] a,
int i,
byte[] b,
int j,
int n) |
static boolean |
equals(LuaString a,
int i,
LuaString b,
int j,
int n) |
boolean |
equals(Object o) |
LuaValue |
getmetatable()
Get the metatable for this
LuaValue
For LuaTable and LuaUserdata instances,
the metatable returned is this instance metatable. |
boolean |
gt_b(double rhs)
Greater than: Perform numeric or string comparison with another value
of unknown type, including metatag processing,
and returning java boolean.
|
boolean |
gt_b(int rhs) |
boolean |
gt_b(LuaValue rhs)
Greater than: Perform numeric or string comparison with another value
of unknown type, including metatag processing,
and returning java boolean.
|
LuaValue |
gt(LuaValue rhs)
Greater than: Perform numeric or string comparison with another value
of unknown type,
including metatag processing, and returning
LuaValue. |
boolean |
gteq_b(double rhs)
Greater than or equals: Perform numeric comparison with another value
of double type,
including metatag processing,
and returning java boolean.
|
boolean |
gteq_b(int rhs) |
boolean |
gteq_b(LuaValue rhs)
Greater than or equals: Perform numeric or string comparison with another value
of unknown type, including metatag processing,
and returning java boolean.
|
LuaValue |
gteq(LuaValue rhs)
Greater than or equals: Perform numeric or string comparison with another value
of unknown type,
including metatag processing, and returning
LuaValue. |
int |
hashCode() |
static int |
hashCode(byte[] bytes,
int offset,
int length)
Compute the hash code of a sequence of bytes within a byte array using
lua's rules for string hashes.
|
int |
indexOf(byte b,
int start)
Find the index of a byte starting at a point in this string
|
int |
indexOf(LuaString s,
int start)
Find the index of a string starting at a point in this string
|
int |
indexOfAny(LuaString accept)
Java version of strpbrk - find index of any byte that in an accept string.
|
boolean |
isint()
Check if
this is a number and is representable by java int
without rounding or truncation |
boolean |
islong()
Check if
this is a number and is representable by java long
without rounding or truncation |
boolean |
isnumber()
Check if
this is a number |
boolean |
isstring()
Check if
this is a string |
boolean |
isValidUtf8()
Check that a byte sequence is valid UTF-8
|
int |
lastIndexOf(LuaString s)
Find the last index of a string in this string
|
LuaValue |
len()
Length operator: return lua length of object
(#this) including metatag processing as java int |
int |
length()
Length operator: return lua length of object
(#this) including metatag processing as java int |
int |
lengthAsUtf8() |
static int |
lengthAsUtf8(char[] chars)
Count the number of bytes required to encode the string as UTF-8.
|
boolean |
lt_b(double rhs)
Less than: Perform numeric or string comparison with another value
of unknown type, including metatag processing,
and returning java boolean.
|
boolean |
lt_b(int rhs) |
boolean |
lt_b(LuaValue rhs)
Less than: Perform numeric or string comparison with another value
of unknown type, including metatag processing,
and returning java boolean.
|
LuaValue |
lt(LuaValue rhs)
Less than: Perform numeric or string comparison with another value
of unknown type,
including metatag processing, and returning
LuaValue. |
boolean |
lteq_b(double rhs)
Less than or equals: Perform numeric comparison with another value
of double type,
including metatag processing,
and returning java boolean.
|
boolean |
lteq_b(int rhs) |
boolean |
lteq_b(LuaValue rhs)
Less than or equals: Perform numeric or string comparison with another value
of unknown type, including metatag processing,
and returning java boolean.
|
LuaValue |
lteq(LuaValue rhs)
Less than or equals: Perform numeric or string comparison with another value
of unknown type,
including metatag processing, and returning
LuaValue. |
int |
luaByte(int index) |
LuaValue |
mod(double rhs)
Modulo: Perform numeric modulo operation with another value
of double type without metatag processing
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
For metatag processing LuaValue.mod(LuaValue) must be used |
LuaValue |
mod(int rhs) |
LuaValue |
mod(LuaValue rhs)
Modulo: Perform numeric modulo operation with another value
of unknown type,
including metatag processing.
|
LuaValue |
modFrom(double lhs)
|
LuaValue |
mul(double rhs)
|
LuaValue |
mul(int rhs) |
LuaValue |
mul(LuaValue rhs)
Multiply: Perform numeric multiply operation with another value
of unknown type,
including metatag processing.
|
LuaValue |
neg()
Unary minus: return negative value
(-this) as defined by lua unary minus operator |
double |
optdouble(double defval)
Check that optional argument is a number or string convertible to number and return as double
|
int |
optint(int defval)
Check that optional argument is a number or string convertible to number and return as int
|
LuaInteger |
optinteger(LuaInteger defval)
Check that optional argument is a number or string convertible to number and return as
LuaInteger |
String |
optjstring(String defval)
Check that optional argument is a string or number and return as Java String
|
long |
optlong(long defval)
Check that optional argument is a number or string convertible to number and return as long
|
LuaNumber |
optnumber(LuaNumber defval)
Check that optional argument is a number or string convertible to number and return as
LuaNumber |
LuaString |
optstring(LuaString defval)
Check that optional argument is a string or number and return as
LuaString |
LuaValue |
pow(double rhs)
|
LuaValue |
pow(int rhs) |
LuaValue |
pow(LuaValue rhs)
Raise to power: Raise this value to a power
including metatag processing.
|
LuaValue |
powWith(double lhs)
|
LuaValue |
powWith(int lhs) |
void |
printToStream(PrintStream ps)
Print the bytes of the LuaString to a PrintStream as if it were
an ASCII string, quoting and escaping control characters.
|
boolean |
raweq(LuaString s)
Equals: Perform direct equality comparison with a
LuaString value
without metatag processing. |
boolean |
raweq(LuaValue val)
Equals: Perform direct equality comparison with another value
without metatag processing.
|
int |
rawlen()
Get raw length of table or string without metatag processing.
|
double |
scannumber()
Convert to a number in base 10, or base 16 if the string starts with '0x',
or return Double.NaN if it cannot be converted to a number.
|
double |
scannumber(int base)
Convert to a number in a base, or return Double.NaN if not a number.
|
int |
strcmp(LuaString rhs)
Perform string comparison with another value
known to be a
LuaString
using string comparison based on byte values. |
int |
strcmp(LuaValue lhs)
Perform string comparison with another value
of any type
using string comparison based on byte values.
|
LuaString |
strvalue()
|
LuaValue |
sub(double rhs)
|
LuaValue |
sub(int rhs) |
LuaValue |
sub(LuaValue rhs)
Subtract: Perform numeric subtract operation with another value
of unknown type,
including metatag processing.
|
LuaValue |
subFrom(double lhs)
|
LuaString |
substring(int beginIndex,
int endIndex)
Take a substring using Java zero-based indexes for begin and end or range.
|
byte |
tobyte()
Convert to byte if numeric, or 0 if not.
|
char |
tochar()
Convert to char if numeric, or 0 if not.
|
char[] |
toCharArray() |
static char[] |
toCharAsUtf8(byte[] bytes,
int offset,
int length) |
double |
todouble()
Convert to double if numeric, or 0 if not.
|
float |
tofloat()
Convert to float if numeric, or 0 if not.
|
InputStream |
toInputStream()
Convert value to an input stream.
|
int |
toint()
Convert to int if numeric, or 0 if not.
|
String |
tojstring()
Convert to human readable String for any type.
|
long |
tolong()
Convert to long if numeric, or 0 if not.
|
LuaValue |
tonumber()
convert to a number using baee 10 or base 16 if it starts with '0x',
or NIL if it can't be converted
|
LuaValue |
tonumber(int base)
convert to a number using a supplied base, or NIL if it can't be converted
|
short |
toshort()
Convert to short if numeric, or 0 if not.
|
LuaValue |
tostring()
Conditionally convert to lua string without throwing errors.
|
int |
type()
Get the enumeration value for the type of this value.
|
String |
typename()
Get the String name of the type of this value.
|
static LuaString |
valueOf(byte[] bytes)
Construct a
LuaString for all the bytes in a byte array. |
static LuaString |
valueOf(byte[] bytes,
int off,
int len)
Construct a
LuaString for a portion of a byte array. |
static LuaString |
valueOf(char[] bytes)
Construct a
LuaString using the supplied characters as byte values. |
static LuaString |
valueOf(char[] bytes,
int off,
int len)
Construct a
LuaString using the supplied characters as byte values. |
static LuaString |
valueOf(String string)
Get a
LuaString instance whose bytes match
the supplied Java String using the UTF8 encoding. |
static LuaString |
valueUsing(byte[] bytes)
Construct a
LuaString for all the bytes in a byte array, possibly using
the supplied array as the backing store. |
static LuaString |
valueUsing(byte[] bytes,
int off,
int len)
Construct a
LuaString around, possibly using the the supplied
byte array as the backing store. |
void |
write(DataOutputStream writer,
int i,
int len) |
add, and, arg, arg1, argerror, argerror, aritherror, aritherror, arithmt, arithmtwith, assert_, band, band, bnot, bor, bor, buffer, bxor, bxor, call, call, call, call, call, callmt, checkboolean, checkclosure, checkfunction, checkglobals, checkmetatag, checknotnil, checktable, checkthread, checkuserdata, checkuserdata, compareerror, compareerror, comparemt, concatmt, concatTo, div, eqmtcall, error, get, get, get, getfenv, gettable, getuservalue, gt_b, gt, gt, gteq_b, gteq, gteq, idiv, idiv, illegal, inext, initupvalue1, invoke, invoke, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isfunction, isinttype, isnil, istable, isthread, isuserdata, isuserdata, isvalidkey, jcall, jget, jset, lenerror, listOf, listOf, load, lt_b, lt, lt, lteq_b, lteq, lteq, metatableOf, metatag, method, method, method, method, method, method, mod, mul, narg, neq_b, neq, next, not, onInvoke, optboolean, optclosure, optfunction, opttable, optthread, optuserdata, optuserdata, optvalue, or, pow, powWith, presize, raweq, raweq, raweq, rawget, rawget, rawget, rawset, rawset, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, set, set, setfenv, setmetatable, settable, setuservalue, shl, shl, shr, shr, strongvalue, sub, subargs, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, toboolean, toString, touserdata, touserdata, typerror, unimplemented, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOfargcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, dealias, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, typepublic static LuaValue s_metatable
public final byte[] m_bytes
public final int m_offset
public final int m_length
public char[] toCharArray()
public static LuaString valueOf(String string)
LuaString instance whose bytes match
the supplied Java String using the UTF8 encoding.string - Java String containing characters to encode as UTF8LuaString with UTF8 bytes corresponding to the supplied Stringpublic static LuaString valueOf(byte[] bytes, int off, int len)
LuaString for a portion of a byte array.
The array is first be used as the backing for this object, so clients must not change contents. If the supplied value for 'len' is more than half the length of the container, the supplied byte array will be used as the backing, otherwise the bytes will be copied to a new byte array, and cache lookup may be performed.
bytes - byte bufferoff - offset into the byte bufferlen - length of the byte bufferLuaString wrapping the byte bufferpublic static LuaString valueUsing(byte[] bytes, int off, int len)
LuaString around, possibly using the the supplied
byte array as the backing store.
The caller must ensure that the array is not mutated after the call. However, if the string is short enough the short-string cache is checked for a match which may be used instead of the supplied byte array.
bytes - byte bufferLuaString wrapping the byte buffer, or an equivalent string.public static LuaString valueOf(char[] bytes)
LuaString using the supplied characters as byte values.
Only the low-order 8-bits of each character are used, the remainder is ignored.
This is most useful for constructing byte sequences that do not conform to UTF8.
bytes - array of char, whose values are truncated at 8-bits each and put into a byte array.LuaString wrapping a copy of the byte bufferpublic static LuaString valueOf(char[] bytes, int off, int len)
LuaString using the supplied characters as byte values.
Only the low-order 8-bits of each character are used, the remainder is ignored.
This is most useful for constructing byte sequences that do not conform to UTF8.
bytes - array of char, whose values are truncated at 8-bits each and put into a byte array.LuaString wrapping a copy of the byte bufferpublic static LuaString valueOf(byte[] bytes)
LuaString for all the bytes in a byte array.
The LuaString returned will either be a new LuaString containing a copy of the bytes array, or be an existing LuaString used already having the same value.
bytes - byte bufferLuaString wrapping the byte bufferpublic static LuaString valueUsing(byte[] bytes)
LuaString for all the bytes in a byte array, possibly using
the supplied array as the backing store.
The LuaString returned will either be a new LuaString containing the byte array, or be an existing LuaString used already having the same value.
The caller must not mutate the contents of the byte array after this call, as it may be used elsewhere due to recent short string caching.
bytes - byte bufferLuaString wrapping the byte bufferpublic boolean isstring()
LuaValuethis is a stringisstring 在类中 LuaValuestring,
meaning derives from LuaString or LuaNumber,
otherwise falseLuaValue.tostring(),
LuaValue.checkstring(),
LuaValue.optstring(LuaString),
LuaValue.TSTRINGpublic LuaValue getmetatable()
LuaValueLuaValue
For LuaTable and LuaUserdata instances,
the metatable returned is this instance metatable.
For all other types, the class metatable value will be returned.
getmetatable 在类中 LuaValueLuaBoolean.s_metatable,
LuaNumber.s_metatable,
LuaNil.s_metatable,
LuaFunction.s_metatable,
LuaThread.s_metatablepublic int type()
LuaValuetype 在类中 LuaValueLuaValue.TNIL,
LuaValue.TBOOLEAN,
LuaValue.TNUMBER,
LuaValue.TSTRING,
LuaValue.TTABLE,
LuaValue.TFUNCTION,
LuaValue.TUSERDATA,
LuaValue.TTHREADLuaValue.typename()public String typename()
LuaValuetypename 在类中 LuaValueLuaValue.TYPE_NAMES
corresponding to the type of this value:
"nil", "boolean", "number", "string",
"table", "function", "userdata", "thread"LuaValue.type()public String tojstring()
LuaValuetojstring 在类中 LuaValueLuaValue.tostring(),
LuaValue.optjstring(String),
LuaValue.checkjstring(),
LuaValue.isstring(),
LuaValue.TSTRINGpublic int lengthAsUtf8()
public LuaValue neg()
LuaValue(-this) as defined by lua unary minus operatorneg 在类中 LuaValueLuaBoolean if boolean or nil,
numeric inverse as LuaNumber if numeric,
or metatag processing result if LuaValue.UNM metatag is definedpublic LuaValue add(LuaValue rhs)
LuaValue
Each operand must derive from LuaNumber
or derive from LuaString and be convertible to a number
add 在类中 LuaValuerhs - The right-hand-side value to perform the add with(this + rhs) if both are numeric,
or LuaValue if metatag processing occursLuaValue.arithmt(LuaValue, LuaValue)public LuaValue add(double rhs)
LuaValue
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
add 在类中 LuaValuerhs - The right-hand-side value to perform the add with(this + rhs) if this is numericLuaValue.add(LuaValue)public LuaValue add(int rhs)
public LuaValue sub(LuaValue rhs)
LuaValue
Each operand must derive from LuaNumber
or derive from LuaString and be convertible to a number
sub 在类中 LuaValuerhs - The right-hand-side value to perform the subtract with(this - rhs) if both are numeric,
or LuaValue if metatag processing occursLuaValue.arithmt(LuaValue, LuaValue)public LuaValue sub(double rhs)
LuaValue
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
sub 在类中 LuaValuerhs - The right-hand-side value to perform the subtract with(this - rhs) if this is numericLuaValue.sub(LuaValue)public LuaValue sub(int rhs)
public LuaValue subFrom(double lhs)
LuaValue
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
subFrom 在类中 LuaValuelhs - The left-hand-side value from which to perform the subtraction(lhs - this) if this is numericLuaValue.sub(LuaValue),
LuaValue.sub(double),
#sub(int)public LuaValue mul(LuaValue rhs)
LuaValue
Each operand must derive from LuaNumber
or derive from LuaString and be convertible to a number
mul 在类中 LuaValuerhs - The right-hand-side value to perform the multiply with(this * rhs) if both are numeric,
or LuaValue if metatag processing occursLuaValue.arithmt(LuaValue, LuaValue)public LuaValue mul(double rhs)
LuaValue
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
mul 在类中 LuaValuerhs - The right-hand-side value to perform the multiply with(this * rhs) if this is numericLuaValue.mul(LuaValue)public LuaValue mul(int rhs)
public LuaValue pow(LuaValue rhs)
LuaValue
Each operand must derive from LuaNumber
or derive from LuaString and be convertible to a number
pow 在类中 LuaValuerhs - The power to raise this value to(this ^ rhs) if both are numeric,
or LuaValue if metatag processing occursLuaValue.arithmt(LuaValue, LuaValue)public LuaValue pow(double rhs)
LuaValue
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
pow 在类中 LuaValuerhs - The power to raise this value to(this ^ rhs) if this is numericLuaValue.pow(LuaValue)public LuaValue pow(int rhs)
public LuaValue powWith(double lhs)
LuaValue
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
powWith 在类中 LuaValuelhs - The left-hand-side value which will be raised to this power(lhs ^ this) if this is numericLuaValue.pow(LuaValue),
LuaValue.pow(double),
#pow(int)public LuaValue powWith(int lhs)
public LuaValue div(LuaValue rhs)
LuaValue
Each operand must derive from LuaNumber
or derive from LuaString and be convertible to a number
div 在类中 LuaValuerhs - The right-hand-side value to perform the divulo with(this / rhs) if both are numeric,
or LuaValue if metatag processing occursLuaValue.arithmt(LuaValue, LuaValue)public LuaValue div(double rhs)
LuaValue
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
For metatag processing LuaValue.div(LuaValue) must be used
div 在类中 LuaValuerhs - The right-hand-side value to perform the divulo with(this / rhs) if this is numericLuaValue.div(LuaValue)public LuaValue div(int rhs)
public LuaValue divInto(double lhs)
LuaValue
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
divInto 在类中 LuaValuelhs - The left-hand-side value which will be divided by this(lhs / this) if this is numericLuaValue.div(LuaValue),
LuaValue.div(double),
#div(int)public LuaValue mod(LuaValue rhs)
LuaValue
Each operand must derive from LuaNumber
or derive from LuaString and be convertible to a number
mod 在类中 LuaValuerhs - The right-hand-side value to perform the modulo with(this % rhs) if both are numeric,
or LuaValue if metatag processing occursLuaValue.arithmt(LuaValue, LuaValue)public LuaValue mod(double rhs)
LuaValue
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
For metatag processing LuaValue.mod(LuaValue) must be used
mod 在类中 LuaValuerhs - The right-hand-side value to perform the modulo with(this % rhs) if this is numericLuaValue.mod(LuaValue)public LuaValue mod(int rhs)
public LuaValue modFrom(double lhs)
LuaValue
this must derive from LuaNumber
or derive from LuaString and be convertible to a number
modFrom 在类中 LuaValuelhs - The left-hand-side value which will be modulo'ed by this(lhs % this) if this is numericLuaValue.mod(LuaValue),
LuaValue.mod(double),
#mod(int)public LuaValue lt(LuaValue rhs)
LuaValueLuaValue.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber.
lt 在类中 LuaValuerhs - The right-hand-side value to perform the comparison withLuaValue.TRUE if (this < rhs), LuaValue.FALSE if not,
or LuaValue if metatag processing occursLuaValue.gteq_b(LuaValue),
LuaValue.comparemt(LuaValue, LuaValue)public boolean lt_b(LuaValue rhs)
LuaValue
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber.
lt_b 在类中 LuaValuerhs - The right-hand-side value to perform the comparison with(this < rhs), false if not,
and boolean interpreation of result if metatag processing occurs.LuaValue.gteq(LuaValue),
LuaValue.comparemt(LuaValue, LuaValue)public boolean lt_b(int rhs)
public boolean lt_b(double rhs)
LuaValue
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber.
lt_b 在类中 LuaValuerhs - The right-hand-side value to perform the comparison with(this < rhs), false if not,
and boolean interpreation of result if metatag processing occurs.LuaValue.gteq(LuaValue),
LuaValue.comparemt(LuaValue, LuaValue)public LuaValue lteq(LuaValue rhs)
LuaValueLuaValue.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber.
lteq 在类中 LuaValuerhs - The right-hand-side value to perform the comparison withLuaValue.TRUE if (this <= rhs), LuaValue.FALSE if not,
or LuaValue if metatag processing occursLuaValue.gteq_b(LuaValue),
LuaValue.comparemt(LuaValue, LuaValue)public boolean lteq_b(LuaValue rhs)
LuaValue
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber.
lteq_b 在类中 LuaValuerhs - The right-hand-side value to perform the comparison with(this <= rhs), false if not,
and boolean interpreation of result if metatag processing occurs.LuaValue.gteq(LuaValue),
LuaValue.comparemt(LuaValue, LuaValue)public boolean lteq_b(int rhs)
public boolean lteq_b(double rhs)
LuaValue
To be comparable, this must derive from LuaNumber.
lteq_b 在类中 LuaValuerhs - The right-hand-side value to perform the comparison with(this <= rhs), false if not,
and boolean interpreation of result if metatag processing occurs.LuaValue.gteq(double),
LuaValue.comparemt(LuaValue, LuaValue)public LuaValue gt(LuaValue rhs)
LuaValueLuaValue.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber.
gt 在类中 LuaValuerhs - The right-hand-side value to perform the comparison withLuaValue.TRUE if (this > rhs), LuaValue.FALSE if not,
or LuaValue if metatag processing occursLuaValue.gteq_b(LuaValue),
LuaValue.comparemt(LuaValue, LuaValue)public boolean gt_b(LuaValue rhs)
LuaValue
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber.
gt_b 在类中 LuaValuerhs - The right-hand-side value to perform the comparison with(this > rhs), false if not,
and boolean interpreation of result if metatag processing occurs.LuaValue.gteq(LuaValue),
LuaValue.comparemt(LuaValue, LuaValue)public boolean gt_b(int rhs)
public boolean gt_b(double rhs)
LuaValue
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber.
gt_b 在类中 LuaValuerhs - The right-hand-side value to perform the comparison with(this > rhs), false if not,
and boolean interpreation of result if metatag processing occurs.LuaValue.gteq(LuaValue),
LuaValue.comparemt(LuaValue, LuaValue)public LuaValue gteq(LuaValue rhs)
LuaValueLuaValue.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber.
gteq 在类中 LuaValuerhs - The right-hand-side value to perform the comparison withLuaValue.TRUE if (this >= rhs), LuaValue.FALSE if not,
or LuaValue if metatag processing occursLuaValue.gteq_b(LuaValue),
LuaValue.comparemt(LuaValue, LuaValue)public boolean gteq_b(LuaValue rhs)
LuaValue
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber.
gteq_b 在类中 LuaValuerhs - The right-hand-side value to perform the comparison with(this >= rhs), false if not,
and boolean interpreation of result if metatag processing occurs.LuaValue.gteq(LuaValue),
LuaValue.comparemt(LuaValue, LuaValue)public boolean gteq_b(int rhs)
public boolean gteq_b(double rhs)
LuaValue
To be comparable, this must derive from LuaNumber.
gteq_b 在类中 LuaValuerhs - The right-hand-side value to perform the comparison with(this >= rhs), false if not,
and boolean interpreation of result if metatag processing occurs.LuaValue.gteq(double),
LuaValue.comparemt(LuaValue, LuaValue)public LuaValue concatTo(LuaNumber lhs)
LuaValueLuaNumber
and return the result using rules of lua string concatenation including
metatag processing.
Only strings and numbers as represented can be concatenated, meaning
each operand must derive from LuaString or LuaNumber.
concatTo 在类中 LuaValuelhs - The left-hand-side value onto which this will be concatenatedLuaValue resulting from concatenation of (lhs .. this)LuaValue.concat(LuaValue)public LuaValue concatTo(LuaString lhs)
LuaValueLuaString
and return the result using rules of lua string concatenation including
metatag processing.
Only strings and numbers as represented can be concatenated, meaning
each operand must derive from LuaString or LuaNumber.
concatTo 在类中 LuaValuelhs - The left-hand-side value onto which this will be concatenatedLuaValue resulting from concatenation of (lhs .. this)LuaValue.concat(LuaValue)public int strcmp(LuaValue lhs)
LuaValue
Only strings can be compared, meaning
each operand must derive from LuaString.
public int checkint()
LuaValueLuaError if not numeric
Values that are LuaNumber will be cast to int and may lose precision.
Values that are LuaString that can be converted to a number will be converted,
then cast to int, so may also lose precision.
checkint 在类中 LuaValueLuaValue.checkinteger(),
LuaValue.checklong(),
LuaValue.checkdouble(),
LuaValue.optint(int),
LuaValue.TNUMBERpublic LuaInteger checkinteger()
LuaValueLuaError if not numeric
Values that are LuaNumber will be cast to int and may lose precision.
Values that are LuaString that can be converted to a number will be converted,
then cast to int, so may also lose precision.
checkinteger 在类中 LuaValueLuaInteger if numericLuaValue.checkint(),
LuaValue.checklong(),
LuaValue.checkdouble(),
LuaValue.optinteger(LuaInteger),
LuaValue.TNUMBERpublic long checklong()
LuaValueLuaError if not numeric
Values that are LuaNumber will be cast to long and may lose precision.
Values that are LuaString that can be converted to a number will be converted,
then cast to long, so may also lose precision.
checklong 在类中 LuaValueLuaValue.checkint(),
LuaValue.checkinteger(),
LuaValue.checkdouble(),
LuaValue.optlong(long),
LuaValue.TNUMBERpublic double checkdouble()
LuaValueLuaError if not numeric
Values that are LuaNumber and values that are LuaString
that can be converted to a number will be converted to double.
checkdouble 在类中 LuaValueLuaValue.checkint(),
LuaValue.checkinteger(),
LuaValue.checklong(),
LuaValue.optdouble(double),
LuaValue.TNUMBERpublic LuaNumber checknumber()
LuaValueLuaError
Values that are LuaString that can be converted to a number will be converted and returned.
checknumber 在类中 LuaValueLuaNumber if numericLuaValue.checkint(),
LuaValue.checkinteger(),
LuaValue.checkdouble(),
LuaValue.checklong(),
LuaValue.optnumber(LuaNumber),
LuaValue.TNUMBERpublic LuaNumber checknumber(String msg)
LuaValueLuaError
Values that are LuaString that can be converted to a number will be converted and returned.
checknumber 在类中 LuaValuemsg - String message to supply if conversion failsLuaNumber if numericLuaValue.checkint(),
LuaValue.checkinteger(),
LuaValue.checkdouble(),
LuaValue.checklong(),
LuaValue.optnumber(LuaNumber),
LuaValue.TNUMBERpublic boolean isnumber()
LuaValuethis is a numberisnumber 在类中 LuaValuenumber,
meaning derives from LuaNumber
or derives from LuaString and is convertible to a number,
otherwise falseLuaValue.tonumber(),
LuaValue.checknumber(),
LuaValue.optnumber(LuaNumber),
LuaValue.TNUMBERpublic boolean isint()
LuaValuethis is a number and is representable by java int
without rounding or truncationisint 在类中 LuaValuenumber
meaning derives from LuaNumber
or derives from LuaString and is convertible to a number,
and can be represented by int,
otherwise falseLuaValue.isinttype(),
LuaValue.islong(),
LuaValue.tonumber(),
LuaValue.checkint(),
LuaValue.optint(int),
LuaValue.TNUMBERpublic boolean islong()
LuaValuethis is a number and is representable by java long
without rounding or truncationislong 在类中 LuaValuenumber
meaning derives from LuaNumber
or derives from LuaString and is convertible to a number,
and can be represented by long,
otherwise falseLuaValue.tonumber(),
LuaValue.checklong(),
LuaValue.optlong(long),
LuaValue.TNUMBERpublic byte tobyte()
LuaValuetobyte 在类中 LuaValueLuaValue.toint(),
LuaValue.todouble(),
LuaValue.checknumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic char tochar()
LuaValuetochar 在类中 LuaValueLuaValue.toint(),
LuaValue.todouble(),
LuaValue.checknumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic double todouble()
LuaValuetodouble 在类中 LuaValueLuaValue.toint(),
LuaValue.tobyte(),
LuaValue.tochar(),
LuaValue.toshort(),
LuaValue.tolong(),
LuaValue.tofloat(),
LuaValue.optdouble(double),
LuaValue.checknumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic float tofloat()
LuaValuetofloat 在类中 LuaValueLuaValue.toint(),
LuaValue.todouble(),
LuaValue.checknumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic int toint()
LuaValuetoint 在类中 LuaValueLuaValue.tobyte(),
LuaValue.tochar(),
LuaValue.toshort(),
LuaValue.tolong(),
LuaValue.tofloat(),
LuaValue.todouble(),
LuaValue.optint(int),
LuaValue.checknumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic long tolong()
LuaValuetolong 在类中 LuaValueLuaValue.isint(),
LuaValue.isinttype(),
LuaValue.toint(),
LuaValue.todouble(),
LuaValue.optlong(long),
LuaValue.checknumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic short toshort()
LuaValuetoshort 在类中 LuaValueLuaValue.toint(),
LuaValue.todouble(),
LuaValue.checknumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic double optdouble(double defval)
LuaValueoptdouble 在类中 LuaValuedefval - double to return if this is nil or nonethis cast to double if numeric,
defval if nil or none,
throws LuaError otherwiseLuaValue.optint(int),
LuaValue.optinteger(LuaInteger),
LuaValue.checkdouble(),
LuaValue.todouble(),
LuaValue.tonumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic int optint(int defval)
LuaValueoptint 在类中 LuaValuedefval - int to return if this is nil or nonethis cast to int if numeric,
defval if nil or none,
throws LuaError otherwiseLuaValue.optdouble(double),
LuaValue.optlong(long),
LuaValue.optinteger(LuaInteger),
LuaValue.checkint(),
LuaValue.toint(),
LuaValue.tonumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic LuaInteger optinteger(LuaInteger defval)
LuaValueLuaIntegeroptinteger 在类中 LuaValuedefval - LuaInteger to return if this is nil or nonethis converted and wrapped in LuaInteger if numeric,
defval if nil or none,
throws LuaError otherwiseLuaValue.optdouble(double),
LuaValue.optint(int),
LuaValue.checkint(),
LuaValue.toint(),
LuaValue.tonumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic long optlong(long defval)
LuaValueoptlong 在类中 LuaValuedefval - long to return if this is nil or nonethis cast to long if numeric,
defval if nil or none,
throws LuaError otherwiseLuaValue.optdouble(double),
LuaValue.optint(int),
LuaValue.checkint(),
LuaValue.toint(),
LuaValue.tonumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic LuaNumber optnumber(LuaNumber defval)
LuaValueLuaNumberoptnumber 在类中 LuaValuedefval - LuaNumber to return if this is nil or nonethis cast to LuaNumber if numeric,
defval if nil or none,
throws LuaError otherwiseLuaValue.optdouble(double),
LuaValue.optlong(long),
LuaValue.optint(int),
LuaValue.checkint(),
LuaValue.toint(),
LuaValue.tonumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic LuaString optstring(LuaString defval)
LuaValueLuaStringoptstring 在类中 LuaValuedefval - LuaString to return if this is nil or nonethis converted to LuaString if a string or number,
defval if nil or none,
throws LuaError if some other typeLuaValue.tojstring(),
LuaValue.optjstring(String),
LuaValue.checkstring(),
LuaValue.toString(),
LuaValue.TSTRINGpublic LuaValue tostring()
LuaValue
In lua all numbers are strings, so this function will return
the LuaValue this if it is a string or number,
and LuaValue.NIL for all other cases.
This allows values to be tested for their "string-ness" without the penalty of throwing exceptions.
tostring 在类中 LuaValuethis if it is a LuaString or LuaNumber,
otherwise LuaValue.NILLuaValue.tonumber(),
LuaValue.tojstring(),
LuaValue.optstring(LuaString),
LuaValue.checkstring(),
LuaValue.toString()public String optjstring(String defval)
LuaValueoptjstring 在类中 LuaValuedefval - LuaString to return if this is nil or nonethis converted to String if a string or number,
defval if nil or none,
throws LuaError if some other typeLuaValue.tojstring(),
LuaValue.optstring(LuaString),
LuaValue.checkjstring(),
LuaValue.toString(),
LuaValue.TSTRINGpublic LuaString substring(int beginIndex, int endIndex)
beginIndex - The zero-based index of the first character to include.endIndex - The zero-based index of position after the last character.public static int hashCode(byte[] bytes,
int offset,
int length)
bytes - byte array containing the bytes.offset - offset into the hash for the first byte.length - number of bytes starting with offset that are part of the string.public LuaValue eq(LuaValue val)
LuaValueLuaValue.EQ.eq 在类中 LuaValueval - The value to compare with.LuaValue.TRUE if values are comparable and (this == rhs),
LuaValue.FALSE if comparable but not equal,
LuaValue if metatag processing occurs.LuaValue.eq_b(LuaValue),
LuaValue.raweq(LuaValue),
LuaValue.neq(LuaValue),
LuaValue.eqmtcall(LuaValue, LuaValue, LuaValue, LuaValue),
LuaValue.EQpublic boolean eq_b(LuaValue val)
LuaValueLuaValue.EQ,
and return java booleaneq_b 在类中 LuaValueval - The value to compare with.(this == rhs),
false if comparable but not equal,
result converted to java boolean if metatag processing occurs.LuaValue.eq(LuaValue),
LuaValue.raweq(LuaValue),
LuaValue.neq_b(LuaValue),
LuaValue.eqmtcall(LuaValue, LuaValue, LuaValue, LuaValue),
LuaValue.EQpublic boolean raweq(LuaValue val)
LuaValueraweq 在类中 LuaValueval - The value to compare with.(this == rhs), false otherwiseLuaValue.eq(LuaValue),
LuaValue.raweq(LuaUserdata),
LuaValue.raweq(LuaString),
LuaValue.raweq(double),
#raweq(int),
LuaValue.EQpublic boolean raweq(LuaString s)
LuaValueLuaString value
without metatag processing.public static boolean equals(byte[] a,
int i,
byte[] b,
int j,
int n)
public void write(DataOutputStream writer, int i, int len) throws IOException
IOExceptionpublic LuaValue len()
LuaValue(#this) including metatag processing as java intpublic int length()
LuaValue(#this) including metatag processing as java intlength 在类中 LuaValueLuaValue.toint()public int rawlen()
LuaValuepublic int luaByte(int index)
public int charAt(int index)
public String checkjstring()
LuaValueThe string representations here will roughly match what is produced by the C lua distribution, however hash codes have no relationship, and there may be differences in number formatting.
checkjstring 在类中 LuaValueLuaValue.checkstring(),
LuaValue.optjstring(String),
LuaValue.tojstring(),
LuaValue.isstring(),
LuaValue.TSTRINGpublic LuaString checkstring()
LuaValueLuaError if it is not.
In lua all numbers are strings, so this will succeed for
anything that derives from LuaString or LuaNumber.
Numbers will be converted to LuaString.
checkstring 在类中 LuaValueLuaString representation of the value if it is a LuaString or LuaNumberLuaValue.checkjstring(),
LuaValue.optstring(LuaString),
LuaValue.tostring(),
LuaValue.isstring(),
LuaValue.TSTRINGpublic InputStream toInputStream()
InputStream whose data matches the bytes in this LuaStringpublic void copyInto(int strOffset,
byte[] bytes,
int arrayOffset,
int len)
strOffset - offset from which to copybytes - destination byte arrayarrayOffset - offset in destinationlen - number of bytes to copypublic int indexOfAny(LuaString accept)
accept - LuaString containing characters to look for.accept string, or -1 if not found.public int indexOf(byte b,
int start)
b - the byte to look forstart - the first index in the stringpublic int indexOf(LuaString s, int start)
s - the string to search forstart - the first index in the stringpublic int lastIndexOf(LuaString s)
s - the string to search forpublic static String decodeAsUtf8(byte[] bytes, int offset, int length)
bytes - byte array in UTF8 encoding to convertoffset - starting index in byte arraylength - number of bytes to convertlengthAsUtf8(char[]),
encodeToUtf8(char[], int, byte[], int),
isValidUtf8()public static char[] toCharAsUtf8(byte[] bytes,
int offset,
int length)
public static int lengthAsUtf8(char[] chars)
chars - Array of unicode characters to be encoded as UTF-8encodeToUtf8(char[], int, byte[], int),
decodeAsUtf8(byte[], int, int),
isValidUtf8()public static int encodeToUtf8(char[] chars,
int nchars,
byte[] bytes,
int off)
The string should be measured first with lengthAsUtf8 to make sure the given byte array is large enough.
chars - Array of unicode characters to be encoded as UTF-8nchars - Number of characters in the array to convert.bytes - byte array to hold the resultoff - offset into the byte array to start writinglengthAsUtf8(char[]),
decodeAsUtf8(byte[], int, int),
isValidUtf8()public boolean isValidUtf8()
lengthAsUtf8(char[]),
encodeToUtf8(char[], int, byte[], int),
decodeAsUtf8(byte[], int, int)public LuaValue tonumber()
tonumber 在类中 LuaValueLuaValue.tonumber()public LuaValue tonumber(int base)
base - the base to use, such as 10LuaValue.tonumber()public double scannumber()
public double scannumber(int base)
base - the base to use between 2 and 36public void printToStream(PrintStream ps)
ps - PrintStream to print to.Copyright © 2020. All rights reserved.