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 LuaValue
Shared 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 throwLuaError
checknumber
(String errmsg) Check that the value is numeric, and return as a LuaNumber if so, or throwLuaError
Concatenate aBuffer
onto 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 aLuaNumber
and return the result using rules of lua string concatenation including metatag processing.Reverse-concatenation: concatenate this value onto another value known to be aLuaString
and return the result using rules of lua string concatenation including metatag processing.Get the metatable for thisLuaValue
boolean
isnumber()
Check ifthis
is anumber
boolean
isstring()
Check ifthis
is astring
Check that optional argument is a number or string convertible to number and return asLuaNumber
tonumber()
Conditionally convert to lua number without throwing errors.int
type()
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, varargsOf
Methods 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:LuaValue
Get the enumeration value for the type of this value.- Specified by:
type
in 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:LuaValue
Get the String name of the type of this value.- Specified by:
typename
in classLuaValue
- Returns:
- name from type name list
LuaValue.TYPE_NAMES
corresponding to the type of this value: "nil", "boolean", "number", "string", "table", "function", "userdata", "thread" - See Also:
-
checknumber
Description copied from class:LuaValue
Check that the value is numeric, and return as a LuaNumber if so, or throwLuaError
Values that are
LuaString
that can be converted to a number will be converted and returned.- Overrides:
checknumber
in classLuaValue
- Returns:
- value as a
LuaNumber
if numeric - See Also:
-
checknumber
Description copied from class:LuaValue
Check that the value is numeric, and return as a LuaNumber if so, or throwLuaError
Values that are
LuaString
that can be converted to a number will be converted and returned.- Overrides:
checknumber
in classLuaValue
- Parameters:
errmsg
- String message to supply if conversion fails- Returns:
- value as a
LuaNumber
if numeric - See Also:
-
optnumber
Description copied from class:LuaValue
Check that optional argument is a number or string convertible to number and return asLuaNumber
-
tonumber
Description copied from class:LuaValue
Conditionally convert to lua number without throwing errors.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, andLuaValue.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.
- Overrides:
tonumber
in classLuaValue
- Returns:
this
if it is aLuaNumber
orLuaString
that can be converted to a number, otherwiseLuaValue.NIL
- See Also:
-
isnumber
public boolean isnumber()Description copied from class:LuaValue
Check ifthis
is anumber
-
isstring
public boolean isstring()Description copied from class:LuaValue
Check ifthis
is astring
-
getmetatable
Description copied from class:LuaValue
Get the metatable for thisLuaValue
For
LuaTable
andLuaUserdata
instances, the metatable returned is this instance metatable. For all other types, the class metatable value will be returned.- Overrides:
getmetatable
in 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:LuaValue
Reverse-concatenation: concatenate this value onto another value known to be aLuaNumber
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
orLuaNumber
. -
concatTo
Description copied from class:LuaValue
Reverse-concatenation: concatenate this value onto another value known to be aLuaString
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
orLuaNumber
.
-