@Test public void jsToString_String() throws Exception { assertEquals( "qwerty", JavaScriptUtils.jsToString( "qwerty", String.class.getName() ) ); }
public static String jsToString( Object value, String classType ) { if ( classType.equalsIgnoreCase( "org.mozilla.javascript.NativeJavaObject" ) || classType.equalsIgnoreCase( "org.mozilla.javascript.Undefined" ) ) { try { Value v = (Value) Context.jsToJava( value, Value.class ); return v.toString(); } catch ( Exception ev ) { return Context.toString( value ); } } else { return Context.toString( value ); } }
JavaScriptUtils { public static String jsToString( Object value, String classType ) { if ( classType.equalsIgnoreCase( "org.mozilla.javascript.NativeJavaObject" ) || classType.equalsIgnoreCase( "org.mozilla.javascript.Undefined" ) ) { try { Value v = (Value) Context.jsToJava( value, Value.class ); return v.toString(); } catch ( Exception ev ) { return Context.toString( value ); } } else { return Context.toString( value ); } } }
JavaScriptUtils { public static String jsToString( Object value, String classType ) { if ( classType.equalsIgnoreCase( "org.mozilla.javascript.NativeJavaObject" ) || classType.equalsIgnoreCase( "org.mozilla.javascript.Undefined" ) ) { try { Value v = (Value) Context.jsToJava( value, Value.class ); return v.toString(); } catch ( Exception ev ) { return Context.toString( value ); } } else { return Context.toString( value ); } }  }
JavaScriptUtils { public static String jsToString( Object value, String classType ) { if ( classType.equalsIgnoreCase( "org.mozilla.javascript.NativeJavaObject" ) || classType.equalsIgnoreCase( "org.mozilla.javascript.Undefined" ) ) { try { Value v = (Value) Context.jsToJava( value, Value.class ); return v.toString(); } catch ( Exception ev ) { return Context.toString( value ); } } else { return Context.toString( value ); } }  static Object convertFromJs( Object value, int type, String fieldName ); static Number jsToNumber( Object value, String classType ); static Long jsToInteger( Object value, Class<?> clazz ); static String jsToString( Object value, String classType ); static Date jsToDate( Object value, String classType ); static BigDecimal jsToBigNumber( Object value, String classType ); }
JavaScriptUtils { public static String jsToString( Object value, String classType ) { if ( classType.equalsIgnoreCase( "org.mozilla.javascript.NativeJavaObject" ) || classType.equalsIgnoreCase( "org.mozilla.javascript.Undefined" ) ) { try { Value v = (Value) Context.jsToJava( value, Value.class ); return v.toString(); } catch ( Exception ev ) { return Context.toString( value ); } } else { return Context.toString( value ); } }  static Object convertFromJs( Object value, int type, String fieldName ); static Number jsToNumber( Object value, String classType ); static Long jsToInteger( Object value, Class<?> clazz ); static String jsToString( Object value, String classType ); static Date jsToDate( Object value, String classType ); static BigDecimal jsToBigNumber( Object value, String classType );  }