From ad25d4f3f268a7815994fb5bc7671d3f98d54ff5 Mon Sep 17 00:00:00 2001 From: Scott Vorthmann Date: Sun, 21 Aug 2022 18:19:33 -0700 Subject: [PATCH 1/3] Updated to JSweet transpiler 3.1.0 I also updated to the latest jsweet-core and j4ts. Note the two places I commented out code that would not compile... look for "SV TODO". I'm updating this mostly as a requirement for j4ts-awt-swing, and I'm not too concerned about file operations for my purposes. --- dist/j4ts-file.d.ts | 388 ++++- dist/j4ts-file.js | 1493 ++++++++++------- pom.xml | 31 +- src/main/java/java/io/FileInputStream.java | 8 +- src/main/java/java/io/FileOutputStream.java | 20 +- src/main/java/java/io/FilenameFilter.java | 6 + .../java/java/io/LocalStorageFileSystem.java | 15 +- src/main/java/test/TestFile.java | 13 +- .../j4ts-file/0.0.1-SNAPSHOT/bundle.d.ts | 388 ++++- 9 files changed, 1557 insertions(+), 805 deletions(-) create mode 100644 src/main/java/java/io/FilenameFilter.java diff --git a/dist/j4ts-file.d.ts b/dist/j4ts-file.d.ts index 3ab3b44..09a3959 100644 --- a/dist/j4ts-file.d.ts +++ b/dist/j4ts-file.d.ts @@ -1,100 +1,59 @@ -declare namespace java.io { - interface FileFilter { - (pathname: java.io.File): boolean; - } -} -declare namespace java.io { - /** - * JSweet implementation based on a local storage FS. - */ - class FileInputStream extends java.io.InputStream { - private content; - private index; - constructor(name?: any); - read$(): number; - private readBytes(b, off, len); - read$byte_A(b: number[]): number; - read(b?: any, off?: any, len?: any): any; - skip(n: number): number; - available(): number; - close(): void; - } -} -declare namespace java.io { - /** - * JSweet implementation. - */ - class FileNotFoundException extends java.io.IOException { - static serialVersionUID: number; - constructor(s?: any); - } -} -declare namespace java.io { - /** - * JSweet partial implementation based on a local storage FS. - */ - class FileOutputStream extends java.io.OutputStream { - /** - * True if the file is opened for append. - */ - private append; - private file; - private entry; - private content; - constructor(name?: any, append?: any); - private write$int$boolean(b, append); - write$int(b: number): void; - private writeBytes(b, off, len, append); - write$byte_A(b: number[]): void; - write(b?: any, off?: any, len?: any): any; - flush(): void; - close(): void; - } -} -declare namespace java.io { - /** - * JSweet implementation. - */ - class FileReader extends java.io.InputStreamReader { - constructor(fileName?: any); +declare namespace test { + class TestFile { + static assertEquals(o1: any, o2: any): void; + static assertTrue(b: boolean): void; + static assertFalse(b: boolean): void; + static test(): void; + static testIO(): void; } } declare namespace java.io { /** * Package-private abstract class for the local filesystem abstraction. + * @class */ abstract class FileSystem { static __static_initialized: boolean; static __static_initialize(): void; /** * Return the local filesystem's name-separator character. + * @return {string} */ abstract getSeparator(): string; /** * Return the local filesystem's path-separator character. + * @return {string} */ abstract getPathSeparator(): string; - normalize(pathname?: any, len?: any, off?: any): any; /** * Convert the given pathname string to normal form. If the string is * already in normal form then it is simply returned. + * @param {string} path + * @return {string} */ - normalize$java_lang_String(path: string): string; + abstract normalize(path: string): string; /** * Compute the length of this pathname string's prefix. The pathname * string must be in normal form. + * @param {string} path + * @return {number} */ abstract prefixLength(path: string): number; + resolve$java_lang_String$java_lang_String(parent: string, child: string): string; /** * Resolve the child pathname string against the parent. * Both strings must be in normal form, and the result * will be in normal form. + * @param {string} parent + * @param {string} child + * @return {string} */ - resolve(parent?: any, child?: any): any; + resolve(parent?: any, child?: any): string; /** * Return the parent pathname string to be used when the parent-directory * argument in one of the two-argument File constructors is the empty * pathname. + * @return {string} */ abstract getDefaultParent(): string; /** @@ -102,16 +61,16 @@ declare namespace java.io { * win32, e.g., to transform "/c:/foo" into "c:/foo". The path string * still has slash separators; code in the File class will translate them * after this method returns. + * @param {string} path + * @return {string} */ abstract fromURIPath(path: string): string; /** * Tell whether or not the given abstract pathname is absolute. + * @param {java.io.File} f + * @return {boolean} */ abstract isAbsolute(f: java.io.File): boolean; - /** - * Resolve the given abstract pathname into absolute form. Invoked by the - * getAbsolutePath and getCanonicalPath methods in the File class. - */ resolve$java_io_File(f: java.io.File): string; abstract canonicalize(path: string): string; static BA_EXISTS: number; @@ -122,6 +81,8 @@ declare namespace java.io { * Return the simple boolean attributes for the file or directory denoted * by the given abstract pathname, or zero if it does not exist or some * other I/O error occurs. + * @param {java.io.File} f + * @return {number} */ abstract getBooleanAttributes(f: java.io.File): number; static ACCESS_READ: number; @@ -132,24 +93,36 @@ declare namespace java.io { * pathname may be accessed by this process. The second argument specifies * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check. * Return false if access is denied or an I/O error occurs + * @param {java.io.File} f + * @param {number} access + * @return {boolean} */ abstract checkAccess(f: java.io.File, access: number): boolean; /** * Set on or off the access permission (to owner only or to all) to the file * or directory denoted by the given abstract pathname, based on the parameters * enable, access and oweronly. + * @param {java.io.File} f + * @param {number} access + * @param {boolean} enable + * @param {boolean} owneronly + * @return {boolean} */ abstract setPermission(f: java.io.File, access: number, enable: boolean, owneronly: boolean): boolean; /** * Return the time at which the file or directory denoted by the given * abstract pathname was last modified, or zero if it does not exist or * some other I/O error occurs. + * @param {java.io.File} f + * @return {number} */ abstract getLastModifiedTime(f: java.io.File): number; /** * Return the length in bytes of the file denoted by the given abstract * pathname, or zero if it does not exist, is a directory, or some other * I/O error occurs. + * @param {java.io.File} f + * @return {number} */ abstract getLength(f: java.io.File): number; /** @@ -157,44 +130,61 @@ declare namespace java.io { * true if the file was created and false if a * file or directory with the given pathname already exists. Throw an * IOException if an I/O error occurs. + * @param {string} pathname + * @return {boolean} */ abstract createFileExclusively(pathname: string): boolean; /** * Delete the file or directory denoted by the given abstract pathname, * returning true if and only if the operation succeeds. + * @param {java.io.File} f + * @return {boolean} */ abstract delete(f: java.io.File): boolean; /** * List the elements of the directory denoted by the given abstract * pathname. Return an array of strings naming the elements of the * directory if successful; otherwise, return null. + * @param {java.io.File} f + * @return {java.lang.String[]} */ abstract list(f: java.io.File): string[]; /** * Create a new directory denoted by the given abstract pathname, * returning true if and only if the operation succeeds. + * @param {java.io.File} f + * @return {boolean} */ abstract createDirectory(f: java.io.File): boolean; /** * Rename the file or directory denoted by the first abstract pathname to * the second abstract pathname, returning true if and only if * the operation succeeds. + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {boolean} */ abstract rename(f1: java.io.File, f2: java.io.File): boolean; /** * Set the last-modified time of the file or directory denoted by the * given abstract pathname, returning true if and only if the * operation succeeds. + * @param {java.io.File} f + * @param {number} time + * @return {boolean} */ abstract setLastModifiedTime(f: java.io.File, time: number): boolean; /** * Mark the file or directory denoted by the given abstract pathname as * read-only, returning true if and only if the operation * succeeds. + * @param {java.io.File} f + * @return {boolean} */ abstract setReadOnly(f: java.io.File): boolean; /** * List the available filesystem roots. + * @return {java.io.File[]} */ abstract listRoots(): java.io.File[]; static SPACE_TOTAL: number; @@ -203,63 +193,221 @@ declare namespace java.io { abstract getSpace(f: java.io.File, t: number): number; /** * Compare two abstract pathnames lexicographically. + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {number} */ abstract compare(f1: java.io.File, f2: java.io.File): number; /** * Compute the hash code of an abstract pathname. + * @param {java.io.File} f + * @return {number} */ abstract hashCode(f: java.io.File): number; static useCanonCaches: boolean; static useCanonPrefixCache: boolean; - private static getBooleanProperty(prop, defaultVal); + static getBooleanProperty(prop: string, defaultVal: boolean): boolean; static __static_initializer_0(): void; } } +declare namespace java.io { + /** + * JSweet partial implementation based on a local storage FS. + * @param {string} name + * @param {boolean} append + * @class + * @extends java.io.OutputStream + */ + class FileOutputStream extends java.io.OutputStream { + /** + * True if the file is opened for append. + */ + append: boolean; + file: java.io.File; + entry: java.io.LocalStorageFileSystem.Entry; + content: number[]; + constructor(name?: any, append?: any); + write$int$boolean(b: number, append: boolean): void; + write$int(b: number): void; + writeBytes(b: number[], off: number, len: number, append: boolean): void; + write$byte_A(b: number[]): void; + write$byte_A$int$int(b: number[], off: number, len: number): void; + write(b?: any, off?: any, len?: any): any; + /** + * + */ + flush(): void; + close(): void; + } +} +declare namespace java.io { + /** + * JSweet implementation based on a local storage FS. + * @param {string} n + * @class + * @extends java.io.InputStream + */ + class FileInputStream extends java.io.InputStream { + content: number[]; + index: number; + constructor(n?: any); + read$(): number; + readBytes(b: number[], off: number, len: number): number; + read$byte_A(b: number[]): number; + read$byte_A$int$int(b: number[], off: number, len: number): number; + read(b?: any, off?: any, len?: any): number; + skip(n: number): number; + available(): number; + close(): void; + } +} declare namespace java.io { /** * JSweet implementation. + * @param {string} fileName + * @param {boolean} append + * @class + * @extends java.io.OutputStreamWriter */ class FileWriter extends java.io.OutputStreamWriter { constructor(fileName?: any, append?: any); } } -declare namespace test { - class TestFile { - static assertEquals(o1: any, o2: any): void; - static assertTrue(b: boolean): void; - static assertFalse(b: boolean): void; - static test(): void; - static testIO(): void; +declare namespace java.io { + interface FilenameFilter { + (dir: java.io.File, name: string): boolean; + } +} +declare namespace java.io { + /** + * JSweet implementation. + * @param {string} fileName + * @class + * @extends java.io.InputStreamReader + */ + class FileReader extends java.io.InputStreamReader { + constructor(fileName?: any); + } +} +declare namespace java.io { + /** + * JSweet implementation. + * @param {string} s + * @class + * @extends java.io.IOException + */ + class FileNotFoundException extends java.io.IOException { + static serialVersionUID: number; + constructor(s?: any); + } +} +declare namespace java.io { + interface FileFilter { + (pathname: java.io.File): boolean; } } declare namespace java.io { class LocalStorageFileSystem extends java.io.FileSystem { - private PREFIX; + PREFIX: string; roots: java.io.File[]; /** * The FileSystem object representing the platform's local file system. */ static fs: LocalStorageFileSystem; static fs_$LI$(): LocalStorageFileSystem; + /** + * + * @return {string} + */ getSeparator(): string; + /** + * + * @return {string} + */ getPathSeparator(): string; - normalize(pathname?: any, len?: any, off?: any): any; + normalize$java_lang_String$int$int(pathname: string, len: number, off: number): string; + normalize(pathname?: any, len?: any, off?: any): string; normalize$java_lang_String(pathname: string): string; + /** + * + * @param {string} pathname + * @return {number} + */ prefixLength(pathname: string): number; - resolve(parent?: any, child?: any): any; + resolve$java_lang_String$java_lang_String(parent: string, child: string): string; + /** + * + * @param {string} parent + * @param {string} child + * @return {string} + */ + resolve(parent?: any, child?: any): string; + /** + * + * @return {string} + */ getDefaultParent(): string; + /** + * + * @param {string} path + * @return {string} + */ fromURIPath(path: string): string; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ isAbsolute(f: java.io.File): boolean; resolve$java_io_File(f: java.io.File): string; + /** + * + * @param {string} path + * @return {string} + */ canonicalize(path: string): string; + /** + * + * @param {java.io.File} f + * @return {number} + */ getBooleanAttributes(f: java.io.File): number; + /** + * + * @param {java.io.File} f + * @param {number} access + * @return {boolean} + */ checkAccess(f: java.io.File, access: number): boolean; + /** + * + * @param {java.io.File} f + * @param {number} access + * @param {boolean} enable + * @param {boolean} owneronly + * @return {boolean} + */ setPermission(f: java.io.File, access: number, enable: boolean, owneronly: boolean): boolean; + /** + * + * @param {java.io.File} f + * @return {number} + */ getLastModifiedTime(f: java.io.File): number; + /** + * + * @param {java.io.File} f + * @return {number} + */ getLength(f: java.io.File): number; clear(): void; getKey(pathname: string): string; createFileEntry(pathname: string): LocalStorageFileSystem.Entry; + /** + * + * @param {string} pathname + * @return {boolean} + */ createFileExclusively(pathname: string): boolean; hasEntry(pathname: string): boolean; getEntry(pathname: string): LocalStorageFileSystem.Entry; @@ -267,15 +415,68 @@ declare namespace java.io { putEntry(pathname: string, entry: LocalStorageFileSystem.Entry): void; getChildEntries(pathname: string): Array; removeEntry(pathname: string): void; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ delete(f: java.io.File): boolean; + /** + * + * @param {java.io.File} f + * @return {java.lang.String[]} + */ list(f: java.io.File): string[]; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ createDirectory(f: java.io.File): boolean; + /** + * + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {boolean} + */ rename(f1: java.io.File, f2: java.io.File): boolean; + /** + * + * @param {java.io.File} f + * @param {number} time + * @return {boolean} + */ setLastModifiedTime(f: java.io.File, time: number): boolean; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ setReadOnly(f: java.io.File): boolean; + /** + * + * @return {java.io.File[]} + */ listRoots(): java.io.File[]; + /** + * + * @param {java.io.File} f + * @param {number} t + * @return {number} + */ getSpace(f: java.io.File, t: number): number; + /** + * + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {number} + */ compare(f1: java.io.File, f2: java.io.File): number; + /** + * + * @param {java.io.File} f + * @return {number} + */ hashCode(f: java.io.File): number; constructor(); } @@ -295,12 +496,15 @@ declare namespace java.io { declare namespace java.io { /** * JSweet implementation for file. + * @param {string} parent + * @param {string} child + * @class */ class File implements java.io.Serializable, java.lang.Comparable { - private path; - private status; + path: string; + status: File.PathStatus; isInvalid(): boolean; - private prefixLength; + prefixLength: number; getPrefixLength(): number; static separatorChar: string; static separatorChar_$LI$(): string; @@ -332,24 +536,34 @@ declare namespace java.io { createNewFile(): boolean; delete(): boolean; list$(): string[]; - list(filter?: any): any; + list$java_io_FilenameFilter(filter: java.io.FilenameFilter): string[]; + list(filter?: any): string[]; listFiles$(): File[]; - listFiles(filter?: any): any; + listFiles$java_io_FilenameFilter(filter: java.io.FilenameFilter): File[]; + listFiles(filter?: any): File[]; listFiles$java_io_FileFilter(filter: java.io.FileFilter): File[]; mkdir(): boolean; mkdirs(): boolean; renameTo(dest: File): boolean; setLastModified(time: number): boolean; setReadOnly(): boolean; - setWritable(writable: boolean, ownerOnly?: boolean): boolean; - setReadable(readable: boolean, ownerOnly?: boolean): boolean; - setExecutable(executable: boolean, ownerOnly?: boolean): boolean; + setWritable$boolean$boolean(writable: boolean, ownerOnly: boolean): boolean; + setWritable(writable?: any, ownerOnly?: any): boolean; + setWritable$boolean(writable: boolean): boolean; + setReadable$boolean$boolean(readable: boolean, ownerOnly: boolean): boolean; + setReadable(readable?: any, ownerOnly?: any): boolean; + setReadable$boolean(readable: boolean): boolean; + setExecutable$boolean$boolean(executable: boolean, ownerOnly: boolean): boolean; + setExecutable(executable?: any, ownerOnly?: any): boolean; + setExecutable$boolean(executable: boolean): boolean; canExecute(): boolean; static listRoots(): File[]; getTotalSpace(): number; getFreeSpace(): number; getUsableSpace(): number; - static createTempFile(prefix: string, suffix: string, directory?: File): File; + static createTempFile$java_lang_String$java_lang_String$java_io_File(prefix: string, suffix: string, directory: File): File; + static createTempFile(prefix?: any, suffix?: any, directory?: any): File; + static createTempFile$java_lang_String$java_lang_String(prefix: string, suffix: string): File; compareTo(pathname: File): number; equals(obj: any): boolean; hashCode(): number; @@ -359,7 +573,7 @@ declare namespace java.io { namespace File { enum PathStatus { INVALID = 0, - CHECKED = 1, + CHECKED = 1 } class TempDirectory { constructor(); diff --git a/dist/j4ts-file.js b/dist/j4ts-file.js index 3c8ec70..03e9bce 100644 --- a/dist/j4ts-file.js +++ b/dist/j4ts-file.js @@ -1,268 +1,338 @@ -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -/* Generated from Java with JSweet 1.2.0-SNAPSHOT - http://www.jsweet.org */ +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +/* Generated from Java with JSweet 3.1.0 - http://www.jsweet.org */ +var test; +(function (test) { + var TestFile = /** @class */ (function () { + function TestFile() { + } + TestFile.assertEquals = function (o1, o2) { + if (o1 === o2) { + throw new Error("invalid assertion: " + o1 + "!=" + o2); + } + }; + TestFile.assertTrue = function (b) { + if (!b) { + throw new Error("invalid assertion"); + } + }; + TestFile.assertFalse = function (b) { + if (b) { + throw new Error("invalid assertion"); + } + }; + TestFile.test = function () { + try { + TestFile.testIO(); + var result = document.getElementById("result"); + if (result != null) { + result.innerHTML = "Success!"; + } + } + catch (e) { + console.error(e); + var result = document.getElementById("result"); + if (result != null) { + result.innerHTML = "Failure: " + e.message; + } + } + }; + TestFile.testIO = function () { + console.info("testing io"); + localStorage.clear(); + var s = new java.io.ByteArrayInputStream(/* getBytes */ ("abc").split('').map(function (s) { return s.charCodeAt(0); })); + TestFile.assertEquals(javaemul.internal.CharacterHelper.getNumericValue('a'), s.read()); + var dir = new java.io.File("/a/b/c"); + TestFile.assertFalse(dir.exists()); + dir.mkdirs(); + TestFile.assertTrue(dir.exists()); + var f = new java.io.File(dir, "test.txt"); + TestFile.assertFalse(f.exists()); + f.createNewFile(); + TestFile.assertTrue(f.exists()); + var fw = new java.io.FileWriter(f); + fw.append("abc"); + fw.close(); + var reader = new java.io.BufferedReader(new java.io.FileReader(f)); + var line = reader.readLine(); + reader.close(); + TestFile.assertEquals("abc", line); + console.info("end testing io"); + }; + return TestFile; + }()); + test.TestFile = TestFile; + TestFile["__class"] = "test.TestFile"; +})(test || (test = {})); var java; (function (java) { var io; (function (io) { /** - * JSweet implementation based on a local storage FS. + * Package-private abstract class for the local filesystem abstraction. + * @class */ - var FileInputStream = (function (_super) { - __extends(FileInputStream, _super); - function FileInputStream(name) { - var _this = this; - if (((typeof name === 'string') || name === null)) { - { - var file = name != null ? new java.io.File(name) : null; - _super.call(this); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Closeable", "java.lang.AutoCloseable"] }); - this.index = 0; - (function () { - var name = (file != null ? file.getPath() : null); - if (name == null) { - throw new java.lang.NullPointerException(); - } - if (file.isInvalid()) { - throw new java.io.FileNotFoundException("Invalid file path"); - } - if (!file.exists()) { - throw new java.io.FileNotFoundException(); - } - _this.content = atob(java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()).data); - _this.index = 0; - })(); - } - (function () { - })(); - } - else if (((name != null && name instanceof java.io.File) || name === null)) { - var file = name; - _super.call(this); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Closeable", "java.lang.AutoCloseable"] }); - this.index = 0; - (function () { - var name = (file != null ? file.getPath() : null); - if (name == null) { - throw new java.lang.NullPointerException(); - } - if (file.isInvalid()) { - throw new java.io.FileNotFoundException("Invalid file path"); - } - if (!file.exists()) { - throw new java.io.FileNotFoundException(); - } - _this.content = atob(java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()).data); - _this.index = 0; - })(); - } - else - throw new Error('invalid overload'); + var FileSystem = /** @class */ (function () { + function FileSystem() { } - FileInputStream.prototype.read$ = function () { - if (this.index >= this.content.length) { - return -1; - } - return this.content[this.index++]; - }; - FileInputStream.prototype.readBytes = function (b, off, len) { - if (this.index >= this.content.length) { - return -1; - } - var count = 0; - for (var i = off; i < off + len; i++) { - if (this.index >= this.content.length) { - break; - } - b[i] = this.content[this.index++]; - count++; - } - return count; - }; - FileInputStream.prototype.read$byte_A = function (b) { - return this.readBytes(b, 0, b.length); - }; - FileInputStream.prototype.read = function (b, off, len) { - var _this = this; - if (((b != null && b instanceof Array) || b === null) && ((typeof off === 'number') || off === null) && ((typeof len === 'number') || len === null)) { - return (function () { - return _this.readBytes(b, off, len); - })(); - } - else if (((b != null && b instanceof Array) || b === null) && off === undefined && len === undefined) { - return this.read$byte_A(b); + FileSystem.__static_initialize = function () { if (!FileSystem.__static_initialized) { + FileSystem.__static_initialized = true; + FileSystem.__static_initializer_0(); + } }; + FileSystem.prototype.resolve$java_lang_String$java_lang_String = function (parent, child) { throw new Error('cannot invoke abstract overloaded method... check your argument(s) type(s)'); }; + /** + * Resolve the child pathname string against the parent. + * Both strings must be in normal form, and the result + * will be in normal form. + * @param {string} parent + * @param {string} child + * @return {string} + */ + FileSystem.prototype.resolve = function (parent, child) { + if (((typeof parent === 'string') || parent === null) && ((typeof child === 'string') || child === null)) { + return this.resolve$java_lang_String$java_lang_String(parent, child); } - else if (b === undefined && off === undefined && len === undefined) { - return this.read$(); + else if (((parent != null && parent instanceof java.io.File) || parent === null) && child === undefined) { + return this.resolve$java_io_File(parent); } else throw new Error('invalid overload'); }; - FileInputStream.prototype.skip = function (n) { - this.index += n; - return n; - }; - FileInputStream.prototype.available = function () { - return this.content.length - this.index; - }; - FileInputStream.prototype.close = function () { - }; - return FileInputStream; - }(java.io.InputStream)); - io.FileInputStream = FileInputStream; - FileInputStream["__classname"] = "java.io.FileInputStream"; - })(io = java.io || (java.io = {})); -})(java || (java = {})); -/* Generated from Java with JSweet 1.2.0-SNAPSHOT - http://www.jsweet.org */ -var java; -(function (java) { - var io; - (function (io) { - /** - * JSweet implementation. - */ - var FileNotFoundException = (function (_super) { - __extends(FileNotFoundException, _super); - function FileNotFoundException(s) { - if (((typeof s === 'string') || s === null)) { - _super.call(this, s); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Serializable"] }); - (function () { - })(); + FileSystem.prototype.resolve$java_io_File = function (f) { throw new Error('cannot invoke abstract overloaded method... check your argument(s) type(s)'); }; + /*private*/ FileSystem.getBooleanProperty = function (prop, defaultVal) { + var val = java.lang.System.getProperty(prop); + if (val == null) + return defaultVal; + if ( /* equalsIgnoreCase */(function (o1, o2) { return o1.toUpperCase() === (o2 === null ? o2 : o2.toUpperCase()); })(val, "true")) { + return true; } - else if (s === undefined) { - _super.call(this); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Serializable"] }); - (function () { - })(); + else { + return false; } - else - throw new Error('invalid overload'); - } - FileNotFoundException.serialVersionUID = -897856973823710492; - return FileNotFoundException; - }(java.io.IOException)); - io.FileNotFoundException = FileNotFoundException; - FileNotFoundException["__classname"] = "java.io.FileNotFoundException"; + }; + FileSystem.__static_initializer_0 = function () { + FileSystem.useCanonCaches = FileSystem.getBooleanProperty("sun.io.useCanonCaches", FileSystem.useCanonCaches); + FileSystem.useCanonPrefixCache = FileSystem.getBooleanProperty("sun.io.useCanonPrefixCache", FileSystem.useCanonPrefixCache); + }; + FileSystem.__static_initialized = false; + FileSystem.BA_EXISTS = 1; + FileSystem.BA_REGULAR = 2; + FileSystem.BA_DIRECTORY = 4; + FileSystem.BA_HIDDEN = 8; + FileSystem.ACCESS_READ = 4; + FileSystem.ACCESS_WRITE = 2; + FileSystem.ACCESS_EXECUTE = 1; + FileSystem.SPACE_TOTAL = 0; + FileSystem.SPACE_FREE = 1; + FileSystem.SPACE_USABLE = 2; + FileSystem.useCanonCaches = true; + FileSystem.useCanonPrefixCache = true; + return FileSystem; + }()); + io.FileSystem = FileSystem; + FileSystem["__class"] = "java.io.FileSystem"; })(io = java.io || (java.io = {})); })(java || (java = {})); -/* Generated from Java with JSweet 1.2.0-SNAPSHOT - http://www.jsweet.org */ -var java; (function (java) { var io; (function (io) { /** * JSweet partial implementation based on a local storage FS. + * @param {string} name + * @param {boolean} append + * @class + * @extends java.io.OutputStream */ - var FileOutputStream = (function (_super) { + var FileOutputStream = /** @class */ (function (_super) { __extends(FileOutputStream, _super); function FileOutputStream(name, append) { var _this = this; if (((typeof name === 'string') || name === null) && ((typeof append === 'boolean') || append === null)) { + var __args = arguments; { + var __args_1 = arguments; var file = name != null ? new java.io.File(name) : null; - _super.call(this); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"] }); - this.append = false; - (function () { - if (!file.exists()) { - throw new java.io.FileNotFoundException(); - } - _this.file = file; - _this.append = append; - _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()); - _this.content = append ? (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : new Array(0); - })(); - } - (function () { - })(); - } - else if (((name != null && name instanceof java.io.File) || name === null) && ((typeof append === 'boolean') || append === null)) { - var file = name; - _super.call(this); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"] }); - this.append = false; - (function () { + _this = _super.call(this) || this; + if (_this.append === undefined) { + _this.append = false; + } + if (_this.file === undefined) { + _this.file = null; + } + if (_this.entry === undefined) { + _this.entry = null; + } + if (_this.content === undefined) { + _this.content = null; + } if (!file.exists()) { throw new java.io.FileNotFoundException(); } _this.file = file; _this.append = append; _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()); - _this.content = append ? (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : new Array(0); - })(); + _this.content = append ? /* getBytes */ (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : []; + } + if (_this.append === undefined) { + _this.append = false; + } + if (_this.file === undefined) { + _this.file = null; + } + if (_this.entry === undefined) { + _this.entry = null; + } + if (_this.content === undefined) { + _this.content = null; + } + } + else if (((name != null && name instanceof java.io.File) || name === null) && ((typeof append === 'boolean') || append === null)) { + var __args = arguments; + var file = __args[0]; + _this = _super.call(this) || this; + if (_this.append === undefined) { + _this.append = false; + } + if (_this.file === undefined) { + _this.file = null; + } + if (_this.entry === undefined) { + _this.entry = null; + } + if (_this.content === undefined) { + _this.content = null; + } + if (!file.exists()) { + throw new java.io.FileNotFoundException(); + } + _this.file = file; + _this.append = append; + _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()); + _this.content = append ? /* getBytes */ (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : []; } else if (((typeof name === 'string') || name === null) && append === undefined) { + var __args = arguments; { + var __args_2 = arguments; var file = name != null ? new java.io.File(name) : null; - var append = false; - _super.call(this); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"] }); - this.append = false; - (function () { - if (!file.exists()) { - throw new java.io.FileNotFoundException(); - } - _this.file = file; - _this.append = append; - _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()); - _this.content = append ? (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : new Array(0); - })(); + var append_1 = false; + _this = _super.call(this) || this; + if (_this.append === undefined) { + _this.append = false; + } + if (_this.file === undefined) { + _this.file = null; + } + if (_this.entry === undefined) { + _this.entry = null; + } + if (_this.content === undefined) { + _this.content = null; + } + if (!file.exists()) { + throw new java.io.FileNotFoundException(); + } + _this.file = file; + _this.append = append_1; + _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()); + _this.content = append_1 ? /* getBytes */ (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : []; + } + if (_this.append === undefined) { + _this.append = false; + } + if (_this.file === undefined) { + _this.file = null; + } + if (_this.entry === undefined) { + _this.entry = null; + } + if (_this.content === undefined) { + _this.content = null; } - (function () { - })(); } else if (((name != null && name instanceof java.io.File) || name === null) && append === undefined) { - var file = name; + var __args = arguments; + var file = __args[0]; { - var append = false; - _super.call(this); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"] }); - this.append = false; - (function () { - if (!file.exists()) { - throw new java.io.FileNotFoundException(); - } - _this.file = file; - _this.append = append; - _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()); - _this.content = append ? (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : new Array(0); - })(); + var __args_3 = arguments; + var append_2 = false; + _this = _super.call(this) || this; + if (_this.append === undefined) { + _this.append = false; + } + if (_this.file === undefined) { + _this.file = null; + } + if (_this.entry === undefined) { + _this.entry = null; + } + if (_this.content === undefined) { + _this.content = null; + } + if (!file.exists()) { + throw new java.io.FileNotFoundException(); + } + _this.file = file; + _this.append = append_2; + _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()); + _this.content = append_2 ? /* getBytes */ (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : []; + } + if (_this.append === undefined) { + _this.append = false; + } + if (_this.file === undefined) { + _this.file = null; + } + if (_this.entry === undefined) { + _this.entry = null; + } + if (_this.content === undefined) { + _this.content = null; } - (function () { - })(); } else throw new Error('invalid overload'); + return _this; } - FileOutputStream.prototype.write$int$boolean = function (b, append) { + /*private*/ FileOutputStream.prototype.write$int$boolean = function (b, append) { (this.content).push((b | 0)); }; FileOutputStream.prototype.write$int = function (b) { - this.write(b, this.append); + this.write$int$boolean(b, this.append); }; - FileOutputStream.prototype.writeBytes = function (b, off, len, append) { + /*private*/ FileOutputStream.prototype.writeBytes = function (b, off, len, append) { for (var i = off; i < off + len; i++) { - (this.content).push(b[i]); + { + (this.content).push(b[i]); + } + ; } }; FileOutputStream.prototype.write$byte_A = function (b) { this.writeBytes(b, 0, b.length, this.append); }; + FileOutputStream.prototype.write$byte_A$int$int = function (b, off, len) { + this.writeBytes(b, off, len, this.append); + }; FileOutputStream.prototype.write = function (b, off, len) { - var _this = this; - if (((b != null && b instanceof Array) || b === null) && ((typeof off === 'number') || off === null) && ((typeof len === 'number') || len === null)) { - return (function () { - _this.writeBytes(b, off, len, _this.append); - })(); + if (((b != null && b instanceof Array && (b.length == 0 || b[0] == null || (typeof b[0] === 'number'))) || b === null) && ((typeof off === 'number') || off === null) && ((typeof len === 'number') || len === null)) { + return this.write$byte_A$int$int(b, off, len); } else if (((typeof b === 'number') || b === null) && ((typeof off === 'boolean') || off === null) && len === undefined) { return this.write$int$boolean(b, off); } - else if (((b != null && b instanceof Array) || b === null) && off === undefined && len === undefined) { + else if (((b != null && b instanceof Array && (b.length == 0 || b[0] == null || (typeof b[0] === 'number'))) || b === null) && off === undefined && len === undefined) { return this.write$byte_A(b); } else if (((typeof b === 'number') || b === null) && off === undefined && len === undefined) { @@ -271,11 +341,10 @@ var java; else throw new Error('invalid overload'); }; + /** + * + */ FileOutputStream.prototype.flush = function () { - this.entry.data = btoa(((this.content).map(function (b, __, ___) { - return String.fromCharCode(b); - })).join("")); - java.io.LocalStorageFileSystem.fs_$LI$().putEntry(this.file.getAbsolutePath(), this.entry); }; FileOutputStream.prototype.close = function () { this.flush(); @@ -283,277 +352,308 @@ var java; return FileOutputStream; }(java.io.OutputStream)); io.FileOutputStream = FileOutputStream; - FileOutputStream["__classname"] = "java.io.FileOutputStream"; + FileOutputStream["__class"] = "java.io.FileOutputStream"; + FileOutputStream["__interfaces"] = ["java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"]; })(io = java.io || (java.io = {})); })(java || (java = {})); -/* Generated from Java with JSweet 1.2.0-SNAPSHOT - http://www.jsweet.org */ -var java; (function (java) { var io; (function (io) { /** - * JSweet implementation. + * JSweet implementation based on a local storage FS. + * @param {string} n + * @class + * @extends java.io.InputStream */ - var FileReader = (function (_super) { - __extends(FileReader, _super); - function FileReader(fileName) { - if (((typeof fileName === 'string') || fileName === null)) { - _super.call(this, new java.io.FileInputStream(fileName)); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Closeable", "java.lang.Readable", "java.lang.AutoCloseable"] }); - (function () { - })(); + var FileInputStream = /** @class */ (function (_super) { + __extends(FileInputStream, _super); + function FileInputStream(n) { + var _this = this; + if (((typeof n === 'string') || n === null)) { + var __args = arguments; + { + var __args_4 = arguments; + var file = n != null ? new java.io.File(n) : null; + _this = _super.call(this) || this; + if (_this.content === undefined) { + _this.content = null; + } + if (_this.index === undefined) { + _this.index = 0; + } + var name_1 = (file != null ? file.getPath() : null); + if (name_1 == null) { + throw new java.lang.NullPointerException(); + } + if (file.isInvalid()) { + throw new java.io.FileNotFoundException("Invalid file path"); + } + if (!file.exists()) { + throw new java.io.FileNotFoundException(); + } + _this.content = atob(java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()).data); + _this.index = 0; + } + if (_this.content === undefined) { + _this.content = null; + } + if (_this.index === undefined) { + _this.index = 0; + } } - else if (((fileName != null && fileName instanceof java.io.File) || fileName === null)) { - var file = fileName; - _super.call(this, new java.io.FileInputStream(file)); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Closeable", "java.lang.Readable", "java.lang.AutoCloseable"] }); - (function () { - })(); + else if (((n != null && n instanceof java.io.File) || n === null)) { + var __args = arguments; + var file = __args[0]; + _this = _super.call(this) || this; + if (_this.content === undefined) { + _this.content = null; + } + if (_this.index === undefined) { + _this.index = 0; + } + var name_2 = (file != null ? file.getPath() : null); + if (name_2 == null) { + throw new java.lang.NullPointerException(); + } + if (file.isInvalid()) { + throw new java.io.FileNotFoundException("Invalid file path"); + } + if (!file.exists()) { + throw new java.io.FileNotFoundException(); + } + _this.content = atob(java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()).data); + _this.index = 0; } else throw new Error('invalid overload'); + return _this; } - return FileReader; - }(java.io.InputStreamReader)); - io.FileReader = FileReader; - FileReader["__classname"] = "java.io.FileReader"; - })(io = java.io || (java.io = {})); -})(java || (java = {})); -/* Generated from Java with JSweet 1.2.0-SNAPSHOT - http://www.jsweet.org */ -var java; -(function (java) { - var io; - (function (io) { - /** - * Package-private abstract class for the local filesystem abstraction. - */ - var FileSystem = (function () { - function FileSystem() { - } - FileSystem.__static_initialize = function () { if (!FileSystem.__static_initialized) { - FileSystem.__static_initialized = true; - FileSystem.__static_initializer_0(); - } }; - FileSystem.prototype.normalize = function (pathname, len, off) { - if (((typeof pathname === 'string') || pathname === null) && len === undefined && off === undefined) { - return this.normalize$java_lang_String(pathname); + FileInputStream.prototype.read$ = function () { + if (this.index >= this.content.length) { + return -1; } - else - throw new Error('invalid overload'); + return this.content[this.index++]; }; - /** - * Convert the given pathname string to normal form. If the string is - * already in normal form then it is simply returned. - */ - FileSystem.prototype.normalize$java_lang_String = function (path) { throw new Error('cannot invoke abstract overloaded method... check your argument(s) type(s)'); }; - /** - * Resolve the child pathname string against the parent. - * Both strings must be in normal form, and the result - * will be in normal form. - */ - FileSystem.prototype.resolve = function (parent, child) { - if (((typeof parent === 'string') || parent === null) && ((typeof child === 'string') || child === null)) { - return null; + /*private*/ FileInputStream.prototype.readBytes = function (b, off, len) { + if (this.index >= this.content.length) { + return -1; } - else if (((parent != null && parent instanceof java.io.File) || parent === null) && child === undefined) { - return this.resolve$java_io_File(parent); + var count = 0; + for (var i = off; i < off + len; i++) { + { + if (this.index >= this.content.length) { + break; + } + b[i] = this.content[this.index++]; + count++; + } + ; } - else - throw new Error('invalid overload'); + return count; }; - /** - * Resolve the given abstract pathname into absolute form. Invoked by the - * getAbsolutePath and getCanonicalPath methods in the File class. - */ - FileSystem.prototype.resolve$java_io_File = function (f) { throw new Error('cannot invoke abstract overloaded method... check your argument(s) type(s)'); }; - FileSystem.getBooleanProperty = function (prop, defaultVal) { - var val = java.lang.System.getProperty(prop); - if (val == null) - return defaultVal; - if ((function (o1, o2) { return o1.toUpperCase() === (o2 === null ? o2 : o2.toUpperCase()); })(val, "true")) { - return true; + FileInputStream.prototype.read$byte_A = function (b) { + return this.readBytes(b, 0, b.length); + }; + FileInputStream.prototype.read$byte_A$int$int = function (b, off, len) { + return this.readBytes(b, off, len); + }; + FileInputStream.prototype.read = function (b, off, len) { + if (((b != null && b instanceof Array && (b.length == 0 || b[0] == null || (typeof b[0] === 'number'))) || b === null) && ((typeof off === 'number') || off === null) && ((typeof len === 'number') || len === null)) { + return this.read$byte_A$int$int(b, off, len); } - else { - return false; + else if (((b != null && b instanceof Array && (b.length == 0 || b[0] == null || (typeof b[0] === 'number'))) || b === null) && off === undefined && len === undefined) { + return this.read$byte_A(b); } + else if (b === undefined && off === undefined && len === undefined) { + return this.read$(); + } + else + throw new Error('invalid overload'); }; - FileSystem.__static_initializer_0 = function () { - FileSystem.useCanonCaches = FileSystem.getBooleanProperty("sun.io.useCanonCaches", FileSystem.useCanonCaches); - FileSystem.useCanonPrefixCache = FileSystem.getBooleanProperty("sun.io.useCanonPrefixCache", FileSystem.useCanonPrefixCache); - }; - FileSystem.__static_initialized = false; - FileSystem.BA_EXISTS = 1; - FileSystem.BA_REGULAR = 2; - FileSystem.BA_DIRECTORY = 4; - FileSystem.BA_HIDDEN = 8; - FileSystem.ACCESS_READ = 4; - FileSystem.ACCESS_WRITE = 2; - FileSystem.ACCESS_EXECUTE = 1; - FileSystem.SPACE_TOTAL = 0; - FileSystem.SPACE_FREE = 1; - FileSystem.SPACE_USABLE = 2; - FileSystem.useCanonCaches = true; - FileSystem.useCanonPrefixCache = true; - return FileSystem; - }()); - io.FileSystem = FileSystem; - FileSystem["__classname"] = "java.io.FileSystem"; + FileInputStream.prototype.skip = function (n) { + this.index += n; + return n; + }; + FileInputStream.prototype.available = function () { + return this.content.length - this.index; + }; + FileInputStream.prototype.close = function () { + }; + return FileInputStream; + }(java.io.InputStream)); + io.FileInputStream = FileInputStream; + FileInputStream["__class"] = "java.io.FileInputStream"; + FileInputStream["__interfaces"] = ["java.io.Closeable", "java.lang.AutoCloseable"]; })(io = java.io || (java.io = {})); })(java || (java = {})); -/* Generated from Java with JSweet 1.2.0-SNAPSHOT - http://www.jsweet.org */ -var java; (function (java) { var io; (function (io) { /** * JSweet implementation. + * @param {string} fileName + * @param {boolean} append + * @class + * @extends java.io.OutputStreamWriter */ - var FileWriter = (function (_super) { + var FileWriter = /** @class */ (function (_super) { __extends(FileWriter, _super); function FileWriter(fileName, append) { + var _this = this; if (((typeof fileName === 'string') || fileName === null) && ((typeof append === 'boolean') || append === null)) { - _super.call(this, new java.io.FileOutputStream(fileName, append)); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.lang.Appendable", "java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"] }); - (function () { - })(); + var __args = arguments; + _this = _super.call(this, new java.io.FileOutputStream(fileName, append)) || this; } else if (((fileName != null && fileName instanceof java.io.File) || fileName === null) && ((typeof append === 'boolean') || append === null)) { - var file = fileName; - _super.call(this, new java.io.FileOutputStream(file, append)); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.lang.Appendable", "java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"] }); - (function () { - })(); + var __args = arguments; + var file = __args[0]; + _this = _super.call(this, new java.io.FileOutputStream(file, append)) || this; } else if (((typeof fileName === 'string') || fileName === null) && append === undefined) { - _super.call(this, new java.io.FileOutputStream(fileName)); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.lang.Appendable", "java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"] }); - (function () { - })(); + var __args = arguments; + _this = _super.call(this, new java.io.FileOutputStream(fileName)) || this; } else if (((fileName != null && fileName instanceof java.io.File) || fileName === null) && append === undefined) { - var file = fileName; - _super.call(this, new java.io.FileOutputStream(file)); - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.lang.Appendable", "java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"] }); - (function () { - })(); + var __args = arguments; + var file = __args[0]; + _this = _super.call(this, new java.io.FileOutputStream(file)) || this; } else throw new Error('invalid overload'); + return _this; } return FileWriter; }(java.io.OutputStreamWriter)); io.FileWriter = FileWriter; - FileWriter["__classname"] = "java.io.FileWriter"; + FileWriter["__class"] = "java.io.FileWriter"; + FileWriter["__interfaces"] = ["java.lang.Appendable", "java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"]; })(io = java.io || (java.io = {})); })(java || (java = {})); -/* Generated from Java with JSweet 1.2.0-SNAPSHOT - http://www.jsweet.org */ -var test; -(function (test) { - var TestFile = (function () { - function TestFile() { - } - TestFile.assertEquals = function (o1, o2) { - if (!(o1 === o2)) { - throw new Error("invalid assertion: " + o1 + "!=" + o2); - } - }; - TestFile.assertTrue = function (b) { - if (!b) { - throw new Error("invalid assertion"); - } - }; - TestFile.assertFalse = function (b) { - if (b) { - throw new Error("invalid assertion"); - } - }; - TestFile.test = function () { - try { - TestFile.testIO(); - var result = document.getElementById("result"); - if (result != null) { - result.innerHTML = "Success!"; +(function (java) { + var io; + (function (io) { + /** + * JSweet implementation. + * @param {string} fileName + * @class + * @extends java.io.InputStreamReader + */ + var FileReader = /** @class */ (function (_super) { + __extends(FileReader, _super); + function FileReader(fileName) { + var _this = this; + if (((typeof fileName === 'string') || fileName === null)) { + var __args = arguments; + _this = _super.call(this, new java.io.FileInputStream(fileName)) || this; + } + else if (((fileName != null && fileName instanceof java.io.File) || fileName === null)) { + var __args = arguments; + var file = __args[0]; + _this = _super.call(this, new java.io.FileInputStream(file)) || this; } + else + throw new Error('invalid overload'); + return _this; } - catch (e) { - console.error(e); - var result = document.getElementById("result"); - if (result != null) { - result.innerHTML = "Failure: " + e.message; + return FileReader; + }(java.io.InputStreamReader)); + io.FileReader = FileReader; + FileReader["__class"] = "java.io.FileReader"; + FileReader["__interfaces"] = ["java.io.Closeable", "java.lang.Readable", "java.lang.AutoCloseable"]; + })(io = java.io || (java.io = {})); +})(java || (java = {})); +(function (java) { + var io; + (function (io) { + /** + * JSweet implementation. + * @param {string} s + * @class + * @extends java.io.IOException + */ + var FileNotFoundException = /** @class */ (function (_super) { + __extends(FileNotFoundException, _super); + function FileNotFoundException(s) { + var _this = this; + if (((typeof s === 'string') || s === null)) { + var __args = arguments; + _this = _super.call(this, s) || this; + } + else if (s === undefined) { + var __args = arguments; + _this = _super.call(this) || this; } + else + throw new Error('invalid overload'); + return _this; } - ; - }; - TestFile.testIO = function () { - console.info("testing io"); - localStorage.clear(); - var s = new java.io.ByteArrayInputStream(/* getBytes */ ("abc").split('').map(function (s) { return s.charCodeAt(0); })); - TestFile.assertEquals(javaemul.internal.CharacterHelper.getNumericValue('a'), s.read()); - var dir = new java.io.File("/a/b/c"); - TestFile.assertFalse(dir.exists()); - dir.mkdirs(); - TestFile.assertTrue(dir.exists()); - var f = new java.io.File(dir, "test.txt"); - TestFile.assertFalse(f.exists()); - f.createNewFile(); - TestFile.assertTrue(f.exists()); - var fw = new java.io.FileWriter(f); - fw.append("abc"); - fw.close(); - var reader = new java.io.BufferedReader(new java.io.FileReader(f)); - var line = reader.readLine(); - reader.close(); - TestFile.assertEquals("abc", line); - console.info("end testing io"); - }; - return TestFile; - }()); - test.TestFile = TestFile; - TestFile["__classname"] = "test.TestFile"; -})(test || (test = {})); -/* Generated from Java with JSweet 1.2.0-SNAPSHOT - http://www.jsweet.org */ -var java; + FileNotFoundException.serialVersionUID = -897856973823710492; + return FileNotFoundException; + }(java.io.IOException)); + io.FileNotFoundException = FileNotFoundException; + FileNotFoundException["__class"] = "java.io.FileNotFoundException"; + FileNotFoundException["__interfaces"] = ["java.io.Serializable"]; + })(io = java.io || (java.io = {})); +})(java || (java = {})); (function (java) { var io; (function (io) { - var LocalStorageFileSystem = (function (_super) { + var LocalStorageFileSystem = /** @class */ (function (_super) { __extends(LocalStorageFileSystem, _super); function LocalStorageFileSystem() { - _super.call(this); - this.PREFIX = "LSFS://"; + var _this = _super.call(this) || this; + _this.PREFIX = "LSFS://"; + if (_this.roots === undefined) { + _this.roots = null; + } + return _this; } - LocalStorageFileSystem.fs_$LI$ = function () { if (LocalStorageFileSystem.fs == null) - LocalStorageFileSystem.fs = new LocalStorageFileSystem(); return LocalStorageFileSystem.fs; }; - ; + LocalStorageFileSystem.fs_$LI$ = function () { if (LocalStorageFileSystem.fs == null) { + LocalStorageFileSystem.fs = new LocalStorageFileSystem(); + } return LocalStorageFileSystem.fs; }; + /** + * + * @return {string} + */ LocalStorageFileSystem.prototype.getSeparator = function () { return '/'; }; + /** + * + * @return {string} + */ LocalStorageFileSystem.prototype.getPathSeparator = function () { return ':'; }; + LocalStorageFileSystem.prototype.normalize$java_lang_String$int$int = function (pathname, len, off) { + if (len === 0) + return pathname; + var n = len; + while (((n > 0) && ((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(pathname.charAt(n - 1)) == '/'.charCodeAt(0)))) { + n--; + } + ; + if (n === 0) + return "/"; + var sb = new java.lang.StringBuffer(pathname.length); + if (off > 0) + sb.append(pathname.substring(0, off)); + var prevChar = String.fromCharCode(0); + for (var i = off; i < n; i++) { + { + var c = pathname.charAt(i); + if (((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(prevChar) == '/'.charCodeAt(0)) && ((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(c) == '/'.charCodeAt(0))) + continue; + sb.append(c); + prevChar = c; + } + ; + } + return sb.toString(); + }; LocalStorageFileSystem.prototype.normalize = function (pathname, len, off) { if (((typeof pathname === 'string') || pathname === null) && ((typeof len === 'number') || len === null) && ((typeof off === 'number') || off === null)) { - return (function () { - if (len === 0) - return pathname; - var n = len; - while (((n > 0) && (pathname.charAt(n - 1) === '/'))) - n--; - if (n === 0) - return "/"; - var sb = new java.lang.StringBuffer(pathname.length); - if (off > 0) - sb.append(pathname.substring(0, off)); - var prevChar = String.fromCharCode(0); - for (var i = off; i < n; i++) { - var c = pathname.charAt(i); - if ((prevChar === '/') && (c === '/')) - continue; - sb.append(c); - prevChar = c; - } - return sb.toString(); - })(); + return this.normalize$java_lang_String$int$int(pathname, len, off); } else if (((typeof pathname === 'string') || pathname === null) && len === undefined && off === undefined) { return this.normalize$java_lang_String(pathname); @@ -565,34 +665,49 @@ var java; var n = pathname.length; var prevChar = String.fromCharCode(0); for (var i = 0; i < n; i++) { - var c = pathname.charAt(i); - if ((prevChar === '/') && (c === '/')) - return this.normalize(pathname, n, i - 1); - prevChar = c; + { + var c = pathname.charAt(i); + if (((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(prevChar) == '/'.charCodeAt(0)) && ((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(c) == '/'.charCodeAt(0))) + return this.normalize$java_lang_String$int$int(pathname, n, i - 1); + prevChar = c; + } + ; } - if (prevChar === '/') - return this.normalize(pathname, n, n - 1); + if ((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(prevChar) == '/'.charCodeAt(0)) + return this.normalize$java_lang_String$int$int(pathname, n, n - 1); return pathname; }; + /** + * + * @param {string} pathname + * @return {number} + */ LocalStorageFileSystem.prototype.prefixLength = function (pathname) { if (pathname.length === 0) return 0; - return (pathname.charAt(0) === '/') ? 1 : 0; + return ((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(pathname.charAt(0)) == '/'.charCodeAt(0)) ? 1 : 0; + }; + LocalStorageFileSystem.prototype.resolve$java_lang_String$java_lang_String = function (parent, child) { + if (child === ("")) + return parent; + if ((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(child.charAt(0)) == '/'.charCodeAt(0)) { + if (parent === ("/")) + return child; + return parent + child; + } + if (parent === ("/")) + return parent + child; + return parent + '/' + child; }; + /** + * + * @param {string} parent + * @param {string} child + * @return {string} + */ LocalStorageFileSystem.prototype.resolve = function (parent, child) { if (((typeof parent === 'string') || parent === null) && ((typeof child === 'string') || child === null)) { - return (function () { - if ((child === "")) - return parent; - if (child.charAt(0) === '/') { - if ((parent === "/")) - return child; - return parent + child; - } - if ((parent === "/")) - return parent + child; - return parent + '/' + child; - })(); + return this.resolve$java_lang_String$java_lang_String(parent, child); } else if (((parent != null && parent instanceof java.io.File) || parent === null) && child === undefined) { return this.resolve$java_io_File(parent); @@ -600,52 +715,103 @@ var java; else throw new Error('invalid overload'); }; + /** + * + * @return {string} + */ LocalStorageFileSystem.prototype.getDefaultParent = function () { return "/"; }; + /** + * + * @param {string} path + * @return {string} + */ LocalStorageFileSystem.prototype.fromURIPath = function (path) { var p = path; - if ((function (str, searchString) { var pos = str.length - searchString.length; var lastIndex = str.indexOf(searchString, pos); return lastIndex !== -1 && lastIndex === pos; })(p, "/") && (p.length > 1)) { + if ( /* endsWith */(function (str, searchString) { var pos = str.length - searchString.length; var lastIndex = str.indexOf(searchString, pos); return lastIndex !== -1 && lastIndex === pos; })(p, "/") && (p.length > 1)) { p = p.substring(0, p.length - 1); } return p; }; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ LocalStorageFileSystem.prototype.isAbsolute = function (f) { return (f.getPrefixLength() !== 0); }; LocalStorageFileSystem.prototype.resolve$java_io_File = function (f) { if (this.isAbsolute(f)) return f.getPath(); - return this.resolve(java.lang.System.getProperty("user.dir"), f.getPath()); + return this.resolve$java_lang_String$java_lang_String(java.lang.System.getProperty("user.dir"), f.getPath()); }; + /** + * + * @param {string} path + * @return {string} + */ LocalStorageFileSystem.prototype.canonicalize = function (path) { - return this.normalize(path); + return this.normalize$java_lang_String(path); }; + /** + * + * @param {java.io.File} f + * @return {number} + */ LocalStorageFileSystem.prototype.getBooleanAttributes = function (f) { var e = this.getEntry(f.getAbsolutePath()); return e == null ? 0 : e.attributes; }; + /** + * + * @param {java.io.File} f + * @param {number} access + * @return {boolean} + */ LocalStorageFileSystem.prototype.checkAccess = function (f, access) { return (this.getEntry(f.getAbsolutePath()).access & access) !== 0; }; + /** + * + * @param {java.io.File} f + * @param {number} access + * @param {boolean} enable + * @param {boolean} owneronly + * @return {boolean} + */ LocalStorageFileSystem.prototype.setPermission = function (f, access, enable, owneronly) { return false; }; + /** + * + * @param {java.io.File} f + * @return {number} + */ LocalStorageFileSystem.prototype.getLastModifiedTime = function (f) { return this.getEntry(f.getAbsolutePath()).lastModifiedTime; }; + /** + * + * @param {java.io.File} f + * @return {number} + */ LocalStorageFileSystem.prototype.getLength = function (f) { return this.getEntry(f.getAbsolutePath()).length; }; LocalStorageFileSystem.prototype.clear = function () { for (var i = 0; i < localStorage.length; i++) { - var key = localStorage.key(i); - if ((function (str, searchString, position) { - if (position === void 0) { position = 0; } - return str.substr(position, searchString.length) === searchString; - })(key, this.PREFIX)) { - localStorage.removeItem(key); + { + var key = localStorage.key(i); + if ( /* startsWith */(function (str, searchString, position) { + if (position === void 0) { position = 0; } + return str.substr(position, searchString.length) === searchString; + })(key, this.PREFIX)) { + localStorage.removeItem(key); + } } + ; } }; LocalStorageFileSystem.prototype.getKey = function (pathname) { @@ -675,9 +841,14 @@ var java; data: "", attributes: java.io.FileSystem.BA_EXISTS | java.io.FileSystem.BA_REGULAR, access: java.io.FileSystem.ACCESS_READ | java.io.FileSystem.ACCESS_WRITE - }, '__interfaces', { configurable: true, value: ["java.io.LocalStorageFileSystem.Entry"] })); + }, 'constructor', { configurable: true, value: { __interfaces: ["java.io.LocalStorageFileSystem.Entry"] } })); return e; }; + /** + * + * @param {string} pathname + * @return {boolean} + */ LocalStorageFileSystem.prototype.createFileExclusively = function (pathname) { var e = this.createFileEntry(pathname); return e != null; @@ -700,14 +871,14 @@ var java; return directoryEntry.entries; } else { - return new Array(); + return (new Array()); } }; LocalStorageFileSystem.prototype.removeEntry = function (pathname) { { - var array122 = this.getChildEntries(pathname); - for (var index121 = 0; index121 < array122.length; index121++) { - var e = array122[index121]; + var array = this.getChildEntries(pathname); + for (var index = 0; index < array.length; index++) { + var e = array[index]; { this.removeEntry(pathname + "/" + e); } @@ -715,21 +886,35 @@ var java; } localStorage.removeItem(this.getKey(pathname)); }; - LocalStorageFileSystem.prototype.delete = function (f) { + /** + * + * @param {java.io.File} f + * @return {boolean} + */ + LocalStorageFileSystem.prototype["delete"] = function (f) { if (this.hasEntry(f.getAbsolutePath())) { this.removeEntry(f.getAbsolutePath()); var parentPath = f.getParentFile().getAbsolutePath(); var directoryEntry = this.getDirectoryEntry(parentPath); var entries = directoryEntry.entries; - directoryEntry.entries = entries.splice(entries.indexOf(f.getName()), 1); this.putEntry(parentPath, directoryEntry); return true; } return false; }; + /** + * + * @param {java.io.File} f + * @return {java.lang.String[]} + */ LocalStorageFileSystem.prototype.list = function (f) { return this.getChildEntries(f.getAbsolutePath()); }; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ LocalStorageFileSystem.prototype.createDirectory = function (f) { if (this.hasEntry(f.getAbsolutePath())) { return false; @@ -748,27 +933,38 @@ var java; this.putEntry(f.getAbsolutePath(), Object.defineProperty({ attributes: java.io.FileSystem.BA_DIRECTORY | java.io.FileSystem.BA_EXISTS, access: java.io.FileSystem.ACCESS_READ | java.io.FileSystem.ACCESS_WRITE, - entries: new Array(0) - }, '__interfaces', { configurable: true, value: ["java.io.LocalStorageFileSystem.DirectoryEntry", "java.io.LocalStorageFileSystem.Entry"] })); + entries: [] + }, 'constructor', { configurable: true, value: { __interfaces: ["java.io.LocalStorageFileSystem.DirectoryEntry", "java.io.LocalStorageFileSystem.Entry"] } })); return true; }; + /** + * + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {boolean} + */ LocalStorageFileSystem.prototype.rename = function (f1, f2) { var e1 = this.getEntry(f1.getAbsolutePath()); var e2 = this.getEntry(f2.getAbsolutePath()); if (e1 == null || e2 != null) { return false; } - this.delete(f1); + this["delete"](f1); try { this.createFileExclusively(f2.getAbsolutePath()); } catch (e) { return false; } - ; this.putEntry(f2.getAbsolutePath(), e1); return true; }; + /** + * + * @param {java.io.File} f + * @param {number} time + * @return {boolean} + */ LocalStorageFileSystem.prototype.setLastModifiedTime = function (f, time) { var e = this.getEntry(f.getAbsolutePath()); if (e != null) { @@ -779,114 +975,164 @@ var java; return false; } }; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ LocalStorageFileSystem.prototype.setReadOnly = function (f) { this.getEntry(f.getAbsolutePath()).access &= ~java.io.FileSystem.ACCESS_WRITE; return true; }; + /** + * + * @return {java.io.File[]} + */ LocalStorageFileSystem.prototype.listRoots = function () { if (this.roots == null) { this.roots = [new java.io.File("/")]; } return this.roots; }; + /** + * + * @param {java.io.File} f + * @param {number} t + * @return {number} + */ LocalStorageFileSystem.prototype.getSpace = function (f, t) { return 0; }; + /** + * + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {number} + */ LocalStorageFileSystem.prototype.compare = function (f1, f2) { - return f1.getAbsolutePath().localeCompare(f2.getAbsolutePath()); + return /* compareTo */ f1.getAbsolutePath().localeCompare(f2.getAbsolutePath()); }; + /** + * + * @param {java.io.File} f + * @return {number} + */ LocalStorageFileSystem.prototype.hashCode = function (f) { - return f.getAbsolutePath().toString(); + return /* hashCode */ (function (o) { if (o.hashCode) { + return o.hashCode(); + } + else { + return o.toString().split('').reduce(function (prevHash, currVal) { return (((prevHash << 5) - prevHash) + currVal.charCodeAt(0)) | 0; }, 0); + } })(f.getAbsolutePath()); }; return LocalStorageFileSystem; }(java.io.FileSystem)); io.LocalStorageFileSystem = LocalStorageFileSystem; - LocalStorageFileSystem["__classname"] = "java.io.LocalStorageFileSystem"; + LocalStorageFileSystem["__class"] = "java.io.LocalStorageFileSystem"; })(io = java.io || (java.io = {})); })(java || (java = {})); -/* Generated from Java with JSweet 1.2.0-SNAPSHOT - http://www.jsweet.org */ -var java; (function (java) { var io; (function (io) { /** * JSweet implementation for file. + * @param {string} parent + * @param {string} child + * @class */ - var File = (function () { + var File = /** @class */ (function () { function File(parent, child, direct) { - var _this = this; - this.status = null; if (((parent != null && parent instanceof java.io.File) || parent === null) && ((typeof child === 'string') || child === null) && ((typeof direct === 'boolean') || direct === null)) { - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.lang.Comparable", "java.io.Serializable"] }); - this.prefixLength = 0; - (function () { - _this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve(parent.path, child); - _this.prefixLength = parent.prefixLength; - })(); + var __args = arguments; + if (this.path === undefined) { + this.path = null; + } + if (this.prefixLength === undefined) { + this.prefixLength = 0; + } + this.status = null; + this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve$java_lang_String$java_lang_String(parent.path, child); + this.prefixLength = parent.prefixLength; } else if (((typeof parent === 'string') || parent === null) && ((typeof child === 'string') || child === null) && direct === undefined) { - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.lang.Comparable", "java.io.Serializable"] }); - this.prefixLength = 0; - (function () { - if (child == null) { - throw new java.lang.NullPointerException(); - } - if (parent != null) { - if ((parent === "")) { - _this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve(java.io.LocalStorageFileSystem.fs_$LI$().getDefaultParent(), java.io.LocalStorageFileSystem.fs_$LI$().normalize(child)); - } - else { - _this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve(java.io.LocalStorageFileSystem.fs_$LI$().normalize(parent), java.io.LocalStorageFileSystem.fs_$LI$().normalize(child)); - } + var __args = arguments; + if (this.path === undefined) { + this.path = null; + } + if (this.prefixLength === undefined) { + this.prefixLength = 0; + } + this.status = null; + if (child == null) { + throw new java.lang.NullPointerException(); + } + if (parent != null) { + if (parent === ("")) { + this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve$java_lang_String$java_lang_String(java.io.LocalStorageFileSystem.fs_$LI$().getDefaultParent(), java.io.LocalStorageFileSystem.fs_$LI$().normalize$java_lang_String(child)); } else { - _this.path = java.io.LocalStorageFileSystem.fs_$LI$().normalize(child); + this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve$java_lang_String$java_lang_String(java.io.LocalStorageFileSystem.fs_$LI$().normalize$java_lang_String(parent), java.io.LocalStorageFileSystem.fs_$LI$().normalize$java_lang_String(child)); } - _this.prefixLength = java.io.LocalStorageFileSystem.fs_$LI$().prefixLength(_this.path); - })(); + } + else { + this.path = java.io.LocalStorageFileSystem.fs_$LI$().normalize$java_lang_String(child); + } + this.prefixLength = java.io.LocalStorageFileSystem.fs_$LI$().prefixLength(this.path); } else if (((parent != null && parent instanceof java.io.File) || parent === null) && ((typeof child === 'string') || child === null) && direct === undefined) { - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.lang.Comparable", "java.io.Serializable"] }); - this.prefixLength = 0; - (function () { - if (child == null) { - throw new java.lang.NullPointerException(); - } - if (parent != null) { - if ((parent.path === "")) { - _this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve(java.io.LocalStorageFileSystem.fs_$LI$().getDefaultParent(), java.io.LocalStorageFileSystem.fs_$LI$().normalize(child)); - } - else { - _this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve(parent.path, java.io.LocalStorageFileSystem.fs_$LI$().normalize(child)); - } + var __args = arguments; + if (this.path === undefined) { + this.path = null; + } + if (this.prefixLength === undefined) { + this.prefixLength = 0; + } + this.status = null; + if (child == null) { + throw new java.lang.NullPointerException(); + } + if (parent != null) { + if (parent.path === ("")) { + this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve$java_lang_String$java_lang_String(java.io.LocalStorageFileSystem.fs_$LI$().getDefaultParent(), java.io.LocalStorageFileSystem.fs_$LI$().normalize$java_lang_String(child)); } else { - _this.path = java.io.LocalStorageFileSystem.fs_$LI$().normalize(child); + this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve$java_lang_String$java_lang_String(parent.path, java.io.LocalStorageFileSystem.fs_$LI$().normalize$java_lang_String(child)); } - _this.prefixLength = java.io.LocalStorageFileSystem.fs_$LI$().prefixLength(_this.path); - })(); + } + else { + this.path = java.io.LocalStorageFileSystem.fs_$LI$().normalize$java_lang_String(child); + } + this.prefixLength = java.io.LocalStorageFileSystem.fs_$LI$().prefixLength(this.path); } else if (((typeof parent === 'string') || parent === null) && ((typeof child === 'number') || child === null) && direct === undefined) { - var pathname = parent; - var prefixLength = child; - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.lang.Comparable", "java.io.Serializable"] }); - this.prefixLength = 0; - (function () { - _this.path = pathname; - _this.prefixLength = prefixLength; - })(); + var __args = arguments; + var pathname = __args[0]; + var prefixLength = __args[1]; + if (this.path === undefined) { + this.path = null; + } + if (this.prefixLength === undefined) { + this.prefixLength = 0; + } + this.status = null; + this.path = pathname; + this.prefixLength = prefixLength; } else if (((typeof parent === 'string') || parent === null) && child === undefined && direct === undefined) { - var pathname = parent; - Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.lang.Comparable", "java.io.Serializable"] }); - this.prefixLength = 0; - (function () { - if (pathname == null) { - throw new java.lang.NullPointerException(); - } - _this.path = java.io.LocalStorageFileSystem.fs_$LI$().normalize(pathname); - _this.prefixLength = java.io.LocalStorageFileSystem.fs_$LI$().prefixLength(_this.path); - })(); + var __args = arguments; + var pathname = __args[0]; + if (this.path === undefined) { + this.path = null; + } + if (this.prefixLength === undefined) { + this.prefixLength = 0; + } + this.status = null; + if (pathname == null) { + throw new java.lang.NullPointerException(); + } + this.path = java.io.LocalStorageFileSystem.fs_$LI$().normalize$java_lang_String(pathname); + this.prefixLength = java.io.LocalStorageFileSystem.fs_$LI$().prefixLength(this.path); } else throw new Error('invalid overload'); @@ -900,18 +1146,18 @@ var java; File.prototype.getPrefixLength = function () { return this.prefixLength; }; - File.separatorChar_$LI$ = function () { if (File.separatorChar == null) - File.separatorChar = java.io.LocalStorageFileSystem.fs_$LI$().getSeparator(); return File.separatorChar; }; - ; - File.separator_$LI$ = function () { if (File.separator == null) - File.separator = "" + File.separatorChar_$LI$(); return File.separator; }; - ; - File.pathSeparatorChar_$LI$ = function () { if (File.pathSeparatorChar == null) - File.pathSeparatorChar = java.io.LocalStorageFileSystem.fs_$LI$().getPathSeparator(); return File.pathSeparatorChar; }; - ; - File.pathSeparator_$LI$ = function () { if (File.pathSeparator == null) - File.pathSeparator = "" + File.pathSeparatorChar_$LI$(); return File.pathSeparator; }; - ; + File.separatorChar_$LI$ = function () { if (File.separatorChar == null) { + File.separatorChar = java.io.LocalStorageFileSystem.fs_$LI$().getSeparator(); + } return File.separatorChar; }; + File.separator_$LI$ = function () { if (File.separator == null) { + File.separator = "" + File.separatorChar_$LI$(); + } return File.separator; }; + File.pathSeparatorChar_$LI$ = function () { if (File.pathSeparatorChar == null) { + File.pathSeparatorChar = java.io.LocalStorageFileSystem.fs_$LI$().getPathSeparator(); + } return File.pathSeparatorChar; }; + File.pathSeparator_$LI$ = function () { if (File.pathSeparator == null) { + File.pathSeparator = "" + File.pathSeparatorChar_$LI$(); + } return File.pathSeparator; }; File.prototype.getName = function () { var index = this.path.lastIndexOf(File.separatorChar_$LI$()); if (index < this.prefixLength) @@ -940,7 +1186,7 @@ var java; return java.io.LocalStorageFileSystem.fs_$LI$().isAbsolute(this); }; File.prototype.getAbsolutePath = function () { - return java.io.LocalStorageFileSystem.fs_$LI$().resolve(this); + return java.io.LocalStorageFileSystem.fs_$LI$().resolve$java_io_File(this); }; File.prototype.getAbsoluteFile = function () { var absPath = this.getAbsolutePath(); @@ -950,7 +1196,7 @@ var java; if (this.isInvalid()) { throw new java.io.IOException("Invalid file path"); } - return java.io.LocalStorageFileSystem.fs_$LI$().canonicalize(java.io.LocalStorageFileSystem.fs_$LI$().resolve(this)); + return java.io.LocalStorageFileSystem.fs_$LI$().canonicalize(java.io.LocalStorageFileSystem.fs_$LI$().resolve$java_io_File(this)); }; File.prototype.getCanonicalFile = function () { var canonPath = this.getCanonicalPath(); @@ -958,8 +1204,8 @@ var java; }; File.slashify = function (path, isDirectory) { var p = path; - if (File.separatorChar_$LI$() !== '/') - p = p.split(File.separatorChar_$LI$()).join('/'); + if ((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(File.separatorChar_$LI$()) != '/'.charCodeAt(0)) + p = /* replace */ p.split(File.separatorChar_$LI$()).join('/'); if (!(function (str, searchString, position) { if (position === void 0) { position = 0; } return str.substr(position, searchString.length) === searchString; @@ -1023,11 +1269,11 @@ var java; } return java.io.LocalStorageFileSystem.fs_$LI$().createFileExclusively(this.path); }; - File.prototype.delete = function () { + File.prototype["delete"] = function () { if (this.isInvalid()) { return false; } - return java.io.LocalStorageFileSystem.fs_$LI$().delete(this); + return java.io.LocalStorageFileSystem.fs_$LI$()["delete"](this); }; File.prototype.list$ = function () { if (this.isInvalid()) { @@ -1035,22 +1281,26 @@ var java; } return java.io.LocalStorageFileSystem.fs_$LI$().list(this); }; - File.prototype.list = function (filter) { - var _this = this; - if (((typeof filter === 'function' && filter.length == 2) || filter === null)) { - return (function () { - var names = _this.list(); - if ((names == null) || (filter == null)) { - return names; - } - var v = new java.util.ArrayList(); - for (var i = 0; i < names.length; i++) { - if (filter(_this, names[i])) { - v.add(names[i]); - } + File.prototype.list$java_io_FilenameFilter = function (filter) { + var names = this.list$(); + if ((names == null) || (filter == null)) { + return names; + } + var v = (new java.util.ArrayList()); + for (var i = 0; i < names.length; i++) { + { + if (filter(this, names[i])) { + v.add(names[i]); } - return v.toArray(new Array(v.size())); - })(); + } + ; + } + return v.toArray((function (s) { var a = []; while (s-- > 0) + a.push(null); return a; })(v.size())); + }; + File.prototype.list = function (filter) { + if (((typeof filter === 'function' && filter.length === 2) || filter === null)) { + return this.list$java_io_FilenameFilter(filter); } else if (filter === undefined) { return this.list$(); @@ -1059,33 +1309,38 @@ var java; throw new Error('invalid overload'); }; File.prototype.listFiles$ = function () { - var ss = this.list(); + var ss = this.list$(); if (ss == null) return null; var n = ss.length; - var fs = new Array(n); + var fs = (function (s) { var a = []; while (s-- > 0) + a.push(null); return a; })(n); for (var i = 0; i < n; i++) { - fs[i] = new File(this, ss[i], true); + { + fs[i] = new File(this, ss[i], true); + } + ; } return fs; }; + File.prototype.listFiles$java_io_FilenameFilter = function (filter) { + var ss = this.list$(); + if (ss == null) + return null; + var files = (new java.util.ArrayList()); + for (var index = 0; index < ss.length; index++) { + var s = ss[index]; + if ((filter == null) || filter(this, s)) + files.add(new File(this, s, true)); + } + return files.toArray((function (s) { var a = []; while (s-- > 0) + a.push(null); return a; })(files.size())); + }; File.prototype.listFiles = function (filter) { - var _this = this; - if (((typeof filter === 'function' && filter.length == 2) || filter === null)) { - return (function () { - var ss = _this.list(); - if (ss == null) - return null; - var files = new java.util.ArrayList(); - for (var index123 = 0; index123 < ss.length; index123++) { - var s = ss[index123]; - if ((filter == null) || filter(_this, s)) - files.add(new File(_this, s, true)); - } - return files.toArray(new Array(files.size())); - })(); + if (((typeof filter === 'function' && filter.length === 2) || filter === null)) { + return this.listFiles$java_io_FilenameFilter(filter); } - else if (((typeof filter === 'function' && filter.length == 1) || filter === null)) { + else if (((typeof filter === 'function' && filter.length === 1) || filter === null)) { return this.listFiles$java_io_FileFilter(filter); } else if (filter === undefined) { @@ -1095,19 +1350,20 @@ var java; throw new Error('invalid overload'); }; File.prototype.listFiles$java_io_FileFilter = function (filter) { - var ss = this.list(); + var ss = this.list$(); if (ss == null) return null; - var files = new java.util.ArrayList(); - for (var index124 = 0; index124 < ss.length; index124++) { - var s = ss[index124]; + var files = (new java.util.ArrayList()); + for (var index = 0; index < ss.length; index++) { + var s = ss[index]; { var f = new File(this, s, true); if ((filter == null) || filter(f)) files.add(f); } } - return files.toArray(new Array(files.size())); + return files.toArray((function (s) { var a = []; while (s-- > 0) + a.push(null); return a; })(files.size())); }; File.prototype.mkdir = function () { if (this.isInvalid()) { @@ -1129,7 +1385,6 @@ var java; catch (e) { return false; } - ; var parent = canonFile.getParentFile(); return (parent != null && (parent.mkdirs() || parent.exists()) && canonFile.mkdir()); }; @@ -1156,27 +1411,63 @@ var java; } return java.io.LocalStorageFileSystem.fs_$LI$().setReadOnly(this); }; - File.prototype.setWritable = function (writable, ownerOnly) { - if (ownerOnly === void 0) { ownerOnly = true; } + File.prototype.setWritable$boolean$boolean = function (writable, ownerOnly) { if (this.isInvalid()) { return false; } return java.io.LocalStorageFileSystem.fs_$LI$().setPermission(this, java.io.FileSystem.ACCESS_WRITE, writable, ownerOnly); }; - File.prototype.setReadable = function (readable, ownerOnly) { - if (ownerOnly === void 0) { ownerOnly = true; } + File.prototype.setWritable = function (writable, ownerOnly) { + if (((typeof writable === 'boolean') || writable === null) && ((typeof ownerOnly === 'boolean') || ownerOnly === null)) { + return this.setWritable$boolean$boolean(writable, ownerOnly); + } + else if (((typeof writable === 'boolean') || writable === null) && ownerOnly === undefined) { + return this.setWritable$boolean(writable); + } + else + throw new Error('invalid overload'); + }; + File.prototype.setWritable$boolean = function (writable) { + return this.setWritable$boolean$boolean(writable, true); + }; + File.prototype.setReadable$boolean$boolean = function (readable, ownerOnly) { if (this.isInvalid()) { return false; } return java.io.LocalStorageFileSystem.fs_$LI$().setPermission(this, java.io.FileSystem.ACCESS_READ, readable, ownerOnly); }; - File.prototype.setExecutable = function (executable, ownerOnly) { - if (ownerOnly === void 0) { ownerOnly = true; } + File.prototype.setReadable = function (readable, ownerOnly) { + if (((typeof readable === 'boolean') || readable === null) && ((typeof ownerOnly === 'boolean') || ownerOnly === null)) { + return this.setReadable$boolean$boolean(readable, ownerOnly); + } + else if (((typeof readable === 'boolean') || readable === null) && ownerOnly === undefined) { + return this.setReadable$boolean(readable); + } + else + throw new Error('invalid overload'); + }; + File.prototype.setReadable$boolean = function (readable) { + return this.setReadable$boolean$boolean(readable, true); + }; + File.prototype.setExecutable$boolean$boolean = function (executable, ownerOnly) { if (this.isInvalid()) { return false; } return java.io.LocalStorageFileSystem.fs_$LI$().setPermission(this, java.io.FileSystem.ACCESS_EXECUTE, executable, ownerOnly); }; + File.prototype.setExecutable = function (executable, ownerOnly) { + if (((typeof executable === 'boolean') || executable === null) && ((typeof ownerOnly === 'boolean') || ownerOnly === null)) { + return this.setExecutable$boolean$boolean(executable, ownerOnly); + } + else if (((typeof executable === 'boolean') || executable === null) && ownerOnly === undefined) { + return this.setExecutable$boolean(executable); + } + else + throw new Error('invalid overload'); + }; + File.prototype.setExecutable$boolean = function (executable) { + return this.setExecutable$boolean$boolean(executable, true); + }; File.prototype.canExecute = function () { if (this.isInvalid()) { return false; @@ -1204,8 +1495,7 @@ var java; } return java.io.LocalStorageFileSystem.fs_$LI$().getSpace(this, java.io.FileSystem.SPACE_USABLE); }; - File.createTempFile = function (prefix, suffix, directory) { - if (directory === void 0) { directory = null; } + File.createTempFile$java_lang_String$java_lang_String$java_io_File = function (prefix, suffix, directory) { if (prefix.length < 3) throw new java.lang.IllegalArgumentException("Prefix string too short"); if (suffix == null) @@ -1213,12 +1503,27 @@ var java; var tmpdir = (directory != null) ? directory : File.TempDirectory.location(); var f; do { - f = File.TempDirectory.generateFile(prefix, suffix, tmpdir); + { + f = File.TempDirectory.generateFile(prefix, suffix, tmpdir); + } } while (((java.io.LocalStorageFileSystem.fs_$LI$().getBooleanAttributes(f) & java.io.FileSystem.BA_EXISTS) !== 0)); if (!java.io.LocalStorageFileSystem.fs_$LI$().createFileExclusively(f.getPath())) throw new java.io.IOException("Unable to create temporary file"); return f; }; + File.createTempFile = function (prefix, suffix, directory) { + if (((typeof prefix === 'string') || prefix === null) && ((typeof suffix === 'string') || suffix === null) && ((directory != null && directory instanceof java.io.File) || directory === null)) { + return java.io.File.createTempFile$java_lang_String$java_lang_String$java_io_File(prefix, suffix, directory); + } + else if (((typeof prefix === 'string') || prefix === null) && ((typeof suffix === 'string') || suffix === null) && directory === undefined) { + return java.io.File.createTempFile$java_lang_String$java_lang_String(prefix, suffix); + } + else + throw new Error('invalid overload'); + }; + File.createTempFile$java_lang_String$java_lang_String = function (prefix, suffix) { + return File.createTempFile$java_lang_String$java_lang_String$java_io_File(prefix, suffix, null); + }; File.prototype.compareTo = function (pathname) { return java.io.LocalStorageFileSystem.fs_$LI$().compare(this, pathname); }; @@ -1238,25 +1543,25 @@ var java; return File; }()); io.File = File; - File["__classname"] = "java.io.File"; - var File; + File["__class"] = "java.io.File"; + File["__interfaces"] = ["java.lang.Comparable", "java.io.Serializable"]; (function (File) { + var PathStatus; (function (PathStatus) { PathStatus[PathStatus["INVALID"] = 0] = "INVALID"; PathStatus[PathStatus["CHECKED"] = 1] = "CHECKED"; - })(File.PathStatus || (File.PathStatus = {})); - var PathStatus = File.PathStatus; - var TempDirectory = (function () { + })(PathStatus = File.PathStatus || (File.PathStatus = {})); + var TempDirectory = /** @class */ (function () { function TempDirectory() { } - TempDirectory.tmpdir_$LI$ = function () { if (TempDirectory.tmpdir == null) - TempDirectory.tmpdir = new java.io.File(java.lang.System.getProperty("java.io.tmpdir")); return TempDirectory.tmpdir; }; - ; + TempDirectory.tmpdir_$LI$ = function () { if (TempDirectory.tmpdir == null) { + TempDirectory.tmpdir = new java.io.File(java.lang.System.getProperty("java.io.tmpdir")); + } return TempDirectory.tmpdir; }; TempDirectory.location = function () { return TempDirectory.tmpdir_$LI$(); }; TempDirectory.generateFile = function (prefix, suffix, dir) { - var n = Math.round(Math.random()) * javaemul.internal.LongHelper.MAX_VALUE; + var n = (function (n) { return n < 0 ? Math.ceil(n) : Math.floor(n); })(Math.random()) * javaemul.internal.LongHelper.MAX_VALUE; if (n === javaemul.internal.LongHelper.MIN_VALUE) { n = 0; } @@ -1264,7 +1569,7 @@ var java; n = Math.abs(n); } prefix = (new java.io.File(prefix)).getName(); - var name = prefix + ('' + n) + suffix; + var name = prefix + /* toString */ ('' + (n)) + suffix; var f = new java.io.File(dir, name); if (!(name === f.getName()) || f.isInvalid()) { throw new java.io.IOException("Unable to create temporary file, " + f); @@ -1274,7 +1579,7 @@ var java; return TempDirectory; }()); File.TempDirectory = TempDirectory; - TempDirectory["__classname"] = "java.io.File.TempDirectory"; + TempDirectory["__class"] = "java.io.File.TempDirectory"; })(File = io.File || (io.File = {})); })(io = java.io || (java.io = {})); })(java || (java = {})); diff --git a/pom.xml b/pom.xml index 2ebb99c..f8c6bd4 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ - + 4.0.0 org.jsweet.candies.j4ts j4ts-file @@ -10,7 +10,7 @@ The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt repo @@ -18,26 +18,26 @@ jsweet-central libs-release - http://repository.jsweet.org/artifactory/libs-release-local + https://repository.jsweet.org/artifactory/libs-release-local jsweet-snapshots libs-snapshot - http://repository.jsweet.org/artifactory/libs-snapshot-local + https://repository.jsweet.org/artifactory/libs-snapshot-local jsweet-plugins-release plugins-release - http://repository.jsweet.org/artifactory/plugins-release-local + https://repository.jsweet.org/artifactory/plugins-release-local jsweet-plugins-snapshots plugins-snapshot - http://repository.jsweet.org/artifactory/plugins-snapshot-local + https://repository.jsweet.org/artifactory/plugins-snapshot-local @@ -60,7 +60,7 @@ org.jsweet jsweet-maven-plugin - 1.2.0-SNAPSHOT + 3.1.0 true @@ -69,6 +69,7 @@ src/main/resources/META-INF/resources/webjars/${project.artifactId}/${project.version} src/main/resources/src/typings/${project.artifactId}/${project.version} ES3 + -source,1.8,-target,1.8 @@ -149,14 +150,14 @@ test - org.jsweet.candies + org.jsweet jsweet-core - 1.2.0-SNAPSHOT + 6.3.1 - org.jsweet.candies + org.jsweet j4ts - 0.3.0-SNAPSHOT + 2.1.0-SNAPSHOT @@ -164,17 +165,17 @@ jsweet-release libs-release - http://repository.jsweet.org/artifactory/libs-release-local + https://repository.jsweet.org/artifactory/libs-release-local jsweet-snapshots libs-snapshot - http://repository.jsweet.org/artifactory/libs-snapshot-local + https://repository.jsweet.org/artifactory/libs-snapshot-local JSweet - http://www.jsweet.org + https://www.jsweet.org \ No newline at end of file diff --git a/src/main/java/java/io/FileInputStream.java b/src/main/java/java/io/FileInputStream.java index 823b46b..6c349fb 100644 --- a/src/main/java/java/io/FileInputStream.java +++ b/src/main/java/java/io/FileInputStream.java @@ -1,7 +1,7 @@ package java.io; -import static jsweet.dom.Globals.atob; -import static jsweet.util.Globals.any; +import static def.dom.Globals.atob; +import static jsweet.util.Lang.any; /** * JSweet implementation based on a local storage FS. @@ -11,8 +11,8 @@ public class FileInputStream extends InputStream { private byte[] content; private int index; - public FileInputStream(String name) throws FileNotFoundException { - this(name != null ? new File(name) : null); + public FileInputStream(String n) throws FileNotFoundException { + this(n != null ? new File(n) : null); } public FileInputStream(File file) throws FileNotFoundException { diff --git a/src/main/java/java/io/FileOutputStream.java b/src/main/java/java/io/FileOutputStream.java index aa8a4f4..fa6c26f 100644 --- a/src/main/java/java/io/FileOutputStream.java +++ b/src/main/java/java/io/FileOutputStream.java @@ -1,7 +1,7 @@ package java.io; -import static jsweet.dom.Globals.btoa; -import static jsweet.util.Globals.array; +import static def.dom.Globals.btoa; +import static jsweet.util.Lang.array; /** * JSweet partial implementation based on a local storage FS. @@ -65,10 +65,18 @@ public void write(byte b[], int off, int len) throws IOException { @Override public void flush() throws IOException { - entry.data = btoa(array(array(content).map((b, __, ___) -> { - return jsweet.lang.String.fromCharCode(b); - })).join("")); - LocalStorageFileSystem.fs.putEntry(file.getAbsolutePath(), entry); + + // SV TODO: get this to compile successfully. JSweet says: + // [ERROR] * /Users/vorth/vZome/j4ts-file/src/main/java/java/io/FileOutputStream.java(72,18)cannot find symbol + // [ERROR] symbol: method join() + // [ERROR] location: class def.js.String[] + + // entry.data = btoa(array( + // array(content).map( (b, __, ___) -> { + // return def.js.String.fromCharCode(b); + // }) + // ).join()); + // LocalStorageFileSystem.fs.putEntry(file.getAbsolutePath(), entry); } public void close() throws IOException { diff --git a/src/main/java/java/io/FilenameFilter.java b/src/main/java/java/io/FilenameFilter.java new file mode 100644 index 0000000..ed54fbf --- /dev/null +++ b/src/main/java/java/io/FilenameFilter.java @@ -0,0 +1,6 @@ +package java.io; + +@FunctionalInterface +public interface FilenameFilter { + boolean accept(File dir, String name); +} diff --git a/src/main/java/java/io/LocalStorageFileSystem.java b/src/main/java/java/io/LocalStorageFileSystem.java index b0757c3..6c24078 100644 --- a/src/main/java/java/io/LocalStorageFileSystem.java +++ b/src/main/java/java/io/LocalStorageFileSystem.java @@ -1,11 +1,11 @@ package java.io; -import static jsweet.dom.Globals.localStorage; -import static jsweet.util.Globals.array; +import static def.dom.Globals.localStorage; +import static jsweet.util.Lang.array; -import jsweet.lang.Array; +import def.js.Array; import jsweet.lang.Interface; -import jsweet.lang.JSON; +import def.js.JSON; public class LocalStorageFileSystem extends FileSystem { @@ -245,8 +245,11 @@ public boolean delete(File f) { removeEntry(f.getAbsolutePath()); String parentPath = f.getParentFile().getAbsolutePath(); DirectoryEntry directoryEntry = getDirectoryEntry(parentPath); - Array entries = array(directoryEntry.entries); - directoryEntry.entries = entries.splice(entries.indexOf(f.getName()), 1); + Array entries = array(directoryEntry.entries); + + // SV TODO: get this to compile. JSweet says: + // 2022-08-21 18:15:00.000 ERROR JSweetTranspiler:99 - /Users/vorth/vZome/j4ts-file/src/main/java/java/io/LocalStorageFileSystem.java:252: error: incompatible types: def.js.Array cannot be converted to java.lang.String[] + // directoryEntry.entries = entries.splice(entries.indexOf(f.getName()), 1); putEntry(parentPath, directoryEntry); return true; } diff --git a/src/main/java/test/TestFile.java b/src/main/java/test/TestFile.java index 0962b6b..a8ae571 100644 --- a/src/main/java/test/TestFile.java +++ b/src/main/java/test/TestFile.java @@ -1,8 +1,8 @@ package test; -import static jsweet.dom.Globals.console; -import static jsweet.dom.Globals.document; -import static jsweet.dom.Globals.localStorage; +import static def.dom.Globals.console; +import static def.dom.Globals.document; +import static def.dom.Globals.localStorage; import java.io.BufferedReader; import java.io.ByteArrayInputStream; @@ -11,13 +11,14 @@ import java.io.FileWriter; import java.io.IOException; -import jsweet.dom.HTMLElement; -import jsweet.util.Globals; +import def.dom.HTMLElement; +import def.dom.Globals; +import static jsweet.util.Lang.$strict; public class TestFile { public static void assertEquals(Object o1, Object o2) { - if (!Globals.equalsStrict(o1, o2)) { + if ($strict(o1 == o2)) { throw new Error("invalid assertion: " + o1 + "!=" + o2); } } diff --git a/src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/bundle.d.ts b/src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/bundle.d.ts index 3ab3b44..09a3959 100644 --- a/src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/bundle.d.ts +++ b/src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/bundle.d.ts @@ -1,100 +1,59 @@ -declare namespace java.io { - interface FileFilter { - (pathname: java.io.File): boolean; - } -} -declare namespace java.io { - /** - * JSweet implementation based on a local storage FS. - */ - class FileInputStream extends java.io.InputStream { - private content; - private index; - constructor(name?: any); - read$(): number; - private readBytes(b, off, len); - read$byte_A(b: number[]): number; - read(b?: any, off?: any, len?: any): any; - skip(n: number): number; - available(): number; - close(): void; - } -} -declare namespace java.io { - /** - * JSweet implementation. - */ - class FileNotFoundException extends java.io.IOException { - static serialVersionUID: number; - constructor(s?: any); - } -} -declare namespace java.io { - /** - * JSweet partial implementation based on a local storage FS. - */ - class FileOutputStream extends java.io.OutputStream { - /** - * True if the file is opened for append. - */ - private append; - private file; - private entry; - private content; - constructor(name?: any, append?: any); - private write$int$boolean(b, append); - write$int(b: number): void; - private writeBytes(b, off, len, append); - write$byte_A(b: number[]): void; - write(b?: any, off?: any, len?: any): any; - flush(): void; - close(): void; - } -} -declare namespace java.io { - /** - * JSweet implementation. - */ - class FileReader extends java.io.InputStreamReader { - constructor(fileName?: any); +declare namespace test { + class TestFile { + static assertEquals(o1: any, o2: any): void; + static assertTrue(b: boolean): void; + static assertFalse(b: boolean): void; + static test(): void; + static testIO(): void; } } declare namespace java.io { /** * Package-private abstract class for the local filesystem abstraction. + * @class */ abstract class FileSystem { static __static_initialized: boolean; static __static_initialize(): void; /** * Return the local filesystem's name-separator character. + * @return {string} */ abstract getSeparator(): string; /** * Return the local filesystem's path-separator character. + * @return {string} */ abstract getPathSeparator(): string; - normalize(pathname?: any, len?: any, off?: any): any; /** * Convert the given pathname string to normal form. If the string is * already in normal form then it is simply returned. + * @param {string} path + * @return {string} */ - normalize$java_lang_String(path: string): string; + abstract normalize(path: string): string; /** * Compute the length of this pathname string's prefix. The pathname * string must be in normal form. + * @param {string} path + * @return {number} */ abstract prefixLength(path: string): number; + resolve$java_lang_String$java_lang_String(parent: string, child: string): string; /** * Resolve the child pathname string against the parent. * Both strings must be in normal form, and the result * will be in normal form. + * @param {string} parent + * @param {string} child + * @return {string} */ - resolve(parent?: any, child?: any): any; + resolve(parent?: any, child?: any): string; /** * Return the parent pathname string to be used when the parent-directory * argument in one of the two-argument File constructors is the empty * pathname. + * @return {string} */ abstract getDefaultParent(): string; /** @@ -102,16 +61,16 @@ declare namespace java.io { * win32, e.g., to transform "/c:/foo" into "c:/foo". The path string * still has slash separators; code in the File class will translate them * after this method returns. + * @param {string} path + * @return {string} */ abstract fromURIPath(path: string): string; /** * Tell whether or not the given abstract pathname is absolute. + * @param {java.io.File} f + * @return {boolean} */ abstract isAbsolute(f: java.io.File): boolean; - /** - * Resolve the given abstract pathname into absolute form. Invoked by the - * getAbsolutePath and getCanonicalPath methods in the File class. - */ resolve$java_io_File(f: java.io.File): string; abstract canonicalize(path: string): string; static BA_EXISTS: number; @@ -122,6 +81,8 @@ declare namespace java.io { * Return the simple boolean attributes for the file or directory denoted * by the given abstract pathname, or zero if it does not exist or some * other I/O error occurs. + * @param {java.io.File} f + * @return {number} */ abstract getBooleanAttributes(f: java.io.File): number; static ACCESS_READ: number; @@ -132,24 +93,36 @@ declare namespace java.io { * pathname may be accessed by this process. The second argument specifies * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check. * Return false if access is denied or an I/O error occurs + * @param {java.io.File} f + * @param {number} access + * @return {boolean} */ abstract checkAccess(f: java.io.File, access: number): boolean; /** * Set on or off the access permission (to owner only or to all) to the file * or directory denoted by the given abstract pathname, based on the parameters * enable, access and oweronly. + * @param {java.io.File} f + * @param {number} access + * @param {boolean} enable + * @param {boolean} owneronly + * @return {boolean} */ abstract setPermission(f: java.io.File, access: number, enable: boolean, owneronly: boolean): boolean; /** * Return the time at which the file or directory denoted by the given * abstract pathname was last modified, or zero if it does not exist or * some other I/O error occurs. + * @param {java.io.File} f + * @return {number} */ abstract getLastModifiedTime(f: java.io.File): number; /** * Return the length in bytes of the file denoted by the given abstract * pathname, or zero if it does not exist, is a directory, or some other * I/O error occurs. + * @param {java.io.File} f + * @return {number} */ abstract getLength(f: java.io.File): number; /** @@ -157,44 +130,61 @@ declare namespace java.io { * true if the file was created and false if a * file or directory with the given pathname already exists. Throw an * IOException if an I/O error occurs. + * @param {string} pathname + * @return {boolean} */ abstract createFileExclusively(pathname: string): boolean; /** * Delete the file or directory denoted by the given abstract pathname, * returning true if and only if the operation succeeds. + * @param {java.io.File} f + * @return {boolean} */ abstract delete(f: java.io.File): boolean; /** * List the elements of the directory denoted by the given abstract * pathname. Return an array of strings naming the elements of the * directory if successful; otherwise, return null. + * @param {java.io.File} f + * @return {java.lang.String[]} */ abstract list(f: java.io.File): string[]; /** * Create a new directory denoted by the given abstract pathname, * returning true if and only if the operation succeeds. + * @param {java.io.File} f + * @return {boolean} */ abstract createDirectory(f: java.io.File): boolean; /** * Rename the file or directory denoted by the first abstract pathname to * the second abstract pathname, returning true if and only if * the operation succeeds. + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {boolean} */ abstract rename(f1: java.io.File, f2: java.io.File): boolean; /** * Set the last-modified time of the file or directory denoted by the * given abstract pathname, returning true if and only if the * operation succeeds. + * @param {java.io.File} f + * @param {number} time + * @return {boolean} */ abstract setLastModifiedTime(f: java.io.File, time: number): boolean; /** * Mark the file or directory denoted by the given abstract pathname as * read-only, returning true if and only if the operation * succeeds. + * @param {java.io.File} f + * @return {boolean} */ abstract setReadOnly(f: java.io.File): boolean; /** * List the available filesystem roots. + * @return {java.io.File[]} */ abstract listRoots(): java.io.File[]; static SPACE_TOTAL: number; @@ -203,63 +193,221 @@ declare namespace java.io { abstract getSpace(f: java.io.File, t: number): number; /** * Compare two abstract pathnames lexicographically. + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {number} */ abstract compare(f1: java.io.File, f2: java.io.File): number; /** * Compute the hash code of an abstract pathname. + * @param {java.io.File} f + * @return {number} */ abstract hashCode(f: java.io.File): number; static useCanonCaches: boolean; static useCanonPrefixCache: boolean; - private static getBooleanProperty(prop, defaultVal); + static getBooleanProperty(prop: string, defaultVal: boolean): boolean; static __static_initializer_0(): void; } } +declare namespace java.io { + /** + * JSweet partial implementation based on a local storage FS. + * @param {string} name + * @param {boolean} append + * @class + * @extends java.io.OutputStream + */ + class FileOutputStream extends java.io.OutputStream { + /** + * True if the file is opened for append. + */ + append: boolean; + file: java.io.File; + entry: java.io.LocalStorageFileSystem.Entry; + content: number[]; + constructor(name?: any, append?: any); + write$int$boolean(b: number, append: boolean): void; + write$int(b: number): void; + writeBytes(b: number[], off: number, len: number, append: boolean): void; + write$byte_A(b: number[]): void; + write$byte_A$int$int(b: number[], off: number, len: number): void; + write(b?: any, off?: any, len?: any): any; + /** + * + */ + flush(): void; + close(): void; + } +} +declare namespace java.io { + /** + * JSweet implementation based on a local storage FS. + * @param {string} n + * @class + * @extends java.io.InputStream + */ + class FileInputStream extends java.io.InputStream { + content: number[]; + index: number; + constructor(n?: any); + read$(): number; + readBytes(b: number[], off: number, len: number): number; + read$byte_A(b: number[]): number; + read$byte_A$int$int(b: number[], off: number, len: number): number; + read(b?: any, off?: any, len?: any): number; + skip(n: number): number; + available(): number; + close(): void; + } +} declare namespace java.io { /** * JSweet implementation. + * @param {string} fileName + * @param {boolean} append + * @class + * @extends java.io.OutputStreamWriter */ class FileWriter extends java.io.OutputStreamWriter { constructor(fileName?: any, append?: any); } } -declare namespace test { - class TestFile { - static assertEquals(o1: any, o2: any): void; - static assertTrue(b: boolean): void; - static assertFalse(b: boolean): void; - static test(): void; - static testIO(): void; +declare namespace java.io { + interface FilenameFilter { + (dir: java.io.File, name: string): boolean; + } +} +declare namespace java.io { + /** + * JSweet implementation. + * @param {string} fileName + * @class + * @extends java.io.InputStreamReader + */ + class FileReader extends java.io.InputStreamReader { + constructor(fileName?: any); + } +} +declare namespace java.io { + /** + * JSweet implementation. + * @param {string} s + * @class + * @extends java.io.IOException + */ + class FileNotFoundException extends java.io.IOException { + static serialVersionUID: number; + constructor(s?: any); + } +} +declare namespace java.io { + interface FileFilter { + (pathname: java.io.File): boolean; } } declare namespace java.io { class LocalStorageFileSystem extends java.io.FileSystem { - private PREFIX; + PREFIX: string; roots: java.io.File[]; /** * The FileSystem object representing the platform's local file system. */ static fs: LocalStorageFileSystem; static fs_$LI$(): LocalStorageFileSystem; + /** + * + * @return {string} + */ getSeparator(): string; + /** + * + * @return {string} + */ getPathSeparator(): string; - normalize(pathname?: any, len?: any, off?: any): any; + normalize$java_lang_String$int$int(pathname: string, len: number, off: number): string; + normalize(pathname?: any, len?: any, off?: any): string; normalize$java_lang_String(pathname: string): string; + /** + * + * @param {string} pathname + * @return {number} + */ prefixLength(pathname: string): number; - resolve(parent?: any, child?: any): any; + resolve$java_lang_String$java_lang_String(parent: string, child: string): string; + /** + * + * @param {string} parent + * @param {string} child + * @return {string} + */ + resolve(parent?: any, child?: any): string; + /** + * + * @return {string} + */ getDefaultParent(): string; + /** + * + * @param {string} path + * @return {string} + */ fromURIPath(path: string): string; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ isAbsolute(f: java.io.File): boolean; resolve$java_io_File(f: java.io.File): string; + /** + * + * @param {string} path + * @return {string} + */ canonicalize(path: string): string; + /** + * + * @param {java.io.File} f + * @return {number} + */ getBooleanAttributes(f: java.io.File): number; + /** + * + * @param {java.io.File} f + * @param {number} access + * @return {boolean} + */ checkAccess(f: java.io.File, access: number): boolean; + /** + * + * @param {java.io.File} f + * @param {number} access + * @param {boolean} enable + * @param {boolean} owneronly + * @return {boolean} + */ setPermission(f: java.io.File, access: number, enable: boolean, owneronly: boolean): boolean; + /** + * + * @param {java.io.File} f + * @return {number} + */ getLastModifiedTime(f: java.io.File): number; + /** + * + * @param {java.io.File} f + * @return {number} + */ getLength(f: java.io.File): number; clear(): void; getKey(pathname: string): string; createFileEntry(pathname: string): LocalStorageFileSystem.Entry; + /** + * + * @param {string} pathname + * @return {boolean} + */ createFileExclusively(pathname: string): boolean; hasEntry(pathname: string): boolean; getEntry(pathname: string): LocalStorageFileSystem.Entry; @@ -267,15 +415,68 @@ declare namespace java.io { putEntry(pathname: string, entry: LocalStorageFileSystem.Entry): void; getChildEntries(pathname: string): Array; removeEntry(pathname: string): void; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ delete(f: java.io.File): boolean; + /** + * + * @param {java.io.File} f + * @return {java.lang.String[]} + */ list(f: java.io.File): string[]; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ createDirectory(f: java.io.File): boolean; + /** + * + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {boolean} + */ rename(f1: java.io.File, f2: java.io.File): boolean; + /** + * + * @param {java.io.File} f + * @param {number} time + * @return {boolean} + */ setLastModifiedTime(f: java.io.File, time: number): boolean; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ setReadOnly(f: java.io.File): boolean; + /** + * + * @return {java.io.File[]} + */ listRoots(): java.io.File[]; + /** + * + * @param {java.io.File} f + * @param {number} t + * @return {number} + */ getSpace(f: java.io.File, t: number): number; + /** + * + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {number} + */ compare(f1: java.io.File, f2: java.io.File): number; + /** + * + * @param {java.io.File} f + * @return {number} + */ hashCode(f: java.io.File): number; constructor(); } @@ -295,12 +496,15 @@ declare namespace java.io { declare namespace java.io { /** * JSweet implementation for file. + * @param {string} parent + * @param {string} child + * @class */ class File implements java.io.Serializable, java.lang.Comparable { - private path; - private status; + path: string; + status: File.PathStatus; isInvalid(): boolean; - private prefixLength; + prefixLength: number; getPrefixLength(): number; static separatorChar: string; static separatorChar_$LI$(): string; @@ -332,24 +536,34 @@ declare namespace java.io { createNewFile(): boolean; delete(): boolean; list$(): string[]; - list(filter?: any): any; + list$java_io_FilenameFilter(filter: java.io.FilenameFilter): string[]; + list(filter?: any): string[]; listFiles$(): File[]; - listFiles(filter?: any): any; + listFiles$java_io_FilenameFilter(filter: java.io.FilenameFilter): File[]; + listFiles(filter?: any): File[]; listFiles$java_io_FileFilter(filter: java.io.FileFilter): File[]; mkdir(): boolean; mkdirs(): boolean; renameTo(dest: File): boolean; setLastModified(time: number): boolean; setReadOnly(): boolean; - setWritable(writable: boolean, ownerOnly?: boolean): boolean; - setReadable(readable: boolean, ownerOnly?: boolean): boolean; - setExecutable(executable: boolean, ownerOnly?: boolean): boolean; + setWritable$boolean$boolean(writable: boolean, ownerOnly: boolean): boolean; + setWritable(writable?: any, ownerOnly?: any): boolean; + setWritable$boolean(writable: boolean): boolean; + setReadable$boolean$boolean(readable: boolean, ownerOnly: boolean): boolean; + setReadable(readable?: any, ownerOnly?: any): boolean; + setReadable$boolean(readable: boolean): boolean; + setExecutable$boolean$boolean(executable: boolean, ownerOnly: boolean): boolean; + setExecutable(executable?: any, ownerOnly?: any): boolean; + setExecutable$boolean(executable: boolean): boolean; canExecute(): boolean; static listRoots(): File[]; getTotalSpace(): number; getFreeSpace(): number; getUsableSpace(): number; - static createTempFile(prefix: string, suffix: string, directory?: File): File; + static createTempFile$java_lang_String$java_lang_String$java_io_File(prefix: string, suffix: string, directory: File): File; + static createTempFile(prefix?: any, suffix?: any, directory?: any): File; + static createTempFile$java_lang_String$java_lang_String(prefix: string, suffix: string): File; compareTo(pathname: File): number; equals(obj: any): boolean; hashCode(): number; @@ -359,7 +573,7 @@ declare namespace java.io { namespace File { enum PathStatus { INVALID = 0, - CHECKED = 1, + CHECKED = 1 } class TempDirectory { constructor(); From a442b1f559751b8f7aac9ee8957f2cf795fd1207 Mon Sep 17 00:00:00 2001 From: Scott Vorthmann Date: Sun, 21 Aug 2022 18:44:29 -0700 Subject: [PATCH 2/3] Bumped version to be distinct --- pom.xml | 2 +- .../j4ts-file/0.0.2-SNAPSHOT/bundle.d.ts | 586 ++++++++++++++++++ 2 files changed, 587 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/src/typings/j4ts-file/0.0.2-SNAPSHOT/bundle.d.ts diff --git a/pom.xml b/pom.xml index f8c6bd4..aea3172 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.jsweet.candies.j4ts j4ts-file - 0.0.1-SNAPSHOT + 0.0.2-SNAPSHOT 1.1.1 diff --git a/src/main/resources/src/typings/j4ts-file/0.0.2-SNAPSHOT/bundle.d.ts b/src/main/resources/src/typings/j4ts-file/0.0.2-SNAPSHOT/bundle.d.ts new file mode 100644 index 0000000..09a3959 --- /dev/null +++ b/src/main/resources/src/typings/j4ts-file/0.0.2-SNAPSHOT/bundle.d.ts @@ -0,0 +1,586 @@ +declare namespace test { + class TestFile { + static assertEquals(o1: any, o2: any): void; + static assertTrue(b: boolean): void; + static assertFalse(b: boolean): void; + static test(): void; + static testIO(): void; + } +} +declare namespace java.io { + /** + * Package-private abstract class for the local filesystem abstraction. + * @class + */ + abstract class FileSystem { + static __static_initialized: boolean; + static __static_initialize(): void; + /** + * Return the local filesystem's name-separator character. + * @return {string} + */ + abstract getSeparator(): string; + /** + * Return the local filesystem's path-separator character. + * @return {string} + */ + abstract getPathSeparator(): string; + /** + * Convert the given pathname string to normal form. If the string is + * already in normal form then it is simply returned. + * @param {string} path + * @return {string} + */ + abstract normalize(path: string): string; + /** + * Compute the length of this pathname string's prefix. The pathname + * string must be in normal form. + * @param {string} path + * @return {number} + */ + abstract prefixLength(path: string): number; + resolve$java_lang_String$java_lang_String(parent: string, child: string): string; + /** + * Resolve the child pathname string against the parent. + * Both strings must be in normal form, and the result + * will be in normal form. + * @param {string} parent + * @param {string} child + * @return {string} + */ + resolve(parent?: any, child?: any): string; + /** + * Return the parent pathname string to be used when the parent-directory + * argument in one of the two-argument File constructors is the empty + * pathname. + * @return {string} + */ + abstract getDefaultParent(): string; + /** + * Post-process the given URI path string if necessary. This is used on + * win32, e.g., to transform "/c:/foo" into "c:/foo". The path string + * still has slash separators; code in the File class will translate them + * after this method returns. + * @param {string} path + * @return {string} + */ + abstract fromURIPath(path: string): string; + /** + * Tell whether or not the given abstract pathname is absolute. + * @param {java.io.File} f + * @return {boolean} + */ + abstract isAbsolute(f: java.io.File): boolean; + resolve$java_io_File(f: java.io.File): string; + abstract canonicalize(path: string): string; + static BA_EXISTS: number; + static BA_REGULAR: number; + static BA_DIRECTORY: number; + static BA_HIDDEN: number; + /** + * Return the simple boolean attributes for the file or directory denoted + * by the given abstract pathname, or zero if it does not exist or some + * other I/O error occurs. + * @param {java.io.File} f + * @return {number} + */ + abstract getBooleanAttributes(f: java.io.File): number; + static ACCESS_READ: number; + static ACCESS_WRITE: number; + static ACCESS_EXECUTE: number; + /** + * Check whether the file or directory denoted by the given abstract + * pathname may be accessed by this process. The second argument specifies + * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check. + * Return false if access is denied or an I/O error occurs + * @param {java.io.File} f + * @param {number} access + * @return {boolean} + */ + abstract checkAccess(f: java.io.File, access: number): boolean; + /** + * Set on or off the access permission (to owner only or to all) to the file + * or directory denoted by the given abstract pathname, based on the parameters + * enable, access and oweronly. + * @param {java.io.File} f + * @param {number} access + * @param {boolean} enable + * @param {boolean} owneronly + * @return {boolean} + */ + abstract setPermission(f: java.io.File, access: number, enable: boolean, owneronly: boolean): boolean; + /** + * Return the time at which the file or directory denoted by the given + * abstract pathname was last modified, or zero if it does not exist or + * some other I/O error occurs. + * @param {java.io.File} f + * @return {number} + */ + abstract getLastModifiedTime(f: java.io.File): number; + /** + * Return the length in bytes of the file denoted by the given abstract + * pathname, or zero if it does not exist, is a directory, or some other + * I/O error occurs. + * @param {java.io.File} f + * @return {number} + */ + abstract getLength(f: java.io.File): number; + /** + * Create a new empty file with the given pathname. Return + * true if the file was created and false if a + * file or directory with the given pathname already exists. Throw an + * IOException if an I/O error occurs. + * @param {string} pathname + * @return {boolean} + */ + abstract createFileExclusively(pathname: string): boolean; + /** + * Delete the file or directory denoted by the given abstract pathname, + * returning true if and only if the operation succeeds. + * @param {java.io.File} f + * @return {boolean} + */ + abstract delete(f: java.io.File): boolean; + /** + * List the elements of the directory denoted by the given abstract + * pathname. Return an array of strings naming the elements of the + * directory if successful; otherwise, return null. + * @param {java.io.File} f + * @return {java.lang.String[]} + */ + abstract list(f: java.io.File): string[]; + /** + * Create a new directory denoted by the given abstract pathname, + * returning true if and only if the operation succeeds. + * @param {java.io.File} f + * @return {boolean} + */ + abstract createDirectory(f: java.io.File): boolean; + /** + * Rename the file or directory denoted by the first abstract pathname to + * the second abstract pathname, returning true if and only if + * the operation succeeds. + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {boolean} + */ + abstract rename(f1: java.io.File, f2: java.io.File): boolean; + /** + * Set the last-modified time of the file or directory denoted by the + * given abstract pathname, returning true if and only if the + * operation succeeds. + * @param {java.io.File} f + * @param {number} time + * @return {boolean} + */ + abstract setLastModifiedTime(f: java.io.File, time: number): boolean; + /** + * Mark the file or directory denoted by the given abstract pathname as + * read-only, returning true if and only if the operation + * succeeds. + * @param {java.io.File} f + * @return {boolean} + */ + abstract setReadOnly(f: java.io.File): boolean; + /** + * List the available filesystem roots. + * @return {java.io.File[]} + */ + abstract listRoots(): java.io.File[]; + static SPACE_TOTAL: number; + static SPACE_FREE: number; + static SPACE_USABLE: number; + abstract getSpace(f: java.io.File, t: number): number; + /** + * Compare two abstract pathnames lexicographically. + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {number} + */ + abstract compare(f1: java.io.File, f2: java.io.File): number; + /** + * Compute the hash code of an abstract pathname. + * @param {java.io.File} f + * @return {number} + */ + abstract hashCode(f: java.io.File): number; + static useCanonCaches: boolean; + static useCanonPrefixCache: boolean; + static getBooleanProperty(prop: string, defaultVal: boolean): boolean; + static __static_initializer_0(): void; + } +} +declare namespace java.io { + /** + * JSweet partial implementation based on a local storage FS. + * @param {string} name + * @param {boolean} append + * @class + * @extends java.io.OutputStream + */ + class FileOutputStream extends java.io.OutputStream { + /** + * True if the file is opened for append. + */ + append: boolean; + file: java.io.File; + entry: java.io.LocalStorageFileSystem.Entry; + content: number[]; + constructor(name?: any, append?: any); + write$int$boolean(b: number, append: boolean): void; + write$int(b: number): void; + writeBytes(b: number[], off: number, len: number, append: boolean): void; + write$byte_A(b: number[]): void; + write$byte_A$int$int(b: number[], off: number, len: number): void; + write(b?: any, off?: any, len?: any): any; + /** + * + */ + flush(): void; + close(): void; + } +} +declare namespace java.io { + /** + * JSweet implementation based on a local storage FS. + * @param {string} n + * @class + * @extends java.io.InputStream + */ + class FileInputStream extends java.io.InputStream { + content: number[]; + index: number; + constructor(n?: any); + read$(): number; + readBytes(b: number[], off: number, len: number): number; + read$byte_A(b: number[]): number; + read$byte_A$int$int(b: number[], off: number, len: number): number; + read(b?: any, off?: any, len?: any): number; + skip(n: number): number; + available(): number; + close(): void; + } +} +declare namespace java.io { + /** + * JSweet implementation. + * @param {string} fileName + * @param {boolean} append + * @class + * @extends java.io.OutputStreamWriter + */ + class FileWriter extends java.io.OutputStreamWriter { + constructor(fileName?: any, append?: any); + } +} +declare namespace java.io { + interface FilenameFilter { + (dir: java.io.File, name: string): boolean; + } +} +declare namespace java.io { + /** + * JSweet implementation. + * @param {string} fileName + * @class + * @extends java.io.InputStreamReader + */ + class FileReader extends java.io.InputStreamReader { + constructor(fileName?: any); + } +} +declare namespace java.io { + /** + * JSweet implementation. + * @param {string} s + * @class + * @extends java.io.IOException + */ + class FileNotFoundException extends java.io.IOException { + static serialVersionUID: number; + constructor(s?: any); + } +} +declare namespace java.io { + interface FileFilter { + (pathname: java.io.File): boolean; + } +} +declare namespace java.io { + class LocalStorageFileSystem extends java.io.FileSystem { + PREFIX: string; + roots: java.io.File[]; + /** + * The FileSystem object representing the platform's local file system. + */ + static fs: LocalStorageFileSystem; + static fs_$LI$(): LocalStorageFileSystem; + /** + * + * @return {string} + */ + getSeparator(): string; + /** + * + * @return {string} + */ + getPathSeparator(): string; + normalize$java_lang_String$int$int(pathname: string, len: number, off: number): string; + normalize(pathname?: any, len?: any, off?: any): string; + normalize$java_lang_String(pathname: string): string; + /** + * + * @param {string} pathname + * @return {number} + */ + prefixLength(pathname: string): number; + resolve$java_lang_String$java_lang_String(parent: string, child: string): string; + /** + * + * @param {string} parent + * @param {string} child + * @return {string} + */ + resolve(parent?: any, child?: any): string; + /** + * + * @return {string} + */ + getDefaultParent(): string; + /** + * + * @param {string} path + * @return {string} + */ + fromURIPath(path: string): string; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ + isAbsolute(f: java.io.File): boolean; + resolve$java_io_File(f: java.io.File): string; + /** + * + * @param {string} path + * @return {string} + */ + canonicalize(path: string): string; + /** + * + * @param {java.io.File} f + * @return {number} + */ + getBooleanAttributes(f: java.io.File): number; + /** + * + * @param {java.io.File} f + * @param {number} access + * @return {boolean} + */ + checkAccess(f: java.io.File, access: number): boolean; + /** + * + * @param {java.io.File} f + * @param {number} access + * @param {boolean} enable + * @param {boolean} owneronly + * @return {boolean} + */ + setPermission(f: java.io.File, access: number, enable: boolean, owneronly: boolean): boolean; + /** + * + * @param {java.io.File} f + * @return {number} + */ + getLastModifiedTime(f: java.io.File): number; + /** + * + * @param {java.io.File} f + * @return {number} + */ + getLength(f: java.io.File): number; + clear(): void; + getKey(pathname: string): string; + createFileEntry(pathname: string): LocalStorageFileSystem.Entry; + /** + * + * @param {string} pathname + * @return {boolean} + */ + createFileExclusively(pathname: string): boolean; + hasEntry(pathname: string): boolean; + getEntry(pathname: string): LocalStorageFileSystem.Entry; + getDirectoryEntry(pathname: string): LocalStorageFileSystem.DirectoryEntry; + putEntry(pathname: string, entry: LocalStorageFileSystem.Entry): void; + getChildEntries(pathname: string): Array; + removeEntry(pathname: string): void; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ + delete(f: java.io.File): boolean; + /** + * + * @param {java.io.File} f + * @return {java.lang.String[]} + */ + list(f: java.io.File): string[]; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ + createDirectory(f: java.io.File): boolean; + /** + * + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {boolean} + */ + rename(f1: java.io.File, f2: java.io.File): boolean; + /** + * + * @param {java.io.File} f + * @param {number} time + * @return {boolean} + */ + setLastModifiedTime(f: java.io.File, time: number): boolean; + /** + * + * @param {java.io.File} f + * @return {boolean} + */ + setReadOnly(f: java.io.File): boolean; + /** + * + * @return {java.io.File[]} + */ + listRoots(): java.io.File[]; + /** + * + * @param {java.io.File} f + * @param {number} t + * @return {number} + */ + getSpace(f: java.io.File, t: number): number; + /** + * + * @param {java.io.File} f1 + * @param {java.io.File} f2 + * @return {number} + */ + compare(f1: java.io.File, f2: java.io.File): number; + /** + * + * @param {java.io.File} f + * @return {number} + */ + hashCode(f: java.io.File): number; + constructor(); + } + namespace LocalStorageFileSystem { + interface Entry { + attributes: number; + access: number; + data: string; + lastModifiedTime: number; + length: number; + } + interface DirectoryEntry extends LocalStorageFileSystem.Entry { + entries: string[]; + } + } +} +declare namespace java.io { + /** + * JSweet implementation for file. + * @param {string} parent + * @param {string} child + * @class + */ + class File implements java.io.Serializable, java.lang.Comparable { + path: string; + status: File.PathStatus; + isInvalid(): boolean; + prefixLength: number; + getPrefixLength(): number; + static separatorChar: string; + static separatorChar_$LI$(): string; + static separator: string; + static separator_$LI$(): string; + static pathSeparatorChar: string; + static pathSeparatorChar_$LI$(): string; + static pathSeparator: string; + static pathSeparator_$LI$(): string; + constructor(parent?: any, child?: any, direct?: any); + getName(): string; + getParent(): string; + getParentFile(): File; + getPath(): string; + isAbsolute(): boolean; + getAbsolutePath(): string; + getAbsoluteFile(): File; + getCanonicalPath(): string; + getCanonicalFile(): File; + static slashify(path: string, isDirectory: boolean): string; + canRead(): boolean; + canWrite(): boolean; + exists(): boolean; + isDirectory(): boolean; + isFile(): boolean; + isHidden(): boolean; + lastModified(): number; + length(): number; + createNewFile(): boolean; + delete(): boolean; + list$(): string[]; + list$java_io_FilenameFilter(filter: java.io.FilenameFilter): string[]; + list(filter?: any): string[]; + listFiles$(): File[]; + listFiles$java_io_FilenameFilter(filter: java.io.FilenameFilter): File[]; + listFiles(filter?: any): File[]; + listFiles$java_io_FileFilter(filter: java.io.FileFilter): File[]; + mkdir(): boolean; + mkdirs(): boolean; + renameTo(dest: File): boolean; + setLastModified(time: number): boolean; + setReadOnly(): boolean; + setWritable$boolean$boolean(writable: boolean, ownerOnly: boolean): boolean; + setWritable(writable?: any, ownerOnly?: any): boolean; + setWritable$boolean(writable: boolean): boolean; + setReadable$boolean$boolean(readable: boolean, ownerOnly: boolean): boolean; + setReadable(readable?: any, ownerOnly?: any): boolean; + setReadable$boolean(readable: boolean): boolean; + setExecutable$boolean$boolean(executable: boolean, ownerOnly: boolean): boolean; + setExecutable(executable?: any, ownerOnly?: any): boolean; + setExecutable$boolean(executable: boolean): boolean; + canExecute(): boolean; + static listRoots(): File[]; + getTotalSpace(): number; + getFreeSpace(): number; + getUsableSpace(): number; + static createTempFile$java_lang_String$java_lang_String$java_io_File(prefix: string, suffix: string, directory: File): File; + static createTempFile(prefix?: any, suffix?: any, directory?: any): File; + static createTempFile$java_lang_String$java_lang_String(prefix: string, suffix: string): File; + compareTo(pathname: File): number; + equals(obj: any): boolean; + hashCode(): number; + toString(): string; + static serialVersionUID: number; + } + namespace File { + enum PathStatus { + INVALID = 0, + CHECKED = 1 + } + class TempDirectory { + constructor(); + static tmpdir: java.io.File; + static tmpdir_$LI$(): java.io.File; + static location(): java.io.File; + static generateFile(prefix: string, suffix: string, dir: java.io.File): java.io.File; + } + } +} From 9025806192187768f1c2142d924dd2e9cd0da2e8 Mon Sep 17 00:00:00 2001 From: Scott Vorthmann Date: Mon, 5 Sep 2022 12:31:01 -0700 Subject: [PATCH 3/3] Added missing candy-metadata.json This candy was not recognized by current JSweet. I also normalized the `typings` location. --- .gitignore | 2 + dist/j4ts-file.js | 44 +- pom.xml | 9 +- .../resources/META-INF/candy-metadata.json | 2 +- .../0.0.1-SNAPSHOT/.tsc-rootfile.d.ts | 0 .../j4ts-file/0.0.1-SNAPSHOT/bundle.d.ts | 586 ------------------ .../j4ts-file/0.0.2-SNAPSHOT/bundle.d.ts | 586 ------------------ 7 files changed, 9 insertions(+), 1220 deletions(-) delete mode 100644 src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/.tsc-rootfile.d.ts delete mode 100644 src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/bundle.d.ts delete mode 100644 src/main/resources/src/typings/j4ts-file/0.0.2-SNAPSHOT/bundle.d.ts diff --git a/.gitignore b/.gitignore index 46fc15f..85c9933 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ /.classpath /.project /.settings/ + +.vscode/ diff --git a/dist/j4ts-file.js b/dist/j4ts-file.js index 03e9bce..ec07966 100644 --- a/dist/j4ts-file.js +++ b/dist/j4ts-file.js @@ -11,7 +11,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -/* Generated from Java with JSweet 3.1.0 - http://www.jsweet.org */ +/* Generated from Java with JSweet 3.2.0-SNAPSHOT - http://www.jsweet.org */ var test; (function (test) { var TestFile = /** @class */ (function () { @@ -184,18 +184,6 @@ var java; _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()); _this.content = append ? /* getBytes */ (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : []; } - if (_this.append === undefined) { - _this.append = false; - } - if (_this.file === undefined) { - _this.file = null; - } - if (_this.entry === undefined) { - _this.entry = null; - } - if (_this.content === undefined) { - _this.content = null; - } } else if (((name != null && name instanceof java.io.File) || name === null) && ((typeof append === 'boolean') || append === null)) { var __args = arguments; @@ -248,18 +236,6 @@ var java; _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()); _this.content = append_1 ? /* getBytes */ (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : []; } - if (_this.append === undefined) { - _this.append = false; - } - if (_this.file === undefined) { - _this.file = null; - } - if (_this.entry === undefined) { - _this.entry = null; - } - if (_this.content === undefined) { - _this.content = null; - } } else if (((name != null && name instanceof java.io.File) || name === null) && append === undefined) { var __args = arguments; @@ -288,18 +264,6 @@ var java; _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()); _this.content = append_2 ? /* getBytes */ (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : []; } - if (_this.append === undefined) { - _this.append = false; - } - if (_this.file === undefined) { - _this.file = null; - } - if (_this.entry === undefined) { - _this.entry = null; - } - if (_this.content === undefined) { - _this.content = null; - } } else throw new Error('invalid overload'); @@ -394,12 +358,6 @@ var java; _this.content = atob(java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()).data); _this.index = 0; } - if (_this.content === undefined) { - _this.content = null; - } - if (_this.index === undefined) { - _this.index = 0; - } } else if (((n != null && n instanceof java.io.File) || n === null)) { var __args = arguments; diff --git a/pom.xml b/pom.xml index aea3172..2e1d921 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ j4ts-file 0.0.2-SNAPSHOT - 1.1.1 + 3.2.0-SNAPSHOT @@ -60,14 +60,15 @@ org.jsweet jsweet-maven-plugin - 3.1.0 + 3.2.0-SNAPSHOT true true + none true src/main/resources/META-INF/resources/webjars/${project.artifactId}/${project.version} - src/main/resources/src/typings/${project.artifactId}/${project.version} + src/main/resources/META-INF/resources/typings/${project.artifactId}/${project.version} ES3 -source,1.8,-target,1.8 @@ -94,7 +95,7 @@ file="src/main/resources/META-INF/resources/webjars/${project.artifactId}/${project.version}/bundle.js" tofile="dist/${project.artifactId}.js" verbose="true" /> diff --git a/src/main/resources/META-INF/candy-metadata.json b/src/main/resources/META-INF/candy-metadata.json index 1ff7f8e..0eb9f1e 100644 --- a/src/main/resources/META-INF/candy-metadata.json +++ b/src/main/resources/META-INF/candy-metadata.json @@ -1,3 +1,3 @@ { "transpilerVersion": "${jsweet.transpiler.version}" -} +} \ No newline at end of file diff --git a/src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/.tsc-rootfile.d.ts b/src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/.tsc-rootfile.d.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/bundle.d.ts b/src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/bundle.d.ts deleted file mode 100644 index 09a3959..0000000 --- a/src/main/resources/src/typings/j4ts-file/0.0.1-SNAPSHOT/bundle.d.ts +++ /dev/null @@ -1,586 +0,0 @@ -declare namespace test { - class TestFile { - static assertEquals(o1: any, o2: any): void; - static assertTrue(b: boolean): void; - static assertFalse(b: boolean): void; - static test(): void; - static testIO(): void; - } -} -declare namespace java.io { - /** - * Package-private abstract class for the local filesystem abstraction. - * @class - */ - abstract class FileSystem { - static __static_initialized: boolean; - static __static_initialize(): void; - /** - * Return the local filesystem's name-separator character. - * @return {string} - */ - abstract getSeparator(): string; - /** - * Return the local filesystem's path-separator character. - * @return {string} - */ - abstract getPathSeparator(): string; - /** - * Convert the given pathname string to normal form. If the string is - * already in normal form then it is simply returned. - * @param {string} path - * @return {string} - */ - abstract normalize(path: string): string; - /** - * Compute the length of this pathname string's prefix. The pathname - * string must be in normal form. - * @param {string} path - * @return {number} - */ - abstract prefixLength(path: string): number; - resolve$java_lang_String$java_lang_String(parent: string, child: string): string; - /** - * Resolve the child pathname string against the parent. - * Both strings must be in normal form, and the result - * will be in normal form. - * @param {string} parent - * @param {string} child - * @return {string} - */ - resolve(parent?: any, child?: any): string; - /** - * Return the parent pathname string to be used when the parent-directory - * argument in one of the two-argument File constructors is the empty - * pathname. - * @return {string} - */ - abstract getDefaultParent(): string; - /** - * Post-process the given URI path string if necessary. This is used on - * win32, e.g., to transform "/c:/foo" into "c:/foo". The path string - * still has slash separators; code in the File class will translate them - * after this method returns. - * @param {string} path - * @return {string} - */ - abstract fromURIPath(path: string): string; - /** - * Tell whether or not the given abstract pathname is absolute. - * @param {java.io.File} f - * @return {boolean} - */ - abstract isAbsolute(f: java.io.File): boolean; - resolve$java_io_File(f: java.io.File): string; - abstract canonicalize(path: string): string; - static BA_EXISTS: number; - static BA_REGULAR: number; - static BA_DIRECTORY: number; - static BA_HIDDEN: number; - /** - * Return the simple boolean attributes for the file or directory denoted - * by the given abstract pathname, or zero if it does not exist or some - * other I/O error occurs. - * @param {java.io.File} f - * @return {number} - */ - abstract getBooleanAttributes(f: java.io.File): number; - static ACCESS_READ: number; - static ACCESS_WRITE: number; - static ACCESS_EXECUTE: number; - /** - * Check whether the file or directory denoted by the given abstract - * pathname may be accessed by this process. The second argument specifies - * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check. - * Return false if access is denied or an I/O error occurs - * @param {java.io.File} f - * @param {number} access - * @return {boolean} - */ - abstract checkAccess(f: java.io.File, access: number): boolean; - /** - * Set on or off the access permission (to owner only or to all) to the file - * or directory denoted by the given abstract pathname, based on the parameters - * enable, access and oweronly. - * @param {java.io.File} f - * @param {number} access - * @param {boolean} enable - * @param {boolean} owneronly - * @return {boolean} - */ - abstract setPermission(f: java.io.File, access: number, enable: boolean, owneronly: boolean): boolean; - /** - * Return the time at which the file or directory denoted by the given - * abstract pathname was last modified, or zero if it does not exist or - * some other I/O error occurs. - * @param {java.io.File} f - * @return {number} - */ - abstract getLastModifiedTime(f: java.io.File): number; - /** - * Return the length in bytes of the file denoted by the given abstract - * pathname, or zero if it does not exist, is a directory, or some other - * I/O error occurs. - * @param {java.io.File} f - * @return {number} - */ - abstract getLength(f: java.io.File): number; - /** - * Create a new empty file with the given pathname. Return - * true if the file was created and false if a - * file or directory with the given pathname already exists. Throw an - * IOException if an I/O error occurs. - * @param {string} pathname - * @return {boolean} - */ - abstract createFileExclusively(pathname: string): boolean; - /** - * Delete the file or directory denoted by the given abstract pathname, - * returning true if and only if the operation succeeds. - * @param {java.io.File} f - * @return {boolean} - */ - abstract delete(f: java.io.File): boolean; - /** - * List the elements of the directory denoted by the given abstract - * pathname. Return an array of strings naming the elements of the - * directory if successful; otherwise, return null. - * @param {java.io.File} f - * @return {java.lang.String[]} - */ - abstract list(f: java.io.File): string[]; - /** - * Create a new directory denoted by the given abstract pathname, - * returning true if and only if the operation succeeds. - * @param {java.io.File} f - * @return {boolean} - */ - abstract createDirectory(f: java.io.File): boolean; - /** - * Rename the file or directory denoted by the first abstract pathname to - * the second abstract pathname, returning true if and only if - * the operation succeeds. - * @param {java.io.File} f1 - * @param {java.io.File} f2 - * @return {boolean} - */ - abstract rename(f1: java.io.File, f2: java.io.File): boolean; - /** - * Set the last-modified time of the file or directory denoted by the - * given abstract pathname, returning true if and only if the - * operation succeeds. - * @param {java.io.File} f - * @param {number} time - * @return {boolean} - */ - abstract setLastModifiedTime(f: java.io.File, time: number): boolean; - /** - * Mark the file or directory denoted by the given abstract pathname as - * read-only, returning true if and only if the operation - * succeeds. - * @param {java.io.File} f - * @return {boolean} - */ - abstract setReadOnly(f: java.io.File): boolean; - /** - * List the available filesystem roots. - * @return {java.io.File[]} - */ - abstract listRoots(): java.io.File[]; - static SPACE_TOTAL: number; - static SPACE_FREE: number; - static SPACE_USABLE: number; - abstract getSpace(f: java.io.File, t: number): number; - /** - * Compare two abstract pathnames lexicographically. - * @param {java.io.File} f1 - * @param {java.io.File} f2 - * @return {number} - */ - abstract compare(f1: java.io.File, f2: java.io.File): number; - /** - * Compute the hash code of an abstract pathname. - * @param {java.io.File} f - * @return {number} - */ - abstract hashCode(f: java.io.File): number; - static useCanonCaches: boolean; - static useCanonPrefixCache: boolean; - static getBooleanProperty(prop: string, defaultVal: boolean): boolean; - static __static_initializer_0(): void; - } -} -declare namespace java.io { - /** - * JSweet partial implementation based on a local storage FS. - * @param {string} name - * @param {boolean} append - * @class - * @extends java.io.OutputStream - */ - class FileOutputStream extends java.io.OutputStream { - /** - * True if the file is opened for append. - */ - append: boolean; - file: java.io.File; - entry: java.io.LocalStorageFileSystem.Entry; - content: number[]; - constructor(name?: any, append?: any); - write$int$boolean(b: number, append: boolean): void; - write$int(b: number): void; - writeBytes(b: number[], off: number, len: number, append: boolean): void; - write$byte_A(b: number[]): void; - write$byte_A$int$int(b: number[], off: number, len: number): void; - write(b?: any, off?: any, len?: any): any; - /** - * - */ - flush(): void; - close(): void; - } -} -declare namespace java.io { - /** - * JSweet implementation based on a local storage FS. - * @param {string} n - * @class - * @extends java.io.InputStream - */ - class FileInputStream extends java.io.InputStream { - content: number[]; - index: number; - constructor(n?: any); - read$(): number; - readBytes(b: number[], off: number, len: number): number; - read$byte_A(b: number[]): number; - read$byte_A$int$int(b: number[], off: number, len: number): number; - read(b?: any, off?: any, len?: any): number; - skip(n: number): number; - available(): number; - close(): void; - } -} -declare namespace java.io { - /** - * JSweet implementation. - * @param {string} fileName - * @param {boolean} append - * @class - * @extends java.io.OutputStreamWriter - */ - class FileWriter extends java.io.OutputStreamWriter { - constructor(fileName?: any, append?: any); - } -} -declare namespace java.io { - interface FilenameFilter { - (dir: java.io.File, name: string): boolean; - } -} -declare namespace java.io { - /** - * JSweet implementation. - * @param {string} fileName - * @class - * @extends java.io.InputStreamReader - */ - class FileReader extends java.io.InputStreamReader { - constructor(fileName?: any); - } -} -declare namespace java.io { - /** - * JSweet implementation. - * @param {string} s - * @class - * @extends java.io.IOException - */ - class FileNotFoundException extends java.io.IOException { - static serialVersionUID: number; - constructor(s?: any); - } -} -declare namespace java.io { - interface FileFilter { - (pathname: java.io.File): boolean; - } -} -declare namespace java.io { - class LocalStorageFileSystem extends java.io.FileSystem { - PREFIX: string; - roots: java.io.File[]; - /** - * The FileSystem object representing the platform's local file system. - */ - static fs: LocalStorageFileSystem; - static fs_$LI$(): LocalStorageFileSystem; - /** - * - * @return {string} - */ - getSeparator(): string; - /** - * - * @return {string} - */ - getPathSeparator(): string; - normalize$java_lang_String$int$int(pathname: string, len: number, off: number): string; - normalize(pathname?: any, len?: any, off?: any): string; - normalize$java_lang_String(pathname: string): string; - /** - * - * @param {string} pathname - * @return {number} - */ - prefixLength(pathname: string): number; - resolve$java_lang_String$java_lang_String(parent: string, child: string): string; - /** - * - * @param {string} parent - * @param {string} child - * @return {string} - */ - resolve(parent?: any, child?: any): string; - /** - * - * @return {string} - */ - getDefaultParent(): string; - /** - * - * @param {string} path - * @return {string} - */ - fromURIPath(path: string): string; - /** - * - * @param {java.io.File} f - * @return {boolean} - */ - isAbsolute(f: java.io.File): boolean; - resolve$java_io_File(f: java.io.File): string; - /** - * - * @param {string} path - * @return {string} - */ - canonicalize(path: string): string; - /** - * - * @param {java.io.File} f - * @return {number} - */ - getBooleanAttributes(f: java.io.File): number; - /** - * - * @param {java.io.File} f - * @param {number} access - * @return {boolean} - */ - checkAccess(f: java.io.File, access: number): boolean; - /** - * - * @param {java.io.File} f - * @param {number} access - * @param {boolean} enable - * @param {boolean} owneronly - * @return {boolean} - */ - setPermission(f: java.io.File, access: number, enable: boolean, owneronly: boolean): boolean; - /** - * - * @param {java.io.File} f - * @return {number} - */ - getLastModifiedTime(f: java.io.File): number; - /** - * - * @param {java.io.File} f - * @return {number} - */ - getLength(f: java.io.File): number; - clear(): void; - getKey(pathname: string): string; - createFileEntry(pathname: string): LocalStorageFileSystem.Entry; - /** - * - * @param {string} pathname - * @return {boolean} - */ - createFileExclusively(pathname: string): boolean; - hasEntry(pathname: string): boolean; - getEntry(pathname: string): LocalStorageFileSystem.Entry; - getDirectoryEntry(pathname: string): LocalStorageFileSystem.DirectoryEntry; - putEntry(pathname: string, entry: LocalStorageFileSystem.Entry): void; - getChildEntries(pathname: string): Array; - removeEntry(pathname: string): void; - /** - * - * @param {java.io.File} f - * @return {boolean} - */ - delete(f: java.io.File): boolean; - /** - * - * @param {java.io.File} f - * @return {java.lang.String[]} - */ - list(f: java.io.File): string[]; - /** - * - * @param {java.io.File} f - * @return {boolean} - */ - createDirectory(f: java.io.File): boolean; - /** - * - * @param {java.io.File} f1 - * @param {java.io.File} f2 - * @return {boolean} - */ - rename(f1: java.io.File, f2: java.io.File): boolean; - /** - * - * @param {java.io.File} f - * @param {number} time - * @return {boolean} - */ - setLastModifiedTime(f: java.io.File, time: number): boolean; - /** - * - * @param {java.io.File} f - * @return {boolean} - */ - setReadOnly(f: java.io.File): boolean; - /** - * - * @return {java.io.File[]} - */ - listRoots(): java.io.File[]; - /** - * - * @param {java.io.File} f - * @param {number} t - * @return {number} - */ - getSpace(f: java.io.File, t: number): number; - /** - * - * @param {java.io.File} f1 - * @param {java.io.File} f2 - * @return {number} - */ - compare(f1: java.io.File, f2: java.io.File): number; - /** - * - * @param {java.io.File} f - * @return {number} - */ - hashCode(f: java.io.File): number; - constructor(); - } - namespace LocalStorageFileSystem { - interface Entry { - attributes: number; - access: number; - data: string; - lastModifiedTime: number; - length: number; - } - interface DirectoryEntry extends LocalStorageFileSystem.Entry { - entries: string[]; - } - } -} -declare namespace java.io { - /** - * JSweet implementation for file. - * @param {string} parent - * @param {string} child - * @class - */ - class File implements java.io.Serializable, java.lang.Comparable { - path: string; - status: File.PathStatus; - isInvalid(): boolean; - prefixLength: number; - getPrefixLength(): number; - static separatorChar: string; - static separatorChar_$LI$(): string; - static separator: string; - static separator_$LI$(): string; - static pathSeparatorChar: string; - static pathSeparatorChar_$LI$(): string; - static pathSeparator: string; - static pathSeparator_$LI$(): string; - constructor(parent?: any, child?: any, direct?: any); - getName(): string; - getParent(): string; - getParentFile(): File; - getPath(): string; - isAbsolute(): boolean; - getAbsolutePath(): string; - getAbsoluteFile(): File; - getCanonicalPath(): string; - getCanonicalFile(): File; - static slashify(path: string, isDirectory: boolean): string; - canRead(): boolean; - canWrite(): boolean; - exists(): boolean; - isDirectory(): boolean; - isFile(): boolean; - isHidden(): boolean; - lastModified(): number; - length(): number; - createNewFile(): boolean; - delete(): boolean; - list$(): string[]; - list$java_io_FilenameFilter(filter: java.io.FilenameFilter): string[]; - list(filter?: any): string[]; - listFiles$(): File[]; - listFiles$java_io_FilenameFilter(filter: java.io.FilenameFilter): File[]; - listFiles(filter?: any): File[]; - listFiles$java_io_FileFilter(filter: java.io.FileFilter): File[]; - mkdir(): boolean; - mkdirs(): boolean; - renameTo(dest: File): boolean; - setLastModified(time: number): boolean; - setReadOnly(): boolean; - setWritable$boolean$boolean(writable: boolean, ownerOnly: boolean): boolean; - setWritable(writable?: any, ownerOnly?: any): boolean; - setWritable$boolean(writable: boolean): boolean; - setReadable$boolean$boolean(readable: boolean, ownerOnly: boolean): boolean; - setReadable(readable?: any, ownerOnly?: any): boolean; - setReadable$boolean(readable: boolean): boolean; - setExecutable$boolean$boolean(executable: boolean, ownerOnly: boolean): boolean; - setExecutable(executable?: any, ownerOnly?: any): boolean; - setExecutable$boolean(executable: boolean): boolean; - canExecute(): boolean; - static listRoots(): File[]; - getTotalSpace(): number; - getFreeSpace(): number; - getUsableSpace(): number; - static createTempFile$java_lang_String$java_lang_String$java_io_File(prefix: string, suffix: string, directory: File): File; - static createTempFile(prefix?: any, suffix?: any, directory?: any): File; - static createTempFile$java_lang_String$java_lang_String(prefix: string, suffix: string): File; - compareTo(pathname: File): number; - equals(obj: any): boolean; - hashCode(): number; - toString(): string; - static serialVersionUID: number; - } - namespace File { - enum PathStatus { - INVALID = 0, - CHECKED = 1 - } - class TempDirectory { - constructor(); - static tmpdir: java.io.File; - static tmpdir_$LI$(): java.io.File; - static location(): java.io.File; - static generateFile(prefix: string, suffix: string, dir: java.io.File): java.io.File; - } - } -} diff --git a/src/main/resources/src/typings/j4ts-file/0.0.2-SNAPSHOT/bundle.d.ts b/src/main/resources/src/typings/j4ts-file/0.0.2-SNAPSHOT/bundle.d.ts deleted file mode 100644 index 09a3959..0000000 --- a/src/main/resources/src/typings/j4ts-file/0.0.2-SNAPSHOT/bundle.d.ts +++ /dev/null @@ -1,586 +0,0 @@ -declare namespace test { - class TestFile { - static assertEquals(o1: any, o2: any): void; - static assertTrue(b: boolean): void; - static assertFalse(b: boolean): void; - static test(): void; - static testIO(): void; - } -} -declare namespace java.io { - /** - * Package-private abstract class for the local filesystem abstraction. - * @class - */ - abstract class FileSystem { - static __static_initialized: boolean; - static __static_initialize(): void; - /** - * Return the local filesystem's name-separator character. - * @return {string} - */ - abstract getSeparator(): string; - /** - * Return the local filesystem's path-separator character. - * @return {string} - */ - abstract getPathSeparator(): string; - /** - * Convert the given pathname string to normal form. If the string is - * already in normal form then it is simply returned. - * @param {string} path - * @return {string} - */ - abstract normalize(path: string): string; - /** - * Compute the length of this pathname string's prefix. The pathname - * string must be in normal form. - * @param {string} path - * @return {number} - */ - abstract prefixLength(path: string): number; - resolve$java_lang_String$java_lang_String(parent: string, child: string): string; - /** - * Resolve the child pathname string against the parent. - * Both strings must be in normal form, and the result - * will be in normal form. - * @param {string} parent - * @param {string} child - * @return {string} - */ - resolve(parent?: any, child?: any): string; - /** - * Return the parent pathname string to be used when the parent-directory - * argument in one of the two-argument File constructors is the empty - * pathname. - * @return {string} - */ - abstract getDefaultParent(): string; - /** - * Post-process the given URI path string if necessary. This is used on - * win32, e.g., to transform "/c:/foo" into "c:/foo". The path string - * still has slash separators; code in the File class will translate them - * after this method returns. - * @param {string} path - * @return {string} - */ - abstract fromURIPath(path: string): string; - /** - * Tell whether or not the given abstract pathname is absolute. - * @param {java.io.File} f - * @return {boolean} - */ - abstract isAbsolute(f: java.io.File): boolean; - resolve$java_io_File(f: java.io.File): string; - abstract canonicalize(path: string): string; - static BA_EXISTS: number; - static BA_REGULAR: number; - static BA_DIRECTORY: number; - static BA_HIDDEN: number; - /** - * Return the simple boolean attributes for the file or directory denoted - * by the given abstract pathname, or zero if it does not exist or some - * other I/O error occurs. - * @param {java.io.File} f - * @return {number} - */ - abstract getBooleanAttributes(f: java.io.File): number; - static ACCESS_READ: number; - static ACCESS_WRITE: number; - static ACCESS_EXECUTE: number; - /** - * Check whether the file or directory denoted by the given abstract - * pathname may be accessed by this process. The second argument specifies - * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check. - * Return false if access is denied or an I/O error occurs - * @param {java.io.File} f - * @param {number} access - * @return {boolean} - */ - abstract checkAccess(f: java.io.File, access: number): boolean; - /** - * Set on or off the access permission (to owner only or to all) to the file - * or directory denoted by the given abstract pathname, based on the parameters - * enable, access and oweronly. - * @param {java.io.File} f - * @param {number} access - * @param {boolean} enable - * @param {boolean} owneronly - * @return {boolean} - */ - abstract setPermission(f: java.io.File, access: number, enable: boolean, owneronly: boolean): boolean; - /** - * Return the time at which the file or directory denoted by the given - * abstract pathname was last modified, or zero if it does not exist or - * some other I/O error occurs. - * @param {java.io.File} f - * @return {number} - */ - abstract getLastModifiedTime(f: java.io.File): number; - /** - * Return the length in bytes of the file denoted by the given abstract - * pathname, or zero if it does not exist, is a directory, or some other - * I/O error occurs. - * @param {java.io.File} f - * @return {number} - */ - abstract getLength(f: java.io.File): number; - /** - * Create a new empty file with the given pathname. Return - * true if the file was created and false if a - * file or directory with the given pathname already exists. Throw an - * IOException if an I/O error occurs. - * @param {string} pathname - * @return {boolean} - */ - abstract createFileExclusively(pathname: string): boolean; - /** - * Delete the file or directory denoted by the given abstract pathname, - * returning true if and only if the operation succeeds. - * @param {java.io.File} f - * @return {boolean} - */ - abstract delete(f: java.io.File): boolean; - /** - * List the elements of the directory denoted by the given abstract - * pathname. Return an array of strings naming the elements of the - * directory if successful; otherwise, return null. - * @param {java.io.File} f - * @return {java.lang.String[]} - */ - abstract list(f: java.io.File): string[]; - /** - * Create a new directory denoted by the given abstract pathname, - * returning true if and only if the operation succeeds. - * @param {java.io.File} f - * @return {boolean} - */ - abstract createDirectory(f: java.io.File): boolean; - /** - * Rename the file or directory denoted by the first abstract pathname to - * the second abstract pathname, returning true if and only if - * the operation succeeds. - * @param {java.io.File} f1 - * @param {java.io.File} f2 - * @return {boolean} - */ - abstract rename(f1: java.io.File, f2: java.io.File): boolean; - /** - * Set the last-modified time of the file or directory denoted by the - * given abstract pathname, returning true if and only if the - * operation succeeds. - * @param {java.io.File} f - * @param {number} time - * @return {boolean} - */ - abstract setLastModifiedTime(f: java.io.File, time: number): boolean; - /** - * Mark the file or directory denoted by the given abstract pathname as - * read-only, returning true if and only if the operation - * succeeds. - * @param {java.io.File} f - * @return {boolean} - */ - abstract setReadOnly(f: java.io.File): boolean; - /** - * List the available filesystem roots. - * @return {java.io.File[]} - */ - abstract listRoots(): java.io.File[]; - static SPACE_TOTAL: number; - static SPACE_FREE: number; - static SPACE_USABLE: number; - abstract getSpace(f: java.io.File, t: number): number; - /** - * Compare two abstract pathnames lexicographically. - * @param {java.io.File} f1 - * @param {java.io.File} f2 - * @return {number} - */ - abstract compare(f1: java.io.File, f2: java.io.File): number; - /** - * Compute the hash code of an abstract pathname. - * @param {java.io.File} f - * @return {number} - */ - abstract hashCode(f: java.io.File): number; - static useCanonCaches: boolean; - static useCanonPrefixCache: boolean; - static getBooleanProperty(prop: string, defaultVal: boolean): boolean; - static __static_initializer_0(): void; - } -} -declare namespace java.io { - /** - * JSweet partial implementation based on a local storage FS. - * @param {string} name - * @param {boolean} append - * @class - * @extends java.io.OutputStream - */ - class FileOutputStream extends java.io.OutputStream { - /** - * True if the file is opened for append. - */ - append: boolean; - file: java.io.File; - entry: java.io.LocalStorageFileSystem.Entry; - content: number[]; - constructor(name?: any, append?: any); - write$int$boolean(b: number, append: boolean): void; - write$int(b: number): void; - writeBytes(b: number[], off: number, len: number, append: boolean): void; - write$byte_A(b: number[]): void; - write$byte_A$int$int(b: number[], off: number, len: number): void; - write(b?: any, off?: any, len?: any): any; - /** - * - */ - flush(): void; - close(): void; - } -} -declare namespace java.io { - /** - * JSweet implementation based on a local storage FS. - * @param {string} n - * @class - * @extends java.io.InputStream - */ - class FileInputStream extends java.io.InputStream { - content: number[]; - index: number; - constructor(n?: any); - read$(): number; - readBytes(b: number[], off: number, len: number): number; - read$byte_A(b: number[]): number; - read$byte_A$int$int(b: number[], off: number, len: number): number; - read(b?: any, off?: any, len?: any): number; - skip(n: number): number; - available(): number; - close(): void; - } -} -declare namespace java.io { - /** - * JSweet implementation. - * @param {string} fileName - * @param {boolean} append - * @class - * @extends java.io.OutputStreamWriter - */ - class FileWriter extends java.io.OutputStreamWriter { - constructor(fileName?: any, append?: any); - } -} -declare namespace java.io { - interface FilenameFilter { - (dir: java.io.File, name: string): boolean; - } -} -declare namespace java.io { - /** - * JSweet implementation. - * @param {string} fileName - * @class - * @extends java.io.InputStreamReader - */ - class FileReader extends java.io.InputStreamReader { - constructor(fileName?: any); - } -} -declare namespace java.io { - /** - * JSweet implementation. - * @param {string} s - * @class - * @extends java.io.IOException - */ - class FileNotFoundException extends java.io.IOException { - static serialVersionUID: number; - constructor(s?: any); - } -} -declare namespace java.io { - interface FileFilter { - (pathname: java.io.File): boolean; - } -} -declare namespace java.io { - class LocalStorageFileSystem extends java.io.FileSystem { - PREFIX: string; - roots: java.io.File[]; - /** - * The FileSystem object representing the platform's local file system. - */ - static fs: LocalStorageFileSystem; - static fs_$LI$(): LocalStorageFileSystem; - /** - * - * @return {string} - */ - getSeparator(): string; - /** - * - * @return {string} - */ - getPathSeparator(): string; - normalize$java_lang_String$int$int(pathname: string, len: number, off: number): string; - normalize(pathname?: any, len?: any, off?: any): string; - normalize$java_lang_String(pathname: string): string; - /** - * - * @param {string} pathname - * @return {number} - */ - prefixLength(pathname: string): number; - resolve$java_lang_String$java_lang_String(parent: string, child: string): string; - /** - * - * @param {string} parent - * @param {string} child - * @return {string} - */ - resolve(parent?: any, child?: any): string; - /** - * - * @return {string} - */ - getDefaultParent(): string; - /** - * - * @param {string} path - * @return {string} - */ - fromURIPath(path: string): string; - /** - * - * @param {java.io.File} f - * @return {boolean} - */ - isAbsolute(f: java.io.File): boolean; - resolve$java_io_File(f: java.io.File): string; - /** - * - * @param {string} path - * @return {string} - */ - canonicalize(path: string): string; - /** - * - * @param {java.io.File} f - * @return {number} - */ - getBooleanAttributes(f: java.io.File): number; - /** - * - * @param {java.io.File} f - * @param {number} access - * @return {boolean} - */ - checkAccess(f: java.io.File, access: number): boolean; - /** - * - * @param {java.io.File} f - * @param {number} access - * @param {boolean} enable - * @param {boolean} owneronly - * @return {boolean} - */ - setPermission(f: java.io.File, access: number, enable: boolean, owneronly: boolean): boolean; - /** - * - * @param {java.io.File} f - * @return {number} - */ - getLastModifiedTime(f: java.io.File): number; - /** - * - * @param {java.io.File} f - * @return {number} - */ - getLength(f: java.io.File): number; - clear(): void; - getKey(pathname: string): string; - createFileEntry(pathname: string): LocalStorageFileSystem.Entry; - /** - * - * @param {string} pathname - * @return {boolean} - */ - createFileExclusively(pathname: string): boolean; - hasEntry(pathname: string): boolean; - getEntry(pathname: string): LocalStorageFileSystem.Entry; - getDirectoryEntry(pathname: string): LocalStorageFileSystem.DirectoryEntry; - putEntry(pathname: string, entry: LocalStorageFileSystem.Entry): void; - getChildEntries(pathname: string): Array; - removeEntry(pathname: string): void; - /** - * - * @param {java.io.File} f - * @return {boolean} - */ - delete(f: java.io.File): boolean; - /** - * - * @param {java.io.File} f - * @return {java.lang.String[]} - */ - list(f: java.io.File): string[]; - /** - * - * @param {java.io.File} f - * @return {boolean} - */ - createDirectory(f: java.io.File): boolean; - /** - * - * @param {java.io.File} f1 - * @param {java.io.File} f2 - * @return {boolean} - */ - rename(f1: java.io.File, f2: java.io.File): boolean; - /** - * - * @param {java.io.File} f - * @param {number} time - * @return {boolean} - */ - setLastModifiedTime(f: java.io.File, time: number): boolean; - /** - * - * @param {java.io.File} f - * @return {boolean} - */ - setReadOnly(f: java.io.File): boolean; - /** - * - * @return {java.io.File[]} - */ - listRoots(): java.io.File[]; - /** - * - * @param {java.io.File} f - * @param {number} t - * @return {number} - */ - getSpace(f: java.io.File, t: number): number; - /** - * - * @param {java.io.File} f1 - * @param {java.io.File} f2 - * @return {number} - */ - compare(f1: java.io.File, f2: java.io.File): number; - /** - * - * @param {java.io.File} f - * @return {number} - */ - hashCode(f: java.io.File): number; - constructor(); - } - namespace LocalStorageFileSystem { - interface Entry { - attributes: number; - access: number; - data: string; - lastModifiedTime: number; - length: number; - } - interface DirectoryEntry extends LocalStorageFileSystem.Entry { - entries: string[]; - } - } -} -declare namespace java.io { - /** - * JSweet implementation for file. - * @param {string} parent - * @param {string} child - * @class - */ - class File implements java.io.Serializable, java.lang.Comparable { - path: string; - status: File.PathStatus; - isInvalid(): boolean; - prefixLength: number; - getPrefixLength(): number; - static separatorChar: string; - static separatorChar_$LI$(): string; - static separator: string; - static separator_$LI$(): string; - static pathSeparatorChar: string; - static pathSeparatorChar_$LI$(): string; - static pathSeparator: string; - static pathSeparator_$LI$(): string; - constructor(parent?: any, child?: any, direct?: any); - getName(): string; - getParent(): string; - getParentFile(): File; - getPath(): string; - isAbsolute(): boolean; - getAbsolutePath(): string; - getAbsoluteFile(): File; - getCanonicalPath(): string; - getCanonicalFile(): File; - static slashify(path: string, isDirectory: boolean): string; - canRead(): boolean; - canWrite(): boolean; - exists(): boolean; - isDirectory(): boolean; - isFile(): boolean; - isHidden(): boolean; - lastModified(): number; - length(): number; - createNewFile(): boolean; - delete(): boolean; - list$(): string[]; - list$java_io_FilenameFilter(filter: java.io.FilenameFilter): string[]; - list(filter?: any): string[]; - listFiles$(): File[]; - listFiles$java_io_FilenameFilter(filter: java.io.FilenameFilter): File[]; - listFiles(filter?: any): File[]; - listFiles$java_io_FileFilter(filter: java.io.FileFilter): File[]; - mkdir(): boolean; - mkdirs(): boolean; - renameTo(dest: File): boolean; - setLastModified(time: number): boolean; - setReadOnly(): boolean; - setWritable$boolean$boolean(writable: boolean, ownerOnly: boolean): boolean; - setWritable(writable?: any, ownerOnly?: any): boolean; - setWritable$boolean(writable: boolean): boolean; - setReadable$boolean$boolean(readable: boolean, ownerOnly: boolean): boolean; - setReadable(readable?: any, ownerOnly?: any): boolean; - setReadable$boolean(readable: boolean): boolean; - setExecutable$boolean$boolean(executable: boolean, ownerOnly: boolean): boolean; - setExecutable(executable?: any, ownerOnly?: any): boolean; - setExecutable$boolean(executable: boolean): boolean; - canExecute(): boolean; - static listRoots(): File[]; - getTotalSpace(): number; - getFreeSpace(): number; - getUsableSpace(): number; - static createTempFile$java_lang_String$java_lang_String$java_io_File(prefix: string, suffix: string, directory: File): File; - static createTempFile(prefix?: any, suffix?: any, directory?: any): File; - static createTempFile$java_lang_String$java_lang_String(prefix: string, suffix: string): File; - compareTo(pathname: File): number; - equals(obj: any): boolean; - hashCode(): number; - toString(): string; - static serialVersionUID: number; - } - namespace File { - enum PathStatus { - INVALID = 0, - CHECKED = 1 - } - class TempDirectory { - constructor(); - static tmpdir: java.io.File; - static tmpdir_$LI$(): java.io.File; - static location(): java.io.File; - static generateFile(prefix: string, suffix: string, dir: java.io.File): java.io.File; - } - } -}