Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
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 (322)
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/tools/shell/Environment.java
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/. */
/*
Environment.java
Wraps java.lang.System properties.
by Patrick C. Beard <beard@netscape.com>
*/
package org.mozilla.javascript.tools.shell;
import java.util.Map;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
/**
* Environment, intended to be instantiated at global scope, provides
* a natural way to access System properties from JavaScript.
*
* @author Patrick C. Beard
*/
public class Environment extends ScriptableObject
{
static final long serialVersionUID = -430727378460177065L;
private Environment thePrototypeInstance = null;
public static void defineClass(ScriptableObject scope) {
try {
ScriptableObject.defineClass(scope, Environment.class);
} catch (Exception e) {
throw new Error(e.getMessage());
}
}
@Override
public String getClassName() {
return "Environment";
}
public Environment() {
if (thePrototypeInstance == null)
thePrototypeInstance = this;
}
public Environment(ScriptableObject scope) {
setParentScope(scope);
Object ctor = ScriptRuntime.getTopLevelProp(scope, "Environment");
if (ctor != null && ctor instanceof Scriptable) {
Scriptable s = (Scriptable) ctor;
setPrototype((Scriptable) s.get("prototype", s));
}
}
@Override
public boolean has(String name, Scriptable start) {
if (this == thePrototypeInstance)
return super.has(name, start);
return (System.getProperty(name) != null);
}
@Override
public Object get(String name, Scriptable start) {
if (this == thePrototypeInstance)
return super.get(name, start);
String result = System.getProperty(name);
if (result != null)
return ScriptRuntime.toObject(getParentScope(), result);
else
return Scriptable.NOT_FOUND;
}
@Override
public void put(String name, Scriptable start, Object value) {
if (this == thePrototypeInstance)
super.put(name, start, value);
else
System.getProperties().put(name, ScriptRuntime.toString(value));
}
private Object[] collectIds() {
Map<Object,Object> props = System.getProperties();
return props.keySet().toArray();
}
@Override
public Object[] getIds() {
if (this == thePrototypeInstance)
return super.getIds();
return collectIds();
}
@Override
public Object[] getAllIds() {
if (this == thePrototypeInstance)
return super.getAllIds();
return collectIds();
}
}
⏎ org/mozilla/javascript/tools/shell/Environment.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, ≈207🔥, 1💬
Popular Posts:
JDK 11 jdk.internal.opt.jmod is the JMOD file for JDK 11 Internal Opt module. JDK 11 Internal Opt mo...
Snappy-Java is a Java port of the "snappy", a fast C++ compresser/decompresser developed by Google. ...
How to download and install mysql-connector-j-8.0.31 .zip?Connector/J Java library is a JDBC Driver ...
What Is poi-ooxml-3.5.jar? poi-ooxml-3.5.jar is one of the JAR files for Apache POI 3.5, which provi...
commons-lang-1.0.1.jar is the JAR file for Apache Commons Lang 1.0.1, which provides a host of helpe...