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/typedarrays/ByteIo.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/. */ package org.mozilla.javascript.typedarrays; public class ByteIo { public static Byte readInt8(byte[] buf, int offset) { return Byte.valueOf(buf[offset]); } public static void writeInt8(byte[] buf, int offset, int val) { buf[offset] = (byte)val; } public static Integer readUint8(byte[] buf, int offset) { return Integer.valueOf(buf[offset] & 0xff); } public static void writeUint8(byte[] buf, int offset, int val) { buf[offset] = (byte)(val & 0xff); } private static short doReadInt16(byte[] buf, int offset, boolean littleEndian) { // Need to coalesce to short here so that we stay in range if (littleEndian) { return (short)((buf[offset] & 0xff) | ((buf[offset + 1] & 0xff) << 8)); } return (short)(((buf[offset] & 0xff) << 8) | (buf[offset + 1] & 0xff)); } private static void doWriteInt16(byte[] buf, int offset, int val, boolean littleEndian) { if (littleEndian) { buf[offset] = (byte)(val & 0xff); buf[offset + 1] = (byte)((val >>> 8) & 0xff); } else { buf[offset] = (byte)((val >>> 8) & 0xff); buf[offset + 1] = (byte)(val & 0xff); } } public static Short readInt16(byte[] buf, int offset, boolean littleEndian) { return Short.valueOf(doReadInt16(buf, offset, littleEndian)); } public static void writeInt16(byte[] buf, int offset, int val, boolean littleEndian) { doWriteInt16(buf, offset, val, littleEndian); } public static Integer readUint16(byte[] buf, int offset, boolean littleEndian) { return Integer.valueOf(doReadInt16(buf, offset, littleEndian) & 0xffff); } public static void writeUint16(byte[] buf, int offset, int val, boolean littleEndian) { doWriteInt16(buf, offset, val & 0xffff, littleEndian); } public static Integer readInt32(byte[] buf, int offset, boolean littleEndian) { if (littleEndian) { return Integer.valueOf( (buf[offset] & 0xff) | ((buf[offset + 1] & 0xff) << 8) | ((buf[offset + 2] & 0xff) << 16) | ((buf[offset + 3] & 0xff) << 24)); } return Integer.valueOf( ((buf[offset] & 0xff) << 24) | ((buf[offset + 1] & 0xff) << 16) | ((buf[offset + 2] & 0xff) << 8) | (buf[offset + 3] & 0xff)); } public static void writeInt32(byte[] buf, int offset, int val, boolean littleEndian) { if (littleEndian) { buf[offset] = (byte)(val & 0xff); buf[offset + 1] = (byte)((val >>> 8) & 0xff); buf[offset + 2] = (byte)((val >>> 16) & 0xff); buf[offset + 3] = (byte)((val >>> 24) & 0xff); } else { buf[offset] = (byte)((val >>> 24) & 0xff); buf[offset + 1] = (byte)((val >>> 16) & 0xff); buf[offset + 2] = (byte)((val >>> 8) & 0xff); buf[offset + 3] = (byte)(val & 0xff); } } public static long readUint32Primitive(byte[] buf, int offset, boolean littleEndian) { if (littleEndian) { return ((buf[offset] & 0xffL) | ((buf[offset + 1] & 0xffL) << 8L) | ((buf[offset + 2] & 0xffL) << 16L) | ((buf[offset + 3] & 0xffL) << 24L)) & 0xffffffffL; } return (((buf[offset] & 0xffL) << 24L) | ((buf[offset + 1] & 0xffL) << 16L) | ((buf[offset + 2] & 0xffL) << 8L) | (buf[offset + 3] & 0xffL)) & 0xffffffffL; } public static void writeUint32(byte[] buf, int offset, long val, boolean littleEndian) { if (littleEndian) { buf[offset] = (byte)(val & 0xffL); buf[offset + 1] = (byte)((val >>> 8L) & 0xffL); buf[offset + 2] = (byte)((val >>> 16L) & 0xffL); buf[offset + 3] = (byte)((val >>> 24L) & 0xffL); } else { buf[offset] = (byte)((val >>> 24L) & 0xffL); buf[offset + 1] = (byte)((val >>> 16L) & 0xffL); buf[offset + 2] = (byte)((val >>> 8L) & 0xffL); buf[offset + 3] = (byte)(val & 0xffL); } } public static Object readUint32(byte[] buf, int offset, boolean littleEndian) { return Long.valueOf(readUint32Primitive(buf, offset, littleEndian)); } public static long readUint64Primitive(byte[] buf, int offset, boolean littleEndian) { if (littleEndian) { return ((buf[offset] & 0xffL) | ((buf[offset + 1] & 0xffL) << 8L) | ((buf[offset + 2] & 0xffL) << 16L) | ((buf[offset + 3] & 0xffL) << 24L) | ((buf[offset + 4] & 0xffL) << 32L) | ((buf[offset + 5] & 0xffL) << 40L) | ((buf[offset + 6] & 0xffL) << 48L) | ((buf[offset + 7] & 0xffL) << 56L)); } return (((buf[offset] & 0xffL) << 56L) | ((buf[offset + 1] & 0xffL) << 48L) | ((buf[offset + 2] & 0xffL) << 40L) | ((buf[offset + 3] & 0xffL) << 32L) | ((buf[offset + 4] & 0xffL) << 24L) | ((buf[offset + 5] & 0xffL) << 16L) | ((buf[offset + 6] & 0xffL) << 8L) | ((buf[offset + 7] & 0xffL) << 0L)); } public static void writeUint64(byte[] buf, int offset, long val, boolean littleEndian) { if (littleEndian) { buf[offset] = (byte)(val & 0xffL); buf[offset + 1] = (byte)((val >>> 8L) & 0xffL); buf[offset + 2] = (byte)((val >>> 16L) & 0xffL); buf[offset + 3] = (byte)((val >>> 24L) & 0xffL); buf[offset + 4] = (byte)((val >>> 32L) & 0xffL); buf[offset + 5] = (byte)((val >>> 40L) & 0xffL); buf[offset + 6] = (byte)((val >>> 48L) & 0xffL); buf[offset + 7] = (byte)((val >>> 56L) & 0xffL); } else { buf[offset] = (byte)((val >>> 56L) & 0xffL); buf[offset + 1] = (byte)((val >>> 48L) & 0xffL); buf[offset + 2] = (byte)((val >>> 40L) & 0xffL); buf[offset + 3] = (byte)((val >>> 32L) & 0xffL); buf[offset + 4] = (byte)((val >>> 24L) & 0xffL); buf[offset + 5] = (byte)((val >>> 16L) & 0xffL); buf[offset + 6] = (byte)((val >>> 8L) & 0xffL); buf[offset + 7] = (byte)(val & 0xffL); } } public static Float readFloat32(byte[] buf, int offset, boolean littleEndian) { long base = readUint32Primitive(buf, offset, littleEndian); return Float.valueOf(Float.intBitsToFloat((int)base)); } public static void writeFloat32(byte[] buf, int offset, double val, boolean littleEndian) { long base = Float.floatToIntBits((float)val); writeUint32(buf, offset, base, littleEndian); } public static Double readFloat64(byte[] buf, int offset, boolean littleEndian) { long base = readUint64Primitive(buf, offset, littleEndian); return Double.valueOf(Double.longBitsToDouble(base)); } public static void writeFloat64(byte[] buf, int offset, double val, boolean littleEndian) { long base = Double.doubleToLongBits(val); writeUint64(buf, offset, base, littleEndian); } }
⏎ org/mozilla/javascript/typedarrays/ByteIo.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, 35502👍, 1💬
Popular Posts:
Apache Log4j provides the interface that applications should code to and provides the adapter compon...
Java Advanced Imaging (JAI) is a Java platform extension API that provides a set of object-oriented ...
JDK 11 jdk.jshell.jmod is the JMOD file for JDK 11 JShell tool, which can be invoked by the "jshell"...
xml-commons Resolver Source Code Files are provided in the source package file, xml-commons-resolver...
Java Architecture for XML Binding (JAXB) is a Java API that allows Java developers to map Java class...