本文整理汇总了Java中org.luaj.vm2.Varargs.checkjstring方法的典型用法代码示例。如果您正苦于以下问题:Java Varargs.checkjstring方法的具体用法?Java Varargs.checkjstring怎么用?Java Varargs.checkjstring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.luaj.vm2.Varargs
的用法示例。
在下文中一共展示了Varargs.checkjstring方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
String s = args.checkjstring(1);
if ("collect".equals(s)) {
System.gc();
return ZERO;
} else if ("count".equals(s)) {
Runtime rt = Runtime.getRuntime();
long used = rt.totalMemory() - rt.freeMemory();
return varargsOf(valueOf(used / 1024.), valueOf(used % 1024));
} else if ("step".equals(s)) {
System.gc();
return LuaValue.TRUE;
} else {
this.argerror("gc op");
}
return NIL;
}
示例2: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
String name = args.checkjstring(1);
String path = args.checkjstring(2);
String sep = args.optjstring(3, ".");
String rep = args.optjstring(4, FILE_SEP);
// check the path elements
int e = -1;
int n = path.length();
StringBuffer sb = null;
name = name.replace(sep.charAt(0), rep.charAt(0));
while (e < n) {
// find next template
int b = e + 1;
e = path.indexOf(';', b);
if (e < 0)
e = path.length();
String template = path.substring(b, e);
// create filename
int q = template.indexOf('?');
String filename = template;
if (q >= 0) {
filename = template.substring(0, q) + name + template.substring(q + 1);
}
// try opening the file
InputStream is = globals.getLuaResourceFinder().findResource(filename);//modify by song
if (is != null) {
try {
is.close();
} catch (java.io.IOException ioe) {
}
return valueOf(filename);
}
// report error
if (sb == null)
sb = new StringBuffer();
sb.append("\n\t" + filename);
}
return varargsOf(NIL, valueOf(sb.toString()));
}
示例3: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
String name = args.checkjstring(1);
String path = args.checkjstring(2);
String sep = args.optjstring(3, ".");
String rep = args.optjstring(4, FILE_SEP);
// check the path elements
int e = -1;
int n = path.length();
StringBuffer sb = null;
name = name.replace(sep.charAt(0), rep.charAt(0));
while ( e < n ) {
// find next template
int b = e+1;
e = path.indexOf(';',b);
if ( e < 0 )
e = path.length();
String template = path.substring(b,e);
// create filename
int q = template.indexOf('?');
String filename = template;
if ( q >= 0 ) {
filename = template.substring(0,q) + name + template.substring(q+1);
}
// try opening the file
InputStream is = globals.finder.findResource(filename);
if (is != null) {
try { is.close(); } catch ( java.io.IOException ioe ) {}
return valueOf(filename);
}
// report error
if ( sb == null )
sb = new StringBuffer();
sb.append( "\n\t"+filename );
}
return varargsOf(NIL, valueOf(sb.toString()));
}