private static Pattern paramsPattern = Pattern.compile("%\\{(.*?)\\}");
public FBSDefaultObject extractParams(String[] ss) throws InterpretException {
PlaygroundEnvironment env = PlaygroundEnvironment.getCurrentEnvironment();
ArrayObject params = new ArrayObject(JavaScriptUtil.getJSContext());
if(ss!=null) {
for(int i=0; i<ss.length; i++) {
Matcher paramsMatcher = paramsPattern.matcher(ss[i]);
while(paramsMatcher.find()){
String s = paramsMatcher.group(1);
String[] all = StringUtil.splitString(s, '|', true);
FBSDefaultObject o = new ObjectObject(JavaScriptUtil.getJSContext());
for(int j=0; j<all.length; j++) {
String[] p = StringUtil.splitString(all[j], '=', true);
if(p.length==1) {
o.put("name", FBSString.get(p[0]));
} else if(p.length>1) {
o.put(p[0],FBSString.get(p[1]));
}
}
FBSString propName = (FBSString)o.get("name");
if(propName!=null) {
String v = env.getPropertyValueByName(propName.stringValue());
if(StringUtil.isNotEmpty(v)) {
o.put("value", FBSString.get(v));
}
}
params.addArrayValue(o);
}
}
}
return params;
}