當前位置: 首頁>>代碼示例>>Java>>正文


Java LuaValue.isstring方法代碼示例

本文整理匯總了Java中org.luaj.vm2.LuaValue.isstring方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.isstring方法的具體用法?Java LuaValue.isstring怎麽用?Java LuaValue.isstring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.luaj.vm2.LuaValue的用法示例。


在下文中一共展示了LuaValue.isstring方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: invoke

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs invoke(Varargs args) {
    LuaString name = args.checkstring(1);
    InputStream is = null;

    // get package path
    LuaValue path = package_.get(_PATH);
    if (!path.isstring())
        return valueOf("package.path is not a string");

    // get the searchpath function.
    Varargs v = package_.get(_SEARCHPATH).invoke(varargsOf(name, path));

    // Did we get a result?
    if (!v.isstring(1))
        return v.arg(2).tostring();
    LuaString filename = v.arg1().strvalue();

    // Try to load the file.
    v = globals.loadfile(filename.tojstring());
    if (v.arg1().isfunction())
        return LuaValue.varargsOf(v.arg1(), filename);

    // report error
    return varargsOf(NIL, valueOf("'" + filename + "': " + v.arg(2).tojstring()));
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:26,代碼來源:PackageLib.java

示例2: invoke

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs invoke(Varargs args) {
	LuaString name = args.checkstring(1);
	InputStream is = null;
			
	// get package path
	LuaValue path = package_.get(_PATH);
	if ( ! path.isstring() ) 
		return valueOf("package.path is not a string");

	// get the searchpath function.
	Varargs v = package_.get(_SEARCHPATH).invoke(varargsOf(name, path));
	
	// Did we get a result?
	if (!v.isstring(1))
		return v.arg(2).tostring();
	LuaString filename = v.arg1().strvalue();

	// Try to load the file.
	v = globals.loadfile(filename.tojstring()); 
	if ( v.arg1().isfunction() )
		return LuaValue.varargsOf(v.arg1(), filename);
	
	// report error
	return varargsOf(NIL, valueOf("'"+filename+"': "+v.arg(2).tojstring()));
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:26,代碼來源:PackageLib.java

示例3: luaTableToMap

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
static Map<String, String> luaTableToMap(LuaTable value) {
    Map<String, String> params = new HashMap<>();

    LuaValue[] keys = value.keys();

    for (LuaValue k : keys) {
        if (k.isstring()) {
            LuaValue v = value.get(k);
            if (v.isstring()) {
                params.put(k.tojstring(), v.tojstring());
            }
        }
    }

    return params;
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:17,代碼來源:LuaUtils.java

示例4: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public final LuaValue call(LuaValue message) {
    if (message.isstring() && mc.player != null) {
        mc.player.sendChatMessage(message.tojstring());
        return TRUE;
    }
    return FALSE;
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:9,代碼來源:mc.java

示例5: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public LuaValue call(LuaValue event, LuaValue identifier, LuaValue function) {
    if (!event.isstring() || !identifier.isstring() || !function.isfunction()) {
        return FALSE;
    }
    LuaHandler.getHandler().getHookManager().add(event.tojstring(), identifier.tojstring(), (LuaFunction) function);
    return TRUE;
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:9,代碼來源:hook.java

示例6: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public final LuaValue call(LuaValue text, LuaValue x, LuaValue y, LuaValue color) {
    if (!text.isstring() || !x.isnumber() || !y.isnumber() || !color.isnumber())
        return NIL;

    return LuaInteger.valueOf(mc.fontRenderer.drawString(text.tojstring(), x.tofloat(), y.tofloat(), color.toint(), true));
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:8,代碼來源:render.java

示例7: add_value

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public void add_value(Buffer lbuf, int soffset, int end, LuaValue repl) {
    switch (repl.type()) {
        case LuaValue.TSTRING:
        case LuaValue.TNUMBER:
            add_s(lbuf, repl.strvalue(), soffset, end);
            return;

        case LuaValue.TFUNCTION:
            repl = repl.invoke(push_captures(true, soffset, end)).arg1();
            break;

        case LuaValue.TTABLE:
            // Need to call push_onecapture here for the error checking
            repl = repl.get(push_onecapture(0, soffset, end));
            break;

        default:
            error("bad argument: string/function/table expected");
            return;
    }

    if (!repl.toboolean()) {
        repl = s.substring(soffset, end);
    } else if (!repl.isstring()) {
        error("invalid replacement value (a " + repl.typename() + ")");
    }
    lbuf.append(repl.strvalue());
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:29,代碼來源:StringLib.java

示例8: fromType

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public static Object fromType(LuaValue luaValue) {
    if (luaValue.isboolean()) {
        return coerce(luaValue, Boolean.class);
    }
    if (luaValue.isint()) {
        return coerce(luaValue, Integer.class);
    }
    if (luaValue.isnumber()) {
        return coerce(luaValue, Double.class);
    }
    if (luaValue.isstring()) {
        return LuaLogger.colorString(luaValue.tojstring());
    }
    return null;
}
 
開發者ID:LukkitPlus,項目名稱:Lukkit,代碼行數:16,代碼來源:LuaAccessor.java

示例9: add_value

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public void add_value( Buffer lbuf, int soffset, int end, LuaValue repl ) {
	switch ( repl.type() ) {
	case LuaValue.TSTRING:
	case LuaValue.TNUMBER:
		add_s( lbuf, repl.strvalue(), soffset, end );
		return;
		
	case LuaValue.TFUNCTION:
		repl = repl.invoke( push_captures( true, soffset, end ) ).arg1();
		break;
		
	case LuaValue.TTABLE:
		// Need to call push_onecapture here for the error checking
		repl = repl.get( push_onecapture( 0, soffset, end ) );
		break;
		
	default:
		error( "bad argument: string/function/table expected" );
		return;
	}
	
	if ( !repl.toboolean() ) {
		repl = s.substring( soffset, end );
	} else if ( ! repl.isstring() ) {
		error( "invalid replacement value (a "+repl.typename()+")" );
	}
	lbuf.append( repl.strvalue() );
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:29,代碼來源:StringLib.java

示例10: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue arg1, LuaValue arg2) {
	throw arg1.isnil()? new LuaError(null, arg2.optint(1)): 
		arg1.isstring()? new LuaError(arg1.tojstring(), arg2.optint(1)): 
			new LuaError(arg1);
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:6,代碼來源:BaseLib.java

示例11: _io_input

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs _io_input(LuaValue file) {
	infile = file.isnil()? input(): 
			file.isstring()? ioopenfile(FTYPE_NAMED, file.checkjstring(),"r"):
			checkfile(file);
	return infile;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:7,代碼來源:IoLib.java

示例12: _io_output

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs _io_output(LuaValue filename) {
	outfile = filename.isnil()? output(): 
			  filename.isstring()? ioopenfile(FTYPE_NAMED, filename.checkjstring(),"w"):
			  checkfile(filename);
	return outfile;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:7,代碼來源:IoLib.java

示例13: initSpannableStringBuilder

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
private void initSpannableStringBuilder(LuaValue text, LuaValue config) {
    SpannableStringBuilder spannableStringBuilder = getSpannableStringBuilder();
    if (text != null && text.isstring()) {
        spannableStringBuilder = spannableStringBuilder.append(text.tojstring());
    }

    if (spannableStringBuilder.length() > 0) {
        if (config != null && config.istable()) {
            final int end = spannableStringBuilder.length();
            final int fontSize = DimenUtil.spToPx(config.get("fontSize").optint(-1));
            final Integer fontColor = ColorUtil.parse(LuaUtil.getValue(config, "fontColor"));
            final String fontName = config.get("fontName").optjstring(null);

            final LuaValue weightValue = config.get("fontWeight");
            final int fontWeight = LuaUtil.isNumber(weightValue) ? weightValue.optint(UDFontWeight.WEIGHT_NORMAL_INT) : UDFontWeight.getValue(weightValue.optjstring(UDFontWeight.WEIGHT_NORMAL));

            final LuaValue styleValue = config.get("fontStyle");
            final int fontStyle = LuaUtil.isNumber(styleValue) ? styleValue.optint(Typeface.NORMAL) : UDFontStyle.getValue(styleValue.optjstring(UDFontStyle.STYLE_NORMAL));

            final Integer backgroundColor = ColorUtil.parse(LuaUtil.getValue(config, "backgroundColor"));
            final boolean strikethrough = config.get("strikethrough").optboolean(false);
            final boolean underline = config.get("underline").optboolean(false);

            if (fontSize != -1) {//字體大小
                spannableStringBuilder.setSpan(new AbsoluteSizeSpan(fontSize), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (fontColor != null) {//字體顏色
                spannableStringBuilder.setSpan(new ForegroundColorSpan(fontColor), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (fontName != null && getLuaResourceFinder() != null) {//字體
                spannableStringBuilder.setSpan(new CustomTypefaceSpan(fontName, getLuaResourceFinder().findTypeface(fontName)), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (fontWeight != -1 && fontWeight > UDFontWeight.WEIGHT_NORMAL_INT) {//文字Weight
                spannableStringBuilder.setSpan(new WeightStyleSpan(fontWeight), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (fontStyle != -1 && (fontStyle >= Typeface.NORMAL && fontStyle <= Typeface.BOLD_ITALIC)) {//文字樣式
                spannableStringBuilder.setSpan(new StyleSpan(fontStyle), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (backgroundColor != null) {//背景色
                spannableStringBuilder.setSpan(new BackgroundColorSpan(backgroundColor), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (strikethrough) {//刪除線
                spannableStringBuilder.setSpan(new StrikethroughSpan(), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (underline) {//下劃線
                spannableStringBuilder.setSpan(new UnderlineSpan(), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:58,代碼來源:UDSpannableString.java

示例14: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue arg1, LuaValue arg2) {
    throw arg1.isnil() ? new LuaError(null, arg2.optint(1)) : arg1.isstring() ? new
            LuaError(arg1.tojstring(), arg2.optint(1)) : new LuaError(arg1);
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:5,代碼來源:BaseLib.java


注:本文中的org.luaj.vm2.LuaValue.isstring方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。