diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Launcher.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Launcher.java index 175a7adbe..e706e40db 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Launcher.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Launcher.java @@ -151,7 +151,7 @@ public final class Launcher { int flag = 0; try { - minecraftMain.invoke(null, new Object[]{(String[]) cmdList.toArray(new String[cmdList.size()])}); + minecraftMain.invoke(null, new Object[] { (String[]) cmdList.toArray(new String[cmdList.size()]) }); } catch (Throwable throwable) { String trace = StrUtils.getStackTrace(throwable); final String advice = MinecraftCrashAdvicer.getAdvice(trace); @@ -174,15 +174,16 @@ public final class Launcher { } } /* - static Object getShutdownHaltLock() { - try { - Class z = Class.forName("java.lang.Shutdown"); - Field haltLock = z.getDeclaredField("haltLock"); - haltLock.setAccessible(true); - return haltLock.get(null); - } catch (Throwable ex) { - ex.printStackTrace(); - return new Object(); - } - }*/ + * static Object getShutdownHaltLock() { + * try { + * Class z = Class.forName("java.lang.Shutdown"); + * Field haltLock = z.getDeclaredField("haltLock"); + * haltLock.setAccessible(true); + * return haltLock.get(null); + * } catch (Throwable ex) { + * ex.printStackTrace(); + * return new Object(); + * } + * } + */ } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Main.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Main.java index 3fa7a31d2..89f2c5f2b 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Main.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Main.java @@ -76,7 +76,7 @@ public final class Main implements Runnable { try { sslContext = SSLContext.getInstance("TLS"); - X509TrustManager[] xtmArray = new X509TrustManager[]{XTM}; + X509TrustManager[] xtmArray = new X509TrustManager[] { XTM }; sslContext.init(null, xtmArray, new java.security.SecureRandom()); } catch (GeneralSecurityException gse) { } @@ -112,7 +112,7 @@ public final class Main implements Runnable { public static final Main INSTANCE = new Main(); public static HelloMinecraftLookAndFeel LOOK_AND_FEEL; - @SuppressWarnings({"CallToPrintStackTrace", "UseSpecificCatch"}) + @SuppressWarnings({ "CallToPrintStackTrace", "UseSpecificCatch" }) public static void main(String[] args) { { //PluginManager.getServerPlugin(); @@ -147,7 +147,7 @@ public final class Main implements Runnable { Settings.UPDATE_CHECKER.outdated.register(IUpgrader.NOW_UPGRADER); Settings.UPDATE_CHECKER.process(false).subscribeOn(Schedulers.newThread()).subscribe(t - -> Main.invokeUpdate()); + -> Main.invokeUpdate()); if (StrUtils.isNotBlank(Settings.getInstance().getProxyHost()) && StrUtils.isNotBlank(Settings.getInstance().getProxyPort()) && MathUtils.canParseInt(Settings.getInstance().getProxyPort())) { HMCLog.log("Initializing customized proxy"); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/api/IPlugin.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/api/IPlugin.java index 339ab1661..881ffcc2b 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/api/IPlugin.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/api/IPlugin.java @@ -34,6 +34,7 @@ public interface IPlugin { * You can modify the application actions by this method. * * @param profile info to the Minecraft Loader + * * @return For example, you can implement IMinecraftProvider to support * MultiMC */ diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/DefaultGameLauncher.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/DefaultGameLauncher.java index f1a71a3de..cf0210f7f 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/DefaultGameLauncher.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/DefaultGameLauncher.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -18,7 +18,6 @@ package org.jackhuang.hellominecraft.launcher.launch; import java.io.IOException; -import javax.swing.SwingUtilities; import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.launcher.launch.GameLauncher.DownloadLibraryJob; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/GameLauncher.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/GameLauncher.java index 254604cd3..ae7bec0c4 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/GameLauncher.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/GameLauncher.java @@ -111,7 +111,7 @@ public class GameLauncher { return null; } - List lst = null; + List lst; try { lst = loader.makeLaunchingCommand(); } catch (Exception e) { @@ -146,7 +146,7 @@ public class GameLauncher { if (get == null || get.getSelectedMinecraftVersion() == null || StrUtils.isBlank(get.getCanonicalGameDir())) throw new Error("Fucking bug!"); builder.directory(provider.getRunDirectory(get.getSelectedMinecraftVersion().id)) - .environment().put("APPDATA", get.getCanonicalGameDir()); + .environment().put("APPDATA", get.getCanonicalGameDir()); JavaProcess jp = new JavaProcess(str, builder.start(), PROCESS_MANAGER); launchEvent.execute(jp); } catch (Exception e) { @@ -159,7 +159,7 @@ public class GameLauncher { * According to the name... * * @param launcherName the name of launch bat/sh - * @param str launch command + * @param str launch command * * @return launcher location * diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftAssetService.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftAssetService.java index 9e7912df3..d48b559cc 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftAssetService.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftAssetService.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -27,11 +27,11 @@ import org.jackhuang.hellominecraft.tasks.Task; * @author huangyuhui */ public abstract class IMinecraftAssetService extends IMinecraftService { - + public IMinecraftAssetService(Profile profile) { super(profile); } - + public abstract Task downloadAssets(String mcVersion); public abstract File getAssets(); @@ -44,8 +44,8 @@ public abstract class IMinecraftAssetService extends IMinecraftService { * @return Is the action successful? */ public abstract boolean refreshAssetsIndex(String a); - + public abstract boolean downloadMinecraftAssetsIndex(String assetsId); - + public abstract File getAssetObject(String assetVersion, String name) throws IOException; } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftDownloadService.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftDownloadService.java index cb54a8209..3f4072bb1 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftDownloadService.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftDownloadService.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -38,8 +38,6 @@ public abstract class IMinecraftDownloadService extends IMinecraftService { public abstract boolean downloadMinecraftJar(String id); public abstract boolean downloadMinecraftVersionJson(String id); - - /** * Get the libraries that need to download. @@ -56,7 +54,7 @@ public abstract class IMinecraftDownloadService extends IMinecraftService { * @return Is the action successful? */ public abstract boolean install(String version); - + public abstract Observable getRemoteVersions(); - + } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftProvider.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftProvider.java index f03e2cb62..f08577a8c 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftProvider.java @@ -74,6 +74,7 @@ public abstract class IMinecraftProvider { /** * * @param v should be resolved + * * @return libraries of resolved minecraft version v. */ public abstract GameLauncher.DecompressLibraryJob getDecompressLibraries(MinecraftVersion v); @@ -106,7 +107,7 @@ public abstract class IMinecraftProvider { * Rename version * * @param from The old name - * @param to The new name + * @param to The new name * * @return Is the action successful? */ diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftService.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftService.java index c49949c3e..6d7d08f30 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftService.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftService.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -24,10 +24,11 @@ import org.jackhuang.hellominecraft.launcher.settings.Profile; * @author huangyuhui */ public abstract class IMinecraftService { + public Profile profile; public IMinecraftService(Profile profile) { this.profile = profile; } - + } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LibraryDownloadTask.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LibraryDownloadTask.java index f48f1152e..385e42f71 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LibraryDownloadTask.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LibraryDownloadTask.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -76,7 +76,7 @@ public class LibraryDownloadTask extends FileDownloadTask { @SuppressWarnings("UnusedAssignment") public static void unpackLibrary(File output, File input) - throws IOException { + throws IOException { HMCLog.log("Unpacking " + input); if (output.exists()) output.delete(); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/MinecraftCrashAdvicer.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/MinecraftCrashAdvicer.java index fc4c7f87f..13474e81e 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/MinecraftCrashAdvicer.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/MinecraftCrashAdvicer.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/LauncherVisibility.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/LauncherVisibility.java index 146b1a02a..93a9d3eb2 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/LauncherVisibility.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/LauncherVisibility.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/FileNameFilter.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/FileNameFilter.java index 38e953018..25ff55459 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/FileNameFilter.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/FileNameFilter.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/MCUtils.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/MCUtils.java index 654920b7d..797911dfc 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/MCUtils.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/MCUtils.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -33,21 +33,21 @@ public final class MCUtils { String userhome = System.getProperty("user.home", "."); File file; switch (OS.os()) { - case LINUX: + case LINUX: + file = new File(userhome, '.' + baseName + '/'); + break; + case WINDOWS: + String appdata = System.getenv("APPDATA"); + if (appdata != null) + file = new File(appdata, "." + baseName + '/'); + else file = new File(userhome, '.' + baseName + '/'); - break; - case WINDOWS: - String appdata = System.getenv("APPDATA"); - if (appdata != null) - file = new File(appdata, "." + baseName + '/'); - else - file = new File(userhome, '.' + baseName + '/'); - break; - case OSX: - file = new File(userhome, "Library/Application Support/" + baseName); - break; - default: - file = new File(userhome, baseName + '/'); + break; + case OSX: + file = new File(userhome, "Library/Application Support/" + baseName); + break; + default: + file = new File(userhome, baseName + '/'); } return file; } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/ModInfo.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/ModInfo.java index d2aca069c..7376d6d81 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/ModInfo.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/ModInfo.java @@ -112,8 +112,8 @@ public class ModInfo implements Comparable { ModInfo i = new ModInfo(); i.location = f; List m = C.gson.fromJson(new InputStreamReader(jar.getInputStream(entry)), - new TypeToken>() { - }.getType()); + new TypeToken>() { + }.getType()); if (m != null && m.size() > 0) { i = m.get(0); i.location = f; @@ -123,7 +123,7 @@ public class ModInfo implements Comparable { private static ModInfo getLiteLoaderModInfo(File f, ZipFile jar, ZipEntry entry) throws IOException { ModInfo m = C.gson.fromJson(new InputStreamReader(jar.getInputStream(entry)), - ModInfo.class); + ModInfo.class); if (m == null) m = new ModInfo(); m.location = f; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsIndex.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsIndex.java index 3941e3c59..3b57286c0 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsIndex.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsIndex.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsMojangLoader.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsMojangLoader.java index f33168908..5e3ed519a 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsMojangLoader.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsMojangLoader.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsObject.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsObject.java index 154714d1b..4aba42df9 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsObject.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsObject.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,7 +17,6 @@ */ package org.jackhuang.hellominecraft.launcher.utils.assets; - /** * * @author huangyuhui diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/Contents.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/Contents.java index aef06356a..0af70a9f9 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/Contents.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/Contents.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/IAssetsHandler.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/IAssetsHandler.java index 78e045c81..829b3ef3e 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/IAssetsHandler.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/IAssetsHandler.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/AuthenticationException.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/AuthenticationException.java index df877f092..bfc7a5c94 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/AuthenticationException.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/AuthenticationException.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/BestLogin.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/BestLogin.java index 1484b0276..229484564 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/BestLogin.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/BestLogin.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -48,29 +48,29 @@ public final class BestLogin extends IAuthenticator { InputStream is = socket.getInputStream(); int code = is.read(); switch (code) { - case -1: - throw new AuthenticationException("internet error."); - case 200: - throw new AuthenticationException("server restarting."); - case 255: - throw new AuthenticationException("unknown error"); - case 3: - throw new AuthenticationException("unregistered."); - case 50: - throw new AuthenticationException("please update your launcher and act your account."); - case 2: - throw new AuthenticationException("wrong password."); - case 100: - throw new AuthenticationException("server reloading."); - case 0: - byte[] b = new byte[64]; - is.read(b, 0, b.length); - String[] ss = new String(b).split(":"); - lr.setUserName(info.username); - lr.setUserId(ss[1]); - lr.setSession(ss[0]); - lr.setAccessToken(ss[0]); - break; + case -1: + throw new AuthenticationException("internet error."); + case 200: + throw new AuthenticationException("server restarting."); + case 255: + throw new AuthenticationException("unknown error"); + case 3: + throw new AuthenticationException("unregistered."); + case 50: + throw new AuthenticationException("please update your launcher and act your account."); + case 2: + throw new AuthenticationException("wrong password."); + case 100: + throw new AuthenticationException("server reloading."); + case 0: + byte[] b = new byte[64]; + is.read(b, 0, b.length); + String[] ss = new String(b).split(":"); + lr.setUserName(info.username); + lr.setUserId(ss[1]); + lr.setSession(ss[0]); + lr.setAccessToken(ss[0]); + break; } lr.setUserType("Legacy"); return lr; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/IAuthenticator.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/IAuthenticator.java index 9125cc145..711b7e663 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/IAuthenticator.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/IAuthenticator.java @@ -46,6 +46,7 @@ public abstract class IAuthenticator { * @param info username & password * * @return login result + * * @throws * org.jackhuang.hellominecraft.launcher.utils.auth.AuthenticationException */ diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/LoginInfo.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/LoginInfo.java index b0ab32b64..382fd1338 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/LoginInfo.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/LoginInfo.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/YggdrasilAuthenticator.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/YggdrasilAuthenticator.java index 47dafd4f9..650a8c61d 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/YggdrasilAuthenticator.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/YggdrasilAuthenticator.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/AuthenticationRequest.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/AuthenticationRequest.java index 2acddfb2b..fcb7a169e 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/AuthenticationRequest.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/AuthenticationRequest.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/GameProfile.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/GameProfile.java index ca77e32fa..b0ee6a97b 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/GameProfile.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/GameProfile.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/Property.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/Property.java index 2e5648e9f..ac75f87fa 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/Property.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/Property.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/PropertyMap.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/PropertyMap.java index d3c0fd75d..bf1b98d51 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/PropertyMap.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/PropertyMap.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -96,7 +96,7 @@ public class PropertyMap extends HashMap { } public static class LegacySerializer - implements JsonSerializer { + implements JsonSerializer { @Override public JsonElement serialize(PropertyMap src, Type typeOfSrc, JsonSerializationContext context) { diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/RefreshRequest.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/RefreshRequest.java index c436d19a5..69cc78a63 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/RefreshRequest.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/RefreshRequest.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/Response.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/Response.java index a06c7cab2..b505cba28 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/Response.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/Response.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/UUIDTypeAdapter.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/UUIDTypeAdapter.java index 5ae76ace0..269952f1c 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/UUIDTypeAdapter.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/UUIDTypeAdapter.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/User.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/User.java index 613c30bb4..524ae98ff 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/User.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/User.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/YggdrasilAuthentication.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/YggdrasilAuthentication.java index 08fea5681..ed5d5b91a 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/YggdrasilAuthentication.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/yggdrasil/YggdrasilAuthentication.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -36,9 +36,9 @@ import org.jackhuang.hellominecraft.utils.StrUtils; public class YggdrasilAuthentication { public static final Gson GSON = new GsonBuilder() - .registerTypeAdapter(GameProfile.class, new GameProfile.GameProfileSerializer()) - .registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()) - .registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create(); + .registerTypeAdapter(GameProfile.class, new GameProfile.GameProfileSerializer()) + .registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()) + .registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create(); protected static final String BASE_URL = "https://authserver.mojang.com/"; protected static final URL ROUTE_AUTHENTICATE = NetUtils.constantURL(BASE_URL + "authenticate"); @@ -134,7 +134,7 @@ public class YggdrasilAuthentication { else throw new AuthenticationException(C.i18n("login.invalid_password")); } - + private void loggedIn(URL url, Object input) throws AuthenticationException { try { String jsonResult = input == null ? NetUtils.get(url) : NetUtils.post(url, GSON.toJson(input), "application/json", proxy); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/BMCLAPIDownloadProvider.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/BMCLAPIDownloadProvider.java index fb0c82270..8fdaaea6c 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/BMCLAPIDownloadProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/BMCLAPIDownloadProvider.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/DownloadType.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/DownloadType.java index 80b3a349d..e6248e97f 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/DownloadType.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/DownloadType.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/IDownloadProvider.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/IDownloadProvider.java index 5ef4dd53b..b37e83637 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/IDownloadProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/IDownloadProvider.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -27,7 +27,7 @@ import org.jackhuang.hellominecraft.launcher.utils.installers.InstallerVersionLi public abstract class IDownloadProvider { public InstallerVersionList getInstallerByType(InstallerType type) { - switch(type) { + switch (type) { case Forge: return getForgeInstaller(); case LiteLoader: @@ -38,7 +38,7 @@ public abstract class IDownloadProvider { return null; } } - + public abstract InstallerVersionList getForgeInstaller(); public abstract InstallerVersionList getLiteLoaderInstaller(); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/MojangDownloadProvider.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/MojangDownloadProvider.java index 1099a0294..929b18cb4 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/MojangDownloadProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/MojangDownloadProvider.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/RapidDataDownloadProvider.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/RapidDataDownloadProvider.java index 8759beafa..703be72ed 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/RapidDataDownloadProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/download/RapidDataDownloadProvider.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallProfile.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallProfile.java index c75e66232..35442cbb6 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallProfile.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallProfile.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerService.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerService.java index a4829301c..dfb59b3b6 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerService.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerService.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -42,17 +42,17 @@ public final class InstallerService { public InstallerService(Profile p) { this.p = p; } - + public Task download(InstallerVersion v, InstallerType type) { - switch(type) { - case Forge: - return downloadForge(v); - case Optifine: - return downloadOptifine(v); - case LiteLoader: - return downloadLiteLoader(v); - default: - return null; + switch (type) { + case Forge: + return downloadForge(v); + case Optifine: + return downloadOptifine(v); + case LiteLoader: + return downloadLiteLoader(v); + default: + return null; } } @@ -63,9 +63,9 @@ public final class InstallerService { File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "forge-installer.jar"); if (v.installer != null) TaskWindow.getInstance() - .addTask(new FileDownloadTask(p.getDownloadType().getProvider().getParsedLibraryDownloadURL(v.installer), filepath).setTag("forge")) - .addTask(new ForgeInstaller(p.getMinecraftProvider(), filepath, v)) - .start(); + .addTask(new FileDownloadTask(p.getDownloadType().getProvider().getParsedLibraryDownloadURL(v.installer), filepath).setTag("forge")) + .addTask(new ForgeInstaller(p.getMinecraftProvider(), filepath, v)) + .start(); } }; } @@ -78,9 +78,9 @@ public final class InstallerService { if (v.installer != null) { OptiFineDownloadFormatter task = new OptiFineDownloadFormatter(v.installer); TaskWindow.getInstance().addTask(task) - .addTask(new FileDownloadTask(filepath).registerPreviousResult(task).setTag("optifine")) - .addTask(new OptiFineInstaller(p, v.selfVersion, filepath)) - .start(); + .addTask(new FileDownloadTask(filepath).registerPreviousResult(task).setTag("optifine")) + .addTask(new OptiFineInstaller(p, v.selfVersion, filepath)) + .start(); } } }; @@ -93,8 +93,8 @@ public final class InstallerService { File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "liteloader-universal.jar"); FileDownloadTask task = (FileDownloadTask) new FileDownloadTask(v.universal, filepath).setTag("LiteLoader"); TaskWindow.getInstance() - .addTask(task).addTask(new LiteLoaderInstaller(p, (LiteLoaderVersionList.LiteLoaderInstallerVersion) v).registerPreviousResult(task)) - .start(); + .addTask(task).addTask(new LiteLoaderInstaller(p, (LiteLoaderVersionList.LiteLoaderInstallerVersion) v).registerPreviousResult(task)) + .start(); } }; } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerType.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerType.java index 346b7231a..86fee9215 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerType.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerType.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -23,14 +23,13 @@ package org.jackhuang.hellominecraft.launcher.utils.installers; */ public enum InstallerType { Forge("forge"), Optifine("optifine"), LiteLoader("liteloader"); - + public final String id; private InstallerType(String id) { this.id = id; } - - + public String getLocalizedName() { return this.name(); } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerVersionList.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerVersionList.java index 232d743a9..dbf577749 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerVersionList.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerVersionList.java @@ -48,6 +48,7 @@ public abstract class InstallerVersionList implements Consumer { * Get installers you want. * * @param mcVersion the installers to this Minecraft version. + * * @return cached result. */ protected abstract List getVersionsImpl(String mcVersion); @@ -56,8 +57,9 @@ public abstract class InstallerVersionList implements Consumer { * Get installers you want, please cache this method's result to save time. * * @param mcVersion the installers to this Minecraft version. + * * @return a copy of the cached data to prevent - * ConcurrentModificationException. + * ConcurrentModificationException. */ public List getVersions(String mcVersion) { List a = getVersionsImpl(mcVersion); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerVersionNewerComparator.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerVersionNewerComparator.java index 3eb4c207b..bff779099 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerVersionNewerComparator.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/InstallerVersionNewerComparator.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/PackMinecraftInstaller.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/PackMinecraftInstaller.java index 0cf50d6db..e2225afd6 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/PackMinecraftInstaller.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/PackMinecraftInstaller.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/ForgeInstaller.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/ForgeInstaller.java index f79f4b471..450b8cbcd 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/ForgeInstaller.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/ForgeInstaller.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -76,9 +76,11 @@ public class ForgeInstaller extends Task { FileUtils.copyFile(new File(from, profile.install.minecraft + ".jar"), new File(to, profile.install.target + ".jar")); HMCLog.log("Creating new version profile..." + profile.install.target + ".json"); - /*for (MinecraftLibrary library : profile.versionInfo.libraries) - if (library.name.startsWith("net.minecraftforge:forge:")) - library.url = installerVersion.universal;*/ + /* + * for (MinecraftLibrary library : profile.versionInfo.libraries) + * if (library.name.startsWith("net.minecraftforge:forge:")) + * library.url = installerVersion.universal; + */ FileUtils.write(new File(to, profile.install.target + ".json"), C.gsonPrettyPrinting.toJson(profile.versionInfo)); HMCLog.log("Extracting universal forge pack..." + profile.install.filePath); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/ForgeOldInstaller.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/ForgeOldInstaller.java index 3ddc8ac8d..a33985cbb 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/ForgeOldInstaller.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/ForgeOldInstaller.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/Install.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/Install.java index 26d43d05b..6ee59ea46 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/Install.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/Install.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersion.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersion.java index 0c9897323..4c8924256 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersion.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersion.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersionList.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersionList.java index ee5b3bc94..954fdb95c 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersionList.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersionList.java @@ -72,15 +72,15 @@ public class MinecraftForgeVersionList extends InstallerVersionList { String filename = root.artifact + "-" + ver + "-" + f[1] + "." + f[0]; String url = Settings.getInstance().getDownloadSource().getProvider().getParsedLibraryDownloadURL(root.webpath + ver + "/" + filename); switch (f[1]) { - case "installer": - iv.installer = url; - break; - case "universal": - iv.universal = url; - break; - case "changelog": - iv.changelog = url; - break; + case "installer": + iv.installer = url; + break; + case "universal": + iv.universal = url; + break; + case "changelog": + iv.changelog = url; + break; } } if (StrUtils.isBlank(iv.installer) || StrUtils.isBlank(iv.universal)) diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersionRoot.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersionRoot.java index 47e24242f..023cb9893 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersionRoot.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/MinecraftForgeVersionRoot.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderInstaller.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderInstaller.java index beeaf52c6..71ce79a86 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderInstaller.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderInstaller.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderMCVersions.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderMCVersions.java index 0d3e98254..c7d8a3793 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderMCVersions.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderMCVersions.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersion.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersion.java index 50254960f..b996385f5 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersion.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersion.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionsMeta.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionsMeta.java index 089994243..5b4b90b00 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionsMeta.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionsMeta.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionsRoot.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionsRoot.java index 07874eced..d05a89dea 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionsRoot.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionsRoot.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/OptiFineInstaller.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/OptiFineInstaller.java index f483d8b45..cd98d20a9 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/OptiFineInstaller.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/OptiFineInstaller.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/OptiFineVersion.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/OptiFineVersion.java index 11e24ff5c..ec2fcdfe5 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/OptiFineVersion.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/OptiFineVersion.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/bmcl/OptiFineBMCLVersionList.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/bmcl/OptiFineBMCLVersionList.java index 04aac2ddf..5c08dcd19 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/bmcl/OptiFineBMCLVersionList.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/bmcl/OptiFineBMCLVersionList.java @@ -60,7 +60,7 @@ public class OptiFineBMCLVersionList extends InstallerVersionList { if (s == null) return; root = C.gson.fromJson(s, new TypeToken>() { - }.getType()); + }.getType()); for (OptiFineVersion v : root) { v.mirror = v.mirror.replace("http://optifine.net/http://optifine.net/", "http://optifine.net/"); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/vanilla/OptiFineDownloadFormatter.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/vanilla/OptiFineDownloadFormatter.java index edfc8dc2e..d0aafe9ad 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/vanilla/OptiFineDownloadFormatter.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/vanilla/OptiFineDownloadFormatter.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/AppDataUpgrader.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/AppDataUpgrader.java index 40b0cd76d..c0180536e 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/AppDataUpgrader.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/AppDataUpgrader.java @@ -74,9 +74,9 @@ public class AppDataUpgrader extends IUpgrader { if (mainClass != null) { ArrayList al = new ArrayList<>(Arrays.asList(args)); al.add("notfound"); - new URLClassLoader(new URL[] {jar.toURI().toURL()}, + new URLClassLoader(new URL[] { jar.toURI().toURL() }, URLClassLoader.getSystemClassLoader().getParent()).loadClass(mainClass) - .getMethod("main", String[].class).invoke(null, new Object[] {al.toArray(new String[0])}); + .getMethod("main", String[].class).invoke(null, new Object[] { al.toArray(new String[0]) }); return true; } } @@ -95,7 +95,7 @@ public class AppDataUpgrader extends IUpgrader { if (map != null && map.containsKey("pack")) try { if (TaskWindow.getInstance().addTask(new AppDataUpgraderTask(map.get("pack"), number.version)).start()) { - new ProcessBuilder(new String[] {IOUtils.getJavaDir(), "-jar", AppDataUpgraderTask.getSelf(number.version).getAbsolutePath()}).directory(new File(".")).start(); + new ProcessBuilder(new String[] { IOUtils.getJavaDir(), "-jar", AppDataUpgraderTask.getSelf(number.version).getAbsolutePath() }).directory(new File(".")).start(); System.exit(0); } } catch (IOException ex) { diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/IUpgrader.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/IUpgrader.java index dd3f325af..e722e261e 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/IUpgrader.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/IUpgrader.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -27,7 +27,7 @@ import org.jackhuang.hellominecraft.utils.VersionNumber; * @author huangyuhui */ public abstract class IUpgrader implements Event { - + public static final IUpgrader NOW_UPGRADER = new AppDataUpgrader(); /** @@ -35,6 +35,7 @@ public abstract class IUpgrader implements Event { * * @param nowVersion now launcher version * @param args Application CommandLine Arguments + * * @return true if it is needed to break the main thread to shutdown this * application. */ @@ -45,6 +46,7 @@ public abstract class IUpgrader implements Event { * * @param sender Should be VersionChecker * @param number the newest version + * * @return should return true */ @Override diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/NewFileUpgrader.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/NewFileUpgrader.java index 170e70b29..dd5592f7e 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/NewFileUpgrader.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/NewFileUpgrader.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -52,7 +52,7 @@ public class NewFileUpgrader extends IUpgrader { File newf = new File(FileUtils.getName(str)); if (TaskWindow.getInstance().addTask(new FileDownloadTask(str, newf)).start()) { try { - new ProcessBuilder(new String[] {IOUtils.tryGetCanonicalFilePath(newf), "--removeOldLauncher", IOUtils.getRealPath()}).directory(new File(".")).start(); + new ProcessBuilder(new String[] { IOUtils.tryGetCanonicalFilePath(newf), "--removeOldLauncher", IOUtils.getRealPath() }).directory(new File(".")).start(); } catch (IOException ex) { HMCLog.err("Failed to start new app", ex); } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Extract.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Extract.java index 3475cfb5b..b49c3043a 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Extract.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Extract.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/GameDirType.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/GameDirType.java index be73a029b..f78a52b92 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/GameDirType.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/GameDirType.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/IMinecraftLibrary.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/IMinecraftLibrary.java index 1fe30ba88..a01e2ff58 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/IMinecraftLibrary.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/IMinecraftLibrary.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftAssetService.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftAssetService.java index ddaf2154c..f674359fd 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftAssetService.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftAssetService.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftClassicVersion.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftClassicVersion.java index 60c3c4c58..64512719f 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftClassicVersion.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftClassicVersion.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftDownloadService.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftDownloadService.java index 03ed9df06..e013ccb1a 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftDownloadService.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftDownloadService.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -40,6 +40,7 @@ import rx.Observable; * @author huangyuhui */ public class MinecraftDownloadService extends IMinecraftDownloadService { + MinecraftVersionManager mgr; public MinecraftDownloadService(Profile p, MinecraftVersionManager mgr) { diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftLibrary.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftLibrary.java index ee22985bd..c1a55c498 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftLibrary.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftLibrary.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftOldLibrary.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftOldLibrary.java index 59ccb3c99..8961691fd 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftOldLibrary.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftOldLibrary.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftVersion.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftVersion.java index 98d9eabb5..c7e96e9f6 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftVersion.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftVersion.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -33,7 +33,7 @@ import org.jackhuang.hellominecraft.utils.ArrayUtils; public class MinecraftVersion implements Cloneable, Comparable { public String minecraftArguments, mainClass, time, id, type, processArguments, - releaseTime, assets, jar, inheritsFrom; + releaseTime, assets, jar, inheritsFrom; public int minimumLauncherVersion; public boolean hidden; @@ -88,13 +88,13 @@ public class MinecraftVersion implements Cloneable, Comparable } parent = parent.resolve(manager, resolvedSoFar); MinecraftVersion result = new MinecraftVersion( - this.minecraftArguments != null ? this.minecraftArguments : parent.minecraftArguments, - this.mainClass != null ? this.mainClass : parent.mainClass, - this.time, this.id, this.type, parent.processArguments, this.releaseTime, - this.assets != null ? this.assets : parent.assets, - this.jar != null ? this.jar : parent.jar, - null, parent.minimumLauncherVersion, - this.libraries != null ? ArrayUtils.merge(this.libraries, parent.libraries) : parent.libraries, this.hidden); + this.minecraftArguments != null ? this.minecraftArguments : parent.minecraftArguments, + this.mainClass != null ? this.mainClass : parent.mainClass, + this.time, this.id, this.type, parent.processArguments, this.releaseTime, + this.assets != null ? this.assets : parent.assets, + this.jar != null ? this.jar : parent.jar, + null, parent.minimumLauncherVersion, + this.libraries != null ? ArrayUtils.merge(this.libraries, parent.libraries) : parent.libraries, this.hidden); return result; } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftVersionManager.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftVersionManager.java index f70a6cf9f..117621b44 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftVersionManager.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftVersionManager.java @@ -273,10 +273,10 @@ public class MinecraftVersionManager extends IMinecraftProvider { for (MinecraftVersion s : getVersions()) { FileUtils.deleteDirectoryQuietly(new File(profile.getGameDirFile(), "versions" + File.separator + s.id + File.separator + s.id + "-natives")); File f = getRunDirectory(s.id); - String[] dir = {"logs", "asm", "NVIDIA", "crash-reports", "server-resource-packs", "natives", "native"}; + String[] dir = { "logs", "asm", "NVIDIA", "crash-reports", "server-resource-packs", "natives", "native" }; for (String str : dir) FileUtils.deleteDirectoryQuietly(new File(f, str)); - String[] files = {"output-client.log", "usercache.json", "usernamecache.json", "hmclmc.log"}; + String[] files = { "output-client.log", "usercache.json", "usernamecache.json", "hmclmc.log" }; for (String str : files) new File(f, str).delete(); } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Natives.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Natives.java index 445225fc2..e9b1cc166 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Natives.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Natives.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/OS.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/OS.java index 4ecea0e41..5c0f5ca5e 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/OS.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/OS.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Rules.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Rules.java index a70aeeeb7..8561d27ad 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Rules.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/Rules.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/DraggableFrame.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/DraggableFrame.java index 9dc90661b..ac22179e3 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/DraggableFrame.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/DraggableFrame.java @@ -27,7 +27,7 @@ import javax.swing.JFrame; * @author huangyuhui */ public class DraggableFrame extends JFrame - implements MouseListener, MouseMotionListener { + implements MouseListener, MouseMotionListener { private int dragGripX; private int dragGripY; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameDownloadPanel.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameDownloadPanel.java index 9d965db30..5b0645144 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameDownloadPanel.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameDownloadPanel.java @@ -42,10 +42,9 @@ public class GameDownloadPanel extends AnimatedPanel implements Selectable { } /** - * This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents @@ -110,8 +109,8 @@ public class GameDownloadPanel extends AnimatedPanel implements Selectable { DefaultTableModel model = SwingUtils.clearDefaultTable(lstDownloads); gsp.getProfile().getMinecraftProvider().getDownloadService().getRemoteVersions() .observeOn(Schedulers.eventQueue()).subscribeOn(Schedulers.newThread()) - .subscribe((ver) -> model.addRow(new Object[] {ver.id, ver.time, - StrUtils.equalsOne(ver.type, "old_beta", "old_alpha", "release", "snapshot") ? C.i18n("versions." + ver.type) : ver.type}), + .subscribe((ver) -> model.addRow(new Object[] { ver.id, ver.time, + StrUtils.equalsOne(ver.type, "old_beta", "old_alpha", "release", "snapshot") ? C.i18n("versions." + ver.type) : ver.type }), (e) -> { MessageBox.Show("Failed to refresh download: " + e.getLocalizedMessage()); HMCLog.err("Failed to refresh download.", e); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameSettingsPanel.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameSettingsPanel.java index b8a43a3ce..e5eb363a1 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameSettingsPanel.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameSettingsPanel.java @@ -1247,13 +1247,13 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget reloadingMods = true; DefaultTableModel model = SwingUtils.clearDefaultTable(lstExternalMods); Observable.>createWithEmptySubscription( - t -> t.onNext(getProfile().getMinecraftProvider().getModService().recacheMods())) - .subscribeOn(Schedulers.newThread()).observeOn(Schedulers.eventQueue()) - .subscribe(t -> { - for (ModInfo x : t) - model.addRow(new Object[]{x.isActive(), x, x.version}); - reloadingMods = false; - }); + t -> t.onNext(getProfile().getMinecraftProvider().getModService().recacheMods())) + .subscribeOn(Schedulers.newThread()).observeOn(Schedulers.eventQueue()) + .subscribe(t -> { + for (ModInfo x : t) + model.addRow(new Object[] { x.isActive(), x, x.version }); + reloadingMods = false; + }); } // diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/HeaderTab.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/HeaderTab.java index 90d82247a..92c21f2ad 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/HeaderTab.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/HeaderTab.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -30,7 +30,7 @@ import javax.swing.JLabel; * @author huangyuhui */ public class HeaderTab extends JLabel -implements MouseListener { + implements MouseListener { private boolean isActive; private final DefaultButtonModel model; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/InstallerPanel.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/InstallerPanel.java index a2abddf88..1faa6b321 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/InstallerPanel.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/InstallerPanel.java @@ -43,7 +43,7 @@ public class InstallerPanel extends AnimatedPanel implements Selectable { /** * Creates new form InstallerPanel * - * @param gsp To get the minecraft version + * @param gsp To get the minecraft version * @param installerType load which installer */ public InstallerPanel(GameSettingsPanel gsp, InstallerType installerType) { @@ -124,7 +124,7 @@ public class InstallerPanel extends AnimatedPanel implements Selectable { void refreshVersions() { if (TaskWindow.getInstance().addTask(new TaskRunnableArg1<>(C.i18n("install." + id.id + ".get_list"), list) - .registerPreviousResult(new DefaultPreviousResult<>(new String[]{gsp.getMinecraftVersionFormatted()}))) + .registerPreviousResult(new DefaultPreviousResult<>(new String[] { gsp.getMinecraftVersionFormatted() }))) .start()) loadVersions(); } @@ -152,7 +152,7 @@ public class InstallerPanel extends AnimatedPanel implements Selectable { if (versions != null) for (InstallerVersionList.InstallerVersion v : versions) if (v != null) - model.addRow(new Object[]{v.selfVersion == null ? "null" : v.selfVersion, v.mcVersion == null ? "null" : v.mcVersion}); + model.addRow(new Object[] { v.selfVersion == null ? "null" : v.selfVersion, v.mcVersion == null ? "null" : v.mcVersion }); } }); } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/LauncherSettingsPanel.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/LauncherSettingsPanel.java index cd3ed499e..8b57212c8 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/LauncherSettingsPanel.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/LauncherSettingsPanel.java @@ -43,7 +43,7 @@ public class LauncherSettingsPanel extends AnimatedPanel { initComponents(); Observable.from(DownloadType.values()).map(t -> t.getName()).toList() - .subscribe(t -> cboDownloadSource.setModel(new DefaultComboBoxModel(t.toArray(new String[0])))); + .subscribe(t -> cboDownloadSource.setModel(new DefaultComboBoxModel(t.toArray(new String[0])))); txtBackgroundPath.setText(Settings.getInstance().getBgpath()); txtProxyHost.setText(Settings.getInstance().getProxyHost()); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/MainFrame.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/MainFrame.java index 5c981ac38..ca82f9e48 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/MainFrame.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/MainFrame.java @@ -438,7 +438,7 @@ public final class MainFrame extends DraggableFrame { int contentWidth = width - off - off; int contentHeight = height - off - off; BufferedImage contentImage = new BufferedImage(contentWidth, - contentHeight, Transparency.OPAQUE); + contentHeight, Transparency.OPAQUE); Graphics2D contentG2d = contentImage.createGraphics(); contentG2d.translate(-off, -off); paintImpl(g); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/ServerListCellRenderer.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/ServerListCellRenderer.java index 870676ecf..89e751044 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/ServerListCellRenderer.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/ServerListCellRenderer.java @@ -39,10 +39,9 @@ public class ServerListCellRenderer extends javax.swing.JPanel implements ListCe } /** - * This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/ServerListView.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/ServerListView.java index cca2edd10..fbbf38016 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/ServerListView.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/ServerListView.java @@ -57,10 +57,9 @@ public class ServerListView extends javax.swing.JDialog { public static final int FAILED_TO_SELECT = -1; /** - * This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/C.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/C.java index 714c7da07..c9c9a0a6d 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/C.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/C.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/HMCLog.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/HMCLog.java index 670edc10a..89169e2da 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/HMCLog.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/HMCLog.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/AppenderControl.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/AppenderControl.java index 074ff6545..ebaccdcc5 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/AppenderControl.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/AppenderControl.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/Level.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/Level.java index fd26bbe51..3938d61e0 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/Level.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/Level.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LogEvent.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LogEvent.java index 0a2d8d54c..e75460ff0 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LogEvent.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LogEvent.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LoggingException.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LoggingException.java index 1433e8e36..afe165f80 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LoggingException.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LoggingException.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/AbstractAppender.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/AbstractAppender.java index 1c2913164..a7ee28ed7 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/AbstractAppender.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/AbstractAppender.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/ConsoleAppender.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/ConsoleAppender.java index c73f11cb7..a39f7ef18 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/ConsoleAppender.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/ConsoleAppender.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -50,7 +50,7 @@ public class ConsoleAppender extends OutputStreamAppender { @Override public void write(byte[] b, int off, int len) - throws IOException { + throws IOException { System.out.write(b, off, len); } @@ -78,7 +78,7 @@ public class ConsoleAppender extends OutputStreamAppender { @Override public void write(byte[] b, int off, int len) - throws IOException { + throws IOException { System.err.write(b, off, len); } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/IAppender.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/IAppender.java index 1cfd9f0e3..e1bedad53 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/IAppender.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/IAppender.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/OutputStreamAppender.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/OutputStreamAppender.java index d441d9fb0..13330d760 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/OutputStreamAppender.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/appender/OutputStreamAppender.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/AbstractStringLayout.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/AbstractStringLayout.java index f61a37f38..11c7d40ed 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/AbstractStringLayout.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/AbstractStringLayout.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/ILayout.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/ILayout.java index 0e59162f2..f880f7e8a 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/ILayout.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/ILayout.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/ILogger.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/ILogger.java index 75e6952d9..e2182712f 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/ILogger.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/ILogger.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/AbstractMessageFactory.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/AbstractMessageFactory.java index b6b1446d3..c921691ae 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/AbstractMessageFactory.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/AbstractMessageFactory.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -22,7 +22,7 @@ package org.jackhuang.hellominecraft.logging.message; * @author huangyuhui */ public abstract class AbstractMessageFactory -implements IMessageFactory { + implements IMessageFactory { @Override public IMessage newMessage(Object message) { diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/IMessage.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/IMessage.java index 66f77859b..ba86dc1c8 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/IMessage.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/IMessage.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/IMessageFactory.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/IMessageFactory.java index 30ef0d10d..da19f2ea4 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/IMessageFactory.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/IMessageFactory.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ObjectMessage.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ObjectMessage.java index f12d1f5e3..5a7a9eaec 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ObjectMessage.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ObjectMessage.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -18,7 +18,7 @@ package org.jackhuang.hellominecraft.logging.message; public class ObjectMessage -implements IMessage { + implements IMessage { private static final long serialVersionUID = -5903272448334166185L; private final transient Object obj; @@ -41,7 +41,7 @@ implements IMessage { @Override public Object[] getParameters() { - return new Object[] {this.obj}; + return new Object[] { this.obj }; } @Override diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ParameterizedMessage.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ParameterizedMessage.java index 336e1cb4d..6a431dfd1 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ParameterizedMessage.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ParameterizedMessage.java @@ -68,11 +68,11 @@ public class ParameterizedMessage } public ParameterizedMessage(String messagePattern, Object arg) { - this(messagePattern, new Object[] {arg}); + this(messagePattern, new Object[] { arg }); } public ParameterizedMessage(String messagePattern, Object arg1, Object arg2) { - this(messagePattern, new Object[] {arg1, arg2}); + this(messagePattern, new Object[] { arg1, arg2 }); } private String[] parseArguments(Object[] arguments) { diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ParameterizedMessageFactory.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ParameterizedMessageFactory.java index 719d5e2c9..c6c699e57 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ParameterizedMessageFactory.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ParameterizedMessageFactory.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/SimpleMessage.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/SimpleMessage.java index 061074950..ec6f01a4a 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/SimpleMessage.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/SimpleMessage.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -22,7 +22,7 @@ package org.jackhuang.hellominecraft.logging.message; * @author huangyuhui */ public class SimpleMessage -implements IMessage { + implements IMessage { private static final long serialVersionUID = -8398002534962715992L; private final String message; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/StringFormattedMessage.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/StringFormattedMessage.java index 58ec309d4..1a376c55e 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/StringFormattedMessage.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/StringFormattedMessage.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.IllegalFormatException; public class StringFormattedMessage -implements IMessage { + implements IMessage { private static final long serialVersionUID = -665975803997290697L; private final String messagePattern; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DecompressTask.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DecompressTask.java index e35ac0ea7..4415680dd 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DecompressTask.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DecompressTask.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -25,7 +25,7 @@ import org.jackhuang.hellominecraft.utils.system.Compressor; * @author huangyuhui */ public class DecompressTask extends Task { - + File src, dest; public DecompressTask(File src, File dest) { @@ -42,5 +42,5 @@ public class DecompressTask extends Task { public String getInfo() { return "Decompress: " + src.getAbsolutePath() + " to " + dest.getAbsolutePath(); } - + } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DoingDoneListener.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DoingDoneListener.java index 8fc04d94f..9e03fe388 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DoingDoneListener.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DoingDoneListener.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DoubleTask.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DoubleTask.java index ab0717a43..0b6f49c3d 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DoubleTask.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DoubleTask.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -22,22 +22,23 @@ package org.jackhuang.hellominecraft.tasks; * @author huangyuhui */ public class DoubleTask extends Task { - + Task a, b; public DoubleTask(Task a, Task b) { this.a = a; this.b = b; } - + @Override public void executeTask() throws Throwable { - a.executeTask(); b.executeTask(); + a.executeTask(); + b.executeTask(); } @Override public String getInfo() { return "Double Task"; } - + } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ParallelTask.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ParallelTask.java index 312d14c89..aea47944d 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ParallelTask.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ParallelTask.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ProgressProviderListener.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ProgressProviderListener.java index c9492de86..2d3c4f981 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ProgressProviderListener.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ProgressProviderListener.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/Task.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/Task.java index 52160532e..58aa788ad 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/Task.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/Task.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -101,19 +101,19 @@ public abstract class Task { ppl = p; return this; } - + public Task after(Task t) { return new DoubleTask(this, t); } - + public Task before(Task t) { return new DoubleTask(t, this); } - + public void run() { try { executeTask(); - } catch(Throwable t) { + } catch (Throwable t) { HMCLog.err("Failed to execute task", t); } } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskInfo.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskInfo.java index 341eb497b..1a4e2e019 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskInfo.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskInfo.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskObservable.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskObservable.java index d7c07d8cf..0a53c6c9c 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskObservable.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskObservable.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -38,7 +38,8 @@ public class TaskObservable extends TaskInfo { @Override public void executeTask() { - r.subscribe(t->{}); + r.subscribe(t -> { + }); } } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnable.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnable.java index 1b0b31fed..b20b9a893 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnable.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnable.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnableArg1.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnableArg1.java index 286c94f38..3dedd1eb9 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnableArg1.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnableArg1.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/DefaultPreviousResult.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/DefaultPreviousResult.java index 03711a39e..ee6fe3790 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/DefaultPreviousResult.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/DefaultPreviousResult.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/PreviousResult.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/PreviousResult.java index 36447180f..eb0b02ae5 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/PreviousResult.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/PreviousResult.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/PreviousResultRegistrar.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/PreviousResultRegistrar.java index f11588f2a..8310bd6e6 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/PreviousResultRegistrar.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/communication/PreviousResultRegistrar.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/ContentGetAndShowTask.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/ContentGetAndShowTask.java index 2a79e685d..84439c4cb 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/ContentGetAndShowTask.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/ContentGetAndShowTask.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/DownloadListener.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/DownloadListener.java index a2c7834e4..d23b66b28 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/DownloadListener.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/DownloadListener.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/FileDownloadTask.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/FileDownloadTask.java index ecd3e7542..43aef7fe7 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/FileDownloadTask.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/FileDownloadTask.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -113,15 +113,13 @@ public class FileDownloadTask extends Task implements PreviousResult, Prev connection.connect(); // Make sure response code is in the 200 range. - if (connection.getResponseCode() / 100 != 2) { + if (connection.getResponseCode() / 100 != 2) throw new NetException(C.i18n("download.not_200") + " " + connection.getResponseCode()); - } // Check for valid content length. int contentLength = connection.getContentLength(); - if (contentLength < 1) { + if (contentLength < 1) throw new NetException("The content length is invalid."); - } filePath.getParentFile().mkdirs(); @@ -179,7 +177,8 @@ public class FileDownloadTask extends Task implements PreviousResult, Prev closeFiles(); } } - if (failReason != null) throw failReason; + if (failReason != null) + throw failReason; } public static void download(String url, String file, DownloadListener dl) throws Throwable { diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/HTTPGetTask.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/HTTPGetTask.java index 2aa74b9cd..89d06a570 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/HTTPGetTask.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/HTTPGetTask.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -76,7 +76,8 @@ public class HTTPGetTask extends TaskInfo implements PreviousResult { t = new NetException("Failed to get " + url, ex); } } - if (t != null) throw t; + if (t != null) + throw t; } @Override diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/NetException.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/NetException.java index 30ec3d31c..8e8848166 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/NetException.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/download/NetException.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/CollectionUtils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/CollectionUtils.java index 5e9c0dfb2..bb183a7a5 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/CollectionUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/CollectionUtils.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/DoubleOutputStream.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/DoubleOutputStream.java index fd5639ff2..07e728e5f 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/DoubleOutputStream.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/DoubleOutputStream.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Event.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Event.java index 46b6bf61e..e66decd4c 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Event.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Event.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/IUpdateChecker.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/IUpdateChecker.java index 02cc8e526..750abe432 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/IUpdateChecker.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/IUpdateChecker.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -27,29 +27,36 @@ import rx.Observable; public interface IUpdateChecker { /** - * + * */ void checkOutdate(); /** - * Get the cached newest version number, use "process" method to download! + * Get the cached newest version number, use "process" method to + * download! + * * @return the newest version number + * * @see process */ VersionNumber getNewVersion(); /** - * Download the version number synchronously. - * When you execute this method first, should leave "showMessage" false. - * @param showMessage If it is requested to warn the user that there is a new version. + * Download the version number synchronously. When you execute this method + * first, should leave "showMessage" false. + * + * @param showMessage If it is requested to warn the user that there is a + * new version. + * * @return the process observable. */ Observable process(boolean showMessage); /** * Get the download links. + * * @return a JSON, which contains the server response. */ Observable> requestDownloadLink(); - + } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/LauncherPrintStream.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/LauncherPrintStream.java index b9ee35dab..87e77a8b6 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/LauncherPrintStream.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/LauncherPrintStream.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/MathUtils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/MathUtils.java index 7f274bfd3..0323075a7 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/MathUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/MathUtils.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/NetUtils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/NetUtils.java index a12768c92..66d4cc803 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/NetUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/NetUtils.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -52,8 +52,9 @@ public final class NetUtils { } public static String getStreamContent(InputStream is, String encoding) - throws IOException { - if (is == null) return null; + throws IOException { + if (is == null) + return null; StringBuilder sb = new StringBuilder(); try (InputStreamReader br = new InputStreamReader(is, encoding)) { int len; @@ -136,7 +137,7 @@ public final class NetUtils { con.disconnect(); return result; } - + private static final String DEFAULT_CHARSET = "UTF-8"; public static URL constantURL(String url) { @@ -157,12 +158,12 @@ public final class NetUtils { throw new IllegalArgumentException("Could not concatenate given URL with GET arguments!", ex); } } - + public static Observable getRx(String url) { return Observable.createWithEmptySubscription(t1 -> { try { t1.onNext(get(url)); - } catch(Exception e) { + } catch (Exception e) { t1.onError(e); } }); diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Pair.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Pair.java index d7371ddc2..74268482a 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Pair.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Pair.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/StrUtils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/StrUtils.java index 9a7080440..3a2a687ac 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/StrUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/StrUtils.java @@ -54,10 +54,14 @@ public final class StrUtils { cmdbuf.append("\\"); cmdbuf.append('"'); } else if (s.endsWith("\"")) - /* The argument has already been quoted. */ + /* + * The argument has already been quoted. + */ cmdbuf.append(s); else - /* Unmatched quote for the argument. */ + /* + * Unmatched quote for the argument. + */ throw new IllegalArgumentException(); else cmdbuf.append(s); diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/VersionNumber.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/VersionNumber.java index 2e26fe110..304ae4a2a 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/VersionNumber.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/VersionNumber.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Base64.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Base64.java index dcf959f92..e2cbe5226 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Base64.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Base64.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -87,7 +87,7 @@ public class Base64 { return out; } private static final char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" - .toCharArray(); + .toCharArray(); private static final byte[] codes = new byte[256]; static { diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Charsets.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Charsets.java index 08ac8c999..0694f1583 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Charsets.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Charsets.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/DigestUtils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/DigestUtils.java index a8f3b58fa..38231ef75 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/DigestUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/DigestUtils.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -31,7 +31,7 @@ public class DigestUtils { private static final int STREAM_BUFFER_LENGTH = 1024; private static byte[] digest(MessageDigest digest, InputStream data) - throws IOException { + throws IOException { return updateDigest(digest, data).digest(); } @@ -77,7 +77,7 @@ public class DigestUtils { } public static byte[] md2(InputStream data) - throws IOException { + throws IOException { return digest(getMd2Digest(), data); } @@ -90,7 +90,7 @@ public class DigestUtils { } public static String md2Hex(InputStream data) - throws IOException { + throws IOException { return Hex.encodeHexString(md2(data)); } @@ -103,7 +103,7 @@ public class DigestUtils { } public static byte[] md5(InputStream data) - throws IOException { + throws IOException { return digest(getMd5Digest(), data); } @@ -116,7 +116,7 @@ public class DigestUtils { } public static String md5Hex(InputStream data) - throws IOException { + throws IOException { return Hex.encodeHexString(md5(data)); } @@ -131,7 +131,7 @@ public class DigestUtils { @Deprecated public static byte[] sha(InputStream data) - throws IOException { + throws IOException { return sha1(data); } @@ -145,7 +145,7 @@ public class DigestUtils { } public static byte[] sha1(InputStream data) - throws IOException { + throws IOException { return digest(getSha1Digest(), data); } @@ -158,7 +158,7 @@ public class DigestUtils { } public static String sha1Hex(InputStream data) - throws IOException { + throws IOException { return Hex.encodeHexString(sha1(data)); } @@ -171,7 +171,7 @@ public class DigestUtils { } public static byte[] sha256(InputStream data) - throws IOException { + throws IOException { return digest(getSha256Digest(), data); } @@ -184,7 +184,7 @@ public class DigestUtils { } public static String sha256Hex(InputStream data) - throws IOException { + throws IOException { return Hex.encodeHexString(sha256(data)); } @@ -197,7 +197,7 @@ public class DigestUtils { } public static byte[] sha384(InputStream data) - throws IOException { + throws IOException { return digest(getSha384Digest(), data); } @@ -210,7 +210,7 @@ public class DigestUtils { } public static String sha384Hex(InputStream data) - throws IOException { + throws IOException { return Hex.encodeHexString(sha384(data)); } @@ -223,7 +223,7 @@ public class DigestUtils { } public static byte[] sha512(InputStream data) - throws IOException { + throws IOException { return digest(getSha512Digest(), data); } @@ -236,7 +236,7 @@ public class DigestUtils { } public static String sha512Hex(InputStream data) - throws IOException { + throws IOException { return Hex.encodeHexString(sha512(data)); } @@ -251,7 +251,7 @@ public class DigestUtils { @Deprecated public static String shaHex(InputStream data) - throws IOException { + throws IOException { return sha1Hex(data); } @@ -266,7 +266,7 @@ public class DigestUtils { } public static MessageDigest updateDigest(MessageDigest digest, InputStream data) - throws IOException { + throws IOException { byte[] buffer = new byte[STREAM_BUFFER_LENGTH]; int read = data.read(buffer, 0, STREAM_BUFFER_LENGTH); diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Hex.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Hex.java index c06577ad2..24e9f6a99 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Hex.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/code/Hex.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -23,9 +23,9 @@ public class Hex { public static final Charset DEFAULT_CHARSET = Charsets.UTF_8; public static final String DEFAULT_CHARSET_NAME = "UTF-8"; - private static final char[] DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + private static final char[] DIGITS_LOWER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - private static final char[] DIGITS_UPPER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + private static final char[] DIGITS_UPPER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; private final Charset charset; public static byte[] decodeHex(char[] data) throws Exception { @@ -109,7 +109,7 @@ public class Hex { } public Object encode(Object object) - throws Exception { + throws Exception { try { byte[] byteArray = (object instanceof String) ? ((String) object).getBytes(getCharset()) : (byte[]) (byte[]) object; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/BiConsumer.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/BiConsumer.java index e04298187..4f0ba4b1a 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/BiConsumer.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/BiConsumer.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/BiFunction.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/BiFunction.java index 7db06c3b5..52be871be 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/BiFunction.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/BiFunction.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Consumer.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Consumer.java index a014b4f22..b11705dd9 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Consumer.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Consumer.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Function.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Function.java index dc5e21415..5de19613d 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Function.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Function.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/NonFunction.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/NonFunction.java index af9810754..d36f0fb66 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/NonFunction.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/NonFunction.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Predicate.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Predicate.java index f9dc1bfe4..5171f9ac0 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Predicate.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/Predicate.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/TriConsumer.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/TriConsumer.java index a5e7f9c9c..00c4fa2e5 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/TriConsumer.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/TriConsumer.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Compressor.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Compressor.java index 928334edc..082cc1f16 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Compressor.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Compressor.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -79,7 +79,7 @@ public class Compressor { files = new File[1]; files[0] = source; } - String pathName;//存相对路径(相对于待压缩的根目录) + String pathName;//存相对路径(相对于待压缩的根目录) byte[] buf = new byte[1024]; int length; for (File file : files) diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/FileUtils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/FileUtils.java index 0bb561e19..e26576c18 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/FileUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/FileUtils.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -37,7 +37,7 @@ import org.jackhuang.hellominecraft.utils.NetUtils; public class FileUtils { public static void deleteDirectory(File directory) - throws IOException { + throws IOException { if (!directory.exists()) return; @@ -72,7 +72,7 @@ public class FileUtils { } public static void cleanDirectory(File directory) - throws IOException { + throws IOException { if (!directory.exists()) { //String message = directory + " does not exist"; //throw new IllegalArgumentException(message); @@ -102,7 +102,7 @@ public class FileUtils { } public static void forceDelete(File file) - throws IOException { + throws IOException { if (file.isDirectory()) deleteDirectory(file); else { @@ -118,7 +118,7 @@ public class FileUtils { } public static boolean isSymlink(File file) - throws IOException { + throws IOException { if (file == null) throw new NullPointerException("File must not be null"); if (File.separatorChar == '\\') @@ -135,22 +135,22 @@ public class FileUtils { } public static void copyDirectory(File srcDir, File destDir) - throws IOException { + throws IOException { copyDirectory(srcDir, destDir, true); } public static void copyDirectory(File srcDir, File destDir, boolean preserveFileDate) - throws IOException { + throws IOException { copyDirectory(srcDir, destDir, null, preserveFileDate); } public static void copyDirectory(File srcDir, File destDir, FileFilter filter) - throws IOException { + throws IOException { copyDirectory(srcDir, destDir, filter, true); } public static void copyDirectory(File srcDir, File destDir, FileFilter filter, boolean preserveFileDate) - throws IOException { + throws IOException { if (srcDir == null) throw new NullPointerException("Source must not be null"); if (destDir == null) @@ -177,7 +177,7 @@ public class FileUtils { } private static void doCopyDirectory(File srcDir, File destDir, FileFilter filter, boolean preserveFileDate, List exclusionList) - throws IOException { + throws IOException { File[] srcFiles = filter == null ? srcDir.listFiles() : srcDir.listFiles(filter); if (srcFiles == null) throw new IOException("Failed to list contents of " + srcDir); @@ -204,7 +204,7 @@ public class FileUtils { } public static String readFileToString(File file) - throws IOException { + throws IOException { return NetUtils.getStreamContent(IOUtils.openInputStream(file)); } @@ -218,7 +218,7 @@ public class FileUtils { } public static String readFileToString(File file, String charset) - throws IOException { + throws IOException { return NetUtils.getStreamContent(IOUtils.openInputStream(file), charset); } @@ -239,12 +239,12 @@ public class FileUtils { } public static void copyFile(File srcFile, File destFile) - throws IOException { + throws IOException { copyFile(srcFile, destFile, true); } public static void copyFile(File srcFile, File destFile, boolean preserveFileDate) - throws IOException { + throws IOException { if (srcFile == null) throw new NullPointerException("Source must not be null"); if (destFile == null) @@ -266,7 +266,7 @@ public class FileUtils { } private static void doCopyFile(File srcFile, File destFile, boolean preserveFileDate) - throws IOException { + throws IOException { if ((destFile.exists()) && (destFile.isDirectory())) throw new IOException("Destination '" + destFile + "' exists but is a directory"); @@ -356,38 +356,38 @@ public class FileUtils { } public static void write(File file, CharSequence data) - throws IOException { + throws IOException { write(file, data, "UTF-8", false); } public static void write(File file, CharSequence data, boolean append) - throws IOException { + throws IOException { write(file, data, "UTF-8", append); } public static void write(File file, CharSequence data, String encoding) - throws IOException { + throws IOException { write(file, data, encoding, false); } public static void write(File file, CharSequence data, String encoding, boolean append) - throws IOException { + throws IOException { String str = data == null ? null : data.toString(); writeStringToFile(file, str, encoding, append); } public static void writeStringToFile(File file, String data) - throws IOException { + throws IOException { writeStringToFile(file, data, "UTF-8", false); } public static void writeStringToFile(File file, String data, String encoding) - throws IOException { + throws IOException { writeStringToFile(file, data, encoding, false); } public static void writeStringToFile(File file, String data, String encoding, boolean append) - throws IOException { + throws IOException { OutputStream out = null; try { out = openOutputStream(file, append); @@ -399,7 +399,7 @@ public class FileUtils { } public static FileInputStream openInputStream(File file) - throws IOException { + throws IOException { if (file.exists()) { if (file.isDirectory()) throw new IOException("File '" + file + "' exists but is a directory"); @@ -411,12 +411,12 @@ public class FileUtils { } public static FileOutputStream openOutputStream(File file) - throws IOException { + throws IOException { return openOutputStream(file, false); } public static FileOutputStream openOutputStream(File file, boolean append) - throws IOException { + throws IOException { if (file.exists()) { if (file.isDirectory()) throw new IOException("File '" + file + "' exists but is a directory"); diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/IOUtils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/IOUtils.java index 896d09c37..5a4e96667 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/IOUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/IOUtils.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Java.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Java.java index e80166c09..be7fe1524 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Java.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Java.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -72,9 +72,9 @@ public class Java { } /* - ----------------------------------- - MAC OS X - ----------------------------------- + * ----------------------------------- + * MAC OS X + * ----------------------------------- */ public static List queryAllJDKInMac() { List ans = new ArrayList<>(); @@ -88,9 +88,9 @@ public class Java { } /* - ----------------------------------- - WINDOWS - ----------------------------------- + * ----------------------------------- + * WINDOWS + * ----------------------------------- */ public static List queryAllJavaHomeInWindowsByReg() { List ans = new ArrayList<>(); @@ -126,7 +126,7 @@ public class Java { } private static List queryRegSubFolders(String location) throws IOException, InterruptedException { - String[] cmd = new String[] {"cmd", "/c", "reg", "query", location}; + String[] cmd = new String[] { "cmd", "/c", "reg", "query", location }; List l = IOUtils.readProcessByInputStream(cmd); List ans = new ArrayList<>(); for (String line : l) @@ -136,7 +136,7 @@ public class Java { } private static String queryRegValue(String location, String name) throws IOException, InterruptedException { - String[] cmd = new String[] {"cmd", "/c", "reg", "query", location, "/v", name}; + String[] cmd = new String[] { "cmd", "/c", "reg", "query", location, "/v", name }; List l = IOUtils.readProcessByInputStream(cmd); boolean last = false; for (String s : l) { diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JavaProcess.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JavaProcess.java index d01c9fae7..c3ba36bc7 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JavaProcess.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JavaProcess.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JdkVersion.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JdkVersion.java index 7c578ea29..e7c4e99f7 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JdkVersion.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JdkVersion.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -166,7 +166,7 @@ public final class JdkVersion { private static final Pattern p = Pattern.compile("java version \"[1-9]*\\.[1-9]*\\.[0-9]*(.*?)\""); public static JdkVersion getJavaVersionFromExecutable(String file) throws IOException { - String[] str = new String[] {file, "-version"}; + String[] str = new String[] { file, "-version" }; Platform platform = Platform.BIT_32; String ver = null; try { diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Platform.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Platform.java index ab7075f69..081544a8f 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Platform.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/Platform.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ProcessManager.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ProcessManager.java index bdab99b68..3c0c4e12f 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ProcessManager.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ProcessManager.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ProcessThread.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ProcessThread.java index a3831e065..8f4086a7b 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ProcessThread.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ProcessThread.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ThreadExecutor.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ThreadExecutor.java index da4ca7ca2..5ff32e78f 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ThreadExecutor.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/ThreadExecutor.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteLatestVersion.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteLatestVersion.java index b0f5e16e7..dcd17cd66 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteLatestVersion.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteLatestVersion.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersion.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersion.java index 601c3efe0..4a71b2774 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersion.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersion.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersions.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersions.java index a830287a6..068aca81b 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersions.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersions.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftVersionRequest.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftVersionRequest.java index f98b6bc65..519bf6886 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftVersionRequest.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftVersionRequest.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -32,37 +32,37 @@ import org.jackhuang.hellominecraft.utils.NetUtils; public class MinecraftVersionRequest { public static final int UNKOWN = 0, INVALID = 1, INVALID_JAR = 2, - MODIFIED = 3, OK = 4, NOT_FOUND = 5, UNREADABLE = 6, NOT_FILE = 7; + MODIFIED = 3, OK = 4, NOT_FOUND = 5, UNREADABLE = 6, NOT_FILE = 7; public int type; public String version; public static String getResponse(MinecraftVersionRequest minecraftVersion) { String text = ""; switch (minecraftVersion.type) { - case MinecraftVersionRequest.INVALID: - text = C.i18n("minecraft.invalid"); - break; - case MinecraftVersionRequest.INVALID_JAR: - text = C.i18n("minecraft.invalid_jar"); - break; - case MinecraftVersionRequest.NOT_FILE: - text = C.i18n("minecraft.not_a_file"); - break; - case MinecraftVersionRequest.NOT_FOUND: - text = C.i18n("minecraft.not_found"); - break; - case MinecraftVersionRequest.UNREADABLE: - text = C.i18n("minecraft.not_readable"); - break; - case MinecraftVersionRequest.MODIFIED: - text = C.i18n("minecraft.modified") + " "; - case MinecraftVersionRequest.OK: - text += minecraftVersion.version; - break; - case MinecraftVersionRequest.UNKOWN: - default: - text = "???"; - break; + case MinecraftVersionRequest.INVALID: + text = C.i18n("minecraft.invalid"); + break; + case MinecraftVersionRequest.INVALID_JAR: + text = C.i18n("minecraft.invalid_jar"); + break; + case MinecraftVersionRequest.NOT_FILE: + text = C.i18n("minecraft.not_a_file"); + break; + case MinecraftVersionRequest.NOT_FOUND: + text = C.i18n("minecraft.not_found"); + break; + case MinecraftVersionRequest.UNREADABLE: + text = C.i18n("minecraft.not_readable"); + break; + case MinecraftVersionRequest.MODIFIED: + text = C.i18n("minecraft.modified") + " "; + case MinecraftVersionRequest.OK: + text += minecraftVersion.version; + break; + case MinecraftVersionRequest.UNKOWN: + default: + text = "???"; + break; } return text; } @@ -167,7 +167,7 @@ public class MinecraftVersionRequest { try { localZipFile = new ZipFile(file); ZipEntry minecraft = localZipFile - .getEntry("net/minecraft/client/Minecraft.class"); + .getEntry("net/minecraft/client/Minecraft.class"); if (minecraft != null) return getVersionOfOldMinecraft(localZipFile, minecraft); ZipEntry main = localZipFile.getEntry("net/minecraft/client/main/Main.class"); diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/AbstractFilter.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/AbstractFilter.java index b66d2c5cd..815f27e2d 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/AbstractFilter.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/AbstractFilter.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -28,7 +28,7 @@ import java.awt.image.Raster; import java.awt.image.WritableRaster; public abstract class AbstractFilter -implements BufferedImageOp { + implements BufferedImageOp { @Override public abstract BufferedImage filter(BufferedImage paramBufferedImage1, BufferedImage paramBufferedImage2); diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/BasicColors.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/BasicColors.java index aedce9ec9..553366406 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/BasicColors.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/BasicColors.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -27,9 +27,9 @@ public class BasicColors { private static Color getWebColor(String c) { return new Color( - Integer.parseInt(c.substring(0, 2), 16), - Integer.parseInt(c.substring(2, 4), 16), - Integer.parseInt(c.substring(4, 6), 16) + Integer.parseInt(c.substring(0, 2), 16), + Integer.parseInt(c.substring(2, 4), 16), + Integer.parseInt(c.substring(4, 6), 16) ); } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/DropShadowBorder.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/DropShadowBorder.java index 7f63a18fe..83c0affd5 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/DropShadowBorder.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/DropShadowBorder.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -68,7 +68,7 @@ public class DropShadowBorder extends AbstractBorder { @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Pair pair = new Pair<>(width, height); - if (CACHE.containsKey(pair)) + if (CACHE.containsKey(pair)) g.drawImage(CACHE.get(pair), x, y, width, height, null); else { BufferedImage shadow = new BufferedImage(width, height, 2); diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/FastBlurFilter.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/FastBlurFilter.java index ac8a740db..d756d537a 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/FastBlurFilter.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/FastBlurFilter.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/LogWindowOutputStream.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/LogWindowOutputStream.java index d7f2dd552..46acd92c9 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/LogWindowOutputStream.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/LogWindowOutputStream.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -33,31 +33,32 @@ public class LogWindowOutputStream extends OutputStream { private final LogWindow txt; private final Level sas; + /* - private final CacheTask t = new CacheTask(); - private class CacheTask extends TimerTask { - private final Object lock = new Object(); - private StringBuilder cachedString = new StringBuilder(); - - @Override - public void run() { - synchronized(lock) { - SwingUtilities.invokeLater(() -> { - String t = txt.getText() + cachedString.toString().replace("\t", " "); - txt.setText(t); - txt.setCaretPosition(t.length()); - cachedString = new StringBuilder(); - }); - } - } - - void cache(String s) { - synchronized(lock) { - cachedString.append(s); - } - } - }*/ - + * private final CacheTask t = new CacheTask(); + * private class CacheTask extends TimerTask { + * private final Object lock = new Object(); + * private StringBuilder cachedString = new StringBuilder(); + * + * @Override + * public void run() { + * synchronized(lock) { + * SwingUtilities.invokeLater(() -> { + * String t = txt.getText() + cachedString.toString().replace("\t", " "); + * txt.setText(t); + * txt.setCaretPosition(t.length()); + * cachedString = new StringBuilder(); + * }); + * } + * } + * + * void cache(String s) { + * synchronized(lock) { + * cachedString.append(s); + * } + * } + * } + */ public LogWindowOutputStream(LogWindow logWindow, Level l) { txt = logWindow; this.sas = l; @@ -85,7 +86,7 @@ public class LogWindowOutputStream extends OutputStream { @Override public final void write(int paramInt) { - append(new String(new byte[] {(byte) paramInt})); + append(new String(new byte[] { (byte) paramInt })); } public static void dispose() { diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/SwingUtils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/SwingUtils.java index c85f6aabd..ddd435597 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/SwingUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/SwingUtils.java @@ -50,15 +50,15 @@ public class SwingUtils { * Make DefaultTableModel by overriding getColumnClass and isCellEditable of * DefaultTableModel. * - * @param titleA The title of each column. - * @param typesA The type of each column value. + * @param titleA The title of each column. + * @param typesA The type of each column value. * @param canEditA Is column editable? * * @return */ public static DefaultTableModel makeDefaultTableModel(String[] titleA, final Class[] typesA, final boolean[] canEditA) { return new DefaultTableModel( - new Object[][]{}, + new Object[][] {}, titleA) { Class[] types = typesA; boolean[] canEdit = canEditA; @@ -81,7 +81,7 @@ public class SwingUtils { switch (OS.os()) { case OSX: try { - Runtime.getRuntime().exec(new String[]{"/usr/bin/open", path}); + Runtime.getRuntime().exec(new String[] { "/usr/bin/open", path }); } catch (IOException ex) { HMCLog.err("Failed to open " + path + " through /usr/bin/open", ex); } @@ -108,7 +108,7 @@ public class SwingUtils { } catch (Throwable e) { if (OS.os() == OS.OSX) try { - Runtime.getRuntime().exec(new String[]{"/usr/bin/open", link}); + Runtime.getRuntime().exec(new String[] { "/usr/bin/open", link }); } catch (IOException ex) { HMCLog.warn("Failed to open link: " + link, ex); } @@ -150,7 +150,7 @@ public class SwingUtils { /** * Append new element to JList * - * @param list the JList + * @param list the JList * @param element the Element */ public static void appendLast(JList list, Object element) { diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/TintablePanel.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/TintablePanel.java index 06e058df1..a82e20367 100755 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/TintablePanel.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/TintablePanel.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/BCJCoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/BCJCoder.java index add250f4a..22042db95 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/BCJCoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/BCJCoder.java @@ -21,14 +21,17 @@ abstract class BCJCoder implements FilterCoder { return filterID >= 0x04 && filterID <= 0x09; } + @Override public boolean changesSize() { return false; } + @Override public boolean nonLastOK() { return true; } + @Override public boolean lastOK() { return false; } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/BCJDecoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/BCJDecoder.java index 4ed315720..8a1938987 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/BCJDecoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/BCJDecoder.java @@ -17,27 +17,32 @@ class BCJDecoder extends BCJCoder implements FilterDecoder { private final int startOffset; BCJDecoder(long filterID, byte[] props) - throws UnsupportedOptionsException { + throws UnsupportedOptionsException { assert isBCJFilterID(filterID); this.filterID = filterID; - if (props.length == 0) + switch (props.length) { + case 0: startOffset = 0; - else if (props.length == 4) { + break; + case 4: int n = 0; for (int i = 0; i < 4; ++i) n |= (props[i] & 0xFF) << (i * 8); - startOffset = n; - } else + break; + default: throw new UnsupportedOptionsException( - "Unsupported BCJ filter properties"); + "Unsupported BCJ filter properties"); + } } + @Override public int getMemoryUsage() { return SimpleInputStream.getMemoryUsage(); } + @Override public InputStream getInputStream(InputStream in) { SimpleFilter simpleFilter = null; diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/BCJOptions.java b/HMCLAPI/src/main/java/org/tukaani/xz/BCJOptions.java index b69539306..d09d87b2f 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/BCJOptions.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/BCJOptions.java @@ -18,15 +18,15 @@ abstract class BCJOptions extends FilterOptions { } /** - * Sets the start offset for the address conversions. - * Normally this is useless so you shouldn't use this function. - * The default value is 0. + * Sets the start offset for the address conversions. Normally this is + * useless so you shouldn't use this function. The default value is + * 0. */ public void setStartOffset(int startOffset) - throws UnsupportedOptionsException { + throws UnsupportedOptionsException { if ((startOffset & (alignment - 1)) != 0) throw new UnsupportedOptionsException( - "Start offset must be a multiple of " + alignment); + "Start offset must be a multiple of " + alignment); this.startOffset = startOffset; } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/BlockInputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/BlockInputStream.java index 838b8a7e5..8d597817f 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/BlockInputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/BlockInputStream.java @@ -35,7 +35,7 @@ class BlockInputStream extends InputStream { public BlockInputStream(InputStream in, Check check, int memoryLimit, long unpaddedSizeInIndex, long uncompressedSizeInIndex) - throws IOException, IndexIndicatorException { + throws IOException, IndexIndicatorException { this.check = check; inData = new DataInputStream(in); @@ -59,7 +59,7 @@ class BlockInputStream extends InputStream { // Check for reserved bits in Block Flags. if ((buf[1] & 0x3C) != 0) throw new UnsupportedOptionsException( - "Unsupported options in XZ Block Header"); + "Unsupported options in XZ Block Header"); // Memory for the Filter Flags field int filterCount = (buf[1] & 0x03) + 1; @@ -69,7 +69,7 @@ class BlockInputStream extends InputStream { // Use a stream to parse the fields after the Block Flags field. // Exclude the CRC32 field at the end. ByteArrayInputStream bufStream = new ByteArrayInputStream( - buf, 2, headerSize - 6); + buf, 2, headerSize - 6); try { // Set the maximum valid compressed size. This is overriden @@ -114,7 +114,7 @@ class BlockInputStream extends InputStream { for (int i = bufStream.available(); i > 0; --i) if (bufStream.read() != 0x00) throw new UnsupportedOptionsException( - "Unsupported options in XZ Block Header"); + "Unsupported options in XZ Block Header"); // Validate the Blcok Header against the Index when doing // random access reading. @@ -125,7 +125,7 @@ class BlockInputStream extends InputStream { int headerAndCheckSize = headerSize + check.getSize(); if (headerAndCheckSize >= unpaddedSizeInIndex) throw new CorruptedInputException( - "XZ Index does not match a Block Header"); + "XZ Index does not match a Block Header"); // The compressed size calculated from Unpadded Size must // match the value stored in the Compressed Size field in @@ -136,7 +136,7 @@ class BlockInputStream extends InputStream { || (compressedSizeInHeader != -1 && compressedSizeInHeader != compressedSizeFromIndex)) throw new CorruptedInputException( - "XZ Index does not match a Block Header"); + "XZ Index does not match a Block Header"); // The uncompressed size stored in the Index must match // the value stored in the Uncompressed Size field in @@ -144,7 +144,7 @@ class BlockInputStream extends InputStream { if (uncompressedSizeInHeader != -1 && uncompressedSizeInHeader != uncompressedSizeInIndex) throw new CorruptedInputException( - "XZ Index does not match a Block Header"); + "XZ Index does not match a Block Header"); // For further validation, pretend that the values from the Index // were stored in the Block Header. @@ -170,7 +170,7 @@ class BlockInputStream extends InputStream { else throw new UnsupportedOptionsException( - "Unknown Filter ID " + filterIDs[i]); + "Unknown Filter ID " + filterIDs[i]); RawCoder.validate(filters); diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/CorruptedInputException.java b/HMCLAPI/src/main/java/org/tukaani/xz/CorruptedInputException.java index 677d821da..c135a43f5 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/CorruptedInputException.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/CorruptedInputException.java @@ -9,25 +9,25 @@ package org.tukaani.xz; /** - * Thrown when the compressed input data is corrupt. - * However, it is possible that some or all of the data - * already read from the input stream was corrupt too. + * Thrown when the compressed input data is corrupt. However, it is possible + * that some or all of the data already read from the input stream was corrupt + * too. */ public class CorruptedInputException extends XZIOException { private static final long serialVersionUID = 3L; /** - * Creates a new CorruptedInputException with - * the default error detail message. + * Creates a new CorruptedInputException with the default error detail + * message. */ public CorruptedInputException() { super("Compressed data is corrupt"); } /** - * Creates a new CorruptedInputException with - * the specified error detail message. + * Creates a new CorruptedInputException with the specified error detail + * message. * * @param s error detail message */ diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/DeltaDecoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/DeltaDecoder.java index c58670c39..a2b389041 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/DeltaDecoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/DeltaDecoder.java @@ -17,15 +17,17 @@ class DeltaDecoder extends DeltaCoder implements FilterDecoder { DeltaDecoder(byte[] props) throws UnsupportedOptionsException { if (props.length != 1) throw new UnsupportedOptionsException( - "Unsupported Delta filter properties"); + "Unsupported Delta filter properties"); distance = (props[0] & 0xFF) + 1; } + @Override public int getMemoryUsage() { return 1; } + @Override public InputStream getInputStream(InputStream in) { return new DeltaInputStream(in, distance); } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/DeltaInputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/DeltaInputStream.java index 7db621053..85e29de9c 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/DeltaInputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/DeltaInputStream.java @@ -15,9 +15,9 @@ import org.tukaani.xz.delta.DeltaDecoder; /** * Decodes raw Delta-filtered data (no XZ headers). *

- * The delta filter doesn't change the size of the data and thus it - * cannot have an end-of-payload marker. It will simply decode until - * its input stream indicates end of input. + * The delta filter doesn't change the size of the data and thus it cannot have + * an end-of-payload marker. It will simply decode until its input stream + * indicates end of input. */ public class DeltaInputStream extends InputStream { @@ -41,12 +41,10 @@ public class DeltaInputStream extends InputStream { /** * Creates a new Delta decoder with the given delta calculation distance. * - * @param in input stream from which Delta filtered data - * is read + * @param in input stream from which Delta filtered data is read * - * @param distance delta calculation distance, must be in the - * range [DISTANCE_MIN, - * DISTANCE_MAX] + * @param distance delta calculation distance, must be in the range + * [DISTANCE_MIN, DISTANCE_MAX] */ public DeltaInputStream(InputStream in, int distance) { // Check for null because otherwise null isn't detect @@ -61,11 +59,12 @@ public class DeltaInputStream extends InputStream { /** * Decode the next byte from this input stream. * - * @return the next decoded byte, or -1 to indicate - * the end of input on the input stream in + * @return the next decoded byte, or -1 to indicate the end of + * input on the input stream in * * @throws IOException may be thrown by in */ + @Override public int read() throws IOException { return read(tempBuf, 0, 1) == -1 ? -1 : (tempBuf[0] & 0xFF); } @@ -73,21 +72,22 @@ public class DeltaInputStream extends InputStream { /** * Decode into an array of bytes. *

- * This calls in.read(buf, off, len) and defilters the - * returned data. + * This calls in.read(buf, off, len) and defilters the returned + * data. * * @param buf target buffer for decoded data * @param off start offset in buf * @param len maximum number of bytes to read * - * @return number of bytes read, or -1 to indicate - * the end of the input stream in + * @return number of bytes read, or -1 to indicate the end of + * the input stream in * * @throws XZIOException if the stream has been closed * - * @throws IOException may be thrown by underlaying input - * stream in + * @throws IOException may be thrown by underlaying input stream + * in */ + @Override public int read(byte[] buf, int off, int len) throws IOException { if (len == 0) return 0; @@ -118,6 +118,7 @@ public class DeltaInputStream extends InputStream { * * @return the value returned by in.available() */ + @Override public int available() throws IOException { if (in == null) throw new XZIOException("Stream closed"); @@ -129,11 +130,12 @@ public class DeltaInputStream extends InputStream { } /** - * Closes the stream and calls in.close(). - * If the stream was already closed, this does nothing. + * Closes the stream and calls in.close(). If the stream was + * already closed, this does nothing. * * @throws IOException if thrown by in.close() */ + @Override public void close() throws IOException { if (in != null) try { diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/DeltaOptions.java b/HMCLAPI/src/main/java/org/tukaani/xz/DeltaOptions.java index 28693499c..0f67905ca 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/DeltaOptions.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/DeltaOptions.java @@ -11,19 +11,19 @@ package org.tukaani.xz; import java.io.InputStream; /** - * Delta filter options. The Delta filter can be used only as a non-last - * filter in the chain, for example Delta + LZMA2. + * Delta filter options. The Delta filter can be used only as a non-last filter + * in the chain, for example Delta + LZMA2. *

- * Currently only simple byte-wise delta is supported. The only option - * is the delta distance, which you should set to match your data. - * It's not possible to provide a generic default value for it. + * Currently only simple byte-wise delta is supported. The only option is the + * delta distance, which you should set to match your data. It's not possible to + * provide a generic default value for it. *

- * For example, with distance = 2 and eight-byte input - * A1 B1 A2 B3 A3 B5 A4 B7, the output will be A1 B1 01 02 01 02 01 02. + * For example, with distance = 2 and eight-byte input A1 B1 A2 B3 A3 B5 A4 B7, + * the output will be A1 B1 01 02 01 02 01 02. *

- * The Delta filter can be good with uncompressed bitmap images. It can - * also help with PCM audio, although special-purpose compressors like - * FLAC will give much smaller result at much better compression speed. + * The Delta filter can be good with uncompressed bitmap images. It can also + * help with PCM audio, although special-purpose compressors like FLAC will give + * much smaller result at much better compression speed. */ public class DeltaOptions extends FilterOptions { @@ -53,14 +53,14 @@ public class DeltaOptions extends FilterOptions { } /** - * Sets the delta distance in bytes. The new distance must be in - * the range [DISTANCE_MIN, DISTANCE_MAX]. + * Sets the delta distance in bytes. The new distance must be in the range + * [DISTANCE_MIN, DISTANCE_MAX]. */ public void setDistance(int distance) throws UnsupportedOptionsException { if (distance < DISTANCE_MIN || distance > DISTANCE_MAX) throw new UnsupportedOptionsException( - "Delta distance must be in the range [" + DISTANCE_MIN - + ", " + DISTANCE_MAX + "]: " + distance); + "Delta distance must be in the range [" + DISTANCE_MIN + + ", " + DISTANCE_MAX + "]: " + distance); this.distance = distance; } @@ -72,26 +72,32 @@ public class DeltaOptions extends FilterOptions { return distance; } + @Override public int getEncoderMemoryUsage() { return DeltaOutputStream.getMemoryUsage(); } + @Override public FinishableOutputStream getOutputStream(FinishableOutputStream out) { return new DeltaOutputStream(out, this); } + @Override public int getDecoderMemoryUsage() { return 1; } + @Override public InputStream getInputStream(InputStream in) { return new DeltaInputStream(in, distance); } + @Override FilterEncoder getFilterEncoder() { return new DeltaEncoder(this); } + @Override public Object clone() { try { return super.clone(); diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/FilterOptions.java b/HMCLAPI/src/main/java/org/tukaani/xz/FilterOptions.java index 3c80044b7..160047867 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/FilterOptions.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/FilterOptions.java @@ -18,10 +18,9 @@ import java.io.IOException; public abstract class FilterOptions implements Cloneable { /** - * Gets how much memory the encoder will need with - * the given filter chain. This function simply calls - * getEncoderMemoryUsage() for every filter - * in the array and returns the sum of the returned values. + * Gets how much memory the encoder will need with the given filter chain. + * This function simply calls getEncoderMemoryUsage() for every + * filter in the array and returns the sum of the returned values. */ public static int getEncoderMemoryUsage(FilterOptions[] options) { int m = 0; @@ -33,10 +32,9 @@ public abstract class FilterOptions implements Cloneable { } /** - * Gets how much memory the decoder will need with - * the given filter chain. This function simply calls - * getDecoderMemoryUsage() for every filter - * in the array and returns the sum of the returned values. + * Gets how much memory the decoder will need with the given filter chain. + * This function simply calls getDecoderMemoryUsage() for every + * filter in the array and returns the sum of the returned values. */ public static int getDecoderMemoryUsage(FilterOptions[] options) { int m = 0; @@ -53,18 +51,18 @@ public abstract class FilterOptions implements Cloneable { public abstract int getEncoderMemoryUsage(); /** - * Gets a raw (no XZ headers) encoder output stream using these options. - * Raw streams are an advanced feature. In most cases you want to store - * the compressed data in the .xz container format instead of using - * a raw stream. To use this filter in a .xz file, pass this object - * to XZOutputStream. + * Gets a raw (no XZ headers) encoder output stream using these options. Raw + * streams are an advanced feature. In most cases you want to store the + * compressed data in the .xz container format instead of using a raw + * stream. To use this filter in a .xz file, pass this object to + * XZOutputStream. */ public abstract FinishableOutputStream getOutputStream( - FinishableOutputStream out); + FinishableOutputStream out); /** - * Gets how much memory the decoder will need to decompress the data - * that was encoded with these options. + * Gets how much memory the decoder will need to decompress the data that + * was encoded with these options. */ public abstract int getDecoderMemoryUsage(); @@ -72,7 +70,7 @@ public abstract class FilterOptions implements Cloneable { * Gets a raw (no XZ headers) decoder input stream using these options. */ public abstract InputStream getInputStream(InputStream in) - throws IOException; + throws IOException; abstract FilterEncoder getFilterEncoder(); diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/FinishableWrapperOutputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/FinishableWrapperOutputStream.java index 4d702a6a7..849700b8f 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/FinishableWrapperOutputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/FinishableWrapperOutputStream.java @@ -35,6 +35,7 @@ public class FinishableWrapperOutputStream extends FinishableOutputStream { /** * Calls {@link java.io.OutputStream#write(int) out.write(b)}. */ + @Override public void write(int b) throws IOException { out.write(b); } @@ -42,6 +43,7 @@ public class FinishableWrapperOutputStream extends FinishableOutputStream { /** * Calls {@link java.io.OutputStream#write(byte[]) out.write(buf)}. */ + @Override public void write(byte[] buf) throws IOException { out.write(buf); } @@ -50,6 +52,7 @@ public class FinishableWrapperOutputStream extends FinishableOutputStream { * Calls {@link java.io.OutputStream#write(byte[],int,int) * out.write(buf, off, len)}. */ + @Override public void write(byte[] buf, int off, int len) throws IOException { out.write(buf, off, len); } @@ -57,6 +60,7 @@ public class FinishableWrapperOutputStream extends FinishableOutputStream { /** * Calls {@link java.io.OutputStream#flush() out.flush()}. */ + @Override public void flush() throws IOException { out.flush(); } @@ -64,6 +68,7 @@ public class FinishableWrapperOutputStream extends FinishableOutputStream { /** * Calls {@link java.io.OutputStream#close() out.close()}. */ + @Override public void close() throws IOException { out.close(); } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Decoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Decoder.java index 419eb7108..1152e8200 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Decoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Decoder.java @@ -19,16 +19,18 @@ class LZMA2Decoder extends LZMA2Coder implements FilterDecoder { // are too big for int. if (props.length != 1 || (props[0] & 0xFF) > 37) throw new UnsupportedOptionsException( - "Unsupported LZMA2 properties"); + "Unsupported LZMA2 properties"); dictSize = 2 | (props[0] & 1); dictSize <<= (props[0] >>> 1) + 11; } + @Override public int getMemoryUsage() { return LZMA2InputStream.getMemoryUsage(dictSize); } + @Override public InputStream getInputStream(InputStream in) { return new LZMA2InputStream(in, dictSize); } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Encoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Encoder.java index 4d8acafeb..37267c2b8 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Encoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Encoder.java @@ -18,7 +18,7 @@ class LZMA2Encoder extends LZMA2Coder implements FilterEncoder { LZMA2Encoder(LZMA2Options options) { if (options.getPresetDict() != null) throw new IllegalArgumentException( - "XZ doesn't support a preset dictionary for now"); + "XZ doesn't support a preset dictionary for now"); if (options.getMode() == LZMA2Options.MODE_UNCOMPRESSED) props[0] = (byte) 0; @@ -32,18 +32,22 @@ class LZMA2Encoder extends LZMA2Coder implements FilterEncoder { this.options = (LZMA2Options) options.clone(); } + @Override public long getFilterID() { return FILTER_ID; } + @Override public byte[] getFilterProps() { return props; } + @Override public boolean supportsFlushing() { return true; } + @Override public FinishableOutputStream getOutputStream(FinishableOutputStream out) { return options.getOutputStream(out); } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2InputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2InputStream.java index 5323a31b5..b14b8a33e 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2InputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2InputStream.java @@ -24,8 +24,8 @@ public class LZMA2InputStream extends InputStream { /** * Smallest valid LZMA2 dictionary size. *

- * Very tiny dictionaries would be a performance problem, so - * the minimum is 4 KiB. + * Very tiny dictionaries would be a performance problem, so the minimum is + * 4 KiB. */ public static final int DICT_SIZE_MIN = 4096; @@ -33,11 +33,11 @@ public class LZMA2InputStream extends InputStream { * Largest dictionary size supported by this implementation. *

* The LZMA2 algorithm allows dictionaries up to one byte less than 4 GiB. - * This implementation supports only 16 bytes less than 2 GiB for raw - * LZMA2 streams, and for .xz files the maximum is 1.5 GiB. This - * limitation is due to Java using signed 32-bit integers for array - * indexing. The limitation shouldn't matter much in practice since so - * huge dictionaries are not normally used. + * This implementation supports only 16 bytes less than 2 GiB for raw LZMA2 + * streams, and for .xz files the maximum is 1.5 GiB. This limitation is due + * to Java using signed 32-bit integers for array indexing. The limitation + * shouldn't matter much in practice since so huge dictionaries are not + * normally used. */ public static final int DICT_SIZE_MAX = Integer.MAX_VALUE & ~15; @@ -62,12 +62,11 @@ public class LZMA2InputStream extends InputStream { private final byte[] tempBuf = new byte[1]; /** - * Gets approximate decompressor memory requirements as kibibytes for - * the given dictionary size. + * Gets approximate decompressor memory requirements as kibibytes for the + * given dictionary size. * - * @param dictSize LZMA2 dictionary size as bytes, must be - * in the range [DICT_SIZE_MIN, - * DICT_SIZE_MAX] + * @param dictSize LZMA2 dictionary size as bytes, must be in the range + * [DICT_SIZE_MIN, DICT_SIZE_MAX] * * @return approximate memory requirements as kibibytes (KiB) */ @@ -81,7 +80,7 @@ public class LZMA2InputStream extends InputStream { private static int getDictSize(int dictSize) { if (dictSize < DICT_SIZE_MIN || dictSize > DICT_SIZE_MAX) throw new IllegalArgumentException( - "Unsupported dictionary size " + dictSize); + "Unsupported dictionary size " + dictSize); // Round dictionary size upward to a multiple of 16. This way LZMA // can use LZDecoder.getPos() for calculating LZMA's posMask. @@ -91,27 +90,25 @@ public class LZMA2InputStream extends InputStream { } /** - * Creates a new input stream that decompresses raw LZMA2 data - * from in. + * Creates a new input stream that decompresses raw LZMA2 data from + * in. *

- * The caller needs to know the dictionary size used when compressing; - * the dictionary size isn't stored as part of a raw LZMA2 stream. + * The caller needs to know the dictionary size used when compressing; the + * dictionary size isn't stored as part of a raw LZMA2 stream. *

- * Specifying a too small dictionary size will prevent decompressing - * the stream. Specifying a too big dictionary is waste of memory but + * Specifying a too small dictionary size will prevent decompressing the + * stream. Specifying a too big dictionary is waste of memory but * decompression will work. *

- * There is no need to specify a dictionary bigger than - * the uncompressed size of the data even if a bigger dictionary - * was used when compressing. If you know the uncompressed size - * of the data, this might allow saving some memory. + * There is no need to specify a dictionary bigger than the uncompressed + * size of the data even if a bigger dictionary was used when compressing. + * If you know the uncompressed size of the data, this might allow saving + * some memory. * - * @param in input stream from which LZMA2-compressed - * data is read + * @param in input stream from which LZMA2-compressed data is read * - * @param dictSize LZMA2 dictionary size as bytes, must be - * in the range [DICT_SIZE_MIN, - * DICT_SIZE_MAX] + * @param dictSize LZMA2 dictionary size as bytes, must be in the range + * [DICT_SIZE_MIN, DICT_SIZE_MAX] */ public LZMA2InputStream(InputStream in, int dictSize) { this(in, dictSize, null); @@ -120,20 +117,18 @@ public class LZMA2InputStream extends InputStream { /** * Creates a new LZMA2 decompressor using a preset dictionary. *

- * This is like LZMA2InputStream(InputStream, int) except - * that the dictionary may be initialized using a preset dictionary. - * If a preset dictionary was used when compressing the data, the - * same preset dictionary must be provided when decompressing. + * This is like LZMA2InputStream(InputStream, int) except that + * the dictionary may be initialized using a preset dictionary. If a preset + * dictionary was used when compressing the data, the same preset dictionary + * must be provided when decompressing. * - * @param in input stream from which LZMA2-compressed - * data is read + * @param in input stream from which LZMA2-compressed data is read * - * @param dictSize LZMA2 dictionary size as bytes, must be - * in the range [DICT_SIZE_MIN, - * DICT_SIZE_MAX] + * @param dictSize LZMA2 dictionary size as bytes, must be in the range + * [DICT_SIZE_MIN, DICT_SIZE_MAX] * - * @param presetDict preset dictionary or null - * to use no preset dictionary + * @param presetDict preset dictionary or null to use no preset + * dictionary */ public LZMA2InputStream(InputStream in, int dictSize, byte[] presetDict) { // Check for null because otherwise null isn't detect @@ -151,19 +146,18 @@ public class LZMA2InputStream extends InputStream { /** * Decompresses the next byte from this input stream. *

- * Reading lots of data with read() from this input stream - * may be inefficient. Wrap it in java.io.BufferedInputStream - * if you need to read lots of data one byte at a time. + * Reading lots of data with read() from this input stream may + * be inefficient. Wrap it in java.io.BufferedInputStream if + * you need to read lots of data one byte at a time. * - * @return the next decompressed byte, or -1 - * to indicate the end of the compressed stream + * @return the next decompressed byte, or -1 to indicate the + * end of the compressed stream * * @throws CorruptedInputException * * @throws XZIOException if the stream has been closed * - * @throws EOFException - * compressed input is truncated or corrupt + * @throws EOFException compressed input is truncated or corrupt * * @throws IOException may be thrown by in */ @@ -174,24 +168,23 @@ public class LZMA2InputStream extends InputStream { /** * Decompresses into an array of bytes. *

- * If len is zero, no bytes are read and 0 - * is returned. Otherwise this will block until len - * bytes have been decompressed, the end of the LZMA2 stream is reached, - * or an exception is thrown. + * If len is zero, no bytes are read and 0 is + * returned. Otherwise this will block until len bytes have + * been decompressed, the end of the LZMA2 stream is reached, or an + * exception is thrown. * * @param buf target buffer for uncompressed data * @param off start offset in buf * @param len maximum number of uncompressed bytes to read * - * @return number of bytes read, or -1 to indicate - * the end of the compressed stream + * @return number of bytes read, or -1 to indicate the end of + * the compressed stream * * @throws CorruptedInputException * * @throws XZIOException if the stream has been closed * - * @throws EOFException - * compressed input is truncated or corrupt + * @throws EOFException compressed input is truncated or corrupt * * @throws IOException may be thrown by in */ @@ -311,20 +304,18 @@ public class LZMA2InputStream extends InputStream { } /** - * Returns the number of uncompressed bytes that can be read - * without blocking. The value is returned with an assumption - * that the compressed input data will be valid. If the compressed - * data is corrupt, CorruptedInputException may get - * thrown before the number of bytes claimed to be available have - * been read from this input stream. + * Returns the number of uncompressed bytes that can be read without + * blocking. The value is returned with an assumption that the compressed + * input data will be valid. If the compressed data is corrupt, + * CorruptedInputException may get thrown before the number of + * bytes claimed to be available have been read from this input stream. *

* In LZMA2InputStream, the return value will be non-zero when the - * decompressor is in the middle of an LZMA2 chunk. The return value - * will then be the number of uncompressed bytes remaining from that - * chunk. + * decompressor is in the middle of an LZMA2 chunk. The return value will + * then be the number of uncompressed bytes remaining from that chunk. * - * @return the number of uncompressed bytes that can be read - * without blocking + * @return the number of uncompressed bytes that can be read without + * blocking */ public int available() throws IOException { if (in == null) @@ -337,8 +328,8 @@ public class LZMA2InputStream extends InputStream { } /** - * Closes the stream and calls in.close(). - * If the stream was already closed, this does nothing. + * Closes the stream and calls in.close(). If the stream was + * already closed, this does nothing. * * @throws IOException if thrown by in.close() */ diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Options.java b/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Options.java index 3cc8355c0..2dae30026 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Options.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2Options.java @@ -16,9 +16,8 @@ import org.tukaani.xz.lzma.LZMAEncoder; /** * LZMA2 compression options. *

- * While this allows setting the LZMA2 compression options in detail, - * often you only need LZMA2Options() or - * LZMA2Options(int). + * While this allows setting the LZMA2 compression options in detail, often you + * only need LZMA2Options() or LZMA2Options(int). */ public class LZMA2Options extends FilterOptions { @@ -45,13 +44,13 @@ public class LZMA2Options extends FilterOptions { /** * Maximum dictionary size for compression is 768 MiB. *

- * The decompressor supports bigger dictionaries, up to almost 2 GiB. - * With HC4 the encoder would support dictionaries bigger than 768 MiB. - * The 768 MiB limit comes from the current implementation of BT4 where - * we would otherwise hit the limits of signed ints in array indexing. + * The decompressor supports bigger dictionaries, up to almost 2 GiB. With + * HC4 the encoder would support dictionaries bigger than 768 MiB. The 768 + * MiB limit comes from the current implementation of BT4 where we would + * otherwise hit the limits of signed ints in array indexing. *

- * If you really need bigger dictionary for decompression, - * use {@link LZMA2InputStream} directly. + * If you really need bigger dictionary for decompression, use + * {@link LZMA2InputStream} directly. */ public static final int DICT_SIZE_MAX = 768 << 20; @@ -86,20 +85,20 @@ public class LZMA2Options extends FilterOptions { public static final int PB_DEFAULT = 2; /** - * Compression mode: uncompressed. - * The data is wrapped into a LZMA2 stream without compression. + * Compression mode: uncompressed. The data is wrapped into a LZMA2 stream + * without compression. */ public static final int MODE_UNCOMPRESSED = 0; /** - * Compression mode: fast. - * This is usually combined with a hash chain match finder. + * Compression mode: fast. This is usually combined with a hash chain match + * finder. */ public static final int MODE_FAST = LZMAEncoder.MODE_FAST; /** - * Compression mode: normal. - * This is usually combined with a binary tree match finder. + * Compression mode: normal. This is usually combined with a binary tree + * match finder. */ public static final int MODE_NORMAL = LZMAEncoder.MODE_NORMAL; @@ -125,9 +124,9 @@ public class LZMA2Options extends FilterOptions { private static final int[] presetToDictSize = { 1 << 18, 1 << 20, 1 << 21, 1 << 22, 1 << 22, - 1 << 23, 1 << 23, 1 << 24, 1 << 25, 1 << 26}; + 1 << 23, 1 << 23, 1 << 24, 1 << 25, 1 << 26 }; - private static final int[] presetToDepthLimit = {4, 8, 24, 48}; + private static final int[] presetToDepthLimit = { 4, 8, 24, 48 }; private int dictSize; private byte[] presetDict = null; @@ -140,8 +139,8 @@ public class LZMA2Options extends FilterOptions { private int depthLimit; /** - * Creates new LZMA2 options and sets them to the default values. - * This is equivalent to LZMA2Options(PRESET_DEFAULT). + * Creates new LZMA2 options and sets them to the default values. This is + * equivalent to LZMA2Options(PRESET_DEFAULT). */ public LZMA2Options() { try { @@ -155,8 +154,7 @@ public class LZMA2Options extends FilterOptions { /** * Creates new LZMA2 options and sets them to the given preset. * - * @throws UnsupportedOptionsException - * preset is not supported + * @throws UnsupportedOptionsException preset is not supported */ public LZMA2Options(int preset) throws UnsupportedOptionsException { setPreset(preset); @@ -165,12 +163,11 @@ public class LZMA2Options extends FilterOptions { /** * Creates new LZMA2 options and sets them to the given custom values. * - * @throws UnsupportedOptionsException - * unsupported options were specified + * @throws UnsupportedOptionsException unsupported options were specified */ public LZMA2Options(int dictSize, int lc, int lp, int pb, int mode, int niceLen, int mf, int depthLimit) - throws UnsupportedOptionsException { + throws UnsupportedOptionsException { setDictSize(dictSize); setLcLp(lc, lp); setPb(pb); @@ -183,23 +180,22 @@ public class LZMA2Options extends FilterOptions { /** * Sets the compression options to the given preset. *

- * The presets 0-3 are fast presets with medium compression. - * The presets 4-6 are fairly slow presets with high compression. - * The default preset (PRESET_DEFAULT) is 6. + * The presets 0-3 are fast presets with medium compression. The presets 4-6 + * are fairly slow presets with high compression. The default preset + * (PRESET_DEFAULT) is 6. *

- * The presets 7-9 are like the preset 6 but use bigger dictionaries - * and have higher compressor and decompressor memory requirements. - * Unless the uncompressed size of the file exceeds 8 MiB, - * 16 MiB, or 32 MiB, it is waste of memory to use the - * presets 7, 8, or 9, respectively. + * The presets 7-9 are like the preset 6 but use bigger dictionaries and + * have higher compressor and decompressor memory requirements. Unless the + * uncompressed size of the file exceeds 8 MiB, 16 MiB, or + * 32 MiB, it is waste of memory to use the presets 7, 8, or 9, + * respectively. * - * @throws UnsupportedOptionsException - * preset is not supported + * @throws UnsupportedOptionsException preset is not supported */ public void setPreset(int preset) throws UnsupportedOptionsException { if (preset < 0 || preset > 9) throw new UnsupportedOptionsException( - "Unsupported preset: " + preset); + "Unsupported preset: " + preset); lc = LC_DEFAULT; lp = LP_DEFAULT; @@ -227,23 +223,22 @@ public class LZMA2Options extends FilterOptions { * However, using a dictioanary bigger than the size of the uncompressed * data is waste of memory. *

- * Any value in the range [DICT_SIZE_MIN, DICT_SIZE_MAX] is valid, - * but sizes of 2^n and 2^n + 2^(n-1) bytes are somewhat - * recommended. + * Any value in the range [DICT_SIZE_MIN, DICT_SIZE_MAX] is valid, but sizes + * of 2^n and 2^n + 2^(n-1) bytes are somewhat recommended. * - * @throws UnsupportedOptionsException - * dictSize is not supported + * @throws UnsupportedOptionsException dictSize is not + * supported */ public void setDictSize(int dictSize) throws UnsupportedOptionsException { if (dictSize < DICT_SIZE_MIN) throw new UnsupportedOptionsException( - "LZMA2 dictionary size must be at least 4 KiB: " - + dictSize + " B"); + "LZMA2 dictionary size must be at least 4 KiB: " + + dictSize + " B"); if (dictSize > DICT_SIZE_MAX) throw new UnsupportedOptionsException( - "LZMA2 dictionary size must not exceed " - + (DICT_SIZE_MAX >> 20) + " MiB: " + dictSize + " B"); + "LZMA2 dictionary size must not exceed " + + (DICT_SIZE_MAX >> 20) + " MiB: " + dictSize + " B"); this.dictSize = dictSize; } @@ -256,18 +251,18 @@ public class LZMA2Options extends FilterOptions { } /** - * Sets a preset dictionary. Use null to disable the use of - * a preset dictionary. By default there is no preset dictionary. + * Sets a preset dictionary. Use null to disable the use of a preset + * dictionary. By default there is no preset dictionary. *

- * The .xz format doesn't support a preset dictionary for now. - * Do not set a preset dictionary unless you use raw LZMA2. + * The .xz format doesn't support a preset dictionary for now. Do not set + * a preset dictionary unless you use raw LZMA2. *

- * Preset dictionary can be useful when compressing many similar, - * relatively small chunks of data independently from each other. - * A preset dictionary should contain typical strings that occur in - * the files being compressed. The most probable strings should be - * near the end of the preset dictionary. The preset dictionary used - * for compression is also needed for decompression. + * Preset dictionary can be useful when compressing many similar, relatively + * small chunks of data independently from each other. A preset dictionary + * should contain typical strings that occur in the files being compressed. + * The most probable strings should be near the end of the preset + * dictionary. The preset dictionary used for compression is also needed for + * decompression. */ public void setPresetDict(byte[] presetDict) { this.presetDict = presetDict; @@ -283,20 +278,19 @@ public class LZMA2Options extends FilterOptions { /** * Sets the number of literal context bits and literal position bits. *

- * The sum of lc and lp is limited to 4. - * Trying to exceed it will throw an exception. This function lets - * you change both at the same time. + * The sum of lc and lp is limited to 4. Trying to + * exceed it will throw an exception. This function lets you change both at + * the same time. * - * @throws UnsupportedOptionsException - * lc and lp + * @throws UnsupportedOptionsException lc and lp * are invalid */ public void setLcLp(int lc, int lp) throws UnsupportedOptionsException { if (lc < 0 || lp < 0 || lc > LC_LP_MAX || lp > LC_LP_MAX || lc + lp > LC_LP_MAX) throw new UnsupportedOptionsException( - "lc + lp must not exceed " + LC_LP_MAX + ": " - + lc + " + " + lp); + "lc + lp must not exceed " + LC_LP_MAX + ": " + + lc + " + " + lp); this.lc = lc; this.lp = lp; @@ -305,28 +299,25 @@ public class LZMA2Options extends FilterOptions { /** * Sets the number of literal context bits. *

- * All bytes that cannot be encoded as matches are encoded as literals. - * That is, literals are simply 8-bit bytes that are encoded one at - * a time. + * All bytes that cannot be encoded as matches are encoded as literals. That + * is, literals are simply 8-bit bytes that are encoded one at a time. *

* The literal coding makes an assumption that the highest lc - * bits of the previous uncompressed byte correlate with the next byte. - * For example, in typical English text, an upper-case letter is often - * followed by a lower-case letter, and a lower-case letter is usually - * followed by another lower-case letter. In the US-ASCII character set, - * the highest three bits are 010 for upper-case letters and 011 for - * lower-case letters. When lc is at least 3, the literal - * coding can take advantage of this property in the uncompressed data. + * bits of the previous uncompressed byte correlate with the next byte. For + * example, in typical English text, an upper-case letter is often followed + * by a lower-case letter, and a lower-case letter is usually followed by + * another lower-case letter. In the US-ASCII character set, the highest + * three bits are 010 for upper-case letters and 011 for lower-case letters. + * When lc is at least 3, the literal coding can take advantage + * of this property in the uncompressed data. *

* The default value (3) is usually good. If you want maximum compression, * try setLc(4). Sometimes it helps a little, and sometimes it * makes compression worse. If it makes it worse, test for example * setLc(2) too. * - * @throws UnsupportedOptionsException - * lc is invalid, or the sum - * of lc and lp - * exceed LC_LP_MAX + * @throws UnsupportedOptionsException lc is invalid, or the + * sum of lc and lp exceed LC_LP_MAX */ public void setLc(int lc) throws UnsupportedOptionsException { setLcLp(lc, lp); @@ -335,14 +326,12 @@ public class LZMA2Options extends FilterOptions { /** * Sets the number of literal position bits. *

- * This affets what kind of alignment in the uncompressed data is - * assumed when encoding literals. See {@link #setPb(int) setPb} for - * more information about alignment. + * This affets what kind of alignment in the uncompressed data is assumed + * when encoding literals. See {@link #setPb(int) setPb} for more + * information about alignment. * - * @throws UnsupportedOptionsException - * lp is invalid, or the sum - * of lc and lp - * exceed LC_LP_MAX + * @throws UnsupportedOptionsException lp is invalid, or the + * sum of lc and lp exceed LC_LP_MAX */ public void setLp(int lp) throws UnsupportedOptionsException { setLcLp(lc, lp); @@ -365,31 +354,28 @@ public class LZMA2Options extends FilterOptions { /** * Sets the number of position bits. *

- * This affects what kind of alignment in the uncompressed data is - * assumed in general. The default (2) means four-byte alignment - * (2^pb = 2^2 = 4), which is often a good choice when - * there's no better guess. + * This affects what kind of alignment in the uncompressed data is assumed + * in general. The default (2) means four-byte alignment (2^pb + * = 2^2 = 4), which is often a good choice when there's no better guess. *

* When the alignment is known, setting the number of position bits * accordingly may reduce the file size a little. For example with text * files having one-byte alignment (US-ASCII, ISO-8859-*, UTF-8), using - * setPb(0) can improve compression slightly. For UTF-16 - * text, setPb(1) is a good choice. If the alignment is - * an odd number like 3 bytes, setPb(0) might be the best - * choice. + * setPb(0) can improve compression slightly. For UTF-16 text, + * setPb(1) is a good choice. If the alignment is an odd number + * like 3 bytes, setPb(0) might be the best choice. *

- * Even though the assumed alignment can be adjusted with - * setPb and setLp, LZMA2 still slightly favors - * 16-byte alignment. It might be worth taking into account when designing - * file formats that are likely to be often compressed with LZMA2. + * Even though the assumed alignment can be adjusted with setPb + * and setLp, LZMA2 still slightly favors 16-byte alignment. It + * might be worth taking into account when designing file formats that are + * likely to be often compressed with LZMA2. * - * @throws UnsupportedOptionsException - * pb is invalid + * @throws UnsupportedOptionsException pb is invalid */ public void setPb(int pb) throws UnsupportedOptionsException { if (pb < 0 || pb > PB_MAX) throw new UnsupportedOptionsException( - "pb must not exceed " + PB_MAX + ": " + pb); + "pb must not exceed " + PB_MAX + ": " + pb); this.pb = pb; } @@ -404,25 +390,24 @@ public class LZMA2Options extends FilterOptions { /** * Sets the compression mode. *

- * This specifies the method to analyze the data produced by - * a match finder. The default is MODE_FAST for presets - * 0-3 and MODE_NORMAL for presets 4-9. + * This specifies the method to analyze the data produced by a match finder. + * The default is MODE_FAST for presets 0-3 and + * MODE_NORMAL for presets 4-9. *

- * Usually MODE_FAST is used with Hash Chain match finders - * and MODE_NORMAL with Binary Tree match finders. This is - * also what the presets do. + * Usually MODE_FAST is used with Hash Chain match finders and + * MODE_NORMAL with Binary Tree match finders. This is also + * what the presets do. *

- * The special mode MODE_UNCOMPRESSED doesn't try to - * compress the data at all (and doesn't use a match finder) and will - * simply wrap it in uncompressed LZMA2 chunks. + * The special mode MODE_UNCOMPRESSED doesn't try to compress + * the data at all (and doesn't use a match finder) and will simply wrap it + * in uncompressed LZMA2 chunks. * - * @throws UnsupportedOptionsException - * mode is not supported + * @throws UnsupportedOptionsException mode is not supported */ public void setMode(int mode) throws UnsupportedOptionsException { if (mode < MODE_UNCOMPRESSED || mode > MODE_NORMAL) throw new UnsupportedOptionsException( - "Unsupported compression mode: " + mode); + "Unsupported compression mode: " + mode); this.mode = mode; } @@ -435,25 +420,23 @@ public class LZMA2Options extends FilterOptions { } /** - * Sets the nice length of matches. - * Once a match of at least niceLen bytes is found, - * the algorithm stops looking for better matches. Higher values tend - * to give better compression at the expense of speed. The default - * depends on the preset. + * Sets the nice length of matches. Once a match of at least + * niceLen bytes is found, the algorithm stops looking for + * better matches. Higher values tend to give better compression at the + * expense of speed. The default depends on the preset. * - * @throws UnsupportedOptionsException - * niceLen is invalid + * @throws UnsupportedOptionsException niceLen is invalid */ public void setNiceLen(int niceLen) throws UnsupportedOptionsException { if (niceLen < NICE_LEN_MIN) throw new UnsupportedOptionsException( - "Minimum nice length of matches is " - + NICE_LEN_MIN + " bytes: " + niceLen); + "Minimum nice length of matches is " + + NICE_LEN_MIN + " bytes: " + niceLen); if (niceLen > NICE_LEN_MAX) throw new UnsupportedOptionsException( - "Maximum nice length of matches is " + NICE_LEN_MAX - + ": " + niceLen); + "Maximum nice length of matches is " + NICE_LEN_MAX + + ": " + niceLen); this.niceLen = niceLen; } @@ -468,18 +451,17 @@ public class LZMA2Options extends FilterOptions { /** * Sets the match finder type. *

- * Match finder has a major effect on compression speed, memory usage, - * and compression ratio. Usually Hash Chain match finders are faster - * than Binary Tree match finders. The default depends on the preset: - * 0-3 use MF_HC4 and 4-9 use MF_BT4. + * Match finder has a major effect on compression speed, memory usage, and + * compression ratio. Usually Hash Chain match finders are faster than + * Binary Tree match finders. The default depends on the preset: 0-3 use + * MF_HC4 and 4-9 use MF_BT4. * - * @throws UnsupportedOptionsException - * mf is not supported + * @throws UnsupportedOptionsException mf is not supported */ public void setMatchFinder(int mf) throws UnsupportedOptionsException { if (mf != MF_HC4 && mf != MF_BT4) throw new UnsupportedOptionsException( - "Unsupported match finder: " + mf); + "Unsupported match finder: " + mf); this.mf = mf; } @@ -494,24 +476,23 @@ public class LZMA2Options extends FilterOptions { /** * Sets the match finder search depth limit. *

- * The default is a special value of 0 which indicates that - * the depth limit should be automatically calculated by the selected - * match finder from the nice length of matches. + * The default is a special value of 0 which indicates that the + * depth limit should be automatically calculated by the selected match + * finder from the nice length of matches. *

- * Reasonable depth limit for Hash Chain match finders is 4-100 and - * 16-1000 for Binary Tree match finders. Using very high values can - * make the compressor extremely slow with some files. Avoid settings - * higher than 1000 unless you are prepared to interrupt the compression - * in case it is taking far too long. + * Reasonable depth limit for Hash Chain match finders is 4-100 and 16-1000 + * for Binary Tree match finders. Using very high values can make the + * compressor extremely slow with some files. Avoid settings higher than + * 1000 unless you are prepared to interrupt the compression in case it is + * taking far too long. * - * @throws UnsupportedOptionsException - * depthLimit is invalid + * @throws UnsupportedOptionsException depthLimit is invalid */ public void setDepthLimit(int depthLimit) - throws UnsupportedOptionsException { + throws UnsupportedOptionsException { if (depthLimit < 0) throw new UnsupportedOptionsException( - "Depth limit cannot be negative: " + depthLimit); + "Depth limit cannot be negative: " + depthLimit); this.depthLimit = depthLimit; } @@ -540,12 +521,12 @@ public class LZMA2Options extends FilterOptions { * Gets how much memory the LZMA2 decoder will need to decompress the data * that was encoded with these options and stored in a .xz file. *

- * The returned value may bigger than the value returned by a direct call - * to {@link LZMA2InputStream#getMemoryUsage(int)} if the dictionary size - * is not 2^n or 2^n + 2^(n-1) bytes. This is because the .xz - * headers store the dictionary size in such a format and other values - * are rounded up to the next such value. Such rounding is harmess except - * it might waste some memory if an unsual dictionary size is used. + * The returned value may bigger than the value returned by a direct call to + * {@link LZMA2InputStream#getMemoryUsage(int)} if the dictionary size is + * not 2^n or 2^n + 2^(n-1) bytes. This is because the .xz headers + * store the dictionary size in such a format and other values are rounded + * up to the next such value. Such rounding is harmess except it might waste + * some memory if an unsual dictionary size is used. *

* If you use raw LZMA2 streams and unusual dictioanary size, call * {@link LZMA2InputStream#getMemoryUsage} directly to get raw decoder diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2OutputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2OutputStream.java index dd7747d77..6386a1e0f 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2OutputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/LZMA2OutputStream.java @@ -133,7 +133,7 @@ class LZMA2OutputStream extends FinishableOutputStream { } private void writeLZMA(int uncompressedSize, int compressedSize) - throws IOException { + throws IOException { int control; if (propsNeeded) diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/LZMAInputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/LZMAInputStream.java index e21618bd4..c52447c8f 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/LZMAInputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/LZMAInputStream.java @@ -20,16 +20,16 @@ import org.tukaani.xz.lzma.LZMADecoder; * Decompresses legacy .lzma files and raw LZMA streams (no .lzma header). *

* IMPORTANT: In contrast to other classes in this package, this class - * reads data from its input stream one byte at a time. If the input stream - * is for example {@link java.io.FileInputStream}, wrapping it into - * {@link java.io.BufferedInputStream} tends to improve performance a lot. - * This is not automatically done by this class because there may be use - * cases where it is desired that this class won't read any bytes past - * the end of the LZMA stream. + * reads data from its input stream one byte at a time. If the input stream is + * for example {@link java.io.FileInputStream}, wrapping it into + * {@link java.io.BufferedInputStream} tends to improve performance a lot. This + * is not automatically done by this class because there may be use cases where + * it is desired that this class won't read any bytes past the end of the LZMA + * stream. *

- * Even when using BufferedInputStream, the performance tends - * to be worse (maybe 10-20 % slower) than with {@link LZMA2InputStream} - * or {@link XZInputStream} (when the .xz file contains LZMA2-compressed data). + * Even when using BufferedInputStream, the performance tends to be + * worse (maybe 10-20 % slower) than with {@link LZMA2InputStream} or + * {@link XZInputStream} (when the .xz file contains LZMA2-compressed data). * * @since 1.4 */ @@ -39,10 +39,10 @@ public class LZMAInputStream extends InputStream { * Largest dictionary size supported by this implementation. *

* LZMA allows dictionaries up to one byte less than 4 GiB. This - * implementation supports only 16 bytes less than 2 GiB. This - * limitation is due to Java using signed 32-bit integers for array - * indexing. The limitation shouldn't matter much in practice since so - * huge dictionaries are not normally used. + * implementation supports only 16 bytes less than 2 GiB. This limitation is + * due to Java using signed 32-bit integers for array indexing. The + * limitation shouldn't matter much in practice since so huge dictionaries + * are not normally used. */ public static final int DICT_SIZE_MAX = Integer.MAX_VALUE & ~15; @@ -56,39 +56,35 @@ public class LZMAInputStream extends InputStream { private final byte[] tempBuf = new byte[1]; /** - * Number of uncompressed bytes left to be decompressed, or -1 if - * the end marker is used. + * Number of uncompressed bytes left to be decompressed, or -1 if the end + * marker is used. */ private long remainingSize; private IOException exception = null; /** - * Gets approximate decompressor memory requirements as kibibytes for - * the given dictionary size and LZMA properties byte (lc, lp, and pb). + * Gets approximate decompressor memory requirements as kibibytes for the + * given dictionary size and LZMA properties byte (lc, lp, and pb). * - * @param dictSize LZMA dictionary size as bytes, should be - * in the range [0, - * DICT_SIZE_MAX] + * @param dictSize LZMA dictionary size as bytes, should be in the range + * [0, DICT_SIZE_MAX] * - * @param propsByte LZMA properties byte that encodes the values - * of lc, lp, and pb + * @param propsByte LZMA properties byte that encodes the values of lc, lp, + * and pb * * @return approximate memory requirements as kibibytes (KiB) * - * @throws UnsupportedOptionsException - * if dictSize is outside - * the range [0, - * DICT_SIZE_MAX] + * @throws UnsupportedOptionsException if dictSize is outside + * the range [0, DICT_SIZE_MAX] * - * @throws CorruptedInputException - * if propsByte is invalid + * @throws CorruptedInputException if propsByte is invalid */ public static int getMemoryUsage(int dictSize, byte propsByte) - throws UnsupportedOptionsException, CorruptedInputException { + throws UnsupportedOptionsException, CorruptedInputException { if (dictSize < 0 || dictSize > DICT_SIZE_MAX) throw new UnsupportedOptionsException( - "LZMA dictionary is too big for this implementation"); + "LZMA dictionary is too big for this implementation"); int props = propsByte & 0xFF; if (props > (4 * 5 + 4) * 9 + 8) @@ -102,18 +98,17 @@ public class LZMAInputStream extends InputStream { } /** - * Gets approximate decompressor memory requirements as kibibytes for - * the given dictionary size, lc, and lp. Note that pb isn't needed. + * Gets approximate decompressor memory requirements as kibibytes for the + * given dictionary size, lc, and lp. Note that pb isn't needed. * - * @param dictSize LZMA dictionary size as bytes, must be - * in the range [0, - * DICT_SIZE_MAX] + * @param dictSize LZMA dictionary size as bytes, must be in the range + * [0, DICT_SIZE_MAX] * - * @param lc number of literal context bits, must be - * in the range [0, 8] + * @param lc number of literal context bits, must be in the range [0, + * 8] * - * @param lp number of literal position bits, must be - * in the range [0, 4] + * @param lp number of literal position bits, must be in the range [0, + * 4] * * @return approximate memory requirements as kibibytes (KiB) */ @@ -135,7 +130,7 @@ public class LZMAInputStream extends InputStream { private static int getDictSize(int dictSize) { if (dictSize < 0 || dictSize > DICT_SIZE_MAX) throw new IllegalArgumentException( - "LZMA dictionary is too big for this implementation"); + "LZMA dictionary is too big for this implementation"); // For performance reasons, use a 4 KiB dictionary if something // smaller was requested. It's a rare situation and the performance @@ -156,25 +151,22 @@ public class LZMAInputStream extends InputStream { } /** - * Creates a new .lzma file format decompressor without - * a memory usage limit. + * Creates a new .lzma file format decompressor without a memory usage + * limit. * - * @param in input stream from which .lzma data is read; - * it might be a good idea to wrap it in - * BufferedInputStream, see the - * note at the top of this page + * @param in input stream from which .lzma data is read; it might be a good + * idea to wrap it in BufferedInputStream, see the note at the + * top of this page * - * @throws CorruptedInputException - * file is corrupt or perhaps not in - * the .lzma format at all + * @throws CorruptedInputException file is corrupt or perhaps not in the + * .lzma format at all * - * @throws UnsupportedOptionsException - * dictionary size or uncompressed size is too - * big for this implementation + * @throws UnsupportedOptionsException dictionary size or uncompressed size + * is too big for this implementation * - * @throws EOFException - * file is truncated or perhaps not in - * the .lzma format at all + * @throws EOFException file is truncated or perhaps not in + * the .lzma format + * at all * * @throws IOException may be thrown by in */ @@ -183,37 +175,33 @@ public class LZMAInputStream extends InputStream { } /** - * Creates a new .lzma file format decompressor with an optional - * memory usage limit. + * Creates a new .lzma file format decompressor with an optional memory + * usage limit. * - * @param in input stream from which .lzma data is read; - * it might be a good idea to wrap it in - * BufferedInputStream, see the - * note at the top of this page + * @param in input stream from which .lzma data is read; it might + * be a good + * idea to wrap it in BufferedInputStream, see the note at the + * top of this page * - * @param memoryLimit memory usage limit in kibibytes (KiB) - * or -1 to impose no - * memory usage limit + * @param memoryLimit memory usage limit in kibibytes (KiB) or + * -1 to impose no memory usage limit * - * @throws CorruptedInputException - * file is corrupt or perhaps not in - * the .lzma format at all + * @throws CorruptedInputException file is corrupt or perhaps not in the + * .lzma format at all * - * @throws UnsupportedOptionsException - * dictionary size or uncompressed size is too - * big for this implementation + * @throws UnsupportedOptionsException dictionary size or uncompressed size + * is too big for this implementation * - * @throws MemoryLimitException - * memory usage limit was exceeded + * @throws MemoryLimitException memory usage limit was exceeded * - * @throws EOFException - * file is truncated or perhaps not in - * the .lzma format at all + * @throws EOFException file is truncated or perhaps not in + * the .lzma format + * at all * * @throws IOException may be thrown by in */ public LZMAInputStream(InputStream in, int memoryLimit) - throws IOException { + throws IOException { DataInputStream inData = new DataInputStream(in); // Properties byte (lc, lp, and pb) @@ -244,45 +232,43 @@ public class LZMAInputStream extends InputStream { * Creates a new input stream that decompresses raw LZMA data (no .lzma * header) from in. *

- * The caller needs to know if the "end of payload marker (EOPM)" alias - * "end of stream marker (EOS marker)" alias "end marker" present. - * If the end marker isn't used, the caller must know the exact - * uncompressed size of the stream. + * The caller needs to know if the "end of payload marker (EOPM)" alias "end + * of stream marker (EOS marker)" alias "end marker" present. If the end + * marker isn't used, the caller must know the exact uncompressed size of + * the stream. *

* The caller also needs to provide the LZMA properties byte that encodes - * the number of literal context bits (lc), literal position bits (lp), - * and position bits (pb). + * the number of literal context bits (lc), literal position bits (lp), and + * position bits (pb). *

- * The dictionary size used when compressing is also needed. Specifying - * a too small dictionary size will prevent decompressing the stream. - * Specifying a too big dictionary is waste of memory but decompression - * will work. + * The dictionary size used when compressing is also needed. Specifying a + * too small dictionary size will prevent decompressing the stream. + * Specifying a too big dictionary is waste of memory but decompression will + * work. *

- * There is no need to specify a dictionary bigger than - * the uncompressed size of the data even if a bigger dictionary - * was used when compressing. If you know the uncompressed size - * of the data, this might allow saving some memory. + * There is no need to specify a dictionary bigger than the uncompressed + * size of the data even if a bigger dictionary was used when compressing. + * If you know the uncompressed size of the data, this might allow saving + * some memory. * - * @param in input stream from which compressed - * data is read + * @param in input stream from which compressed data is read * - * @param uncompSize uncompressed size of the LZMA stream or -1 - * if the end marker is used in the LZMA stream + * @param uncompSize uncompressed size of the LZMA stream or -1 if the end + * marker is used in the LZMA stream * - * @param propsByte LZMA properties byte that has the encoded - * values for literal context bits (lc), literal - * position bits (lp), and position bits (pb) + * @param propsByte LZMA properties byte that has the encoded values for + * literal context bits (lc), literal position bits (lp), and position bits + * (pb) * * @param dictSize dictionary size as bytes, must be in the range * [0, DICT_SIZE_MAX] * - * @throws CorruptedInputException - * if propsByte is invalid or + * @throws CorruptedInputException if propsByte is invalid + * or * the first input byte is not 0x00 * - * @throws UnsupportedOptionsException - * dictionary size or uncompressed size is too - * big for this implementation + * @throws UnsupportedOptionsException dictionary size or uncompressed size + * is too big for this implementation * * */ @@ -295,29 +281,27 @@ public class LZMAInputStream extends InputStream { * Creates a new input stream that decompresses raw LZMA data (no .lzma * header) from in optionally with a preset dictionary. * - * @param in input stream from which LZMA-compressed - * data is read + * @param in input stream from which LZMA-compressed data is read * - * @param uncompSize uncompressed size of the LZMA stream or -1 - * if the end marker is used in the LZMA stream + * @param uncompSize uncompressed size of the LZMA stream or -1 if the end + * marker is used in the LZMA stream * - * @param propsByte LZMA properties byte that has the encoded - * values for literal context bits (lc), literal - * position bits (lp), and position bits (pb) + * @param propsByte LZMA properties byte that has the encoded values for + * literal context bits (lc), literal position bits (lp), and position bits + * (pb) * * @param dictSize dictionary size as bytes, must be in the range * [0, DICT_SIZE_MAX] * - * @param presetDict preset dictionary or null - * to use no preset dictionary + * @param presetDict preset dictionary or null to use no preset + * dictionary * - * @throws CorruptedInputException - * if propsByte is invalid or + * @throws CorruptedInputException if propsByte is invalid + * or * the first input byte is not 0x00 * - * @throws UnsupportedOptionsException - * dictionary size or uncompressed size is too - * big for this implementation + * @throws UnsupportedOptionsException dictionary size or uncompressed size + * is too big for this implementation * * @throws EOFException file is truncated or corrupt * @@ -325,7 +309,7 @@ public class LZMAInputStream extends InputStream { */ public LZMAInputStream(InputStream in, long uncompSize, byte propsByte, int dictSize, byte[] presetDict) - throws IOException { + throws IOException { initialize(in, uncompSize, propsByte, dictSize, presetDict); } @@ -333,29 +317,26 @@ public class LZMAInputStream extends InputStream { * Creates a new input stream that decompresses raw LZMA data (no .lzma * header) from in optionally with a preset dictionary. * - * @param in input stream from which LZMA-compressed - * data is read + * @param in input stream from which LZMA-compressed data is read * - * @param uncompSize uncompressed size of the LZMA stream or -1 - * if the end marker is used in the LZMA stream + * @param uncompSize uncompressed size of the LZMA stream or -1 if the end + * marker is used in the LZMA stream * - * @param lc number of literal context bits, must be - * in the range [0, 8] + * @param lc number of literal context bits, must be in the range + * [0, 8] * - * @param lp number of literal position bits, must be - * in the range [0, 4] + * @param lp number of literal position bits, must be in the range + * [0, 4] * - * @param pb number position bits, must be - * in the range [0, 4] + * @param pb number position bits, must be in the range [0, 4] * * @param dictSize dictionary size as bytes, must be in the range * [0, DICT_SIZE_MAX] * - * @param presetDict preset dictionary or null - * to use no preset dictionary + * @param presetDict preset dictionary or null to use no preset + * dictionary * - * @throws CorruptedInputException - * if the first input byte is not 0x00 + * @throws CorruptedInputException if the first input byte is not 0x00 * * @throws EOFException file is truncated or corrupt * @@ -364,18 +345,18 @@ public class LZMAInputStream extends InputStream { public LZMAInputStream(InputStream in, long uncompSize, int lc, int lp, int pb, int dictSize, byte[] presetDict) - throws IOException { + throws IOException { initialize(in, uncompSize, lc, lp, pb, dictSize, presetDict); } private void initialize(InputStream in, long uncompSize, byte propsByte, int dictSize, byte[] presetDict) - throws IOException { + throws IOException { // Validate the uncompressed size since the other "initialize" throws // IllegalArgumentException if uncompSize < -1. if (uncompSize < -1) throw new UnsupportedOptionsException( - "Uncompressed size is too big"); + "Uncompressed size is too big"); // Decode the properties byte. In contrast to LZMA2, there is no // limit of lc + lp <= 4. @@ -392,7 +373,7 @@ public class LZMAInputStream extends InputStream { // IllegalArgumentException if dictSize is not supported. if (dictSize < 0 || dictSize > DICT_SIZE_MAX) throw new UnsupportedOptionsException( - "LZMA dictionary is too big for this implementation"); + "LZMA dictionary is too big for this implementation"); initialize(in, uncompSize, lc, lp, pb, dictSize, presetDict); } @@ -400,7 +381,7 @@ public class LZMAInputStream extends InputStream { private void initialize(InputStream in, long uncompSize, int lc, int lp, int pb, int dictSize, byte[] presetDict) - throws IOException { + throws IOException { // getDictSize validates dictSize and gives a message in // the exception too, so skip validating dictSize here. if (uncompSize < -1 || lc < 0 || lc > 8 || lp < 0 || lp > 4 @@ -424,19 +405,18 @@ public class LZMAInputStream extends InputStream { /** * Decompresses the next byte from this input stream. *

- * Reading lots of data with read() from this input stream - * may be inefficient. Wrap it in java.io.BufferedInputStream - * if you need to read lots of data one byte at a time. + * Reading lots of data with read() from this input stream may + * be inefficient. Wrap it in java.io.BufferedInputStream if + * you need to read lots of data one byte at a time. * - * @return the next decompressed byte, or -1 - * to indicate the end of the compressed stream + * @return the next decompressed byte, or -1 to indicate the + * end of the compressed stream * * @throws CorruptedInputException * * @throws XZIOException if the stream has been closed * - * @throws EOFException - * compressed input is truncated or corrupt + * @throws EOFException compressed input is truncated or corrupt * * @throws IOException may be thrown by in */ @@ -447,17 +427,17 @@ public class LZMAInputStream extends InputStream { /** * Decompresses into an array of bytes. *

- * If len is zero, no bytes are read and 0 - * is returned. Otherwise this will block until len - * bytes have been decompressed, the end of the LZMA stream is reached, - * or an exception is thrown. + * If len is zero, no bytes are read and 0 is + * returned. Otherwise this will block until len bytes have + * been decompressed, the end of the LZMA stream is reached, or an exception + * is thrown. * * @param buf target buffer for uncompressed data * @param off start offset in buf * @param len maximum number of uncompressed bytes to read * - * @return number of bytes read, or -1 to indicate - * the end of the compressed stream + * @return number of bytes read, or -1 to indicate the end of + * the compressed stream * * @throws CorruptedInputException * @@ -552,8 +532,8 @@ public class LZMAInputStream extends InputStream { } /** - * Closes the stream and calls in.close(). - * If the stream was already closed, this does nothing. + * Closes the stream and calls in.close(). If the stream was + * already closed, this does nothing. * * @throws IOException if thrown by in.close() */ diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/MemoryLimitException.java b/HMCLAPI/src/main/java/org/tukaani/xz/MemoryLimitException.java index 61d130847..d237453ad 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/MemoryLimitException.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/MemoryLimitException.java @@ -9,11 +9,11 @@ package org.tukaani.xz; /** - * Thrown when the memory usage limit given to the XZ decompressor - * would be exceeded. + * Thrown when the memory usage limit given to the XZ decompressor would be + * exceeded. *

- * The amount of memory required and the memory usage limit are - * included in the error detail message in human readable format. + * The amount of memory required and the memory usage limit are included in the + * error detail message in human readable format. */ public class MemoryLimitException extends XZIOException { @@ -25,8 +25,8 @@ public class MemoryLimitException extends XZIOException { /** * Creates a new MemoryLimitException. *

- * The amount of memory needed and the memory usage limit are - * included in the error detail message. + * The amount of memory needed and the memory usage limit are included in + * the error detail message. * * @param memoryNeeded amount of memory needed as kibibytes (KiB) * @param memoryLimit specified memory usage limit as kibibytes (KiB) @@ -49,8 +49,8 @@ public class MemoryLimitException extends XZIOException { } /** - * Gets what the memory usage limit was at the time the exception - * was created. + * Gets what the memory usage limit was at the time the exception was + * created. * * @return memory usage limit as kibibytes (KiB) */ diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/RawCoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/RawCoder.java index 7a1624b21..e683cacc2 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/RawCoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/RawCoder.java @@ -11,15 +11,15 @@ package org.tukaani.xz; class RawCoder { static void validate(FilterCoder[] filters) - throws UnsupportedOptionsException { + throws UnsupportedOptionsException { for (int i = 0; i < filters.length - 1; ++i) if (!filters[i].nonLastOK()) throw new UnsupportedOptionsException( - "Unsupported XZ filter chain"); + "Unsupported XZ filter chain"); if (!filters[filters.length - 1].lastOK()) throw new UnsupportedOptionsException( - "Unsupported XZ filter chain"); + "Unsupported XZ filter chain"); int changesSizeCount = 0; for (int i = 0; i < filters.length; ++i) @@ -28,6 +28,6 @@ class RawCoder { if (changesSizeCount > 3) throw new UnsupportedOptionsException( - "Unsupported XZ filter chain"); + "Unsupported XZ filter chain"); } } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/SeekableFileInputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/SeekableFileInputStream.java index e54134fbb..932baf138 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/SeekableFileInputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/SeekableFileInputStream.java @@ -14,14 +14,14 @@ import java.io.IOException; import java.io.FileNotFoundException; /** - * Wraps a {@link java.io.RandomAccessFile RandomAccessFile} - * in a SeekableInputStream. + * Wraps a {@link java.io.RandomAccessFile RandomAccessFile} in a + * SeekableInputStream. */ public class SeekableFileInputStream extends SeekableInputStream { /** - * The RandomAccessFile that has been wrapped - * into a SeekableFileInputStream. + * The RandomAccessFile that has been wrapped into a + * SeekableFileInputStream. */ protected RandomAccessFile randomAccessFile; @@ -33,8 +33,8 @@ public class SeekableFileInputStream extends SeekableInputStream { } /** - * Creates a new seekable input stream that reads from a file with - * the specified name. + * Creates a new seekable input stream that reads from a file with the + * specified name. */ public SeekableFileInputStream(String name) throws FileNotFoundException { randomAccessFile = new RandomAccessFile(name, "r"); @@ -63,8 +63,7 @@ public class SeekableFileInputStream extends SeekableInputStream { } /** - * Calls - * {@link RandomAccessFile#read(byte[],int,int) + * Calls null null null null null null null null null null null {@link RandomAccessFile#read(byte[],int,int) * randomAccessFile.read(buf, off, len)}. */ public int read(byte[] buf, int off, int len) throws IOException { diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/SeekableInputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/SeekableInputStream.java index 863cebb62..37256efbc 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/SeekableInputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/SeekableInputStream.java @@ -19,22 +19,21 @@ public abstract class SeekableInputStream extends InputStream { /** * Seeks n bytes forward in this stream. *

- * This will not seek past the end of the file. If the current position - * is already at or past the end of the file, this doesn't seek at all - * and returns 0. Otherwise, if skipping n bytes - * would cause the position to exceed the stream size, this will do - * equivalent of seek(length()) and the return value will - * be adjusted accordingly. + * This will not seek past the end of the file. If the current position is + * already at or past the end of the file, this doesn't seek at all and + * returns 0. Otherwise, if skipping n bytes would + * cause the position to exceed the stream size, this will do equivalent of + * seek(length()) and the return value will be adjusted + * accordingly. *

- * If n is negative, the position isn't changed and - * the return value is 0. It doesn't seek backward - * because it would conflict with the specification of + * If n is negative, the position isn't changed and the return + * value is 0. It doesn't seek backward because it would + * conflict with the specification of * {@link java.io.InputStream#skip(long) InputStream.skip}. * - * @return 0 if n is negative, - * less than n if skipping n - * bytes would seek past the end of the file, - * n otherwise + * @return 0 if n is negative, less than + * n if skipping n bytes would seek past the end + * of the file, n otherwise * * @throws IOException might be thrown by {@link #seek(long)} */ @@ -68,14 +67,14 @@ public abstract class SeekableInputStream extends InputStream { * Seeks to the specified absolute position in the stream. *

* Seeking past the end of the file should be supported by the subclasses - * unless there is a good reason to do otherwise. If one has seeked - * past the end of the stream, read will return - * -1 to indicate end of stream. + * unless there is a good reason to do otherwise. If one has seeked past the + * end of the stream, read will return -1 to + * indicate end of stream. * * @param pos new read position in the stream * - * @throws IOException if pos is negative or if - * a stream-specific I/O error occurs + * @throws IOException if pos is negative or if a + * stream-specific I/O error occurs */ public abstract void seek(long pos) throws IOException; } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/SeekableXZInputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/SeekableXZInputStream.java index 60ec21ef2..dc4504ad1 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/SeekableXZInputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/SeekableXZInputStream.java @@ -20,53 +20,52 @@ import org.tukaani.xz.index.IndexDecoder; import org.tukaani.xz.index.BlockInfo; /** - * Decompresses a .xz file in random access mode. - * This supports decompressing concatenated .xz files. + * Decompresses a .xz file in random access mode. This supports decompressing + * concatenated .xz files. *

- * Each .xz file consist of one or more Streams. Each Stream consist of zero - * or more Blocks. Each Stream contains an Index of Streams' Blocks. - * The Indexes from all Streams are loaded in RAM by a constructor of this - * class. A typical .xz file has only one Stream, and parsing its Index will - * need only three or four seeks. + * Each .xz file consist of one or more Streams. Each Stream consist of zero or + * more Blocks. Each Stream contains an Index of Streams' Blocks. The Indexes + * from all Streams are loaded in RAM by a constructor of this class. A typical + * .xz file has only one Stream, and parsing its Index will need only three or + * four seeks. *

- * To make random access possible, the data in a .xz file must be splitted - * into multiple Blocks of reasonable size. Decompression can only start at - * a Block boundary. When seeking to an uncompressed position that is not at - * a Block boundary, decompression starts at the beginning of the Block and - * throws away data until the target position is reached. Thus, smaller Blocks - * mean faster seeks to arbitrary uncompressed positions. On the other hand, - * smaller Blocks mean worse compression. So one has to make a compromise - * between random access speed and compression ratio. + * To make random access possible, the data in a .xz file must be splitted into + * multiple Blocks of reasonable size. Decompression can only start at a Block + * boundary. When seeking to an uncompressed position that is not at a Block + * boundary, decompression starts at the beginning of the Block and throws away + * data until the target position is reached. Thus, smaller Blocks mean faster + * seeks to arbitrary uncompressed positions. On the other hand, smaller Blocks + * mean worse compression. So one has to make a compromise between random access + * speed and compression ratio. *

* Implementation note: This class uses linear search to locate the correct - * Stream from the data structures in RAM. It was the simplest to implement - * and should be fine as long as there aren't too many Streams. The correct - * Block inside a Stream is located using binary search and thus is fast - * even with a huge number of Blocks. + * Stream from the data structures in RAM. It was the simplest to implement and + * should be fine as long as there aren't too many Streams. The correct Block + * inside a Stream is located using binary search and thus is fast even with a + * huge number of Blocks. * *

Memory usage

*

* The amount of memory needed for the Indexes is taken into account when - * checking the memory usage limit. Each Stream is calculated to need at - * least 1 KiB of memory and each Block 16 bytes of memory, rounded up - * to the next kibibyte. So unless the file has a huge number of Streams or - * Blocks, these don't take significant amount of memory. + * checking the memory usage limit. Each Stream is calculated to need at least + * 1 KiB of memory and each Block 16 bytes of memory, rounded up to the + * next kibibyte. So unless the file has a huge number of Streams or Blocks, + * these don't take significant amount of memory. * *

Creating random-accessible .xz files

*

- * When using {@link XZOutputStream}, a new Block can be started by calling - * its {@link XZOutputStream#endBlock() endBlock} method. If you know - * that the decompressor will only need to seek to certain uncompressed - * positions, it can be a good idea to start a new Block at (some of) these - * positions (and only at these positions to get better compression ratio). + * When using {@link XZOutputStream}, a new Block can be started by calling its + * {@link XZOutputStream#endBlock() endBlock} method. If you know that the + * decompressor will only need to seek to certain uncompressed positions, it can + * be a good idea to start a new Block at (some of) these positions (and only at + * these positions to get better compression ratio). *

* liblzma in XZ Utils supports starting a new Block with - * LZMA_FULL_FLUSH. XZ Utils 5.1.1alpha added threaded - * compression which creates multi-Block .xz files. XZ Utils 5.1.1alpha - * also added the option --block-size=SIZE to the xz command - * line tool. XZ Utils 5.1.2alpha added a partial implementation of - * --block-list=SIZES which allows specifying sizes of - * individual Blocks. + * LZMA_FULL_FLUSH. XZ Utils 5.1.1alpha added threaded compression + * which creates multi-Block .xz files. XZ Utils 5.1.1alpha also added the + * option --block-size=SIZE to the xz command line tool. XZ Utils + * 5.1.2alpha added a partial implementation of --block-list=SIZES + * which allows specifying sizes of individual Blocks. * * @see SeekableFileInputStream * @see XZInputStream @@ -80,22 +79,21 @@ public class SeekableXZInputStream extends SeekableInputStream { private SeekableInputStream in; /** - * Memory usage limit after the memory usage of the IndexDecoders have - * been substracted. + * Memory usage limit after the memory usage of the IndexDecoders have been + * substracted. */ private final int memoryLimit; /** * Memory usage of the IndexDecoders. - * memoryLimit + indexMemoryUsage equals the original - * memory usage limit that was passed to the constructor. + * memoryLimit + indexMemoryUsage equals the original memory + * usage limit that was passed to the constructor. */ private int indexMemoryUsage = 0; /** - * List of IndexDecoders, one for each Stream in the file. - * The list is in reverse order: The first element is - * the last Stream in the file. + * List of IndexDecoders, one for each Stream in the file. The list is in + * reverse order: The first element is the last Stream in the file. */ private final ArrayList streams = new ArrayList(); @@ -120,20 +118,20 @@ public class SeekableXZInputStream extends SeekableInputStream { private int blockCount = 0; /** - * Size and position information about the current Block. - * If there are no Blocks, all values will be -1. + * Size and position information about the current Block. If there are no + * Blocks, all values will be -1. */ private final BlockInfo curBlockInfo; /** - * Temporary (and cached) information about the Block whose information - * is queried via getBlockPos and related functions. + * Temporary (and cached) information about the Block whose information is + * queried via getBlockPos and related functions. */ private final BlockInfo queriedBlockInfo; /** - * Integrity Check in the current XZ Stream. The constructor leaves - * this to point to the Check of the first Stream. + * Integrity Check in the current XZ Stream. The constructor leaves this to + * point to the Check of the first Stream. */ private Check check; @@ -153,14 +151,14 @@ public class SeekableXZInputStream extends SeekableInputStream { private long seekPos; /** - * True when seek(long) has been called but the actual - * seeking hasn't been done yet. + * True when seek(long) has been called but the actual seeking + * hasn't been done yet. */ private boolean seekNeeded = false; /** - * True when end of the file was reached. This can be cleared by - * calling seek(long). + * True when end of the file was reached. This can be cleared by calling + * seek(long). */ private boolean endReached = false; @@ -170,75 +168,67 @@ public class SeekableXZInputStream extends SeekableInputStream { private IOException exception = null; /** - * Temporary buffer for read(). This avoids reallocating memory - * on every read() call. + * Temporary buffer for read(). This avoids reallocating memory on every + * read() call. */ private final byte[] tempBuf = new byte[1]; /** * Creates a new seekable XZ decompressor without a memory usage limit. * - * @param in seekable input stream containing one or more - * XZ Streams; the whole input stream is used + * @param in seekable input stream containing one or more XZ Streams; the + * whole input stream is used * - * @throws XZFormatException - * input is not in the XZ format + * @throws XZFormatException input is not in the XZ format * - * @throws CorruptedInputException - * XZ data is corrupt or truncated + * @throws CorruptedInputException XZ data is corrupt or truncated * - * @throws UnsupportedOptionsException - * XZ headers seem valid but they specify - * options not supported by this implementation + * @throws UnsupportedOptionsException XZ headers seem valid but they + * specify options not supported by this implementation * - * @throws EOFException - * less than 6 bytes of input was available - * from in, or (unlikely) the size - * of the underlying stream got smaller while - * this was reading from it + * @throws EOFException less than 6 bytes of input was + * available from + * in, or (unlikely) the size of the underlying stream got + * smaller while this was reading from it * * @throws IOException may be thrown by in */ public SeekableXZInputStream(SeekableInputStream in) - throws IOException { + throws IOException { this(in, -1); } /** - * Creates a new seekable XZ decomporessor with an optional - * memory usage limit. + * Creates a new seekable XZ decomporessor with an optional memory usage + * limit. * - * @param in seekable input stream containing one or more - * XZ Streams; the whole input stream is used + * @param in seekable input stream containing one or more XZ + * Streams; the + * whole input stream is used * - * @param memoryLimit memory usage limit in kibibytes (KiB) - * or -1 to impose no - * memory usage limit + * @param memoryLimit memory usage limit in kibibytes (KiB) or + * -1 to impose no memory usage limit * - * @throws XZFormatException - * input is not in the XZ format + * @throws XZFormatException input is not in the XZ format * - * @throws CorruptedInputException - * XZ data is corrupt or truncated + * @throws CorruptedInputException XZ data is corrupt or truncated * - * @throws UnsupportedOptionsException - * XZ headers seem valid but they specify - * options not supported by this implementation + * @throws UnsupportedOptionsException XZ headers seem valid but they + * specify options not supported by this implementation * - * @throws MemoryLimitException - * decoded XZ Indexes would need more memory + * @throws MemoryLimitException decoded XZ Indexes would need more + * memory * than allowed by the memory usage limit * - * @throws EOFException - * less than 6 bytes of input was available - * from in, or (unlikely) the size - * of the underlying stream got smaller while - * this was reading from it + * @throws EOFException less than 6 bytes of input was + * available from + * in, or (unlikely) the size of the underlying stream got + * smaller while this was reading from it * * @throws IOException may be thrown by in */ public SeekableXZInputStream(SeekableInputStream in, int memoryLimit) - throws IOException { + throws IOException { this.in = in; DataInputStream inData = new DataInputStream(in); @@ -255,7 +245,7 @@ public class SeekableXZInputStream extends SeekableInputStream { long pos = in.length(); if ((pos & 3) != 0) throw new CorruptedInputException( - "XZ file size is not a multiple of 4 bytes"); + "XZ file size is not a multiple of 4 bytes"); // Parse the headers starting from the end of the file. byte[] buf = new byte[DecoderUtil.STREAM_HEADER_SIZE]; @@ -287,7 +277,7 @@ public class SeekableXZInputStream extends SeekableInputStream { StreamFlags streamFooter = DecoderUtil.decodeStreamFooter(buf); if (streamFooter.backwardSize >= pos) throw new CorruptedInputException( - "Backward Size in XZ Stream Footer is too big"); + "Backward Size in XZ Stream Footer is too big"); // Check that the Check ID is supported. Store it in case this // is the first Stream in the file. @@ -309,8 +299,8 @@ public class SeekableXZInputStream extends SeekableInputStream { // already needed so we need to recreate the exception. assert memoryLimit >= 0; throw new MemoryLimitException( - e.getMemoryNeeded() + indexMemoryUsage, - memoryLimit + indexMemoryUsage); + e.getMemoryNeeded() + indexMemoryUsage, + memoryLimit + indexMemoryUsage); } // Update the memory usage and limit counters. @@ -342,7 +332,7 @@ public class SeekableXZInputStream extends SeekableInputStream { // Verify that the Stream Header matches the Stream Footer. if (!DecoderUtil.areStreamFlagsEqual(streamHeader, streamFooter)) throw new CorruptedInputException( - "XZ Stream Footer does not match Stream Header"); + "XZ Stream Footer does not match Stream Header"); // Update the total uncompressed size of the file and check that // it doesn't overflow. @@ -354,7 +344,7 @@ public class SeekableXZInputStream extends SeekableInputStream { blockCount += index.getRecordCount(); if (blockCount < 0) throw new UnsupportedOptionsException( - "XZ file has over " + Integer.MAX_VALUE + " Blocks"); + "XZ file has over " + Integer.MAX_VALUE + " Blocks"); // Add this Stream to the list of Streams. streams.add(index); @@ -391,13 +381,11 @@ public class SeekableXZInputStream extends SeekableInputStream { } /** - * Gets the types of integrity checks used in the .xz file. - * Multiple checks are possible only if there are multiple - * concatenated XZ Streams. + * Gets the types of integrity checks used in the .xz file. Multiple checks + * are possible only if there are multiple concatenated XZ Streams. *

* The returned value has a bit set for every check type that is present. - * For example, if CRC64 and SHA-256 were used, the return value is - * (1 << XZ.CHECK_CRC64) + * For example, if CRC64 and SHA-256 were used, the return value is (1 << XZ.CHECK_CRC64) * | (1 << XZ.CHECK_SHA256). */ public int getCheckTypes() { @@ -405,22 +393,21 @@ public class SeekableXZInputStream extends SeekableInputStream { } /** - * Gets the amount of memory in kibibytes (KiB) used by - * the data structures needed to locate the XZ Blocks. - * This is usually useless information but since it is calculated - * for memory usage limit anyway, it is nice to make it available to too. + * Gets the amount of memory in kibibytes (KiB) used by the data structures + * needed to locate the XZ Blocks. This is usually useless information but + * since it is calculated for memory usage limit anyway, it is nice to make + * it available to too. */ public int getIndexMemoryUsage() { return indexMemoryUsage; } /** - * Gets the uncompressed size of the largest XZ Block in bytes. - * This can be useful if you want to check that the file doesn't - * have huge XZ Blocks which could make seeking to arbitrary offsets - * very slow. Note that huge Blocks don't automatically mean that - * seeking would be slow, for example, seeking to the beginning of - * any Block is always fast. + * Gets the uncompressed size of the largest XZ Block in bytes. This can be + * useful if you want to check that the file doesn't have huge XZ Blocks + * which could make seeking to arbitrary offsets very slow. Note that huge + * Blocks don't automatically mean that seeking would be slow, for example, + * seeking to the beginning of any Block is always fast. */ public long getLargestBlockSize() { return largestBlockSize; @@ -473,9 +460,9 @@ public class SeekableXZInputStream extends SeekableInputStream { } /** - * Gets the position where the given compressed Block starts in - * the underlying .xz file. - * This information is rarely useful to the users of this class. + * Gets the position where the given compressed Block starts in the + * underlying .xz file. This information is rarely useful to the users of + * this class. * * @throws IndexOutOfBoundsException if * blockNumber < 0 or @@ -489,9 +476,9 @@ public class SeekableXZInputStream extends SeekableInputStream { } /** - * Gets the compressed size of the given Block. - * This together with the uncompressed size can be used to calculate - * the compression ratio of the specific Block. + * Gets the compressed size of the given Block. This together with the + * uncompressed size can be used to calculate the compression ratio of the + * specific Block. * * @throws IndexOutOfBoundsException if * blockNumber < 0 or @@ -524,8 +511,7 @@ public class SeekableXZInputStream extends SeekableInputStream { * Gets the number of the Block that contains the byte at the given * uncompressed position. * - * @throws IndexOutOfBoundsException if - * pos < 0 or + * @throws IndexOutOfBoundsException if pos < 0 or * pos >= length(). * * @since 1.3 @@ -538,8 +524,8 @@ public class SeekableXZInputStream extends SeekableInputStream { /** * Decompresses the next byte from this input stream. * - * @return the next decompressed byte, or -1 - * to indicate the end of the compressed stream + * @return the next decompressed byte, or -1 to indicate the + * end of the compressed stream * * @throws CorruptedInputException * @throws UnsupportedOptionsException @@ -556,16 +542,16 @@ public class SeekableXZInputStream extends SeekableInputStream { /** * Decompresses into an array of bytes. *

- * If len is zero, no bytes are read and 0 - * is returned. Otherwise this will try to decompress len - * bytes of uncompressed data. Less than len bytes may - * be read only in the following situations: + * If len is zero, no bytes are read and 0 is + * returned. Otherwise this will try to decompress len bytes of + * uncompressed data. Less than len bytes may be read only in + * the following situations: *

    *
  • The end of the compressed data was reached successfully.
  • *
  • An error is detected after at least one but less than - * len bytes have already been successfully - * decompressed. The next call with non-zero len - * will immediately throw the pending exception.
  • + * len bytes have already been successfully decompressed. The + * next call with non-zero len will immediately throw the + * pending exception. *
  • An exception is thrown.
  • *
* @@ -573,8 +559,8 @@ public class SeekableXZInputStream extends SeekableInputStream { * @param off start offset in buf * @param len maximum number of uncompressed bytes to read * - * @return number of bytes read, or -1 to indicate - * the end of the compressed stream + * @return number of bytes read, or -1 to indicate the end of + * the compressed stream * * @throws CorruptedInputException * @throws UnsupportedOptionsException @@ -639,15 +625,14 @@ public class SeekableXZInputStream extends SeekableInputStream { } /** - * Returns the number of uncompressed bytes that can be read - * without blocking. The value is returned with an assumption - * that the compressed input data will be valid. If the compressed - * data is corrupt, CorruptedInputException may get - * thrown before the number of bytes claimed to be available have - * been read from this input stream. + * Returns the number of uncompressed bytes that can be read without + * blocking. The value is returned with an assumption that the compressed + * input data will be valid. If the compressed data is corrupt, + * CorruptedInputException may get thrown before the number of + * bytes claimed to be available have been read from this input stream. * - * @return the number of uncompressed bytes that can be read - * without blocking + * @return the number of uncompressed bytes that can be read without + * blocking */ public int available() throws IOException { if (in == null) @@ -663,8 +648,8 @@ public class SeekableXZInputStream extends SeekableInputStream { } /** - * Closes the stream and calls in.close(). - * If the stream was already closed, this does nothing. + * Closes the stream and calls in.close(). If the stream was + * already closed, this does nothing. * * @throws IOException if thrown by in.close() */ @@ -678,8 +663,8 @@ public class SeekableXZInputStream extends SeekableInputStream { } /** - * Gets the uncompressed size of this input stream. If there are multiple - * XZ Streams, the total uncompressed size of all XZ Streams is returned. + * Gets the uncompressed size of this input stream. If there are multiple XZ + * Streams, the total uncompressed size of all XZ Streams is returned. */ public long length() { return uncompressedSize; @@ -698,20 +683,19 @@ public class SeekableXZInputStream extends SeekableInputStream { } /** - * Seeks to the specified absolute uncompressed position in the stream. - * This only stores the new position, so this function itself is always - * very fast. The actual seek is done when read is called - * to read at least one byte. + * Seeks to the specified absolute uncompressed position in the stream. This + * only stores the new position, so this function itself is always very + * fast. The actual seek is done when read is called to read at + * least one byte. *

* Seeking past the end of the stream is possible. In that case - * read will return -1 to indicate - * the end of the stream. + * read will return -1 to indicate the end of the + * stream. * * @param pos new uncompressed read position * - * @throws XZIOException - * if pos is negative, or - * if stream has been closed + * @throws XZIOException if pos is negative, or if stream has + * been closed */ public void seek(long pos) throws IOException { if (in == null) @@ -727,10 +711,9 @@ public class SeekableXZInputStream extends SeekableInputStream { /** * Seeks to the beginning of the given XZ Block. * - * @throws XZIOException - * if blockNumber < 0 or - * blockNumber >= getBlockCount(), - * or if stream has been closed + * @throws XZIOException if blockNumber < 0 or + * blockNumber >= getBlockCount(), or if stream + * has been closed * * @since 1.3 */ @@ -749,8 +732,8 @@ public class SeekableXZInputStream extends SeekableInputStream { } /** - * Does the actual seeking. This is also called when read - * needs a new Block to decode. + * Does the actual seeking. This is also called when read needs + * a new Block to decode. */ private void seek() throws IOException { // If seek(long) wasn't called, we simply need to get the next Block @@ -824,7 +807,7 @@ public class SeekableXZInputStream extends SeekableInputStream { private void locateBlockByPos(BlockInfo info, long pos) { if (pos < 0 || pos >= uncompressedSize) throw new IndexOutOfBoundsException( - "Invalid uncompressed position: " + pos); + "Invalid uncompressed position: " + pos); // Locate the Stream that contains the target position. IndexDecoder index; @@ -844,14 +827,14 @@ public class SeekableXZInputStream extends SeekableInputStream { } /** - * Locates the given Block and stores information about it - * to info. + * Locates the given Block and stores information about it to + * info. */ private void locateBlockByNumber(BlockInfo info, int blockNumber) { // Validate. if (blockNumber < 0 || blockNumber >= blockCount) throw new IndexOutOfBoundsException( - "Invalid XZ Block number: " + blockNumber); + "Invalid XZ Block number: " + blockNumber); // Skip the search if info already points to the correct Block. if (info.blockNumber == blockNumber) @@ -884,8 +867,8 @@ public class SeekableXZInputStream extends SeekableInputStream { // already needed so we need to recreate the exception. assert memoryLimit >= 0; throw new MemoryLimitException( - e.getMemoryNeeded() + indexMemoryUsage, - memoryLimit + indexMemoryUsage); + e.getMemoryNeeded() + indexMemoryUsage, + memoryLimit + indexMemoryUsage); } catch (IndexIndicatorException e) { // It cannot be Index so the file must be corrupt. throw new CorruptedInputException(); diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/SingleXZInputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/SingleXZInputStream.java index 6f05bcf93..29dc3f324 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/SingleXZInputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/SingleXZInputStream.java @@ -18,11 +18,11 @@ import org.tukaani.xz.index.IndexHash; import org.tukaani.xz.check.Check; /** - * Decompresses exactly one XZ Stream in streamed mode (no seeking). - * The decompression stops after the first XZ Stream has been decompressed, - * and the read position in the input stream is left at the first byte - * after the end of the XZ Stream. This can be useful when XZ data has - * been stored inside some other file format or protocol. + * Decompresses exactly one XZ Stream in streamed mode (no seeking). The + * decompression stops after the first XZ Stream has been decompressed, and the + * read position in the input stream is left at the first byte after the end of + * the XZ Stream. This can be useful when XZ data has been stored inside some + * other file format or protocol. *

* Unless you know what you are doing, don't use this class to decompress * standalone .xz files. For that purpose, use XZInputStream. @@ -30,11 +30,11 @@ import org.tukaani.xz.check.Check; *

When uncompressed size is known beforehand

*

* If you are decompressing complete XZ streams and your application knows - * exactly how much uncompressed data there should be, it is good to try - * reading one more byte by calling read() and checking - * that it returns -1. This way the decompressor will parse the - * file footers and verify the integrity checks, giving the caller more - * confidence that the uncompressed data is valid. + * exactly how much uncompressed data there should be, it is good to try reading + * one more byte by calling read() and checking that it returns + * -1. This way the decompressor will parse the file footers and + * verify the integrity checks, giving the caller more confidence that the + * uncompressed data is valid. * * @see XZInputStream */ @@ -52,29 +52,25 @@ public class SingleXZInputStream extends InputStream { private final byte[] tempBuf = new byte[1]; /** - * Creates a new XZ decompressor that decompresses exactly one - * XZ Stream from in without a memory usage limit. + * Creates a new XZ decompressor that decompresses exactly one XZ Stream + * from in without a memory usage limit. *

- * This constructor reads and parses the XZ Stream Header (12 bytes) - * from in. The header of the first Block is not read - * until read is called. + * This constructor reads and parses the XZ Stream Header (12 bytes) from + * in. The header of the first Block is not read until + * read is called. * - * @param in input stream from which XZ-compressed - * data is read + * @param in input stream from which XZ-compressed data is read * - * @throws XZFormatException - * input is not in the XZ format + * @throws XZFormatException input is not in the XZ format * - * @throws CorruptedInputException - * XZ header CRC32 doesn't match + * @throws CorruptedInputException XZ header CRC32 doesn't match * - * @throws UnsupportedOptionsException - * XZ header is valid but specifies options - * not supported by this implementation + * @throws UnsupportedOptionsException XZ header is valid but specifies + * options not supported by this implementation * - * @throws EOFException - * less than 12 bytes of input was available - * from in + * @throws EOFException less than 12 bytes of input was + * available from + * in * * @throws IOException may be thrown by in */ @@ -83,37 +79,32 @@ public class SingleXZInputStream extends InputStream { } /** - * Creates a new XZ decompressor that decompresses exactly one - * XZ Stream from in with an optional memory usage limit. + * Creates a new XZ decompressor that decompresses exactly one XZ Stream + * from in with an optional memory usage limit. *

- * This is identical to SingleXZInputStream(InputStream) - * except that this takes also the memoryLimit argument. + * This is identical to SingleXZInputStream(InputStream) except + * that this takes also the memoryLimit argument. * - * @param in input stream from which XZ-compressed - * data is read + * @param in input stream from which XZ-compressed data is read * - * @param memoryLimit memory usage limit in kibibytes (KiB) - * or -1 to impose no - * memory usage limit + * @param memoryLimit memory usage limit in kibibytes (KiB) or + * -1 to impose no memory usage limit * - * @throws XZFormatException - * input is not in the XZ format + * @throws XZFormatException input is not in the XZ format * - * @throws CorruptedInputException - * XZ header CRC32 doesn't match + * @throws CorruptedInputException XZ header CRC32 doesn't match * - * @throws UnsupportedOptionsException - * XZ header is valid but specifies options - * not supported by this implementation + * @throws UnsupportedOptionsException XZ header is valid but specifies + * options not supported by this implementation * - * @throws EOFException - * less than 12 bytes of input was available - * from in + * @throws EOFException less than 12 bytes of input was + * available from + * in * * @throws IOException may be thrown by in */ public SingleXZInputStream(InputStream in, int memoryLimit) - throws IOException { + throws IOException { initialize(in, memoryLimit); } @@ -123,7 +114,7 @@ public class SingleXZInputStream extends InputStream { } private void initialize(InputStream in, int memoryLimit) - throws IOException { + throws IOException { byte[] streamHeader = new byte[DecoderUtil.STREAM_HEADER_SIZE]; new DataInputStream(in).readFully(streamHeader); initialize(in, memoryLimit, streamHeader); @@ -158,12 +149,12 @@ public class SingleXZInputStream extends InputStream { /** * Decompresses the next byte from this input stream. *

- * Reading lots of data with read() from this input stream - * may be inefficient. Wrap it in {@link java.io.BufferedInputStream} - * if you need to read lots of data one byte at a time. + * Reading lots of data with read() from this input stream may + * be inefficient. Wrap it in {@link java.io.BufferedInputStream} if you + * need to read lots of data one byte at a time. * - * @return the next decompressed byte, or -1 - * to indicate the end of the compressed stream + * @return the next decompressed byte, or -1 to indicate the + * end of the compressed stream * * @throws CorruptedInputException * @throws UnsupportedOptionsException @@ -171,8 +162,8 @@ public class SingleXZInputStream extends InputStream { * * @throws XZIOException if the stream has been closed * - * @throws EOFException - * compressed input is truncated or corrupt + * @throws EOFException compressed input is truncated or + * corrupt * * @throws IOException may be thrown by in */ @@ -183,16 +174,16 @@ public class SingleXZInputStream extends InputStream { /** * Decompresses into an array of bytes. *

- * If len is zero, no bytes are read and 0 - * is returned. Otherwise this will try to decompress len - * bytes of uncompressed data. Less than len bytes may - * be read only in the following situations: + * If len is zero, no bytes are read and 0 is + * returned. Otherwise this will try to decompress len bytes of + * uncompressed data. Less than len bytes may be read only in + * the following situations: *

    *
  • The end of the compressed data was reached successfully.
  • *
  • An error is detected after at least one but less len - * bytes have already been successfully decompressed. - * The next call with non-zero len will immediately - * throw the pending exception.
  • + * bytes have already been successfully decompressed. The next call with + * non-zero len will immediately throw the pending + * exception. *
  • An exception is thrown.
  • *
* @@ -200,8 +191,8 @@ public class SingleXZInputStream extends InputStream { * @param off start offset in buf * @param len maximum number of uncompressed bytes to read * - * @return number of bytes read, or -1 to indicate - * the end of the compressed stream + * @return number of bytes read, or -1 to indicate the end of + * the compressed stream * * @throws CorruptedInputException * @throws UnsupportedOptionsException @@ -209,8 +200,8 @@ public class SingleXZInputStream extends InputStream { * * @throws XZIOException if the stream has been closed * - * @throws EOFException - * compressed input is truncated or corrupt + * @throws EOFException compressed input is truncated or + * corrupt * * @throws IOException may be thrown by in */ @@ -237,7 +228,7 @@ public class SingleXZInputStream extends InputStream { if (blockDecoder == null) try { blockDecoder = new BlockInputStream( - in, check, memoryLimit, -1, -1); + in, check, memoryLimit, -1, -1); } catch (IndexIndicatorException e) { indexHash.validate(in); validateStreamFooter(); @@ -275,19 +266,18 @@ public class SingleXZInputStream extends InputStream { streamFooterFlags) || indexHash.getIndexSize() != streamFooterFlags.backwardSize) throw new CorruptedInputException( - "XZ Stream Footer does not match Stream Header"); + "XZ Stream Footer does not match Stream Header"); } /** - * Returns the number of uncompressed bytes that can be read - * without blocking. The value is returned with an assumption - * that the compressed input data will be valid. If the compressed - * data is corrupt, CorruptedInputException may get - * thrown before the number of bytes claimed to be available have - * been read from this input stream. + * Returns the number of uncompressed bytes that can be read without + * blocking. The value is returned with an assumption that the compressed + * input data will be valid. If the compressed data is corrupt, + * CorruptedInputException may get thrown before the number of + * bytes claimed to be available have been read from this input stream. * - * @return the number of uncompressed bytes that can be read - * without blocking + * @return the number of uncompressed bytes that can be read without + * blocking */ public int available() throws IOException { if (in == null) @@ -300,8 +290,8 @@ public class SingleXZInputStream extends InputStream { } /** - * Closes the stream and calls in.close(). - * If the stream was already closed, this does nothing. + * Closes the stream and calls in.close(). If the stream was + * already closed, this does nothing. * * @throws IOException if thrown by in.close() */ diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/UnsupportedOptionsException.java b/HMCLAPI/src/main/java/org/tukaani/xz/UnsupportedOptionsException.java index 5acf1cf4c..8a20396fa 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/UnsupportedOptionsException.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/UnsupportedOptionsException.java @@ -9,23 +9,23 @@ package org.tukaani.xz; /** - * Thrown when compression options not supported by this implementation - * are detected. Some other implementation might support those options. + * Thrown when compression options not supported by this implementation are + * detected. Some other implementation might support those options. */ public class UnsupportedOptionsException extends XZIOException { private static final long serialVersionUID = 3L; /** - * Creates a new UnsupportedOptionsException with null - * as its error detail message. + * Creates a new UnsupportedOptionsException with null as its error detail + * message. */ public UnsupportedOptionsException() { } /** - * Creates a new UnsupportedOptionsException with the given - * error detail message. + * Creates a new UnsupportedOptionsException with the given error detail + * message. * * @param s error detail message */ diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/XZ.java b/HMCLAPI/src/main/java/org/tukaani/xz/XZ.java index 261b12285..4ef56539e 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/XZ.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/XZ.java @@ -14,23 +14,23 @@ package org.tukaani.xz; public class XZ { /** - * XZ Header Magic Bytes begin a XZ file. - * This can be useful to detect XZ compressed data. + * XZ Header Magic Bytes begin a XZ file. This can be useful to detect XZ + * compressed data. */ public static final byte[] HEADER_MAGIC = { - (byte) 0xFD, '7', 'z', 'X', 'Z', '\0'}; + (byte) 0xFD, '7', 'z', 'X', 'Z', '\0' }; /** * XZ Footer Magic Bytes are the last bytes of a XZ Stream. */ - public static final byte[] FOOTER_MAGIC = {'Y', 'Z'}; + public static final byte[] FOOTER_MAGIC = { 'Y', 'Z' }; /** * Integrity check ID indicating that no integrity check is calculated. *

- * Omitting the integrity check is strongly discouraged except when - * the integrity of the data will be verified by other means anyway, - * and calculating the check twice would be useless. + * Omitting the integrity check is strongly discouraged except when the + * integrity of the data will be verified by other means anyway, and + * calculating the check twice would be useless. */ public static final int CHECK_NONE = 0; diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/XZIOException.java b/HMCLAPI/src/main/java/org/tukaani/xz/XZIOException.java index 7ad5743ab..701147b1b 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/XZIOException.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/XZIOException.java @@ -9,9 +9,8 @@ package org.tukaani.xz; /** - * Generic {@link java.io.IOException IOException} specific to this package. - * The other IOExceptions in this package extend - * from XZIOException. + * Generic {@link java.io.IOException IOException} specific to this package. The + * other IOExceptions in this package extend from XZIOException. */ public class XZIOException extends java.io.IOException { diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/XZInputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/XZInputStream.java index b96c7b723..3737485cf 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/XZInputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/XZInputStream.java @@ -17,9 +17,9 @@ import org.tukaani.xz.common.DecoderUtil; /** * Decompresses a .xz file in streamed mode (no seeking). *

- * Use this to decompress regular standalone .xz files. This reads from - * its input stream until the end of the input or until an error occurs. - * This supports decompressing concatenated .xz files. + * Use this to decompress regular standalone .xz files. This reads from its + * input stream until the end of the input or until an error occurs. This + * supports decompressing concatenated .xz files. * *

Typical use cases

*

@@ -30,18 +30,18 @@ import org.tukaani.xz.common.DecoderUtil; * XZInputStream inxz = new XZInputStream(infile); * *

- * It's important to keep in mind that decompressor memory usage depends - * on the settings used to compress the file. The worst-case memory usage - * of XZInputStream is currently 1.5 GiB. Still, very few files will - * require more than about 65 MiB because that's how much decompressing - * a file created with the highest preset level will need, and only a few - * people use settings other than the predefined presets. + * It's important to keep in mind that decompressor memory usage depends on the + * settings used to compress the file. The worst-case memory usage of + * XZInputStream is currently 1.5 GiB. Still, very few files will require + * more than about 65 MiB because that's how much decompressing a file + * created with the highest preset level will need, and only a few people use + * settings other than the predefined presets. *

* It is possible to specify a memory usage limit for - * XZInputStream. If decompression requires more memory than - * the specified limit, MemoryLimitException will be thrown when reading - * from the stream. For example, the following sets the memory usage limit - * to 100 MiB: + * XZInputStream. If decompression requires more memory than the + * specified limit, MemoryLimitException will be thrown when reading from the + * stream. For example, the following sets the memory usage limit to + * 100 MiB: *

*

  * InputStream infile = new FileInputStream("foo.xz");
@@ -50,13 +50,12 @@ import org.tukaani.xz.common.DecoderUtil;
  *
  * 

When uncompressed size is known beforehand

*

- * If you are decompressing complete files and your application knows - * exactly how much uncompressed data there should be, it is good to try - * reading one more byte by calling read() and checking - * that it returns -1. This way the decompressor will parse the - * file footers and verify the integrity checks, giving the caller more - * confidence that the uncompressed data is valid. (This advice seems to - * apply to + * If you are decompressing complete files and your application knows exactly + * how much uncompressed data there should be, it is good to try reading one + * more byte by calling read() and checking that it returns + * -1. This way the decompressor will parse the file footers and + * verify the integrity checks, giving the caller more confidence that the + * uncompressed data is valid. (This advice seems to apply to * {@link java.util.zip.GZIPInputStream java.util.zip.GZIPInputStream} too.) * * @see SingleXZInputStream @@ -74,26 +73,22 @@ public class XZInputStream extends InputStream { /** * Creates a new XZ decompressor without a memory usage limit. *

- * This constructor reads and parses the XZ Stream Header (12 bytes) - * from in. The header of the first Block is not read - * until read is called. + * This constructor reads and parses the XZ Stream Header (12 bytes) from + * in. The header of the first Block is not read until + * read is called. * - * @param in input stream from which XZ-compressed - * data is read + * @param in input stream from which XZ-compressed data is read * - * @throws XZFormatException - * input is not in the XZ format + * @throws XZFormatException input is not in the XZ format * - * @throws CorruptedInputException - * XZ header CRC32 doesn't match + * @throws CorruptedInputException XZ header CRC32 doesn't match * - * @throws UnsupportedOptionsException - * XZ header is valid but specifies options - * not supported by this implementation + * @throws UnsupportedOptionsException XZ header is valid but specifies + * options not supported by this implementation * - * @throws EOFException - * less than 12 bytes of input was available - * from in + * @throws EOFException less than 12 bytes of input was + * available from + * in * * @throws IOException may be thrown by in */ @@ -104,29 +99,24 @@ public class XZInputStream extends InputStream { /** * Creates a new XZ decompressor with an optional memory usage limit. *

- * This is identical to XZInputStream(InputStream) except - * that this takes also the memoryLimit argument. + * This is identical to XZInputStream(InputStream) except that + * this takes also the memoryLimit argument. * - * @param in input stream from which XZ-compressed - * data is read + * @param in input stream from which XZ-compressed data is read * - * @param memoryLimit memory usage limit in kibibytes (KiB) - * or -1 to impose no - * memory usage limit + * @param memoryLimit memory usage limit in kibibytes (KiB) or + * -1 to impose no memory usage limit * - * @throws XZFormatException - * input is not in the XZ format + * @throws XZFormatException input is not in the XZ format * - * @throws CorruptedInputException - * XZ header CRC32 doesn't match + * @throws CorruptedInputException XZ header CRC32 doesn't match * - * @throws UnsupportedOptionsException - * XZ header is valid but specifies options - * not supported by this implementation + * @throws UnsupportedOptionsException XZ header is valid but specifies + * options not supported by this implementation * - * @throws EOFException - * less than 12 bytes of input was available - * from in + * @throws EOFException less than 12 bytes of input was + * available from + * in * * @throws IOException may be thrown by in */ @@ -139,12 +129,12 @@ public class XZInputStream extends InputStream { /** * Decompresses the next byte from this input stream. *

- * Reading lots of data with read() from this input stream - * may be inefficient. Wrap it in {@link java.io.BufferedInputStream} - * if you need to read lots of data one byte at a time. + * Reading lots of data with read() from this input stream may + * be inefficient. Wrap it in {@link java.io.BufferedInputStream} if you + * need to read lots of data one byte at a time. * - * @return the next decompressed byte, or -1 - * to indicate the end of the compressed stream + * @return the next decompressed byte, or -1 to indicate the + * end of the compressed stream * * @throws CorruptedInputException * @throws UnsupportedOptionsException @@ -152,8 +142,8 @@ public class XZInputStream extends InputStream { * * @throws XZIOException if the stream has been closed * - * @throws EOFException - * compressed input is truncated or corrupt + * @throws EOFException compressed input is truncated or + * corrupt * * @throws IOException may be thrown by in */ @@ -164,16 +154,16 @@ public class XZInputStream extends InputStream { /** * Decompresses into an array of bytes. *

- * If len is zero, no bytes are read and 0 - * is returned. Otherwise this will try to decompress len - * bytes of uncompressed data. Less than len bytes may - * be read only in the following situations: + * If len is zero, no bytes are read and 0 is + * returned. Otherwise this will try to decompress len bytes of + * uncompressed data. Less than len bytes may be read only in + * the following situations: *

    *
  • The end of the compressed data was reached successfully.
  • *
  • An error is detected after at least one but less len - * bytes have already been successfully decompressed. - * The next call with non-zero len will immediately - * throw the pending exception.
  • + * bytes have already been successfully decompressed. The next call with + * non-zero len will immediately throw the pending + * exception. *
  • An exception is thrown.
  • *
* @@ -181,8 +171,8 @@ public class XZInputStream extends InputStream { * @param off start offset in buf * @param len maximum number of uncompressed bytes to read * - * @return number of bytes read, or -1 to indicate - * the end of the compressed stream + * @return number of bytes read, or -1 to indicate the end of + * the compressed stream * * @throws CorruptedInputException * @throws UnsupportedOptionsException @@ -190,8 +180,8 @@ public class XZInputStream extends InputStream { * * @throws XZIOException if the stream has been closed * - * @throws EOFException - * compressed input is truncated or corrupt + * @throws EOFException compressed input is truncated or + * corrupt * * @throws IOException may be thrown by in */ @@ -271,20 +261,19 @@ public class XZInputStream extends InputStream { // Since this isn't the first .xz Stream, it is more // logical to tell that the data is corrupt. throw new CorruptedInputException( - "Garbage after a valid XZ Stream"); + "Garbage after a valid XZ Stream"); } } /** - * Returns the number of uncompressed bytes that can be read - * without blocking. The value is returned with an assumption - * that the compressed input data will be valid. If the compressed - * data is corrupt, CorruptedInputException may get - * thrown before the number of bytes claimed to be available have - * been read from this input stream. + * Returns the number of uncompressed bytes that can be read without + * blocking. The value is returned with an assumption that the compressed + * input data will be valid. If the compressed data is corrupt, + * CorruptedInputException may get thrown before the number of + * bytes claimed to be available have been read from this input stream. * - * @return the number of uncompressed bytes that can be read - * without blocking + * @return the number of uncompressed bytes that can be read without + * blocking */ public int available() throws IOException { if (in == null) @@ -297,8 +286,8 @@ public class XZInputStream extends InputStream { } /** - * Closes the stream and calls in.close(). - * If the stream was already closed, this does nothing. + * Closes the stream and calls in.close(). If the stream was + * already closed, this does nothing. * * @throws IOException if thrown by in.close() */ diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/XZOutputStream.java b/HMCLAPI/src/main/java/org/tukaani/xz/XZOutputStream.java index fbc18114d..99dcbddcd 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/XZOutputStream.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/XZOutputStream.java @@ -20,25 +20,24 @@ import org.tukaani.xz.index.IndexEncoder; * *

Examples

*

- * Getting an output stream to compress with LZMA2 using the default - * settings and the default integrity check type (CRC64): + * Getting an output stream to compress with LZMA2 using the default settings + * and the default integrity check type (CRC64): *

*

  * FileOutputStream outfile = new FileOutputStream("foo.xz");
  * XZOutputStream outxz = new XZOutputStream(outfile, new LZMA2Options());
  * 
*

- * Using the preset level 8 for LZMA2 (the default - * is 6) and SHA-256 instead of CRC64 for integrity checking: + * Using the preset level 8 for LZMA2 (the default is + * 6) and SHA-256 instead of CRC64 for integrity checking: *

*

  * XZOutputStream outxz = new XZOutputStream(outfile, new LZMA2Options(8),
  *                                           XZ.CHECK_SHA256);
  * 
*

- * Using the x86 BCJ filter together with LZMA2 to compress x86 executables - * and printing the memory usage information before creating the - * XZOutputStream: + * Using the x86 BCJ filter together with LZMA2 to compress x86 executables and + * printing the memory usage information before creating the XZOutputStream: *

*

  * X86Options x86 = new X86Options();
@@ -64,9 +63,9 @@ public class XZOutputStream extends FinishableOutputStream {
     private FilterEncoder[] filters;
 
     /**
-     * True if the current filter chain supports flushing.
-     * If it doesn't support flushing, flush()
-     * will use endBlock() as a fallback.
+     * True if the current filter chain supports flushing. If it doesn't support
+     * flushing, flush() will use endBlock() as a
+     * fallback.
      */
     private boolean filtersSupportFlushing;
 
@@ -76,88 +75,80 @@ public class XZOutputStream extends FinishableOutputStream {
     private final byte[] tempBuf = new byte[1];
 
     /**
-     * Creates a new XZ compressor using one filter and CRC64 as
-     * the integrity check. This constructor is equivalent to passing
-     * a single-member FilterOptions array to
+     * Creates a new XZ compressor using one filter and CRC64 as the integrity
+     * check. This constructor is equivalent to passing a single-member
+     * FilterOptions array to
      * XZOutputStream(OutputStream, FilterOptions[]).
      *
-     * @param out           output stream to which the compressed data
-     *                      will be written
+     * @param out           output stream to which the compressed data will be
+     *                      written
      *
-     * @param filterOptions
-     *                      filter options to use
+     * @param filterOptions filter options to use
      *
-     * @throws UnsupportedOptionsException
-     *                                     invalid filter chain
+     * @throws UnsupportedOptionsException invalid filter chain
      *
      * @throws IOException                 may be thrown from out
      */
     public XZOutputStream(OutputStream out, FilterOptions filterOptions)
-    throws IOException {
+        throws IOException {
         this(out, filterOptions, XZ.CHECK_CRC64);
     }
 
     /**
-     * Creates a new XZ compressor using one filter and the specified
-     * integrity check type. This constructor is equivalent to
-     * passing a single-member FilterOptions array to
+     * Creates a new XZ compressor using one filter and the specified integrity
+     * check type. This constructor is equivalent to passing a single-member
+     * FilterOptions array to
      * XZOutputStream(OutputStream, FilterOptions[], int).
      *
-     * @param out           output stream to which the compressed data
-     *                      will be written
+     * @param out           output stream to which the compressed data will be
+     *                      written
      *
-     * @param filterOptions
-     *                      filter options to use
+     * @param filterOptions filter options to use
      *
-     * @param checkType     type of the integrity check,
-     *                      for example XZ.CHECK_CRC32
+     * @param checkType     type of the integrity check, for example
+     *                      XZ.CHECK_CRC32
      *
-     * @throws UnsupportedOptionsException
-     *                                     invalid filter chain
+     * @throws UnsupportedOptionsException invalid filter chain
      *
      * @throws IOException                 may be thrown from out
      */
     public XZOutputStream(OutputStream out, FilterOptions filterOptions,
                           int checkType) throws IOException {
-        this(out, new FilterOptions[] {filterOptions}, checkType);
+        this(out, new FilterOptions[] { filterOptions }, checkType);
     }
 
     /**
-     * Creates a new XZ compressor using 1-4 filters and CRC64 as
-     * the integrity check. This constructor is equivalent
+     * Creates a new XZ compressor using 1-4 filters and CRC64 as the integrity
+     * check. This constructor is equivalent
      * XZOutputStream(out, filterOptions, XZ.CHECK_CRC64).
      *
-     * @param out           output stream to which the compressed data
-     *                      will be written
+     * @param out           output stream to which the compressed data will be
+     *                      written
      *
-     * @param filterOptions
-     *                      array of filter options to use
+     * @param filterOptions array of filter options to use
      *
-     * @throws UnsupportedOptionsException
-     *                                     invalid filter chain
+     * @throws UnsupportedOptionsException invalid filter chain
      *
      * @throws IOException                 may be thrown from out
      */
     public XZOutputStream(OutputStream out, FilterOptions[] filterOptions)
-    throws IOException {
+        throws IOException {
         this(out, filterOptions, XZ.CHECK_CRC64);
     }
 
     /**
-     * Creates a new XZ compressor using 1-4 filters and the specified
-     * integrity check type.
+     * Creates a new XZ compressor using 1-4 filters and the specified integrity
+     * check type.
      *
-     * @param out           output stream to which the compressed data
-     *                      will be written
+     * @param out           output stream to which the compressed data will be
+     *                      written
      *
-     * @param filterOptions
-     *                      array of filter options to use
+     * @param filterOptions array of filter options to use
      *
-     * @param checkType     type of the integrity check,
-     *                      for example XZ.CHECK_CRC32
+     * @param checkType     type of the integrity check, for example
+     *                      XZ.CHECK_CRC32
      *
-     * @throws UnsupportedOptionsException
-     *                                     invalid filter chain
+     * @throws UnsupportedOptionsException invalid filter chain
      *
      * @throws IOException                 may be thrown from out
      */
@@ -173,19 +164,17 @@ public class XZOutputStream extends FinishableOutputStream {
     }
 
     /**
-     * Updates the filter chain with a single filter.
-     * This is equivalent to passing a single-member FilterOptions array
-     * to updateFilters(FilterOptions[]).
+     * Updates the filter chain with a single filter. This is equivalent to
+     * passing a single-member FilterOptions array to
+     * updateFilters(FilterOptions[]).
      *
-     * @param filterOptions
-     *                      new filter to use
+     * @param filterOptions new filter to use
      *
-     * @throws UnsupportedOptionsException
-     *                                     unsupported filter chain, or trying to change
-     *                                     the filter chain in the middle of a Block
+     * @throws UnsupportedOptionsException unsupported filter chain, or trying
+     *                                     to change the filter chain in the middle of a Block
      */
     public void updateFilters(FilterOptions filterOptions)
-    throws XZIOException {
+        throws XZIOException {
         FilterOptions[] opts = new FilterOptions[1];
         opts[0] = filterOptions;
         updateFilters(opts);
@@ -194,27 +183,25 @@ public class XZOutputStream extends FinishableOutputStream {
     /**
      * Updates the filter chain with 1-4 filters.
      * 

- * Currently this cannot be used to update e.g. LZMA2 options in the - * middle of a XZ Block. Use endBlock() to finish the - * current XZ Block before calling this function. The new filter chain - * will then be used for the next XZ Block. + * Currently this cannot be used to update e.g. LZMA2 options in the middle + * of a XZ Block. Use endBlock() to finish the current XZ Block + * before calling this function. The new filter chain will then be used for + * the next XZ Block. * - * @param filterOptions - * new filter chain to use + * @param filterOptions new filter chain to use * - * @throws UnsupportedOptionsException - * unsupported filter chain, or trying to change - * the filter chain in the middle of a Block + * @throws UnsupportedOptionsException unsupported filter chain, or trying + * to change the filter chain in the middle of a Block */ public void updateFilters(FilterOptions[] filterOptions) - throws XZIOException { + throws XZIOException { if (blockEncoder != null) throw new UnsupportedOptionsException("Changing filter options " + "in the middle of a XZ Block not implemented"); if (filterOptions.length < 1 || filterOptions.length > 4) throw new UnsupportedOptionsException( - "XZ filter chain must be 1-4 filters"); + "XZ filter chain must be 1-4 filters"); filtersSupportFlushing = true; FilterEncoder[] newFilters = new FilterEncoder[filterOptions.length]; @@ -230,12 +217,10 @@ public class XZOutputStream extends FinishableOutputStream { /** * Writes one byte to be compressed. * - * @throws XZIOException - * XZ Stream has grown too big + * @throws XZIOException XZ Stream has grown too big * - * @throws XZIOException - * finish() or close() - * was already called + * @throws XZIOException finish() or close() was + * already called * * @throws IOException may be thrown by the underlying output stream */ @@ -245,26 +230,22 @@ public class XZOutputStream extends FinishableOutputStream { } /** - * Writes an array of bytes to be compressed. - * The compressors tend to do internal buffering and thus the written - * data won't be readable from the compressed output immediately. - * Use flush() to force everything written so far to - * be written to the underlaying output stream, but be aware that - * flushing reduces compression ratio. + * Writes an array of bytes to be compressed. The compressors tend to do + * internal buffering and thus the written data won't be readable from the + * compressed output immediately. Use flush() to force + * everything written so far to be written to the underlaying output stream, + * but be aware that flushing reduces compression ratio. * * @param buf buffer of bytes to be written * @param off start offset in buf * @param len number of bytes to write * - * @throws XZIOException - * XZ Stream has grown too big: total file size - * about 8 EiB or the Index field exceeds - * 16 GiB; you shouldn't reach these sizes - * in practice + * @throws XZIOException XZ Stream has grown too big: total file size about + * 8 EiB or the Index field exceeds 16 GiB; you shouldn't reach + * these sizes in practice * - * @throws XZIOException - * finish() or close() - * was already called and len > 0 + * @throws XZIOException finish() or close() was + * already called and len > 0 * * @throws IOException may be thrown by the underlying output stream */ @@ -290,27 +271,25 @@ public class XZOutputStream extends FinishableOutputStream { } /** - * Finishes the current XZ Block (but not the whole XZ Stream). - * This doesn't flush the stream so it's possible that not all data will - * be decompressible from the output stream when this function returns. - * Call also flush() if flushing is wanted in addition to - * finishing the current XZ Block. + * Finishes the current XZ Block (but not the whole XZ Stream). This doesn't + * flush the stream so it's possible that not all data will be + * decompressible from the output stream when this function returns. Call + * also flush() if flushing is wanted in addition to finishing + * the current XZ Block. *

- * If there is no unfinished Block open, this function will do nothing. - * (No empty XZ Block will be created.) + * If there is no unfinished Block open, this function will do nothing. (No + * empty XZ Block will be created.) *

- * This function can be useful, for example, to create - * random-accessible .xz files. + * This function can be useful, for example, to create random-accessible .xz + * files. *

- * Starting a new XZ Block means that the encoder state is reset. - * Doing this very often will increase the size of the compressed - * file a lot (more than plain flush() would do). + * Starting a new XZ Block means that the encoder state is reset. Doing this + * very often will increase the size of the compressed file a lot (more than + * plain flush() would do). * - * @throws XZIOException - * XZ Stream has grown too big + * @throws XZIOException XZ Stream has grown too big * - * @throws XZIOException - * stream finished or closed + * @throws XZIOException stream finished or closed * * @throws IOException may be thrown by the underlying output stream */ @@ -337,24 +316,21 @@ public class XZOutputStream extends FinishableOutputStream { } /** - * Flushes the encoder and calls out.flush(). - * All buffered pending data will then be decompressible from - * the output stream. + * Flushes the encoder and calls out.flush(). All buffered + * pending data will then be decompressible from the output stream. *

- * Calling this function very often may increase the compressed - * file size a lot. The filter chain options may affect the size - * increase too. For example, with LZMA2 the HC4 match finder has - * smaller penalty with flushing than BT4. + * Calling this function very often may increase the compressed file size a + * lot. The filter chain options may affect the size increase too. For + * example, with LZMA2 the HC4 match finder has smaller penalty with + * flushing than BT4. *

- * Some filters don't support flushing. If the filter chain has - * such a filter, flush() will call endBlock() - * before flushing. + * Some filters don't support flushing. If the filter chain has such a + * filter, flush() will call endBlock() before + * flushing. * - * @throws XZIOException - * XZ Stream has grown too big + * @throws XZIOException XZ Stream has grown too big * - * @throws XZIOException - * stream finished or closed + * @throws XZIOException stream finished or closed * * @throws IOException may be thrown by the underlying output stream */ @@ -384,20 +360,19 @@ public class XZOutputStream extends FinishableOutputStream { } /** - * Finishes compression without closing the underlying stream. - * No more data can be written to this stream after finishing - * (calling write with an empty buffer is OK). + * Finishes compression without closing the underlying stream. No more data + * can be written to this stream after finishing (calling write + * with an empty buffer is OK). *

- * Repeated calls to finish() do nothing unless - * an exception was thrown by this stream earlier. In that case - * the same exception is thrown again. + * Repeated calls to finish() do nothing unless an exception + * was thrown by this stream earlier. In that case the same exception is + * thrown again. *

* After finishing, the stream may be closed normally with - * close(). If the stream will be closed anyway, there - * usually is no need to call finish() separately. + * close(). If the stream will be closed anyway, there usually + * is no need to call finish() separately. * - * @throws XZIOException - * XZ Stream has grown too big + * @throws XZIOException XZ Stream has grown too big * * @throws IOException may be thrown by the underlying output stream */ @@ -423,14 +398,13 @@ public class XZOutputStream extends FinishableOutputStream { } /** - * Finishes compression and closes the underlying stream. - * The underlying stream out is closed even if finishing - * fails. If both finishing and closing fail, the exception thrown - * by finish() is thrown and the exception from the failed - * out.close() is lost. + * Finishes compression and closes the underlying stream. The underlying + * stream out is closed even if finishing fails. If both + * finishing and closing fail, the exception thrown by finish() + * is thrown and the exception from the failed out.close() is + * lost. * - * @throws XZIOException - * XZ Stream has grown too big + * @throws XZIOException XZ Stream has grown too big * * @throws IOException may be thrown by the underlying output stream */ diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/check/CRC32.java b/HMCLAPI/src/main/java/org/tukaani/xz/check/CRC32.java index 3e2cd6f63..15dec5a19 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/check/CRC32.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/check/CRC32.java @@ -23,10 +23,10 @@ public class CRC32 extends Check { public byte[] finish() { long value = state.getValue(); - byte[] buf = {(byte) (value), - (byte) (value >>> 8), - (byte) (value >>> 16), - (byte) (value >>> 24)}; + byte[] buf = { (byte) (value), + (byte) (value >>> 8), + (byte) (value >>> 16), + (byte) (value >>> 24) }; state.reset(); return buf; } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/check/Check.java b/HMCLAPI/src/main/java/org/tukaani/xz/check/Check.java index 0d9af8435..e0c92afad 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/check/Check.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/check/Check.java @@ -33,27 +33,27 @@ public abstract class Check { } public static Check getInstance(int checkType) - throws UnsupportedOptionsException { + throws UnsupportedOptionsException { switch (checkType) { - case XZ.CHECK_NONE: - return new None(); + case XZ.CHECK_NONE: + return new None(); - case XZ.CHECK_CRC32: - return new CRC32(); + case XZ.CHECK_CRC32: + return new CRC32(); - case XZ.CHECK_CRC64: - return new CRC64(); + case XZ.CHECK_CRC64: + return new CRC64(); - case XZ.CHECK_SHA256: - try { - return new SHA256(); - } catch (java.security.NoSuchAlgorithmException e) { - } + case XZ.CHECK_SHA256: + try { + return new SHA256(); + } catch (java.security.NoSuchAlgorithmException e) { + } - break; + break; } throw new UnsupportedOptionsException( - "Unsupported Check ID " + checkType); + "Unsupported Check ID " + checkType); } } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/common/DecoderUtil.java b/HMCLAPI/src/main/java/org/tukaani/xz/common/DecoderUtil.java index 9b50bbd9b..dd9d185b0 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/common/DecoderUtil.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/common/DecoderUtil.java @@ -33,7 +33,7 @@ public class DecoderUtil extends Util { } public static StreamFlags decodeStreamHeader(byte[] buf) - throws IOException { + throws IOException { for (int i = 0; i < XZ.HEADER_MAGIC.length; ++i) if (buf[i] != XZ.HEADER_MAGIC[i]) throw new XZFormatException(); @@ -46,12 +46,12 @@ public class DecoderUtil extends Util { return decodeStreamFlags(buf, XZ.HEADER_MAGIC.length); } catch (UnsupportedOptionsException e) { throw new UnsupportedOptionsException( - "Unsupported options in XZ Stream Header"); + "Unsupported options in XZ Stream Header"); } } public static StreamFlags decodeStreamFooter(byte[] buf) - throws IOException { + throws IOException { if (buf[10] != XZ.FOOTER_MAGIC[0] || buf[11] != XZ.FOOTER_MAGIC[1]) // NOTE: The exception could be XZFormatException too. // It depends on the situation which one is better. @@ -65,7 +65,7 @@ public class DecoderUtil extends Util { streamFlags = decodeStreamFlags(buf, 8); } catch (UnsupportedOptionsException e) { throw new UnsupportedOptionsException( - "Unsupported options in XZ Stream Footer"); + "Unsupported options in XZ Stream Footer"); } streamFlags.backwardSize = 0; @@ -78,7 +78,7 @@ public class DecoderUtil extends Util { } private static StreamFlags decodeStreamFlags(byte[] buf, int off) - throws UnsupportedOptionsException { + throws UnsupportedOptionsException { if (buf[off] != 0x00 || (buf[off + 1] & 0xFF) >= 0x10) throw new UnsupportedOptionsException(); diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/common/EncoderUtil.java b/HMCLAPI/src/main/java/org/tukaani/xz/common/EncoderUtil.java index 8dd2176aa..9e84d0e4a 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/common/EncoderUtil.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/common/EncoderUtil.java @@ -15,7 +15,7 @@ import java.util.zip.CRC32; public class EncoderUtil extends Util { public static void writeCRC32(OutputStream out, byte[] buf) - throws IOException { + throws IOException { CRC32 crc32 = new CRC32(); crc32.update(buf); long value = crc32.getValue(); @@ -25,7 +25,7 @@ public class EncoderUtil extends Util { } public static void encodeVLI(OutputStream out, long num) - throws IOException { + throws IOException { while (num >= 0x80) { out.write((byte) (num | 0x80)); num >>>= 7; diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexDecoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexDecoder.java index 66685ef75..5efa2e293 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexDecoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexDecoder.java @@ -40,7 +40,7 @@ public class IndexDecoder extends IndexBase { public IndexDecoder(SeekableInputStream in, StreamFlags streamFooterFlags, long streamPadding, int memoryLimit) - throws IOException { + throws IOException { super(new CorruptedInputException("XZ Index is corrupt")); this.streamFlags = streamFooterFlags; this.streamPadding = streamPadding; diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexEncoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexEncoder.java index f1e142767..4a369f475 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexEncoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexEncoder.java @@ -25,7 +25,7 @@ public class IndexEncoder extends IndexBase { } public void add(long unpaddedSize, long uncompressedSize) - throws XZIOException { + throws XZIOException { super.add(unpaddedSize, uncompressedSize); records.add(new IndexRecord(unpaddedSize, uncompressedSize)); } diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexHash.java b/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexHash.java index ea74eaf6c..1f6587ca2 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexHash.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/index/IndexHash.java @@ -33,7 +33,7 @@ public class IndexHash extends IndexBase { } public void add(long unpaddedSize, long uncompressedSize) - throws XZIOException { + throws XZIOException { super.add(unpaddedSize, uncompressedSize); ByteBuffer buf = ByteBuffer.allocate(2 * 8); diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/lz/HC4.java b/HMCLAPI/src/main/java/org/tukaani/xz/lz/HC4.java index 1e839551e..17b97b86b 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/lz/HC4.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/lz/HC4.java @@ -28,8 +28,8 @@ final class HC4 extends LZEncoder { } /** - * Creates a new LZEncoder with the HC4 match finder. - * See LZEncoder.getInstance for parameter descriptions. + * Creates a new LZEncoder with the HC4 match finder. See + * LZEncoder.getInstance for parameter descriptions. */ HC4(int dictSize, int beforeSizeMin, int readAheadMax, int niceLen, int matchLenMax, int depthLimit) { @@ -54,8 +54,8 @@ final class HC4 extends LZEncoder { } /** - * Moves to the next byte, checks that there is enough available space, - * and possibly normalizes the hash tables and the hash chain. + * Moves to the next byte, checks that there is enough available space, and + * possibly normalizes the hash tables and the hash chain. * * @return number of bytes available, including the current byte */ diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/lz/LZDecoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/lz/LZDecoder.java index 1bfbe38d1..9ca0bb416 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/lz/LZDecoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/lz/LZDecoder.java @@ -104,7 +104,7 @@ public final class LZDecoder { } public void copyUncompressed(DataInputStream inData, int len) - throws IOException { + throws IOException { int copySize = Math.min(buf.length - pos, len); inData.readFully(buf, pos, copySize); pos += copySize; diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/lz/LZEncoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/lz/LZEncoder.java index f1b31a763..e247bda59 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/lz/LZEncoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/lz/LZEncoder.java @@ -18,16 +18,16 @@ public abstract class LZEncoder { public static final int MF_BT4 = 0x14; /** - * Number of bytes to keep available before the current byte - * when moving the LZ window. + * Number of bytes to keep available before the current byte when moving the + * LZ window. */ private final int keepSizeBefore; /** - * Number of bytes that must be available, the current byte included, - * to make hasEnoughData return true. Flushing and finishing are - * naturally exceptions to this since there cannot be any data after - * the end of the uncompressed input. + * Number of bytes that must be available, the current byte included, to + * make hasEnoughData return true. Flushing and finishing are naturally + * exceptions to this since there cannot be any data after the end of the + * uncompressed input. */ private final int keepSizeAfter; @@ -54,8 +54,8 @@ public abstract class LZEncoder { * Gets the size of the LZ window buffer that needs to be allocated. */ private static int getBufSize( - int dictSize, int extraSizeBefore, int extraSizeAfter, - int matchLenMax) { + int dictSize, int extraSizeBefore, int extraSizeAfter, + int matchLenMax) { int keepSizeBefore = extraSizeBefore + dictSize; int keepSizeAfter = extraSizeAfter + matchLenMax; int reserveSize = Math.min(dictSize / 2 + (256 << 10), 512 << 20); @@ -63,27 +63,27 @@ public abstract class LZEncoder { } /** - * Gets approximate memory usage of the LZEncoder base structure and - * the match finder as kibibytes. + * Gets approximate memory usage of the LZEncoder base structure and the + * match finder as kibibytes. */ public static int getMemoryUsage( - int dictSize, int extraSizeBefore, int extraSizeAfter, - int matchLenMax, int mf) { + int dictSize, int extraSizeBefore, int extraSizeAfter, + int matchLenMax, int mf) { // Buffer size + a little extra int m = getBufSize(dictSize, extraSizeBefore, extraSizeAfter, matchLenMax) / 1024 + 10; switch (mf) { - case MF_HC4: - m += HC4.getMemoryUsage(dictSize); - break; + case MF_HC4: + m += HC4.getMemoryUsage(dictSize); + break; - case MF_BT4: - m += BT4.getMemoryUsage(dictSize); - break; + case MF_BT4: + m += BT4.getMemoryUsage(dictSize); + break; - default: - throw new IllegalArgumentException(); + default: + throw new IllegalArgumentException(); } return m; @@ -94,17 +94,15 @@ public abstract class LZEncoder { *

* @param dictSize dictionary size * - * @param extraSizeBefore - * number of bytes to keep available in the - * history in addition to dictSize + * @param extraSizeBefore number of bytes to keep available in the history + * in addition to dictSize * - * @param extraSizeAfter - * number of bytes that must be available - * after current position + matchLenMax + * @param extraSizeAfter number of bytes that must be available after + * current position + matchLenMax * - * @param niceLen if a match of at least niceLen - * bytes is found, be happy with it and don't - * stop looking for longer matches + * @param niceLen if a match of at least niceLen bytes + * is + * found, be happy with it and don't stop looking for longer matches * * @param matchLenMax don't test for matches longer than * matchLenMax bytes @@ -114,16 +112,16 @@ public abstract class LZEncoder { * @param depthLimit match finder search depth limit */ public static LZEncoder getInstance( - int dictSize, int extraSizeBefore, int extraSizeAfter, - int niceLen, int matchLenMax, int mf, int depthLimit) { + int dictSize, int extraSizeBefore, int extraSizeAfter, + int niceLen, int matchLenMax, int mf, int depthLimit) { switch (mf) { - case MF_HC4: - return new HC4(dictSize, extraSizeBefore, extraSizeAfter, - niceLen, matchLenMax, depthLimit); + case MF_HC4: + return new HC4(dictSize, extraSizeBefore, extraSizeAfter, + niceLen, matchLenMax, depthLimit); - case MF_BT4: - return new BT4(dictSize, extraSizeBefore, extraSizeAfter, - niceLen, matchLenMax, depthLimit); + case MF_BT4: + return new BT4(dictSize, extraSizeBefore, extraSizeAfter, + niceLen, matchLenMax, depthLimit); } throw new IllegalArgumentException(); @@ -145,9 +143,9 @@ public abstract class LZEncoder { } /** - * Sets a preset dictionary. If a preset dictionary is wanted, this - * function must be called immediately after creating the LZEncoder - * before any data has been encoded. + * Sets a preset dictionary. If a preset dictionary is wanted, this function + * must be called immediately after creating the LZEncoder before any data + * has been encoded. */ public void setPresetDict(int dictSize, byte[] presetDict) { assert !isStarted(); @@ -165,8 +163,8 @@ public abstract class LZEncoder { } /** - * Moves data from the end of the buffer to the beginning, discarding - * old data and making space for new input. + * Moves data from the end of the buffer to the beginning, discarding old + * data and making space for new input. */ private void moveWindow() { // Align the move to a multiple of 16 bytes. LZMA2 needs this @@ -212,8 +210,8 @@ public abstract class LZEncoder { } /** - * Process pending bytes remaining from preset dictionary initialization - * or encoder flush operation. + * Process pending bytes remaining from preset dictionary initialization or + * encoder flush operation. */ private void processPendingBytes() { // After flushing or setting a preset dictionary there will be @@ -234,16 +232,16 @@ public abstract class LZEncoder { } /** - * Returns true if at least one byte has already been run through - * the match finder. + * Returns true if at least one byte has already been run through the match + * finder. */ public boolean isStarted() { return readPos != -1; } /** - * Marks that all the input needs to be made available in - * the encoded output. + * Marks that all the input needs to be made available in the encoded + * output. */ public void setFlushing() { readLimit = writePos - 1; @@ -251,8 +249,8 @@ public abstract class LZEncoder { } /** - * Marks that there is no more input remaining. The read position - * can be advanced until the end of the data. + * Marks that there is no more input remaining. The read position can be + * advanced until the end of the data. */ public void setFinishing() { readLimit = writePos - 1; @@ -261,15 +259,15 @@ public abstract class LZEncoder { } /** - * Tests if there is enough input available to let the caller encode - * at least one more byte. + * Tests if there is enough input available to let the caller encode at + * least one more byte. */ public boolean hasEnoughData(int alreadyReadLen) { return readPos - alreadyReadLen < readLimit; } public void copyUncompressed(OutputStream out, int backward, int len) - throws IOException { + throws IOException { out.write(buf, readPos + 1 - backward, len); } @@ -277,8 +275,8 @@ public abstract class LZEncoder { * Get the number of bytes available, including the current byte. *

* Note that the result is undefined if getMatches or - * skip hasn't been called yet and no preset dictionary - * is being used. + * skip hasn't been called yet and no preset dictionary is + * being used. */ public int getAvail() { assert isStarted(); @@ -296,9 +294,8 @@ public abstract class LZEncoder { /** * Gets the byte from the given backward offset. *

- * The current byte is at 0, the previous byte - * at 1 etc. To get a byte at zero-based distance, - * use getByte(dist + 1). + * The current byte is at 0, the previous byte at + * 1 etc. To get a byte at zero-based distance, use getByte(dist + 1). *

* This function is equivalent to getByte(0, backward). */ @@ -307,9 +304,9 @@ public abstract class LZEncoder { } /** - * Gets the byte from the given forward minus backward offset. - * The forward offset is added to the current position. This lets - * one read bytes ahead of the current byte. + * Gets the byte from the given forward minus backward offset. The forward + * offset is added to the current position. This lets one read bytes ahead + * of the current byte. */ public int getByte(int forward, int backward) { return buf[readPos + forward - backward] & 0xFF; @@ -354,10 +351,10 @@ public abstract class LZEncoder { } /** - * Verifies that the matches returned by the match finder are valid. - * This is meant to be used in an assert statement. This is totally - * useless for actual encoding since match finder's results should - * naturally always be valid if it isn't broken. + * Verifies that the matches returned by the match finder are valid. This is + * meant to be used in an assert statement. This is totally useless for + * actual encoding since match finder's results should naturally always be + * valid if it isn't broken. * * @param matches return value from getMatches * @@ -374,21 +371,17 @@ public abstract class LZEncoder { } /** - * Moves to the next byte, checks if there is enough input available, - * and returns the amount of input available. + * Moves to the next byte, checks if there is enough input available, and + * returns the amount of input available. * - * @param requiredForFlushing - * minimum number of available bytes when - * flushing; encoding may be continued with - * new input after flushing - * @param requiredForFinishing - * minimum number of available bytes when - * finishing; encoding must not be continued - * after finishing or the match finder state - * may be corrupt + * @param requiredForFlushing minimum number of available bytes when + * flushing; encoding may be continued with new input after flushing + * @param requiredForFinishing minimum number of available bytes when + * finishing; encoding must not be continued after finishing or the match + * finder state may be corrupt * - * @return the number of bytes available or zero if there - * is not enough input available + * @return the number of bytes available or zero if there is not enough + * input available */ int movePos(int requiredForFlushing, int requiredForFinishing) { assert requiredForFlushing >= requiredForFinishing; diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMACoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMACoder.java index 64887df0c..2f6318186 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMACoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMACoder.java @@ -44,11 +44,11 @@ abstract class LZMACoder { final short[] isRep2 = new short[State.STATES]; final short[][] isRep0Long = new short[State.STATES][POS_STATES_MAX]; final short[][] distSlots = new short[DIST_STATES][DIST_SLOTS]; - final short[][] distSpecial = {new short[2], new short[2], - new short[4], new short[4], - new short[8], new short[8], - new short[16], new short[16], - new short[32], new short[32]}; + final short[][] distSpecial = { new short[2], new short[2], + new short[4], new short[4], + new short[8], new short[8], + new short[16], new short[16], + new short[32], new short[32] }; final short[] distAlign = new short[ALIGN_SIZE]; static final int getDistState(int len) { diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMADecoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMADecoder.java index 1d0737047..53df31adb 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMADecoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMADecoder.java @@ -37,10 +37,10 @@ public final class LZMADecoder extends LZMACoder { } /** - * Returns true if LZMA end marker was detected. It is encoded as - * the maximum match distance which with signed ints becomes -1. This - * function is needed only for LZMA1. LZMA2 doesn't use the end marker - * in the LZMA layer. + * Returns true if LZMA end marker was detected. It is encoded as the + * maximum match distance which with signed ints becomes -1. This function + * is needed only for LZMA1. LZMA2 doesn't use the end marker in the LZMA + * layer. */ public boolean endMarkerDetected() { return reps[0] == -1; @@ -87,7 +87,7 @@ public final class LZMADecoder extends LZMACoder { if (distSlot < DIST_MODEL_END) reps[0] |= rc.decodeReverseBitTree( - distSpecial[distSlot - DIST_MODEL_START]); + distSpecial[distSlot - DIST_MODEL_START]); else { reps[0] |= rc.decodeDirectBits(limit - ALIGN_BITS) << ALIGN_BITS; diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoder.java b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoder.java index e4dff726d..33af80075 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoder.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoder.java @@ -22,10 +22,10 @@ public abstract class LZMAEncoder extends LZMACoder { * LZMA2 chunk is considered full when its uncompressed size exceeds * LZMA2_UNCOMPRESSED_LIMIT. *

- * A compressed LZMA2 chunk can hold 2 MiB of uncompressed data. - * A single LZMA symbol may indicate up to MATCH_LEN_MAX bytes - * of data, so the LZMA2 chunk is considered full when there is - * less space than MATCH_LEN_MAX bytes. + * A compressed LZMA2 chunk can hold 2 MiB of uncompressed data. A single + * LZMA symbol may indicate up to MATCH_LEN_MAX bytes of data, so the LZMA2 + * chunk is considered full when there is less space than MATCH_LEN_MAX + * bytes. */ private static final int LZMA2_UNCOMPRESSED_LIMIT = (2 << 20) - MATCH_LEN_MAX; @@ -34,11 +34,11 @@ public abstract class LZMAEncoder extends LZMACoder { * LZMA2 chunk is considered full when its compressed size exceeds * LZMA2_COMPRESSED_LIMIT. *

- * The maximum compressed size of a LZMA2 chunk is 64 KiB. - * A single LZMA symbol might use 20 bytes of space even though - * it usually takes just one byte or so. Two more bytes are needed - * for LZMA2 uncompressed chunks (see LZMA2OutputStream.writeChunk). - * Leave a little safety margin and use 26 bytes. + * The maximum compressed size of a LZMA2 chunk is 64 KiB. A single LZMA + * symbol might use 20 bytes of space even though it usually takes just one + * byte or so. Two more bytes are needed for LZMA2 uncompressed chunks (see + * LZMA2OutputStream.writeChunk). Leave a little safety margin and use 26 + * bytes. */ private static final int LZMA2_COMPRESSED_LIMIT = (64 << 10) - 26; @@ -70,46 +70,46 @@ public abstract class LZMAEncoder extends LZMACoder { int m = 80; switch (mode) { - case MODE_FAST: - m += LZMAEncoderFast.getMemoryUsage( + case MODE_FAST: + m += LZMAEncoderFast.getMemoryUsage( dictSize, extraSizeBefore, mf); - break; + break; - case MODE_NORMAL: - m += LZMAEncoderNormal.getMemoryUsage( + case MODE_NORMAL: + m += LZMAEncoderNormal.getMemoryUsage( dictSize, extraSizeBefore, mf); - break; + break; - default: - throw new IllegalArgumentException(); + default: + throw new IllegalArgumentException(); } return m; } public static LZMAEncoder getInstance( - RangeEncoder rc, int lc, int lp, int pb, int mode, - int dictSize, int extraSizeBefore, - int niceLen, int mf, int depthLimit) { + RangeEncoder rc, int lc, int lp, int pb, int mode, + int dictSize, int extraSizeBefore, + int niceLen, int mf, int depthLimit) { switch (mode) { - case MODE_FAST: - return new LZMAEncoderFast(rc, lc, lp, pb, - dictSize, extraSizeBefore, - niceLen, mf, depthLimit); + case MODE_FAST: + return new LZMAEncoderFast(rc, lc, lp, pb, + dictSize, extraSizeBefore, + niceLen, mf, depthLimit); - case MODE_NORMAL: - return new LZMAEncoderNormal(rc, lc, lp, pb, - dictSize, extraSizeBefore, - niceLen, mf, depthLimit); + case MODE_NORMAL: + return new LZMAEncoderNormal(rc, lc, lp, pb, + dictSize, extraSizeBefore, + niceLen, mf, depthLimit); } throw new IllegalArgumentException(); } /** - * Gets an integer [0, 63] matching the highest two bits of an integer. - * This is like bit scan reverse (BSR) on x86 except that this also - * cares about the second highest bit. + * Gets an integer [0, 63] matching the highest two bits of an integer. This + * is like bit scan reverse (BSR) on x86 except that this also cares about + * the second highest bit. */ public static int getDistSlot(int dist) { if (dist <= DIST_MODEL_START) @@ -147,19 +147,18 @@ public abstract class LZMAEncoder extends LZMACoder { /** * Gets the next LZMA symbol. *

- * There are three types of symbols: literal (a single byte), - * repeated match, and normal match. The symbol is indicated - * by the return value and by the variable back. + * There are three types of symbols: literal (a single byte), repeated + * match, and normal match. The symbol is indicated by the return value and + * by the variable back. *

- * Literal: back == -1 and return value is 1. - * The literal itself needs to be read from lz separately. + * Literal: back == -1 and return value is 1. The + * literal itself needs to be read from lz separately. *

- * Repeated match: back is in the range [0, 3] and - * the return value is the length of the repeated match. + * Repeated match: back is in the range [0, 3] and the return + * value is the length of the repeated match. *

- * Normal match: back - REPS (back - 4) - * is the distance of the match and the return value is the length - * of the match. + * Normal match: back - REPS (back - 4) is the + * distance of the match and the return value is the length of the match. */ abstract int getNextSymbol(); @@ -293,8 +292,8 @@ public abstract class LZMAEncoder extends LZMACoder { if (distSlot < DIST_MODEL_END) rc.encodeReverseBitTree( - distSpecial[distSlot - DIST_MODEL_START], - distReduced); + distSpecial[distSlot - DIST_MODEL_START], + distReduced); else { rc.encodeDirectBits(distReduced >>> ALIGN_BITS, footerBits - ALIGN_BITS); @@ -382,7 +381,7 @@ public abstract class LZMAEncoder extends LZMACoder { if (rep == 0) price += RangeEncoder.getBitPrice(isRep0[state.get()], 0) + RangeEncoder.getBitPrice( - isRep0Long[state.get()][posState], 1); + isRep0Long[state.get()][posState], 1); else { price += RangeEncoder.getBitPrice(isRep0[state.get()], 1); @@ -430,7 +429,7 @@ public abstract class LZMAEncoder extends LZMACoder { for (int distSlot = 0; distSlot < distSlotPricesSize; ++distSlot) distSlotPrices[distState][distSlot] = RangeEncoder.getBitTreePrice( - distSlots[distState], distSlot); + distSlots[distState], distSlot); for (int distSlot = DIST_MODEL_END; distSlot < distSlotPricesSize; ++distSlot) { @@ -454,8 +453,8 @@ public abstract class LZMAEncoder extends LZMACoder { for (int i = 0; i < limit; ++i) { int distReduced = dist - base; int price = RangeEncoder.getReverseBitTreePrice( - distSpecial[distSlot - DIST_MODEL_START], - distReduced); + distSpecial[distSlot - DIST_MODEL_START], + distReduced); for (int distState = 0; distState < DIST_STATES; ++distState) fullDistPrices[distState][dist] @@ -477,9 +476,9 @@ public abstract class LZMAEncoder extends LZMACoder { } /** - * Updates the lookup tables used for calculating match distance - * and length prices. The updating is skipped for performance reasons - * if the tables haven't changed much since the previous update. + * Updates the lookup tables used for calculating match distance and length + * prices. The updating is skipped for performance reasons if the tables + * haven't changed much since the previous update. */ void updatePrices() { if (distPriceCount <= 0) @@ -527,7 +526,7 @@ public abstract class LZMAEncoder extends LZMACoder { int getPrice(int curByte, int matchByte, int prevByte, int pos, State state) { int price = RangeEncoder.getBitPrice( - isMatch[state.get()][pos & posMask], 0); + isMatch[state.get()][pos & posMask], 0); int i = getSubcoderIndex(prevByte, pos); price += state.isLiteral() @@ -621,8 +620,8 @@ public abstract class LZMAEncoder extends LZMACoder { /** * The prices are updated after at least - * PRICE_UPDATE_INTERVAL many lengths - * have been encoded with the same posState. + * PRICE_UPDATE_INTERVAL many lengths have been encoded + * with the same posState. */ private static final int PRICE_UPDATE_INTERVAL = 32; // FIXME? diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoderFast.java b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoderFast.java index e507c8fed..31e690f8d 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoderFast.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoderFast.java @@ -22,8 +22,8 @@ final class LZMAEncoderFast extends LZMAEncoder { static int getMemoryUsage(int dictSize, int extraSizeBefore, int mf) { return LZEncoder.getMemoryUsage( - dictSize, Math.max(extraSizeBefore, EXTRA_SIZE_BEFORE), - EXTRA_SIZE_AFTER, MATCH_LEN_MAX, mf); + dictSize, Math.max(extraSizeBefore, EXTRA_SIZE_BEFORE), + EXTRA_SIZE_AFTER, MATCH_LEN_MAX, mf); } LZMAEncoderFast(RangeEncoder rc, int lc, int lp, int pb, diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoderNormal.java b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoderNormal.java index 8fad60ed5..c84d388ef 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoderNormal.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/LZMAEncoderNormal.java @@ -60,9 +60,9 @@ final class LZMAEncoderNormal extends LZMAEncoder { } /** - * Converts the opts array from backward indexes to forward indexes. - * Then it will be simple to get the next symbol from the array - * in later calls to getNextSymbol(). + * Converts the opts array from backward indexes to forward indexes. Then it + * will be simple to get the next symbol from the array in later calls to + * getNextSymbol(). */ private int convertOpts() { optEnd = optCur; diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/Optimum.java b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/Optimum.java index 8a259897f..d3660604a 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/lzma/Optimum.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/lzma/Optimum.java @@ -58,8 +58,7 @@ final class Optimum { } /** - * Sets to indicate three LZMA symbols of which the second one - * is a literal. + * Sets to indicate three LZMA symbols of which the second one is a literal. */ void set3(int newPrice, int optCur, int back2, int len2, int back) { price = newPrice; diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/package-info.java b/HMCLAPI/src/main/java/org/tukaani/xz/package-info.java index a06dadaa4..15e4590a9 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/package-info.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/package-info.java @@ -3,14 +3,14 @@ * *

Introduction

*

- * This aims to be a complete implementation of XZ data compression - * in pure Java. Features: + * This aims to be a complete implementation of XZ data compression in pure + * Java. Features: *

    *
  • Full support for the .xz file format specification version 1.0.4
  • *
  • Single-threaded streamed compression and decompression
  • *
  • Single-threaded decompression with limited random access support
  • - *
  • Raw streams (no .xz headers) for advanced users, including LZMA2 - * with preset dictionary
  • + *
  • Raw streams (no .xz headers) for advanced users, including LZMA2 with + * preset dictionary
  • *
*

* Threading is planned but it is unknown when it will be implemented. @@ -21,15 +21,14 @@ *

Getting started

*

* Start by reading the documentation of {@link org.tukaani.xz.XZOutputStream} - * and {@link org.tukaani.xz.XZInputStream}. - * If you use XZ inside another file format or protocol, - * see also {@link org.tukaani.xz.SingleXZInputStream}. + * and {@link org.tukaani.xz.XZInputStream}. If you use XZ inside another file + * format or protocol, see also {@link org.tukaani.xz.SingleXZInputStream}. * *

Licensing

*

- * XZ for Java has been put into the public domain, thus you can do - * whatever you want with it. All the files in the package have been - * written by Lasse Collin and/or Igor Pavlov. + * XZ for Java has been put into the public domain, thus you can do whatever you + * want with it. All the files in the package have been written by Lasse Collin + * and/or Igor Pavlov. *

* This software is provided "as is", without any warranty. */ diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/rangecoder/RangeDecoderFromBuffer.java b/HMCLAPI/src/main/java/org/tukaani/xz/rangecoder/RangeDecoderFromBuffer.java index f8a788733..e90a548da 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/rangecoder/RangeDecoderFromBuffer.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/rangecoder/RangeDecoderFromBuffer.java @@ -26,7 +26,7 @@ public final class RangeDecoderFromBuffer extends RangeDecoder { } public void prepareInputBuffer(DataInputStream in, int len) - throws IOException { + throws IOException { if (len < INIT_SIZE) throw new CorruptedInputException(); diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/simple/IA64.java b/HMCLAPI/src/main/java/org/tukaani/xz/simple/IA64.java index 097dcfba0..ab182355d 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/simple/IA64.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/simple/IA64.java @@ -15,7 +15,7 @@ public final class IA64 implements SimpleFilter { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 6, 6, 0, 0, 7, 7, - 4, 4, 0, 0, 4, 4, 0, 0}; + 4, 4, 0, 0, 4, 4, 0, 0 }; private final boolean isEncoder; private int pos; diff --git a/HMCLAPI/src/main/java/org/tukaani/xz/simple/X86.java b/HMCLAPI/src/main/java/org/tukaani/xz/simple/X86.java index 2883e2779..8ac32faba 100755 --- a/HMCLAPI/src/main/java/org/tukaani/xz/simple/X86.java +++ b/HMCLAPI/src/main/java/org/tukaani/xz/simple/X86.java @@ -12,9 +12,9 @@ package org.tukaani.xz.simple; public final class X86 implements SimpleFilter { private static final boolean[] MASK_TO_ALLOWED_STATUS - = {true, true, true, false, true, false, false, false}; + = { true, true, true, false, true, false, false, false }; - private static final int[] MASK_TO_BIT_NUMBER = {0, 1, 2, 2, 3, 3, 3, 3}; + private static final int[] MASK_TO_BIT_NUMBER = { 0, 1, 2, 2, 3, 3, 3, 3 }; private final boolean isEncoder; private int pos; @@ -46,7 +46,7 @@ public final class X86 implements SimpleFilter { prevMask = (prevMask << (prevPos - 1)) & 7; if (prevMask != 0) if (!MASK_TO_ALLOWED_STATUS[prevMask] || test86MSByte( - buf[i + 4 - MASK_TO_BIT_NUMBER[prevMask]])) { + buf[i + 4 - MASK_TO_BIT_NUMBER[prevMask]])) { prevPos = i; prevMask = (prevMask << 1) | 1; continue; diff --git a/HMCLAPI/src/main/java/rx/Observable.java b/HMCLAPI/src/main/java/rx/Observable.java index 662de29f7..56ae09f37 100755 --- a/HMCLAPI/src/main/java/rx/Observable.java +++ b/HMCLAPI/src/main/java/rx/Observable.java @@ -1,17 +1,17 @@ /** * Copyright 2013 Netflix, Inc. *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at *

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. */ package rx; @@ -84,8 +84,7 @@ import rx.util.functions.Functions; * the various operators. *

* The documentation for this interface makes use of marble diagrams. The - * following legend explains - * these diagrams: + * following legend explains these diagrams: *

* *

@@ -110,8 +109,8 @@ public class Observable { * NOTE: Generally you're better off using {@link #create(Func1)} to create * an Observable instead of using inheritance. * - * @param onSubscribe - * {@link Func1} to be executed when {@link #subscribe(Observer)} is called. + * @param onSubscribe {@link Func1} to be executed when + * {@link #subscribe(Observer)} is called. */ protected Observable(Func1, Subscription> onSubscribe) { this.onSubscribe = onSubscribe; @@ -119,31 +118,25 @@ public class Observable { /** * an {@link Observer} must call an Observable's subscribe - * method in order to register itself - * to receive push-based notifications from the Observable. A typical - * implementation of the + * method in order to register itself to receive push-based notifications + * from the Observable. A typical implementation of the * subscribe method does the following: *

* It stores a reference to the Observer in a collection object, such as a - * List - * object. + * List object. *

* It returns a reference to the {@link Subscription} interface. This - * enables - * Observers to unsubscribe (that is, to stop receiving notifications) - * before the Observable has - * finished sending them and has called the Observer's - * {@link Observer#onCompleted()} method. + * enables Observers to unsubscribe (that is, to stop receiving + * notifications) before the Observable has finished sending them and has + * called the Observer's {@link Observer#onCompleted()} method. *

* At any given time, a particular instance of an Observable - * implementation is - * responsible for accepting all subscriptions and notifying all - * subscribers. Unless the - * documentation for a particular Observable implementation - * indicates otherwise, - * Observers should make no assumptions about the Observable - * implementation, such - * as the order of notifications that multiple Observers will receive. + * implementation is responsible for accepting all subscriptions and + * notifying all subscribers. Unless the documentation for a particular + * Observable implementation indicates otherwise, Observers + * should make no assumptions about the Observable + * implementation, such as the order of notifications that multiple + * Observers will receive. *

* For more information see the * RxJava @@ -151,9 +144,9 @@ public class Observable { * * * @param observer - * @return a {@link Subscription} reference that allows observers - * to stop receiving notifications before the provider has finished sending - * them + * + * @return a {@link Subscription} reference that allows observers to stop + * receiving notifications before the provider has finished sending them */ public Subscription subscribe(Observer observer) { // allow the hook to intercept and/or decorate @@ -197,31 +190,25 @@ public class Observable { /** * an {@link Observer} must call an Observable's subscribe - * method in order to register itself - * to receive push-based notifications from the Observable. A typical - * implementation of the + * method in order to register itself to receive push-based notifications + * from the Observable. A typical implementation of the * subscribe method does the following: *

* It stores a reference to the Observer in a collection object, such as a - * List - * object. + * List object. *

* It returns a reference to the {@link Subscription} interface. This - * enables - * Observers to unsubscribe (that is, to stop receiving notifications) - * before the Observable has - * finished sending them and has called the Observer's - * {@link Observer#onCompleted()} method. + * enables Observers to unsubscribe (that is, to stop receiving + * notifications) before the Observable has finished sending them and has + * called the Observer's {@link Observer#onCompleted()} method. *

* At any given time, a particular instance of an Observable - * implementation is - * responsible for accepting all subscriptions and notifying all - * subscribers. Unless the - * documentation for a particular Observable implementation - * indicates otherwise, - * Observers should make no assumptions about the Observable - * implementation, such - * as the order of notifications that multiple Observers will receive. + * implementation is responsible for accepting all subscriptions and + * notifying all subscribers. Unless the documentation for a particular + * Observable implementation indicates otherwise, Observers + * should make no assumptions about the Observable + * implementation, such as the order of notifications that multiple + * Observers will receive. *

* For more information see the * RxJava @@ -229,11 +216,11 @@ public class Observable { * * * @param observer - * @param scheduler - * The {@link Scheduler} that the sequence is subscribed to on. - * @return a {@link Subscription} reference that allows observers - * to stop receiving notifications before the provider has finished sending - * them + * @param scheduler The {@link Scheduler} that the sequence is subscribed to + * on. + * + * @return a {@link Subscription} reference that allows observers to stop + * receiving notifications before the provider has finished sending them */ public Subscription subscribe(Observer observer, Scheduler scheduler) { return subscribeOn(scheduler).subscribe(observer); @@ -252,7 +239,7 @@ public class Observable { return subscription.wrap(subscribe(new AtomicObserver<>(subscription, o))); } - @SuppressWarnings({"rawtypes", "unchecked"}) + @SuppressWarnings({ "rawtypes", "unchecked" }) public Subscription subscribe(final Map callbacks) { // lookup and memoize onNext Object _onNext = callbacks.get("onNext"); @@ -295,7 +282,7 @@ public class Observable { return subscribeOn(scheduler).subscribe(callbacks); } - @SuppressWarnings({"rawtypes", "unchecked"}) + @SuppressWarnings({ "rawtypes", "unchecked" }) public Subscription subscribe(final Object o) { if (o instanceof Observer) // in case a dynamic language is not correctly handling the overloaded methods and we receive an Observer just forward to the correct method. @@ -372,7 +359,7 @@ public class Observable { return subscribeOn(scheduler).subscribe(onNext); } - @SuppressWarnings({"rawtypes", "unchecked"}) + @SuppressWarnings({ "rawtypes", "unchecked" }) public Subscription subscribe(final Object onNext, final Object onError) { // lookup and memoize onNext if (onNext == null) @@ -447,7 +434,7 @@ public class Observable { return subscribeOn(scheduler).subscribe(onNext, onError); } - @SuppressWarnings({"rawtypes", "unchecked"}) + @SuppressWarnings({ "rawtypes", "unchecked" }) public Subscription subscribe(final Object onNext, final Object onError, final Object onComplete) { // lookup and memoize onNext if (onNext == null) @@ -533,10 +520,9 @@ public class Observable { * blocks it does not need the {@link Observer#onCompleted()} or * {@link Observer#onError(Exception)} methods. * - * @param onNext - * {@link Action1} - * @throws RuntimeException - * if error occurs + * @param onNext {@link Action1} + * + * @throws RuntimeException if error occurs */ public void forEach(final Action1 onNext) { final CountDownLatch latch = new CountDownLatch(1); @@ -557,10 +543,12 @@ public class Observable { @Override public void onError(Exception e) { /* - * If we receive an onError event we set the reference on the outer thread + * If we receive an onError event we set the reference on the + * outer thread * so we can git it and throw after the latch.await(). - * - * We do this instead of throwing directly since this may be on a different thread and the latch is still waiting. + * + * We do this instead of throwing directly since this may be on + * a different thread and the latch is still waiting. */ exceptionFromOnError.set(e); latch.countDown(); @@ -599,12 +587,11 @@ public class Observable { * blocks it does not need the {@link Observer#onCompleted()} or * {@link Observer#onError(Exception)} methods. * - * @param o - * {@link Action1} - * @throws RuntimeException - * if error occurs + * @param o {@link Action1} + * + * @throws RuntimeException if error occurs */ - @SuppressWarnings({"rawtypes", "unchecked"}) + @SuppressWarnings({ "rawtypes", "unchecked" }) public void forEach(final Object o) { if (o instanceof Action1) // in case a dynamic language is not correctly handling the overloaded methods and we receive an Action1 just forward to the correct method. @@ -633,8 +620,9 @@ public class Observable { * predicate and throws an exception if there is not exactly one element in * the observable sequence. * - * @param predicate - * A predicate function to evaluate for elements in the sequence. + * @param predicate A predicate function to evaluate for elements in the + * sequence. + * * @return The single element in the observable sequence. */ public T single(Func1 predicate) { @@ -646,8 +634,9 @@ public class Observable { * predicate and throws an exception if there is not exactly one element in * the observable sequence. * - * @param predicate - * A predicate function to evaluate for elements in the sequence. + * @param predicate A predicate function to evaluate for elements in the + * sequence. + * * @return The single element in the observable sequence. */ public T single(Object predicate) { @@ -658,8 +647,8 @@ public class Observable { * Returns the only element of an observable sequence, or a default value if * the observable sequence is empty. * - * @param defaultValue - * default value for a sequence. + * @param defaultValue default value for a sequence. + * * @return The single element in the observable sequence, or a default value * if no value is found. */ @@ -671,10 +660,10 @@ public class Observable { * Returns the only element of an observable sequence that matches the * predicate, or a default value if no value is found. * - * @param defaultValue - * default value for a sequence. - * @param predicate - * A predicate function to evaluate for elements in the sequence. + * @param defaultValue default value for a sequence. + * @param predicate A predicate function to evaluate for elements in the + * sequence. + * * @return The single element in the observable sequence, or a default value * if no value is found. */ @@ -686,10 +675,10 @@ public class Observable { * Returns the only element of an observable sequence that matches the * predicate, or a default value if no value is found. * - * @param defaultValue - * default value for a sequence. - * @param predicate - * A predicate function to evaluate for elements in the sequence. + * @param defaultValue default value for a sequence. + * @param predicate A predicate function to evaluate for elements in the + * sequence. + * * @return The single element in the observable sequence, or a default value * if no value is found. */ @@ -713,8 +702,7 @@ public class Observable { *

* This Observable is useful primarily for testing purposes. * - * @param - * the type of item emitted by the Observable + * @param the type of item emitted by the Observable */ private static class NeverObservable extends Observable { @@ -727,8 +715,7 @@ public class Observable { * an Observable that calls {@link Observer#onError(Exception)} when the * Observer subscribes. * - * @param - * the type of object returned by the Observable + * @param the type of object returned by the Observable */ private static class ThrowObservable extends Observable { @@ -737,8 +724,8 @@ public class Observable { * Accepts an {@link Observer} and calls its onError * method. * - * @param observer - * an {@link Observer} of this Observable + * @param observer an {@link Observer} of this Observable + * * @return a reference to the subscription */ super((Observer observer) -> { @@ -761,9 +748,8 @@ public class Observable { * {@link Observer} subscribes to it. *

* Write the function you pass to create so that it behaves as - * an Observable - calling the passed-in - * onNext, onError, and onCompleted - * methods appropriately. + * an Observable - calling the passed-in onNext, + * onError, and onCompleted methods appropriately. *

* A well-formed Observable must call either the {@link Observer}'s * onCompleted method exactly once or its onError @@ -772,14 +758,12 @@ public class Observable { * See Rx Design * Guidelines (PDF) for detailed information. * - * @param - * the type emitted by the Observable sequence - * @param func - * a function that accepts an Observer and calls its - * onNext, onError, and - * onCompleted methods - * as appropriate, and returns a {@link Subscription} to allow canceling the - * subscription (if applicable) + * @param the type emitted by the Observable sequence + * @param func a function that accepts an Observer and calls + * its onNext, onError, and + * onCompleted methods as appropriate, and returns a + * {@link Subscription} to allow canceling the subscription (if applicable) + * * @return an Observable that, when an {@link Observer} subscribes to it, * will execute the given function */ @@ -795,9 +779,8 @@ public class Observable { * closures using {@link FunctionLanguageAdaptor}. *

* Write the function you pass to create so that it behaves as - * an Observable - calling the passed-in - * onNext, onError, and onCompleted - * methods appropriately. + * an Observable - calling the passed-in onNext, + * onError, and onCompleted methods appropriately. *

* A well-formed Observable must call either the {@link Observer}'s * onCompleted method exactly once or its onError @@ -806,14 +789,12 @@ public class Observable { * See Rx Design * Guidelines (PDF) for detailed information. * - * @param - * the type emitted by the Observable sequence - * @param func - * a function that accepts an Observer and calls its - * onNext, onError, and - * onCompleted methods - * as appropriate, and returns a {@link Subscription} to allow canceling the - * subscription (if applicable) + * @param the type emitted by the Observable sequence + * @param func a function that accepts an Observer and calls + * its onNext, onError, and + * onCompleted methods as appropriate, and returns a + * {@link Subscription} to allow canceling the subscription (if applicable) + * * @return an Observable that, when an {@link Observer} subscribes to it, * will execute the given function */ @@ -828,11 +809,11 @@ public class Observable { *

* * - * @param - * the type of item emitted by the Observable + * @param the type of item emitted by the Observable + * * @return an Observable that returns no data to the {@link Observer} and - * immediately invokes the {@link Observer}'s - * onCompleted method + * immediately invokes the {@link Observer}'s onCompleted + * method */ public static Observable empty() { return toObservable(new ArrayList()); @@ -843,10 +824,9 @@ public class Observable { * {@link Observer} subscribes to it. *

* - * @param exception - * the error to throw - * @param - * the type of object returned by the Observable + * @param exception the error to throw + * @param the type of object returned by the Observable + * * @return an Observable object that calls onError when an * {@link Observer} subscribes */ @@ -860,11 +840,10 @@ public class Observable { *

* * - * @param that - * the Observable to filter - * @param predicate - * a function that evaluates the items emitted by the source Observable, - * returning true if they pass the filter + * @param that the Observable to filter + * @param predicate a function that evaluates the items emitted by the + * source Observable, returning true if they pass the filter + * * @return an Observable that emits only those items in the original * Observable that the filter evaluates as true */ @@ -878,11 +857,10 @@ public class Observable { *

* * - * @param that - * the Observable to filter - * @param function - * a function that evaluates the items emitted by the source Observable, - * returning true if they pass the filter + * @param that the Observable to filter + * @param function a function that evaluates the items emitted by the source + * Observable, returning true if they pass the filter + * * @return an Observable that emits only those items in the original * Observable that the filter evaluates as true */ @@ -897,11 +875,10 @@ public class Observable { *

* * - * @param that - * the Observable to filter - * @param predicate - * a function that evaluates the items emitted by the source Observable, - * returning true if they pass the filter + * @param that the Observable to filter + * @param predicate a function that evaluates the items emitted by the + * source Observable, returning true if they pass the filter + * * @return an Observable that emits only those items in the original * Observable that the filter evaluates as true */ @@ -912,13 +889,14 @@ public class Observable { /** * Converts an {@link Iterable} sequence to an Observable sequence. * - * @param iterable - * the source {@link Iterable} sequence - * @param - * the type of items in the {@link Iterable} sequence and the type emitted - * by the resulting Observable + * @param iterable the source {@link Iterable} sequence + * @param the type of items in the {@link Iterable} sequence and + * the + * type emitted by the resulting Observable + * * @return an Observable that emits each item in the source {@link Iterable} * sequence + * * @see {@link #toObservable(Iterable)} */ public static Observable from(Iterable iterable) { @@ -928,12 +906,13 @@ public class Observable { /** * Converts an Array to an Observable sequence. * - * @param items - * the source Array - * @param - * the type of items in the Array, and the type of items emitted by the - * resulting Observable + * @param items the source Array + * @param the type of items in the Array, and the type of items + * emitted + * by the resulting Observable + * * @return an Observable that emits each item in the source Array + * * @see {@link #toObservable(Object...)} */ public static Observable from(T... items) { @@ -944,10 +923,8 @@ public class Observable { * Generates an observable sequence of integral numbers within a specified * range. * - * @param start - * The value of the first integer in the sequence - * @param count - * The number of sequential integers to generate. + * @param start The value of the first integer in the sequence + * @param count The number of sequential integers to generate. * * @return An observable sequence that contains a range of sequential * integral numbers. @@ -964,12 +941,11 @@ public class Observable { * Asynchronously subscribes and unsubscribes observers on the specified * scheduler. * - * @param source - * the source observable. - * @param scheduler - * the scheduler to perform subscription and unsubscription actions on. - * @param - * the type of observable. + * @param source the source observable. + * @param scheduler the scheduler to perform subscription and unsubscription + * actions on. + * @param the type of observable. + * * @return the source sequence whose subscriptions and unsubscriptions * happen on the specified scheduler. */ @@ -980,12 +956,10 @@ public class Observable { /** * Asynchronously notify observers on the specified scheduler. * - * @param source - * the source observable. - * @param scheduler - * the scheduler to notify observers on. - * @param - * the type of observable. + * @param source the source observable. + * @param scheduler the scheduler to notify observers on. + * @param the type of observable. + * * @return the source sequence whose observations happen on the specified * scheduler. */ @@ -995,18 +969,15 @@ public class Observable { /** * Returns an observable sequence that invokes the observable factory - * whenever a new observer subscribes. - * The Defer operator allows you to defer or delay the creation of the - * sequence until the time when an observer - * subscribes to the sequence. This is useful to allow an observer to easily - * obtain an updates or refreshed version - * of the sequence. + * whenever a new observer subscribes. The Defer operator allows you to + * defer or delay the creation of the sequence until the time when an + * observer subscribes to the sequence. This is useful to allow an observer + * to easily obtain an updates or refreshed version of the sequence. + * + * @param observableFactory the observable factory function to invoke for + * each observer that subscribes to the resulting sequence. + * @param the type of the observable. * - * @param observableFactory - * the observable factory function to invoke for each observer that - * subscribes to the resulting sequence. - * @param - * the type of the observable. * @return the observable sequence whose observers trigger an invocation of * the given observable factory function. */ @@ -1016,18 +987,15 @@ public class Observable { /** * Returns an observable sequence that invokes the observable factory - * whenever a new observer subscribes. - * The Defer operator allows you to defer or delay the creation of the - * sequence until the time when an observer - * subscribes to the sequence. This is useful to allow an observer to easily - * obtain an updates or refreshed version - * of the sequence. + * whenever a new observer subscribes. The Defer operator allows you to + * defer or delay the creation of the sequence until the time when an + * observer subscribes to the sequence. This is useful to allow an observer + * to easily obtain an updates or refreshed version of the sequence. + * + * @param observableFactory the observable factory function to invoke for + * each observer that subscribes to the resulting sequence. + * @param the type of the observable. * - * @param observableFactory - * the observable factory function to invoke for each observer that - * subscribes to the resulting sequence. - * @param - * the type of the observable. * @return the observable sequence whose observers trigger an invocation of * the given observable factory function. */ @@ -1045,19 +1013,18 @@ public class Observable { * that object into the just method. *

* This is similar to the {@link #toObservable} method, except that - * toObservable will convert - * an {@link Iterable} object into an Observable that emits each of the - * items in the {@link Iterable}, one - * at a time, while the just method would convert the - * {@link Iterable} into an Observable - * that emits the entire {@link Iterable} as a single item. + * toObservable will convert an {@link Iterable} object into an + * Observable that emits each of the items in the {@link Iterable}, one at a + * time, while the just method would convert the + * {@link Iterable} into an Observable that emits the entire + * {@link Iterable} as a single item. *

* * - * @param value - * the value to pass to the Observer's onNext method - * @param - * the type of the value + * @param value the value to pass to the Observer's onNext + * method + * @param the type of the value + * * @return an Observable that notifies an {@link Observer} of a single value * and then completes */ @@ -1072,8 +1039,8 @@ public class Observable { * Returns the last element of an observable sequence with a specified * source. * - * @param that - * the source Observable + * @param that the source Observable + * * @return the last element in the observable sequence. */ public static T last(final Observable that) { @@ -1087,10 +1054,10 @@ public class Observable { * Returns the last element of an observable sequence that matches the * predicate. * - * @param that - * the source Observable - * @param predicate - * a predicate function to evaluate for elements in the sequence. + * @param that the source Observable + * @param predicate a predicate function to evaluate for elements in the + * sequence. + * * @return the last element in the observable sequence. */ public static T last(final Observable that, final Func1 predicate) { @@ -1101,10 +1068,10 @@ public class Observable { * Returns the last element of an observable sequence that matches the * predicate. * - * @param that - * the source Observable - * @param predicate - * a predicate function to evaluate for elements in the sequence. + * @param that the source Observable + * @param predicate a predicate function to evaluate for elements in the + * sequence. + * * @return the last element in the observable sequence. */ public static T last(final Observable that, final Object predicate) { @@ -1115,12 +1082,11 @@ public class Observable { * Returns the last element of an observable sequence, or a default value if * no value is found. * - * @param source - * the source observable. - * @param defaultValue - * a default value that would be returned if observable is empty. - * @param - * the type of source. + * @param source the source observable. + * @param defaultValue a default value that would be returned if observable + * is empty. + * @param the type of source. + * * @return the last element of an observable sequence that matches the * predicate, or a default value if no value is found. */ @@ -1143,14 +1109,13 @@ public class Observable { * Returns the last element of an observable sequence that matches the * predicate, or a default value if no value is found. * - * @param source - * the source observable. - * @param defaultValue - * a default value that would be returned if observable is empty. - * @param predicate - * a predicate function to evaluate for elements in the sequence. - * @param - * the type of source. + * @param source the source observable. + * @param defaultValue a default value that would be returned if observable + * is empty. + * @param predicate a predicate function to evaluate for elements in the + * sequence. + * @param the type of source. + * * @return the last element of an observable sequence that matches the * predicate, or a default value if no value is found. */ @@ -1162,14 +1127,13 @@ public class Observable { * Returns the last element of an observable sequence that matches the * predicate, or a default value if no value is found. * - * @param source - * the source observable. - * @param defaultValue - * a default value that would be returned if observable is empty. - * @param predicate - * a predicate function to evaluate for elements in the sequence. - * @param - * the type of source. + * @param source the source observable. + * @param defaultValue a default value that would be returned if observable + * is empty. + * @param predicate a predicate function to evaluate for elements in the + * sequence. + * @param the type of source. + * * @return the last element of an observable sequence that matches the * predicate, or a default value if no value is found. */ @@ -1181,23 +1145,19 @@ public class Observable { /** * Applies a function of your choosing to every notification emitted by an - * Observable, and returns - * this transformation as a new Observable sequence. + * Observable, and returns this transformation as a new Observable sequence. *

* * - * @param sequence + * @param sequence the source Observable + * @param func a function to apply to each item in the sequence emitted + * by * the source Observable - * @param func - * a function to apply to each item in the sequence emitted by the source - * Observable - * @param - * the type of items emitted by the the source Observable - * @param - * the type of items returned by map function + * @param the type of items emitted by the the source Observable + * @param the type of items returned by map function + * * @return an Observable that is the result of applying the transformation - * function to each item - * in the sequence emitted by the source Observable + * function to each item in the sequence emitted by the source Observable */ public static Observable map(Observable sequence, Func1 func) { return create(OperationMap.map(sequence, func)); @@ -1205,23 +1165,19 @@ public class Observable { /** * Applies a function of your choosing to every notification emitted by an - * Observable, and returns - * this transformation as a new Observable sequence. + * Observable, and returns this transformation as a new Observable sequence. *

* * - * @param sequence + * @param sequence the source Observable + * @param func a function to apply to each item in the sequence emitted + * by * the source Observable - * @param func - * a function to apply to each item in the sequence emitted by the source - * Observable - * @param - * the type of items emitted by the the source Observable - * @param - * the type of items returned by map function + * @param the type of items emitted by the the source Observable + * @param the type of items returned by map function + * * @return an Observable that is the result of applying the transformation - * function to each item - * in the sequence emitted by the source Observable + * function to each item in the sequence emitted by the source Observable */ public static Observable map(Observable sequence, final Object func) { final FuncN _f = Functions.from(func); @@ -1230,30 +1186,24 @@ public class Observable { /** * Creates a new Observable sequence by applying a function that you supply - * to each object in the - * original Observable sequence, where that function is itself an Observable - * that emits objects, - * and then merges the results of that function applied to every item - * emitted by the original + * to each object in the original Observable sequence, where that function + * is itself an Observable that emits objects, and then merges the results + * of that function applied to every item emitted by the original * Observable, emitting these merged results as its own sequence. *

* * - * @param sequence - * the source Observable - * @param func - * a function to apply to each item emitted by the source Observable, - * generating a - * Observable - * @param - * the type emitted by the source Observable - * @param - * the type emitted by the Observables emitted by func + * @param sequence the source Observable + * @param func a function to apply to each item emitted by the source + * Observable, generating a Observable + * @param the type emitted by the source Observable + * @param the type emitted by the Observables emitted by + * func + * * @return an Observable that emits a sequence that is the result of - * applying the transformation - * function to each item emitted by the source Observable and merging the - * results of - * the Observables obtained from this transformation + * applying the transformation function to each item emitted by the source + * Observable and merging the results of the Observables obtained from this + * transformation */ public static Observable mapMany(Observable sequence, Func1> func) { return create(OperationMap.mapMany(sequence, func)); @@ -1261,30 +1211,24 @@ public class Observable { /** * Creates a new Observable sequence by applying a function that you supply - * to each object in the - * original Observable sequence, where that function is itself an Observable - * that emits objects, - * and then merges the results of that function applied to every item - * emitted by the original + * to each object in the original Observable sequence, where that function + * is itself an Observable that emits objects, and then merges the results + * of that function applied to every item emitted by the original * Observable, emitting these merged results as its own sequence. *

* * - * @param sequence - * the source Observable - * @param func - * a function to apply to each item emitted by the source Observable, - * generating a - * Observable - * @param - * the type emitted by the source Observable - * @param - * the type emitted by the Observables emitted by func + * @param sequence the source Observable + * @param func a function to apply to each item emitted by the source + * Observable, generating a Observable + * @param the type emitted by the source Observable + * @param the type emitted by the Observables emitted by + * func + * * @return an Observable that emits a sequence that is the result of - * applying the transformation - * function to each item emitted by the source Observable and merging the - * results of - * the Observables obtained from this transformation + * applying the transformation function to each item emitted by the source + * Observable and merging the results of the Observables obtained from this + * transformation */ public static Observable mapMany(Observable sequence, final Object func) { final FuncN _f = Functions.from(func); @@ -1297,10 +1241,11 @@ public class Observable { *

* * - * @param sequence - * An observable sequence of elements to project. + * @param sequence An observable sequence of elements to project. + * * @return An observable sequence whose elements are the result of * materializing the notifications of the given sequence. + * * @see * MSDN: * Observable.Materialize @@ -1313,11 +1258,12 @@ public class Observable { * Dematerializes the explicit notification values of an observable sequence * as implicit notifications. * - * @param sequence - * An observable sequence containing explicit notification values which have - * to be turned into implicit notifications. + * @param sequence An observable sequence containing explicit notification + * values which have to be turned into implicit notifications. + * * @return An observable sequence exhibiting the behavior corresponding to * the source sequence's notification values. + * * @see * MSDN: * Observable.Dematerialize @@ -1328,18 +1274,18 @@ public class Observable { /** * Flattens the Observable sequences from a list of Observables into one - * Observable sequence - * without any transformation. You can combine the output of multiple - * Observables so that they - * act like a single Observable, by using the merge method. + * Observable sequence without any transformation. You can combine the + * output of multiple Observables so that they act like a single Observable, + * by using the merge method. *

* * - * @param source - * a list of Observables that emit sequences of items + * @param source a list of Observables that emit sequences of items + * * @return an Observable that emits a sequence of elements that are the - * result of flattening the - * output from the source list of Observables + * result of flattening the output from the source list of + * Observables + * * @see * MSDN: * Observable.Merge @@ -1350,19 +1296,19 @@ public class Observable { /** * Flattens the Observable sequences emitted by a sequence of Observables - * that are emitted by a - * Observable into one Observable sequence without any transformation. You - * can combine the output - * of multiple Observables so that they act like a single Observable, by - * using the merge method. + * that are emitted by a Observable into one Observable sequence without any + * transformation. You can combine the output of multiple Observables so + * that they act like a single Observable, by using the merge + * method. *

* * - * @param source - * an Observable that emits Observables + * @param source an Observable that emits Observables + * * @return an Observable that emits a sequence of elements that are the - * result of flattening the - * output from the Observables emitted by the source Observable + * result of flattening the output from the Observables emitted by the + * source Observable + * * @see * MSDN: * Observable.Merge Method @@ -1373,18 +1319,17 @@ public class Observable { /** * Flattens the Observable sequences from a series of Observables into one - * Observable sequence - * without any transformation. You can combine the output of multiple - * Observables so that they - * act like a single Observable, by using the merge method. + * Observable sequence without any transformation. You can combine the + * output of multiple Observables so that they act like a single Observable, + * by using the merge method. *

* * - * @param source - * a series of Observables that emit sequences of items + * @param source a series of Observables that emit sequences of items + * * @return an Observable that emits a sequence of elements that are the - * result of flattening the - * output from the source Observables + * result of flattening the output from the source Observables + * * @see * MSDN: * Observable.Merge Method @@ -1397,15 +1342,12 @@ public class Observable { * Returns the values from the source observable sequence until the other * observable sequence produces a value. * - * @param source - * the source sequence to propagate elements for. - * @param other - * the observable sequence that terminates propagation of elements of the - * source sequence. - * @param - * the type of source. - * @param - * the other type. + * @param source the source sequence to propagate elements for. + * @param other the observable sequence that terminates propagation of + * elements of the source sequence. + * @param the type of source. + * @param the other type. + * * @return An observable sequence containing the elements of the source * sequence up to the point the other sequence interrupted further * propagation. @@ -1416,16 +1358,15 @@ public class Observable { /** * Combines the objects emitted by two or more Observables, and emits the - * result as a single Observable, - * by using the concat method. + * result as a single Observable, by using the concat method. *

* * - * @param source - * a series of Observables that emit sequences of items + * @param source a series of Observables that emit sequences of items + * * @return an Observable that emits a sequence of elements that are the - * result of combining the - * output from the source Observables + * result of combining the output from the source Observables + * * @see * MSDN: * Observable.Concat Method @@ -1438,11 +1379,11 @@ public class Observable { * Emits the same objects as the given Observable, calling the given action * when it calls onComplete or onError. * - * @param source - * an observable - * @param action - * an action to be called when the source completes or errors. + * @param source an observable + * @param action an action to be called when the source completes or errors. + * * @return an Observable that emits the same objects, then calls the action. + * * @see * MSDN: * Observable.Finally Method @@ -1455,22 +1396,17 @@ public class Observable { * Groups the elements of an observable and selects the resulting elements * by using a specified function. * - * @param source - * an observable whose elements to group. - * @param keySelector - * a function to extract the key for each element. - * @param elementSelector - * a function to map each source element to an element in an observable - * group. - * @param - * the key type. - * @param - * the source type. - * @param - * the resulting observable type. + * @param source an observable whose elements to group. + * @param keySelector a function to extract the key for each element. + * @param elementSelector a function to map each source element to an + * element in an observable group. + * @param the key type. + * @param the source type. + * @param the resulting observable type. + * * @return an observable of observable groups, each of which corresponds to - * a unique key value, containing all elements that share that same - * key value. + * a unique key value, containing all elements that share that same key + * value. */ public static Observable> groupBy(Observable source, final Func1 keySelector, final Func1 elementSelector) { return create(OperatorGroupBy.groupBy(source, keySelector, elementSelector)); @@ -1480,17 +1416,14 @@ public class Observable { * Groups the elements of an observable according to a specified key * selector function and * - * @param source - * an observable whose elements to group. - * @param keySelector - * a function to extract the key for each element. - * @param - * the key type. - * @param - * the source type. + * @param source an observable whose elements to group. + * @param keySelector a function to extract the key for each element. + * @param the key type. + * @param the source type. + * * @return an observable of observable groups, each of which corresponds to - * a unique key value, containing all elements that share that same - * key value. + * a unique key value, containing all elements that share that same key + * value. */ public static Observable> groupBy(Observable source, final Func1 keySelector) { return create(OperatorGroupBy.groupBy(source, keySelector)); @@ -1508,11 +1441,12 @@ public class Observable { *

* * - * @param source - * a list of Observables that emit sequences of items + * @param source a list of Observables that emit sequences of items + * * @return an Observable that emits a sequence of elements that are the - * result of flattening the - * output from the source list of Observables + * result of flattening the output from the source list of + * Observables + * * @see * MSDN: * Observable.Merge Method @@ -1533,11 +1467,12 @@ public class Observable { *

* * - * @param source - * an Observable that emits Observables + * @param source an Observable that emits Observables + * * @return an Observable that emits a sequence of elements that are the - * result of flattening the - * output from the Observables emitted by the source Observable + * result of flattening the output from the Observables emitted by the + * source Observable + * * @see * MSDN: * Observable.Merge Method @@ -1558,11 +1493,11 @@ public class Observable { *

* * - * @param source - * a series of Observables that emit sequences of items + * @param source a series of Observables that emit sequences of items + * * @return an Observable that emits a sequence of elements that are the - * result of flattening the - * output from the source Observables + * result of flattening the output from the source Observables + * * @see * MSDN: * Observable.Merge Method @@ -1577,8 +1512,8 @@ public class Observable { *

* This observable is useful primarily for testing purposes. * - * @param - * the type of item (not) emitted by the Observable + * @param the type of item (not) emitted by the Observable + * * @return an Observable that never sends any information to an * {@link Observer} */ @@ -1588,36 +1523,32 @@ public class Observable { /** * Instruct an Observable to pass control to another Observable (the return - * value of a function) - * rather than calling onError if it encounters an error. + * value of a function) rather than calling onError if it + * encounters an error. *

* By default, when an Observable encounters an error that prevents it from - * emitting the expected item to its Observer, - * the Observable calls its {@link Observer}'s onError - * function, and then quits without calling any more - * of its {@link Observer}'s closures. The onErrorResumeNext - * method changes this behavior. If you pass a - * function that emits an Observable (resumeFunction) to an - * Observable's onErrorResumeNext method, - * if the original Observable encounters an error, instead of calling its - * {@link Observer}'s onError function, it - * will instead relinquish control to this new Observable, which will call - * the {@link Observer}'s onNext method if - * it is able to do so. In such a case, because no Observable necessarily - * invokes onError, the Observer may - * never know that an error happened. + * emitting the expected item to its Observer, the Observable calls its + * {@link Observer}'s onError function, and then quits without + * calling any more of its {@link Observer}'s closures. The + * onErrorResumeNext method changes this behavior. If you pass + * a function that emits an Observable (resumeFunction) to an + * Observable's onErrorResumeNext method, if the original + * Observable encounters an error, instead of calling its {@link Observer}'s + * onError function, it will instead relinquish control to this + * new Observable, which will call the {@link Observer}'s + * onNext method if it is able to do so. In such a case, + * because no Observable necessarily invokes onError, the + * Observer may never know that an error happened. *

* You can use this to prevent errors from propagating or to supply fallback * data should errors be encountered. *

* * - * @param that - * the source Observable - * @param resumeFunction - * a function that returns an Observable that will take over if the source - * Observable - * encounters an error + * @param that the source Observable + * @param resumeFunction a function that returns an Observable that will + * take over if the source Observable encounters an error + * * @return the source Observable, with its behavior modified as described */ public static Observable onErrorResumeNext(final Observable that, final Func1> resumeFunction) { @@ -1626,36 +1557,32 @@ public class Observable { /** * Instruct an Observable to pass control to another Observable (the return - * value of a function) - * rather than calling onError if it encounters an error. + * value of a function) rather than calling onError if it + * encounters an error. *

* By default, when an Observable encounters an error that prevents it from - * emitting the expected item to its Observer, - * the Observable calls its {@link Observer}'s onError - * function, and then quits without calling any more - * of its {@link Observer}'s closures. The onErrorResumeNext - * method changes this behavior. If you pass a - * function that emits an Observable (resumeFunction) to an - * Observable's onErrorResumeNext method, - * if the original Observable encounters an error, instead of calling its - * {@link Observer}'s onError function, it - * will instead relinquish control to this new Observable, which will call - * the {@link Observer}'s onNext method if - * it is able to do so. In such a case, because no Observable necessarily - * invokes onError, the Observer may - * never know that an error happened. + * emitting the expected item to its Observer, the Observable calls its + * {@link Observer}'s onError function, and then quits without + * calling any more of its {@link Observer}'s closures. The + * onErrorResumeNext method changes this behavior. If you pass + * a function that emits an Observable (resumeFunction) to an + * Observable's onErrorResumeNext method, if the original + * Observable encounters an error, instead of calling its {@link Observer}'s + * onError function, it will instead relinquish control to this + * new Observable, which will call the {@link Observer}'s + * onNext method if it is able to do so. In such a case, + * because no Observable necessarily invokes onError, the + * Observer may never know that an error happened. *

* You can use this to prevent errors from propagating or to supply fallback * data should errors be encountered. *

* * - * @param that - * the source Observable - * @param resumeFunction - * a function that returns an Observable that will take over if the source - * Observable - * encounters an error + * @param that the source Observable + * @param resumeFunction a function that returns an Observable that will + * take over if the source Observable encounters an error + * * @return the source Observable, with its behavior modified as described */ public static Observable onErrorResumeNext(final Observable that, final Object resumeFunction) { @@ -1668,32 +1595,28 @@ public class Observable { * calling onError if it encounters an error. *

* By default, when an Observable encounters an error that prevents it from - * emitting the expected item to its Observer, - * the Observable calls its {@link Observer}'s onError - * function, and then quits without calling any more - * of its {@link Observer}'s closures. The onErrorResumeNext - * method changes this behavior. If you pass a - * function that emits an Observable (resumeFunction) to an - * Observable's onErrorResumeNext method, - * if the original Observable encounters an error, instead of calling its - * {@link Observer}'s onError function, it - * will instead relinquish control to this new Observable, which will call - * the {@link Observer}'s onNext method if - * it is able to do so. In such a case, because no Observable necessarily - * invokes onError, the Observer may - * never know that an error happened. + * emitting the expected item to its Observer, the Observable calls its + * {@link Observer}'s onError function, and then quits without + * calling any more of its {@link Observer}'s closures. The + * onErrorResumeNext method changes this behavior. If you pass + * a function that emits an Observable (resumeFunction) to an + * Observable's onErrorResumeNext method, if the original + * Observable encounters an error, instead of calling its {@link Observer}'s + * onError function, it will instead relinquish control to this + * new Observable, which will call the {@link Observer}'s + * onNext method if it is able to do so. In such a case, + * because no Observable necessarily invokes onError, the + * Observer may never know that an error happened. *

* You can use this to prevent errors from propagating or to supply fallback * data should errors be encountered. *

* * - * @param that - * the source Observable - * @param resumeSequence - * a function that returns an Observable that will take over if the source - * Observable - * encounters an error + * @param that the source Observable + * @param resumeSequence a function that returns an Observable that will + * take over if the source Observable encounters an error + * * @return the source Observable, with its behavior modified as described */ public static Observable onErrorResumeNext(final Observable that, final Observable resumeSequence) { @@ -1702,33 +1625,30 @@ public class Observable { /** * Instruct an Observable to emit a particular item to its Observer's - * onNext function - * rather than calling onError if it encounters an error. + * onNext function rather than calling onError if + * it encounters an error. *

* By default, when an Observable encounters an error that prevents it from * emitting the expected item to its {@link Observer}, the Observable calls - * its {@link Observer}'s onError - * function, and then quits + * its {@link Observer}'s onError function, and then quits * without calling any more of its {@link Observer}'s closures. The - * onErrorReturn method changes - * this behavior. If you pass a function (resumeFunction) to an - * Observable's onErrorReturn - * method, if the original Observable encounters an error, instead of - * calling its {@link Observer}'s - * onError function, it will instead pass the return value of + * onErrorReturn method changes this behavior. If you pass a + * function (resumeFunction) to an Observable's + * onErrorReturn method, if the original Observable encounters + * an error, instead of calling its {@link Observer}'s onError + * function, it will instead pass the return value of * resumeFunction to the {@link Observer}'s onNext * method. *

* You can use this to prevent errors from propagating or to supply fallback * data should errors be encountered. * - * @param that - * the source Observable - * @param resumeFunction - * a function that returns a value that will be passed into an - * {@link Observer}'s onNext function if - * the Observable encounters an error that would - * otherwise cause it to call onError + * @param that the source Observable + * @param resumeFunction a function that returns a value that will be passed + * into an {@link Observer}'s onNext function if the Observable + * encounters an error that would otherwise cause it to call + * onError + * * @return the source Observable, with its behavior modified as described */ public static Observable onErrorReturn(final Observable that, Func1 resumeFunction) { @@ -1737,36 +1657,29 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the final result from the final call to your - * function as its sole - * output. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the final result from the final call to your + * function as its sole output. *

* This technique, which is called "reduce" here, is sometimes called * "fold," "accumulate," "compress," or "inject" in other programming - * contexts. Groovy, for instance, has an inject - * method that does a similar operation on lists. + * contexts. Groovy, for instance, has an inject method that + * does a similar operation on lists. *

* * - * @param - * the type item emitted by the source Observable - * @param sequence - * the source Observable - * @param accumulator - * an accumulator function to be invoked on each element from the sequence, - * whose - * result will be used in the next accumulator call (if applicable) + * @param the type item emitted by the source Observable + * @param sequence the source Observable + * @param accumulator an accumulator function to be invoked on each element + * from the sequence, whose result will be used in the next accumulator call + * (if applicable) * * @return an Observable that emits a single element that is the result of - * accumulating the - * output from applying the accumulator to the sequence of items emitted by - * the source - * Observable + * accumulating the output from applying the accumulator to the sequence of + * items emitted by the source Observable + * * @see * MSDN: * Observable.Aggregate @@ -1780,36 +1693,29 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the final result from the final call to your - * function as its sole - * output. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the final result from the final call to your + * function as its sole output. *

* This technique, which is called "reduce" here, is sometimes called * "fold," "accumulate," "compress," or "inject" in other programming - * contexts. Groovy, for instance, has an inject - * method that does a similar operation on lists. + * contexts. Groovy, for instance, has an inject method that + * does a similar operation on lists. *

* * - * @param - * the type item emitted by the source Observable - * @param sequence - * the source Observable - * @param accumulator - * an accumulator function to be invoked on each element from the sequence, - * whose - * result will be used in the next accumulator call (if applicable) + * @param the type item emitted by the source Observable + * @param sequence the source Observable + * @param accumulator an accumulator function to be invoked on each element + * from the sequence, whose result will be used in the next accumulator call + * (if applicable) * * @return an Observable that emits a single element that is the result of - * accumulating the - * output from applying the accumulator to the sequence of items emitted by - * the source - * Observable + * accumulating the output from applying the accumulator to the sequence of + * items emitted by the source Observable + * * @see * MSDN: * Observable.Aggregate @@ -1824,38 +1730,31 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the final result from the final call to your - * function as its sole - * output. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the final result from the final call to your + * function as its sole output. *

* This technique, which is called "reduce" here, is sometimes called * "fold," "accumulate," "compress," or "inject" in other programming - * contexts. Groovy, for instance, has an inject - * method that does a similar operation on lists. + * contexts. Groovy, for instance, has an inject method that + * does a similar operation on lists. *

* * - * @param - * the type item emitted by the source Observable - * @param sequence - * the source Observable - * @param initialValue - * a seed passed into the first execution of the accumulator function - * @param accumulator - * an accumulator function to be invoked on each element from the sequence, - * whose - * result will be used in the next accumulator call (if applicable) + * @param the type item emitted by the source Observable + * @param sequence the source Observable + * @param initialValue a seed passed into the first execution of the + * accumulator function + * @param accumulator an accumulator function to be invoked on each element + * from the sequence, whose result will be used in the next accumulator call + * (if applicable) * * @return an Observable that emits a single element that is the result of - * accumulating the - * output from applying the accumulator to the sequence of items emitted by - * the source - * Observable + * accumulating the output from applying the accumulator to the sequence of + * items emitted by the source Observable + * * @see * MSDN: * Observable.Aggregate @@ -1869,37 +1768,31 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the final result from the final call to your - * function as its sole - * output. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the final result from the final call to your + * function as its sole output. *

* This technique, which is called "reduce" here, is sometimes called * "fold," "accumulate," "compress," or "inject" in other programming - * contexts. Groovy, for instance, has an inject - * method that does a similar operation on lists. + * contexts. Groovy, for instance, has an inject method that + * does a similar operation on lists. *

* * - * @param - * the type item emitted by the source Observable - * @param sequence - * the source Observable - * @param initialValue - * a seed passed into the first execution of the accumulator function - * @param accumulator - * an accumulator function to be invoked on each element from the sequence, - * whose - * result will be used in the next accumulator call (if applicable) + * @param the type item emitted by the source Observable + * @param sequence the source Observable + * @param initialValue a seed passed into the first execution of the + * accumulator function + * @param accumulator an accumulator function to be invoked on each element + * from the sequence, whose result will be used in the next accumulator call + * (if applicable) + * * @return an Observable that emits a single element that is the result of - * accumulating the - * output from applying the accumulator to the sequence of items emitted by - * the source - * Observable + * accumulating the output from applying the accumulator to the sequence of + * items emitted by the source Observable + * * @see * MSDN: * Observable.Aggregate @@ -1914,28 +1807,24 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the result of each of these iterations as its - * own sequence. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the result of each of these iterations as its own + * sequence. *

* * - * @param - * the type item emitted by the source Observable - * @param sequence - * the source Observable - * @param accumulator - * an accumulator function to be invoked on each element from the sequence, - * whose - * result will be emitted and used in the next accumulator call (if - * applicable) + * @param the type item emitted by the source Observable + * @param sequence the source Observable + * @param accumulator an accumulator function to be invoked on each element + * from the sequence, whose result will be emitted and used in the next + * accumulator call (if applicable) + * * @return an Observable that emits a sequence of items that are the result - * of accumulating the - * output from the sequence emitted by the source Observable + * of accumulating the output from the sequence emitted by the source + * Observable + * * @see * MSDN: * Observable.Scan @@ -1946,28 +1835,24 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the result of each of these iterations as its - * own sequence. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the result of each of these iterations as its own + * sequence. *

* * - * @param - * the type item emitted by the source Observable - * @param sequence - * the source Observable - * @param accumulator - * an accumulator function to be invoked on each element from the sequence, - * whose - * result will be emitted and used in the next accumulator call (if - * applicable) + * @param the type item emitted by the source Observable + * @param sequence the source Observable + * @param accumulator an accumulator function to be invoked on each element + * from the sequence, whose result will be emitted and used in the next + * accumulator call (if applicable) + * * @return an Observable that emits a sequence of items that are the result - * of accumulating the - * output from the sequence emitted by the source Observable + * of accumulating the output from the sequence emitted by the source + * Observable + * * @see * MSDN: * Observable.Scan @@ -1979,30 +1864,25 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the result of each of these iterations as its - * own sequence. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the result of each of these iterations as its own + * sequence. *

* * - * @param - * the type item emitted by the source Observable - * @param sequence - * the source Observable - * @param initialValue - * the initial (seed) accumulator value - * @param accumulator - * an accumulator function to be invoked on each element from the sequence, - * whose - * result will be emitted and used in the next accumulator call (if - * applicable) + * @param the type item emitted by the source Observable + * @param sequence the source Observable + * @param initialValue the initial (seed) accumulator value + * @param accumulator an accumulator function to be invoked on each element + * from the sequence, whose result will be emitted and used in the next + * accumulator call (if applicable) + * * @return an Observable that emits a sequence of items that are the result - * of accumulating the - * output from the sequence emitted by the source Observable + * of accumulating the output from the sequence emitted by the source + * Observable + * * @see * MSDN: * Observable.Scan @@ -2013,30 +1893,25 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the result of each of these iterations as its - * own sequence. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the result of each of these iterations as its own + * sequence. *

* * - * @param - * the type item emitted by the source Observable - * @param sequence - * the source Observable - * @param initialValue - * the initial (seed) accumulator value - * @param accumulator - * an accumulator function to be invoked on each element from the sequence, - * whose - * result will be emitted and used in the next accumulator call (if - * applicable) + * @param the type item emitted by the source Observable + * @param sequence the source Observable + * @param initialValue the initial (seed) accumulator value + * @param accumulator an accumulator function to be invoked on each element + * from the sequence, whose result will be emitted and used in the next + * accumulator call (if applicable) + * * @return an Observable that emits a sequence of items that are the result - * of accumulating the - * output from the sequence emitted by the source Observable + * of accumulating the output from the sequence emitted by the source + * Observable + * * @see * MSDN: * Observable.Scan @@ -2050,12 +1925,11 @@ public class Observable { * Determines whether all elements of an observable sequence satisfies a * condition. * - * @param sequence - * an observable sequence whose elements to apply the predicate to. - * @param predicate - * a function to test each element for a condition. - * @param - * the type of observable. + * @param sequence an observable sequence whose elements to apply the + * predicate to. + * @param predicate a function to test each element for a condition. + * @param the type of observable. + * * @return true if all elements of an observable sequence satisfies a * condition; otherwise, false. */ @@ -2067,12 +1941,11 @@ public class Observable { * Determines whether all elements of an observable sequence satisfies a * condition. * - * @param sequence - * an observable sequence whose elements to apply the predicate to. - * @param predicate - * a function to test each element for a condition. - * @param - * the type of observable. + * @param sequence an observable sequence whose elements to apply the + * predicate to. + * @param predicate a function to test each element for a condition. + * @param the type of observable. + * * @return true if all elements of an observable sequence satisfies a * condition; otherwise, false. */ @@ -2083,21 +1956,18 @@ public class Observable { /** * Returns an Observable that skips the first num items emitted - * by the source - * Observable. You can ignore the first num items emitted by an - * Observable and attend - * only to those items that come after, by modifying the Observable with the - * skip method. + * by the source Observable. You can ignore the first num items + * emitted by an Observable and attend only to those items that come after, + * by modifying the Observable with the skip method. *

* * - * @param items - * the source Observable - * @param num - * the number of items to skip + * @param items the source Observable + * @param num the number of items to skip + * * @return an Observable that emits the same sequence of items emitted by - * the source Observable, - * except for the first num items + * the source Observable, except for the first num items + * * @see * MSDN: * Observable.Skip Method @@ -2108,8 +1978,7 @@ public class Observable { /** * Accepts an Observable and wraps it in another Observable that ensures - * that the resulting - * Observable is chronologically well-behaved. + * that the resulting Observable is chronologically well-behaved. *

* A well-behaved observable ensures onNext, * onCompleted, or onError calls to its @@ -2118,10 +1987,9 @@ public class Observable { * onNext calls follow onCompleted and * onError calls. * - * @param observable - * the source Observable - * @param - * the type of item emitted by the source Observable + * @param observable the source Observable + * @param the type of item emitted by the source Observable + * * @return an Observable that is a chronologically well-behaved version of * the source Observable */ @@ -2131,26 +1999,23 @@ public class Observable { /** * Returns an Observable that emits the first num items emitted - * by the source - * Observable. + * by the source Observable. *

* You can choose to pay attention only to the first num values * emitted by an Observable by calling its take method. This - * method returns an Observable that will call a - * subscribing Observer's onNext function a - * maximum of num times before calling - * onCompleted. + * method returns an Observable that will call a subscribing Observer's + * onNext function a maximum of num times before + * calling onCompleted. *

* * - * @param items - * the source Observable - * @param num - * the number of items from the start of the sequence emitted by the source - * Observable to emit + * @param items the source Observable + * @param num the number of items from the start of the sequence emitted + * by + * the source Observable to emit + * * @return an Observable that only emits the first num items - * emitted by the source - * Observable + * emitted by the source Observable */ public static Observable take(final Observable items, final int num) { return create(OperationTake.take(items, num)); @@ -2158,17 +2023,14 @@ public class Observable { /** * Returns an Observable that emits the last count items - * emitted by the source - * Observable. + * emitted by the source Observable. + * + * @param items the source Observable + * @param count the number of items from the end of the sequence emitted by + * the source Observable to emit * - * @param items - * the source Observable - * @param count - * the number of items from the end of the sequence emitted by the source - * Observable to emit * @return an Observable that only emits the last count items - * emitted by the source - * Observable + * emitted by the source Observable */ public static Observable takeLast(final Observable items, final int count) { return create(OperationTakeLast.takeLast(items, count)); @@ -2179,8 +2041,8 @@ public class Observable { * observable sequence. * * @param items - * @param predicate - * a function to test each source element for a condition + * @param predicate a function to test each source element for a condition + * * @return */ public static Observable takeWhile(final Observable items, Func1 predicate) { @@ -2192,8 +2054,8 @@ public class Observable { * observable sequence. * * @param items - * @param predicate - * a function to test each source element for a condition + * @param predicate a function to test each source element for a condition + * * @return */ public static Observable takeWhile(final Observable items, Object predicate) { @@ -2207,10 +2069,10 @@ public class Observable { * condition is true, and then skips the remaining values. * * @param items - * @param predicate - * a function to test each element for a condition; the second parameter of - * the function represents the index of the source element; - * otherwise, false. + * @param predicate a function to test each element for a condition; the + * second parameter of the function represents the index of the source + * element; otherwise, false. + * * @return */ public static Observable takeWhileWithIndex(final Observable items, Func2 predicate) { @@ -2225,28 +2087,22 @@ public class Observable { /** * Returns an Observable that emits a single item, a list composed of all - * the items emitted by - * the source Observable. + * the items emitted by the source Observable. *

* Normally, an Observable that returns multiple items will do so by calling * its Observer's onNext function for each such item. You can - * change this behavior, instructing the - * Observable - * to - * compose a list of all of these multiple items and - * then to call the Observer's onNext function once, passing it - * the entire list, by calling the Observable object's toList - * method prior to calling its - * subscribe - * method. + * change this behavior, instructing the Observable to compose a list of all + * of these multiple items and then to call the Observer's + * onNext function once, passing it the entire list, by calling + * the Observable object's toList method prior to calling its + * subscribe method. *

* * - * @param that - * the source Observable + * @param that the source Observable + * * @return an Observable that emits a single item: a List - * containing all of the - * items emitted by the source Observable + * containing all of the items emitted by the source Observable */ public static Observable> toList(final Observable that) { return create(OperationToObservableList.toObservableList(that)); @@ -2255,8 +2111,8 @@ public class Observable { /** * Converts an observable sequence to an Iterable. * - * @param that - * the source Observable + * @param that the source Observable + * * @return Observable converted to Iterable. */ public static Iterable toIterable(final Observable that) { @@ -2272,10 +2128,9 @@ public class Observable { /** * Returns an iterator that iterates all values of the observable. * - * @param that - * an observable sequence to get an iterator for. - * @param - * the type of source. + * @param that an observable sequence to get an iterator for. + * @param the type of source. + * * @return the iterator that could be used to iterate over the elements of * the observable. */ @@ -2287,10 +2142,9 @@ public class Observable { * Samples the next value (blocking without buffering) from in an observable * sequence. * - * @param items - * the source observable sequence. - * @param - * the type of observable. + * @param items the source observable sequence. + * @param the type of observable. + * * @return iterable that blocks upon each iteration until the next element * in the observable source sequence becomes available. */ @@ -2301,13 +2155,11 @@ public class Observable { /** * Samples the most recent value in an observable sequence. * - * @param source - * the source observable sequence. - * @param - * the type of observable. - * @param initialValue - * the initial value that will be yielded by the enumerable sequence if no - * element has been sampled yet. + * @param source the source observable sequence. + * @param the type of observable. + * @param initialValue the initial value that will be yielded by the + * enumerable sequence if no element has been sampled yet. + * * @return the iterable that returns the last sampled element upon each * iteration. */ @@ -2319,11 +2171,12 @@ public class Observable { * Returns the only element of an observable sequence and throws an * exception if there is not exactly one element in the observable sequence. * - * @param that - * the source Observable + * @param that the source Observable + * * @return The single element in the observable sequence. - * @throws IllegalStateException - * if there is not exactly one element in the observable sequence + * + * @throws IllegalStateException if there is not exactly one element in the + * observable sequence */ public static T single(Observable that) { return singleOrDefault(that, false, null); @@ -2334,14 +2187,14 @@ public class Observable { * predicate and throws an exception if there is not exactly one element in * the observable sequence. * - * @param that - * the source Observable - * @param predicate - * A predicate function to evaluate for elements in the sequence. + * @param that the source Observable + * @param predicate A predicate function to evaluate for elements in the + * sequence. + * * @return The single element in the observable sequence. - * @throws IllegalStateException - * if there is not exactly one element in the observable sequence that - * matches the predicate + * + * @throws IllegalStateException if there is not exactly one element in the + * observable sequence that matches the predicate */ public static T single(Observable that, Func1 predicate) { return single(that.filter(predicate)); @@ -2352,14 +2205,14 @@ public class Observable { * predicate and throws an exception if there is not exactly one element in * the observable sequence. * - * @param that - * the source Observable - * @param predicate - * A predicate function to evaluate for elements in the sequence. + * @param that the source Observable + * @param predicate A predicate function to evaluate for elements in the + * sequence. + * * @return The single element in the observable sequence. - * @throws IllegalStateException - * if there is not exactly one element in the observable sequence that - * matches the predicate + * + * @throws IllegalStateException if there is not exactly one element in the + * observable sequence that matches the predicate */ public static T single(Observable that, Object predicate) { final FuncN _f = Functions.from(predicate); @@ -2371,10 +2224,9 @@ public class Observable { * Returns the only element of an observable sequence, or a default value if * the observable sequence is empty. * - * @param that - * the source Observable - * @param defaultValue - * default value for a sequence. + * @param that the source Observable + * @param defaultValue default value for a sequence. + * * @return The single element in the observable sequence, or a default value * if no value is found. */ @@ -2386,12 +2238,11 @@ public class Observable { * Returns the only element of an observable sequence that matches the * predicate, or a default value if no value is found. * - * @param that - * the source Observable - * @param defaultValue - * default value for a sequence. - * @param predicate - * A predicate function to evaluate for elements in the sequence. + * @param that the source Observable + * @param defaultValue default value for a sequence. + * @param predicate A predicate function to evaluate for elements in the + * sequence. + * * @return The single element in the observable sequence, or a default value * if no value is found. */ @@ -2403,12 +2254,11 @@ public class Observable { * Returns the only element of an observable sequence that matches the * predicate, or a default value if no value is found. * - * @param that - * the source Observable - * @param defaultValue - * default value for a sequence. - * @param predicate - * A predicate function to evaluate for elements in the sequence. + * @param that the source Observable + * @param defaultValue default value for a sequence. + * @param predicate A predicate function to evaluate for elements in the + * sequence. + * * @return The single element in the observable sequence, or a default value * if no value is found. */ @@ -2439,18 +2289,15 @@ public class Observable { * Converts an Iterable sequence to an Observable sequence. *

* Any object that supports the Iterable interface can be converted into an - * Observable that emits - * each iterable item in the object, by passing the object into the - * toObservable method. + * Observable that emits each iterable item in the object, by passing the + * object into the toObservable method. *

* * - * @param iterable - * the source Iterable sequence - * @param - * the type of items in the iterable sequence and the type emitted by the - * resulting - * Observable + * @param iterable the source Iterable sequence + * @param the type of items in the iterable sequence and the type + * emitted by the resulting Observable + * * @return an Observable that emits each item in the source Iterable * sequence */ @@ -2462,19 +2309,17 @@ public class Observable { * Converts an Future to an Observable sequence. *

* Any object that supports the {@link Future} interface can be converted - * into an Observable that emits - * the return value of the get() method in the object, by passing the object - * into the toObservable method. + * into an Observable that emits the return value of the get() method in the + * object, by passing the object into the toObservable method. *

* This is blocking so the Subscription returned when calling * {@link #subscribe(Observer)} does nothing. * - * @param future - * the source {@link Future} - * @param - * the type of of object that the future's returns and the type emitted by - * the resulting - * Observable + * @param future the source {@link Future} + * @param the type of of object that the future's returns and the + * type + * emitted by the resulting Observable + * * @return an Observable that emits the item from the source Future */ public static Observable toObservable(Future future) { @@ -2485,25 +2330,21 @@ public class Observable { * Converts an Future to an Observable sequence. *

* Any object that supports the {@link Future} interface can be converted - * into an Observable that emits - * the return value of the get() method in the object, by passing the object - * into the toObservable method. + * into an Observable that emits the return value of the get() method in the + * object, by passing the object into the toObservable method. * The subscribe method on this synchronously so the Subscription returned * doesn't nothing. *

* This is blocking so the Subscription returned when calling * {@link #subscribe(Observer)} does nothing. * - * @param future - * the source {@link Future} - * @param timeout - * the maximum time to wait - * @param unit - * the time unit of the time argument - * @param - * the type of of object that the future's returns and the type emitted by - * the resulting - * Observable + * @param future the source {@link Future} + * @param timeout the maximum time to wait + * @param unit the time unit of the time argument + * @param the type of of object that the future's returns and the + * type + * emitted by the resulting Observable + * * @return an Observable that emits the item from the source Future */ public static Observable toObservable(Future future, long timeout, TimeUnit unit) { @@ -2514,17 +2355,15 @@ public class Observable { * Converts an Array sequence to an Observable sequence. *

* An Array can be converted into an Observable that emits each item in the - * Array, by passing the - * Array into the toObservable method. + * Array, by passing the Array into the toObservable method. *

* * - * @param items - * the source Array - * @param - * the type of items in the Array, and the type of items emitted by the - * resulting - * Observable + * @param items the source Array + * @param the type of items in the Array, and the type of items + * emitted + * by the resulting Observable + * * @return an Observable that emits each item in the source Array */ public static Observable toObservable(T... items) { @@ -2537,8 +2376,8 @@ public class Observable { * * * @param sequence - * @throws ClassCastException - * if T objects do not implement Comparable + * + * @throws ClassCastException if T objects do not implement Comparable * @return */ public static Observable> toSortedList(Observable sequence) { @@ -2552,6 +2391,7 @@ public class Observable { * * @param sequence * @param sortFunction + * * @return */ public static Observable> toSortedList(Observable sequence, Func2 sortFunction) { @@ -2565,6 +2405,7 @@ public class Observable { * * @param sequence * @param sortFunction + * * @return */ public static Observable> toSortedList(Observable sequence, final Object sortFunction) { @@ -2574,35 +2415,31 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * combination of items - * emitted, in sequence, by two other Observables, with the results of this - * function becoming the - * sequence emitted by the returned Observable. + * combination of items emitted, in sequence, by two other Observables, with + * the results of this function becoming the sequence emitted by the + * returned Observable. *

* zip applies this function in strict sequence, so the first * item emitted by the new Observable will be the result of the function - * applied to the first item emitted by - * w0 - * and the first item emitted by w1; the - * second item emitted by the new Observable will be the result of the - * function applied to the second item emitted by w0 and the - * second item emitted by w1; and so forth. + * applied to the first item emitted by w0 and the first item + * emitted by w1; the second item emitted by the new Observable + * will be the result of the function applied to the second item emitted by + * w0 and the second item emitted by w1; and so + * forth. *

* The resulting Observable returned from zip * will call onNext as many times as the number - * onNext calls of the source Observable with the - * shortest sequence. + * onNext calls of the source Observable with the shortest + * sequence. *

* * - * @param w0 - * one source Observable - * @param w1 - * another source Observable - * @param reduceFunction - * a function that, when applied to an item emitted by each of the source - * Observables, - * results in a value that will be emitted by the resulting Observable + * @param w0 one source Observable + * @param w1 another source Observable + * @param reduceFunction a function that, when applied to an item emitted by + * each of the source Observables, results in a value that will be emitted + * by the resulting Observable + * * @return an Observable that emits the zipped results */ public static Observable zip(Observable w0, Observable w1, Func2 reduceFunction) { @@ -2613,12 +2450,10 @@ public class Observable { * Determines whether two sequences are equal by comparing the elements * pairwise. * - * @param first - * observable to compare - * @param second - * observable to compare - * @param - * type of sequence + * @param first observable to compare + * @param second observable to compare + * @param type of sequence + * * @return sequence of booleans, true if two sequences are equal by * comparing the elements pairwise; otherwise, false. */ @@ -2630,14 +2465,11 @@ public class Observable { * Determines whether two sequences are equal by comparing the elements * pairwise using a specified equality function. * - * @param first - * observable sequence to compare - * @param second - * observable sequence to compare - * @param equality - * a function used to compare elements of both sequences - * @param - * type of sequence + * @param first observable sequence to compare + * @param second observable sequence to compare + * @param equality a function used to compare elements of both sequences + * @param type of sequence + * * @return sequence of booleans, true if two sequences are equal by * comparing the elements pairwise; otherwise, false. */ @@ -2649,14 +2481,11 @@ public class Observable { * Determines whether two sequences are equal by comparing the elements * pairwise using a specified equality function. * - * @param first - * observable sequence to compare - * @param second - * observable sequence to compare - * @param equality - * a function used to compare elements of both sequences - * @param - * type of sequence + * @param first observable sequence to compare + * @param second observable sequence to compare + * @param equality a function used to compare elements of both sequences + * @param type of sequence + * * @return sequence of booleans, true if two sequences are equal by * comparing the elements pairwise; otherwise, false. */ @@ -2666,35 +2495,31 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * combination of items - * emitted, in sequence, by two other Observables, with the results of this - * function becoming the - * sequence emitted by the returned Observable. + * combination of items emitted, in sequence, by two other Observables, with + * the results of this function becoming the sequence emitted by the + * returned Observable. *

* zip applies this function in strict sequence, so the first * item emitted by the new Observable will be the result of the function - * applied to the first item emitted by - * w0 - * and the first item emitted by w1; the - * second item emitted by the new Observable will be the result of the - * function applied to the second item emitted by w0 and the - * second item emitted by w1; and so forth. + * applied to the first item emitted by w0 and the first item + * emitted by w1; the second item emitted by the new Observable + * will be the result of the function applied to the second item emitted by + * w0 and the second item emitted by w1; and so + * forth. *

* The resulting Observable returned from zip * will call onNext as many times as the number - * onNext calls of the source Observable with the - * shortest sequence. + * onNext calls of the source Observable with the shortest + * sequence. *

* * - * @param w0 - * one source Observable - * @param w1 - * another source Observable - * @param function - * a function that, when applied to an item emitted by each of the source - * Observables, - * results in a value that will be emitted by the resulting Observable + * @param w0 one source Observable + * @param w1 another source Observable + * @param function a function that, when applied to an item emitted by each + * of the source Observables, results in a value that will be emitted by the + * resulting Observable + * * @return an Observable that emits the zipped results */ public static Observable zip(Observable w0, Observable w1, final Object function) { @@ -2704,39 +2529,33 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * combination of items - * emitted, in sequence, by three other Observables, with the results of - * this function becoming - * the sequence emitted by the returned Observable. + * combination of items emitted, in sequence, by three other Observables, + * with the results of this function becoming the sequence emitted by the + * returned Observable. *

* zip applies this function in strict sequence, so the first * item emitted by the new Observable will be the result of the function - * applied to the first item emitted by - * w0, - * the first item emitted by w1, and the - * first item emitted by w2; the second item emitted by the new - * Observable will be the result of the function applied to the second item - * emitted by w0, the second item - * emitted by w1, and the second item - * emitted by w2; and so forth. + * applied to the first item emitted by w0, the first item + * emitted by w1, and the first item emitted by + * w2; the second item emitted by the new Observable will be + * the result of the function applied to the second item emitted by + * w0, the second item emitted by w1, and the + * second item emitted by w2; and so forth. *

* The resulting Observable returned from zip * will call onNext as many times as the number - * onNext calls of the source Observable with the - * shortest sequence. + * onNext calls of the source Observable with the shortest + * sequence. *

* * - * @param w0 - * one source Observable - * @param w1 - * another source Observable - * @param w2 - * a third source Observable - * @param function - * a function that, when applied to an item emitted by each of the source - * Observables, - * results in a value that will be emitted by the resulting Observable + * @param w0 one source Observable + * @param w1 another source Observable + * @param w2 a third source Observable + * @param function a function that, when applied to an item emitted by each + * of the source Observables, results in a value that will be emitted by the + * resulting Observable + * * @return an Observable that emits the zipped results */ public static Observable zip(Observable w0, Observable w1, Observable w2, Func3 function) { @@ -2745,39 +2564,33 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * combination of items - * emitted, in sequence, by three other Observables, with the results of - * this function becoming - * the sequence emitted by the returned Observable. + * combination of items emitted, in sequence, by three other Observables, + * with the results of this function becoming the sequence emitted by the + * returned Observable. *

* zip applies this function in strict sequence, so the first * item emitted by the new Observable will be the result of the function - * applied to the first item emitted by - * w0, - * the first item emitted by w1, and the - * first item emitted by w2; the second item emitted by the new - * Observable will be the result of the function applied to the second item - * emitted by w0, the second item - * emitted by w1, and the second item - * emitted by w2; and so forth. + * applied to the first item emitted by w0, the first item + * emitted by w1, and the first item emitted by + * w2; the second item emitted by the new Observable will be + * the result of the function applied to the second item emitted by + * w0, the second item emitted by w1, and the + * second item emitted by w2; and so forth. *

* The resulting Observable returned from zip * will call onNext as many times as the number - * onNext calls of the source Observable with the - * shortest sequence. + * onNext calls of the source Observable with the shortest + * sequence. *

* * - * @param w0 - * one source Observable - * @param w1 - * another source Observable - * @param w2 - * a third source Observable - * @param function - * a function that, when applied to an item emitted by each of the source - * Observables, - * results in a value that will be emitted by the resulting Observable + * @param w0 one source Observable + * @param w1 another source Observable + * @param w2 a third source Observable + * @param function a function that, when applied to an item emitted by each + * of the source Observables, results in a value that will be emitted by the + * resulting Observable + * * @return an Observable that emits the zipped results */ public static Observable zip(Observable w0, Observable w1, Observable w2, final Object function) { @@ -2787,40 +2600,33 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * combination of items - * emitted, in sequence, by four other Observables, with the results of this - * function becoming - * the sequence emitted by the returned Observable. + * combination of items emitted, in sequence, by four other Observables, + * with the results of this function becoming the sequence emitted by the + * returned Observable. *

* zip applies this function in strict sequence, so the first * item emitted by the new Observable will be the result of the function - * applied to the first item emitted by - * w0, - * the first item emitted by w1, the - * first item emitted by w2, and the first item emitted by - * w3; the second item emitted by the new Observable will be - * the result of the function applied to the second item - * emitted by each of those Observables; and so forth. + * applied to the first item emitted by w0, the first item + * emitted by w1, the first item emitted by w2, + * and the first item emitted by w3; the second item emitted by + * the new Observable will be the result of the function applied to the + * second item emitted by each of those Observables; and so forth. *

* The resulting Observable returned from zip * will call onNext as many times as the number - * onNext calls of the source Observable with the - * shortest sequence. + * onNext calls of the source Observable with the shortest + * sequence. *

* * - * @param w0 - * one source Observable - * @param w1 - * another source Observable - * @param w2 - * a third source Observable - * @param w3 - * a fourth source Observable - * @param reduceFunction - * a function that, when applied to an item emitted by each of the source - * Observables, - * results in a value that will be emitted by the resulting Observable + * @param w0 one source Observable + * @param w1 another source Observable + * @param w2 a third source Observable + * @param w3 a fourth source Observable + * @param reduceFunction a function that, when applied to an item emitted by + * each of the source Observables, results in a value that will be emitted + * by the resulting Observable + * * @return an Observable that emits the zipped results */ public static Observable zip(Observable w0, Observable w1, Observable w2, Observable w3, Func4 reduceFunction) { @@ -2829,40 +2635,33 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * combination of items - * emitted, in sequence, by four other Observables, with the results of this - * function becoming - * the sequence emitted by the returned Observable. + * combination of items emitted, in sequence, by four other Observables, + * with the results of this function becoming the sequence emitted by the + * returned Observable. *

* zip applies this function in strict sequence, so the first * item emitted by the new Observable will be the result of the function - * applied to the first item emitted by - * w0, - * the first item emitted by w1, the - * first item emitted by w2, and the first item emitted by - * w3; the second item emitted by the new Observable will be - * the result of the function applied to the second item - * emitted by each of those Observables; and so forth. + * applied to the first item emitted by w0, the first item + * emitted by w1, the first item emitted by w2, + * and the first item emitted by w3; the second item emitted by + * the new Observable will be the result of the function applied to the + * second item emitted by each of those Observables; and so forth. *

* The resulting Observable returned from zip * will call onNext as many times as the number - * onNext calls of the source Observable with the - * shortest sequence. + * onNext calls of the source Observable with the shortest + * sequence. *

* * - * @param w0 - * one source Observable - * @param w1 - * another source Observable - * @param w2 - * a third source Observable - * @param w3 - * a fourth source Observable - * @param function - * a function that, when applied to an item emitted by each of the source - * Observables, - * results in a value that will be emitted by the resulting Observable + * @param w0 one source Observable + * @param w1 another source Observable + * @param w2 a third source Observable + * @param w3 a fourth source Observable + * @param function a function that, when applied to an item emitted by each + * of the source Observables, results in a value that will be emitted by the + * resulting Observable + * * @return an Observable that emits the zipped results */ public static Observable zip(Observable w0, Observable w1, Observable w2, Observable w3, final Object function) { @@ -2876,13 +2675,11 @@ public class Observable { *

* * - * @param predicate - * a function that evaluates the items emitted by the source Observable, - * returning - * true if they pass the filter + * @param predicate a function that evaluates the items emitted by the + * source Observable, returning true if they pass the filter + * * @return an Observable that emits only those items in the original - * Observable that the filter - * evaluates as true + * Observable that the filter evaluates as true */ public Observable filter(Func1 predicate) { return filter(this, predicate); @@ -2892,10 +2689,12 @@ public class Observable { * Registers an action to be called when this observable calls * onComplete or onError. * - * @param action - * an action to be called when this observable completes or errors. + * @param action an action to be called when this observable completes or + * errors. + * * @return an Observable that emits the same objects as this observable, * then calls the action. + * * @see * MSDN: * Observable.Finally Method @@ -2910,13 +2709,11 @@ public class Observable { *

* * - * @param callback - * a function that evaluates the items emitted by the source Observable, - * returning - * true if they pass the filter + * @param callback a function that evaluates the items emitted by the source + * Observable, returning true if they pass the filter + * * @return an Observable that emits only those items in the original - * Observable that the filter - * evaluates as "true" + * Observable that the filter evaluates as "true" */ public Observable filter(final Object callback) { final FuncN _f = Functions.from(callback); @@ -2929,13 +2726,11 @@ public class Observable { *

* * - * @param predicate - * a function that evaluates the items emitted by the source Observable, - * returning - * true if they pass the filter + * @param predicate a function that evaluates the items emitted by the + * source Observable, returning true if they pass the filter + * * @return an Observable that emits only those items in the original - * Observable that the filter - * evaluates as true + * Observable that the filter evaluates as true */ public Observable where(Func1 predicate) { return where(this, predicate); @@ -2959,8 +2754,9 @@ public class Observable { * Returns the last element of an observable sequence that matches the * predicate. * - * @param predicate - * a predicate function to evaluate for elements in the sequence. + * @param predicate a predicate function to evaluate for elements in the + * sequence. + * * @return the last element in the observable sequence. */ public T last(final Func1 predicate) { @@ -2971,8 +2767,9 @@ public class Observable { * Returns the last element of an observable sequence that matches the * predicate. * - * @param predicate - * a predicate function to evaluate for elements in the sequence. + * @param predicate a predicate function to evaluate for elements in the + * sequence. + * * @return the last element in the observable sequence. */ public T last(final Object predicate) { @@ -2984,8 +2781,9 @@ public class Observable { /** * Returns the last element, or a default value if no value is found. * - * @param defaultValue - * a default value that would be returned if observable is empty. + * @param defaultValue a default value that would be returned if observable + * is empty. + * * @return the last element of an observable sequence that matches the * predicate, or a default value if no value is found. */ @@ -2997,10 +2795,11 @@ public class Observable { * Returns the last element that matches the predicate, or a default value * if no value is found. * - * @param defaultValue - * a default value that would be returned if observable is empty. - * @param predicate - * a predicate function to evaluate for elements in the sequence. + * @param defaultValue a default value that would be returned if observable + * is empty. + * @param predicate a predicate function to evaluate for elements in the + * sequence. + * * @return the last element of an observable sequence that matches the * predicate, or a default value if no value is found. */ @@ -3012,10 +2811,11 @@ public class Observable { * Returns the last element that matches the predicate, or a default value * if no value is found. * - * @param defaultValue - * a default value that would be returned if observable is empty. - * @param predicate - * a predicate function to evaluate for elements in the sequence. + * @param defaultValue a default value that would be returned if observable + * is empty. + * @param predicate a predicate function to evaluate for elements in the + * sequence. + * * @return the last element of an observable sequence that matches the * predicate, or a default value if no value is found. */ @@ -3025,16 +2825,15 @@ public class Observable { /** * Applies a function of your choosing to every item emitted by an - * Observable, and returns this - * transformation as a new Observable sequence. + * Observable, and returns this transformation as a new Observable sequence. *

* * - * @param func - * a function to apply to each item in the sequence. + * @param func a function to apply to each item in the sequence. + * * @return an Observable that emits a sequence that is the result of - * applying the transformation - * function to each item in the sequence emitted by the input Observable. + * applying the transformation function to each item in the sequence emitted + * by the input Observable. */ public Observable map(Func1 func) { return map(this, func); @@ -3042,16 +2841,15 @@ public class Observable { /** * Applies a function of your choosing to every item emitted by an - * Observable, and returns this - * transformation as a new Observable sequence. + * Observable, and returns this transformation as a new Observable sequence. *

* * - * @param callback - * a function to apply to each item in the sequence. + * @param callback a function to apply to each item in the sequence. + * * @return an Observable that emits a sequence that is the result of - * applying the transformation - * function to each item in the sequence emitted by the input Observable. + * applying the transformation function to each item in the sequence emitted + * by the input Observable. */ public Observable map(final Object callback) { final FuncN _f = Functions.from(callback); @@ -3060,23 +2858,20 @@ public class Observable { /** * Creates a new Observable sequence by applying a function that you supply - * to each item in the - * original Observable sequence, where that function is itself an Observable - * that emits items, and - * then merges the results of that function applied to every item emitted by - * the original - * Observable, emitting these merged results as its own sequence. + * to each item in the original Observable sequence, where that function is + * itself an Observable that emits items, and then merges the results of + * that function applied to every item emitted by the original Observable, + * emitting these merged results as its own sequence. *

* * - * @param func - * a function to apply to each item in the sequence, that returns an - * Observable. + * @param func a function to apply to each item in the sequence, that + * returns an Observable. + * * @return an Observable that emits a sequence that is the result of - * applying the transformation - * function to each item in the input sequence and merging the results of - * the - * Observables obtained from this transformation. + * applying the transformation function to each item in the input sequence + * and merging the results of the Observables obtained from this + * transformation. */ public Observable mapMany(Func1> func) { return mapMany(this, func); @@ -3084,23 +2879,20 @@ public class Observable { /** * Creates a new Observable sequence by applying a function that you supply - * to each item in the - * original Observable sequence, where that function is itself an Observable - * that emits items, and - * then merges the results of that function applied to every item emitted by - * the original - * Observable, emitting these merged results as its own sequence. + * to each item in the original Observable sequence, where that function is + * itself an Observable that emits items, and then merges the results of + * that function applied to every item emitted by the original Observable, + * emitting these merged results as its own sequence. *

* * - * @param callback - * a function to apply to each item in the sequence that returns an - * Observable. + * @param callback a function to apply to each item in the sequence that + * returns an Observable. + * * @return an Observable that emits a sequence that is the result of - * applying the transformation' - * function to each item in the input sequence and merging the results of - * the - * Observables obtained from this transformation. + * applying the transformation' function to each item in the input sequence + * and merging the results of the Observables obtained from this + * transformation. */ public Observable mapMany(final Object callback) { final FuncN _f = Functions.from(callback); @@ -3115,6 +2907,7 @@ public class Observable { * * @return An observable sequence whose elements are the result of * materializing the notifications of the given sequence. + * * @see * MSDN: * Observable.materialize @@ -3127,8 +2920,9 @@ public class Observable { * Asynchronously subscribes and unsubscribes observers on the specified * scheduler. * - * @param scheduler - * the scheduler to perform subscription and unsubscription actions on. + * @param scheduler the scheduler to perform subscription and unsubscription + * actions on. + * * @return the source sequence whose subscriptions and unsubscriptions * happen on the specified scheduler. */ @@ -3139,8 +2933,8 @@ public class Observable { /** * Asynchronously notify observers on the specified scheduler. * - * @param scheduler - * the scheduler to notify observers on. + * @param scheduler the scheduler to notify observers on. + * * @return the source sequence whose observations happen on the specified * scheduler. */ @@ -3154,11 +2948,11 @@ public class Observable { * * @return An observable sequence exhibiting the behavior corresponding to * the source sequence's notification values. + * * @see * MSDN: * Observable.dematerialize - * @throws Exception - * if attempted on Observable not of type + * @throws Exception if attempted on Observable not of type * {@code Observable>}. */ public Observable dematerialize() { @@ -3170,30 +2964,26 @@ public class Observable { * calling onError if it encounters an error. *

* By default, when an Observable encounters an error that prevents it from - * emitting the expected - * item to its Observer, the Observable calls its Observer's - * onError function, and - * then quits without calling any more of its Observer's closures. The - * onErrorResumeNext method changes this behavior. If you pass - * another Observable + * emitting the expected item to its Observer, the Observable calls its + * Observer's onError function, and then quits without calling + * any more of its Observer's closures. The onErrorResumeNext + * method changes this behavior. If you pass another Observable * (resumeFunction) to an Observable's - * onErrorResumeNext method, if the - * original Observable encounters an error, instead of calling its - * Observer's + * onErrorResumeNext method, if the original Observable + * encounters an error, instead of calling its Observer's * onErrort function, it will instead relinquish control to * resumeFunction which will call the Observer's - * onNext method if it - * is able to do so. In such a case, because no Observable necessarily - * invokes - * onError, the Observer may never know that an error happened. + * onNext method if it is able to do so. In such a case, + * because no Observable necessarily invokes onError, the + * Observer may never know that an error happened. *

* You can use this to prevent errors from propagating or to supply fallback - * data should errors - * be encountered. + * data should errors be encountered. *

* * * @param resumeFunction + * * @return the original Observable, with appropriately modified behavior */ public Observable onErrorResumeNext(final Func1> resumeFunction) { @@ -3202,34 +2992,29 @@ public class Observable { /** * Instruct an Observable to emit a particular item rather than calling - * onError if - * it encounters an error. + * onError if it encounters an error. *

* By default, when an Observable encounters an error that prevents it from - * emitting the expected - * item to its Observer, the Observable calls its Observer's - * onError function, and - * then quits without calling any more of its Observer's closures. The - * onErrorResumeNext method changes this behavior. If you pass - * another Observable + * emitting the expected item to its Observer, the Observable calls its + * Observer's onError function, and then quits without calling + * any more of its Observer's closures. The onErrorResumeNext + * method changes this behavior. If you pass another Observable * (resumeFunction) to an Observable's - * onErrorResumeNext method, if the - * original Observable encounters an error, instead of calling its - * Observer's + * onErrorResumeNext method, if the original Observable + * encounters an error, instead of calling its Observer's * onError function, it will instead relinquish control to * resumeFunction which will call the Observer's - * onNext method if it - * is able to do so. In such a case, because no Observable necessarily - * invokes - * onError, the Observer may never know that an error happened. + * onNext method if it is able to do so. In such a case, + * because no Observable necessarily invokes onError, the + * Observer may never know that an error happened. *

* You can use this to prevent errors from propagating or to supply fallback - * data should errors - * be encountered. + * data should errors be encountered. *

* * * @param resumeFunction + * * @return the original Observable with appropriately modified behavior */ public Observable onErrorResumeNext(final Object resumeFunction) { @@ -3239,34 +3024,29 @@ public class Observable { /** * Instruct an Observable to pass control to another Observable rather than - * calling - * onError if it encounters an error. + * calling onError if it encounters an error. *

* By default, when an Observable encounters an error that prevents it from - * emitting the expected - * item to its Observer, the Observable calls its Observer's - * onError function, and - * then quits without calling any more of its Observer's closures. The - * onErrorResumeNext method changes this behavior. If you pass - * another Observable + * emitting the expected item to its Observer, the Observable calls its + * Observer's onError function, and then quits without calling + * any more of its Observer's closures. The onErrorResumeNext + * method changes this behavior. If you pass another Observable * (resumeSequence) to an Observable's - * onErrorResumeNext method, if the - * original Observable encounters an error, instead of calling its - * Observer's + * onErrorResumeNext method, if the original Observable + * encounters an error, instead of calling its Observer's * onError function, it will instead relinquish control to * resumeSequence which will call the Observer's - * onNext method if it - * is able to do so. In such a case, because no Observable necessarily - * invokes - * onError, the Observer may never know that an error happened. + * onNext method if it is able to do so. In such a case, + * because no Observable necessarily invokes onError, the + * Observer may never know that an error happened. *

* You can use this to prevent errors from propagating or to supply fallback - * data should errors - * be encountered. + * data should errors be encountered. *

* * * @param resumeSequence + * * @return the original Observable, with appropriately modified behavior */ public Observable onErrorResumeNext(final Observable resumeSequence) { @@ -3275,29 +3055,24 @@ public class Observable { /** * Instruct an Observable to emit a particular item rather than calling - * onError if - * it encounters an error. + * onError if it encounters an error. *

* By default, when an Observable encounters an error that prevents it from - * emitting the expected - * object to its Observer, the Observable calls its Observer's - * onError function, and - * then quits without calling any more of its Observer's closures. The - * onErrorReturn method changes this behavior. If you pass a - * function + * emitting the expected object to its Observer, the Observable calls its + * Observer's onError function, and then quits without calling + * any more of its Observer's closures. The onErrorReturn + * method changes this behavior. If you pass a function * (resumeFunction) to an Observable's - * onErrorReturn method, if the - * original Observable encounters an error, instead of calling its - * Observer's - * onError function, it will instead call pass the return value - * of + * onErrorReturn method, if the original Observable encounters + * an error, instead of calling its Observer's onError + * function, it will instead call pass the return value of * resumeFunction to the Observer's onNext method. *

* You can use this to prevent errors from propagating or to supply fallback - * data should errors - * be encountered. + * data should errors be encountered. * * @param resumeFunction + * * @return the original Observable with appropriately modified behavior */ public Observable onErrorReturn(Func1 resumeFunction) { @@ -3306,29 +3081,24 @@ public class Observable { /** * Instruct an Observable to emit a particular item rather than calling - * onError if - * it encounters an error. + * onError if it encounters an error. *

* By default, when an Observable encounters an error that prevents it from - * emitting the expected - * object to its Observer, the Observable calls its Observer's - * onError function, and - * then quits without calling any more of its Observer's closures. The - * onErrorReturn method changes this behavior. If you pass a - * function + * emitting the expected object to its Observer, the Observable calls its + * Observer's onError function, and then quits without calling + * any more of its Observer's closures. The onErrorReturn + * method changes this behavior. If you pass a function * (resumeFunction) to an Observable's - * onErrorReturn method, if the - * original Observable encounters an error, instead of calling its - * Observer's - * onError function, it will instead call pass the return value - * of + * onErrorReturn method, if the original Observable encounters + * an error, instead of calling its Observer's onError + * function, it will instead call pass the return value of * resumeFunction to the Observer's onNext method. *

* You can use this to prevent errors from propagating or to supply fallback - * data should errors - * be encountered. + * data should errors be encountered. * * @param resumeFunction + * * @return the original Observable with appropriately modified behavior */ public Observable onErrorReturn(final Object resumeFunction) { @@ -3338,31 +3108,26 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the final result from the final call to your - * function as its sole - * output. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the final result from the final call to your + * function as its sole output. *

* This technique, which is called "reduce" here, is sometimes called - * "fold," "accumulate," - * "compress," or "inject" in other programming contexts. Groovy, for - * instance, has an - * inject method that does a similar operation on lists. + * "fold," "accumulate," "compress," or "inject" in other programming + * contexts. Groovy, for instance, has an inject method that + * does a similar operation on lists. *

* * - * @param accumulator - * An accumulator function to be invoked on each element from the sequence, - * whose result - * will be used in the next accumulator call (if applicable). + * @param accumulator An accumulator function to be invoked on each element + * from the sequence, whose result will be used in the next accumulator call + * (if applicable). * * @return An observable sequence with a single element from the result of - * accumulating the - * output from the list of Observables. + * accumulating the output from the list of Observables. + * * @see * MSDN: * Observable.Aggregate @@ -3376,31 +3141,26 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the final result from the final call to your - * function as its sole - * output. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the final result from the final call to your + * function as its sole output. *

* This technique, which is called "reduce" here, is sometimes called - * "fold," "accumulate," - * "compress," or "inject" in other programming contexts. Groovy, for - * instance, has an - * inject method that does a similar operation on lists. + * "fold," "accumulate," "compress," or "inject" in other programming + * contexts. Groovy, for instance, has an inject method that + * does a similar operation on lists. *

* * - * @param accumulator - * An accumulator function to be invoked on each element from the sequence, - * whose result - * will be used in the next accumulator call (if applicable). + * @param accumulator An accumulator function to be invoked on each element + * from the sequence, whose result will be used in the next accumulator call + * (if applicable). * * @return an Observable that emits a single element from the result of - * accumulating the output - * from the list of Observables. + * accumulating the output from the list of Observables. + * * @see * MSDN: * Observable.Aggregate @@ -3414,33 +3174,27 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the final result from the final call to your - * function as its sole - * output. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the final result from the final call to your + * function as its sole output. *

* This technique, which is called "reduce" here, is sometimes called - * "fold," "accumulate," - * "compress," or "inject" in other programming contexts. Groovy, for - * instance, has an - * inject method that does a similar operation on lists. + * "fold," "accumulate," "compress," or "inject" in other programming + * contexts. Groovy, for instance, has an inject method that + * does a similar operation on lists. *

* * - * @param initialValue - * The initial (seed) accumulator value. - * @param accumulator - * An accumulator function to be invoked on each element from the sequence, - * whose - * result will be used in the next accumulator call (if applicable). + * @param initialValue The initial (seed) accumulator value. + * @param accumulator An accumulator function to be invoked on each element + * from the sequence, whose result will be used in the next accumulator call + * (if applicable). * * @return an Observable that emits a single element from the result of - * accumulating the output - * from the list of Observables. + * accumulating the output from the list of Observables. + * * @see * MSDN: * Observable.Aggregate @@ -3454,32 +3208,27 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the final result from the final call to your - * function as its sole - * output. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the final result from the final call to your + * function as its sole output. *

* This technique, which is called "reduce" here, is sometimes called - * "fold," "accumulate," - * "compress," or "inject" in other programming contexts. Groovy, for - * instance, has an - * inject method that does a similar operation on lists. + * "fold," "accumulate," "compress," or "inject" in other programming + * contexts. Groovy, for instance, has an inject method that + * does a similar operation on lists. *

* * - * @param initialValue - * The initial (seed) accumulator value. - * @param accumulator - * An accumulator function to be invoked on each element from the sequence, - * whose - * result will be used in the next accumulator call (if applicable). + * @param initialValue The initial (seed) accumulator value. + * @param accumulator An accumulator function to be invoked on each element + * from the sequence, whose result will be used in the next accumulator call + * (if applicable). + * * @return an Observable that emits a single element from the result of - * accumulating the output - * from the list of Observables. + * accumulating the output from the list of Observables. + * * @see * MSDN: * Observable.Aggregate @@ -3493,28 +3242,22 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the result of each of these iterations. It - * emits the result of - * each of these iterations as a sequence from the returned Observable. This - * sort of function is - * sometimes called an accumulator. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the result of each of these iterations. It emits the + * result of each of these iterations as a sequence from the returned + * Observable. This sort of function is sometimes called an accumulator. *

* * - * @param accumulator - * An accumulator function to be invoked on each element from the sequence - * whose - * result will be sent via onNext and used in the next - * accumulator call - * (if applicable). + * @param accumulator An accumulator function to be invoked on each element + * from the sequence whose result will be sent via onNext and + * used in the next accumulator call (if applicable). + * * @return an Observable sequence whose elements are the result of - * accumulating the output from - * the list of Observables. + * accumulating the output from the list of Observables. + * * @see * MSDN: * Observable.Scan @@ -3525,29 +3268,22 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the result of each of these iterations. It - * emits the result of - * each of these iterations as a sequence from the returned Observable. This - * sort of function is - * sometimes called an accumulator. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the result of each of these iterations. It emits the + * result of each of these iterations as a sequence from the returned + * Observable. This sort of function is sometimes called an accumulator. *

* * - * @param accumulator - * An accumulator function to be invoked on each element from the sequence - * whose - * result will be sent via onNext and used in the next - * accumulator call - * (if applicable). + * @param accumulator An accumulator function to be invoked on each element + * from the sequence whose result will be sent via onNext and + * used in the next accumulator call (if applicable). * * @return an Observable sequence whose elements are the result of - * accumulating the output from - * the list of Observables. + * accumulating the output from the list of Observables. + * * @see * MSDN: * Observable.Scan @@ -3558,28 +3294,22 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, and so on until all items have - * been emitted by the - * source Observable, emitting the result of each of these iterations. This - * sort of function is - * sometimes called an accumulator. + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, and so on until all items have been emitted by the source + * Observable, emitting the result of each of these iterations. This sort of + * function is sometimes called an accumulator. *

* * - * @param initialValue - * The initial (seed) accumulator value. - * @param accumulator - * An accumulator function to be invoked on each element from the sequence - * whose - * result will be sent via onNext and used in the next - * accumulator call - * (if applicable). + * @param initialValue The initial (seed) accumulator value. + * @param accumulator An accumulator function to be invoked on each element + * from the sequence whose result will be sent via onNext and + * used in the next accumulator call (if applicable). + * * @return an Observable sequence whose elements are the result of - * accumulating the output from - * the list of Observables. + * accumulating the output from the list of Observables. + * * @see * MSDN: * Observable.Scan @@ -3590,28 +3320,23 @@ public class Observable { /** * Returns an Observable that applies a function of your choosing to the - * first item emitted by a - * source Observable, then feeds the result of that function along with the - * second item emitted - * by an Observable into the same function, then feeds the result of that - * function along with the + * first item emitted by a source Observable, then feeds the result of that + * function along with the second item emitted by an Observable into the + * same function, then feeds the result of that function along with the * third item into the same function, and so on, emitting the result of each - * of these - * iterations. This sort of function is sometimes called an accumulator. + * of these iterations. This sort of function is sometimes called an + * accumulator. *

* * - * @param initialValue - * The initial (seed) accumulator value. - * @param accumulator - * An accumulator function to be invoked on each element from the sequence - * whose result - * will be sent via onNext and used in the next accumulator - * call (if - * applicable). + * @param initialValue The initial (seed) accumulator value. + * @param accumulator An accumulator function to be invoked on each element + * from the sequence whose result will be sent via onNext and + * used in the next accumulator call (if applicable). + * * @return an Observable sequence whose elements are the result of - * accumulating the output from - * the list of Observables. + * accumulating the output from the list of Observables. + * * @see * MSDN: * Observable.Scan @@ -3624,8 +3349,8 @@ public class Observable { * Determines whether all elements of an observable sequence satisfies a * condition. * - * @param predicate - * a function to test each element for a condition. + * @param predicate a function to test each element for a condition. + * * @return true if all elements of an observable sequence satisfies a * condition; otherwise, false. */ @@ -3637,8 +3362,8 @@ public class Observable { * Determines whether all elements of an observable sequence satisfies a * condition. * - * @param predicate - * a function to test each element for a condition. + * @param predicate a function to test each element for a condition. + * * @return true if all elements of an observable sequence satisfies a * condition; otherwise, false. */ @@ -3648,20 +3373,17 @@ public class Observable { /** * Returns an Observable that skips the first num items emitted - * by the source - * Observable. - * You can ignore the first num items emitted by an Observable - * and attend only to - * those items that come after, by modifying the Observable with the - * skip method. + * by the source Observable. You can ignore the first num items + * emitted by an Observable and attend only to those items that come after, + * by modifying the Observable with the skip method. *

* * - * @param num - * The number of items to skip + * @param num The number of items to skip + * * @return an Observable sequence that is identical to the source Observable - * except that it does - * not emit the first num items from that sequence. + * except that it does not emit the first num items from that + * sequence. */ public Observable skip(int num) { return skip(this, num); @@ -3669,25 +3391,21 @@ public class Observable { /** * Returns an Observable that emits the first num items emitted - * by the source - * Observable. + * by the source Observable. *

* You can choose to pay attention only to the first num values - * emitted by a - * Observable by calling its take method. This method returns - * an Observable that will - * call a subscribing Observer's onNext function a maximum of - * num times - * before calling onCompleted. + * emitted by a Observable by calling its take method. This + * method returns an Observable that will call a subscribing Observer's + * onNext function a maximum of num times before + * calling onCompleted. *

* * * @param num + * * @return an Observable that emits only the first num items - * from the source - * Observable, or all of the items from the source Observable if that - * Observable emits - * fewer than num items. + * from the source Observable, or all of the items from the source + * Observable if that Observable emits fewer than num items. */ public Observable take(final int num) { return take(this, num); @@ -3697,8 +3415,8 @@ public class Observable { * Returns an Observable that items emitted by the source Observable as long * as a specified condition is true. * - * @param predicate - * a function to test each source element for a condition + * @param predicate a function to test each source element for a condition + * * @return */ public Observable takeWhile(final Func1 predicate) { @@ -3709,8 +3427,8 @@ public class Observable { * Returns a specified number of contiguous values from the start of an * observable sequence. * - * @param predicate - * a function to test each source element for a condition + * @param predicate a function to test each source element for a condition + * * @return */ public Observable takeWhile(final Object predicate) { @@ -3721,10 +3439,10 @@ public class Observable { * Returns values from an observable sequence as long as a specified * condition is true, and then skips the remaining values. * - * @param predicate - * a function to test each element for a condition; the second parameter of - * the function represents the index of the source element; - * otherwise, false. + * @param predicate a function to test each element for a condition; the + * second parameter of the function represents the index of the source + * element; otherwise, false. + * * @return */ public Observable takeWhileWithIndex(final Func2 predicate) { @@ -3735,10 +3453,10 @@ public class Observable { * Returns values from an observable sequence as long as a specified * condition is true, and then skips the remaining values. * - * @param predicate - * a function to test each element for a condition; the second parameter of - * the function represents the index of the source element; - * otherwise, false. + * @param predicate a function to test each element for a condition; the + * second parameter of the function represents the index of the source + * element; otherwise, false. + * * @return */ public Observable takeWhileWithIndex(final Object predicate) { @@ -3747,15 +3465,13 @@ public class Observable { /** * Returns an Observable that emits the last count items - * emitted by the source - * Observable. + * emitted by the source Observable. + * + * @param count the number of items from the end of the sequence emitted by + * the source Observable to emit * - * @param count - * the number of items from the end of the sequence emitted by the source - * Observable to emit * @return an Observable that only emits the last count items - * emitted by the source - * Observable + * emitted by the source Observable */ public Observable takeLast(final int count) { return takeLast(this, count); @@ -3765,11 +3481,10 @@ public class Observable { * Returns the values from the source observable sequence until the other * observable sequence produces a value. * - * @param other - * the observable sequence that terminates propagation of elements of the - * source sequence. - * @param - * the other type. + * @param other the observable sequence that terminates propagation of + * elements of the source sequence. + * @param the other type. + * * @return An observable sequence containing the elements of the source * sequence up to the point the other sequence interrupted further * propagation. @@ -3780,26 +3495,20 @@ public class Observable { /** * Returns an Observable that emits a single item, a list composed of all - * the items emitted by - * the source Observable. + * the items emitted by the source Observable. *

* Normally, an Observable that returns multiple items will do so by calling - * its Observer's - * onNext function for each such item. You can change this - * behavior, instructing - * the Observable to compose a list of all of these multiple items and then - * to call the - * Observer's onNext function once, passing it the entire list, - * by calling the - * Observable object's toList method prior to calling its - * subscribe - * method. + * its Observer's onNext function for each such item. You can + * change this behavior, instructing the Observable to compose a list of all + * of these multiple items and then to call the Observer's + * onNext function once, passing it the entire list, by calling + * the Observable object's toList method prior to calling its + * subscribe method. *

* * * @return an Observable that emits a single item: a List containing all of - * the items emitted by - * the source Observable. + * the items emitted by the source Observable. */ public Observable> toList() { return toList(this); @@ -3810,8 +3519,7 @@ public class Observable { *

* * - * @throws ClassCastException - * if T objects do not implement Comparable + * @throws ClassCastException if T objects do not implement Comparable * @return */ public Observable> toSortedList() { @@ -3824,6 +3532,7 @@ public class Observable { * * * @param sortFunction + * * @return */ public Observable> toSortedList(Func2 sortFunction) { @@ -3836,6 +3545,7 @@ public class Observable { * * * @param sortFunction + * * @return */ public Observable> toSortedList(final Object sortFunction) { @@ -3860,18 +3570,15 @@ public class Observable { * Groups the elements of an observable and selects the resulting elements * by using a specified function. * - * @param keySelector - * a function to extract the key for each element. - * @param elementSelector - * a function to map each source element to an element in an observable - * group. - * @param - * the key type. - * @param - * the resulting observable type. + * @param keySelector a function to extract the key for each element. + * @param elementSelector a function to map each source element to an + * element in an observable group. + * @param the key type. + * @param the resulting observable type. + * * @return an observable of observable groups, each of which corresponds to - * a unique key value, containing all elements that share that same - * key value. + * a unique key value, containing all elements that share that same key + * value. */ public Observable> groupBy(final Func1 keySelector, final Func1 elementSelector) { return groupBy(this, keySelector, elementSelector); @@ -3881,13 +3588,12 @@ public class Observable { * Groups the elements of an observable according to a specified key * selector function and * - * @param keySelector - * a function to extract the key for each element. - * @param - * the key type. + * @param keySelector a function to extract the key for each element. + * @param the key type. + * * @return an observable of observable groups, each of which corresponds to - * a unique key value, containing all elements that share that same - * key value. + * a unique key value, containing all elements that share that same key + * value. */ public Observable> groupBy(final Func1 keySelector) { return groupBy(this, keySelector); @@ -3917,9 +3623,9 @@ public class Observable { /** * Samples the most recent value in an observable sequence. * - * @param initialValue - * the initial value that will be yielded by the enumerable sequence if no - * element has been sampled yet. + * @param initialValue the initial value that will be yielded by the + * enumerable sequence if no element has been sampled yet. + * * @return the iterable that returns the last sampled element upon each * iteration. */ @@ -3940,6 +3646,7 @@ public class Observable { * interface. * * @param f + * * @return */ private boolean isInternalImplementation(Object o) { diff --git a/HMCLAPI/src/main/java/rx/Observer.java b/HMCLAPI/src/main/java/rx/Observer.java index dc12c8e97..a8e688ec4 100755 --- a/HMCLAPI/src/main/java/rx/Observer.java +++ b/HMCLAPI/src/main/java/rx/Observer.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,28 +18,36 @@ package rx; /** * Provides a mechanism for receiving push-based notifications. *

- * After an Observer calls an {@link Observable}'s Observable.subscribe method, the {@link Observable} calls the Observer's onNext method to provide notifications. A - * well-behaved {@link Observable} will - * call an Observer's onCompleted closure exactly once or the Observer's onError closure exactly once. + * After an Observer calls an {@link Observable}'s + * Observable.subscribe method, the {@link Observable} calls the + * Observer's onNext method to provide notifications. A + * well-behaved {@link Observable} will call an Observer's + * onCompleted closure exactly once or the Observer's + * onError closure exactly once. *

- * For more information see the RxJava Wiki - * + * For more information see the + * RxJava Wiki + * * @param */ public interface Observer { /** - * Notifies the Observer that the {@link Observable} has finished sending push-based notifications. + * Notifies the Observer that the {@link Observable} has finished sending + * push-based notifications. *

- * The {@link Observable} will not call this closure if it calls onError. + * The {@link Observable} will not call this closure if it calls + * onError. */ public void onCompleted(); /** - * Notifies the Observer that the {@link Observable} has experienced an error condition. + * Notifies the Observer that the {@link Observable} has experienced an + * error condition. *

- * If the {@link Observable} calls this closure, it will not thereafter call onNext or onCompleted. - * + * If the {@link Observable} calls this closure, it will not thereafter call + * onNext or onCompleted. + * * @param e */ public void onError(Exception e); @@ -47,10 +55,13 @@ public interface Observer { /** * Provides the Observer with new data. *

- * The {@link Observable} calls this closure 1 or more times, unless it calls onError in which case this closure may never be called. + * The {@link Observable} calls this closure 1 or more times, unless it + * calls onError in which case this closure may never be + * called. *

- * The {@link Observable} will not call this closure again after it calls either onCompleted or onError. - * + * The {@link Observable} will not call this closure again after it calls + * either onCompleted or onError. + * * @param args */ public void onNext(T args); diff --git a/HMCLAPI/src/main/java/rx/Scheduler.java b/HMCLAPI/src/main/java/rx/Scheduler.java index 74fe274b3..6d455c060 100755 --- a/HMCLAPI/src/main/java/rx/Scheduler.java +++ b/HMCLAPI/src/main/java/rx/Scheduler.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,36 +27,36 @@ public interface Scheduler { /** * Schedules a cancelable action to be executed. - * - * @param action - * action + * + * @param action action + * * @return a subscription to be able to unsubscribe from action. */ Subscription schedule(Func0 action); /** * Schedules an action to be executed. - * - * @param action - * action + * + * @param action action + * * @return a subscription to be able to unsubscribe from action. */ Subscription schedule(Action0 action); /** * Schedules an action to be executed in dueTime. - * - * @param action - * action + * + * @param action action + * * @return a subscription to be able to unsubscribe from action. */ Subscription schedule(Action0 action, long dueTime, TimeUnit unit); /** * Schedules a cancelable action to be executed in dueTime. - * - * @param action - * action + * + * @param action action + * * @return a subscription to be able to unsubscribe from action. */ Subscription schedule(Func0 action, long dueTime, TimeUnit unit); diff --git a/HMCLAPI/src/main/java/rx/Subscription.java b/HMCLAPI/src/main/java/rx/Subscription.java index e2347257c..0ee662126 100755 --- a/HMCLAPI/src/main/java/rx/Subscription.java +++ b/HMCLAPI/src/main/java/rx/Subscription.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,16 +18,20 @@ package rx; import rx.subscriptions.Subscriptions; /** - * Subscription returns from {@link Observable#subscribe(Observer)} to allow unsubscribing. + * Subscription returns from {@link Observable#subscribe(Observer)} to allow + * unsubscribing. *

- * See utilities in {@link Subscriptions} and implementations in the {@link rx.subscriptions} package. + * See utilities in {@link Subscriptions} and implementations in the + * {@link rx.subscriptions} package. */ public interface Subscription { /** - * Stop receiving notifications on the {@link Observer} that was registered when this Subscription was received. + * Stop receiving notifications on the {@link Observer} that was registered + * when this Subscription was received. *

- * This allows unregistering an {@link Observer} before it has finished receiving all events (ie. before onCompleted is called). + * This allows unregistering an {@link Observer} before it has finished + * receiving all events (ie. before onCompleted is called). */ public void unsubscribe(); diff --git a/HMCLAPI/src/main/java/rx/concurrency/AbstractScheduler.java b/HMCLAPI/src/main/java/rx/concurrency/AbstractScheduler.java index d4a4def12..2800f672c 100755 --- a/HMCLAPI/src/main/java/rx/concurrency/AbstractScheduler.java +++ b/HMCLAPI/src/main/java/rx/concurrency/AbstractScheduler.java @@ -23,7 +23,9 @@ import rx.subscriptions.Subscriptions; import rx.util.functions.Action0; import rx.util.functions.Func0; -/* package */ +/* + * package + */ abstract class AbstractScheduler implements Scheduler { @Override diff --git a/HMCLAPI/src/main/java/rx/concurrency/CurrentThreadScheduler.java b/HMCLAPI/src/main/java/rx/concurrency/CurrentThreadScheduler.java index 0fd634523..d9ac2c8a9 100755 --- a/HMCLAPI/src/main/java/rx/concurrency/CurrentThreadScheduler.java +++ b/HMCLAPI/src/main/java/rx/concurrency/CurrentThreadScheduler.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,9 +23,11 @@ import rx.Subscription; import rx.util.functions.Func0; /** - * Schedules work on the current thread but does not execute immediately. Work is put in a queue and executed after the current unit of work is completed. + * Schedules work on the current thread but does not execute immediately. Work + * is put in a queue and executed after the current unit of work is completed. */ public class CurrentThreadScheduler extends AbstractScheduler { + private static final CurrentThreadScheduler INSTANCE = new CurrentThreadScheduler(); public static CurrentThreadScheduler getInstance() { @@ -61,9 +63,8 @@ public class CurrentThreadScheduler extends AbstractScheduler { queue.add(action); if (exec) { - while (!queue.isEmpty()) { + while (!queue.isEmpty()) queue.poll().call(); - } QUEUE.set(null); } diff --git a/HMCLAPI/src/main/java/rx/concurrency/DiscardableAction.java b/HMCLAPI/src/main/java/rx/concurrency/DiscardableAction.java index bf036befd..416eeacf1 100755 --- a/HMCLAPI/src/main/java/rx/concurrency/DiscardableAction.java +++ b/HMCLAPI/src/main/java/rx/concurrency/DiscardableAction.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,9 +22,15 @@ import rx.util.AtomicObservableSubscription; import rx.util.functions.Func0; /** - * Combines standard {@link Subscription#unsubscribe()} functionality with ability to skip execution if an unsubscribe occurs before the {@link #call()} method is invoked. + * Combines standard {@link Subscription#unsubscribe()} functionality with + * ability to skip execution if an unsubscribe occurs before the {@link #call()} + * method is invoked. */ -/* package */class DiscardableAction implements Func0, Subscription { +/* + * package + */ +class DiscardableAction implements Func0, Subscription { + private final Func0 underlying; private final AtomicObservableSubscription wrapper = new AtomicObservableSubscription(); diff --git a/HMCLAPI/src/main/java/rx/concurrency/EventQueueScheduler.java b/HMCLAPI/src/main/java/rx/concurrency/EventQueueScheduler.java index 88b68e0cf..2d70ac138 100755 --- a/HMCLAPI/src/main/java/rx/concurrency/EventQueueScheduler.java +++ b/HMCLAPI/src/main/java/rx/concurrency/EventQueueScheduler.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -27,6 +27,7 @@ import rx.util.functions.Func0; * @author huangyuhui */ public class EventQueueScheduler extends AbstractScheduler { + private static final EventQueueScheduler INSTANCE = new EventQueueScheduler(); public static EventQueueScheduler getInstance() { diff --git a/HMCLAPI/src/main/java/rx/concurrency/ExecutorScheduler.java b/HMCLAPI/src/main/java/rx/concurrency/ExecutorScheduler.java index b6c8940aa..610849360 100755 --- a/HMCLAPI/src/main/java/rx/concurrency/ExecutorScheduler.java +++ b/HMCLAPI/src/main/java/rx/concurrency/ExecutorScheduler.java @@ -53,16 +53,16 @@ public class ExecutorScheduler extends AbstractScheduler { count = 8; SYSTEM_SCHEDULED_EXECUTOR = Executors.newScheduledThreadPool(count, new ThreadFactory() { - final AtomicInteger counter = new AtomicInteger(); + final AtomicInteger counter = new AtomicInteger(); - @Override - public Thread newThread(Runnable r) { - Thread t = new Thread(r, "RxScheduledExecutorPool-" + counter.incrementAndGet()); - t.setDaemon(true); - return t; - } + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r, "RxScheduledExecutorPool-" + counter.incrementAndGet()); + t.setDaemon(true); + return t; + } - }); + }); } diff --git a/HMCLAPI/src/main/java/rx/concurrency/ImmediateScheduler.java b/HMCLAPI/src/main/java/rx/concurrency/ImmediateScheduler.java index 1b5febe2d..b0f7de54d 100755 --- a/HMCLAPI/src/main/java/rx/concurrency/ImmediateScheduler.java +++ b/HMCLAPI/src/main/java/rx/concurrency/ImmediateScheduler.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,6 +24,7 @@ import rx.util.functions.Func0; * Executes work immediately on the current thread. */ public final class ImmediateScheduler extends AbstractScheduler { + private static final ImmediateScheduler INSTANCE = new ImmediateScheduler(); public static ImmediateScheduler getInstance() { diff --git a/HMCLAPI/src/main/java/rx/concurrency/NewThreadScheduler.java b/HMCLAPI/src/main/java/rx/concurrency/NewThreadScheduler.java index b9f1606b1..e8a4b9150 100755 --- a/HMCLAPI/src/main/java/rx/concurrency/NewThreadScheduler.java +++ b/HMCLAPI/src/main/java/rx/concurrency/NewThreadScheduler.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,6 +24,7 @@ import rx.util.functions.Func0; * Schedules work on a new thread. */ public class NewThreadScheduler extends AbstractScheduler { + private static final NewThreadScheduler INSTANCE = new NewThreadScheduler(); public static NewThreadScheduler getInstance() { diff --git a/HMCLAPI/src/main/java/rx/concurrency/Schedulers.java b/HMCLAPI/src/main/java/rx/concurrency/Schedulers.java index c24afb3ce..666a2e3d8 100755 --- a/HMCLAPI/src/main/java/rx/concurrency/Schedulers.java +++ b/HMCLAPI/src/main/java/rx/concurrency/Schedulers.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,6 +28,7 @@ import rx.Scheduler; * Static factory methods for creating Schedulers. */ public class Schedulers { + private static final ScheduledExecutorService COMPUTATION_EXECUTOR = createComputationExecutor(); private static final Executor IO_EXECUTOR = createIOExecutor(); @@ -37,7 +38,7 @@ public class Schedulers { /** * {@link Scheduler} that executes work immediately on the current thread. - * + * * @return {@link ImmediateScheduler} instance */ public static Scheduler immediate() { @@ -45,8 +46,9 @@ public class Schedulers { } /** - * {@link Scheduler} that queues work on the current thread to be executed after the current work completes. - * + * {@link Scheduler} that queues work on the current thread to be executed + * after the current work completes. + * * @return {@link CurrentThreadScheduler} instance */ public static Scheduler currentThread() { @@ -54,8 +56,9 @@ public class Schedulers { } /** - * {@link Scheduler} that creates a new {@link Thread} for each unit of work. - * + * {@link Scheduler} that creates a new {@link Thread} for each unit of + * work. + * * @return {@link NewThreadScheduler} instance */ public static Scheduler newThread() { @@ -63,8 +66,9 @@ public class Schedulers { } /** - * {@link Scheduler} that queues work on the EventQueue thread to be executed on the Swing UI Thread. - * + * {@link Scheduler} that queues work on the EventQueue thread to be + * executed on the Swing UI Thread. + * * @return {@link NewThreadScheduler} instance */ public static Scheduler eventQueue() { @@ -75,7 +79,7 @@ public class Schedulers { * {@link Scheduler} that queues work on an {@link Executor}. *

* Note that this does not support scheduled actions with a delay. - * + * * @return {@link ExecutorScheduler} instance */ public static Scheduler executor(Executor executor) { @@ -83,8 +87,9 @@ public class Schedulers { } /** - * {@link Scheduler} that queues work on an {@link ScheduledExecutorService}. - * + * {@link Scheduler} that queues work on an + * {@link ScheduledExecutorService}. + * * @return {@link ExecutorScheduler} instance */ public static Scheduler executor(ScheduledExecutorService executor) { @@ -94,12 +99,15 @@ public class Schedulers { /** * {@link Scheduler} intended for computational work. *

- * The implementation is backed by a {@link ScheduledExecutorService} thread-pool sized to the number of CPU cores. + * The implementation is backed by a {@link ScheduledExecutorService} + * thread-pool sized to the number of CPU cores. *

- * This can be used for event-loops, processing callbacks and other computational work. + * This can be used for event-loops, processing callbacks and other + * computational work. *

- * Do not perform IO-bound work on this scheduler. Use {@link #threadPoolForComputation()} instead. - * + * Do not perform IO-bound work on this scheduler. Use + * {@link #threadPoolForComputation()} instead. + * * @return {@link ExecutorScheduler} for computation-bound work. */ public static Scheduler threadPoolForComputation() { @@ -109,12 +117,14 @@ public class Schedulers { /** * {@link Scheduler} intended for IO-bound work. *

- * The implementation is backed by an {@link Executor} thread-pool that will grow as needed. + * The implementation is backed by an {@link Executor} thread-pool that will + * grow as needed. *

* This can be used for asynchronously performing blocking IO. *

- * Do not perform computational work on this scheduler. Use {@link #threadPoolForComputation()} instead. - * + * Do not perform computational work on this scheduler. Use + * {@link #threadPoolForComputation()} instead. + * * @return {@link ExecutorScheduler} for IO-bound work. */ public static Scheduler threadPoolForIO() { @@ -124,15 +134,15 @@ public class Schedulers { private static ScheduledExecutorService createComputationExecutor() { int cores = Runtime.getRuntime().availableProcessors(); return Executors.newScheduledThreadPool(cores, new ThreadFactory() { - final AtomicInteger counter = new AtomicInteger(); + final AtomicInteger counter = new AtomicInteger(); - @Override - public Thread newThread(Runnable r) { - Thread t = new Thread(r, "RxComputationThreadPool-" + counter.incrementAndGet()); - t.setDaemon(true); - return t; - } - }); + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r, "RxComputationThreadPool-" + counter.incrementAndGet()); + t.setDaemon(true); + return t; + } + }); } private static Executor createIOExecutor() { diff --git a/HMCLAPI/src/main/java/rx/concurrency/SleepingAction.java b/HMCLAPI/src/main/java/rx/concurrency/SleepingAction.java index a57fd9046..0eeca1288 100755 --- a/HMCLAPI/src/main/java/rx/concurrency/SleepingAction.java +++ b/HMCLAPI/src/main/java/rx/concurrency/SleepingAction.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,11 @@ import rx.Scheduler; import rx.Subscription; import rx.util.functions.Func0; -/* package */class SleepingAction implements Func0 { +/* + * package + */ +class SleepingAction implements Func0 { + private final Func0 underlying; private final Scheduler scheduler; private final long execTime; @@ -34,14 +38,13 @@ import rx.util.functions.Func0; @Override public Subscription call() { - if (execTime < scheduler.now()) { + if (execTime < scheduler.now()) try { Thread.sleep(scheduler.now() - execTime); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } - } return underlying.call(); diff --git a/HMCLAPI/src/main/java/rx/observables/GroupedObservable.java b/HMCLAPI/src/main/java/rx/observables/GroupedObservable.java index 28ee67de4..96c702575 100755 --- a/HMCLAPI/src/main/java/rx/observables/GroupedObservable.java +++ b/HMCLAPI/src/main/java/rx/observables/GroupedObservable.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,14 +21,17 @@ import rx.Subscription; import rx.util.functions.Func1; /** - * An {@link Observable} that has been grouped by a key whose value can be obtained using {@link #getKey()}

- * + * An {@link Observable} that has been grouped by a key whose value can be + * obtained using {@link #getKey()} + *

+ * * @see {@link Observable#groupBy(Observable, Func1)} - * + * * @param * @param */ public class GroupedObservable extends Observable { + private final K key; public GroupedObservable(K key, Func1, Subscription> onSubscribe) { diff --git a/HMCLAPI/src/main/java/rx/operators/OperationAll.java b/HMCLAPI/src/main/java/rx/operators/OperationAll.java index 01af295c7..09187a961 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationAll.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationAll.java @@ -15,19 +15,18 @@ public class OperationAll { } private static class AllObservable implements Func1, Subscription> { + private final Observable sequence; private final Func1 predicate; private final AtomicBoolean status = new AtomicBoolean(true); private final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); - private AllObservable(Observable sequence, Func1 predicate) { this.sequence = sequence; this.predicate = predicate; } - @Override public Subscription call(final Observer observer) { return subscription.wrap(sequence.subscribe(new Observer() { diff --git a/HMCLAPI/src/main/java/rx/operators/OperationCombineLatest.java b/HMCLAPI/src/main/java/rx/operators/OperationCombineLatest.java index f9c077cf5..aa80e468e 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationCombineLatest.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationCombineLatest.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,12 +36,18 @@ import rx.util.functions.Functions; public class OperationCombineLatest { /** - * Combines the two given observables, emitting an event containing an aggregation of the latest values of each of the source observables - * each time an event is received from one of the source observables, where the aggregation is defined by the given function. - * @param w0 The first source observable. - * @param w1 The second source observable. - * @param combineLatestFunction The aggregation function used to combine the source observable values. - * @return A function from an observer to a subscription. This can be used to create an observable from. + * Combines the two given observables, emitting an event containing an + * aggregation of the latest values of each of the source observables each + * time an event is received from one of the source observables, where the + * aggregation is defined by the given function. + * + * @param w0 The first source observable. + * @param w1 The second source observable. + * @param combineLatestFunction The aggregation function used to combine the + * source observable values. + * + * @return A function from an observer to a subscription. This can be used + * to create an observable from. */ public static Func1, Subscription> combineLatest(Observable w0, Observable w1, Func2 combineLatestFunction) { Aggregator a = new Aggregator<>(Functions.fromFunc(combineLatestFunction)); @@ -51,7 +57,8 @@ public class OperationCombineLatest { } /** - * @see #combineLatest(Observable w0, Observable w1, Func2 combineLatestFunction) + * @see #combineLatest(Observable w0, Observable w1, Func2 + * combineLatestFunction) */ public static Func1, Subscription> combineLatest(Observable w0, Observable w1, Observable w2, Func3 combineLatestFunction) { Aggregator a = new Aggregator<>(Functions.fromFunc(combineLatestFunction)); @@ -62,7 +69,8 @@ public class OperationCombineLatest { } /** - * @see #combineLatest(Observable w0, Observable w1, Func2 combineLatestFunction) + * @see #combineLatest(Observable w0, Observable w1, Func2 + * combineLatestFunction) */ public static Func1, Subscription> combineLatest(Observable w0, Observable w1, Observable w2, Observable w3, Func4 combineLatestFunction) { Aggregator a = new Aggregator<>(Functions.fromFunc(combineLatestFunction)); @@ -74,6 +82,7 @@ public class OperationCombineLatest { } private static class CombineObserver implements Observer { + final Observable w; final Aggregator a; private Subscription subscription; @@ -84,9 +93,8 @@ public class OperationCombineLatest { } public synchronized void startWatching() { - if (subscription != null) { + if (subscription != null) throw new RuntimeException("This should only be called once."); - } subscription = w.subscribe(this); } @@ -107,9 +115,10 @@ public class OperationCombineLatest { } /** - * Receive notifications from each of the observables we are reducing and execute the combineLatestFunction - * whenever we have received an event from one of the observables, as soon as each Observable has received - * at least one event. + * Receive notifications from each of the observables we are reducing and + * execute the combineLatestFunction whenever we have received an event from + * one of the observables, as soon as each Observable has received at least + * one event. */ private static class Aggregator implements Func1, Subscription> { @@ -120,31 +129,37 @@ public class OperationCombineLatest { // used as an internal lock for handling the latest values and the completed state of each observer private final Object lockObject = new Object(); - + /** * Store when an observer completes. *

- * Note that access to this set MUST BE SYNCHRONIZED via 'lockObject' above. - * */ + * Note that access to this set MUST BE SYNCHRONIZED via 'lockObject' + * above. + * + */ private final Set> completed = new HashSet<>(); /** * The latest value from each observer *

- * Note that access to this set MUST BE SYNCHRONIZED via 'lockObject' above. - * */ + * Note that access to this set MUST BE SYNCHRONIZED via 'lockObject' + * above. + * + */ private final Map, Object> latestValue = new HashMap<>(); - + /** * Whether each observer has a latest value at all. *

- * Note that access to this set MUST BE SYNCHRONIZED via 'lockObject' above. - * */ + * Note that access to this set MUST BE SYNCHRONIZED via 'lockObject' + * above. + * + */ private final Set> hasLatestValue = new HashSet<>(); /** - * Ordered list of observers to combine. - * No synchronization is necessary as these can not be added or changed asynchronously. + * Ordered list of observers to combine. No synchronization is necessary + * as these can not be added or changed asynchronously. */ private final List> observers = new LinkedList<>(); @@ -153,8 +168,9 @@ public class OperationCombineLatest { } /** - * Receive notification of a Observer starting (meaning we should require it for aggregation) - * + * Receive notification of a Observer starting (meaning we should + * require it for aggregation) + * * @param w The observer to add. */ void addObserver(CombineObserver w) { @@ -163,51 +179,56 @@ public class OperationCombineLatest { /** * Receive notification of a Observer completing its iterations. - * + * * @param w The observer that has completed. */ void complete(CombineObserver w) { - synchronized(lockObject) { + synchronized (lockObject) { // store that this CombineLatestObserver is completed completed.add(w); // if all CombineObservers are completed, we mark the whole thing as completed - if (completed.size() == observers.size()) { + if (completed.size() == observers.size()) if (running.get()) { // mark ourselves as done observer.onCompleted(); // just to ensure we stop processing in case we receive more onNext/complete/error calls after this running.set(false); } - } } } /** - * Receive error for a Observer. Throw the error up the chain and stop processing. + * Receive error for a Observer. Throw the error up the chain and stop + * processing. */ void error(Exception e) { observer.onError(e); - /* tell all observers to unsubscribe since we had an error */ + /* + * tell all observers to unsubscribe since we had an error + */ stop(); } /** * Receive the next value from an observer. *

- * If we have received values from all observers, trigger the combineLatest function, otherwise store the value and keep waiting. - * + * If we have received values from all observers, trigger the + * combineLatest function, otherwise store the value and keep waiting. + * * @param w * @param arg */ void next(CombineObserver w, T arg) { - if (observer == null) { + if (observer == null) throw new RuntimeException("This shouldn't be running if an Observer isn't registered"); - } - /* if we've been 'unsubscribed' don't process anything further even if the things we're watching keep sending (likely because they are not responding to the unsubscribe call) */ - if (!running.get()) { + /* + * if we've been 'unsubscribed' don't process anything further even + * if the things we're watching keep sending (likely because they + * are not responding to the unsubscribe call) + */ + if (!running.get()) return; - } // define here so the variable is out of the synchronized scope Object[] argsToCombineLatest = new Object[observers.size()]; @@ -216,22 +237,19 @@ public class OperationCombineLatest { synchronized (lockObject) { // remember this as the latest value for this observer latestValue.put(w, arg); - + // remember that this observer now has a latest value set hasLatestValue.add(w); // if all observers in the 'observers' list have a value, invoke the combineLatestFunction - for (CombineObserver rw : observers) { - if (!hasLatestValue.contains(rw)) { + for (CombineObserver rw : observers) + if (!hasLatestValue.contains(rw)) // we don't have a value yet for each observer to combine, so we don't have a combined value yet either return; - } - } // if we get to here this means all the queues have data int i = 0; - for (CombineObserver _w : observers) { + for (CombineObserver _w : observers) argsToCombineLatest[i++] = latestValue.get(_w); - } } // if we did not return above from the synchronized block we can now invoke the combineLatestFunction with all of the args // we do this outside the synchronized block as it is now safe to call this concurrently and don't need to block other threads from calling @@ -241,15 +259,15 @@ public class OperationCombineLatest { @Override public Subscription call(Observer observer) { - if (this.observer != null) { + if (this.observer != null) throw new IllegalStateException("Only one Observer can subscribe to this Observable."); - } this.observer = observer; - /* start the observers */ - for (CombineObserver rw : observers) { + /* + * start the observers + */ + for (CombineObserver rw : observers) rw.startWatching(); - } return new Subscription() { @Override @@ -260,14 +278,16 @@ public class OperationCombineLatest { } private void stop() { - /* tell ourselves to stop processing onNext events */ + /* + * tell ourselves to stop processing onNext events + */ running.set(false); - /* propogate to all observers to unsubscribe */ - for (CombineObserver rw : observers) { - if (rw.subscription != null) { + /* + * propogate to all observers to unsubscribe + */ + for (CombineObserver rw : observers) + if (rw.subscription != null) rw.subscription.unsubscribe(); - } - } } } } diff --git a/HMCLAPI/src/main/java/rx/operators/OperationConcat.java b/HMCLAPI/src/main/java/rx/operators/OperationConcat.java index a5ee11d6c..e1577bb81 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationConcat.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationConcat.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,11 +30,13 @@ import rx.util.functions.Func1; public final class OperationConcat { /** - * Combine the observable sequences from the list of Observables into one observable sequence without any transformation. - * - * @param sequences - * An observable sequence of elements to project. - * @return An observable sequence whose elements are the result of combining the output from the list of Observables. + * Combine the observable sequences from the list of Observables into one + * observable sequence without any transformation. + * + * @param sequences An observable sequence of elements to project. + * + * @return An observable sequence whose elements are the result of combining + * the output from the list of Observables. */ public static Func1, Subscription> concat(final Observable... sequences) { return new Func1, Subscription>() { @@ -66,6 +68,7 @@ public final class OperationConcat { } private static class Concat implements Func1, Subscription> { + private final Observable[] sequences; private int num = 0; private int count = 0; @@ -94,6 +97,7 @@ public final class OperationConcat { } private class ConcatObserver implements Observer { + private final Observer observer; ConcatObserver(Observer observer) { @@ -123,4 +127,4 @@ public final class OperationConcat { } } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationDefer.java b/HMCLAPI/src/main/java/rx/operators/OperationDefer.java index 66b31b50e..45abd1a38 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationDefer.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationDefer.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/HMCLAPI/src/main/java/rx/operators/OperationDematerialize.java b/HMCLAPI/src/main/java/rx/operators/OperationDematerialize.java index 535da7bfa..fa5eca845 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationDematerialize.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationDematerialize.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,17 +22,23 @@ import rx.Subscription; import rx.util.functions.Func1; /** - * Dematerializes the explicit notification values of an observable sequence as implicit notifications. - * See http://msdn.microsoft.com/en-us/library/hh229047(v=vs.103).aspx for the Microsoft Rx equivalent. + * Dematerializes the explicit notification values of an observable sequence as + * implicit notifications. See + * http://msdn.microsoft.com/en-us/library/hh229047(v=vs.103).aspx for the + * Microsoft Rx equivalent. */ public final class OperationDematerialize { /** - * Dematerializes the explicit notification values of an observable sequence as implicit notifications. - * - * @param sequence - * An observable sequence containing explicit notification values which have to be turned into implicit notifications. - * @return An observable sequence exhibiting the behavior corresponding to the source sequence's notification values. + * Dematerializes the explicit notification values of an observable sequence + * as implicit notifications. + * + * @param sequence An observable sequence containing explicit notification + * values which have to be turned into implicit notifications. + * + * @return An observable sequence exhibiting the behavior corresponding to + * the source sequence's notification values. + * * @see http://msdn.microsoft.com/en-us/library/hh229047(v=vs.103).aspx */ public static Func1, Subscription> dematerialize(final Observable> sequence) { diff --git a/HMCLAPI/src/main/java/rx/operators/OperationFilter.java b/HMCLAPI/src/main/java/rx/operators/OperationFilter.java index b6c2f23e1..5447d302e 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationFilter.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationFilter.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,16 +44,15 @@ public final class OperationFilter { @Override public void onNext(T value) { try { - if (predicate.call(value)) { + if (predicate.call(value)) observer.onNext(value); - } } catch (Exception ex) { observer.onError(ex); // this will work if the sequence is asynchronous, it will have no effect on a synchronous observable subscription.unsubscribe(); } } - + @Override public void onError(Exception ex) { observer.onError(ex); @@ -67,4 +66,4 @@ public final class OperationFilter { } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationFinally.java b/HMCLAPI/src/main/java/rx/operators/OperationFinally.java index 9b1b98796..1d4fc9d94 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationFinally.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationFinally.java @@ -25,25 +25,31 @@ public final class OperationFinally { /** * Call a given action when a sequence completes (with or without an - * exception). The returned observable is exactly as threadsafe as the + * exception). The returned observable is exactly as threadsafe as the * source observable. *

* Note that "finally" is a Java reserved word and cannot be an identifier, * so we use "finallyDo". * * @param sequence An observable sequence of elements - * @param action An action to be taken when the sequence is complete or throws an exception - * @return An observable sequence with the same elements as the input. - * After the last element is consumed (and {@link Observer#onCompleted} has been called), - * or after an exception is thrown (and {@link Observer#onError} has been called), - * the given action will be called. - * @see MSDN Observable.Finally method + * @param action An action to be taken when the sequence is complete or + * throws an exception + * + * @return An observable sequence with the same elements as the input. After + * the last element is consumed (and {@link Observer#onCompleted} has been + * called), or after an exception is thrown (and {@link Observer#onError} + * has been called), the given action will be called. + * + * @see + * MSDN + * Observable.Finally method */ public static Func1, Subscription> finallyDo(final Observable sequence, final Action0 action) { return new Finally<>(sequence, action)::call; } private static class Finally implements Func1, Subscription> { + private final Observable sequence; private final Action0 finalAction; @@ -58,6 +64,7 @@ public final class OperationFinally { } private class FinallyObserver implements Observer { + private final Observer observer; FinallyObserver(Observer observer) { diff --git a/HMCLAPI/src/main/java/rx/operators/OperationMap.java b/HMCLAPI/src/main/java/rx/operators/OperationMap.java index 62431b105..1a80237c0 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationMap.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationMap.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,52 +23,51 @@ import rx.util.functions.Func1; public final class OperationMap { /** - * Accepts a sequence and a transformation function. Returns a sequence that is the result of - * applying the transformation function to each item in the sequence. - * - * @param sequence - * the input sequence. - * @param func - * a function to apply to each item in the sequence. - * @param - * the type of the input sequence. - * @param - * the type of the output sequence. - * @return a sequence that is the result of applying the transformation function to each item in the input sequence. + * Accepts a sequence and a transformation function. Returns a sequence that + * is the result of applying the transformation function to each item in the + * sequence. + * + * @param sequence the input sequence. + * @param func a function to apply to each item in the sequence. + * @param the type of the input sequence. + * @param the type of the output sequence. + * + * @return a sequence that is the result of applying the transformation + * function to each item in the input sequence. */ public static Func1, Subscription> map(Observable sequence, Func1 func) { return new MapObservable<>(sequence, func); } /** - * Accepts a sequence of observable sequences and a transformation function. Returns a flattened sequence that is the result of - * applying the transformation function to each item in the sequence of each observable sequence. + * Accepts a sequence of observable sequences and a transformation function. + * Returns a flattened sequence that is the result of applying the + * transformation function to each item in the sequence of each observable + * sequence. *

* The closure should return an Observable which will then be merged. - * - * @param sequence - * the input sequence. - * @param func - * a function to apply to each item in the sequence. - * @param - * the type of the input sequence. - * @param - * the type of the output sequence. - * @return a sequence that is the result of applying the transformation function to each item in the input sequence. + * + * @param sequence the input sequence. + * @param func a function to apply to each item in the sequence. + * @param the type of the input sequence. + * @param the type of the output sequence. + * + * @return a sequence that is the result of applying the transformation + * function to each item in the input sequence. */ public static Func1, Subscription> mapMany(Observable sequence, Func1> func) { return OperationMerge.merge(Observable.create(map(sequence, func))); } /** - * An observable sequence that is the result of applying a transformation to each item in an input sequence. - * - * @param - * the type of the input sequence. - * @param - * the type of the output sequence. + * An observable sequence that is the result of applying a transformation to + * each item in an input sequence. + * + * @param the type of the input sequence. + * @param the type of the output sequence. */ private static class MapObservable implements Func1, Subscription> { + public MapObservable(Observable sequence, Func1 func) { this.sequence = sequence; this.func = func; @@ -85,14 +84,14 @@ public final class OperationMap { } /** - * An observer that applies a transformation function to each item and forwards the result to an inner observer. - * - * @param - * the type of the observer items. - * @param - * the type of the inner observer items. + * An observer that applies a transformation function to each item and + * forwards the result to an inner observer. + * + * @param the type of the observer items. + * @param the type of the inner observer items. */ private static class MapObserver implements Observer { + public MapObserver(Observer observer, Func1 func) { this.observer = observer; this.func = func; diff --git a/HMCLAPI/src/main/java/rx/operators/OperationMaterialize.java b/HMCLAPI/src/main/java/rx/operators/OperationMaterialize.java index c1f3a850a..252acf542 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationMaterialize.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationMaterialize.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,20 +22,27 @@ import rx.Subscription; import rx.util.functions.Func1; /** - * Materializes the implicit notifications of an observable sequence as explicit notification values. + * Materializes the implicit notifications of an observable sequence as explicit + * notification values. *

- * In other words, converts a sequence of OnNext, OnError and OnCompleted events into a sequence of ObservableNotifications containing the OnNext, OnError and OnCompleted values. + * In other words, converts a sequence of OnNext, OnError and OnCompleted events + * into a sequence of ObservableNotifications containing the OnNext, OnError and + * OnCompleted values. *

- * See http://msdn.microsoft.com/en-us/library/hh229453(v=VS.103).aspx for the Microsoft Rx equivalent. + * See http://msdn.microsoft.com/en-us/library/hh229453(v=VS.103).aspx for the + * Microsoft Rx equivalent. */ public final class OperationMaterialize { /** - * Materializes the implicit notifications of an observable sequence as explicit notification values. - * - * @param sequence - * An observable sequence of elements to project. - * @return An observable sequence whose elements are the result of materializing the notifications of the given sequence. + * Materializes the implicit notifications of an observable sequence as + * explicit notification values. + * + * @param sequence An observable sequence of elements to project. + * + * @return An observable sequence whose elements are the result of + * materializing the notifications of the given sequence. + * * @see http://msdn.microsoft.com/en-us/library/hh229453(v=VS.103).aspx */ public static Func1>, Subscription> materialize(final Observable sequence) { diff --git a/HMCLAPI/src/main/java/rx/operators/OperationMerge.java b/HMCLAPI/src/main/java/rx/operators/OperationMerge.java index 3f3d4a194..f9ca27f63 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationMerge.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationMerge.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,11 +30,14 @@ import rx.util.functions.Func1; public final class OperationMerge { /** - * Flattens the observable sequences from the list of Observables into one observable sequence without any transformation. - * - * @param source - * An observable sequence of elements to project. - * @return An observable sequence whose elements are the result of flattening the output from the list of Observables. + * Flattens the observable sequences from the list of Observables into one + * observable sequence without any transformation. + * + * @param source An observable sequence of elements to project. + * + * @return An observable sequence whose elements are the result of + * flattening the output from the list of Observables. + * * @see http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx */ public static Func1, Subscription> merge(final Observable> source) { @@ -53,17 +56,14 @@ public final class OperationMerge { @Override public Subscription call(Observer> observer) { - for (Observable o : sequences) { - if (!unsubscribed) { + for (Observable o : sequences) + if (!unsubscribed) observer.onNext(o); - } else { + else // break out of the loop if we are unsubscribed break; - } - } - if (!unsubscribed) { + if (!unsubscribed) observer.onCompleted(); - } return () -> { unsubscribed = true; @@ -73,17 +73,24 @@ public final class OperationMerge { } /** - * This class is NOT thread-safe if invoked and referenced multiple times. In other words, don't subscribe to it multiple times from different threads. + * This class is NOT thread-safe if invoked and referenced multiple times. + * In other words, don't subscribe to it multiple times from different + * threads. *

- * It IS thread-safe from within it while receiving onNext events from multiple threads. + * It IS thread-safe from within it while receiving onNext events from + * multiple threads. *

- * This should all be fine as long as it's kept as a private class and a new instance created from static factory method above. + * This should all be fine as long as it's kept as a private class and a new + * instance created from static factory method above. *

- * Note how the take() factory method above protects us from a single instance being exposed with the Observable wrapper handling the subscribe flow. - * + * Note how the take() factory method above protects us from a single + * instance being exposed with the Observable wrapper handling the subscribe + * flow. + * * @param */ private static final class MergeObservable implements Func1, Subscription> { + private final Observable> sequences; private final MergeSubscription ourSubscription = new MergeSubscription(); private final AtomicBoolean stopped = new AtomicBoolean(false); @@ -99,7 +106,8 @@ public final class OperationMerge { public Subscription call(Observer actualObserver) { /** - * We must synchronize a merge because we subscribe to multiple sequences in parallel that will each be emitting. + * We must synchronize a merge because we subscribe to multiple + * sequences in parallel that will each be emitting. *

* The calls from each sequence must be serialized. *

@@ -109,18 +117,23 @@ public final class OperationMerge { SynchronizedObserver synchronizedObserver = new SynchronizedObserver<>(actualObserver, subscription); /** - * Subscribe to the parent Observable to get to the children Observables + * Subscribe to the parent Observable to get to the children + * Observables */ sequences.subscribe(new ParentObserver(synchronizedObserver)); - /* return our subscription to allow unsubscribing */ + /* + * return our subscription to allow unsubscribing + */ return subscription; } /** - * Manage the internal subscription with a thread-safe means of stopping/unsubscribing so we don't unsubscribe twice. + * Manage the internal subscription with a thread-safe means of + * stopping/unsubscribing so we don't unsubscribe twice. *

- * Also has the stop() method returning a boolean so callers know if their thread "won" and should perform further actions. + * Also has the stop() method returning a boolean so callers know if + * their thread "won" and should perform further actions. */ private class MergeSubscription implements Subscription { @@ -134,23 +147,23 @@ public final class OperationMerge { boolean didSet = stopped.compareAndSet(false, true); if (didSet) { // this thread won the race to stop, so unsubscribe from the actualSubscription - for (Subscription _s : childSubscriptions.values()) { + for (Subscription _s : childSubscriptions.values()) _s.unsubscribe(); - } return true; - } else { + } else // another thread beat us return false; - } } } /** - * Subscribe to the top level Observable to receive the sequence of Observable children. - * + * Subscribe to the top level Observable to receive the sequence of + * Observable children. + * * @param */ private class ParentObserver implements Observer> { + private final Observer actualObserver; public ParentObserver(Observer actualObserver) { @@ -164,13 +177,10 @@ public final class OperationMerge { // but will let the child worry about it // if however this completes and there are no children processing, then we will send onCompleted - if (childObservers.isEmpty()) { - if (!stopped.get()) { - if (ourSubscription.stop()) { + if (childObservers.isEmpty()) + if (!stopped.get()) + if (ourSubscription.stop()) actualObserver.onCompleted(); - } - } - } } @Override @@ -180,20 +190,21 @@ public final class OperationMerge { @Override public void onNext(Observable childObservable) { - if (stopped.get()) { + if (stopped.get()) // we won't act on any further items return; - } - if (childObservable == null) { + if (childObservable == null) throw new IllegalArgumentException("Observable can not be null."); - } /** - * For each child Observable we receive we'll subscribe with a separate Observer - * that will each then forward their sequences to the actualObserver. + * For each child Observable we receive we'll subscribe with a + * separate Observer that will each then forward their sequences + * to the actualObserver. *

- * We use separate child Observers for each sequence to simplify the onComplete/onError handling so each sequence has its own lifecycle. + * We use separate child Observers for each sequence to simplify + * the onComplete/onError handling so each sequence has its own + * lifecycle. */ ChildObserver _w = new ChildObserver(actualObserver); childObservers.put(_w, _w); @@ -204,8 +215,9 @@ public final class OperationMerge { } /** - * Subscribe to each child Observable and forward their sequence of data to the actualObserver - * + * Subscribe to each child Observable and forward their sequence of + * data to the actualObserver + * */ private class ChildObserver implements Observer { @@ -221,33 +233,27 @@ public final class OperationMerge { childObservers.remove(this); // if there are now 0 Observers left, so if the parent is also completed we send the onComplete to the actualObserver // if the parent is not complete that means there is another sequence (and child Observer) to come - if (!stopped.get()) { - if (childObservers.isEmpty() && parentCompleted) { - if (ourSubscription.stop()) { + if (!stopped.get()) + if (childObservers.isEmpty() && parentCompleted) + if (ourSubscription.stop()) // this thread 'won' the race to unsubscribe/stop so let's send onCompleted actualObserver.onCompleted(); - } - } - } } @Override public void onError(Exception e) { - if (!stopped.get()) { - if (ourSubscription.stop()) { + if (!stopped.get()) + if (ourSubscription.stop()) // this thread 'won' the race to unsubscribe/stop so let's send the error actualObserver.onError(e); - } - } } @Override public void onNext(T args) { // in case the Observable is poorly behaved and doesn't listen to the unsubscribe request // we'll ignore anything that comes in after we've unsubscribed - if (!stopped.get()) { + if (!stopped.get()) actualObserver.onNext(args); - } } } diff --git a/HMCLAPI/src/main/java/rx/operators/OperationMergeDelayError.java b/HMCLAPI/src/main/java/rx/operators/OperationMergeDelayError.java index 38ab323d2..4a2e26bfc 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationMergeDelayError.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationMergeDelayError.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,23 +27,30 @@ import rx.util.CompositeException; import rx.util.functions.Func1; /** - * Same functionality as OperationMerge except that onError events will be skipped so that all onNext calls are passed on until all sequences finish with onComplete or onError, and then the first - * onError received (if any) will be passed on. + * Same functionality as OperationMerge except that onError events will be + * skipped so that all onNext calls are passed on until all sequences finish + * with onComplete or onError, and then the first onError received (if any) will + * be passed on. *

- * This allows retrieving all successful onNext calls without being blocked by an onError early in a sequence. + * This allows retrieving all successful onNext calls without being blocked by + * an onError early in a sequence. *

- * NOTE: If this is used on an infinite stream it will never call onError and effectively will swallow errors. + * NOTE: If this is used on an infinite stream it will never call onError and + * effectively will swallow errors. */ public final class OperationMergeDelayError { /** - * Flattens the observable sequences from the list of Observables into one observable sequence without any transformation and delays any onError calls until after all sequences have called - * onError or onComplete so as to allow all successful - * onNext calls to be received. - * - * @param source - * An observable sequence of elements to project. - * @return An observable sequence whose elements are the result of flattening the output from the list of Observables. + * Flattens the observable sequences from the list of Observables into one + * observable sequence without any transformation and delays any onError + * calls until after all sequences have called onError or onComplete so as + * to allow all successful onNext calls to be received. + * + * @param source An observable sequence of elements to project. + * + * @return An observable sequence whose elements are the result of + * flattening the output from the list of Observables. + * * @see http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx */ public static Func1, Subscription> mergeDelayError(final Observable> sequences) { @@ -63,17 +70,14 @@ public final class OperationMergeDelayError { @Override public Subscription call(Observer> observer) { - for (Observable o : sequences) { - if (!unsubscribed) { + for (Observable o : sequences) + if (!unsubscribed) observer.onNext(o); - } else { + else // break out of the loop if we are unsubscribed break; - } - } - if (!unsubscribed) { + if (!unsubscribed) observer.onCompleted(); - } return new Subscription() { @Override @@ -93,17 +97,14 @@ public final class OperationMergeDelayError { @Override public Subscription call(Observer> observer) { - for (Observable o : sequences) { - if (!unsubscribed) { + for (Observable o : sequences) + if (!unsubscribed) observer.onNext(o); - } else { + else // break out of the loop if we are unsubscribed break; - } - } - if (!unsubscribed) { + if (!unsubscribed) observer.onCompleted(); - } return new Subscription() { @@ -118,17 +119,24 @@ public final class OperationMergeDelayError { } /** - * This class is NOT thread-safe if invoked and referenced multiple times. In other words, don't subscribe to it multiple times from different threads. + * This class is NOT thread-safe if invoked and referenced multiple times. + * In other words, don't subscribe to it multiple times from different + * threads. *

- * It IS thread-safe from within it while receiving onNext events from multiple threads. + * It IS thread-safe from within it while receiving onNext events from + * multiple threads. *

- * This should all be fine as long as it's kept as a private class and a new instance created from static factory method above. + * This should all be fine as long as it's kept as a private class and a new + * instance created from static factory method above. *

- * Note how the take() factory method above protects us from a single instance being exposed with the Observable wrapper handling the subscribe flow. - * + * Note how the take() factory method above protects us from a single + * instance being exposed with the Observable wrapper handling the subscribe + * flow. + * * @param */ private static final class MergeDelayErrorObservable implements Func1, Subscription> { + private final Observable> sequences; private final MergeSubscription ourSubscription = new MergeSubscription(); private AtomicBoolean stopped = new AtomicBoolean(false); @@ -144,18 +152,23 @@ public final class OperationMergeDelayError { public Subscription call(Observer actualObserver) { /** - * Subscribe to the parent Observable to get to the children Observables + * Subscribe to the parent Observable to get to the children + * Observables */ sequences.subscribe(new ParentObserver(actualObserver)); - /* return our subscription to allow unsubscribing */ + /* + * return our subscription to allow unsubscribing + */ return ourSubscription; } /** - * Manage the internal subscription with a thread-safe means of stopping/unsubscribing so we don't unsubscribe twice. + * Manage the internal subscription with a thread-safe means of + * stopping/unsubscribing so we don't unsubscribe twice. *

- * Also has the stop() method returning a boolean so callers know if their thread "won" and should perform further actions. + * Also has the stop() method returning a boolean so callers know if + * their thread "won" and should perform further actions. */ private class MergeSubscription implements Subscription { @@ -169,23 +182,23 @@ public final class OperationMergeDelayError { boolean didSet = stopped.compareAndSet(false, true); if (didSet) { // this thread won the race to stop, so unsubscribe from the actualSubscription - for (Subscription _s : childSubscriptions.values()) { + for (Subscription _s : childSubscriptions.values()) _s.unsubscribe(); - } return true; - } else { + } else // another thread beat us return false; - } } } /** - * Subscribe to the top level Observable to receive the sequence of Observable children. - * + * Subscribe to the top level Observable to receive the sequence of + * Observable children. + * * @param */ private class ParentObserver implements Observer> { + private final Observer actualObserver; public ParentObserver(Observer actualObserver) { @@ -199,22 +212,18 @@ public final class OperationMergeDelayError { // but will let the child worry about it // if however this completes and there are no children processing, then we will send onCompleted - if (childObservers.size() == 0) { - if (!stopped.get()) { - if (ourSubscription.stop()) { - if (onErrorReceived.size() == 1) { + if (childObservers.size() == 0) + if (!stopped.get()) + if (ourSubscription.stop()) + if (onErrorReceived.size() == 1) // an onError was received from 1 ChildObserver so we now send it as a delayed error actualObserver.onError(onErrorReceived.peek()); - } else if (onErrorReceived.size() > 1) { + else if (onErrorReceived.size() > 1) // an onError was received from more than 1 ChildObserver so we now send it as a delayed error actualObserver.onError(new CompositeException(onErrorReceived)); - } else { + else // no delayed error so send onCompleted actualObserver.onCompleted(); - } - } - } - } } @Override @@ -224,20 +233,21 @@ public final class OperationMergeDelayError { @Override public void onNext(Observable childObservable) { - if (stopped.get()) { + if (stopped.get()) // we won't act on any further items return; - } - if (childObservable == null) { + if (childObservable == null) throw new IllegalArgumentException("Observable can not be null."); - } /** - * For each child Observable we receive we'll subscribe with a separate Observer - * that will each then forward their sequences to the actualObserver. + * For each child Observable we receive we'll subscribe with a + * separate Observer that will each then forward their sequences + * to the actualObserver. *

- * We use separate child Observers for each sequence to simplify the onComplete/onError handling so each sequence has its own lifecycle. + * We use separate child Observers for each sequence to simplify + * the onComplete/onError handling so each sequence has its own + * lifecycle. */ ChildObserver _w = new ChildObserver(actualObserver); childObservers.put(_w, _w); @@ -248,8 +258,9 @@ public final class OperationMergeDelayError { } /** - * Subscribe to each child Observable and forward their sequence of data to the actualObserver - * + * Subscribe to each child Observable and forward their sequence of + * data to the actualObserver + * */ private class ChildObserver implements Observer { @@ -266,9 +277,8 @@ public final class OperationMergeDelayError { childObservers.remove(this); // if there are now 0 Observers left, so if the parent is also completed we send the onComplete to the actualObserver // if the parent is not complete that means there is another sequence (and child Observer) to come - if (!stopped.get()) { + if (!stopped.get()) finishObserver(); - } } @Override @@ -289,37 +299,37 @@ public final class OperationMergeDelayError { } /** - * onComplete and onError when called need to check for the parent being complete and if so send the onCompleted or onError to the actualObserver. + * onComplete and onError when called need to check for the parent + * being complete and if so send the onCompleted or onError to the + * actualObserver. *

- * This does NOT get invoked if synchronous execution occurs, but will when asynchronously executing. + * This does NOT get invoked if synchronous execution occurs, but + * will when asynchronously executing. *

- * TestCase testErrorDelayed4WithThreading specifically tests this use case. + * TestCase testErrorDelayed4WithThreading specifically tests this + * use case. */ private void finishObserver() { - if (childObservers.size() == 0 && parentCompleted) { - if (ourSubscription.stop()) { + if (childObservers.size() == 0 && parentCompleted) + if (ourSubscription.stop()) // this thread 'won' the race to unsubscribe/stop so let's send onError or onCompleted - if (onErrorReceived.size() == 1) { + if (onErrorReceived.size() == 1) // an onError was received from 1 ChildObserver so we now send it as a delayed error actualObserver.onError(onErrorReceived.peek()); - } else if (onErrorReceived.size() > 1) { + else if (onErrorReceived.size() > 1) // an onError was received from more than 1 ChildObserver so we now send it as a delayed error actualObserver.onError(new CompositeException(onErrorReceived)); - } else { + else // no delayed error so send onCompleted actualObserver.onCompleted(); - } - } - } } @Override public void onNext(T args) { // in case the Observable is poorly behaved and doesn't listen to the unsubscribe request // we'll ignore anything that comes in after we've unsubscribed or an onError has been received and delayed - if (!stopped.get() && !finished) { + if (!stopped.get() && !finished) actualObserver.onNext(args); - } } } diff --git a/HMCLAPI/src/main/java/rx/operators/OperationMostRecent.java b/HMCLAPI/src/main/java/rx/operators/OperationMostRecent.java index 7cb4c3139..6d37a0e47 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationMostRecent.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationMostRecent.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -54,9 +54,8 @@ public final class OperationMostRecent { @Override public T next() { - if (observer.getException() != null) { + if (observer.getException() != null) throw Exceptions.propagate(observer.getException()); - } return observer.getRecentValue(); } @@ -67,6 +66,7 @@ public final class OperationMostRecent { } private static class MostRecentObserver implements Observer { + private final AtomicBoolean completed = new AtomicBoolean(false); private final AtomicReference value; private final AtomicReference exception = new AtomicReference<>(); diff --git a/HMCLAPI/src/main/java/rx/operators/OperationNext.java b/HMCLAPI/src/main/java/rx/operators/OperationNext.java index 11495fcd5..0204b6f91 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationNext.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationNext.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,8 @@ import rx.Observer; import rx.util.Exceptions; /** - * Samples the next value (blocking without buffering) from in an observable sequence. + * Samples the next value (blocking without buffering) from in an observable + * sequence. */ public final class OperationNext { @@ -56,9 +57,8 @@ public final class OperationNext { @Override public T next() { - if (observer.isCompleted(true)) { + if (observer.isCompleted(true)) throw new IllegalStateException("Observable is completed"); - } observer.await(); @@ -78,6 +78,7 @@ public final class OperationNext { } private static class NextObserver implements Observer> { + private final BlockingQueue> buf = new ArrayBlockingQueue<>(1); private final AtomicBoolean waiting = new AtomicBoolean(false); @@ -100,9 +101,8 @@ public final class OperationNext { Notification concurrentItem = buf.poll(); // in case if we won race condition with onComplete/onError method - if (!concurrentItem.isOnNext()) { + if (!concurrentItem.isOnNext()) toOffer = concurrentItem; - } } } @@ -114,17 +114,14 @@ public final class OperationNext { public boolean isCompleted(boolean rethrowExceptionIfExists) { Notification lastItem = buf.peek(); - if (lastItem == null) { + if (lastItem == null) return false; - } - if (lastItem.isOnError()) { - if (rethrowExceptionIfExists) { + if (lastItem.isOnError()) + if (rethrowExceptionIfExists) throw Exceptions.propagate(lastItem.getException()); - } else { + else return true; - } - } return lastItem.isOnCompleted(); } @@ -132,13 +129,11 @@ public final class OperationNext { public T takeNext() throws InterruptedException { Notification next = buf.take(); - if (next.isOnError()) { + if (next.isOnError()) throw Exceptions.propagate(next.getException()); - } - if (next.isOnCompleted()) { + if (next.isOnCompleted()) throw new IllegalStateException("Observable is completed"); - } return next.getValue(); diff --git a/HMCLAPI/src/main/java/rx/operators/OperationObserveOn.java b/HMCLAPI/src/main/java/rx/operators/OperationObserveOn.java index e3a344586..176d880e1 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationObserveOn.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationObserveOn.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,6 +28,7 @@ public class OperationObserveOn { } private static class ObserveOn implements Func1, Subscription> { + private final Observable source; private final Scheduler scheduler; diff --git a/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaFunction.java b/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaFunction.java index 021fcf920..1f3758fa0 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaFunction.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaFunction.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,30 +55,39 @@ public final class OperationOnErrorResumeNextViaFunction { } /** - * Instead of passing the onError forward, we intercept and "resume" with the resumeSequence. + * Instead of passing the onError forward, we intercept and + * "resume" with the resumeSequence. */ @Override public void onError(Exception ex) { - /* remember what the current subscription is so we can determine if someone unsubscribes concurrently */ + /* + * remember what the current subscription is so we can + * determine if someone unsubscribes concurrently + */ AtomicObservableSubscription currentSubscription = subscriptionRef.get(); // check that we have not been unsubscribed before we can process the error - if (currentSubscription != null) { + if (currentSubscription != null) try { Observable resumeSequence = resumeFunction.call(ex); - /* error occurred, so switch subscription to the 'resumeSequence' */ + /* + * error occurred, so switch subscription to the + * 'resumeSequence' + */ AtomicObservableSubscription innerSubscription = new AtomicObservableSubscription(resumeSequence.subscribe(observer)); - /* we changed the sequence, so also change the subscription to the one of the 'resumeSequence' instead */ - if (!subscriptionRef.compareAndSet(currentSubscription, innerSubscription)) { + /* + * we changed the sequence, so also change the + * subscription to the one of the 'resumeSequence' + * instead + */ + if (!subscriptionRef.compareAndSet(currentSubscription, innerSubscription)) // we failed to set which means 'subscriptionRef' was set to NULL via the unsubscribe below // so we want to immediately unsubscribe from the resumeSequence we just subscribed to innerSubscription.unsubscribe(); - } } catch (Exception e) { // the resume function failed so we need to call onError // I am using CompositeException so that both exceptions can be seen observer.onError(new CompositeException("OnErrorResume function failed", Arrays.asList(ex, e))); } - } } @Override @@ -96,4 +105,4 @@ public final class OperationOnErrorResumeNextViaFunction { }; } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaObservable.java b/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaObservable.java index 7b3302000..adce8687c 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaObservable.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaObservable.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -54,22 +54,32 @@ public final class OperationOnErrorResumeNextViaObservable { } /** - * Instead of passing the onError forward, we intercept and "resume" with the resumeSequence. + * Instead of passing the onError forward, we intercept and + * "resume" with the resumeSequence. */ @Override public void onError(Exception ex) { - /* remember what the current subscription is so we can determine if someone unsubscribes concurrently */ + /* + * remember what the current subscription is so we can + * determine if someone unsubscribes concurrently + */ AtomicObservableSubscription currentSubscription = subscriptionRef.get(); // check that we have not been unsubscribed before we can process the error if (currentSubscription != null) { - /* error occurred, so switch subscription to the 'resumeSequence' */ + /* + * error occurred, so switch subscription to the + * 'resumeSequence' + */ AtomicObservableSubscription innerSubscription = new AtomicObservableSubscription(resumeSequence.subscribe(observer)); - /* we changed the sequence, so also change the subscription to the one of the 'resumeSequence' instead */ - if (!subscriptionRef.compareAndSet(currentSubscription, innerSubscription)) { + /* + * we changed the sequence, so also change the + * subscription to the one of the 'resumeSequence' + * instead + */ + if (!subscriptionRef.compareAndSet(currentSubscription, innerSubscription)) // we failed to set which means 'subscriptionRef' was set to NULL via the unsubscribe below // so we want to immediately unsubscribe from the resumeSequence we just subscribed to innerSubscription.unsubscribe(); - } } } @@ -88,4 +98,4 @@ public final class OperationOnErrorResumeNextViaObservable { }; } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationOnErrorReturn.java b/HMCLAPI/src/main/java/rx/operators/OperationOnErrorReturn.java index 096ad1ea3..1771f0cb4 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationOnErrorReturn.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationOnErrorReturn.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,8 @@ import rx.util.CompositeException; import rx.util.functions.Func1; /** - * When an onError occurs the resumeFunction will be executed and it's response passed to onNext instead of calling onError. + * When an onError occurs the resumeFunction will be executed and it's response + * passed to onNext instead of calling onError. */ public final class OperationOnErrorReturn { @@ -35,6 +36,7 @@ public final class OperationOnErrorReturn { } private static class OnErrorReturn implements Func1, Subscription> { + private final Func1 resumeFunction; private final Observable originalSequence; @@ -59,35 +61,50 @@ public final class OperationOnErrorReturn { } /** - * Instead of passing the onError forward, we intercept and "resume" with the resumeSequence. + * Instead of passing the onError forward, we intercept and + * "resume" with the resumeSequence. */ @Override public void onError(Exception ex) { - /* remember what the current subscription is so we can determine if someone unsubscribes concurrently */ + /* + * remember what the current subscription is so we can + * determine if someone unsubscribes concurrently + */ AtomicObservableSubscription currentSubscription = subscriptionRef.get(); // check that we have not been unsubscribed before we can process the error - if (currentSubscription != null) { + if (currentSubscription != null) try { - /* error occurred, so execute the function, give it the exception and call onNext with the response */ + /* + * error occurred, so execute the function, give it + * the exception and call onNext with the response + */ onNext(resumeFunction.call(ex)); /* - * we are not handling an exception thrown from this function ... should we do something? - * error handling within an error handler is a weird one to determine what we should do - * right now I'm going to just let it throw whatever exceptions occur (such as NPE) - * but I'm considering calling the original Observer.onError to act as if this OnErrorReturn operator didn't happen + * we are not handling an exception thrown from this + * function ... should we do something? + * error handling within an error handler is a weird + * one to determine what we should do + * right now I'm going to just let it throw whatever + * exceptions occur (such as NPE) + * but I'm considering calling the original + * Observer.onError to act as if this OnErrorReturn + * operator didn't happen */ - /* we are now completed */ + /* + * we are now completed + */ onCompleted(); - /* unsubscribe since it blew up */ + /* + * unsubscribe since it blew up + */ currentSubscription.unsubscribe(); } catch (Exception e) { // the return function failed so we need to call onError // I am using CompositeException so that both exceptions can be seen observer.onError(new CompositeException("OnErrorReturn function failed", Arrays.asList(ex, e))); } - } } @Override @@ -105,4 +122,4 @@ public final class OperationOnErrorReturn { }; } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationScan.java b/HMCLAPI/src/main/java/rx/operators/OperationScan.java index 9cd50b3a2..5f1140914 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationScan.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationScan.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,17 +23,19 @@ import rx.util.functions.Func1; import rx.util.functions.Func2; public final class OperationScan { + /** - * Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator. - * - * @param sequence - * An observable sequence of elements to project. - * @param initialValue - * The initial (seed) accumulator value. - * @param accumulator - * An accumulator function to be invoked on each element from the sequence. - * - * @return An observable sequence whose elements are the result of accumulating the output from the list of Observables. + * Applies an accumulator function over an observable sequence and returns + * each intermediate result with the specified source and accumulator. + * + * @param sequence An observable sequence of elements to project. + * @param initialValue The initial (seed) accumulator value. + * @param accumulator An accumulator function to be invoked on each element + * from the sequence. + * + * @return An observable sequence whose elements are the result of + * accumulating the output from the list of Observables. + * * @see http://msdn.microsoft.com/en-us/library/hh211665(v=vs.103).aspx */ public static Func1, Subscription> scan(Observable sequence, T initialValue, Func2 accumulator) { @@ -41,14 +43,16 @@ public final class OperationScan { } /** - * Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator. - * - * @param sequence - * An observable sequence of elements to project. - * @param accumulator - * An accumulator function to be invoked on each element from the sequence. - * - * @return An observable sequence whose elements are the result of accumulating the output from the list of Observables. + * Applies an accumulator function over an observable sequence and returns + * each intermediate result with the specified source and accumulator. + * + * @param sequence An observable sequence of elements to project. + * @param accumulator An accumulator function to be invoked on each element + * from the sequence. + * + * @return An observable sequence whose elements are the result of + * accumulating the output from the list of Observables. + * * @see http://msdn.microsoft.com/en-us/library/hh211665(v=vs.103).aspx */ public static Func1, Subscription> scan(Observable sequence, Func2 accumulator) { @@ -56,6 +60,7 @@ public final class OperationScan { } private static class Accumulator implements Func1, Subscription> { + private final Observable sequence; private final T initialValue; private final Func2 accumlatorFunction; @@ -75,11 +80,13 @@ public final class OperationScan { private boolean hasSentInitialValue = false; /** - * We must synchronize this because we can't allow - * multiple threads to execute the 'accumulatorFunction' at the same time because - * the accumulator code very often will be doing mutation of the 'acc' object such as a non-threadsafe HashMap - * - * Because it's synchronized it's using non-atomic variables since everything in this method is single-threaded + * We must synchronize this because we can't allow multiple + * threads to execute the 'accumulatorFunction' at the same time + * because the accumulator code very often will be doing + * mutation of the 'acc' object such as a non-threadsafe HashMap + * + * Because it's synchronized it's using non-atomic variables + * since everything in this method is single-threaded */ @Override public synchronized void onNext(T value) { @@ -119,9 +126,8 @@ public final class OperationScan { @Override public synchronized void onCompleted() { // if only one sequence value existed, we send it without any accumulation - if (!hasSentInitialValue) { + if (!hasSentInitialValue) observer.onNext(acc); - } observer.onCompleted(); } })); diff --git a/HMCLAPI/src/main/java/rx/operators/OperationSkip.java b/HMCLAPI/src/main/java/rx/operators/OperationSkip.java index 36c3b3f3c..45e371b83 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationSkip.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationSkip.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,17 +23,20 @@ import rx.Subscription; import rx.util.functions.Func1; /** - * Skips a specified number of contiguous values from the start of a Observable sequence and then returns the remaining values. + * Skips a specified number of contiguous values from the start of a Observable + * sequence and then returns the remaining values. */ public final class OperationSkip { /** - * Skips a specified number of contiguous values from the start of a Observable sequence and then returns the remaining values. - * + * Skips a specified number of contiguous values from the start of a + * Observable sequence and then returns the remaining values. + * * @param items * @param num + * * @return - * + * * @see http://msdn.microsoft.com/en-us/library/hh229847(v=vs.103).aspx */ public static Func1, Subscription> skip(final Observable items, final int num) { @@ -42,13 +45,17 @@ public final class OperationSkip { } /** - * This class is NOT thread-safe if invoked and referenced multiple times. In other words, don't subscribe to it multiple times from different threads. + * This class is NOT thread-safe if invoked and referenced multiple times. + * In other words, don't subscribe to it multiple times from different + * threads. *

- * It IS thread-safe from within it while receiving onNext events from multiple threads. - * + * It IS thread-safe from within it while receiving onNext events from + * multiple threads. + * * @param */ private static class Skip implements Func1, Subscription> { + private final int num; private final Observable items; @@ -63,7 +70,8 @@ public final class OperationSkip { } /** - * Used to subscribe to the 'items' Observable sequence and forward to the actualObserver up to 'num' count. + * Used to subscribe to the 'items' Observable sequence and forward to + * the actualObserver up to 'num' count. */ private class ItemObserver implements Observer { @@ -87,12 +95,11 @@ public final class OperationSkip { @Override public void onNext(T args) { // skip them until we reach the 'num' value - if (counter.incrementAndGet() > num) { + if (counter.incrementAndGet() > num) observer.onNext(args); - } } } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationSynchronize.java b/HMCLAPI/src/main/java/rx/operators/OperationSynchronize.java index a011ff011..ea3118873 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationSynchronize.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationSynchronize.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,29 +23,32 @@ import rx.util.SynchronizedObserver; import rx.util.functions.Func1; /** - * An observable that wraps an observable of the same type and then enforces the semantics - * expected of a well-behaved observable. + * An observable that wraps an observable of the same type and then enforces the + * semantics expected of a well-behaved observable. *

- * An observable that ensures onNext, onCompleted, or onError calls on its subscribers are - * not interleaved, onCompleted and onError are only called once respectively, and no - * onNext calls follow onCompleted and onError calls. + * An observable that ensures onNext, onCompleted, or onError calls on its + * subscribers are not interleaved, onCompleted and onError are only called once + * respectively, and no onNext calls follow onCompleted and onError calls. *

- * NOTE: {@link Observable#create} already wraps Observables so this is generally redundant. - * - * @param - * The type of the observable sequence. + * NOTE: {@link Observable#create} already wraps Observables so this is + * generally redundant. + * + * @param The type of the observable sequence. */ public final class OperationSynchronize { /** - * Accepts an observable and wraps it in another observable which ensures that the resulting observable is well-behaved. - * - * A well-behaved observable ensures onNext, onCompleted, or onError calls to its subscribers are - * not interleaved, onCompleted and onError are only called once respectively, and no - * onNext calls follow onCompleted and onError calls. - * + * Accepts an observable and wraps it in another observable which ensures + * that the resulting observable is well-behaved. + * + * A well-behaved observable ensures onNext, onCompleted, or onError calls + * to its subscribers are not interleaved, onCompleted and onError are only + * called once respectively, and no onNext calls follow onCompleted and + * onError calls. + * * @param observable * @param + * * @return */ public static Func1, Subscription> synchronize(Observable observable) { @@ -69,4 +72,4 @@ public final class OperationSynchronize { } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationTake.java b/HMCLAPI/src/main/java/rx/operators/OperationTake.java index 4cd79a425..4ebc51a17 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationTake.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationTake.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,15 +25,18 @@ import rx.util.AtomicObservableSubscription; import rx.util.functions.Func1; /** - * Returns a specified number of contiguous values from the start of an observable sequence. + * Returns a specified number of contiguous values from the start of an + * observable sequence. */ public final class OperationTake { /** - * Returns a specified number of contiguous values from the start of an observable sequence. - * + * Returns a specified number of contiguous values from the start of an + * observable sequence. + * * @param items * @param num + * * @return */ public static Func1, Subscription> take(final Observable items, final int num) { @@ -42,17 +45,24 @@ public final class OperationTake { } /** - * This class is NOT thread-safe if invoked and referenced multiple times. In other words, don't subscribe to it multiple times from different threads. + * This class is NOT thread-safe if invoked and referenced multiple times. + * In other words, don't subscribe to it multiple times from different + * threads. *

- * It IS thread-safe from within it while receiving onNext events from multiple threads. + * It IS thread-safe from within it while receiving onNext events from + * multiple threads. *

- * This should all be fine as long as it's kept as a private class and a new instance created from static factory method above. + * This should all be fine as long as it's kept as a private class and a new + * instance created from static factory method above. *

- * Note how the take() factory method above protects us from a single instance being exposed with the Observable wrapper handling the subscribe flow. - * + * Note how the take() factory method above protects us from a single + * instance being exposed with the Observable wrapper handling the subscribe + * flow. + * * @param */ private static class Take implements Func1, Subscription> { + private final AtomicInteger counter = new AtomicInteger(); private final Observable items; private final int num; @@ -66,21 +76,17 @@ public final class OperationTake { @Override public Subscription call(Observer observer) { if (num < 1) { - items.subscribe(new Observer() - { + items.subscribe(new Observer() { @Override - public void onCompleted() - { + public void onCompleted() { } @Override - public void onError(Exception e) - { + public void onError(Exception e) { } @Override - public void onNext(T args) - { + public void onNext(T args) { } }).unsubscribe(); observer.onCompleted(); @@ -91,6 +97,7 @@ public final class OperationTake { } private class ItemObserver implements Observer { + private final Observer observer; public ItemObserver(Observer observer) { @@ -99,16 +106,14 @@ public final class OperationTake { @Override public void onCompleted() { - if (counter.getAndSet(num) < num) { + if (counter.getAndSet(num) < num) observer.onCompleted(); - } } @Override public void onError(Exception e) { - if (counter.getAndSet(num) < num) { + if (counter.getAndSet(num) < num) observer.onError(e); - } } @Override @@ -116,14 +121,12 @@ public final class OperationTake { final int count = counter.incrementAndGet(); if (count <= num) { observer.onNext(args); - if (count == num) { + if (count == num) observer.onCompleted(); - } } - if (count >= num) { + if (count >= num) // this will work if the sequence is asynchronous, it will have no effect on a synchronous observable subscription.unsubscribe(); - } } } diff --git a/HMCLAPI/src/main/java/rx/operators/OperationTakeLast.java b/HMCLAPI/src/main/java/rx/operators/OperationTakeLast.java index 697a526c4..52164046e 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationTakeLast.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationTakeLast.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,8 @@ import rx.util.AtomicObservableSubscription; import rx.util.functions.Func1; /** - * Returns a specified number of contiguous elements from the end of an observable sequence. + * Returns a specified number of contiguous elements from the end of an + * observable sequence. */ public final class OperationTakeLast { @@ -34,6 +35,7 @@ public final class OperationTakeLast { } private static class TakeLast implements Func1, Subscription> { + private final int count; private final Observable items; private final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); @@ -60,9 +62,8 @@ public final class OperationTakeLast { @Override public void onCompleted() { Iterator reverse = deque.descendingIterator(); - while (reverse.hasNext()) { + while (reverse.hasNext()) observer.onNext(reverse.next()); - } observer.onCompleted(); } @@ -73,9 +74,8 @@ public final class OperationTakeLast { @Override public void onNext(T args) { - while (!deque.offerFirst(args)) { + while (!deque.offerFirst(args)) deque.removeLast(); - } } } diff --git a/HMCLAPI/src/main/java/rx/operators/OperationTakeWhile.java b/HMCLAPI/src/main/java/rx/operators/OperationTakeWhile.java index dbb68a56f..801cedba6 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationTakeWhile.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationTakeWhile.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,28 +26,33 @@ import rx.util.functions.Func1; import rx.util.functions.Func2; /** - * Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values. + * Returns values from an observable sequence as long as a specified condition + * is true, and then skips the remaining values. */ public final class OperationTakeWhile { /** - * Returns a specified number of contiguous values from the start of an observable sequence. - * + * Returns a specified number of contiguous values from the start of an + * observable sequence. + * * @param items - * @param predicate - * a function to test each source element for a condition + * @param predicate a function to test each source element for a condition + * * @return */ public static Func1, Subscription> takeWhile(final Observable items, final Func1 predicate) { - return takeWhileWithIndex(items, OperationTakeWhile. skipIndex(predicate)); + return takeWhileWithIndex(items, OperationTakeWhile.skipIndex(predicate)); } /** - * Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values. - * + * Returns values from an observable sequence as long as a specified + * condition is true, and then skips the remaining values. + * * @param items - * @param predicate - * a function to test each element for a condition; the second parameter of the function represents the index of the source element; otherwise, false. + * @param predicate a function to test each element for a condition; the + * second parameter of the function represents the index of the source + * element; otherwise, false. + * * @return */ public static Func1, Subscription> takeWhileWithIndex(final Observable items, final Func2 predicate) { @@ -60,17 +65,24 @@ public final class OperationTakeWhile { } /** - * This class is NOT thread-safe if invoked and referenced multiple times. In other words, don't subscribe to it multiple times from different threads. + * This class is NOT thread-safe if invoked and referenced multiple times. + * In other words, don't subscribe to it multiple times from different + * threads. *

- * It IS thread-safe from within it while receiving onNext events from multiple threads. + * It IS thread-safe from within it while receiving onNext events from + * multiple threads. *

- * This should all be fine as long as it's kept as a private class and a new instance created from static factory method above. + * This should all be fine as long as it's kept as a private class and a new + * instance created from static factory method above. *

- * Note how the takeWhileWithIndex() factory method above protects us from a single instance being exposed with the Observable wrapper handling the subscribe flow. - * + * Note how the takeWhileWithIndex() factory method above protects us from a + * single instance being exposed with the Observable wrapper handling the + * subscribe flow. + * * @param */ private static class TakeWhile implements Func1, Subscription> { + private final AtomicInteger counter = new AtomicInteger(); private final Observable items; private final Func2 predicate; @@ -87,6 +99,7 @@ public final class OperationTakeWhile { } private class ItemObserver implements Observer { + private final Observer observer; public ItemObserver(Observer observer) { @@ -115,9 +128,9 @@ public final class OperationTakeWhile { observer.onError(e); return; } - if (isSelected) { + if (isSelected) observer.onNext(args); - } else { + else { observer.onCompleted(); // this will work if the sequence is asynchronous, it will have no effect on a synchronous observable subscription.unsubscribe(); diff --git a/HMCLAPI/src/main/java/rx/operators/OperationToObservableFuture.java b/HMCLAPI/src/main/java/rx/operators/OperationToObservableFuture.java index 9ba541db7..bb2a4402c 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationToObservableFuture.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationToObservableFuture.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,9 @@ import rx.subscriptions.Subscriptions; import rx.util.functions.Func1; public class OperationToObservableFuture { + private static class ToObservableFuture implements Func1, Subscription> { + private final Future that; private final Long time; private final TimeUnit unit; @@ -46,9 +48,8 @@ public class OperationToObservableFuture { try { T value = (time == null) ? that.get() : that.get(time, unit); - if (!that.isCancelled()) { + if (!that.isCancelled()) observer.onNext(value); - } observer.onCompleted(); } catch (Exception e) { observer.onError(e); diff --git a/HMCLAPI/src/main/java/rx/operators/OperationToObservableIterable.java b/HMCLAPI/src/main/java/rx/operators/OperationToObservableIterable.java index 20d30eb2c..aa5df40b9 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationToObservableIterable.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationToObservableIterable.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,9 +22,8 @@ import rx.util.functions.Func1; /** * Accepts an Iterable object and exposes it as an Observable. - * - * @param - * The type of the Iterable sequence. + * + * @param The type of the Iterable sequence. */ public final class OperationToObservableIterable { @@ -37,4 +36,4 @@ public final class OperationToObservableIterable { return Subscriptions.empty(); }; } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationToObservableList.java b/HMCLAPI/src/main/java/rx/operators/OperationToObservableList.java index 3bf8811bb..bdc3ca1c6 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationToObservableList.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationToObservableList.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,11 +38,12 @@ public final class OperationToObservableList { this.that = that; } - @Override + @Override public Subscription call(final Observer> observer) { return that.subscribe(new Observer() { final ConcurrentLinkedQueue list = new ConcurrentLinkedQueue<>(); + @Override public void onNext(T value) { // onNext can be concurrently executed so list must be thread-safe @@ -75,4 +76,4 @@ public final class OperationToObservableList { }); } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationToObservableSortedList.java b/HMCLAPI/src/main/java/rx/operators/OperationToObservableSortedList.java index d5a74bd6d..14748e231 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationToObservableSortedList.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationToObservableSortedList.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,18 +27,19 @@ import rx.util.functions.Func1; import rx.util.functions.Func2; /** - * Similar to toList in that it converts a sequence into a List except that it accepts a Function that will provide an implementation of Comparator. - * + * Similar to toList in that it converts a sequence into a List except + * that it accepts a Function that will provide an implementation of Comparator. + * * @param */ public final class OperationToObservableSortedList { /** * Sort T objects by their natural order (object must implement Comparable). - * + * * @param sequence - * @throws ClassCastException - * if T objects do not implement Comparable + * + * @throws ClassCastException if T objects do not implement Comparable * @return */ public static Func1>, Subscription> toSortedList(Observable sequence) { @@ -47,9 +48,10 @@ public final class OperationToObservableSortedList { /** * Sort T objects using the defined sort function. - * + * * @param sequence * @param sortFunction + * * @return */ public static Func1>, Subscription> toSortedList(Observable sequence, Func2 sortFunction) { @@ -92,9 +94,8 @@ public final class OperationToObservableSortedList { try { // copy from LinkedQueue to List since ConcurrentLinkedQueue does not implement the List interface ArrayList l = new ArrayList<>(list.size()); - for (T t : list) { + for (T t : list) l.add(t); - } // sort the list before delivery Collections.sort(l, (T o1, T o2) -> sortFunction.call(o1, o2)); @@ -127,4 +128,4 @@ public final class OperationToObservableSortedList { } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationZip.java b/HMCLAPI/src/main/java/rx/operators/OperationZip.java index 15f43523e..861217305 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperationZip.java +++ b/HMCLAPI/src/main/java/rx/operators/OperationZip.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -61,6 +61,7 @@ public final class OperationZip { * ThreadSafe */ private static class ZipObserver implements Observer { + final Observable w; final Aggregator a; private final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); @@ -72,10 +73,9 @@ public final class OperationZip { } public void startWatching() { - if (subscribed.compareAndSet(false, true)) { + if (subscribed.compareAndSet(false, true)) // only subscribe once even if called more than once subscription.wrap(w.subscribe(this)); - } } @Override @@ -99,10 +99,12 @@ public final class OperationZip { } /** - * Receive notifications from each of the Observables we are reducing and execute the zipFunction whenever we have received events from all Observables. - * + * Receive notifications from each of the Observables we are reducing and + * execute the zipFunction whenever we have received events from all + * Observables. + * * This class is thread-safe. - * + * * @param */ private static class Aggregator implements Func1, Subscription> { @@ -113,9 +115,17 @@ public final class OperationZip { private final AtomicBoolean running = new AtomicBoolean(true); private final ConcurrentHashMap, Boolean> completed = new ConcurrentHashMap<>(); - /* we use ConcurrentHashMap despite synchronization of methods because stop() does NOT use synchronization and this map is used by it and can be called by other threads */ + /* + * we use ConcurrentHashMap despite synchronization of methods because + * stop() does NOT use synchronization and this map is used by it and + * can be called by other threads + */ private final ConcurrentHashMap, ConcurrentLinkedQueue> receivedValuesPerObserver = new ConcurrentHashMap<>(); - /* we use a ConcurrentLinkedQueue to retain ordering (I'd like to just use a ConcurrentLinkedHashMap for 'receivedValuesPerObserver' but that doesn't exist in standard java */ + /* + * we use a ConcurrentLinkedQueue to retain ordering (I'd like to just + * use a ConcurrentLinkedHashMap for 'receivedValuesPerObserver' but + * that doesn't exist in standard java + */ private final ConcurrentLinkedQueue> observers = new ConcurrentLinkedQueue<>(); public Aggregator(FuncN zipFunction) { @@ -123,10 +133,13 @@ public final class OperationZip { } /** - * Receive notification of a Observer starting (meaning we should require it for aggregation) + * Receive notification of a Observer starting (meaning we should + * require it for aggregation) + * + * Thread Safety => Invoke ONLY from the static factory methods at top + * of this class which are always an atomic execution by a single + * thread. * - * Thread Safety => Invoke ONLY from the static factory methods at top of this class which are always an atomic execution by a single thread. - * * @param w */ private void addObserver(ZipObserver w) { @@ -137,32 +150,33 @@ public final class OperationZip { /** * Receive notification of a Observer completing its iterations. - * + * * @param w */ void complete(ZipObserver w) { // store that this ZipObserver is completed completed.put(w, Boolean.TRUE); // if all ZipObservers are completed, we mark the whole thing as completed - if (completed.size() == observers.size()) { - if (running.compareAndSet(true, false)) { + if (completed.size() == observers.size()) + if (running.compareAndSet(true, false)) // this thread succeeded in setting running=false so let's propagate the completion // mark ourselves as done observer.onCompleted(); - } - } } /** - * Receive error for a Observer. Throw the error up the chain and stop processing. - * + * Receive error for a Observer. Throw the error up the chain and stop + * processing. + * * @param w */ void error(ZipObserver w, Exception e) { if (running.compareAndSet(true, false)) { // this thread succeeded in setting running=false so let's propagate the error observer.onError(e); - /* since we receive an error we want to tell everyone to stop */ + /* + * since we receive an error we want to tell everyone to stop + */ stop(); } } @@ -170,20 +184,23 @@ public final class OperationZip { /** * Receive the next value from a Observer. *

- * If we have received values from all Observers, trigger the zip function, otherwise store the value and keep waiting. - * + * If we have received values from all Observers, trigger the zip + * function, otherwise store the value and keep waiting. + * * @param w * @param arg */ void next(ZipObserver w, Object arg) { - if (observer == null) { + if (observer == null) throw new RuntimeException("This shouldn't be running if a Observer isn't registered"); - } - /* if we've been 'unsubscribed' don't process anything further even if the things we're watching keep sending (likely because they are not responding to the unsubscribe call) */ - if (!running.get()) { + /* + * if we've been 'unsubscribed' don't process anything further even + * if the things we're watching keep sending (likely because they + * are not responding to the unsubscribe call) + */ + if (!running.get()) return; - } // store the value we received and below we'll decide if we are to send it to the Observer receivedValuesPerObserver.get(w).add(arg); @@ -191,20 +208,21 @@ public final class OperationZip { // define here so the variable is out of the synchronized scope Object[] argsToZip = new Object[observers.size()]; - /* we have to synchronize here despite using concurrent data structures because the compound logic here must all be done atomically */ + /* + * we have to synchronize here despite using concurrent data + * structures because the compound logic here must all be done + * atomically + */ synchronized (this) { // if all ZipObservers in 'receivedValues' map have a value, invoke the zipFunction - for (ZipObserver rw : receivedValuesPerObserver.keySet()) { - if (receivedValuesPerObserver.get(rw).peek() == null) { + for (ZipObserver rw : receivedValuesPerObserver.keySet()) + if (receivedValuesPerObserver.get(rw).peek() == null) // we have a null meaning the queues aren't all populated so won't do anything return; - } - } // if we get to here this means all the queues have data int i = 0; - for (ZipObserver rw : observers) { + for (ZipObserver rw : observers) argsToZip[i++] = receivedValuesPerObserver.get(rw).remove(); - } } // if we did not return above from the synchronized block we can now invoke the zipFunction with all of the args // we do this outside the synchronized block as it is now safe to call this concurrently and don't need to block other threads from calling @@ -217,41 +235,48 @@ public final class OperationZip { if (started.compareAndSet(false, true)) { AtomicObservableSubscription subscription = new AtomicObservableSubscription(); this.observer = new SynchronizedObserver<>(observer, subscription); - /* start the Observers */ - for (ZipObserver rw : observers) { + /* + * start the Observers + */ + for (ZipObserver rw : observers) rw.startWatching(); - } return subscription.wrap(this::stop); - } else { - /* a Observer already has subscribed so blow up */ + } else + /* + * a Observer already has subscribed so blow up + */ throw new IllegalStateException("Only one Observer can subscribe to this Observable."); - } } /* - * Do NOT synchronize this because it gets called via unsubscribe which can occur on other threads + * Do NOT synchronize this because it gets called via unsubscribe which + * can occur on other threads * and result in deadlocks. (http://jira/browse/API-4060) - * - * AtomicObservableSubscription uses compareAndSet instead of locking to avoid deadlocks but ensure single-execution. - * + * + * AtomicObservableSubscription uses compareAndSet instead of locking to + * avoid deadlocks but ensure single-execution. + * * We do the same in the implementation of this method. - * + * * ThreadSafety of this method is provided by: * - AtomicBoolean[running].compareAndSet * - ConcurrentLinkedQueue[Observers] * - ZipObserver.subscription being an AtomicObservableSubscription */ private void stop() { - /* tell ourselves to stop processing onNext events by setting running=false */ - if (running.compareAndSet(true, false)) { - /* propogate to all Observers to unsubscribe if this thread succeeded in setting running=false */ - for (ZipObserver o : observers) { - if (o.subscription != null) { + /* + * tell ourselves to stop processing onNext events by setting + * running=false + */ + if (running.compareAndSet(true, false)) + /* + * propogate to all Observers to unsubscribe if this thread + * succeeded in setting running=false + */ + for (ZipObserver o : observers) + if (o.subscription != null) o.subscription.unsubscribe(); - } - } - } } } diff --git a/HMCLAPI/src/main/java/rx/operators/OperatorGroupBy.java b/HMCLAPI/src/main/java/rx/operators/OperatorGroupBy.java index 6bfe50480..09b3b464b 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperatorGroupBy.java +++ b/HMCLAPI/src/main/java/rx/operators/OperatorGroupBy.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,10 +42,11 @@ public final class OperatorGroupBy { } public static Func1>, Subscription> groupBy(Observable source, final Func1 keySelector) { - return groupBy(source, keySelector, Functions. identity()); + return groupBy(source, keySelector, Functions.identity()); } private static class GroupBy implements Func1>, Subscription> { + private final Observable> source; private final ConcurrentHashMap keys = new ConcurrentHashMap(); @@ -72,9 +73,8 @@ public final class OperatorGroupBy { public void onNext(final KeyValue args) { K key = args.key; boolean newGroup = keys.putIfAbsent(key, true) == null; - if (newGroup) { + if (newGroup) observer.onNext(buildObservableFor(source, key)); - } } }); @@ -95,15 +95,16 @@ public final class OperatorGroupBy { }); return new GroupedObservable(key, new Func1, Subscription>() { - @Override - public Subscription call(Observer observer) { - return observable.subscribe(observer); - } + @Override + public Subscription call(Observer observer) { + return observable.subscribe(observer); + } - }); + }); } private static class KeyValue { + private final K key; private final V value; diff --git a/HMCLAPI/src/main/java/rx/operators/OperatorTakeUntil.java b/HMCLAPI/src/main/java/rx/operators/OperatorTakeUntil.java index ca954aef5..128419dff 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperatorTakeUntil.java +++ b/HMCLAPI/src/main/java/rx/operators/OperatorTakeUntil.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,17 +23,18 @@ import rx.util.functions.Func1; public class OperatorTakeUntil { /** - * Returns the values from the source observable sequence until the other observable sequence produces a value. - * - * @param source - * the source sequence to propagate elements for. - * @param other - * the observable sequence that terminates propagation of elements of the source sequence. - * @param - * the type of source. - * @param - * the other type. - * @return An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation. + * Returns the values from the source observable sequence until the other + * observable sequence produces a value. + * + * @param source the source sequence to propagate elements for. + * @param other the observable sequence that terminates propagation of + * elements of the source sequence. + * @param the type of source. + * @param the other type. + * + * @return An observable sequence containing the elements of the source + * sequence up to the point the other sequence interrupted further + * propagation. */ public static Observable takeUntil(final Observable source, final Observable other) { Observable> s = Observable.create(new SourceObservable(source)); @@ -41,9 +42,9 @@ public class OperatorTakeUntil { @SuppressWarnings("unchecked") /** - * In JDK 7 we could use 'varargs' instead of 'unchecked'. - * See http://stackoverflow.com/questions/1445233/is-it-possible-to-solve-the-a-generic-array-of-t-is-created-for-a-varargs-param - * and http://hg.openjdk.java.net/jdk7/tl/langtools/rev/46cf751559ae + * In JDK 7 we could use 'varargs' instead of 'unchecked'. See + * http://stackoverflow.com/questions/1445233/is-it-possible-to-solve-the-a-generic-array-of-t-is-created-for-a-varargs-param + * and http://hg.openjdk.java.net/jdk7/tl/langtools/rev/46cf751559ae */ Observable> result = Observable.merge(s, o); @@ -61,6 +62,7 @@ public class OperatorTakeUntil { } private static class Notification { + private final boolean halt; private final T value; @@ -80,6 +82,7 @@ public class OperatorTakeUntil { } private static class SourceObservable implements Func1>, Subscription> { + private final Observable sequence; private SourceObservable(Observable sequence) { @@ -91,7 +94,7 @@ public class OperatorTakeUntil { return sequence.subscribe(new Observer() { @Override public void onCompleted() { - notificationObserver.onNext(Notification. halt()); + notificationObserver.onNext(Notification.halt()); } @Override @@ -108,6 +111,7 @@ public class OperatorTakeUntil { } private static class OtherObservable implements Func1>, Subscription> { + private final Observable sequence; private OtherObservable(Observable sequence) { @@ -129,7 +133,7 @@ public class OperatorTakeUntil { @Override public void onNext(E args) { - notificationObserver.onNext(Notification. halt()); + notificationObserver.onNext(Notification.halt()); } }); } diff --git a/HMCLAPI/src/main/java/rx/operators/OperatorToIterator.java b/HMCLAPI/src/main/java/rx/operators/OperatorToIterator.java index 53b0b8156..61d63f0b7 100755 --- a/HMCLAPI/src/main/java/rx/operators/OperatorToIterator.java +++ b/HMCLAPI/src/main/java/rx/operators/OperatorToIterator.java @@ -16,12 +16,12 @@ public class OperatorToIterator { /** * Returns an iterator that iterates all values of the observable. - * - * @param that - * an observable sequence to get an iterator for. - * @param - * the type of source. - * @return the iterator that could be used to iterate over the elements of the observable. + * + * @param that an observable sequence to get an iterator for. + * @param the type of source. + * + * @return the iterator that could be used to iterate over the elements of + * the observable. */ public static Iterator toIterator(Observable that) { final BlockingQueue> notifications = new LinkedBlockingQueue>(); @@ -48,20 +48,17 @@ public class OperatorToIterator { @Override public boolean hasNext() { - if (buf == null) { + if (buf == null) buf = take(); - } return !buf.isOnCompleted(); } @Override public T next() { - if (buf == null) { + if (buf == null) buf = take(); - } - if (buf.isOnError()) { + if (buf.isOnError()) throw Exceptions.propagate(buf.getException()); - } T result = buf.getValue(); buf = null; diff --git a/HMCLAPI/src/main/java/rx/operators/ScheduledObserver.java b/HMCLAPI/src/main/java/rx/operators/ScheduledObserver.java index 5b9b35676..da43d0adc 100755 --- a/HMCLAPI/src/main/java/rx/operators/ScheduledObserver.java +++ b/HMCLAPI/src/main/java/rx/operators/ScheduledObserver.java @@ -19,7 +19,9 @@ import rx.Observer; import rx.Scheduler; import rx.util.functions.Action0; -/* package */ +/* + * package + */ class ScheduledObserver implements Observer { private final Observer underlying; diff --git a/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandler.java b/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandler.java index 042d59a8a..acbbcc605 100755 --- a/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandler.java +++ b/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandler.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,20 +19,24 @@ import rx.Observable; import rx.Observer; /** - * Abstract class for defining error handling logic in addition to the normal {@link Observer#onError(Exception)} behavior. + * Abstract class for defining error handling logic in addition to the normal + * {@link Observer#onError(Exception)} behavior. *

- * For example, all Exceptions can be logged using this handler even if {@link Observer#onError(Exception)} is ignored or not provided when an {@link Observable} is subscribed to. + * For example, all Exceptions can be logged using this handler even if + * {@link Observer#onError(Exception)} is ignored or not provided when an + * {@link Observable} is subscribed to. *

- * See {@link RxJavaPlugins} or the RxJava GitHub Wiki for information on configuring plugins: https://github.com/Netflix/RxJava/wiki/Plugins. */ public abstract class RxJavaErrorHandler { /** - * Receives all Exceptions from an {@link Observable} passed to {@link Observer#onError(Exception)}. - * - * @param e - * Exception + * Receives all Exceptions from an {@link Observable} passed to + * {@link Observer#onError(Exception)}. + * + * @param e Exception */ public void handleError(Exception e) { // do nothing by default diff --git a/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandlerDefault.java b/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandlerDefault.java index fd997e48c..ab9604123 100755 --- a/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandlerDefault.java +++ b/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandlerDefault.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ package rx.plugins; /** * Default implementation of {@link RxJavaErrorHandler} that does nothing. - * + * * @ExcludeFromJavadoc */ public class RxJavaErrorHandlerDefault extends RxJavaErrorHandler { diff --git a/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java b/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java index 6ded46ed5..55f111437 100755 --- a/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java +++ b/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,31 +21,43 @@ import rx.Subscription; import rx.util.functions.Func1; /** - * Abstract ExecutionHook with invocations at different lifecycle points of {@link Observable} execution with a default no-op implementation. + * Abstract ExecutionHook with invocations at different lifecycle points of + * {@link Observable} execution with a default no-op implementation. *

- * See {@link RxJavaPlugins} or the RxJava GitHub Wiki for information on configuring plugins: https://github.com/Netflix/RxJava/wiki/Plugins. *

* Note on thread-safety and performance *

- * A single implementation of this class will be used globally so methods on this class will be invoked concurrently from multiple threads so all functionality must be thread-safe. + * A single implementation of this class will be used globally so methods on + * this class will be invoked concurrently from multiple threads so all + * functionality must be thread-safe. *

- * Methods are also invoked synchronously and will add to execution time of the observable so all behavior should be fast. If anything time-consuming is to be done it should be spawned asynchronously - * onto separate worker threads. - * - * */ + * Methods are also invoked synchronously and will add to execution time of the + * observable so all behavior should be fast. If anything time-consuming is to + * be done it should be spawned asynchronously onto separate worker threads. + * + * + */ public abstract class RxJavaObservableExecutionHook { /** - * Invoked before {@link Observable#subscribe(rx.Observer)} is about to be executed. + * Invoked before {@link Observable#subscribe(rx.Observer)} is about to be + * executed. *

- * This can be used to decorate or replace the onSubscribe function or just perform extra logging, metrics and other such things and pass-thru the function. - * - * @param observableInstance - * The executing {@link Observable} instance. - * @param onSubscribe - * original {@link Func1}<{@link Observer}{@code}, {@link Subscription}> to be executed - * @return {@link Func1}<{@link Observer}{@code}, {@link Subscription}> function that can be modified, decorated, replaced or just returned as a pass-thru. + * This can be used to decorate or replace the onSubscribe + * function or just perform extra logging, metrics and other such things and + * pass-thru the function. + * + * @param observableInstance The executing {@link Observable} instance. + * @param onSubscribe original {@link Func1}<{@link + * Observer}{@code}, + * {@link Subscription}> to be executed + * + * @return {@link Func1}<{@link Observer}{@code}, {@link Subscription}> + * function that can be modified, decorated, replaced or just returned as a + * pass-thru. */ public Func1, Subscription> onSubscribeStart(Observable observableInstance, Func1, Subscription> onSubscribe) { // pass-thru by default @@ -53,15 +65,19 @@ public abstract class RxJavaObservableExecutionHook { } /** - * Invoked after successful execution of {@link Observable#subscribe(rx.Observer)} with returned {@link Subscription}. + * Invoked after successful execution of + * {@link Observable#subscribe(rx.Observer)} with returned + * {@link Subscription}. *

- * This can be used to decorate or replace the {@link Subscription} instance or just perform extra logging, metrics and other such things and pass-thru the subscription. - * - * @param observableInstance - * The executing {@link Observable} instance. - * @param subscription - * original {@link Subscription} - * @return {@link Subscription} subscription that can be modified, decorated, replaced or just returned as a pass-thru. + * This can be used to decorate or replace the {@link Subscription} instance + * or just perform extra logging, metrics and other such things and + * pass-thru the subscription. + * + * @param observableInstance The executing {@link Observable} instance. + * @param subscription original {@link Subscription} + * + * @return {@link Subscription} subscription that can be modified, + * decorated, replaced or just returned as a pass-thru. */ public Subscription onSubscribeReturn(Observable observableInstance, Subscription subscription) { // pass-thru by default @@ -69,16 +85,19 @@ public abstract class RxJavaObservableExecutionHook { } /** - * Invoked after failed execution of {@link Observable#subscribe(Observer)} with thrown Exception. + * Invoked after failed execution of {@link Observable#subscribe(Observer)} + * with thrown Exception. *

- * This is NOT errors emitted via {@link Observer#onError(Exception)} but exceptions thrown when attempting - * to subscribe to a {@link Func1}<{@link Observer}{@code}, {@link Subscription}>. - * - * @param observableInstance - * The executing {@link Observable} instance. - * @param e - * Exception thrown by {@link Observable#subscribe(Observer)} - * @return Exception that can be decorated, replaced or just returned as a pass-thru. + * This is NOT errors emitted via {@link Observer#onError(Exception)} but + * exceptions thrown when attempting to subscribe to a {@link Func1}<{@link + * Observer}{@code}, {@link Subscription}>. + * + * @param observableInstance The executing {@link Observable} instance. + * @param e Exception thrown by + * {@link Observable#subscribe(Observer)} + * + * @return Exception that can be decorated, replaced or just returned as a + * pass-thru. */ public Exception onSubscribeError(Observable observableInstance, Exception e) { // pass-thru by default diff --git a/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java b/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java index 7f17c5491..eeff228b4 100755 --- a/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java +++ b/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +18,10 @@ package rx.plugins; /** * Default no-op implementation of {@link RxJavaObservableExecutionHook} */ -/* package */class RxJavaObservableExecutionHookDefault extends RxJavaObservableExecutionHook { +/* + * package + */ +class RxJavaObservableExecutionHookDefault extends RxJavaObservableExecutionHook { private static RxJavaObservableExecutionHookDefault INSTANCE = new RxJavaObservableExecutionHookDefault(); diff --git a/HMCLAPI/src/main/java/rx/plugins/RxJavaPlugins.java b/HMCLAPI/src/main/java/rx/plugins/RxJavaPlugins.java index 69b08e6f5..a7d241f77 100755 --- a/HMCLAPI/src/main/java/rx/plugins/RxJavaPlugins.java +++ b/HMCLAPI/src/main/java/rx/plugins/RxJavaPlugins.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,15 +18,21 @@ package rx.plugins; import java.util.concurrent.atomic.AtomicReference; /** - * Registry for plugin implementations that allows global override and handles the retrieval of correct implementation based on order of precedence: + * Registry for plugin implementations that allows global override and handles + * the retrieval of correct implementation based on order of precedence: *

    - *
  1. plugin registered globally via register methods in this class
  2. - *
  3. plugin registered and retrieved using {@link java.lang.System#getProperty(String)} (see get methods for property names)
  4. + *
  5. plugin registered globally via register methods in this + * class
  6. + *
  7. plugin registered and retrieved using + * {@link java.lang.System#getProperty(String)} (see get methods for property + * names)
  8. *
  9. default implementation
  10. *
- * See the RxJava GitHub Wiki for more information: https://github.com/Netflix/RxJava/wiki/Plugins. + * See the RxJava GitHub Wiki for more information: + * https://github.com/Netflix/RxJava/wiki/Plugins. */ public class RxJavaPlugins { + private final static RxJavaPlugins INSTANCE = new RxJavaPlugins(); private final AtomicReference errorHandler = new AtomicReference(); @@ -41,79 +47,82 @@ public class RxJavaPlugins { } /** - * Retrieve instance of {@link RxJavaErrorHandler} to use based on order of precedence as defined in {@link RxJavaPlugins} class header. + * Retrieve instance of {@link RxJavaErrorHandler} to use based on order of + * precedence as defined in {@link RxJavaPlugins} class header. *

- * Override default by using {@link #registerErrorHandler(RxJavaErrorHandler)} or setting property: rxjava.plugin.RxJavaErrorHandler.implementation with the full classname to - * load. - * + * Override default by using + * {@link #registerErrorHandler(RxJavaErrorHandler)} or setting property: + * rxjava.plugin.RxJavaErrorHandler.implementation with the + * full classname to load. + * * @return {@link RxJavaErrorHandler} implementation to use */ public RxJavaErrorHandler getErrorHandler() { if (errorHandler.get() == null) { // check for an implementation from System.getProperty first Object impl = getPluginImplementationViaProperty(RxJavaErrorHandler.class); - if (impl == null) { - // nothing set via properties so initialize with default - errorHandler.compareAndSet(null, RxJavaErrorHandlerDefault.getInstance()); - // we don't return from here but call get() again in case of thread-race so the winner will always get returned - } else { + if (impl == null) + // nothing set via properties so initialize with default + errorHandler.compareAndSet(null, RxJavaErrorHandlerDefault.getInstance()); // we don't return from here but call get() again in case of thread-race so the winner will always get returned + else // we received an implementation from the system property so use it errorHandler.compareAndSet(null, (RxJavaErrorHandler) impl); - } } return errorHandler.get(); } /** - * Register a {@link RxJavaErrorHandler} implementation as a global override of any injected or default implementations. - * - * @param impl - * {@link RxJavaErrorHandler} implementation - * @throws IllegalStateException - * if called more than once or after the default was initialized (if usage occurs before trying to register) + * Register a {@link RxJavaErrorHandler} implementation as a global override + * of any injected or default implementations. + * + * @param impl {@link RxJavaErrorHandler} implementation + * + * @throws IllegalStateException if called more than once or after the + * default was initialized (if usage occurs before trying to register) */ public void registerErrorHandler(RxJavaErrorHandler impl) { - if (!errorHandler.compareAndSet(null, impl)) { + if (!errorHandler.compareAndSet(null, impl)) throw new IllegalStateException("Another strategy was already registered."); - } } /** - * Retrieve instance of {@link RxJavaObservableExecutionHook} to use based on order of precedence as defined in {@link RxJavaPlugins} class header. + * Retrieve instance of {@link RxJavaObservableExecutionHook} to use based + * on order of precedence as defined in {@link RxJavaPlugins} class header. *

- * Override default by using {@link #registerObservableExecutionHook(RxJavaObservableExecutionHook)} or setting property: rxjava.plugin.RxJavaObservableExecutionHook.implementation + * Override default by using + * {@link #registerObservableExecutionHook(RxJavaObservableExecutionHook)} + * or setting property: + * rxjava.plugin.RxJavaObservableExecutionHook.implementation * with the full classname to load. - * + * * @return {@link RxJavaObservableExecutionHook} implementation to use */ public RxJavaObservableExecutionHook getObservableExecutionHook() { if (observableExecutionHook.get() == null) { // check for an implementation from System.getProperty first Object impl = getPluginImplementationViaProperty(RxJavaObservableExecutionHook.class); - if (impl == null) { - // nothing set via properties so initialize with default - observableExecutionHook.compareAndSet(null, RxJavaObservableExecutionHookDefault.getInstance()); - // we don't return from here but call get() again in case of thread-race so the winner will always get returned - } else { + if (impl == null) + // nothing set via properties so initialize with default + observableExecutionHook.compareAndSet(null, RxJavaObservableExecutionHookDefault.getInstance()); // we don't return from here but call get() again in case of thread-race so the winner will always get returned + else // we received an implementation from the system property so use it observableExecutionHook.compareAndSet(null, (RxJavaObservableExecutionHook) impl); - } } return observableExecutionHook.get(); } /** - * Register a {@link RxJavaObservableExecutionHook} implementation as a global override of any injected or default implementations. - * - * @param impl - * {@link RxJavaObservableExecutionHook} implementation - * @throws IllegalStateException - * if called more than once or after the default was initialized (if usage occurs before trying to register) + * Register a {@link RxJavaObservableExecutionHook} implementation as a + * global override of any injected or default implementations. + * + * @param impl {@link RxJavaObservableExecutionHook} implementation + * + * @throws IllegalStateException if called more than once or after the + * default was initialized (if usage occurs before trying to register) */ public void registerObservableExecutionHook(RxJavaObservableExecutionHook impl) { - if (!observableExecutionHook.compareAndSet(null, impl)) { + if (!observableExecutionHook.compareAndSet(null, impl)) throw new IllegalStateException("Another strategy was already registered."); - } } private static Object getPluginImplementationViaProperty(Class pluginClass) { @@ -121,11 +130,12 @@ public class RxJavaPlugins { /* * Check system properties for plugin class. *

- * This will only happen during system startup thus it's okay to use the synchronized System.getProperties + * This will only happen during system startup thus it's okay to use the + * synchronized System.getProperties * as it will never get called in normal operations. */ String implementingClass = System.getProperty("rxjava.plugin." + classSimpleName + ".implementation"); - if (implementingClass != null) { + if (implementingClass != null) try { Class cls = Class.forName(implementingClass); // narrow the scope (cast) to the type we're expecting @@ -140,8 +150,7 @@ public class RxJavaPlugins { } catch (IllegalAccessException e) { throw new RuntimeException(classSimpleName + " implementation not able to be accessed: " + implementingClass, e); } - } else { + else return null; - } } } diff --git a/HMCLAPI/src/main/java/rx/subscriptions/BooleanSubscription.java b/HMCLAPI/src/main/java/rx/subscriptions/BooleanSubscription.java index 0ad92e1d0..3ae294967 100755 --- a/HMCLAPI/src/main/java/rx/subscriptions/BooleanSubscription.java +++ b/HMCLAPI/src/main/java/rx/subscriptions/BooleanSubscription.java @@ -6,9 +6,11 @@ import rx.Observable; import rx.Subscription; /** - * Subscription that can be checked for status such as in a loop inside an {@link Observable} to exit the loop if unsubscribed. - * - * @see Rx.Net equivalent BooleanDisposable at http://msdn.microsoft.com/en-us/library/system.reactive.disposables.booleandisposable(v=vs.103).aspx + * Subscription that can be checked for status such as in a loop inside an + * {@link Observable} to exit the loop if unsubscribed. + * + * @see Rx.Net equivalent BooleanDisposable at + * http://msdn.microsoft.com/en-us/library/system.reactive.disposables.booleandisposable(v=vs.103).aspx */ public class BooleanSubscription implements Subscription { diff --git a/HMCLAPI/src/main/java/rx/subscriptions/Subscriptions.java b/HMCLAPI/src/main/java/rx/subscriptions/Subscriptions.java index b5f9a7689..5e2b4bcd8 100755 --- a/HMCLAPI/src/main/java/rx/subscriptions/Subscriptions.java +++ b/HMCLAPI/src/main/java/rx/subscriptions/Subscriptions.java @@ -6,9 +6,10 @@ import rx.util.functions.FuncN; import rx.util.functions.Functions; public class Subscriptions { + /** * A {@link Subscription} that does nothing. - * + * * @return {@link Subscription} */ public static Subscription empty() { @@ -17,7 +18,7 @@ public class Subscriptions { /** * A {@link Subscription} implemented via a Func - * + * * @return {@link Subscription} */ public static Subscription create(final Action0 unsubscribe) { @@ -25,8 +26,9 @@ public class Subscriptions { } /** - * A {@link Subscription} implemented via an anonymous function (such as closures from other languages). - * + * A {@link Subscription} implemented via an anonymous function (such as + * closures from other languages). + * * @return {@link Subscription} */ public static Subscription create(final Object unsubscribe) { @@ -35,7 +37,9 @@ public class Subscriptions { } /** - * A {@link Subscription} that does nothing when its unsubscribe method is called. + * A {@link Subscription} that does nothing when its unsubscribe method is + * called. */ - private static final Subscription EMPTY = () -> { }; + private static final Subscription EMPTY = () -> { + }; } diff --git a/HMCLAPI/src/main/java/rx/util/AtomicObservableSubscription.java b/HMCLAPI/src/main/java/rx/util/AtomicObservableSubscription.java index cb2d37b10..cbadb8b7a 100755 --- a/HMCLAPI/src/main/java/rx/util/AtomicObservableSubscription.java +++ b/HMCLAPI/src/main/java/rx/util/AtomicObservableSubscription.java @@ -51,8 +51,9 @@ public final class AtomicObservableSubscription implements Subscription { * constructed) * * @param actualSubscription + * * @throws IllegalStateException if trying to set more than once (or use - * this method after setting via constructor) + * this method after setting via constructor) */ public AtomicObservableSubscription wrap(Subscription actualSubscription) { if (!this.actualSubscription.compareAndSet(null, actualSubscription)) diff --git a/HMCLAPI/src/main/java/rx/util/AtomicObserver.java b/HMCLAPI/src/main/java/rx/util/AtomicObserver.java index 24519dc27..9599230cd 100755 --- a/HMCLAPI/src/main/java/rx/util/AtomicObserver.java +++ b/HMCLAPI/src/main/java/rx/util/AtomicObserver.java @@ -9,33 +9,38 @@ import rx.plugins.RxJavaPlugins; /** * Wrapper around Observer to ensure compliance with Rx contract. *

- * The following is taken from the Rx Design Guidelines document: http://go.microsoft.com/fwlink/?LinkID=205219 + * The following is taken from the Rx Design Guidelines document: + * http://go.microsoft.com/fwlink/?LinkID=205219 *

  * Messages sent to instances of the IObserver interface follow the following grammar:
- * 
+ *
  * OnNext* (OnCompleted | OnError)?
- * 
+ *
  * This grammar allows observable sequences to send any amount (0 or more) of OnNext messages to the subscribed
  * observer instance, optionally followed by a single success (OnCompleted) or failure (OnError) message.
- * 
+ *
  * The single message indicating that an observable sequence has finished ensures that consumers of the observable
  * sequence can deterministically establish that it is safe to perform cleanup operations.
- * 
+ *
  * A single failure further ensures that abort semantics can be maintained for operators that work on
  * multiple observable sequences (see paragraph 6.6).
  * 
- * + * *

* This wrapper will do the following: *

    *
  • Allow only single execution of either onError or onCompleted.
  • - *
  • Once an onComplete or onError are performed, no further calls can be executed
  • - *
  • If unsubscribe is called, this means we call completed() and don't allow any further onNext calls.
  • - *
  • When onError or onComplete occur it will unsubscribe from the Observable (if executing asynchronously).
  • + *
  • Once an onComplete or onError are performed, no further calls can be + * executed
  • + *
  • If unsubscribe is called, this means we call completed() and don't allow + * any further onNext calls.
  • + *
  • When onError or onComplete occur it will unsubscribe from the Observable + * (if executing asynchronously).
  • *
*

- * It will not synchronize onNext execution. Use the {@link SynchronizedObserver} to do that. - * + * It will not synchronize onNext execution. Use the + * {@link SynchronizedObserver} to do that. + * * @param */ public class AtomicObserver implements Observer { @@ -85,9 +90,8 @@ public class AtomicObserver implements Observer { @Override public void onNext(T args) { try { - if (!isFinished.get()) { + if (!isFinished.get()) actual.onNext(args); - } } catch (Exception e) { // handle errors if the onNext implementation fails, not just if the Observable fails onError(e); diff --git a/HMCLAPI/src/main/java/rx/util/Exceptions.java b/HMCLAPI/src/main/java/rx/util/Exceptions.java index 6fb97f1d1..3dd8e85c6 100755 --- a/HMCLAPI/src/main/java/rx/util/Exceptions.java +++ b/HMCLAPI/src/main/java/rx/util/Exceptions.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,16 +16,16 @@ package rx.util; public class Exceptions { + private Exceptions() { } public static RuntimeException propagate(Throwable t) { - if (t instanceof RuntimeException) { + if (t instanceof RuntimeException) throw (RuntimeException) t; - } else { + else throw new RuntimeException(t); - } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/Range.java b/HMCLAPI/src/main/java/rx/util/Range.java index 5f7418b21..d53e54736 100755 --- a/HMCLAPI/src/main/java/rx/util/Range.java +++ b/HMCLAPI/src/main/java/rx/util/Range.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,6 +19,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; public final class Range implements Iterable { + private final int start; private final int end; private final int step; @@ -53,9 +54,8 @@ public final class Range implements Iterable { @Override public Integer next() { - if (!hasNext()) { + if (!hasNext()) throw new NoSuchElementException("No more elements"); - } int result = current; current += step; return result; @@ -72,4 +72,4 @@ public final class Range implements Iterable { public String toString() { return "Range (" + start + ", " + end + "), step " + step; } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/SynchronizedObserver.java b/HMCLAPI/src/main/java/rx/util/SynchronizedObserver.java index c75cac2a6..9e203a5df 100755 --- a/HMCLAPI/src/main/java/rx/util/SynchronizedObserver.java +++ b/HMCLAPI/src/main/java/rx/util/SynchronizedObserver.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,29 +22,36 @@ import rx.Observer; *

* Execution rules are: *

    - *
  • Allow only single-threaded, synchronous, ordered execution of onNext, onCompleted, onError
  • - *
  • Once an onComplete or onError are performed, no further calls can be executed
  • - *
  • If unsubscribe is called, this means we call completed() and don't allow any further onNext calls.
  • + *
  • Allow only single-threaded, synchronous, ordered execution of onNext, + * onCompleted, onError
  • + *
  • Once an onComplete or onError are performed, no further calls can be + * executed
  • + *
  • If unsubscribe is called, this means we call completed() and don't allow + * any further onNext calls.
  • *
- * + * * @param */ public final class SynchronizedObserver implements Observer { /** - * Intrinsic synchronized locking with double-check short-circuiting was chosen after testing several other implementations. - * - * The code and results can be found here: - * - https://github.com/benjchristensen/JavaLockPerformanceTests/tree/master/results/Observer - * - https://github.com/benjchristensen/JavaLockPerformanceTests/tree/master/src/com/benjchristensen/performance/locks/Observer - * - * The major characteristic that made me choose synchronized instead of Reentrant or a customer AbstractQueueSynchronizer implementation - * is that intrinsic locking performed better when nested, and AtomicObserver will end up nested most of the time since Rx is - * compositional by its very nature. - * - * // TODO composing of this class should rarely happen now with updated design so this decision should be revisited + * Intrinsic synchronized locking with double-check short-circuiting was + * chosen after testing several other implementations. + * + * The code and results can be found here: - + * https://github.com/benjchristensen/JavaLockPerformanceTests/tree/master/results/Observer + * - + * https://github.com/benjchristensen/JavaLockPerformanceTests/tree/master/src/com/benjchristensen/performance/locks/Observer + * + * The major characteristic that made me choose synchronized instead of + * Reentrant or a customer AbstractQueueSynchronizer implementation is that + * intrinsic locking performed better when nested, and AtomicObserver will + * end up nested most of the time since Rx is compositional by its very + * nature. + * + * // TODO composing of this class should rarely happen now with updated + * design so this decision should be revisited */ - private final Observer observer; private final AtomicObservableSubscription subscription; private volatile boolean finishRequested = false; @@ -57,32 +64,28 @@ public final class SynchronizedObserver implements Observer { @Override public void onNext(T arg) { - if (finished || finishRequested || subscription.isUnsubscribed()) { + if (finished || finishRequested || subscription.isUnsubscribed()) // if we're already stopped, or a finish request has been received, we won't allow further onNext requests return; - } synchronized (this) { // check again since this could have changed while waiting - if (finished || finishRequested || subscription.isUnsubscribed()) { + if (finished || finishRequested || subscription.isUnsubscribed()) // if we're already stopped, or a finish request has been received, we won't allow further onNext requests return; - } observer.onNext(arg); } } @Override public void onError(Exception e) { - if (finished || subscription.isUnsubscribed()) { + if (finished || subscription.isUnsubscribed()) // another thread has already finished us, so we won't proceed return; - } finishRequested = true; synchronized (this) { // check again since this could have changed while waiting - if (finished || subscription.isUnsubscribed()) { + if (finished || subscription.isUnsubscribed()) return; - } observer.onError(e); finished = true; } @@ -90,19 +93,17 @@ public final class SynchronizedObserver implements Observer { @Override public void onCompleted() { - if (finished || subscription.isUnsubscribed()) { + if (finished || subscription.isUnsubscribed()) // another thread has already finished us, so we won't proceed return; - } finishRequested = true; synchronized (this) { // check again since this could have changed while waiting - if (finished || subscription.isUnsubscribed()) { + if (finished || subscription.isUnsubscribed()) return; - } observer.onCompleted(); finished = true; } } -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Action0.java b/HMCLAPI/src/main/java/rx/util/functions/Action0.java index 62d57bd56..a20f1533f 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Action0.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Action0.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Action0 extends Function { + public void call(); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Action1.java b/HMCLAPI/src/main/java/rx/util/functions/Action1.java index 14fa7ced8..8991be796 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Action1.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Action1.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Action1 extends Function { + public void call(T1 t1); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Action2.java b/HMCLAPI/src/main/java/rx/util/functions/Action2.java index 8a17875a9..c12af11e7 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Action2.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Action2.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Action2 extends Function { + public void call(T1 t1, T2 t2); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Action3.java b/HMCLAPI/src/main/java/rx/util/functions/Action3.java index 2b613b621..6ccf1b44a 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Action3.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Action3.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Action3 extends Function { + public void call(T1 t1, T2 t2, T3 t3); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Func0.java b/HMCLAPI/src/main/java/rx/util/functions/Func0.java index 4e7d39703..1c1fd3349 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Func0.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Func0.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Func0 extends Function { + public R call(); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Func1.java b/HMCLAPI/src/main/java/rx/util/functions/Func1.java index 3eb17e625..51bc08e68 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Func1.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Func1.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Func1 extends Function { + public R call(T1 t1); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Func2.java b/HMCLAPI/src/main/java/rx/util/functions/Func2.java index ab2a04442..7e60998d3 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Func2.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Func2.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Func2 extends Function { + public R call(T1 t1, T2 t2); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Func3.java b/HMCLAPI/src/main/java/rx/util/functions/Func3.java index fc1dfb49b..b7ba5a1af 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Func3.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Func3.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Func3 extends Function { + public R call(T1 t1, T2 t2, T3 t3); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Func4.java b/HMCLAPI/src/main/java/rx/util/functions/Func4.java index 09d738ff7..1010ad6a7 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Func4.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Func4.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Func4 extends Function { + public R call(T1 t1, T2 t2, T3 t3, T4 t4); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Func5.java b/HMCLAPI/src/main/java/rx/util/functions/Func5.java index b6550ef0b..f040934cb 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Func5.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Func5.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Func5 extends Function { + public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Func6.java b/HMCLAPI/src/main/java/rx/util/functions/Func6.java index a241d5553..1a2ab8acf 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Func6.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Func6.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Func6 extends Function { + public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Func7.java b/HMCLAPI/src/main/java/rx/util/functions/Func7.java index 972cc405d..815ab596a 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Func7.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Func7.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Func7 extends Function { + public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Func8.java b/HMCLAPI/src/main/java/rx/util/functions/Func8.java index 5cbd10c1f..61be78829 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Func8.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Func8.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Func8 extends Function { + public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/Func9.java b/HMCLAPI/src/main/java/rx/util/functions/Func9.java index 8f2e546e4..ccad90114 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Func9.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Func9.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface Func9 extends Function { + public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/FuncN.java b/HMCLAPI/src/main/java/rx/util/functions/FuncN.java index 7b1b48763..20c66a6b7 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/FuncN.java +++ b/HMCLAPI/src/main/java/rx/util/functions/FuncN.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,5 +16,6 @@ package rx.util.functions; public interface FuncN extends Function { + public R call(Object... args); -} \ No newline at end of file +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/FunctionLanguageAdaptor.java b/HMCLAPI/src/main/java/rx/util/functions/FunctionLanguageAdaptor.java index 6ec87f358..4b12f30c1 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/FunctionLanguageAdaptor.java +++ b/HMCLAPI/src/main/java/rx/util/functions/FunctionLanguageAdaptor.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Netflix, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,9 +19,10 @@ public interface FunctionLanguageAdaptor { /** * Invoke the function and return the results. - * + * * @param function * @param args + * * @return Object results from function execution */ Object call(Object function, Object[] args); @@ -32,7 +33,7 @@ public interface FunctionLanguageAdaptor { * Example: groovy.lang.Closure *

* This should not return classes of java.* packages. - * + * * @return Class[] of classes that this adaptor should be invoked for. */ public Class[] getFunctionClass(); diff --git a/HMCLAPI/src/main/java/rx/util/functions/Functions.java b/HMCLAPI/src/main/java/rx/util/functions/Functions.java index 0e59503f2..9d4e54dec 100755 --- a/HMCLAPI/src/main/java/rx/util/functions/Functions.java +++ b/HMCLAPI/src/main/java/rx/util/functions/Functions.java @@ -1,17 +1,17 @@ /** * Copyright 2013 Netflix, Inc. *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at *

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. */ package rx.util.functions; @@ -74,16 +74,20 @@ public class Functions { * * @param function */ - @SuppressWarnings({"rawtypes"}) + @SuppressWarnings({ "rawtypes" }) public static FuncN from(final Object function) { if (function == null) throw new RuntimeException("function is null. Can't send arguments to null function."); - /* check for typed Rx Function implementation first */ + /* + * check for typed Rx Function implementation first + */ if (function instanceof Function) return fromFunction((Function) function); else - /* not an Rx Function so try language adaptors */ + /* + * not an Rx Function so try language adaptors + */ // check for language adaptor for (final Class c : languageAdaptors.keySet()) @@ -107,7 +111,7 @@ public class Functions { // // @SuppressWarnings("unchecked") // private static R executionRxFunction(Function function, Object... args) { - // // check Func* classes + // // check Func* classes // if (function instanceof Func0) { // Func0 f = (Func0) function; // if (args.length != 0) { @@ -203,9 +207,9 @@ public class Functions { // // throw new RuntimeException("Unknown implementation of Function: " + function.getClass().getSimpleName()); // } - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({ "unchecked", "rawtypes" }) private static FuncN fromFunction(Function function) { - // check Func* classes + // check Func* classes if (function instanceof Func0) return fromFunc((Func0) function); else if (function instanceof Func1) @@ -245,6 +249,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromFunc(final Func0 f) { @@ -260,6 +265,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromFunc(final Func1 f) { @@ -275,6 +281,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromFunc(final Func2 f) { @@ -290,6 +297,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromFunc(final Func3 f) { @@ -305,6 +313,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromFunc(final Func4 f) { @@ -320,6 +329,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromFunc(final Func5 f) { @@ -335,6 +345,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromFunc(final Func6 f) { @@ -350,6 +361,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromFunc(final Func7 f) { @@ -365,6 +377,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromFunc(final Func8 f) { @@ -380,6 +393,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromFunc(final Func9 f) { @@ -395,6 +409,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromAction(final Action0 f) { @@ -411,6 +426,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromAction(final Action1 f) { @@ -427,6 +443,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromAction(final Action2 f) { @@ -443,6 +460,7 @@ public class Functions { * with different arities. * * @param f + * * @return {@link FuncN} */ public static FuncN fromAction(final Action3 f) { diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginInfo.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginInfo.java index 582c5e1c6..742f4181f 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginInfo.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginInfo.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -26,7 +26,7 @@ import java.util.List; public class PluginInfo { public String website, dbo_page, description, slug, plugin_name, - link, stage, main; + link, stage, main; public List authors, categories; public List versions; } diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginManager.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginManager.java index 1bfcd5927..02cfbc2c0 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginManager.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginManager.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -52,32 +52,32 @@ public class PluginManager { String result = NetUtils.get("http://api.bukget.org/3//plugins?fields=slug,plugin_name,description,versions.version,versions.game_versions"); Gson gson = new Gson(); List list = gson.fromJson(result, new TypeToken>() { - }.getType()); + }.getType()); return list; } public static final String CATEGORY_ADMIN_TOOLS = "Admin Tools", - CATEGORY_DEVELOPER_TOOLS = "Developer Tools", - CATEGORY_FUN = "Fun", - CATEGORY_GENERAL = "General", - CATEGORY_ANTI_GRIEFING_TOOLS = "Anti Griefing Tools", - CATEGORY_MECHAICS = "Mechanics", - CATEGORY_FIXES = "Fixes", - CATEGORY_ROLE_PLAYING = "Role Playing", - CATEGORY_WORLD_EDITING_AND_MANAGEMENT = "World Editing and Management", - CATEGORY_TELEPORTATION = "Teleportation", - CATEGORY_INFORMATIONAL = "Informational", - CATEGORY_ECONOMY = "Economy", - CATEGORY_CHAT_RELATED = "Chat Related", - CATEGORY_MISCELLANEOUS = "Miscellaneous", - CATEGORY_WORLD_GENERATORS = "World Generators", - CATEGORY_WEBSITE_ADMINISTRATION = "Website Administration"; + CATEGORY_DEVELOPER_TOOLS = "Developer Tools", + CATEGORY_FUN = "Fun", + CATEGORY_GENERAL = "General", + CATEGORY_ANTI_GRIEFING_TOOLS = "Anti Griefing Tools", + CATEGORY_MECHAICS = "Mechanics", + CATEGORY_FIXES = "Fixes", + CATEGORY_ROLE_PLAYING = "Role Playing", + CATEGORY_WORLD_EDITING_AND_MANAGEMENT = "World Editing and Management", + CATEGORY_TELEPORTATION = "Teleportation", + CATEGORY_INFORMATIONAL = "Informational", + CATEGORY_ECONOMY = "Economy", + CATEGORY_CHAT_RELATED = "Chat Related", + CATEGORY_MISCELLANEOUS = "Miscellaneous", + CATEGORY_WORLD_GENERATORS = "World Generators", + CATEGORY_WEBSITE_ADMINISTRATION = "Website Administration"; public static List getPluginsByCategory(String category) throws Exception { String result = NetUtils.get("http://api.bukget.org/3//categories/" + category + "?fields=slug,plugin_name,description,versions.version,versions.game_versions"); Gson gson = new Gson(); List list = gson.fromJson(result, new TypeToken>() { - }.getType()); + }.getType()); return list; } @@ -85,7 +85,7 @@ public class PluginManager { String result = NetUtils.get("http://api.bukget.org/3//categories/"); Gson gson = new Gson(); List list = gson.fromJson(result, new TypeToken>() { - }.getType()); + }.getType()); return list; } diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeInstaller.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeInstaller.java index 41a8958c0..08e06a03d 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeInstaller.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeInstaller.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -136,7 +136,7 @@ public class ForgeInstaller { } public static void unpackLibrary(File output, byte[] data) - throws IOException { + throws IOException { if (output.exists()) output.delete(); diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/MinecraftVersion.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/MinecraftVersion.java index 884d16fd0..2cde2143f 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/MinecraftVersion.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/MinecraftVersion.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -26,7 +26,7 @@ import java.util.List; public class MinecraftVersion { public String minecraftArguments, mainClass, time, id, type, processArguments, - releaseTime, assets, jar, inheritsFrom; + releaseTime, assets, jar, inheritsFrom; public int minimumLauncherVersion; public List libraries; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/ScheduleTranslator.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/ScheduleTranslator.java index 49b14e86a..5a3386038 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/ScheduleTranslator.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/ScheduleTranslator.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -29,48 +29,48 @@ public class ScheduleTranslator { public static TimerTask translate(Server ser, Schedule s) { switch (s.type) { - case Schedule.TYPE_AUTO_SAVE: - return new AutoSaveSchedule(s, ser); - case Schedule.TYPE_AUTO_RESTART: - return new AutoRestartSchedule(s, ser); - case Schedule.TYPE_AUTO_BACKUP: - return new AutoBackupSchedule(s, ser); - case Schedule.TYPE_AUTO_BROADCAST: - return new AutoBroadcastSchedule(s, ser); - case Schedule.TYPE_AUTO_SEND_COMMAND: - return new AutoBroadcastSchedule(s, ser); + case Schedule.TYPE_AUTO_SAVE: + return new AutoSaveSchedule(s, ser); + case Schedule.TYPE_AUTO_RESTART: + return new AutoRestartSchedule(s, ser); + case Schedule.TYPE_AUTO_BACKUP: + return new AutoBackupSchedule(s, ser); + case Schedule.TYPE_AUTO_BROADCAST: + return new AutoBroadcastSchedule(s, ser); + case Schedule.TYPE_AUTO_SEND_COMMAND: + return new AutoBroadcastSchedule(s, ser); } return null; } public static String getName(Schedule s) { switch (s.type) { - case Schedule.TYPE_AUTO_SAVE: - return "自动保存"; - case Schedule.TYPE_AUTO_RESTART: - return "自动重启"; - case Schedule.TYPE_AUTO_BACKUP: - return "自动备份"; - case Schedule.TYPE_AUTO_BROADCAST: - return "自动广播"; - case Schedule.TYPE_AUTO_SEND_COMMAND: - return "自动发送命令"; + case Schedule.TYPE_AUTO_SAVE: + return "自动保存"; + case Schedule.TYPE_AUTO_RESTART: + return "自动重启"; + case Schedule.TYPE_AUTO_BACKUP: + return "自动备份"; + case Schedule.TYPE_AUTO_BROADCAST: + return "自动广播"; + case Schedule.TYPE_AUTO_SEND_COMMAND: + return "自动发送命令"; } return ""; } public static String getTimeTypeName(Schedule s) { switch (s.timeType) { - case Schedule.TIME_TYPE_PER: - return "每x分钟"; - case Schedule.TIME_TYPE_PAST_HOUR: - return "整点后x分钟"; - case Schedule.TIME_TYPE_SERVER_STARTED: - return "当服务器启动"; - case Schedule.TIME_TYPE_SERVER_STOPPED: - return "当服务器关闭"; - case Schedule.TIME_TYPE_SERVER_CRASHED: - return "当服务器崩溃"; + case Schedule.TIME_TYPE_PER: + return "每x分钟"; + case Schedule.TIME_TYPE_PAST_HOUR: + return "整点后x分钟"; + case Schedule.TIME_TYPE_SERVER_STARTED: + return "当服务器启动"; + case Schedule.TIME_TYPE_SERVER_STOPPED: + return "当服务器关闭"; + case Schedule.TIME_TYPE_SERVER_CRASHED: + return "当服务器崩溃"; } return ""; } diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Schedule.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Schedule.java index 9f48ed716..b9d9f6d5e 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Schedule.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Schedule.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -24,19 +24,19 @@ package org.jackhuang.hellominecraft.svrmgr.settings; public class Schedule { public static final int TYPE_AUTO_SAVE = 0, - TYPE_AUTO_RESTART = 1, - TYPE_AUTO_BACKUP = 2, - TYPE_AUTO_BROADCAST = 3, - TYPE_AUTO_SEND_COMMAND = 4, - TYPE_AUTO_EXECUTE = 5; + TYPE_AUTO_RESTART = 1, + TYPE_AUTO_BACKUP = 2, + TYPE_AUTO_BROADCAST = 3, + TYPE_AUTO_SEND_COMMAND = 4, + TYPE_AUTO_EXECUTE = 5; public static final int TYPE2_AUTO_BACKUP_PLUGINS = 1, - TYPE2_AUTH_BACKUP_CONFIG = 2, - TYPE3_AUTH_BACKUP_WORLD = 3; + TYPE2_AUTH_BACKUP_CONFIG = 2, + TYPE3_AUTH_BACKUP_WORLD = 3; public static final int TIME_TYPE_PER = 0, - TIME_TYPE_PAST_HOUR = 1, - TIME_TYPE_SERVER_STARTED = 2, - TIME_TYPE_SERVER_STOPPED = 3, - TIME_TYPE_SERVER_CRASHED = 4; + TIME_TYPE_PAST_HOUR = 1, + TIME_TYPE_SERVER_STARTED = 2, + TIME_TYPE_SERVER_STOPPED = 3, + TIME_TYPE_SERVER_CRASHED = 4; public int type, type2, timeType; public String content; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Settings.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Settings.java index bca3a07cf..5f90e766f 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Settings.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Settings.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -29,7 +29,7 @@ public class Settings { public String maxMemory; public String mainjar, bgPath, javaDir, javaArgs; public ArrayList inactiveExtMods, inactiveCoreMods, inactivePlugins, - inactiveWorlds; + inactiveWorlds; public ArrayList schedules; public Settings() { diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/InputDialog.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/InputDialog.java index 9c7abcee7..805180881 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/InputDialog.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/InputDialog.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -71,24 +71,24 @@ public class InputDialog extends javax.swing.JDialog { javax.swing.GroupLayout jPanelLayout = new javax.swing.GroupLayout(panel); panel.setLayout(jPanelLayout); jPanelLayout.setHorizontalGroup( - jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanelLayout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanelLayout.createSequentialGroup() - .addComponent(label) - .addGap(0, 0, Short.MAX_VALUE)) - .addComponent(textField)) - .addContainerGap()) + jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanelLayout.createSequentialGroup() + .addComponent(label) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(textField)) + .addContainerGap()) ); jPanelLayout.setVerticalGroup( - jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanelLayout.createSequentialGroup() - .addContainerGap() - .addComponent(label) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(label) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); textFields.add(textField); panels.add(panel); @@ -104,22 +104,22 @@ public class InputDialog extends javax.swing.JDialog { .addGap(0, 0, Short.MAX_VALUE) .addComponent(jButton1)); layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(g) - .addContainerGap()) + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(g) + .addContainerGap()) ); GroupLayout.SequentialGroup g2 = layout.createSequentialGroup() - .addContainerGap(); + .addContainerGap(); for (JPanel p : panels) g2 = g2.addComponent(p, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); g2 = g2.addComponent(jButton1) - .addContainerGap(); + .addContainerGap(); layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(g2) + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(g2) ); pack(); diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/MainWindow.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/MainWindow.java index 776bfafc6..ebe2999a8 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/MainWindow.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/MainWindow.java @@ -238,7 +238,7 @@ public final class MainWindow extends javax.swing.JFrame itm.addActionListener(new ActionListenerImpl("me " + JOptionPane.showInputDialog("广播讯息"))); itm = new JMenuItem("私聊"); itm.addActionListener(e -> { - InputDialog id = new InputDialog(MainWindow.this, true, new String[] {"玩家", "讯息"}); + InputDialog id = new InputDialog(MainWindow.this, true, new String[] { "玩家", "讯息" }); id.setVisible(true); Server.getInstance().sendCommand("tell " + id.result[0] + " " + id.result[1]); }); @@ -318,7 +318,7 @@ public final class MainWindow extends javax.swing.JFrame ppmBasically.add(itm); itm = new JMenuItem("给予玩家物品"); itm.addActionListener(e -> { - InputDialog id = new InputDialog(MainWindow.this, true, new String[] {"玩家", "物品ID", "数量"}); + InputDialog id = new InputDialog(MainWindow.this, true, new String[] { "玩家", "物品ID", "数量" }); id.setVisible(true); if (id.result != null) Server.getInstance().sendCommand("give " + id.result[0] + " " + id.result[1] + " " + id.result[2]); @@ -2779,7 +2779,7 @@ public final class MainWindow extends javax.swing.JFrame while (model.getRowCount() > 0) model.removeRow(0); for (String s : sl) - model.addRow(new Object[] {!SettingsManager.settings.inactiveExtMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(IOUtils.addSeparator(path) + s))}); + model.addRow(new Object[] { !SettingsManager.settings.inactiveExtMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(IOUtils.addSeparator(path) + s)) }); lstExternalMods.updateUI(); } @@ -2795,11 +2795,11 @@ public final class MainWindow extends javax.swing.JFrame for (String s : sl) { PluginInformation p = PluginManager.getPluginYML(new File(Utilities.getGameDir() + "plugins" + File.separator + s)); if (p == null) - model.addRow(new Object[] {!SettingsManager.settings.inactivePlugins.contains(s), s, - "", "", "", ""}); + model.addRow(new Object[] { !SettingsManager.settings.inactivePlugins.contains(s), s, + "", "", "", "" }); else - model.addRow(new Object[] {!SettingsManager.settings.inactivePlugins.contains(s), s, - p.name, p.version, p.author, p.description}); + model.addRow(new Object[] { !SettingsManager.settings.inactivePlugins.contains(s), s, + p.name, p.version, p.author, p.description }); } lstPlugins.updateUI(); @@ -2814,7 +2814,7 @@ public final class MainWindow extends javax.swing.JFrame while (model.getRowCount() > 0) model.removeRow(0); for (String s : sl) - model.addRow(new Object[] {!SettingsManager.settings.inactiveCoreMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(IOUtils.addSeparator(path) + s))}); + model.addRow(new Object[] { !SettingsManager.settings.inactiveCoreMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(IOUtils.addSeparator(path) + s)) }); lstCoreMods.updateUI(); } @@ -3003,7 +3003,7 @@ public final class MainWindow extends javax.swing.JFrame ArrayList al = IOUtils.findAllFile(new File(Utilities.getGameDir() + "infos-HMCSM")); DefaultTableModel model = (DefaultTableModel) lstInfos.getModel(); for (String s : al) - model.addRow(new Object[] {s, FileUtils.getExtension(s)}); + model.addRow(new Object[] { s, FileUtils.getExtension(s) }); lstInfos.updateUI(); } @@ -3416,7 +3416,7 @@ public final class MainWindow extends javax.swing.JFrame FileUtils.copyFile(new File(path), newf); DefaultTableModel model = (DefaultTableModel) lstExternalMods.getModel(); - model.addRow(new Object[] {fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf))}); + model.addRow(new Object[] { fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf)) }); lstExternalMods.updateUI(); } catch (IOException e) { MessageBox.Show(C.i18n("mods.failed")); @@ -3455,7 +3455,7 @@ public final class MainWindow extends javax.swing.JFrame DefaultTableModel model = (DefaultTableModel) lstCoreMods.getModel(); lstCoreMods.updateUI(); - model.addRow(new Object[] {fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf))}); + model.addRow(new Object[] { fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf)) }); FileUtils.copyFile(new File(path), newf); } catch (IOException e) { MessageBox.Show(C.i18n("mods.failed")); @@ -3495,7 +3495,7 @@ public final class MainWindow extends javax.swing.JFrame DefaultTableModel model = (DefaultTableModel) lstPlugins.getModel(); lstPlugins.updateUI(); - model.addRow(new Object[] {fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf))}); + model.addRow(new Object[] { fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf)) }); FileUtils.copyFile(new File(path), newf); } catch (IOException e) { MessageBox.Show(C.i18n("mods.failed")); diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/PluginInfoDialog.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/PluginInfoDialog.java index 893035421..d89a0d78b 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/PluginInfoDialog.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/PluginInfoDialog.java @@ -1,7 +1,7 @@ /* * Hello Minecraft! Launcher. * Copyright (C) 2013 huangyuhui - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -232,9 +232,9 @@ public class PluginInfoDialog extends javax.swing.JDialog { return; String url = pi.versions.get(index).download; TaskWindow.getInstance() - .addTask(new FileDownloadTask(url, new File(Utilities.getGameDir() + "plugins" - + File.separator + pi.versions.get(index).filename))) - .start(); + .addTask(new FileDownloadTask(url, new File(Utilities.getGameDir() + "plugins" + + File.separator + pi.versions.get(index).filename))) + .start(); }//GEN-LAST:event_jButton1ActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables