org.luaj.vm2
Class LuaString

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

public class LuaString
extends LuaValue


Field Summary
 byte[] m_bytes
           
 int m_length
           
 int m_offset
           
static LuaValue s_metatable
           
 
Fields inherited from class org.luaj.vm2.LuaValue
CALL, EMPTYSTRING, FALSE, INDEX, METATABLE, MINUSONE, MODE, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, ZERO
 
Method Summary
 LuaValue add(double lhs)
           
 LuaValue add(LuaValue rhs)
           
 int charAt(int index)
           
 double checkdouble()
           
 int checkint()
           
 LuaInteger checkinteger()
           
 java.lang.String checkjstring()
           
 long checklong()
           
 LuaNumber checknumber()
           
 LuaNumber checknumber(java.lang.String msg)
           
 LuaString checkstring()
           
 java.lang.String concat_s(LuaValue rhs)
           
 java.lang.String concatTo_s(java.lang.String lhs)
           
 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(LuaValue rhs)
           
 LuaValue divInto(double lhs)
           
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(LuaString s)
           
 boolean eq_b(LuaValue val)
           
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)
           
 LuaValue getmetatable()
           
 boolean gt_b(double rhs)
           
 boolean gt_b(int rhs)
           
 boolean gt_b(LuaValue rhs)
           
 LuaValue gt(LuaValue rhs)
           
 boolean gteq_b(double rhs)
           
 boolean gteq_b(int rhs)
           
 boolean gteq_b(LuaValue rhs)
           
 LuaValue gteq(LuaValue rhs)
           
 int hashCode()
           
 int indexOf(byte b, int start)
           
 int indexOf(LuaString s, int start)
           
 int indexOfAny(LuaString accept)
          Java version of strpbrk, which is a terribly named C function.
 boolean isint()
           
 boolean islong()
           
 boolean isnumber()
           
 boolean isstring()
           
 boolean isValidUtf8()
           
 int lastIndexOf(LuaString s)
           
 LuaValue len()
           
 int length()
           
static int lengthAsUtf8(char[] chars)
          Count the number of bytes required to encode the string as UTF-8.
 boolean lt_b(double rhs)
           
 boolean lt_b(int rhs)
           
 boolean lt_b(LuaValue rhs)
           
 LuaValue lt(LuaValue rhs)
           
 boolean lteq_b(double rhs)
           
 boolean lteq_b(int rhs)
           
 boolean lteq_b(LuaValue rhs)
           
 LuaValue lteq(LuaValue rhs)
           
 int luaByte(int index)
           
 LuaValue mod(LuaValue rhs)
           
 LuaValue modFrom(double lhs)
           
 LuaValue mul(double lhs)
           
 LuaValue mul(int lhs)
           
 LuaValue mul(LuaValue rhs)
           
 LuaValue neg()
           
 double optdouble(double defval)
           
 int optint(int defval)
           
 LuaInteger optinteger(LuaInteger defval)
           
 java.lang.String optjstring(java.lang.String defval)
           
 long optlong(long defval)
           
 LuaNumber optnumber(LuaNumber defval)
           
 LuaString optstring(LuaString defval)
           
 LuaValue pow(LuaValue rhs)
           
 LuaValue powWith(double lhs)
           
 LuaValue powWith(int lhs)
           
 int strcmp(LuaString rhs)
           
 int strcmp(LuaValue lhs)
           
 LuaString strvalue()
           
 LuaValue sub(LuaValue rhs)
           
 LuaValue subFrom(double lhs)
           
 LuaString substring(int beginIndex, int endIndex)
           
 byte tobyte()
           
 char tochar()
           
 double todouble()
           
 float tofloat()
           
 java.io.InputStream toInputStream()
           
 int toint()
           
 java.lang.String tojstring()
           
 long tolong()
           
 LuaValue tonumber()
           
 LuaValue tonumber(int base)
          convert to a number using a supplied base, or NIL if it can't be converted
 short toshort()
           
 LuaValue tostring()
           
 int type()
           
 java.lang.String typename()
           
static LuaString valueOf(byte[] bytes)
           
static LuaString valueOf(byte[] bytes, int off, int len)
           
static LuaString valueOf(char[] bytes)
           
static LuaString valueOf(java.lang.String string)
           
 void write(java.io.DataOutputStream writer, int i, int len)
           
 
Methods inherited from class org.luaj.vm2.LuaValue
add, and, arg, arg1, argerror, argerror, aritherror, aritherror, assert_, call, call, call, call, callerror, checkboolean, checkclosure, checkfunction, checknotnil, checkString, checktable, checkthread, checkuserdata, checkuserdata, checkvalidkey, compareerror, compareerror, concat, eq_b, eq_b, eq, error, get, get, getfenv, getn, gettable, incr, inext, invoke, invoke, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isfunction, isinttype, isnil, istable, isthread, isuserdata, isuserdata, lenerror, listOf, listOf, load, metatag, method, method, method, method, method, method, narg, neq_b, neq_b, neq_b, neq, next, not, onInvoke, optboolean, optclosure, optfunction, optString, opttable, optthread, optuserdata, optuserdata, optvalue, or, presize, rawget, rawget, rawget, rawset, rawset, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, set, set, setfenv, setmetatable, settable, strongvalue, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, testfor_b, testfor_b, toboolean, toString, touserdata, touserdata, typerror, unimplemented, userdataOf, userdataOf, 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, 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, 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

s_metatable

public static LuaValue s_metatable

m_bytes

public final byte[] m_bytes

m_offset

public final int m_offset

m_length

public final int m_length
Method Detail

valueOf

public static LuaString valueOf(java.lang.String string)

valueOf

public static LuaString valueOf(byte[] bytes,
                                int off,
                                int len)

valueOf

public static LuaString valueOf(char[] bytes)

valueOf

public static LuaString valueOf(byte[] bytes)

isstring

public boolean isstring()
Overrides:
isstring in class LuaValue

getmetatable

public LuaValue getmetatable()
Overrides:
getmetatable in class LuaValue

type

public int type()
Specified by:
type in class LuaValue

typename

public java.lang.String typename()
Specified by:
typename in class LuaValue

tojstring

public java.lang.String tojstring()
Overrides:
tojstring in class LuaValue

get

public LuaValue get(LuaValue key)
Overrides:
get in class LuaValue

neg

public LuaValue neg()
Overrides:
neg in class LuaValue

add

public LuaValue add(LuaValue rhs)
Overrides:
add in class LuaValue

add

public LuaValue add(double lhs)
Overrides:
add in class LuaValue

sub

public LuaValue sub(LuaValue rhs)
Overrides:
sub in class LuaValue

subFrom

public LuaValue subFrom(double lhs)
Overrides:
subFrom in class LuaValue

mul

public LuaValue mul(LuaValue rhs)
Overrides:
mul in class LuaValue

mul

public LuaValue mul(double lhs)
Overrides:
mul in class LuaValue

mul

public LuaValue mul(int lhs)
Overrides:
mul in class LuaValue

pow

public LuaValue pow(LuaValue rhs)
Overrides:
pow in class LuaValue

powWith

public LuaValue powWith(double lhs)
Overrides:
powWith in class LuaValue

powWith

public LuaValue powWith(int lhs)
Overrides:
powWith in class LuaValue

div

public LuaValue div(LuaValue rhs)
Overrides:
div in class LuaValue

divInto

public LuaValue divInto(double lhs)
Overrides:
divInto in class LuaValue

mod

public LuaValue mod(LuaValue rhs)
Overrides:
mod in class LuaValue

modFrom

public LuaValue modFrom(double lhs)
Overrides:
modFrom in class LuaValue

lt

public LuaValue lt(LuaValue rhs)
Overrides:
lt in class LuaValue

lt_b

public boolean lt_b(LuaValue rhs)
Overrides:
lt_b in class LuaValue

lt_b

public boolean lt_b(int rhs)
Overrides:
lt_b in class LuaValue

lt_b

public boolean lt_b(double rhs)
Overrides:
lt_b in class LuaValue

lteq

public LuaValue lteq(LuaValue rhs)
Overrides:
lteq in class LuaValue

lteq_b

public boolean lteq_b(LuaValue rhs)
Overrides:
lteq_b in class LuaValue

lteq_b

public boolean lteq_b(int rhs)
Overrides:
lteq_b in class LuaValue

lteq_b

public boolean lteq_b(double rhs)
Overrides:
lteq_b in class LuaValue

gt

public LuaValue gt(LuaValue rhs)
Overrides:
gt in class LuaValue

gt_b

public boolean gt_b(LuaValue rhs)
Overrides:
gt_b in class LuaValue

gt_b

public boolean gt_b(int rhs)
Overrides:
gt_b in class LuaValue

gt_b

public boolean gt_b(double rhs)
Overrides:
gt_b in class LuaValue

gteq

public LuaValue gteq(LuaValue rhs)
Overrides:
gteq in class LuaValue

gteq_b

public boolean gteq_b(LuaValue rhs)
Overrides:
gteq_b in class LuaValue

gteq_b

public boolean gteq_b(int rhs)
Overrides:
gteq_b in class LuaValue

gteq_b

public boolean gteq_b(double rhs)
Overrides:
gteq_b in class LuaValue

concat_s

public java.lang.String concat_s(LuaValue rhs)
Overrides:
concat_s in class LuaValue

concatTo_s

