NativeArray array; array.put(array.size(), array, result);
public static String fromJSObject(Object obj) { if (obj instanceof NativeArray) { StringBuilder stringBuilder = new StringBuilder(); NativeArray nativeArray = (NativeArray) obj; int size = nativeArray.size(); for (int i = 0; i < size; i++) { Object arrayElement = nativeArray.get(i); if (arrayElement != null) stringBuilder.append(arrayElement); if (i != size - 1) stringBuilder.append(","); } return stringBuilder.toString(); } else { return obj == null ? null : obj.toString(); } } }
public static Set<String> getHeaderNames(NativeArray nativeArray) { final String sourceMethod = "getHeaderNames"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(BundleVersionsHash.FunctionObject.class.getName(), sourceMethod, new Object[]{nativeArray}); } Set<String> result = new HashSet<String>(); Object[] items = nativeArray.toArray(new Object[nativeArray.size()]); for (Object item : items) { if (!(item instanceof String)) { throw new IllegalArgumentException(item.toString()); } result.add((String)item); } if (isTraceLogging) { log.exiting(BundleVersionsHash.FunctionObject.class.getName(), sourceMethod, result); } return result; }
headersToInclude = getHeaderNames((NativeArray)arg); NativeArray nativeArray = (NativeArray)arg; Object[] array = nativeArray.toArray(new Object[nativeArray.size()]); } else if (arg instanceof String) { bundleNames.add(arg.toString());
private void setRange(NativeArray a, int off) { if (off > length) { throw ScriptRuntime.constructError("RangeError", "offset out of range"); } if ((off + a.size()) > length) { throw ScriptRuntime.constructError("RangeError", "offset + length out of range"); } int pos = off; for (Object val : a) { js_set(pos, val); pos++; } }
@SneakyThrows public NativeArray resolveFiles(NativeArray referencedFiles) { List<NativeObject> codeUnits = Lists.newArrayList(); for (int i = 0; i < referencedFiles.size(); i++) { NativeObject referencedFile = (NativeObject) referencedFiles.get(i); String path = (String) referencedFile.get("path"); String fullPath = FilenameUtils.concat(basePath.getCanonicalPath(), path); // if (generatedFileReferences.containsKey(fullPath)) //// { // continue; // } String source = FileUtils.readFileToString(new File(fullPath)); val codeUnit = new NativeObject(); NativeObject.putProperty(codeUnit, "content", source); NativeObject.putProperty(codeUnit, "path", path); codeUnits.add(codeUnit); generatedFileReferences.put(fullPath, codeUnit); } NativeObject[] nativeObjects = codeUnits.toArray(new NativeObject[]{}); return new NativeArray(nativeObjects); } public TypescriptCompilationProblem getProblem(int i) {
public String compile(final String typeScript) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("compile"); try { final String execute = getCompilationCommand(typeScript); final NativeObject compilationResult = (NativeObject) builder.evaluate(execute, "compile"); final NativeArray errors = (NativeArray) compilationResult.get(PARAM_ERRORS); if (errors.size() > 0) { throwCompilationError(errors); } return compilationResult.get(PARAM_SOURCE).toString(); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
public String compile(final String typeScript) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("compile"); try { final String execute = getCompilationCommand(typeScript); final NativeObject compilationResult = (NativeObject) builder.evaluate(execute, "compile"); final NativeArray errors = (NativeArray) compilationResult.get(PARAM_ERRORS); if (errors.size() > 0) { throwCompilationError(errors); } return compilationResult.get(PARAM_SOURCE).toString(); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
String[][] javaArray = new String[nativeArray.size()][((NativeArray)nativeArray.get(0)).size()]; for (Integer row : nativeArray.getIndexIds()) { for(int column=0;column<((NativeArray)nativeArray.get(row)).size();column++){