diff --git a/dist/j4ts-file.d.ts b/dist/j4ts-file.d.ts
index 3ab3b44..3b4163b 100644
--- a/dist/j4ts-file.d.ts
+++ b/dist/j4ts-file.d.ts
@@ -1,19 +1,27 @@
-declare namespace java.io {
- interface FileFilter {
- (pathname: java.io.File): boolean;
+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 {
/**
* JSweet implementation based on a local storage FS.
+ * @param {string} name
+ * @class
+ * @extends java.io.InputStream
*/
class FileInputStream extends java.io.InputStream {
- private content;
- private index;
+ content: number[];
+ index: number;
constructor(name?: any);
read$(): number;
- private readBytes(b, off, len);
+ 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): any;
skip(n: number): number;
available(): number;
@@ -21,80 +29,52 @@ declare namespace java.io {
}
}
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);
+ interface FileFilter {
+ (pathname: java.io.File): boolean;
}
}
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.
- */
normalize$java_lang_String(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;
/**
* 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 +82,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 +102,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 +114,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 +151,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 {Array}
*/
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 {Array}
*/
abstract listRoots(): java.io.File[];
static SPACE_TOTAL: number;
@@ -203,63 +214,195 @@ 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.
+ * @param {string} fileName
+ * @class
+ * @extends java.io.InputStreamReader
*/
- class FileWriter extends java.io.OutputStreamWriter {
- constructor(fileName?: any, append?: any);
+ 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 {
+ /**
+ * 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 FilenameFilter {
+ (dir: java.io.File, name: string): boolean;
+ }
+}
+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 {
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$java_lang_String$int$int(pathname: string, len: number, off: number): string;
normalize(pathname?: any, len?: any, off?: any): any;
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): any;
+ /**
+ *
+ * @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 +410,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 {Array}
+ */
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 {Array}
+ */
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 +491,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,8 +531,10 @@ declare namespace java.io {
createNewFile(): boolean;
delete(): boolean;
list$(): string[];
+ list$java_io_FilenameFilter(filter: java.io.FilenameFilter): string[];
list(filter?: any): any;
listFiles$(): File[];
+ listFiles$java_io_FilenameFilter(filter: java.io.FilenameFilter): File[];
listFiles(filter?: any): any;
listFiles$java_io_FileFilter(filter: java.io.FileFilter): File[];
mkdir(): boolean;
@@ -341,15 +542,23 @@ declare namespace java.io {
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): any;
+ setWritable$boolean(writable: boolean): boolean;
+ setReadable$boolean$boolean(readable: boolean, ownerOnly: boolean): boolean;
+ setReadable(readable?: any, ownerOnly?: any): any;
+ setReadable$boolean(readable: boolean): boolean;
+ setExecutable$boolean$boolean(executable: boolean, ownerOnly: boolean): boolean;
+ setExecutable(executable?: any, ownerOnly?: any): any;
+ 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): any;
+ static createTempFile$java_lang_String$java_lang_String(prefix: string, suffix: string): File;
compareTo(pathname: File): number;
equals(obj: any): boolean;
hashCode(): number;
diff --git a/dist/j4ts-file.js b/dist/j4ts-file.js
index 3c8ec70..180f882 100644
--- a/dist/j4ts-file.js
+++ b/dist/j4ts-file.js
@@ -3,64 +3,145 @@ var __extends = (this && this.__extends) || function (d, b) {
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 */
+/* Generated from Java with JSweet 2.0.1-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!";
+ }
+ }
+ 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.
+ * @param {string} name
+ * @class
+ * @extends java.io.InputStream
*/
var FileInputStream = (function (_super) {
__extends(FileInputStream, _super);
function FileInputStream(name) {
var _this = this;
if (((typeof name === 'string') || name === null)) {
+ var __args = Array.prototype.slice.call(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"] });
- this.index = 0;
+ var __args_1 = Array.prototype.slice.call(arguments);
+ var file_1 = name != null ? new java.io.File(name) : null;
+ _this = _super.call(this) || this;
+ if (_this.content === undefined)
+ _this.content = null;
+ if (_this.index === undefined)
+ _this.index = 0;
+ if (_this.content === undefined)
+ _this.content = null;
+ if (_this.index === undefined)
+ _this.index = 0;
(function () {
- var name = (file != null ? file.getPath() : null);
+ var name = (file_1 != null ? file_1.getPath() : null);
if (name == null) {
throw new java.lang.NullPointerException();
}
- if (file.isInvalid()) {
+ if (file_1.isInvalid()) {
throw new java.io.FileNotFoundException("Invalid file path");
}
- if (!file.exists()) {
+ if (!file_1.exists()) {
throw new java.io.FileNotFoundException();
}
- _this.content = atob(java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()).data);
+ _this.content = (atob(java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file_1.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;
+ var __args = Array.prototype.slice.call(arguments);
+ var file_2 = __args[0];
+ _this = _super.call(this) || this;
+ if (_this.content === undefined)
+ _this.content = null;
+ if (_this.index === undefined)
+ _this.index = 0;
+ if (_this.content === undefined)
+ _this.content = null;
+ if (_this.index === undefined)
+ _this.index = 0;
(function () {
- var name = (file != null ? file.getPath() : null);
+ var name = (file_2 != null ? file_2.getPath() : null);
if (name == null) {
throw new java.lang.NullPointerException();
}
- if (file.isInvalid()) {
+ if (file_2.isInvalid()) {
throw new java.io.FileNotFoundException("Invalid file path");
}
- if (!file.exists()) {
+ if (!file_2.exists()) {
throw new java.io.FileNotFoundException();
}
- _this.content = atob(java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file.getAbsolutePath()).data);
+ _this.content = (atob(java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file_2.getAbsolutePath()).data));
_this.index = 0;
})();
}
else
throw new Error('invalid overload');
+ return _this;
}
FileInputStream.prototype.read$ = function () {
if (this.index >= this.content.length) {
@@ -68,7 +149,7 @@ var java;
}
return this.content[this.index++];
};
- FileInputStream.prototype.readBytes = function (b, off, len) {
+ /*private*/ FileInputStream.prototype.readBytes = function (b, off, len) {
if (this.index >= this.content.length) {
return -1;
}
@@ -80,19 +161,20 @@ var java;
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$byte_A$int$int = function (b, off, len) {
+ return this.readBytes(b, off, len);
+ };
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);
- })();
+ 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 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.read$byte_A(b);
}
else if (b === undefined && off === undefined && len === undefined) {
@@ -113,156 +195,261 @@ var java;
return FileInputStream;
}(java.io.InputStream));
io.FileInputStream = FileInputStream;
- FileInputStream["__classname"] = "java.io.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.
+ * Package-private abstract class for the local filesystem abstraction.
+ * @class
*/
- 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 () {
- })();
+ 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);
}
- else if (s === undefined) {
- _super.call(this);
- Object.defineProperty(this, '__interfaces', { configurable: true, value: ["java.io.Serializable"] });
- (function () {
- })();
+ else
+ throw new Error('invalid overload');
+ };
+ FileSystem.prototype.normalize$java_lang_String = function (path) { throw new Error('cannot invoke abstract overloaded method... check your argument(s) type(s)'); };
+ 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 (((parent != null && parent instanceof java.io.File) || parent === null) && child === undefined) {
+ return this.resolve$java_io_File(parent);
}
else
throw new Error('invalid overload');
- }
- FileNotFoundException.serialVersionUID = -897856973823710492;
- return FileNotFoundException;
- }(java.io.IOException));
- io.FileNotFoundException = FileNotFoundException;
- FileNotFoundException["__classname"] = "java.io.FileNotFoundException";
+ };
+ 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 ((function (o1, o2) { return o1.toUpperCase() === (o2 === null ? o2 : o2.toUpperCase()); })(val, "true")) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ };
+ FileSystem.__static_initializer_0 = function () {
+ FileSystem.useCanonCaches = FileSystem.getBooleanProperty("sun.io.useCanonCaches", FileSystem.useCanonCaches);
+ FileSystem.useCanonPrefixCache = FileSystem.getBooleanProperty("sun.io.useCanonPrefixCache", FileSystem.useCanonPrefixCache);
+ };
+ return FileSystem;
+ }());
+ 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;
+ 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) {
__extends(FileOutputStream, _super);
function FileOutputStream(name, append) {
var _this = this;
if (((typeof name === 'string') || name === null) && ((typeof append === 'boolean') || append === null)) {
+ var __args = Array.prototype.slice.call(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;
+ var __args_2 = Array.prototype.slice.call(arguments);
+ var file_3 = name != null ? new java.io.File(name) : null;
+ _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 (_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 () {
- if (!file.exists()) {
+ if (!file_3.exists()) {
throw new java.io.FileNotFoundException();
}
- _this.file = file;
+ _this.file = file_3;
_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.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file_3.getAbsolutePath());
+ _this.content = append ? (_this.entry.data).split('').map(function (s) { return s.charCodeAt(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;
+ var __args = Array.prototype.slice.call(arguments);
+ var file_4 = __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 (_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 () {
- if (!file.exists()) {
+ if (!file_4.exists()) {
throw new java.io.FileNotFoundException();
}
- _this.file = file;
+ _this.file = file_4;
_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.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file_4.getAbsolutePath());
+ _this.content = append ? (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : [];
})();
}
else if (((typeof name === 'string') || name === null) && append === undefined) {
+ var __args = Array.prototype.slice.call(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;
+ var __args_3 = Array.prototype.slice.call(arguments);
+ var file_5 = name != null ? new java.io.File(name) : null;
+ 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 (_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 () {
- if (!file.exists()) {
+ if (!file_5.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.file = file_5;
+ _this.append = append_1;
+ _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file_5.getAbsolutePath());
+ _this.content = append_1 ? (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : [];
})();
}
- (function () {
- })();
}
else if (((name != null && name instanceof java.io.File) || name === null) && append === undefined) {
- var file = name;
+ var __args = Array.prototype.slice.call(arguments);
+ var file_6 = __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;
+ var __args_4 = Array.prototype.slice.call(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 (_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 () {
- if (!file.exists()) {
+ if (!file_6.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.file = file_6;
+ _this.append = append_2;
+ _this.entry = java.io.LocalStorageFileSystem.fs_$LI$().getEntry(file_6.getAbsolutePath());
+ _this.content = append_2 ? (_this.entry.data).split('').map(function (s) { return s.charCodeAt(0); }) : [];
})();
}
- (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]);
}
+ ;
};
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,10 +458,13 @@ 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(""));
+ }).join("")));
java.io.LocalStorageFileSystem.fs_$LI$().putEntry(this.file.getAbsolutePath(), this.entry);
};
FileOutputStream.prototype.close = function () {
@@ -283,277 +473,175 @@ 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.
+ * @param {string} fileName
+ * @class
+ * @extends java.io.InputStreamReader
*/
var FileReader = (function (_super) {
__extends(FileReader, _super);
function FileReader(fileName) {
+ var _this = this;
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 __args = Array.prototype.slice.call(arguments);
+ _this = _super.call(this, new java.io.FileInputStream(fileName)) || this;
}
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 () {
- })();
+ var __args = Array.prototype.slice.call(arguments);
+ var file = __args[0];
+ _this = _super.call(this, new java.io.FileInputStream(file)) || this;
}
else
throw new Error('invalid overload');
+ return _this;
}
return FileReader;
}(java.io.InputStreamReader));
io.FileReader = FileReader;
- FileReader["__classname"] = "java.io.FileReader";
+ FileReader["__class"] = "java.io.FileReader";
+ FileReader["__interfaces"] = ["java.io.Closeable", "java.lang.Readable", "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) {
/**
- * Package-private abstract class for the local filesystem abstraction.
+ * JSweet implementation.
+ * @param {string} s
+ * @class
+ * @extends java.io.IOException
*/
- 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);
- }
- else
- throw new Error('invalid overload');
- };
- /**
- * 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;
+ var FileNotFoundException = (function (_super) {
+ __extends(FileNotFoundException, _super);
+ function FileNotFoundException(s) {
+ var _this = this;
+ if (((typeof s === 'string') || s === null)) {
+ var __args = Array.prototype.slice.call(arguments);
+ _this = _super.call(this, s) || this;
+ Object.setPrototypeOf(_this, FileNotFoundException.prototype);
}
- else if (((parent != null && parent instanceof java.io.File) || parent === null) && child === undefined) {
- return this.resolve$java_io_File(parent);
+ else if (s === undefined) {
+ var __args = Array.prototype.slice.call(arguments);
+ _this = _super.call(this) || this;
+ Object.setPrototypeOf(_this, FileNotFoundException.prototype);
}
else
throw new Error('invalid overload');
- };
- /**
- * 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;
- }
- else {
- return false;
- }
- };
- 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";
+ return _this;
+ }
+ return FileNotFoundException;
+ }(java.io.IOException));
+ FileNotFoundException.serialVersionUID = -897856973823710492;
+ io.FileNotFoundException = FileNotFoundException;
+ FileNotFoundException["__class"] = "java.io.FileNotFoundException";
+ FileNotFoundException["__interfaces"] = ["java.io.Serializable"];
})(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) {
__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 = Array.prototype.slice.call(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 = Array.prototype.slice.call(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 = Array.prototype.slice.call(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 = Array.prototype.slice.call(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!";
- }
- }
- 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["__classname"] = "test.TestFile";
-})(test || (test = {}));
-/* Generated from Java with JSweet 1.2.0-SNAPSHOT - http://www.jsweet.org */
-var java;
(function (java) {
var io;
(function (io) {
var LocalStorageFileSystem = (function (_super) {
__extends(LocalStorageFileSystem, _super);
function LocalStorageFileSystem() {
- _super.call(this);
- this.PREFIX = "LSFS://";
+ var _this = _super.call(this) || this;
+ /*private*/ _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; };
;
+ /**
+ *
+ * @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);
@@ -566,33 +654,61 @@ var java;
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);
+ 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 ((function (o1, o2) { if (o1 && o1.equals) {
+ return o1.equals(o2);
+ }
+ else {
+ return o1 === o2;
+ } })(child, ""))
+ return parent;
+ if ((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(child.charAt(0)) == '/'.charCodeAt(0)) {
+ if ((function (o1, o2) { if (o1 && o1.equals) {
+ return o1.equals(o2);
+ }
+ else {
+ return o1 === o2;
+ } })(parent, "/"))
+ return child;
+ return parent + child;
+ }
+ if ((function (o1, o2) { if (o1 && o1.equals) {
+ return o1.equals(o2);
+ }
+ else {
+ return o1 === o2;
+ } })(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,9 +716,18 @@ 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)) {
@@ -610,30 +735,69 @@ var java;
}
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;
};
@@ -647,6 +811,7 @@ var java;
localStorage.removeItem(key);
}
}
+ ;
};
LocalStorageFileSystem.prototype.getKey = function (pathname) {
return this.PREFIX + pathname;
@@ -678,6 +843,11 @@ var java;
}, '__interfaces', { configurable: true, value: ["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,7 +870,7 @@ var java;
return directoryEntry.entries;
}
else {
- return new Array();
+ return (new Array());
}
};
LocalStorageFileSystem.prototype.removeEntry = function (pathname) {
@@ -715,7 +885,12 @@ 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();
@@ -727,9 +902,19 @@ var java;
}
return false;
};
+ /**
+ *
+ * @param {java.io.File} f
+ * @return {Array}
+ */
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,17 +933,23 @@ 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)
+ entries: []
}, '__interfaces', { configurable: true, value: ["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());
}
@@ -769,6 +960,12 @@ var java;
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,112 +976,194 @@ 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 {Array}
+ */
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());
};
+ /**
+ *
+ * @param {java.io.File} f
+ * @return {number}
+ */
LocalStorageFileSystem.prototype.hashCode = function (f) {
- return f.getAbsolutePath().toString();
+ return (function (o) { if (o.hashCode) {
+ return o.hashCode();
+ }
+ else {
+ return o.toString();
+ } })(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 () {
function File(parent, child, direct) {
var _this = this;
- this.status = null;
+ /*private*/ 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;
+ var __args = Array.prototype.slice.call(arguments);
+ if (this.path === undefined)
+ this.path = null;
+ if (this.prefixLength === undefined)
+ this.prefixLength = 0;
+ this.status = null;
+ if (this.path === undefined)
+ this.path = null;
+ if (this.prefixLength === undefined)
+ this.prefixLength = 0;
(function () {
- _this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve(parent.path, child);
+ _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;
+ var __args = Array.prototype.slice.call(arguments);
+ if (this.path === undefined)
+ this.path = null;
+ if (this.prefixLength === undefined)
+ this.prefixLength = 0;
+ this.status = null;
+ if (this.path === undefined)
+ this.path = null;
+ if (this.prefixLength === undefined)
+ 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));
+ if ((function (o1, o2) { if (o1 && o1.equals) {
+ return o1.equals(o2);
}
else {
- _this.path = java.io.LocalStorageFileSystem.fs_$LI$().resolve(java.io.LocalStorageFileSystem.fs_$LI$().normalize(parent), java.io.LocalStorageFileSystem.fs_$LI$().normalize(child));
+ return o1 === o2;
+ } })(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$().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));
}
}
else {
- _this.path = java.io.LocalStorageFileSystem.fs_$LI$().normalize(child);
+ _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;
+ var __args = Array.prototype.slice.call(arguments);
+ if (this.path === undefined)
+ this.path = null;
+ if (this.prefixLength === undefined)
+ this.prefixLength = 0;
+ this.status = null;
+ if (this.path === undefined)
+ this.path = null;
+ if (this.prefixLength === undefined)
+ 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));
+ if ((function (o1, o2) { if (o1 && o1.equals) {
+ return o1.equals(o2);
+ }
+ else {
+ return o1 === o2;
+ } })(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$().resolve(parent.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));
}
}
else {
- _this.path = java.io.LocalStorageFileSystem.fs_$LI$().normalize(child);
+ _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;
+ var __args = Array.prototype.slice.call(arguments);
+ var pathname_1 = __args[0];
+ var prefixLength_1 = __args[1];
+ if (this.path === undefined)
+ this.path = null;
+ if (this.prefixLength === undefined)
+ this.prefixLength = 0;
+ this.status = null;
+ if (this.path === undefined)
+ this.path = null;
+ if (this.prefixLength === undefined)
+ this.prefixLength = 0;
(function () {
- _this.path = pathname;
- _this.prefixLength = prefixLength;
+ _this.path = pathname_1;
+ _this.prefixLength = prefixLength_1;
})();
}
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;
+ var __args = Array.prototype.slice.call(arguments);
+ var pathname_2 = __args[0];
+ if (this.path === undefined)
+ this.path = null;
+ if (this.prefixLength === undefined)
+ this.prefixLength = 0;
+ this.status = null;
+ if (this.path === undefined)
+ this.path = null;
+ if (this.prefixLength === undefined)
+ this.prefixLength = 0;
(function () {
- if (pathname == null) {
+ if (pathname_2 == null) {
throw new java.lang.NullPointerException();
}
- _this.path = java.io.LocalStorageFileSystem.fs_$LI$().normalize(pathname);
+ _this.path = java.io.LocalStorageFileSystem.fs_$LI$().normalize$java_lang_String(pathname_2);
_this.prefixLength = java.io.LocalStorageFileSystem.fs_$LI$().prefixLength(_this.path);
})();
}
@@ -940,7 +1219,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 +1229,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,7 +1237,7 @@ var java;
};
File.slashify = function (path, isDirectory) {
var p = path;
- if (File.separatorChar_$LI$() !== '/')
+ if ((function (c) { return c.charCodeAt == null ? c : c.charCodeAt(0); })(File.separatorChar_$LI$()) != '/'.charCodeAt(0))
p = p.split(File.separatorChar_$LI$()).join('/');
if (!(function (str, searchString, position) {
if (position === void 0) { position = 0; }
@@ -1023,11 +1302,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 +1314,24 @@ var java;
}
return java.io.LocalStorageFileSystem.fs_$LI$().list(this);
};
+ 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((function (s) { var a = []; while (s-- > 0)
+ a.push(null); return a; })(v.size()));
+ };
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]);
- }
- }
- return v.toArray(new Array(v.size()));
- })();
+ return this.list$java_io_FilenameFilter(filter);
}
else if (filter === undefined) {
return this.list$();
@@ -1063,27 +1344,30 @@ var java;
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);
}
+ ;
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 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((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()));
- })();
+ return this.listFiles$java_io_FilenameFilter(filter);
}
else if (((typeof filter === 'function' && filter.length == 1) || filter === null)) {
return this.listFiles$java_io_FileFilter(filter);
@@ -1098,7 +1382,7 @@ var java;
var ss = this.list();
if (ss == null)
return null;
- var files = new java.util.ArrayList();
+ var files = (new java.util.ArrayList());
for (var index124 = 0; index124 < ss.length; index124++) {
var s = ss[index124];
{
@@ -1107,7 +1391,8 @@ var java;
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()) {
@@ -1156,27 +1441,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 +1525,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)
@@ -1219,6 +1539,19 @@ var java;
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);
};
@@ -1229,23 +1562,28 @@ var java;
return false;
};
File.prototype.hashCode = function () {
- return java.io.LocalStorageFileSystem.fs_$LI$().hashCode(this);
+ return (function (o) { if (o.hashCode) {
+ return o.hashCode();
+ }
+ else {
+ return o.toString();
+ } })(java.io.LocalStorageFileSystem.fs_$LI$());
};
File.prototype.toString = function () {
return this.getPath();
};
- File.serialVersionUID = 301077366599181567;
return File;
}());
+ File.serialVersionUID = 301077366599181567;
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;
+ })(PathStatus = File.PathStatus || (File.PathStatus = {}));
var TempDirectory = (function () {
function TempDirectory() {
}
@@ -1256,7 +1594,7 @@ var java;
return TempDirectory.tmpdir_$LI$();
};
TempDirectory.generateFile = function (prefix, suffix, dir) {
- var n = Math.round(Math.random()) * javaemul.internal.LongHelper.MAX_VALUE;
+ var n = Math.floor(Math.random()) * javaemul.internal.LongHelper.MAX_VALUE;
if (n === javaemul.internal.LongHelper.MIN_VALUE) {
n = 0;
}
@@ -1264,9 +1602,14 @@ var java;
n = Math.abs(n);
}
prefix = (new java.io.File(prefix)).getName();
- var name = prefix + ('' + n) + suffix;
+ var name = prefix + ('' + (n)) + suffix;
var f = new java.io.File(dir, name);
- if (!(name === f.getName()) || f.isInvalid()) {
+ if (!(function (o1, o2) { if (o1 && o1.equals) {
+ return o1.equals(o2);
+ }
+ else {
+ return o1 === o2;
+ } })(name, f.getName()) || f.isInvalid()) {
throw new java.io.IOException("Unable to create temporary file, " + f);
}
return f;
@@ -1274,7 +1617,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/jsweetconfig.json b/jsweetconfig.json
new file mode 100644
index 0000000..7f2a070
--- /dev/null
+++ b/jsweetconfig.json
@@ -0,0 +1,5 @@
+{
+ "adapters": [
+ "org.jsweet.transpiler.extension.Java2TypeScriptAdapter"
+ ]
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 2ebb99c..5468e34 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
j4ts-file
0.0.1-SNAPSHOT
- 1.1.1
+ 2.0.1
@@ -60,7 +60,7 @@
org.jsweet
jsweet-maven-plugin
- 1.2.0-SNAPSHOT
+ 2.0.1-SNAPSHOT
true
@@ -149,14 +149,14 @@
test
- org.jsweet.candies
+ org.jsweet
jsweet-core
- 1.2.0-SNAPSHOT
+ 5-SNAPSHOT
- org.jsweet.candies
+ org.jsweet
j4ts
- 0.3.0-SNAPSHOT
+ 0.6.0-SNAPSHOT
@@ -177,4 +177,4 @@
http://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..8e59209 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.
diff --git a/src/main/java/java/io/FileOutputStream.java b/src/main/java/java/io/FileOutputStream.java
index aa8a4f4..451089b 100644
--- a/src/main/java/java/io/FileOutputStream.java
+++ b/src/main/java/java/io/FileOutputStream.java
@@ -1,7 +1,8 @@
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;
+import static jsweet.util.Lang.string;
/**
* JSweet partial implementation based on a local storage FS.
@@ -65,9 +66,9 @@ 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(""));
+ entry.data = btoa(string(array(content).map((b, __, ___) -> {
+ return string(def.js.String.fromCharCode(b));
+ }).join("")));
LocalStorageFileSystem.fs.putEntry(file.getAbsolutePath(), entry);
}
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..4ad6101 100644
--- a/src/main/java/java/io/LocalStorageFileSystem.java
+++ b/src/main/java/java/io/LocalStorageFileSystem.java
@@ -1,11 +1,12 @@
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 static jsweet.util.Lang.string;
-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 {
@@ -246,7 +247,7 @@ public boolean delete(File f) {
String parentPath = f.getParentFile().getAbsolutePath();
DirectoryEntry directoryEntry = getDirectoryEntry(parentPath);
Array entries = array(directoryEntry.entries);
- directoryEntry.entries = entries.splice(entries.indexOf(f.getName()), 1);
+ directoryEntry.entries = array(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..b63bac6 100644
--- a/src/main/java/test/TestFile.java
+++ b/src/main/java/test/TestFile.java
@@ -1,8 +1,9 @@
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 static jsweet.util.Lang.$strict;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -11,13 +12,12 @@
import java.io.FileWriter;
import java.io.IOException;
-import jsweet.dom.HTMLElement;
-import jsweet.util.Globals;
+import def.dom.HTMLElement;
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..3b4163b 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,19 +1,27 @@
-declare namespace java.io {
- interface FileFilter {
- (pathname: java.io.File): boolean;
+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 {
/**
* JSweet implementation based on a local storage FS.
+ * @param {string} name
+ * @class
+ * @extends java.io.InputStream
*/
class FileInputStream extends java.io.InputStream {
- private content;
- private index;
+ content: number[];
+ index: number;
constructor(name?: any);
read$(): number;
- private readBytes(b, off, len);
+ 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): any;
skip(n: number): number;
available(): number;
@@ -21,80 +29,52 @@ declare namespace java.io {
}
}
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);
+ interface FileFilter {
+ (pathname: java.io.File): boolean;
}
}
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.
- */
normalize$java_lang_String(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;
/**
* 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 +82,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 +102,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 +114,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 +151,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 {Array}
*/
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 {Array}
*/
abstract listRoots(): java.io.File[];
static SPACE_TOTAL: number;
@@ -203,63 +214,195 @@ 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.
+ * @param {string} fileName
+ * @class
+ * @extends java.io.InputStreamReader
*/
- class FileWriter extends java.io.OutputStreamWriter {
- constructor(fileName?: any, append?: any);
+ 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 {
+ /**
+ * 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 FilenameFilter {
+ (dir: java.io.File, name: string): boolean;
+ }
+}
+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 {
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$java_lang_String$int$int(pathname: string, len: number, off: number): string;
normalize(pathname?: any, len?: any, off?: any): any;
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): any;
+ /**
+ *
+ * @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 +410,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 {Array}
+ */
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 {Array}
+ */
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 +491,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,8 +531,10 @@ declare namespace java.io {
createNewFile(): boolean;
delete(): boolean;
list$(): string[];
+ list$java_io_FilenameFilter(filter: java.io.FilenameFilter): string[];
list(filter?: any): any;
listFiles$(): File[];
+ listFiles$java_io_FilenameFilter(filter: java.io.FilenameFilter): File[];
listFiles(filter?: any): any;
listFiles$java_io_FileFilter(filter: java.io.FileFilter): File[];
mkdir(): boolean;
@@ -341,15 +542,23 @@ declare namespace java.io {
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): any;
+ setWritable$boolean(writable: boolean): boolean;
+ setReadable$boolean$boolean(readable: boolean, ownerOnly: boolean): boolean;
+ setReadable(readable?: any, ownerOnly?: any): any;
+ setReadable$boolean(readable: boolean): boolean;
+ setExecutable$boolean$boolean(executable: boolean, ownerOnly: boolean): boolean;
+ setExecutable(executable?: any, ownerOnly?: any): any;
+ 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): any;
+ static createTempFile$java_lang_String$java_lang_String(prefix: string, suffix: string): File;
compareTo(pathname: File): number;
equals(obj: any): boolean;
hashCode(): number;