com.loocme.sys.jni.AppConstJni Maven / Gradle / Ivy
package com.loocme.sys.jni;
import java.util.HashMap;
import java.util.Map;
import com.loocme.sys.util.ArrayUtil;
import com.loocme.sys.util.StringUtil;
import com.loocme.sys.util.SystemUtil;
/**
* @author liuchi
*/
public class AppConstJni
{
public native String getConsts();
static
{
System.load(SystemUtil.getClassesPath() + "javaappconst"
+ SystemUtil.getCDllSuffix());
}
private static Map constsMap = null;
private static byte[] by = new byte[1024];
private static void loadConstsMap()
{
constsMap = new HashMap(16);
String str = new AppConstJni().getConsts();
String[] contentArr = str.split("\\|\\|");
if (ArrayUtil.isNotNull(contentArr))
{
for (int i = 0; i < contentArr.length; i++)
{
String[] mapArr = contentArr[i].split("__");
if (mapArr.length == 2)
{
constsMap.put(mapArr[0], mapArr[1]);
}
}
}
}
public static String getString(String key)
{
if (null == constsMap)
{
synchronized (by)
{
loadConstsMap();
}
}
return constsMap.get(key);
}
public static int getInteger(String key)
{
return StringUtil.getInteger(getString(key));
}
public static long getLong(String key)
{
return StringUtil.getLong(getString(key));
}
public static float getFloat(String key)
{
return StringUtil.getFloat(getString(key));
}
public static double getDouble(String key)
{
return StringUtil.getDouble(getString(key));
}
public static boolean getBoolean(String key)
{
return StringUtil.getBoolean(getString(key));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy