@Signature public static URLConnection create(String url, @Nullable Proxy proxy) throws IOException { URL _url = new URL(url); URLConnection urlConnection = proxy == null ? _url.openConnection() : _url.openConnection(proxy); urlConnection.setDoOutput(true); urlConnection.setDoInput(true); if (urlConnection instanceof HttpURLConnection) { HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection; httpURLConnection.setRequestMethod("GET"); } return urlConnection; }
@Signature public PHttpServerResponse status(int status, @Nullable String message) throws IOException { response.setStatus(status); if (message != null && !message.isEmpty()) { response.sendError(status, message); } return this; }
@Signature public void unpack(File outputDir, String charset, @Nullable final Invoker callback) throws FileNotFoundException { if (!zipFile.isFile()) { throw new FileNotFoundException(zipFile.getPath() + " not found"); } NameMapper mapper = invokerToNameMapper(callback); if (charset == null || charset.isEmpty()) { ZipUtil.unpack(zipFile, outputDir, mapper); } else { ZipUtil.unpack(zipFile, outputDir, Charset.forName(charset)); } }
@Signature public static Memory get(Environment env, String input, @Nullable String charset) throws Throwable { return get(env, input, charset, "r"); }
@Signature public void setErrorStream(Environment env, @Nullable Stream stream, boolean dontClose) { getWrappedObject().setErrStream(stream == null ? null : Stream.getOutputStream(env, stream), dontClose); } }
@Signature public void __construct(Environment env, OutputStream outputStream, @Nullable @Arg(type = ARRAY) Memory parameters) throws IOException { if (parameters.isNull()) { this.outputStream = new GzipCompressorOutputStream(outputStream); } else { this.outputStream = new GzipCompressorOutputStream( outputStream, parameters.toValue(ArrayMemory.class).toBean(env, GzipParameters.class) ); } } }
@Signature public void onFatalError(@Nullable Invoker invoker) { onFatalError = invoker; } }
@Signature public PHtmlEmail setBounceAddress(@Nullable String email) throws EmailException { htmlEmail.setBounceAddress(email); return this; }
@Signature public void setRequestLogHandler(Environment env, @Nullable Invoker invoker) { if (invoker == null) { server.setRequestLog(null); } else { server.setRequestLog((request, response) -> { invoker.callAny(new PHttpServerRequest(env, request), new PHttpServerResponse(env, response)); }); } }
@Signature public void setOutputStream(Environment env, @Nullable Stream stream, boolean dontClose) { getWrappedObject().setOutputStream(stream == null ? null : Stream.getOutputStream(env, stream), dontClose); } }
@Signature public void setProxy(@Nullable Proxy proxy) { this.proxy = proxy; }
@Setter public void setParent(@Nullable ClassRecord parent) { this.parent = parent; }
@Signature public void setUserInfo(Environment env, @Nullable @Arg(type = ARRAY) Memory ui) { if (ui.isNull()) { getWrappedObject().setUserInfo(null); } else { UserInfoBean userInfo = ui.toValue(ArrayMemory.class).toBean(env, UserInfoBean.class); getWrappedObject().setUserInfo(userInfo); } }
@Signature public static void unwrap(PZipFile zip, File outputDir, @Nullable Invoker callback) throws FileNotFoundException { if (!zip.zipFile.isFile()) { throw new FileNotFoundException(zip.zipFile.getPath() + " not found"); } NameMapper mapper = invokerToNameMapper(callback); ZipUtil.unwrap(zip.zipFile, outputDir, mapper); }
@Signature public static PSqlConnection getConnection(Environment env, String url, @Nullable Properties properties) throws SQLException { return new PSqlConnection(env, DriverManager.getConnection("jdbc:" + url, properties == null ? new Properties() : properties)); } }
@Signature public Integer fuzzyScore(Environment env, Memory query, @Nullable Locale locale) { FuzzyScore cosineDistance = new FuzzyScore(locale != null ? locale : env.getLocale()); return cosineDistance.fuzzyScore(text, query.toString()); } }
@Name("catch") @Signature public WrapPromise _catch(Environment env, @Nullable @Optional("null") Invoker onRejected) throws Exception { return this.then(env, null, onRejected); }
@Signature public PGdxGame on(HandlerType type, @Nullable Invoker invoker) { handlers.put(type, invoker); return this; }
@Signature public static PSqlConnectionPool getPool(Environment env, String url, String driverName, @Nullable Properties properties) throws SQLException { HikariConfig config = new HikariConfig(properties == null ? new Properties() : properties); if (config.getDataSourceClassName() == null) { config.setDataSourceClassName(dataSourceClasses.get(driverName)); } HikariDataSource pool = new HikariDataSource(config); pool.setDriverClassName(_getDriverClass(driverName)); pool.setJdbcUrl("jdbc:" + url); return new PSqlConnectionPool(env, pool); }
@Signature public void __construct(@Nullable InputStream in, String encoding) throws IOException { properties = new Properties(); if (in != null) { load(in, encoding); } }