GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node-java/java.d.ts at master · joeferner/node-java Expand file tree/ Copy pathjava.d.tsMore file actions 343 lines (305 loc) · 13.9 KB / Copy pathjava.d.tsFile metadata and controls343 lines (305 loc) · 13.9 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 /* eslint-disable @typescript-eslint/no-unsafe-function-type */ /* eslint-disable @typescript-eslint/no-explicit-any */ declare const NodeJavaCore: NodeJavaCore.Java; export = NodeJavaCore; declare namespace NodeJavaCore { type JavaObject = any; type JavaError = Error & { cause?: JavaObject }; export interface Callback<T> { (err?: Error, result?: T): void; } export interface JavaCallback<T> { (err?: JavaError, result?: T): void; } interface AsyncOptions { /** * Suffix for synchronous method call signatures. */ syncSuffix: string; /** * Suffix for callback-based async method call signatures. */ asyncSuffix?: string | undefined; /** * Suffix for promise-based async method call signatures */ promiseSuffix?: string | undefined; /** * The JavaScript object returned by `java.import(classname)` is a JavaScript constructor * Function, implemented such that you can create instances of the Java class. For example: */ ifReadOnlySuffix?: string | undefined; } interface ProxyFunctions { [index: string]: Function; } interface Java { /** * Array of paths or jars to pass to the creation of the JVM. * * All items must be added to the classpath before calling any other node-java methods. * * @example * java.classpath.push('commons.io.jar'); * java.classpath.push('src'); */ classpath: string[]; /** * Array of options to pass to the creation of the JVM. * * All items must be added to the options before calling any other node-java methods. * * @example * java.options.push('-Djava.awt.headless=true'); * java.options.push('-Xmx1024m'); */ options: string[]; /** * @see AsyncOptions */ asyncOptions: AsyncOptions; /** * Location of nodejavabridge_bindings.node */ nativeBindingLocation: string; /** * Calls a method on the specified instance. If you are using the sync method an exception * will be throw if an error occurs, otherwise it will be the first argument in the callback. * * @param instance An instance of the class from newInstance. * @param methodName The name of the method to call. The method name can include the full * signature (see [Getting the full method signature](README.md#getFullMethodSignature)). * @param args The arguments to pass to the method, the last argument will be the callback to the function * * @example * const instance = java.newInstanceSync("com.nearinfinty.MyClass"); * java.callMethod(instance, "doSomething", 42, "test", function(err, results) { * if(err) { console.error(err); return; } * // results from doSomething * }); */ callMethod(instance: JavaObject, methodName: string, ...args: any[]): void; /** * Calls a method on the specified instance. If you are using the sync method an exception * will be throw if an error occurs, otherwise it will be the first argument in the callback. * * @param instance An instance of the class from newInstance. * @param methodName The name of the method to call. The method name can include the full * signature (see [Getting the full method signature](README.md#getFullMethodSignature)). * @param args The arguments to pass to the method * @returns The result of the method call * * @example * const instance = java.newInstanceSync("com.nearinfinty.MyClass"); * const result = java.callMethodSync("com.nearinfinty.MyClass", "doSomething", 42, "test"); */ callMethodSync(instance: JavaObject, methodName: string, ...args: any[]): any; /** * Calls a static method on the specified class. If you are using the sync method an exception will be * throw if an error occurs, otherwise it will be the first argument in the callback. * * @param className The name of the class to call the method on. Separate nested classes * using `'$'` (eg. `com.nearinfinty.MyClass$NestedClass`). * @param methodName The name of the method to call. The method name can include the full * signature (see [Getting the full method signature](README.md#getFullMethodSignature)). * @param args The arguments to pass to the method, the last argument will be the callback to the function */ callStaticMethod(className: string, methodName: string, ...args: any[]): void; /** * Calls a static method on the specified class. If you are using the sync method an exception will be * throw if an error occurs, otherwise it will be the first argument in the callback. * * @param className The name of the class to call the method on. Separate nested classes * using `'$'` (eg. `com.nearinfinty.MyClass$NestedClass`). * @param methodName The name of the method to call. The method name can include the full * signature (see [Getting the full method signature](README.md#getFullMethodSignature)). * @param args The arguments to pass to the method * @returns The result of the method call */ callStaticMethodSync(className: string, methodName: string, ...args: any[]): any; /** * Finds the class with the specified binary name. This method should be overridden by class loader * implementations that follow the delegation model for loading classes, and will be invoked by the * loadClass method after checking the parent class loader for the requested class. The default * implementation throws a ClassNotFoundException. * * @param className The binary name of the class * @returns The resulting Class object */ findClassSync(className: string): JavaObject; /** * Gets a static field value from the specified class. * * @param className The name of the class to get the value from. Separate nested classes * using `'$'` (eg. `com.nearinfinty.MyClass$NestedClass`). * @param fieldName The name of the field to get the value from. * @returns The valid of the static field */ getStaticFieldValue(className: string, fieldName: string): any; /** * Sets a static field value on the specified class. * * @param className The name of the class to set the value on. Separate nested classes * using `'$'` (eg. `com.nearinfinty.MyClass$NestedClass`). * @param fieldName The name of the field to set the value on. * @param newValue The new value to assign to the field. */ setStaticFieldValue(className: string, fieldName: string, newValue: any): void; /** * Determines of a javaObject is an instance of a class. * * @param javaObject Instance of a java object returned from a method or from newInstance. * @param className A string class name. * * @example * const obj = java.newInstanceSync("my.package.SubClass"); * if(java.instanceOf(obj, "my.package.SuperClass")) { * console.log("obj is an instance of SuperClass"); * } */ instanceOf(javaObject: JavaObject, className: string): boolean; /** * Register that a client wants to be called back immediately before and/or immediately * after the JVM is created. If used, this function must be called before the JVM has been * created. The before function is typically used to add to the classpath. The function may * execute asynchronous operations (such as a async glob function). The after function is * sometimes useful for doing one-time initialization that requires the JVM to first be * initialized. If either function is unnecessary, use `null` or `undefined`. See also * `registerClientP` and `ensureJvm`. See the unit tests in `testAsyncOptions` for examples. */ registerClient( before: ((cb: Callback<void>) => void) | undefined | null, after?: (cb: Callback<void>) => void ): void; /** * Register that a client wants to be called back immediately before and/or immediately * after the JVM is created. If used, this function must be called before the JVM has been * created. The before function is typically used to add to the classpath. The function may * execute asynchronous operations (such as a async glob function). The after function is * sometimes useful for doing one-time initialization that requires the JVM to first be * initialized. If either function is unnecessary, use `null` or `undefined`. See also * `registerClientP` and `ensureJvm`. See the unit tests in `testAsyncOptions` for examples. */ registerClientP(beforeP: (() => Promise<void>) | undefined | null, afterP?: () => Promise<void>): void; /** * If the JVM has not yet been created, execute the full JVM initialization process, then * call callback function when initialization is complete. If the JVM has been created, just * call the callback. Note that the full initialization process includes: 1) executing all * registered client *before* hooks, 2) creating the JVM, then 3) executing all registered * client *after* hooks. */ ensureJvm(done: Callback<void>): void; /** * If the JVM has not yet been created, execute the full JVM initialization process, then * call callback function when initialization is complete. If the JVM has been created, just * call the callback. Note that the full initialization process includes: 1) executing all * registered client *before* hooks, 2) creating the JVM, then 3) executing all registered * client *after* hooks. */ ensureJvm(): Promise<void>; /** * Returns true if the JVM has been created. The JVM can only be created once. */ isJvmCreated(): boolean; /** * Creates a new java byte. This is needed because JavaScript does not have the concept of a byte. */ newByte(val: number): JavaObject; /** * Creates a new java short. This is needed because JavaScript does not have the concept of a short. */ newShort(val: number): JavaObject; /** * Creates a new java long. This is needed because JavaScript does not have the concept of a long. */ newLong(val: number): JavaObject; /** * Creates a new java char. This is needed because JavaScript does not have the concept of a char. */ newChar(val: string | number): JavaObject; /** * Creates a new java float. This is needed to force JavaScript's number to a float to call some methods. */ newFloat(val: number): JavaObject; /** * Creates a new java double. This is needed to force JavaScript's number to a double to call some methods. */ newDouble(val: number): JavaObject; /** * Loads the class given by className such that it acts and feels like a JavaScript object. * * @param className The name of the class to create. Separate nested classes * using `'$'` (eg. `com.nearinfinty.MyClass$NestedClass`). * * @example * const Test = java.import('Test'); * Test.someStaticMethodSync(5); * console.log(Test.someStaticField); * * const value1 = Test.NestedEnum.Value1; * * const test = new Test(); * list.instanceMethodSync('item1'); */ import(className: string): JavaObject; /** * Creates an instance of the specified class. If you are using the sync method an exception will * be throw if an error occurs, otherwise it will be the first argument in the callback. * * @param className The name of the class to create. Separate nested classes * using `'$'` (eg. `com.nearinfinty.MyClass$NestedClass`). * @param args Arguments to pass to the constructor, the last argument is a callback function */ newInstance(className: string, ...args: any[]): void; /** * Creates an instance of the specified class. If you are using the sync method an exception will * be throw if an error occurs, otherwise it will be the first argument in the callback. * * @param className The name of the class to create. Separate nested classes * using `'$'` (eg. `com.nearinfinty.MyClass$NestedClass`). * @param args Arguments to pass to the constructor */ newInstanceSync(className: string, ...args: any[]): JavaObject; /** * Creates a new java array of given glass type. To create array of primitive types * like `char`, `byte`, etc, pass the primitive typename * (eg. `java.newArray("char", "hello world\n".split(''))`). * * @param className The name of the type of array elements. Separate nested classes * using `'$'` (eg. `com.nearinfinty.MyClass$NestedClass`). * @param arg A JavaScript array of values to assign to the java array. */ newArray(className: string, arg: any[]): JavaObject; /** * Get the current class loader */ getClassLoader(): JavaObject; /** * Creates a new java Proxy for the given interface. Functions passed in will run on the v8 * main thread and not a new thread. * * The returned object has a method unref() which you can use to free the object for garbage * collection. * * @param interfaceName The name of the interface to proxy. Separate nested classes * using `'$'` (eg. `com.nearinfinty.MyClass$NestedClass`). * @param functions A hash of functions matching the function in the interface. * * @example * const myProxy = java.newProxy('java.lang.Runnable', { * run: function () { * // This is actually run on the v8 thread and not the new java thread * console.log("hello from thread"); * } * }); * * const thread = java.newInstanceSync("java.lang.Thread", myProxy); * thread.start(); */ newProxy(interfaceName: string, functions: ProxyFunctions): JavaObject; /** * Stops the running event loop */ stop(): void; } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |