public class PramaryBean {
private String praName;
private String reName;
private int valueType;
private String valueTypeCN;
private int length;
private int precision;
private boolean replaceable;
}
public static List<PramaryBean> getValues(String javascript){
List<PramaryBean> plist = new ArrayList<PramaryBean>();
Context jscx;
Scriptable jsscope;
// Making Refresh to get Active Script State
String scr = javascript;
jscx = ContextFactory.getGlobal().enterContext();
jscx.setOptimizationLevel( -1 );
jsscope = jscx.initStandardObjects( null, false );
ScriptOrFnNode tree = parseVariables( jscx, jsscope, scr, "script", 1, null );
for ( int i = 0; i < tree.getParamAndVarCount(); i++ ) {
String varname = tree.getParamOrVarName( i );
if ( !varname.equalsIgnoreCase( "row" ) && !varname.equalsIgnoreCase( "trans_Status" ) ) {
int type = ValueMetaInterface.TYPE_STRING;
int length = -1, precision = -1;
Object result = jsscope.get( varname, jsscope );
if ( result != null ) {
String classname = result.getClass().getName();
if ( classname.equalsIgnoreCase( "java.lang.Byte" ) ) {
// MAX = 127
type = ValueMetaInterface.TYPE_INTEGER;
length = 3;
precision = 0;
} else if ( classname.equalsIgnoreCase( "java.lang.Integer" ) ) {
// MAX = 2147483647
type = ValueMetaInterface.TYPE_INTEGER;
length = 9;
precision = 0;
} else if ( classname.equalsIgnoreCase( "java.lang.Long" ) ) {
// MAX = 9223372036854775807
type = ValueMetaInterface.TYPE_INTEGER;
length = 18;
precision = 0;
} else if ( classname.equalsIgnoreCase( "java.lang.Double" ) ) {
type = ValueMetaInterface.TYPE_NUMBER;
length = 16;
precision = 2;
} else if ( classname.equalsIgnoreCase( "org.mozilla.javascript.NativeDate" )
|| classname.equalsIgnoreCase( "java.util.Date" ) ) {
type = ValueMetaInterface.TYPE_DATE;
} else if ( classname.equalsIgnoreCase( "java.lang.Boolean" ) ) {
type = ValueMetaInterface.TYPE_BOOLEAN;
}
}
PramaryBean p = new PramaryBean();
p.setPraName(varname);
p.setReName(varname);
p.setValueType(type);
p.setValueTypeCN(ValueMeta.getTypeDesc( type ));
p.setLength(length);
p.setPrecision(precision);
p.setReplaceable(false);
plist.add(p);
System.out.println("1:" + varname);
System.out.println("2:" + "");
System.out.println("3:" + type);
System.out.println("3:" + ValueMeta.getTypeDesc( type ));
System.out.println("4:" + (length >= 0 ? ( "" + length ) : "") );
System.out.println("5:" + (precision >= 0 ? ( "" + precision ) : "") );
}
}
return plist;
}