public java.lang.String concatTo_s(java.lang.String lhs)
Overrides:
concatTo_s in class LuaValue

strcmp

public int strcmp(LuaValue lhs)
Overrides:
strcmp in class LuaValue

strcmp

public int strcmp(LuaString rhs)
Overrides:
strcmp in class LuaValue

checkint

public int checkint()
Overrides:
checkint in class LuaValue

checkinteger

public LuaInteger checkinteger()
Overrides:
checkinteger in class LuaValue

checklong

public long checklong()
Overrides:
checklong in class LuaValue

checkdouble

public double checkdouble()
Overrides:
checkdouble in class LuaValue

checknumber

public LuaNumber checknumber()
Overrides:
checknumber in class LuaValue

checknumber

public LuaNumber checknumber(java.lang.String msg)
Overrides:
checknumber in class LuaValue

tonumber

public LuaValue tonumber()
Overrides:
tonumber in class LuaValue
Returns:
NIL if not a number or convertible to a number

isnumber

public boolean isnumber()
Overrides:
isnumber in class LuaValue

isint

public boolean isint()
Overrides:
isint in class LuaValue

islong

public boolean islong()
Overrides:
islong in class LuaValue

tobyte

public byte tobyte()
Overrides:
tobyte in class LuaValue

tochar

public char tochar()
Overrides:
tochar in class LuaValue

todouble

public double todouble()
Overrides:
todouble in class LuaValue

tofloat

public float tofloat()
Overrides:
tofloat in class LuaValue

toint

public int toint()
Overrides:
toint in class LuaValue

tolong

public long tolong()
Overrides:
tolong in class LuaValue

toshort

public short toshort()
Overrides:
toshort in class LuaValue

optdouble

public double optdouble(double defval)
Overrides:
optdouble in class LuaValue

optint

public int optint(int defval)
Overrides:
optint in class LuaValue

optinteger

public LuaInteger optinteger(LuaInteger defval)
Overrides:
optinteger in class LuaValue

optlong

public long optlong(long defval)
Overrides:
optlong in class LuaValue

optnumber

public LuaNumber optnumber(LuaNumber defval)
Overrides:
optnumber in class LuaValue

optstring

public LuaString optstring(LuaString defval)
Overrides:
optstring in class LuaValue

tostring

public LuaValue tostring()
Overrides:
tostring in class LuaValue
Returns:
NIL if not a string or number

optjstring

public java.lang.String optjstring(java.lang.String defval)
Overrides:
optjstring in class LuaValue

strvalue

public LuaString strvalue()
Overrides:
strvalue in class LuaValue

substring

public LuaString substring(int beginIndex,
                           int endIndex)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class LuaValue

eq_b

public boolean eq_b(LuaString s)
Overrides:
eq_b in class LuaValue

eq_b

public boolean eq_b(LuaValue val)
Overrides:
eq_b in class LuaValue

equals

public static boolean equals(LuaString a,
                             int i,
                             LuaString b,
                             int j,
                             int n)

equals

public static boolean equals(byte[] a,
                             int i,
                             byte[] b,
                             int j,
                             int n)

write

public void write(java.io.DataOutputStream writer,
                  int i,
                  int len)
           throws java.io.IOException
Throws:
java.io.IOException

len

public LuaValue len()
Overrides:
len in class LuaValue

length

public int length()
Overrides:
length in class LuaValue

luaByte

public int luaByte(int index)

charAt

public int charAt(int index)

checkjstring

public java.lang.String checkjstring()
Overrides:
checkjstring in class LuaValue

checkstring

public LuaString checkstring()
Overrides:
checkstring in class LuaValue

toInputStream

public java.io.InputStream toInputStream()

copyInto

public void copyInto(int strOffset,
                     byte[] bytes,
                     int arrayOffset,
                     int len)
Copy the bytes of the string into the given byte array.


indexOfAny

public int indexOfAny(LuaString accept)
Java version of strpbrk, which is a terribly named C function.


indexOf

public int indexOf(byte b,
                   int start)

indexOf

public int indexOf(LuaString s,
                   int start)

lastIndexOf

public int lastIndexOf(LuaString s)

decodeAsUtf8

public static java.lang.String decodeAsUtf8(byte[] bytes,
                                            int offset,
                                            int length)
Convert to Java String interpreting as utf8 characters


lengthAsUtf8

public static int lengthAsUtf8(char[] chars)
Count the number of bytes required to encode the string as UTF-8.


encodeToUtf8

public 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. The string should be measured first with lengthAsUtf8 to make sure the given byte array is large enough.


isValidUtf8

public boolean isValidUtf8()

tonumber

public LuaValue tonumber(int base)
convert to a number using a supplied base, or NIL if it can't be converted

Returns:
IntValue, DoubleValue, or NIL depending on the content of the string.


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