1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00
This commit is contained in:
Quinton Ashley 2022-06-27 19:09:22 -05:00
parent 848226ee2f
commit c2a07d4cdd
7 changed files with 44 additions and 1 deletions

View File

@ -10,6 +10,13 @@ jdk.imports['java.lang.Double'].load = async () => {
Double.compare = (a, b) => { Double.compare = (a, b) => {
return a - b; return a - b;
}; };
Double.valueOf = (a) => {
let val = Number(a);
if (isNaN(val)) {
throw new Error('NumberFormatException: For input string: ' + a);
}
return val;
};
Double.MAX_VALUE = Number.MAX_VALUE; Double.MAX_VALUE = Number.MAX_VALUE;
Double.POSITIVE_INFINITY = Number.POSITIVE_INFINITY; Double.POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
Double.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY; Double.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;

View File

@ -6,6 +6,13 @@ jdk.imports['java.lang.Float'].load = async () => {
Float.compare = (a, b) => { Float.compare = (a, b) => {
return a - b; return a - b;
}; };
Float.valueOf = (a) => {
let val = Number(a);
if (isNaN(val)) {
throw new Error('NumberFormatException: For input string: ' + a);
}
return val;
};
Float.MAX_VALUE = Number.MAX_VALUE; Float.MAX_VALUE = Number.MAX_VALUE;
Float.POSITIVE_INFINITY = Number.POSITIVE_INFINITY; Float.POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
Float.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY; Float.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;

View File

@ -6,6 +6,13 @@ jdk.imports['java.lang.Integer'].load = async () => {
Integer.compare = (a, b) => { Integer.compare = (a, b) => {
return a - b; return a - b;
}; };
Integer.valueOf = (a) => {
let val = Number(a);
if (isNaN(val)) {
throw new Error('NumberFormatException: For input string: ' + a);
}
return val;
};
Integer.MAX_VALUE = Number.MAX_VALUE; Integer.MAX_VALUE = Number.MAX_VALUE;
Integer.POSITIVE_INFINITY = Number.POSITIVE_INFINITY; Integer.POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
Integer.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY; Integer.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;

View File

@ -6,6 +6,13 @@ jdk.imports['java.lang.Long'].load = async () => {
Long.compare = (a, b) => { Long.compare = (a, b) => {
return a - b; return a - b;
}; };
Long.valueOf = (a) => {
let val = Number(a);
if (isNaN(val)) {
throw new Error('NumberFormatException: For input string: ' + a);
}
return val;
};
Long.MAX_VALUE = Number.MAX_VALUE; Long.MAX_VALUE = Number.MAX_VALUE;
Long.POSITIVE_INFINITY = Number.POSITIVE_INFINITY; Long.POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
Long.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY; Long.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;

View File

@ -6,6 +6,13 @@ jdk.imports['java.lang.Short'].load = async () => {
Short.compare = (a, b) => { Short.compare = (a, b) => {
return a - b; return a - b;
}; };
Short.valueOf = (a) => {
let val = Number(a);
if (isNaN(val)) {
throw new Error('NumberFormatException: For input string: ' + a);
}
return val;
};
Short.MAX_VALUE = Number.MAX_VALUE; Short.MAX_VALUE = Number.MAX_VALUE;
Short.POSITIVE_INFINITY = Number.POSITIVE_INFINITY; Short.POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
Short.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY; Short.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;

View File

@ -34,4 +34,12 @@ jdk.imports['java.lang.String'].load = async () => {
return new Formatter().format(format, ...args); return new Formatter().format(format, ...args);
}; };
jdk.java.lang.String = String; jdk.java.lang.String = String;
Number.prototype.toUpperCase = function () {
return this + '';
};
Number.prototype.toLowerCase = function () {
return this + '';
};
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "java2js", "name": "java2js",
"version": "1.2.18", "version": "1.2.19",
"description": "Converts Java to JavaScript and runs it with a JS JDK", "description": "Converts Java to JavaScript and runs it with a JS JDK",
"main": "jdk.js", "main": "jdk.js",
"scripts": { "scripts": {