Java Code Examples for org.luaj.vm2.LuaTable#keys()
The following examples show how to use
org.luaj.vm2.LuaTable#keys() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UIImageViewMethodMapper.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 6 votes |
/** * 开始帧动画 * * @param view * @param varargs 时间是秒而不是毫秒 * @return */ @Deprecated public LuaValue startAnimationImages(U view, Varargs varargs) {//TODO 支持UDImageView和UDBitmap final LuaTable imagesTable = varargs.opttable(2, null); final double duration = varargs.optdouble(3, 1f); boolean repeat = false; if (varargs.isnumber(4)) { repeat = varargs.optint(4, -1) > 0; } else { repeat = varargs.optboolean(4, false); } if (imagesTable != null && imagesTable.length() > 0) { final String[] images = new String[imagesTable.length()]; int i = 0; for (LuaValue key : imagesTable.keys()) { images[i++] = imagesTable.get(key).optjstring(null); } return view.startAnimationImages(images, (int) duration * 1000, repeat); } return view; }
Example 2
Source File: LuaUtils.java From HtmlNative with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: Utilities.java From Lukkit with MIT License | 6 votes |
public static Object convertTable(LuaTable table) { HashMap<Object, Object> returnedMap = new HashMap<>(); boolean isArray = true; LuaValue[] keys = table.keys(); for (LuaValue k : keys) { if (!isInteger(k.tojstring())) isArray = false; returnedMap.put(k.tojstring(), getObjectFromLuavalue(table.get(k))); } if (isArray) { List<Object> list = new ArrayList<>(); returnedMap.values().forEach(o -> list.add(o)); return list; } return returnedMap; }
Example 4
Source File: LuaUtil.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
/** * convert a table to map * * @param table * @return */ public static HashMap<String, String> toMap(LuaTable table) { if (table != null) { final HashMap<String, String> result = new HashMap<String, String>(); final LuaValue[] keys = table.keys(); for (LuaValue key : keys) { LuaValue luaValue = table.get(key); String value = null; if (luaValue.istable()) { value = JsonUtil.toString(luaValue); } else { if (luaValue instanceof LuaBoolean) { value = String.valueOf(luaValue.optboolean(false)); } else if (luaValue instanceof LuaInteger) { value = String.valueOf(luaValue.optint(0)); } else if (luaValue instanceof LuaDouble) { value = String.valueOf(luaValue.optdouble(0)); } else if (luaValue instanceof LuaString) { value = String.valueOf(luaValue.optstring(null)); } else { value = String.valueOf(luaValue); } } if (value != null) { result.put(key.optjstring(null), value); } } return result; } return null; }
Example 5
Source File: LuaInterpreter.java From claudb with MIT License | 5 votes |
private RedisToken convertLuaTable(LuaTable value) { List<RedisToken> tokens = new ArrayList<>(); for (LuaValue key : value.keys()) { tokens.add(convert(value.get(key))); } return array(tokens); }
Example 6
Source File: IoLib.java From XPrivacyLua with GNU General Public License v3.0 | 4 votes |
private void setLibInstance(LuaTable t) { LuaValue[] k = t.keys(); for ( int i=0, n=k.length; i<n; i++ ) ((IoLibV) t.get(k[i])).iolib = this; }
Example 7
Source File: IoLib.java From HtmlNative with Apache License 2.0 | 4 votes |
private void setLibInstance(LuaTable t) { LuaValue[] k = t.keys(); for ( int i=0, n=k.length; i<n; i++ ) ((IoLibV) t.get(k[i])).iolib = this; }
Example 8
Source File: IoLib.java From luaj with MIT License | 4 votes |
private void setLibInstance(LuaTable t) { LuaValue[] k = t.keys(); for ( int i=0, n=k.length; i<n; i++ ) ((IoLibV) t.get(k[i])).iolib = this; }