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/v8dtoa/FastDtoaBuilder.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.v8dtoa;
import java.util.Arrays;
public class FastDtoaBuilder {
// allocate buffer for generated digits + extra notation + padding zeroes
final char[] chars = new char[FastDtoa.kFastDtoaMaximalLength + 8];
int end = 0;
int point;
boolean formatted = false;
void append(char c) {
chars[end++] = c;
}
void decreaseLast() {
chars[end - 1]--;
}
public void reset() {
end = 0;
formatted = false;
}
@Override
public String toString() {
return "[chars:" + new String(chars, 0, end) + ", point:" + point + "]";
}
public String format() {
if (!formatted) {
// check for minus sign
int firstDigit = chars[0] == '-' ? 1 : 0;
int decPoint = point - firstDigit;
if (decPoint < -5 || decPoint > 21) {
toExponentialFormat(firstDigit, decPoint);
} else {
toFixedFormat(firstDigit, decPoint);
}
formatted = true;
}
return new String(chars, 0, end);
}
private void toFixedFormat(int firstDigit, int decPoint) {
if (point < end) {
// insert decimal point
if (decPoint > 0) {
// >= 1, split decimals and insert point
System.arraycopy(chars, point, chars, point + 1, end - point);
chars[point] = '.';
end++;
} else {
// < 1,
int target = firstDigit + 2 - decPoint;
System.arraycopy(chars, firstDigit, chars, target, end - firstDigit);
chars[firstDigit] = '0';
chars[firstDigit + 1] = '.';
if (decPoint < 0) {
Arrays.fill(chars, firstDigit + 2, target, '0');
}
end += 2 - decPoint;
}
} else if (point > end) {
// large integer, add trailing zeroes
Arrays.fill(chars, end, point, '0');
end += point - end;
}
}
private void toExponentialFormat(int firstDigit, int decPoint) {
if (end - firstDigit > 1) {
// insert decimal point if more than one digit was produced
int dot = firstDigit + 1;
System.arraycopy(chars, dot, chars, dot + 1, end - dot);
chars[dot] = '.';
end++;
}
chars[end++] = 'e';
char sign = '+';
int exp = decPoint - 1;
if (exp < 0) {
sign = '-';
exp = -exp;
}
chars[end++] = sign;
int charPos = exp > 99 ? end + 2 : exp > 9 ? end + 1 : end;
end = charPos + 1;
// code below is needed because Integer.getChars() is not public
for (;;) {
int r = exp % 10;
chars[charPos--] = digits[r];
exp = exp / 10;
if (exp == 0) break;
}
}
final static char[] digits = {
'0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9'
};
}
⏎ org/mozilla/javascript/v8dtoa/FastDtoaBuilder.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, ≈104🔥, 1💬
Popular Posts:
What Is ojdbc5.jar for Oracle 11g R1? ojdbc5.jar for Oracle 11g R1 is the JAR files of ojdbc.jar, JD...
How to perform XML Schema validation with sax\Writer.java provided in the Apache Xerces package? You...
Apache Avalon began in 1999 as the Java Apache Server Framework and in late 2002 separated from the ...
How to download and install JDK (Java Development Kit) 8? If you want to write Java applications, yo...
How to display types defined in an XML Schema file with the xs\QueryXS.java provided in the Apache X...