org.luaj.vm2
Class LuaBoolean

java.lang.Object
  extended by org.luaj.vm2.Varargs
      extended by org.luaj.vm2.LuaValue
          extended by org.luaj.vm2.LuaBoolean

public final class LuaBoolean
extends LuaValue

Extension of LuaValue which can hold a Java boolean as its value.

These instance are not instantiated directly by clients. Instead, there are exactly twon instances of this class, LuaValue.TRUE and LuaValue.FALSE representing the lua values true and false. The function LuaValue.valueOf(boolean) will always return one of these two values.

Any LuaValue can be converted to its equivalent boolean representation using LuaValue.toboolean()

See Also:
LuaValue, LuaValue.valueOf(boolean), LuaValue.TRUE, LuaValue.FALSE

Field Summary
static LuaValue s_metatable
          Shared static metatable for boolean values represented in lua.
 boolean v
          The value of the boolean
 
Fields inherited from class org.luaj.vm2.LuaValue
ADD, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, POW, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, ZERO
 
Method Summary
 boolean booleanValue()
          Return the boolean value for this boolean
 boolean checkboolean()
          Check that the value is a LuaBoolean, or throw LuaError if not
 LuaValue getmetatable()
          Get the metatable for this LuaValue
 boolean isboolean()
          Check if this is a boolean
 LuaValue not()
          Unary not: return inverse boolean value (~this) as defined by lua not operator
 boolean optboolean(boolean defval)
          Check that optional argument is a boolean and return its boolean value
 boolean toboolean()
          Convert to boolean false if LuaValue.NIL or LuaValue.FALSE, true if anything else
 java.lang.String tojstring()
          Convert to human readable String for any type.
 int type()
          Get the enumeration value for the type of this value.
 java.lang.String typename()
          Get the String name of the type of this value.
 
Methods inherited from class org.luaj.vm2.LuaValue
add, add, add, and, arg, arg1, argerror, argerror, aritherror, aritherror, arithmt, arithmtwith, assert_, buffer, call, call, call, call, call, callmt, checkclosure, checkdouble, checkfunction, checkglobals, checkint, checkinteger, checkjstring, checklong, checkmetatag, checknotnil, checknumber, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, compareerror, compareerror, comparemt, concat, concat, concatmt, concatTo, concatTo, concatTo, div, div, div, divInto, eq_b, eq, eqmtcall, equals, error, get, get, get, gettable, gt_b, gt_b, gt_b, gt, gt, gt, gteq_b, gteq_b, gteq_b, gteq, gteq, gteq, illegal, inext, initupvalue1, invoke, invoke, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, isclosure, isfunction, isint, isinttype, islong, isnil, isnumber, isstring, istable, isthread, isuserdata, isuserdata, isvalidkey, 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, onInvoke, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, 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, settable, strcmp, strcmp, strongvalue, strvalue, sub, sub, sub, subargs, subFrom, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, tobyte, tochar, todouble, tofloat, toint, tolong, tonumber, toshort, tostring, toString, touserdata, touserdata, typerror, unimplemented, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf
 
Methods inherited from class org.luaj.vm2.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, 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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

s_metatable

public static LuaValue s_metatable
Shared static metatable for boolean values represented in lua.


v

public final boolean v
The value of the boolean

Method Detail

type

public int type()
Description copied from class: LuaValue
Get the enumeration value for the type of this value.

Specified by:
type in class LuaValue
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:
LuaValue.typename()

typename

public java.lang.String typename()
Description copied from class: LuaValue
Get the String name of the type of this value.

Specified by:
typename in class LuaValue
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:
LuaValue.type()

isboolean

public boolean isboolean()
Description copied from class: LuaValue
Check if this is a boolean

Overrides:
isboolean in class LuaValue
Returns:
true if this is a boolean, otherwise false
See Also:
LuaValue.isboolean(), LuaValue.toboolean(), LuaValue.checkboolean(), LuaValue.optboolean(boolean), LuaValue.TBOOLEAN

not

public LuaValue not()
Description copied from class: LuaValue
Unary not: return inverse boolean value (~this) as defined by lua not operator

Overrides:
not in class LuaValue
Returns:
LuaValue.TRUE if LuaValue.NIL or LuaValue.FALSE, otherwise LuaValue.FALSE

booleanValue

public boolean booleanValue()
Return the boolean value for this boolean

Returns:
value as a Java boolean

toboolean

public boolean toboolean()
Description copied from class: LuaValue
Convert to boolean false if LuaValue.NIL or LuaValue.FALSE, true if anything else

Overrides:
toboolean in class LuaValue
Returns:
Value cast to byte if number or string convertible to number, otherwise 0
See Also:
LuaValue.optboolean(boolean), LuaValue.checkboolean(), LuaValue.isboolean(), LuaValue.TBOOLEAN

tojstring

public java.lang.String tojstring()
Description copied from class: LuaValue
Convert to human readable String for any type.

Overrides:
tojstring in class LuaValue
Returns:
String for use by human readers based on type.
See Also:
LuaValue.tostring(), LuaValue.optjstring(String), LuaValue.checkjstring(), LuaValue.isstring(), LuaValue.TSTRING

optboolean

public boolean optboolean(boolean defval)
Description copied from class: LuaValue
Check that optional argument is a boolean and return its boolean value

Overrides:
optboolean in class LuaValue
Parameters:
defval - boolean value to return if this is nil or none
Returns:
this cast to boolean if a LuaBoolean, defval if nil or none, throws LuaError otherwise
See Also:
LuaValue.checkboolean(), LuaValue.isboolean(), LuaValue.TBOOLEAN

checkboolean

public boolean checkboolean()
Description copied from class: LuaValue
Check that the value is a LuaBoolean, or throw LuaError if not

Overrides:
checkboolean in class LuaValue
Returns:
boolean value for this if it is a LuaBoolean
See Also:
LuaValue.optboolean(boolean), LuaValue.TBOOLEAN

getmetatable

public LuaValue getmetatable()
Description copied from class: LuaValue
Get the metatable for this LuaValue

For LuaTable and LuaUserdata instances, the metatable returned is this instance metatable. For all other types, the class metatable value will be returned.

Overrides:
getmetatable in class LuaValue
Returns:
metatable, or null if it there is none
See Also:
s_metatable, LuaNumber.s_metatable, LuaNil.s_metatable, LuaFunction.s_metatable, LuaThread.s_metatable


Copyright © 2007-2015 Luaj.org. All Rights Reserved.