|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.luaj.vm2.Varargs org.luaj.vm2.LuaValue org.luaj.vm2.LuaString
public class LuaString
Subclass of 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 generally not mutable once constructed,
so multiple LuaString
values can chare a single byte array.
Currently LuaString
s 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.
When Java Strings are used to initialize LuaString
data, the UTF8 encoding is assumed.
The functions
LuaString#lengthAsUtf8(char[]),
{@link LuaString#encodeToUtf8(char[], byte[], int)}, and
{@link LuaString#decodeAsUtf8(byte[], int, int)
are used to convert back and forth between UTF8 byte arrays and character arrays.
LuaValue
,
LuaValue.valueOf(String)
,
LuaValue.valueOf(byte[])
Field Summary | |
---|---|
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 representing lua true |
Fields inherited from class org.luaj.vm2.LuaValue |
---|
ADD, CALL, CONCAT, DIV, EMPTYSTRING, 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 | |
---|---|
LuaValue |
add(double rhs)
Add: Perform numeric add operation with another value of double type with metatag processing |
LuaValue |
add(int rhs)
Add: Perform numeric add operation with another value of int type with metatag processing |
LuaValue |
add(LuaValue rhs)
Add: Perform numeric add operation with another value including metatag processing. |
int |
charAt(int index)
|
double |
checkdouble()
Check that the value is numeric and return the value as a double, or throw LuaError if not numeric |
int |
checkint()
Check that the value is numeric, and convert and cast value to int, or throw LuaError if not numeric |
LuaInteger |
checkinteger()
Check that the value is numeric, and convert and cast value to int, or throw LuaError if not numeric |
java.lang.String |
checkjstring()
Convert this value to a Java String. |
long |
checklong()
Check that the value is numeric, and convert and cast value to long, or throw LuaError if not numeric |
LuaNumber |
checknumber()
Check that the value is numeric, and return as a LuaNumber if so, or throw LuaError |
LuaNumber |
checknumber(java.lang.String msg)
Check that the value is numeric, and return as a LuaNumber if so, or throw LuaError |
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 java.lang.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 |
LuaValue |
div(int rhs)
Divide: Perform numeric divide operation by another value of int type without metatag processing |
LuaValue |
div(LuaValue rhs)
Divide: Perform numeric divide operation by another value of unknown type, including metatag processing. |
LuaValue |
divInto(double lhs)
Reverse-divide: Perform numeric divide operation into another value with metatag processing |
static void |
encodeToUtf8(char[] chars,
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 EQ ,
and return java boolean |
LuaValue |
eq(LuaValue val)
Equals: Perform equality comparison with another value including metatag processing using 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(java.lang.Object o)
|
LuaValue |
get(LuaValue key)
Get a value in a table including metatag processing using INDEX . |
LuaValue |
getmetatable()
Get the metatable for this LuaValue |
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)
Greater than: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean. |
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)
Greater than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean. |
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()
|
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 |
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)
Less than: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean. |
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)
Less than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean. |
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 |
LuaValue |
mod(int rhs)
Modulo: Perform numeric modulo operation with another value of int type without metatag processing |
LuaValue |
mod(LuaValue rhs)
Modulo: Perform numeric modulo operation with another value of unknown type, including metatag processing. |
LuaValue |
modFrom(double lhs)
Reverse-modulo: Perform numeric modulo operation from another value with metatag processing |
LuaValue |
mul(double rhs)
Multiply: Perform numeric multiply operation with another value of double type with metatag processing |
LuaValue |
mul(int rhs)
Multiply: Perform numeric multiply operation with another value of int type with metatag processing |
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 |
java.lang.String |
optjstring(java.lang.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)
Raise to power: Raise this value to a power of double type with metatag processing |
LuaValue |
pow(int rhs)
Raise to power: Raise this value to a power of int type with metatag processing |
LuaValue |
pow(LuaValue rhs)
Raise to power: Raise this value to a power including metatag processing. |
LuaValue |
powWith(double lhs)
Reverse-raise to power: Raise another value of double type to this power with metatag processing |
LuaValue |
powWith(int lhs)
Reverse-raise to power: Raise another value of double type to this power with metatag processing |
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. |
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()
Convert this value to a string if it is a LuaString or LuaNumber ,
or throw a LuaError if it is not |
LuaValue |
sub(double rhs)
Subtract: Perform numeric subtract operation with another value of double type with metatag processing |
LuaValue |
sub(int rhs)
Subtract: Perform numeric subtract operation with another value of int type with metatag processing |
LuaValue |
sub(LuaValue rhs)
Subtract: Perform numeric subtract operation with another value of unknown type, including metatag processing. |
LuaValue |
subFrom(double lhs)
Reverse-subtract: Perform numeric subtract operation from an int value with metatag processing |
LuaString |
substring(int beginIndex,
int endIndex)
|
byte |
tobyte()
Convert to byte if numeric, or 0 if not. |
char |
tochar()
Convert to char if numeric, or 0 if not. |
double |
todouble()
Convert to double if numeric, or 0 if not. |
float |
tofloat()
Convert to float if numeric, or 0 if not. |
java.io.InputStream |
toInputStream()
Convert value to an input stream. |
int |
toint()
Convert to int if numeric, or 0 if not. |
java.lang.String |
tojstring()
Convert to human readable String for any type. |
long |
tolong()
Convert to long if numeric, or 0 if not. |
LuaValue |
tonumber()
Conditionally convert to lua number without throwing errors. |
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. |
java.lang.String |
typename()
Get the String name of the type of this value. |
static LuaString |
valueOf(byte[] bytes)
Construct a LuaString around a byte array without copying the contents. |
static LuaString |
valueOf(byte[] bytes,
int off,
int len)
Construct a LuaString around a byte array without copying the contents. |
static LuaString |
valueOf(char[] bytes)
Construct a LuaString using the supplied characters as byte values. |
static LuaString |
valueOf(java.lang.String string)
Get a LuaString instance whose bytes match
the supplied Java String using the UTF8 encoding. |
void |
write(java.io.DataOutputStream writer,
int i,
int len)
|
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, subargs, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static LuaValue s_metatable
true
public final byte[] m_bytes
public final int m_offset
public final int m_length
Method Detail |
---|
public static LuaString valueOf(java.lang.String string)
LuaString
instance whose bytes match
the supplied Java String using the UTF8 encoding.
string
- Java String containing characters to encode as UTF8
LuaString
with UTF8 bytes corresponding to the supplied Stringpublic static LuaString valueOf(byte[] bytes, int off, int len)
LuaString
around a byte array without copying the contents.
The array is used directly after this is called, so clients must not change contents.
bytes
- byte bufferoff
- offset into the byte bufferlen
- length of the byte buffer
LuaString
wrapping the byte bufferpublic static LuaString valueOf(char[] bytes)
LuaString
using the supplied characters as byte values.
Only th elow-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
around a byte array without copying the contents.
The array is used directly after this is called, so clients must not change contents.
bytes
- byte buffer
LuaString
wrapping the byte bufferpublic boolean isstring()
LuaValue
this
is a string
isstring
in class LuaValue
string
,
meaning derives from LuaString
or LuaNumber
,
otherwise falseLuaValue.tostring()
,
LuaValue.checkstring()
,
LuaValue.optstring(LuaString)
,
LuaValue.TSTRING
public LuaValue getmetatable()
LuaValue
LuaValue
For LuaTable
and LuaUserdata
instances,
the metatable returned is this instance metatable.
For all other types, the class metatable value will be returned.
getmetatable
in class LuaValue
LuaBoolean.s_metatable
,
LuaNumber.s_metatable
,
LuaNil.s_metatable
,
LuaFunction.s_metatable
,
LuaThread.s_metatable
public int type()
LuaValue
type
in class LuaValue
TNIL
,
TBOOLEAN
,
TNUMBER
,
TSTRING
,
TTABLE
,
TFUNCTION
,
TUSERDATA
,
TTHREAD
LuaValue.typename()
public java.lang.String typename()
LuaValue
typename
in class LuaValue
LuaValue.TYPE_NAMES
corresponding to the type of this value:
"nil", "boolean", "number", "string",
"table", "function", "userdata", "thread"LuaValue.type()
public java.lang.String tojstring()
LuaValue
tojstring
in class LuaValue
LuaValue.tostring()
,
LuaValue.optjstring(String)
,
LuaValue.checkjstring()
,
LuaValue.isstring()
,
TSTRING
public LuaValue get(LuaValue key)
LuaValue
INDEX
.
get
in class LuaValue
key
- the key to look up, must not be NIL
or null
LuaValue
for that key, or NIL
if not found and no metatagLuaValue.get(int)
,
LuaValue.get(String)
,
LuaValue.rawget(LuaValue)
public LuaValue neg()
LuaValue
(-this)
as defined by lua unary minus operator
neg
in class LuaValue
LuaBoolean
if boolean or nil,
numeric inverse as if numeric,
or metatag processing result if 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
in class LuaValue
rhs
- 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
in class LuaValue
rhs
- The right-hand-side value to perform the add with
(this + rhs)
if this is numericLuaValue.add(LuaValue)
public LuaValue add(int rhs)
LuaValue
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
add
in class LuaValue
rhs
- The right-hand-side value to perform the add with
(this + rhs)
if this is numericLuaValue.add(LuaValue)
public LuaValue sub(LuaValue rhs)
LuaValue
Each operand must derive from LuaNumber
or derive from LuaString
and be convertible to a number
sub
in class LuaValue
rhs
- 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
in class LuaValue
rhs
- The right-hand-side value to perform the subtract with
(this - rhs)
if this is numericLuaValue.sub(LuaValue)
public LuaValue sub(int rhs)
LuaValue
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
sub
in class LuaValue
rhs
- The right-hand-side value to perform the subtract with
(this - rhs)
if this is numericLuaValue.sub(LuaValue)
public LuaValue subFrom(double lhs)
LuaValue
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
subFrom
in class LuaValue
lhs
- The left-hand-side value from which to perform the subtraction
(lhs - this)
if this is numericLuaValue.sub(LuaValue)
,
LuaValue.sub(double)
,
LuaValue.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
in class LuaValue
rhs
- 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
in class LuaValue
rhs
- The right-hand-side value to perform the multiply with
(this * rhs)
if this is numericLuaValue.mul(LuaValue)
public LuaValue mul(int rhs)
LuaValue
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
mul
in class LuaValue
rhs
- The right-hand-side value to perform the multiply with
(this * rhs)
if this is numericLuaValue.mul(LuaValue)
public LuaValue pow(LuaValue rhs)
LuaValue
Each operand must derive from LuaNumber
or derive from LuaString
and be convertible to a number
pow
in class LuaValue
rhs
- 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
in class LuaValue
rhs
- The power to raise this value to
(this ^ rhs)
if this is numericLuaValue.pow(LuaValue)
public LuaValue pow(int rhs)
LuaValue
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
pow
in class LuaValue
rhs
- The power to raise this value to
(this ^ rhs)
if this is numericLuaValue.pow(LuaValue)
public LuaValue powWith(double lhs)
LuaValue
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
powWith
in class LuaValue
lhs
- The left-hand-side value which will be raised to this power
(lhs ^ this)
if this is numericLuaValue.pow(LuaValue)
,
LuaValue.pow(double)
,
LuaValue.pow(int)
public LuaValue powWith(int lhs)
LuaValue
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
powWith
in class LuaValue
lhs
- The left-hand-side value which will be raised to this power
(lhs ^ this)
if this is numericLuaValue.pow(LuaValue)
,
LuaValue.pow(double)
,
LuaValue.pow(int)
public LuaValue div(LuaValue rhs)
LuaValue
Each operand must derive from LuaNumber
or derive from LuaString
and be convertible to a number
div
in class LuaValue
rhs
- 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
in class LuaValue
rhs
- The right-hand-side value to perform the divulo with
(this / rhs)
if this is numericLuaValue.div(LuaValue)
public LuaValue div(int 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
in class LuaValue
rhs
- The right-hand-side value to perform the divulo with
(this / rhs)
if this is numericLuaValue.div(LuaValue)
public LuaValue divInto(double lhs)
LuaValue
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
divInto
in class LuaValue
lhs
- The left-hand-side value which will be divided by this
(lhs / this)
if this is numericLuaValue.div(LuaValue)
,
LuaValue.div(double)
,
LuaValue.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
in class LuaValue
rhs
- 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
in class LuaValue
rhs
- The right-hand-side value to perform the modulo with
(this % rhs)
if this is numericLuaValue.mod(LuaValue)
public LuaValue mod(int 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
in class LuaValue
rhs
- The right-hand-side value to perform the modulo with
(this % rhs)
if this is numericLuaValue.mod(LuaValue)
public LuaValue modFrom(double lhs)
LuaValue
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
modFrom
in class LuaValue
lhs
- The left-hand-side value which will be modulo'ed by this
(lhs % this)
if this is numericLuaValue.mod(LuaValue)
,
LuaValue.mod(double)
,
LuaValue.mod(int)
public LuaValue lt(LuaValue rhs)
LuaValue
LuaValue
.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
lt
in class LuaValue
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this < rhs)
, 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
in class LuaValue
rhs
- 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)
LuaValue
To be comparable, this must derive from LuaNumber
.
lt_b
in class LuaValue
rhs
- 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(int)
,
LuaValue.comparemt(LuaValue, LuaValue)
public boolean lt_b(double rhs)
LuaValue
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
lt_b
in class LuaValue
rhs
- 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)
LuaValue
LuaValue
.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
lteq
in class LuaValue
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this <= rhs)
, 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
in class LuaValue
rhs
- 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)
LuaValue
To be comparable, this must derive from LuaNumber
.
lteq_b
in class LuaValue
rhs
- 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(int)
,
LuaValue.comparemt(LuaValue, LuaValue)
public boolean lteq_b(double rhs)
LuaValue
To be comparable, this must derive from LuaNumber
.
lteq_b
in class LuaValue
rhs
- 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)
LuaValue
LuaValue
.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
gt
in class LuaValue
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this > rhs)
, 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
in class LuaValue
rhs
- 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)
LuaValue
To be comparable, this must derive from LuaNumber
.
gt_b
in class LuaValue
rhs
- 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(int)
,
LuaValue.comparemt(LuaValue, LuaValue)
public boolean gt_b(double rhs)
LuaValue
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
gt_b
in class LuaValue
rhs
- 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)
LuaValue
LuaValue
.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
gteq
in class LuaValue
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this >= rhs)
, 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
in class LuaValue
rhs
- 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)
LuaValue
To be comparable, this must derive from LuaNumber
.
gteq_b
in class LuaValue
rhs
- 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(int)
,
LuaValue.comparemt(LuaValue, LuaValue)
public boolean gteq_b(double rhs)
LuaValue
To be comparable, this must derive from LuaNumber
.
gteq_b
in class LuaValue
rhs
- 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 concat(LuaValue rhs)
LuaValue
Only strings and numbers as represented can be concatenated, meaning
each operand must derive from LuaString
or LuaNumber
.
concat
in class LuaValue
rhs
- The right-hand-side value to perform the operation withpublic Buffer concat(Buffer rhs)
LuaValue
Buffer
onto this value 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
.
concat
in class LuaValue
rhs
- The right-hand-side Buffer
to perform the operation with
(this .. rhs)
public LuaValue concatTo(LuaNumber lhs)
LuaValue
LuaNumber
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
in class LuaValue
lhs
- The left-hand-side value onto which this will be concatenatedLuaValue.concat(LuaValue)
public LuaValue concatTo(LuaString lhs)
LuaValue
LuaString
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
in class LuaValue
lhs
- The left-hand-side value onto which this will be concatenatedLuaValue.concat(LuaValue)
public int strcmp(LuaValue lhs)
LuaValue
Only strings can be compared, meaning
each operand must derive from LuaString
.
strcmp
in class LuaValue
lhs
- The right-hand-side value to perform the comparison withpublic int strcmp(LuaString rhs)
LuaValue
LuaString
using string comparison based on byte values.
Only strings can be compared, meaning
each operand must derive from LuaString
.
strcmp
in class LuaValue
rhs
- The right-hand-side value to perform the comparison withpublic int checkint()
LuaValue
LuaError
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
in class LuaValue
LuaValue.checkinteger()
,
LuaValue.checklong()
,
LuaValue.checkdouble()
,
LuaValue.optint(int)
,
LuaValue.TNUMBER
public LuaInteger checkinteger()
LuaValue
LuaError
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
in class LuaValue
LuaInteger
if numericLuaValue.checkint()
,
LuaValue.checklong()
,
LuaValue.checkdouble()
,
LuaValue.optinteger(LuaInteger)
,
LuaValue.TNUMBER
public long checklong()
LuaValue
LuaError
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
in class LuaValue
LuaValue.checkint()
,
LuaValue.checkinteger()
,
LuaValue.checkdouble()
,
LuaValue.optlong(long)
,
LuaValue.TNUMBER
public double checkdouble()
LuaValue
LuaError
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
in class LuaValue
LuaValue.checkint()
,
LuaValue.checkinteger()
,
LuaValue.checklong()
,
LuaValue.optdouble(double)
,
LuaValue.TNUMBER
public LuaNumber checknumber()
LuaValue
LuaError
Values that are LuaString
that can be converted to a number will be converted and returned.
checknumber
in class LuaValue
LuaNumber
if numericLuaValue.checkint()
,
LuaValue.checkinteger()
,
LuaValue.checkdouble()
,
LuaValue.checklong()
,
LuaValue.optnumber(LuaNumber)
,
LuaValue.TNUMBER
public LuaNumber checknumber(java.lang.String msg)
LuaValue
LuaError
Values that are LuaString
that can be converted to a number will be converted and returned.
checknumber
in class LuaValue
msg
- String message to supply if conversion fails
LuaNumber
if numericLuaValue.checkint()
,
LuaValue.checkinteger()
,
LuaValue.checkdouble()
,
LuaValue.checklong()
,
LuaValue.optnumber(LuaNumber)
,
LuaValue.TNUMBER
public 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 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
in class LuaValue
this
if it is a LuaNumber
or LuaString
that can be converted to a number,
otherwise LuaValue.NIL
LuaValue.tostring()
,
LuaValue.optnumber(LuaNumber)
,
LuaValue.checknumber()
,
LuaValue.toint()
,
LuaValue.todouble()
public boolean isnumber()
LuaValue
this
is a number
isnumber
in class LuaValue
number
,
meaning derives from LuaNumber
or derives from LuaString
and is convertible to a number,
otherwise falseLuaValue.tonumber()
,
LuaValue.checknumber()
,
LuaValue.optnumber(LuaNumber)
,
LuaValue.TNUMBER
public boolean isint()
LuaValue
this
is a number
and is representable by java int
without rounding or truncation
isint
in class LuaValue
number
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.TNUMBER
public boolean islong()
LuaValue
this
is a number
and is representable by java long
without rounding or truncation
islong
in class LuaValue
number
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.TNUMBER
public byte tobyte()
LuaValue
tobyte
in class LuaValue
LuaValue.toint()
,
LuaValue.todouble()
,
#optbyte(byte)
,
LuaValue.checknumber()
,
LuaValue.isnumber()
,
TNUMBER
public char tochar()
LuaValue
tochar
in class LuaValue
LuaValue.toint()
,
LuaValue.todouble()
,
#optchar(char)
,
LuaValue.checknumber()
,
LuaValue.isnumber()
,
TNUMBER
public double todouble()
LuaValue
todouble
in class LuaValue
LuaValue.toint()
,
LuaValue.tobyte()
,
LuaValue.tochar()
,
LuaValue.toshort()
,
LuaValue.tolong()
,
LuaValue.tofloat()
,
LuaValue.optdouble(double)
,
LuaValue.checknumber()
,
LuaValue.isnumber()
,
TNUMBER
public float tofloat()
LuaValue
tofloat
in class LuaValue
LuaValue.toint()
,
LuaValue.todouble()
,
#optfloat(float)
,
LuaValue.checknumber()
,
LuaValue.isnumber()
,
TNUMBER
public int toint()
LuaValue
toint
in class LuaValue
LuaValue.tobyte()
,
LuaValue.tochar()
,
LuaValue.toshort()
,
LuaValue.tolong()
,
LuaValue.tofloat()
,
LuaValue.todouble()
,
LuaValue.optint(int)
,
LuaValue.checknumber()
,
LuaValue.isnumber()
,
TNUMBER
public long tolong()
LuaValue
tolong
in class LuaValue
LuaValue.isint()
,
LuaValue.isinttype()
,
LuaValue.toint()
,
LuaValue.todouble()
,
LuaValue.optlong(long)
,
LuaValue.checknumber()
,
LuaValue.isnumber()
,
TNUMBER
public short toshort()
LuaValue
toshort
in class LuaValue
LuaValue.toint()
,
LuaValue.todouble()
,
#optshort(short)
,
LuaValue.checknumber()
,
LuaValue.isnumber()
,
TNUMBER
public double optdouble(double defval)
LuaValue
optdouble
in class LuaValue
defval
- double to return if this
is nil or none
this
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.TNUMBER
public int optint(int defval)
LuaValue
optint
in class LuaValue
defval
- int to return if this
is nil or none
this
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.TNUMBER
public LuaInteger optinteger(LuaInteger defval)
LuaValue
LuaInteger
optinteger
in class LuaValue
defval
- LuaInteger
to return if this
is nil or none
this
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.TNUMBER
public long optlong(long defval)
LuaValue
optlong
in class LuaValue
defval
- long to return if this
is nil or none
this
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.TNUMBER
public LuaNumber optnumber(LuaNumber defval)
LuaValue
LuaNumber
optnumber
in class LuaValue
defval
- LuaNumber
to return if this
is nil or none
this
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.TNUMBER
public LuaString optstring(LuaString defval)
LuaValue
LuaString
optstring
in class LuaValue
defval
- LuaString
to return if this
is nil or none
this
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.TSTRING
public 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 NIL
for all other cases.
This allows values to be tested for their "string-ness" without the penalty of throwing exceptions.
tostring
in class LuaValue
this
if it is a LuaString
or LuaNumber
,
otherwise NIL
LuaValue.tonumber()
,
LuaValue.tojstring()
,
LuaValue.optstring(LuaString)
,
LuaValue.checkstring()
,
LuaValue.toString()
public java.lang.String optjstring(java.lang.String defval)
LuaValue
optjstring
in class LuaValue
defval
- LuaString
to return if this
is nil or none
this
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.TSTRING
public LuaString strvalue()
LuaValue
LuaString
or LuaNumber
,
or throw a LuaError
if it is not
strvalue
in class LuaValue
LuaString
corresponding to the value if a string or numberpublic LuaString substring(int beginIndex, int endIndex)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class LuaValue
public LuaValue eq(LuaValue val)
LuaValue
EQ
.
eq
in class LuaValue
val
- The value to compare with.
TRUE
if values are comparable and (this == rhs)
,
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.EQ
public boolean eq_b(LuaValue val)
LuaValue
EQ
,
and return java boolean
eq_b
in class LuaValue
val
- 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.EQ
public boolean raweq(LuaValue val)
LuaValue
raweq
in class LuaValue
val
- The value to compare with.
(this == rhs)
, false otherwiseLuaValue.eq(LuaValue)
,
LuaValue.raweq(LuaUserdata)
,
LuaValue.raweq(LuaString)
,
LuaValue.raweq(double)
,
LuaValue.raweq(int)
,
LuaValue.EQ
public boolean raweq(LuaString s)
LuaValue
LuaString
value
without metatag processing.
raweq
in class LuaValue
s
- The LuaString
to compare with.
this
is a LuaString
and their byte sequences match,
otherwise falsepublic static boolean equals(LuaString a, int i, LuaString b, int j, int n)
public static boolean equals(byte[] a, int i, byte[] b, int j, int n)
public void write(java.io.DataOutputStream writer, int i, int len) throws java.io.IOException
java.io.IOException
public LuaValue len()
LuaValue
(#this)
including metatag processing as java int
len
in class LuaValue
public int length()
LuaValue
(#this)
including metatag processing as java int
length
in class LuaValue
LuaValue.toint()
public int luaByte(int index)
public int charAt(int index)
public java.lang.String checkjstring()
LuaValue
The 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
in class LuaValue
LuaValue.checkstring()
,
LuaValue.optjstring(String)
,
LuaValue.tojstring()
,
LuaValue.isstring()
,
LuaValue.TSTRING
public LuaString checkstring()
LuaValue
LuaError
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
in class LuaValue
LuaString
representation of the value if it is a LuaString
or LuaNumber
LuaValue.checkjstring()
,
LuaValue.optstring(LuaString)
,
LuaValue.tostring()
,
LuaValue.isstring()
,
LuaValue.TSTRING
public java.io.InputStream toInputStream()
InputStream
whose data matches the bytes in this LuaString
public 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 string
public int indexOf(LuaString s, int start)
s
- the string to search forstart
- the first index in the string
public int lastIndexOf(LuaString s)
s
- the string to search for
public static java.lang.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 convert
lengthAsUtf8(char[])
,
encodeToUtf8(char[], byte[], int)
,
isValidUtf8()
public static int lengthAsUtf8(char[] chars)
chars
- Array of unicode characters to be encoded as UTF-8
encodeToUtf8(char[], byte[], int)
,
decodeAsUtf8(byte[], int, int)
,
isValidUtf8()
public static void encodeToUtf8(char[] chars, 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-8bytes
- 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[], byte[], int)
,
decodeAsUtf8(byte[], int, int)
public LuaValue tonumber(int base)
base
- the base to use, such as 10
LuaValue.tonumber()
public double scannumber(int base)
base
- the base to use, such as 10
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |