Class LuaNumber
- Direct Known Subclasses:
LuaDouble,LuaInteger
The main subclasses are LuaInteger which holds values that fit in a java int,
and LuaDouble which holds all other number values.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.prineside.luaj.LuaValue
LuaValue.NillableSerializer, LuaValue.None -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic LuaValueShared static metatable for all number values represented in lua.Fields inherited from class com.prineside.luaj.LuaValue
ADD, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILLABLE_SERIALIZER, NILS, NONE, NOVALS, ONE, POW, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, ZERO -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCheck that the value is numeric, and return as a LuaNumber if so, or throwLuaErrorchecknumber(String errmsg) Check that the value is numeric, and return as a LuaNumber if so, or throwLuaErrorConcatenate aBufferonto this value and return the result using rules of lua string concatenation including metatag processing.Concatenate another value onto this value and return the result using rules of lua string concatenation including metatag processing.Reverse-concatenation: concatenate this value onto another value known to be aLuaNumberand return the result using rules of lua string concatenation including metatag processing.Reverse-concatenation: concatenate this value onto another value known to be aLuaStringand return the result using rules of lua string concatenation including metatag processing.Get the metatable for thisLuaValuebooleanisnumber()Check ifthisis anumberbooleanisstring()Check ifthisis astringCheck that optional argument is a number or string convertible to number and return asLuaNumbertonumber()Conditionally convert to lua number without throwing errors.inttype()Get the enumeration value for the type of this value.typename()Get the String name of the type of this value.Methods inherited from class com.prineside.luaj.LuaValue
add, add, add, and, arg, arg1, argerror, assert_, buffer, cachedDouble, cachedInt, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, call, call, call, call, call, checkboolean, checkclosure, checkdouble, checkfunction, checkglobals, checkint, checkinteger, checkjstring, checklong, checknotnil, checkstring, checktable, checkthread, checkuserdata, checkuserdata, comparemt, concatmt, concatTo, div, div, div, divInto, eq, eq_b, eqmtcall, equals, error, get, get, get, gt, gt, gt, gt_b, gt_b, gt_b, gteq, gteq, gteq, gteq_b, gteq_b, gteq_b, 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, len, length, listOf, listOf, load, lt, lt, lt, lt_b, lt_b, lt_b, lteq, lteq, lteq, lteq_b, lteq_b, lteq_b, metatag, method, method, method, method, method, method, mod, mod, mod, modFrom, mul, mul, mul, narg, neg, neq, neq_b, 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, setmetatable, 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, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOfMethods inherited from class com.prineside.luaj.Varargs
argcheck, 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, type
-
Field Details
-
s_metatable
Shared static metatable for all number values represented in lua.
-
-
Constructor Details
-
LuaNumber
public LuaNumber()
-
-
Method Details
-
type
public int type()Description copied from class:LuaValueGet the enumeration value for the type of this value.- Specified by:
typein classLuaValue- Returns:
- value for this type, one of
LuaValue.TNIL,LuaValue.TBOOLEAN,LuaValue.TNUMBER,LuaValue.TSTRING,LuaValue.TTABLE,LuaValue.TFUNCTION,LuaValue.TUSERDATA,LuaValue.TTHREAD - See Also:
-
typename
Description copied from class:LuaValueGet the String name of the type of this value.- Specified by:
typenamein classLuaValue- Returns:
- name from type name list
LuaValue.TYPE_NAMEScorresponding to the type of this value: "nil", "boolean", "number", "string", "table", "function", "userdata", "thread" - See Also:
-
checknumber
Description copied from class:LuaValueCheck that the value is numeric, and return as a LuaNumber if so, or throwLuaErrorValues that are
LuaStringthat can be converted to a number will be converted and returned.- Overrides:
checknumberin classLuaValue- Returns:
- value as a
LuaNumberif numeric - See Also:
-
checknumber
Description copied from class:LuaValueCheck that the value is numeric, and return as a LuaNumber if so, or throwLuaErrorValues that are
LuaStringthat can be converted to a number will be converted and returned.- Overrides:
checknumberin classLuaValue- Parameters:
errmsg- String message to supply if conversion fails- Returns:
- value as a
LuaNumberif numeric - See Also:
-
optnumber
Description copied from class:LuaValueCheck that optional argument is a number or string convertible to number and return asLuaNumber -
tonumber
Description copied from class:LuaValueConditionally convert to lua number without throwing errors.In lua all numbers are strings, but not all strings are numbers. This function will return the
LuaValuethisif it is a number or a string convertible to a number, andLuaValue.NILfor 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.
- Overrides:
tonumberin classLuaValue- Returns:
thisif it is aLuaNumberorLuaStringthat can be converted to a number, otherwiseLuaValue.NIL- See Also:
-
isnumber
public boolean isnumber()Description copied from class:LuaValueCheck ifthisis anumber -
isstring
public boolean isstring()Description copied from class:LuaValueCheck ifthisis astring -
getmetatable
Description copied from class:LuaValueGet the metatable for thisLuaValueFor
LuaTableandLuaUserdatainstances, the metatable returned is this instance metatable. For all other types, the class metatable value will be returned.- Overrides:
getmetatablein classLuaValue- Returns:
- metatable, or null if it there is none
- See Also:
-
concat
Description copied from class:LuaValue -
concat
Description copied from class:LuaValue -
concatTo
Description copied from class:LuaValueReverse-concatenation: concatenate this value onto another value known to be aLuaNumberand 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
LuaStringorLuaNumber. -
concatTo
Description copied from class:LuaValueReverse-concatenation: concatenate this value onto another value known to be aLuaStringand 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
LuaStringorLuaNumber.
-