public static void fun3(ScriptObjectMirror mirror) { System.out.println(mirror.getClassName() + ": " + Arrays.toString(mirror.getOwnKeys(true))); }
private static boolean isDateType( final ScriptObjectMirror value ) { return "Date".equalsIgnoreCase( value.getClassName() ); }
/** * @since 8.4 */ public static Calendar unwrapDate(ScriptObjectMirror jso) { if (!JAVASCRIPT_DATE_CLASS_TYPE.equals(jso.getClassName())) { throw new IllegalArgumentException("JavaScript input is not a Date!"); } Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(((Double) jso.callMember("getTime")).longValue()); return cal; }
public static void fun3(ScriptObjectMirror mirror) { System.out.println(mirror.getClassName() + ": " + Arrays.toString(mirror.getOwnKeys(true))); }
public static Object unwrap(ScriptObjectMirror jso) { if (jso.isArray()) { return unwrapList(jso); } else if (JAVASCRIPT_MAP_CLASS_TYPE.equals(jso.getClassName())) { return unwrapMap(jso); } else if (JAVASCRIPT_DATE_CLASS_TYPE.equals(jso.getClassName())) { return unwrapDate(jso); } else if (JAVASCRIPT_GLOBAL_CLASS_TYPE.equals(jso.getClassName())) { return null; } else if (JAVASCRIPT_FUNCTION_CLASS_TYPE.equals(jso.getClassName())) { return null; } else { throw new UnsupportedOperationException(jso.getClassName() + " is not supported!"); } }
public static Map<String, Object> unwrapMap(ScriptObjectMirror jso) { if (!JAVASCRIPT_MAP_CLASS_TYPE.equals(jso.getClassName())) { throw new IllegalArgumentException("JavaScript input is not an Object!"); } Map<String, Object> result = new HashMap<>(); for (String k : jso.keySet()) { Object o = jso.get(k); if (o instanceof ScriptObjectMirror) { result.put(k, unwrap((ScriptObjectMirror) o)); } else { result.put(k, DocumentScriptingWrapper.unwrap(o)); } } return result; }
.collect(Collectors.toList()); } else { if ("Date".equals(scriptObjectMirror.getClassName())) {
if (m.getClassName().toLowerCase().equals("object"))
String className = mirror.getClassName(); if(className.equals("Object")) { return toMap(mirror);