Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Rhino JavaScript Java Library Source Code
Rhino JavaScript Java Library is an open-source implementation of JavaScript written entirely in Java.
Rhino JavaScript Java Library Source Code files are provided in binary package (rhino-1.7.14.zip).
You can also browse the source code below:
✍: FYIcenter.com
⏎ org/mozilla/javascript/IteratorLikeIterable.java
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package org.mozilla.javascript; import java.io.Closeable; import java.util.Iterator; import java.util.NoSuchElementException; /** * This is a class that makes it easier to iterate over "iterator-like" objects as defined in the * ECMAScript spec. The caller is responsible for retrieving an object that implements the * "iterator" pattern. This class will follow that pattern and throw appropriate JavaScript * exceptions. * * <p>The pattern that the target class should follow is: * It must have a function property called * "next" * The function must return an object with a boolean value called "done". * If "done" is * true, then the returned object should also contain a "value" property. * If it has a function * property called "return" then it will be called when the caller is done iterating. */ public class IteratorLikeIterable implements Iterable<Object>, Closeable { private final Context cx; private final Scriptable scope; private final Callable next; private final Callable returnFunc; private final Scriptable iterator; private boolean closed; public IteratorLikeIterable(Context cx, Scriptable scope, Object target) { this.cx = cx; this.scope = scope; // This will throw if "next" is not a function or undefined next = ScriptRuntime.getPropFunctionAndThis(target, ES6Iterator.NEXT_METHOD, cx, scope); iterator = ScriptRuntime.lastStoredScriptable(cx); Object retObj = ScriptRuntime.getObjectPropNoWarn(target, ES6Iterator.RETURN_PROPERTY, cx, scope); // We only care about "return" if it is not null or undefined if ((retObj != null) && !Undefined.isUndefined(retObj)) { if (!(retObj instanceof Callable)) { throw ScriptRuntime.notFunctionError(target, retObj, ES6Iterator.RETURN_PROPERTY); } returnFunc = (Callable) retObj; } else { returnFunc = null; } } @Override public void close() { if (!closed) { closed = true; if (returnFunc != null) { returnFunc.call(cx, scope, iterator, ScriptRuntime.emptyArgs); } } } @Override public Itr iterator() { return new Itr(); } public final class Itr implements Iterator<Object> { private Object nextVal; private boolean isDone; @Override public boolean hasNext() { if (isDone) { return false; } Object val = next.call(cx, scope, iterator, ScriptRuntime.emptyArgs); // This will throw if "val" is not an object. // "getObjectPropNoWarn" won't, so do this as follows. Object doneval = ScriptableObject.getProperty( ScriptableObject.ensureScriptable(val), ES6Iterator.DONE_PROPERTY); if (doneval == Scriptable.NOT_FOUND) { doneval = Undefined.instance; } // It's OK if done is undefined. if (ScriptRuntime.toBoolean(doneval)) { isDone = true; return false; } nextVal = ScriptRuntime.getObjectPropNoWarn(val, ES6Iterator.VALUE_PROPERTY, cx, scope); return true; } @Override public Object next() { if (isDone) { throw new NoSuchElementException(); } return nextVal; } /** Find out if "hasNext" returned done without invoking the function again. */ public boolean isDone() { return isDone; } /** Manually set "done." Used for exception handling in promises. */ public void setDone(boolean done) { this.isDone = done; } } }
⏎ org/mozilla/javascript/IteratorLikeIterable.java
Or download all of them as a single archive file:
File name: rhino-1.7.14-sources.jar File size: 1029165 bytes Release date: 2022-01-06 Download
⇒ Example code to Test rhino-runtime-1.7.14.jar
⇐ Download Rhino JavaScript Binary Package
2022-05-03, 35703👍, 1💬
Popular Posts:
The Java Naming and Directory Interface (JNDI) is part of the Java platform, providing applications ...
JDK 11 jdk.crypto.cryptoki.jmod is the JMOD file for JDK 11 Crypto Cryptoki module. JDK 11 Crypto KI...
JLayer is a library that decodes/plays/converts MPEG 1/2/2.5 Layer 1/2/3 (i.e. MP3) in real time for...
commons-net.jar is the bytecode of Apache Commons Net library, which implements the client side of m...
GJT (Giant Java Tree) implementation of XML Pull Parser. JAR File Size and Download Location: File n...