public abstract class LuaNumber extends LuaValue
The main subclasses are LuaInteger which holds values that fit in a java int,
and LuaDouble which holds all other number values.
LuaInteger,
LuaDouble,
LuaValue| 限定符和类型 | 字段和说明 |
|---|---|
static LuaValue |
s_metatable
Shared static metatable for all number values represented in lua.
|
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| 构造器和说明 |
|---|
LuaNumber() |
| 限定符和类型 | 方法和说明 |
|---|---|
LuaNumber |
checknumber()
|
LuaNumber |
checknumber(String errmsg)
|
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. |
LuaValue |
getmetatable()
Get the metatable for this
LuaValue
For LuaTable and LuaUserdata instances,
the metatable returned is this instance metatable. |
boolean |
isnumber()
Check if
this is a number |
boolean |
isstring()
Check if
this is a string |
LuaNumber |
optnumber(LuaNumber defval)
Check that optional argument is a number or string convertible to number and return as
LuaNumber |
LuaValue |
tonumber()
Conditionally convert to lua number 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.
|
add, add, 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, checkdouble, checkfunction, checkglobals, checkint, checkinteger, checkjstring, checklong, checkmetatag, checknotnil, checkstring, checktable, checkthread, checkuserdata, checkuserdata, compareerror, compareerror, comparemt, concatmt, concatTo, div, div, div, divInto, eq_b, eq, eqmtcall, equals, error, get, get, get, getfenv, gettable, getuservalue, gt_b, gt_b, gt_b, gt, gt, gt, gteq_b, gteq_b, gteq_b, gteq, gteq, gteq, idiv, idiv, illegal, inext, initupvalue1, invoke, invoke, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isfunction, isint, isinttype, islong, isnil, istable, isthread, isuserdata, isuserdata, isvalidkey, jcall, jget, jset, len, lenerror, length, listOf, listOf, load, lt_b, lt_b, lt_b, lt, lt, lt, lteq_b, lteq_b, lteq_b, lteq, lteq, lteq, metatableOf, metatag, method, method, method, method, method, method, mod, mod, mod, modFrom, mul, mul, mul, narg, neg, neq_b, neq, next, not, onInvoke, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, or, pow, pow, pow, powWith, powWith, presize, raweq, raweq, raweq, raweq, raweq, rawget, rawget, rawget, rawlen, rawset, rawset, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, set, set, setfenv, setmetatable, settable, setuservalue, shl, shl, shr, shr, strcmp, strcmp, strongvalue, strvalue, sub, sub, sub, subargs, subFrom, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, tostring, toString, touserdata, touserdata, typerror, unimplemented, userdataOf, userdataOf, valueOf, valueOf, valueOf, 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 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 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 errmsg)
LuaValueLuaError
Values that are LuaString that can be converted to a number will be converted and returned.
checknumber 在类中 LuaValueerrmsg - String message to supply if conversion failsLuaNumber if numericLuaValue.checkint(),
LuaValue.checkinteger(),
LuaValue.checkdouble(),
LuaValue.checklong(),
LuaValue.optnumber(LuaNumber),
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 LuaValue tonumber()
LuaValue
In lua all numbers are strings, but not all strings are numbers.
This function will return
the LuaValue this if it is a number
or a string convertible to a number,
and LuaValue.NIL for all other cases.
This allows values to be tested for their "numeric-ness" without the penalty of throwing exceptions, nor the cost of converting the type and creating storage for it.
tonumber 在类中 LuaValuethis if it is a LuaNumber
or LuaString that can be converted to a number,
otherwise LuaValue.NILLuaValue.tostring(),
LuaValue.optnumber(LuaNumber),
LuaValue.checknumber(),
LuaValue.toint(),
LuaValue.todouble()public 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 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,
s_metatable,
LuaNil.s_metatable,
LuaFunction.s_metatable,
LuaThread.s_metatablepublic 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)Copyright © 2020. All rights reserved.