From d3ad805ad3a7e8f6f1ac8bd01417663597ea256f Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Sat, 5 Dec 2015 21:41:50 +0800 Subject: [PATCH] Change the license to GPL v3 to be compatible with Apache License 2.0. --- .../hellominecraft/launcher/Launcher.java | 25 +- .../hellominecraft/launcher/Main.java | 18 +- .../launch/AbstractMinecraftLoader.java | 17 +- .../launcher/launch/DefaultGameLauncher.java | 17 +- .../launcher/launch/GameLauncher.java | 17 +- .../launcher/launch/IMinecraftLoader.java | 15 +- .../launcher/launch/IMinecraftModService.java | 15 +- .../launcher/launch/IMinecraftProvider.java | 19 +- .../launcher/launch/LaunchFinisher.java | 18 +- .../launcher/launch/LaunchScriptFinisher.java | 17 +- .../launcher/launch/LibraryDownloadTask.java | 15 +- .../launch/MinecraftCrashAdvicer.java | 15 +- .../launcher/launch/MinecraftLoader.java | 17 +- .../launcher/settings/Config.java | 16 +- .../launcher/settings/LauncherVisibility.java | 15 +- .../launcher/settings/Profile.java | 19 +- .../launcher/settings/Settings.java | 17 +- .../launcher/utils/CrashReporter.java | 17 +- .../launcher/utils/FileNameFilter.java | 15 +- .../launcher/utils/MCUtils.java | 42 +- .../launcher/utils/ModInfo.java | 39 +- .../launcher/utils/assets/AssetsIndex.java | 15 +- .../launcher/utils/assets/AssetsLoader.java | 15 +- .../utils/assets/AssetsLoaderListener.java | 15 +- .../utils/assets/AssetsMojangLoader.java | 15 +- .../utils/assets/AssetsMojangOldLoader.java | 17 +- .../launcher/utils/assets/AssetsObject.java | 15 +- .../launcher/utils/assets/Contents.java | 15 +- .../launcher/utils/assets/IAssetsHandler.java | 15 +- .../utils/auth/AuthenticationException.java | 17 + .../launcher/utils/auth/BestLogin.java | 15 +- .../launcher/utils/auth/IAuthenticator.java | 15 +- .../launcher/utils/auth/LoginInfo.java | 15 +- .../utils/auth/OfflineAuthenticator.java | 15 +- .../utils/auth/SkinmeAuthenticator.java | 15 +- .../utils/auth/UserProfileProvider.java | 15 +- .../utils/auth/YggdrasilAuthenticator.java | 15 +- .../auth/yggdrasil/AuthenticationRequest.java | 17 + .../utils/auth/yggdrasil/GameProfile.java | 17 + .../utils/auth/yggdrasil/Property.java | 17 + .../utils/auth/yggdrasil/PropertyMap.java | 17 + .../utils/auth/yggdrasil/RefreshRequest.java | 17 + .../utils/auth/yggdrasil/Response.java | 17 + .../utils/auth/yggdrasil/UUIDTypeAdapter.java | 17 + .../launcher/utils/auth/yggdrasil/User.java | 17 + .../yggdrasil/YggdrasilAuthentication.java | 17 + .../download/BMCLAPIDownloadProvider.java | 15 +- .../launcher/utils/download/DownloadType.java | 15 +- .../utils/download/IDownloadProvider.java | 15 +- .../download/MojangDownloadProvider.java | 15 +- .../download/RapidDataDownloadProvider.java | 15 +- .../utils/installers/InstallProfile.java | 15 +- .../utils/installers/InstallerService.java | 15 +- .../installers/InstallerVersionList.java | 15 +- .../InstallerVersionNewerComparator.java | 15 +- .../installers/PackMinecraftInstaller.java | 15 +- .../installers/forge/ForgeInstaller.java | 17 +- .../installers/forge/ForgeOldInstaller.java | 15 +- .../utils/installers/forge/Install.java | 15 +- .../installers/forge/bmcl/Downloads.java | 15 +- .../forge/bmcl/ForgeBMCLVersionList.java | 15 +- .../installers/forge/bmcl/ForgeVersion.java | 15 +- .../forge/vanilla/MinecraftForgeVersion.java | 15 +- .../vanilla/MinecraftForgeVersionList.java | 15 +- .../vanilla/MinecraftForgeVersionRoot.java | 15 +- .../liteloader/LiteLoaderInstaller.java | 15 +- .../liteloader/LiteLoaderMCVersions.java | 15 +- .../liteloader/LiteLoaderVersion.java | 15 +- .../liteloader/LiteLoaderVersionList.java | 15 +- .../liteloader/LiteLoaderVersionsMeta.java | 15 +- .../liteloader/LiteLoaderVersionsRoot.java | 15 +- .../optifine/OptiFineInstaller.java | 15 +- .../installers/optifine/OptiFineVersion.java | 15 +- .../bmcl/OptiFineBMCLVersionList.java | 15 +- .../vanilla/OptiFineDownloadFormatter.java | 15 +- .../optifine/vanilla/OptiFineVersionList.java | 15 +- .../launcher/utils/upgrade/Upgrader.java | 15 +- .../launcher/version/Extract.java | 15 +- .../launcher/version/GameDirType.java | 15 +- .../launcher/version/IMinecraftLibrary.java | 15 +- .../version/MinecraftClassicVersion.java | 15 +- .../launcher/version/MinecraftLibrary.java | 15 +- .../launcher/version/MinecraftModService.java | 15 +- .../launcher/version/MinecraftOldLibrary.java | 15 +- .../launcher/version/MinecraftService.java | 15 +- .../launcher/version/MinecraftVersion.java | 15 +- .../version/MinecraftVersionManager.java | 17 +- .../launcher/version/Natives.java | 15 +- .../hellominecraft/launcher/version/OS.java | 15 +- .../launcher/version/Rules.java | 15 +- .../launcher/views/DraggableFrame.java | 15 +- .../launcher/views/GameSettingsPanel.java | 17 +- .../launcher/views/HeaderTab.java | 15 +- .../launcher/views/LauncherSettingsPanel.java | 17 +- .../launcher/views/MainFrame.java | 26 +- .../launcher/views/MainPagePanel.java | 19 +- .../launcher/views/NewProfileWindow.java | 15 +- .../java/org/jackhuang/hellominecraft/C.java | 15 +- .../org/jackhuang/hellominecraft/HMCLog.java | 15 +- .../logging/AppenderControl.java | 15 +- .../hellominecraft/logging/Configuration.java | 15 +- .../hellominecraft/logging/Level.java | 15 +- .../hellominecraft/logging/LogEvent.java | 15 +- .../logging/LoggingException.java | 15 +- .../logging/appender/AbstractAppender.java | 15 +- .../logging/appender/ConsoleAppender.java | 15 +- .../logging/appender/IAppender.java | 15 +- .../appender/OutputStreamAppender.java | 15 +- .../logging/layout/AbstractStringLayout.java | 15 +- .../logging/layout/DefaultLayout.java | 15 +- .../logging/layout/ILayout.java | 15 +- .../logging/logger/AbstractLogger.java | 15 +- .../logging/logger/ILogger.java | 15 +- .../hellominecraft/logging/logger/Logger.java | 15 +- .../logging/logger/SimpleLogger.java | 15 +- .../message/AbstractMessageFactory.java | 15 +- .../logging/message/IMessage.java | 15 +- .../logging/message/IMessageFactory.java | 15 +- .../logging/message/ObjectMessage.java | 15 +- .../logging/message/ParameterizedMessage.java | 15 +- .../message/ParameterizedMessageFactory.java | 15 +- .../logging/message/SimpleMessage.java | 15 +- .../message/StringFormattedMessage.java | 15 +- .../tasks/DoingDoneListener.java | 15 +- .../hellominecraft/tasks/DoubleTask.java | 18 +- .../hellominecraft/tasks/ParallelTask.java | 15 +- .../tasks/ProgressProviderListener.java | 15 +- .../jackhuang/hellominecraft/tasks/Task.java | 15 +- .../hellominecraft/tasks/TaskInfo.java | 15 +- .../hellominecraft/tasks/TaskList.java | 15 +- .../hellominecraft/tasks/TaskRunnable.java | 15 +- .../tasks/TaskRunnableArg1.java | 15 +- .../hellominecraft/tasks/TaskWindow.java | 17 +- .../communication/DefaultPreviousResult.java | 15 +- .../tasks/communication/PreviousResult.java | 15 +- .../PreviousResultRegistrar.java | 15 +- .../tasks/download/ContentGetAndShowTask.java | 15 +- .../tasks/download/DownloadListener.java | 15 +- .../tasks/download/FileDownloadTask.java | 15 +- .../tasks/download/HTTPGetTask.java | 15 +- .../tasks/download/NetException.java | 15 +- .../hellominecraft/utils/ArrayUtils.java | 15 +- .../hellominecraft/utils/CollectionUtils.java | 15 +- .../utils/DoubleOutputStream.java | 15 +- .../jackhuang/hellominecraft/utils/Event.java | 15 +- .../hellominecraft/utils/EventHandler.java | 15 +- .../utils/LauncherPrintStream.java | 15 +- .../utils/LogWindowOutputStream.java | 15 +- .../hellominecraft/utils/MathUtils.java | 15 +- .../utils/{system => }/MessageBox.java | 17 +- .../hellominecraft/utils/NetUtils.java | 15 +- .../jackhuang/hellominecraft/utils/Pair.java | 15 +- .../hellominecraft/utils/StrUtils.java | 15 +- .../hellominecraft/utils/SwingUtils.java | 15 +- .../hellominecraft/utils/UpdateChecker.java | 16 +- .../jackhuang/hellominecraft/utils/Utils.java | 37 +- .../hellominecraft/utils/VersionNumber.java | 15 +- .../hellominecraft/utils/code/Base64.java | 15 +- .../hellominecraft/utils/code/Charsets.java | 15 +- .../utils/code/DigestUtils.java | 15 +- .../hellominecraft/utils/code/Hex.java | 15 +- .../utils/functions/BiConsumer.java | 15 +- .../utils/functions/BiFunction.java | 15 +- .../utils/functions/Consumer.java | 15 +- .../utils/functions/FalseFunction.java | 30 - .../utils/functions/Function.java | 15 +- .../utils/functions/NonFunction.java | 15 +- .../utils/functions/Predicate.java | 15 +- .../utils/functions/TriConsumer.java | 15 +- .../utils/functions/TrueFunction.java | 35 - .../utils/system/Compressor.java | 15 +- .../utils/system/FileUtils.java | 15 +- .../hellominecraft/utils/system/IOUtils.java | 15 +- .../hellominecraft/utils/system/Java.java | 15 +- .../utils/system/JavaProcess.java | 15 +- .../utils/system/JavaProcessMonitor.java | 16 +- .../utils/system/JdkVersion.java | 15 +- .../hellominecraft/utils/system/OS.java | 15 +- .../hellominecraft/utils/system/Platform.java | 15 +- .../utils/system/ProcessManager.java | 25 +- .../utils/system/ProcessThread.java | 15 +- .../utils/system/ThreadExecutor.java | 15 +- .../version/MinecraftRemoteLatestVersion.java | 15 +- .../version/MinecraftRemoteVersion.java | 15 +- .../version/MinecraftRemoteVersions.java | 15 +- .../version/MinecraftVersionRequest.java | 33 +- .../hellominecraft/views/AbstractFilter.java | 15 +- .../hellominecraft/views/BasicColors.java | 15 +- .../views/DropShadowBorder.java | 15 +- .../hellominecraft/views/FastBlurFilter.java | 15 +- .../hellominecraft/views/LogWindow.java | 15 +- .../hellominecraft/views/Selector.java | 15 +- .../hellominecraft/views/TintablePanel.java | 15 +- HMCLAPI/src/main/java/rx/Notification.java | 161 + HMCLAPI/src/main/java/rx/Observable.java | 3273 +++++++++++++++++ HMCLAPI/src/main/java/rx/Observer.java | 57 + HMCLAPI/src/main/java/rx/Scheduler.java | 69 + HMCLAPI/src/main/java/rx/Subscription.java | 34 + .../rx/concurrency/AbstractScheduler.java | 53 + .../concurrency/CurrentThreadScheduler.java | 71 + .../rx/concurrency/DiscardableAction.java | 52 + .../rx/concurrency/ExecutorScheduler.java | 126 + .../rx/concurrency/ImmediateScheduler.java | 46 + .../rx/concurrency/NewThreadScheduler.java | 49 + .../main/java/rx/concurrency/Schedulers.java | 143 + .../java/rx/concurrency/SleepingAction.java | 49 + .../java/rx/concurrency/package-info.java | 19 + .../rx/observables/GroupedObservable.java | 43 + .../main/java/rx/operators/OperationAll.java | 61 + .../rx/operators/OperationCombineLatest.java | 273 ++ .../java/rx/operators/OperationConcat.java | 126 + .../java/rx/operators/OperationDefer.java | 30 + .../rx/operators/OperationDematerialize.java | 78 + .../java/rx/operators/OperationFilter.java | 70 + .../java/rx/operators/OperationFinally.java | 91 + .../main/java/rx/operators/OperationMap.java | 124 + .../rx/operators/OperationMaterialize.java | 78 + .../java/rx/operators/OperationMerge.java | 255 ++ .../operators/OperationMergeDelayError.java | 327 ++ .../rx/operators/OperationMostRecent.java | 106 + .../main/java/rx/operators/OperationNext.java | 148 + .../java/rx/operators/OperationObserveOn.java | 44 + ...OperationOnErrorResumeNextViaFunction.java | 99 + ...erationOnErrorResumeNextViaObservable.java | 91 + .../rx/operators/OperationOnErrorReturn.java | 108 + .../main/java/rx/operators/OperationScan.java | 130 + .../main/java/rx/operators/OperationSkip.java | 98 + .../rx/operators/OperationSubscribeOn.java | 67 + .../rx/operators/OperationSynchronize.java | 72 + .../main/java/rx/operators/OperationTake.java | 132 + .../java/rx/operators/OperationTakeLast.java | 84 + .../java/rx/operators/OperationTakeWhile.java | 131 + .../OperationToObservableFuture.java | 70 + .../OperationToObservableIterable.java | 40 + .../operators/OperationToObservableList.java | 78 + .../OperationToObservableSortedList.java | 130 + .../java/rx/operators/OperationWhere.java | 28 + .../main/java/rx/operators/OperationZip.java | 259 ++ .../java/rx/operators/OperatorGroupBy.java | 116 + .../java/rx/operators/OperatorTakeUntil.java | 137 + .../java/rx/operators/OperatorToIterator.java | 85 + .../java/rx/operators/ScheduledObserver.java | 60 + .../src/main/java/rx/operators/package.html | 23 + HMCLAPI/src/main/java/rx/package-info.java | 45 + .../java/rx/plugins/RxJavaErrorHandler.java | 41 + .../rx/plugins/RxJavaErrorHandlerDefault.java | 31 + .../RxJavaObservableExecutionHook.java | 88 + .../RxJavaObservableExecutionHookDefault.java | 29 + .../main/java/rx/plugins/RxJavaPlugins.java | 147 + .../src/main/java/rx/subjects/Subject.java | 65 + .../rx/subscriptions/BooleanSubscription.java | 26 + .../java/rx/subscriptions/Subscriptions.java | 58 + .../rx/util/AtomicObservableSubscription.java | 74 + .../src/main/java/rx/util/AtomicObserver.java | 97 + .../main/java/rx/util/CompositeException.java | 65 + HMCLAPI/src/main/java/rx/util/Exceptions.java | 31 + HMCLAPI/src/main/java/rx/util/Range.java | 75 + .../java/rx/util/SynchronizedObserver.java | 108 + .../main/java/rx/util/functions/Action0.java | 20 + .../main/java/rx/util/functions/Action1.java | 20 + .../main/java/rx/util/functions/Action2.java | 20 + .../main/java/rx/util/functions/Action3.java | 20 + .../main/java/rx/util/functions/Func0.java | 20 + .../main/java/rx/util/functions/Func1.java | 20 + .../main/java/rx/util/functions/Func2.java | 20 + .../main/java/rx/util/functions/Func3.java | 20 + .../main/java/rx/util/functions/Func4.java | 20 + .../main/java/rx/util/functions/Func5.java | 20 + .../main/java/rx/util/functions/Func6.java | 20 + .../main/java/rx/util/functions/Func7.java | 20 + .../main/java/rx/util/functions/Func8.java | 20 + .../main/java/rx/util/functions/Func9.java | 20 + .../main/java/rx/util/functions/FuncN.java | 20 + .../main/java/rx/util/functions/Function.java | 10 + .../functions/FunctionLanguageAdaptor.java | 39 + .../java/rx/util/functions/Functions.java | 579 +++ .../hellominecraft/launcher/I18N.properties | 21 +- .../launcher/I18N_en.properties | 21 +- .../launcher/I18N_zh.properties | 21 +- .../launcher/I18N_zh_CN.properties | 21 +- .../jackhuang/hellominecraft/svrmgr/Main.java | 17 +- .../svrmgr/cbplugins/BukkitPlugin.java | 15 +- .../svrmgr/cbplugins/Category.java | 15 +- .../svrmgr/cbplugins/PluginInfo.java | 15 +- .../svrmgr/cbplugins/PluginInformation.java | 15 +- .../svrmgr/cbplugins/PluginManager.java | 15 +- .../svrmgr/cbplugins/PluginVersion.java | 15 +- .../installer/bukkit/BukkitFormatThread.java | 15 +- .../installer/bukkit/BukkitVersion.java | 15 +- .../installer/cauldron/ForgeFormatThread.java | 15 +- .../installer/cauldron/ForgeInstaller.java | 17 +- .../installer/cauldron/ForgeVersion.java | 15 +- .../svrmgr/installer/cauldron/Install.java | 15 +- .../installer/cauldron/InstallProfile.java | 15 +- .../installer/cauldron/MinecraftLibrary.java | 15 +- .../installer/cauldron/MinecraftVersion.java | 15 +- .../svrmgr/server/ScheduleTranslator.java | 15 +- .../hellominecraft/svrmgr/server/Server.java | 17 +- .../svrmgr/server/ServerChecker.java | 15 +- .../svrmgr/server/backups/BackupManager.java | 15 +- .../download/ServerDownloadPackage.java | 15 +- .../server/schedules/AutoBackupSchedule.java | 15 +- .../schedules/AutoBroadcastSchedule.java | 15 +- .../server/schedules/AutoExecuteSchedule.java | 15 +- .../server/schedules/AutoRestartSchedule.java | 15 +- .../server/schedules/AutoSaveSchedule.java | 15 +- .../svrmgr/server/schedules/AutoSchedule.java | 15 +- .../schedules/AutoSendCommandSchedule.java | 15 +- .../svrmgr/settings/BannedPlayers.java | 15 +- .../hellominecraft/svrmgr/settings/Op.java | 15 +- .../svrmgr/settings/PlayerList.java | 15 +- .../svrmgr/settings/Schedule.java | 15 +- .../svrmgr/settings/ServerProperties.java | 15 +- .../svrmgr/settings/Settings.java | 15 +- .../svrmgr/settings/SettingsManager.java | 15 +- .../svrmgr/settings/WhiteList.java | 15 +- .../svrmgr/threads/MonitorThread.java | 15 +- .../svrmgr/threads/WaitForThread.java | 15 +- .../svrmgr/utils/FolderOpener.java | 17 +- .../svrmgr/utils/IMonitorService.java | 15 +- .../hellominecraft/svrmgr/utils/IPGet.java | 15 +- .../hellominecraft/svrmgr/utils/ModType.java | 15 +- .../svrmgr/utils/MonitorInfoBean.java | 15 +- .../svrmgr/utils/MonitorServiceImpl.java | 15 +- .../svrmgr/utils/Utilities.java | 15 +- .../svrmgr/views/CommandsWindow.java | 15 +- .../svrmgr/views/InputDialog.java | 16 +- .../svrmgr/views/MainWindow.java | 2 +- .../svrmgr/views/PluginInfoDialog.java | 15 +- LICENSE | 683 +++- license-header.txt | 15 +- 331 files changed, 12761 insertions(+), 1878 deletions(-) rename HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/{system => }/MessageBox.java (88%) delete mode 100644 HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/FalseFunction.java delete mode 100644 HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/TrueFunction.java create mode 100644 HMCLAPI/src/main/java/rx/Notification.java create mode 100644 HMCLAPI/src/main/java/rx/Observable.java create mode 100644 HMCLAPI/src/main/java/rx/Observer.java create mode 100644 HMCLAPI/src/main/java/rx/Scheduler.java create mode 100644 HMCLAPI/src/main/java/rx/Subscription.java create mode 100644 HMCLAPI/src/main/java/rx/concurrency/AbstractScheduler.java create mode 100644 HMCLAPI/src/main/java/rx/concurrency/CurrentThreadScheduler.java create mode 100644 HMCLAPI/src/main/java/rx/concurrency/DiscardableAction.java create mode 100644 HMCLAPI/src/main/java/rx/concurrency/ExecutorScheduler.java create mode 100644 HMCLAPI/src/main/java/rx/concurrency/ImmediateScheduler.java create mode 100644 HMCLAPI/src/main/java/rx/concurrency/NewThreadScheduler.java create mode 100644 HMCLAPI/src/main/java/rx/concurrency/Schedulers.java create mode 100644 HMCLAPI/src/main/java/rx/concurrency/SleepingAction.java create mode 100644 HMCLAPI/src/main/java/rx/concurrency/package-info.java create mode 100644 HMCLAPI/src/main/java/rx/observables/GroupedObservable.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationAll.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationCombineLatest.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationConcat.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationDefer.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationDematerialize.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationFilter.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationFinally.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationMap.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationMaterialize.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationMerge.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationMergeDelayError.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationMostRecent.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationNext.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationObserveOn.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaFunction.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaObservable.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationOnErrorReturn.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationScan.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationSkip.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationSubscribeOn.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationSynchronize.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationTake.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationTakeLast.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationTakeWhile.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationToObservableFuture.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationToObservableIterable.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationToObservableList.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationToObservableSortedList.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationWhere.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperationZip.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperatorGroupBy.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperatorTakeUntil.java create mode 100644 HMCLAPI/src/main/java/rx/operators/OperatorToIterator.java create mode 100644 HMCLAPI/src/main/java/rx/operators/ScheduledObserver.java create mode 100644 HMCLAPI/src/main/java/rx/operators/package.html create mode 100644 HMCLAPI/src/main/java/rx/package-info.java create mode 100644 HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandler.java create mode 100644 HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandlerDefault.java create mode 100644 HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java create mode 100644 HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java create mode 100644 HMCLAPI/src/main/java/rx/plugins/RxJavaPlugins.java create mode 100644 HMCLAPI/src/main/java/rx/subjects/Subject.java create mode 100644 HMCLAPI/src/main/java/rx/subscriptions/BooleanSubscription.java create mode 100644 HMCLAPI/src/main/java/rx/subscriptions/Subscriptions.java create mode 100644 HMCLAPI/src/main/java/rx/util/AtomicObservableSubscription.java create mode 100644 HMCLAPI/src/main/java/rx/util/AtomicObserver.java create mode 100644 HMCLAPI/src/main/java/rx/util/CompositeException.java create mode 100644 HMCLAPI/src/main/java/rx/util/Exceptions.java create mode 100644 HMCLAPI/src/main/java/rx/util/Range.java create mode 100644 HMCLAPI/src/main/java/rx/util/SynchronizedObserver.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Action0.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Action1.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Action2.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Action3.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Func0.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Func1.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Func2.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Func3.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Func4.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Func5.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Func6.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Func7.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Func8.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Func9.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/FuncN.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Function.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/FunctionLanguageAdaptor.java create mode 100644 HMCLAPI/src/main/java/rx/util/functions/Functions.java 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 d19acc6bb..d6412fc61 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Launcher.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Launcher.java @@ -1,37 +1,36 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher; import java.io.File; import java.io.FileOutputStream; -import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import javax.swing.SwingUtilities; import org.jackhuang.hellominecraft.C; -import org.jackhuang.hellominecraft.utils.functions.TrueFunction; import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.views.LogWindow; import org.jackhuang.hellominecraft.launcher.launch.MinecraftCrashAdvicer; import org.jackhuang.hellominecraft.utils.DoubleOutputStream; import org.jackhuang.hellominecraft.utils.LauncherPrintStream; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.Utils; /** @@ -127,7 +126,7 @@ public final class Launcher { System.err.println(C.i18n("crash.minecraft")); System.err.println(advice); System.err.println(trace); - LogWindow.instance.setExit(TrueFunction.instance); + LogWindow.instance.setExit(() -> true); LogWindow.instance.setVisible(true); flag = 1; } @@ -135,7 +134,7 @@ public final class Launcher { println("*** Game Exited ***"); Utils.shutdownForcely(1); } - + /* static Object getShutdownHaltLock() { try { Class z = Class.forName("java.lang.Shutdown"); @@ -146,5 +145,5 @@ public final class Launcher { 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 4b71137b8..f1f19ffb9 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Main.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Main.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher; @@ -60,7 +61,7 @@ import org.jackhuang.hellominecraft.lookandfeel.HelloMinecraftLookAndFeel; import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.ArrayUtils; import org.jackhuang.hellominecraft.utils.MathUtils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.VersionNumber; import org.jackhuang.hellominecraft.utils.system.FileUtils; @@ -189,6 +190,7 @@ public final class Main implements Runnable { Settings.UPDATE_CHECKER.start(); if (StrUtils.isNotBlank(Settings.getInstance().getProxyHost()) && StrUtils.isNotBlank(Settings.getInstance().getProxyPort()) && MathUtils.canParseInt(Settings.getInstance().getProxyPort())) { + HMCLog.log("Initializing customized proxy"); System.setProperty("http.proxyHost", Settings.getInstance().getProxyHost()); System.setProperty("http.proxyPort", Settings.getInstance().getProxyPort()); if (StrUtils.isNotBlank(Settings.getInstance().getProxyUserName()) && StrUtils.isNotBlank(Settings.getInstance().getProxyPassword())) diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/AbstractMinecraftLoader.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/AbstractMinecraftLoader.java index 5266a0f03..fd90ae68b 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/AbstractMinecraftLoader.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/AbstractMinecraftLoader.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; @@ -29,7 +30,7 @@ import org.jackhuang.hellominecraft.launcher.settings.Profile; import org.jackhuang.hellominecraft.launcher.settings.Settings; import org.jackhuang.hellominecraft.utils.system.JdkVersion; import org.jackhuang.hellominecraft.utils.MathUtils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.system.OS; import org.jackhuang.hellominecraft.utils.system.Platform; import org.jackhuang.hellominecraft.utils.StrUtils; 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 f99186055..394c1efac 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; @@ -27,7 +28,7 @@ import org.jackhuang.hellominecraft.launcher.settings.Profile; import org.jackhuang.hellominecraft.tasks.ParallelTask; import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.system.Compressor; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; public class DefaultGameLauncher extends GameLauncher { 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 ddbdd7570..0eb9db9a7 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/GameLauncher.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/GameLauncher.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; @@ -34,7 +35,7 @@ import org.jackhuang.hellominecraft.launcher.utils.auth.AuthenticationException; import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.JavaProcess; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.system.OS; import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.EventHandler; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftLoader.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftLoader.java index ca31e8372..5f3a492e3 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftLoader.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftLoader.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftModService.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftModService.java index 2098f95d4..139cef227 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftModService.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftModService.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; 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 ab3676c2b..9c052fcb7 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftProvider.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; @@ -194,7 +195,7 @@ public abstract class IMinecraftProvider { public abstract void refreshVersions(); /** - * Clean redundancy files. + * Clean redundant files. */ public abstract void cleanFolder(); @@ -209,7 +210,7 @@ public abstract class IMinecraftProvider { public abstract boolean install(String version, DownloadType type); /** - * When GameLauncher launches the Minecraft, this function will be called. + * When GameLauncher launches the game, this function will be called. */ public abstract void onLaunch(); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LaunchFinisher.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LaunchFinisher.java index ea0f2c4e3..45fab9678 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LaunchFinisher.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LaunchFinisher.java @@ -1,24 +1,24 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; import java.util.List; import org.jackhuang.hellominecraft.launcher.settings.LauncherVisibility; -import org.jackhuang.hellominecraft.utils.functions.TrueFunction; import org.jackhuang.hellominecraft.launcher.views.MainFrame; import org.jackhuang.hellominecraft.utils.Event; import org.jackhuang.hellominecraft.utils.system.JavaProcessMonitor; @@ -40,7 +40,7 @@ public class LaunchFinisher implements Event> { MainFrame.INSTANCE.closeMessage(); else { if (LogWindow.instance.isVisible()) - LogWindow.instance.setExit(TrueFunction.instance); + LogWindow.instance.setExit(() -> true); MainFrame.INSTANCE.dispose(); } JavaProcessMonitor jpm = new JavaProcessMonitor(p); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LaunchScriptFinisher.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LaunchScriptFinisher.java index 08d49d705..37b0fd2e9 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LaunchScriptFinisher.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LaunchScriptFinisher.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; @@ -23,7 +24,7 @@ import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.launcher.views.MainFrame; import org.jackhuang.hellominecraft.utils.Event; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; /** * 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 ec546233b..f48f1152e 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; 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 578c6f894..fc4c7f87f 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/MinecraftLoader.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/MinecraftLoader.java index 96932cbb8..09ee18248 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/MinecraftLoader.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/MinecraftLoader.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.launch; @@ -36,7 +37,7 @@ import org.jackhuang.hellominecraft.launcher.version.MinecraftLibrary; import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion; import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.system.FileUtils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; /** * diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Config.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Config.java index 8f4abd704..2a212f6b7 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Config.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Config.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.settings; @@ -24,7 +25,6 @@ import java.util.Map; import java.util.TreeMap; import java.util.UUID; import org.jackhuang.hellominecraft.utils.system.JdkVersion; -import org.jackhuang.hellominecraft.utils.system.OS; /** * 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 d7194e15c..146b1a02a 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.settings; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Profile.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Profile.java index 37522b7df..104c30def 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Profile.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Profile.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.settings; @@ -358,12 +359,12 @@ public final class Profile { gameDir = gameDir.replace('/', OS.os().fileSeparator).replace('\\', OS.os().fileSeparator); } - final InstallerService is = new InstallerService(this); + transient final InstallerService is = new InstallerService(this); public InstallerService getInstallerService() { return is; } - final MinecraftService ms = new MinecraftService(this); + transient final MinecraftService ms = new MinecraftService(this); public MinecraftService getMinecraftService() { return ms; } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Settings.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Settings.java index 89c95a5c9..f854d4e7e 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Settings.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/settings/Settings.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.settings; @@ -30,7 +31,7 @@ import org.jackhuang.hellominecraft.launcher.Main; import org.jackhuang.hellominecraft.utils.CollectionUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.UpdateChecker; import org.jackhuang.hellominecraft.utils.VersionNumber; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/CrashReporter.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/CrashReporter.java index 3ab613c1d..fb982c7b3 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/CrashReporter.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/CrashReporter.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils; @@ -27,7 +28,7 @@ import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.launcher.Main; import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.UpdateChecker; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.views.LogWindow; 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 197fc80e8..38e953018 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils; 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 c31f4e56a..3953357c6 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils; @@ -28,7 +29,6 @@ import org.jackhuang.hellominecraft.launcher.utils.assets.AssetsIndex; import org.jackhuang.hellominecraft.launcher.utils.assets.AssetsObject; import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType; import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion; -import org.jackhuang.hellominecraft.version.MinecraftRemoteVersions; import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask; import org.jackhuang.hellominecraft.utils.ArrayUtils; @@ -73,20 +73,20 @@ public final class MCUtils { byte[] bytes = "Minecraft Minecraft ".getBytes("ASCII"); int j; if ((j = ArrayUtils.matchArray(tmp, bytes)) < 0) { - r.type = MinecraftVersionRequest.Unkown; + r.type = MinecraftVersionRequest.UNKOWN; return r; } int i = j + bytes.length; if ((j = lessThan32(tmp, i)) < 0) { - r.type = MinecraftVersionRequest.Unkown; + r.type = MinecraftVersionRequest.UNKOWN; return r; } String ver = new String(tmp, i, j - i, "ASCII"); r.version = ver; r.type = file.getEntry("META-INF/MANIFEST.MF") == null - ? MinecraftVersionRequest.Modified : MinecraftVersionRequest.OK; + ? MinecraftVersionRequest.MODIFIED : MinecraftVersionRequest.OK; return r; } @@ -97,14 +97,14 @@ public final class MCUtils { byte[] str = "-server.txt".getBytes("ASCII"); int j = ArrayUtils.matchArray(tmp, str); if (j < 0) { - r.type = MinecraftVersionRequest.Unkown; + r.type = MinecraftVersionRequest.UNKOWN; return r; } int i = j + str.length; i += 11; j = lessThan32(tmp, i); if (j < 0) { - r.type = MinecraftVersionRequest.Unkown; + r.type = MinecraftVersionRequest.UNKOWN; return r; } r.version = new String(tmp, i, j - i, "ASCII"); @@ -115,7 +115,7 @@ public final class MCUtils { str = "Can't keep up! Did the system time change, or is the server overloaded?".getBytes("ASCII"); j = ArrayUtils.matchArray(tmp, str); if (j < 0) { - r.type = MinecraftVersionRequest.Unkown; + r.type = MinecraftVersionRequest.UNKOWN; return r; } i = -1; @@ -127,7 +127,7 @@ public final class MCUtils { j--; } if (i == -1) { - r.type = MinecraftVersionRequest.Unkown; + r.type = MinecraftVersionRequest.UNKOWN; return r; } int k = i; @@ -137,22 +137,22 @@ public final class MCUtils { r.version = new String(tmp, k, i - k + 1); } r.type = file.getEntry("META-INF/MANIFEST.MF") == null - ? MinecraftVersionRequest.Modified : MinecraftVersionRequest.OK; + ? MinecraftVersionRequest.MODIFIED : MinecraftVersionRequest.OK; return r; } public static MinecraftVersionRequest minecraftVersion(File file) { MinecraftVersionRequest r = new MinecraftVersionRequest(); if (!file.exists()) { - r.type = MinecraftVersionRequest.NotFound; + r.type = MinecraftVersionRequest.NOT_FOUND; return r; } if (!file.isFile()) { - r.type = MinecraftVersionRequest.NotAFile; + r.type = MinecraftVersionRequest.NOT_FILE; return r; } if (!file.canRead()) { - r.type = MinecraftVersionRequest.NotReadable; + r.type = MinecraftVersionRequest.UNREADABLE; return r; } ZipFile localZipFile = null; @@ -166,11 +166,11 @@ public final class MCUtils { ZipEntry minecraftserver = localZipFile.getEntry("net/minecraft/server/MinecraftServer.class"); if ((main != null) && (minecraftserver != null)) return getVersionOfNewMinecraft(localZipFile, minecraftserver); - r.type = MinecraftVersionRequest.Invaild; + r.type = MinecraftVersionRequest.INVALID; return r; } catch (IOException localException) { HMCLog.warn("Zip file is invalid", localException); - r.type = MinecraftVersionRequest.InvaildJar; + r.type = MinecraftVersionRequest.INVALID_JAR; return r; } finally { if (localZipFile != null) 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 bf7ba68c5..1e77f1c7c 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/ModInfo.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/ModInfo.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils; @@ -106,22 +107,22 @@ public class ModInfo implements Comparable { ModInfo i = new ModInfo(); i.location = f; try { - ZipFile jar = new ZipFile(f); - ZipEntry entry = jar.getEntry("mcmod.info"); - if (entry == null) - entry = jar.getEntry("litemod.json"); - if (entry == null) - return i; - else { - List m = C.gson.fromJson(new InputStreamReader(jar.getInputStream(entry)), + try (ZipFile jar = new ZipFile(f)) { + ZipEntry entry = jar.getEntry("mcmod.info"); + if (entry == null) + entry = jar.getEntry("litemod.json"); + if (entry == null) + return i; + else { + List m = C.gson.fromJson(new InputStreamReader(jar.getInputStream(entry)), new TypeToken>() { }.getType()); - if (m != null && m.size() > 0) { - i = m.get(0); - i.location = f; + if (m != null && m.size() > 0) { + i = m.get(0); + i.location = f; + } } } - jar.close(); } catch (IOException ex) { HMCLog.warn("File " + f + " is not a jar.", ex); } catch (JsonSyntaxException ignore) { 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 3c348ee7a..3941e3c59 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.assets; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsLoader.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsLoader.java index d4a2b61ab..07d159242 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsLoader.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsLoader.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.assets; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsLoaderListener.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsLoaderListener.java index 598ccd1b7..bb269cc87 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsLoaderListener.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsLoaderListener.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.assets; 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 e4e0df779..853564775 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.assets; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsMojangOldLoader.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsMojangOldLoader.java index 5caa3e481..a64067f78 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsMojangOldLoader.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/assets/AssetsMojangOldLoader.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.assets; @@ -25,6 +26,8 @@ import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion; import org.jackhuang.hellominecraft.utils.VersionNumber; import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.functions.Consumer; +import rx.Observable; +import rx.util.functions.Func1; /** * 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 f8c790b4a..e62bb72e9 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.assets; 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 8252d0f6d..aef06356a 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.assets; 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 024b09c7c..bfcc30b26 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.assets; 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 e1b91d626..df877f092 100644 --- 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,3 +1,20 @@ +/* + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ package org.jackhuang.hellominecraft.launcher.utils.auth; public class AuthenticationException extends Exception { 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 1a4cd93cb..1484b0276 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.auth; 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 8950dabd5..5530933a2 100644 --- 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 @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.auth; 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 3a56df797..b0ab32b64 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.auth; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/OfflineAuthenticator.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/OfflineAuthenticator.java index a0b1edd8b..d68b951dd 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/OfflineAuthenticator.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/OfflineAuthenticator.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.auth; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/SkinmeAuthenticator.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/SkinmeAuthenticator.java index a2f402baa..1a20d6fe6 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/SkinmeAuthenticator.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/SkinmeAuthenticator.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.auth; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/UserProfileProvider.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/UserProfileProvider.java index b482044aa..ece464a82 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/UserProfileProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/UserProfileProvider.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.auth; 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 a2d2d9cb4..d33b2b01f 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.auth; 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 4589c2bdd..2acddfb2b 100644 --- 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,3 +1,20 @@ +/* + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil; import java.util.HashMap; 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 211dc44e5..ca77e32fa 100644 --- 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,3 +1,20 @@ +/* + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil; import com.google.gson.JsonDeserializationContext; 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 f98b19270..2e5648e9f 100644 --- 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,3 +1,20 @@ +/* + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil; public class Property { 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 722a79976..d3c0fd75d 100644 --- 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,3 +1,20 @@ +/* + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil; import com.google.gson.JsonArray; 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 b23691c18..c436d19a5 100644 --- 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,3 +1,20 @@ +/* + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil; public class RefreshRequest { 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 a84a8097c..a06c7cab2 100644 --- 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,3 +1,20 @@ +/* + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil; public class Response { 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 e038d92da..5ae76ace0 100644 --- 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,3 +1,20 @@ +/* + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil; import com.google.gson.TypeAdapter; 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 f98022133..613c30bb4 100644 --- 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,3 +1,20 @@ +/* + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil; public class User { 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 8c7b834be..08fea5681 100644 --- 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,3 +1,20 @@ +/* + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil; import org.jackhuang.hellominecraft.launcher.utils.auth.AuthenticationException; 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 c2e0b5798..e32f1924f 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.download; 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 c6c158e08..80b3a349d 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.download; 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 fc694b358..eb1c70b5a 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.download; 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 ea2b1e740..7b8da3cf9 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.download; 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 d2d12343d..8759beafa 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.download; 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 f383b61f4..c75e66232 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers; 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 35133fe4d..5120a925d 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers; 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 337dbdff1..9db222ef7 100644 --- 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 @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers; 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 194e57019..3eb4c207b 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers; 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 ac1e4f4eb..0cf50d6db 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers; 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 ac2dc1146..993765c10 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.forge; @@ -34,7 +35,7 @@ import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.launcher.version.MinecraftLibrary; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; /** * 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 ee0b5edb0..3ddc8ac8d 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.forge; 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 1110be42c..26d43d05b 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.forge; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/Downloads.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/Downloads.java index 2d947e343..29373a495 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/Downloads.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/Downloads.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.forge.bmcl; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/ForgeBMCLVersionList.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/ForgeBMCLVersionList.java index 8736184a4..e80fd5ef2 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/ForgeBMCLVersionList.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/ForgeBMCLVersionList.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.forge.bmcl; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/ForgeVersion.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/ForgeVersion.java index d6c1d9507..ff2f906fb 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/ForgeVersion.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/bmcl/ForgeVersion.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.forge.bmcl; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersion.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersion.java index 4ded15798..5f0b59d5a 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersion.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersion.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.forge.vanilla; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersionList.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersionList.java index f51950ad5..cebfe2500 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersionList.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersionList.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.forge.vanilla; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersionRoot.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersionRoot.java index 76753df30..a0c77558b 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersionRoot.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/forge/vanilla/MinecraftForgeVersionRoot.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.forge.vanilla; 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 0c4ff5500..beeaf52c6 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.liteloader; 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 cc92dad20..0d3e98254 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.liteloader; 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 086e00fa3..50254960f 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.liteloader; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionList.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionList.java index c52987998..5a2ca3d29 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionList.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/liteloader/LiteLoaderVersionList.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.liteloader; 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 4350fbffa..089994243 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.liteloader; 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 488cb64c5..07874eced 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.liteloader; 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 f4e81a328..f483d8b45 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.optifine; 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 8ff0fbdc8..11e24ff5c 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.optifine; 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 d5e81c6a9..1c32f34db 100644 --- 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 @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.optifine.bmcl; 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 a09a901f9..edfc8dc2e 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.optifine.vanilla; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/vanilla/OptiFineVersionList.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/vanilla/OptiFineVersionList.java index 4dc52aafa..eeb340cdb 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/vanilla/OptiFineVersionList.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/installers/optifine/vanilla/OptiFineVersionList.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.installers.optifine.vanilla; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/Upgrader.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/Upgrader.java index f5038ed75..a31bb81a1 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/Upgrader.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/upgrade/Upgrader.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.utils.upgrade; 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 fac71dedf..3475cfb5b 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; 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 d2a554070..be73a029b 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; 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 f56ad4578..1fe30ba88 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; 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 2ee5279a7..979521059 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; 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 aa377432c..ee22985bd 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftModService.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftModService.java index 6402ab99b..866cacc69 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftModService.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftModService.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; 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 5da811836..59ccb3c99 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftService.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftService.java index 60947aaca..1ea1657d5 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftService.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftService.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; 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 e1b4d75e5..b0226f7e4 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; 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 b51f1c9b6..bb421c088 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftVersionManager.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/version/MinecraftVersionManager.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; @@ -39,7 +40,7 @@ import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType; import org.jackhuang.hellominecraft.launcher.settings.Profile; import org.jackhuang.hellominecraft.launcher.settings.Settings; import org.jackhuang.hellominecraft.utils.system.IOUtils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.Utils; /** 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 f882dd4e7..445225fc2 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; 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 933684e60..4ecea0e41 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; 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 6309dbba4..a70aeeeb7 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.version; 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 63bf09787..4cbc0670d 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/DraggableFrame.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/DraggableFrame.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.views; 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 e7d73d419..5a095b033 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameSettingsPanel.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameSettingsPanel.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.views; @@ -64,7 +65,7 @@ import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.tasks.communication.DefaultPreviousResult; import org.jackhuang.hellominecraft.tasks.download.HTTPGetTask; import org.jackhuang.hellominecraft.utils.system.IOUtils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.version.MinecraftVersionRequest; import org.jackhuang.hellominecraft.utils.system.OS; import org.jackhuang.hellominecraft.utils.StrUtils; 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 402b0b91b..90d82247a 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.views; 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 54e52923d..0d635b76f 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/LauncherSettingsPanel.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/LauncherSettingsPanel.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.views; @@ -26,7 +27,7 @@ import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.launcher.settings.Settings; import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType; import org.jackhuang.hellominecraft.utils.system.IOUtils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; /** * 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 a41e0c8ec..df7830a0b 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/MainFrame.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/MainFrame.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.views; @@ -62,7 +63,7 @@ public final class MainFrame extends DraggableFrame { LauncherSettingsPanel launcherPanel; CardLayout infoLayout; JPanel infoSwap; - JPanel launcherPanelWrapper, gamePanelWrapper; + JPanel mainPanelWrapper, launcherPanelWrapper, gamePanelWrapper; JLabel backgroundLabel, windowTitle; JPanel realPanel; DropShadowBorder border; @@ -221,8 +222,9 @@ public final class MainFrame extends DraggableFrame { this.infoSwap.setLayout(infoLayout); this.infoSwap.setOpaque(false); - this.mainPanel = new MainPagePanel(); - this.infoSwap.add(mainPanel, "main"); + mainPanelWrapper = new JPanel(); + mainPanelWrapper.setLayout(new GridLayout()); + this.infoSwap.add(mainPanelWrapper, "main"); gamePanelWrapper = new JPanel(); gamePanelWrapper.setLayout(new GridLayout()); this.infoSwap.add(gamePanelWrapper, "game"); @@ -247,6 +249,10 @@ public final class MainFrame extends DraggableFrame { this.launcherTab.setIsActive(false); if (tabName.equalsIgnoreCase("main")) { + if (mainPanel == null) { + mainPanel = new MainPagePanel(); + mainPanelWrapper.add(mainPanel); + } this.mainTab.setIsActive(true); this.mainPanel.onSelected(); } else if (tabName.equalsIgnoreCase("game")) { diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/MainPagePanel.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/MainPagePanel.java index 47bc6ce38..cab3198c8 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/MainPagePanel.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/MainPagePanel.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.views; @@ -30,7 +31,7 @@ import org.jackhuang.hellominecraft.launcher.launch.DefaultGameLauncher; import org.jackhuang.hellominecraft.launcher.utils.auth.IAuthenticator; import org.jackhuang.hellominecraft.launcher.utils.auth.LoginInfo; import org.jackhuang.hellominecraft.launcher.settings.Profile; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion; import org.jackhuang.hellominecraft.launcher.launch.GameLauncher; @@ -423,7 +424,7 @@ public class MainPagePanel extends javax.swing.JPanel { if (0 <= loginType && loginType < cboLoginMode.getItemCount()) { preaparingAuth = false; - cboLoginMode.setSelectedIndex(loginType); + //cboLoginMode.setSelectedIndex(loginType); cboLoginModeItemStateChanged(null); } diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/NewProfileWindow.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/NewProfileWindow.java index 12dda0599..b44bbf235 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/NewProfileWindow.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/NewProfileWindow.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.launcher.views; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/C.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/C.java index 3775e2ed1..714c7da07 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/C.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/C.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/HMCLog.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/HMCLog.java index 6c6b0100e..29cfe614f 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/HMCLog.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/HMCLog.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft; 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 ac9e1290d..074ff6545 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/AppenderControl.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/AppenderControl.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/Configuration.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/Configuration.java index 39e8e36d9..8cff673df 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/Configuration.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/Configuration.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging; 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 2d715e1f9..fd26bbe51 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/Level.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/Level.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging; 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 3f620ecbb..0a2d8d54c 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LogEvent.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LogEvent.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging; 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 0fb34dfd1..1433e8e36 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LoggingException.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/LoggingException.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging; 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 12eca7f67..1c2913164 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.appender; 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 87a0b5b44..c73f11cb7 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.appender; 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 54ae06e3b..1cfd9f0e3 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.appender; 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 77afaa6a9..d441d9fb0 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.appender; 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 873cb5181..f61a37f38 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.layout; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/DefaultLayout.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/DefaultLayout.java index 847bfe87d..d7dc04b38 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/DefaultLayout.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/layout/DefaultLayout.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.layout; 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 27888f79e..0e59162f2 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.layout; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/AbstractLogger.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/AbstractLogger.java index 412f748fb..76a8aa926 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/AbstractLogger.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/AbstractLogger.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.logger; 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 9e0e1bcd8..75e6952d9 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.logger; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/Logger.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/Logger.java index e9477cea4..77151d8d7 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/Logger.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/Logger.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.logger; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/SimpleLogger.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/SimpleLogger.java index 5972c143a..c507f9e0b 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/SimpleLogger.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/logger/SimpleLogger.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.logger; 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 347c8d6a7..b6b1446d3 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.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 7bbdf016c..66f77859b 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.message; 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 906fd943e..30ef0d10d 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.message; 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 975ebb700..f12d1f5e3 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.message; 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 620f099b7..7348acf96 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ParameterizedMessage.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/logging/message/ParameterizedMessage.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.message; 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 b0ce2e611..719d5e2c9 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.message; 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 01bd73b3a..061074950 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.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 5b4ca1896..58ec309d4 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.logging.message; 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 1c0f9edcf..8fc04d94f 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DoingDoneListener.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/DoingDoneListener.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks; 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 d353295aa..ab0717a43 100644 --- 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,19 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks; 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 0e525c0ec..312d14c89 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ParallelTask.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ParallelTask.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks; 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 b19630107..c9492de86 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ProgressProviderListener.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/ProgressProviderListener.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks; 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 7702d3d22..52160532e 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/Task.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/Task.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks; 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 3fc98d8e6..341eb497b 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskInfo.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskInfo.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskList.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskList.java index 497235954..bfff52ad4 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskList.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskList.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks; 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 1c038eb24..1b0b31fed 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnable.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnable.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks; 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 91d7d90b7..286c94f38 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnableArg1.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskRunnableArg1.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskWindow.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskWindow.java index 8d4e2badb..a44e59264 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskWindow.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/tasks/TaskWindow.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks; @@ -21,7 +22,7 @@ import java.util.LinkedList; import javax.swing.SwingUtilities; import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.HMCLog; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.SwingUtils; 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 444a1c1ae..03711a39e 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks.communication; 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 c63a38e6b..36447180f 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks.communication; 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 acea1064e..f11588f2a 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks.communication; 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 1f657ca01..26e5ffdf6 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks.download; 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 20779d880..a2c7834e4 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks.download; 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 4eb0dbb6e..8ab99520e 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks.download; 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 29934c946..2aa74b9cd 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks.download; 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 b3e5cb0a5..30ec3d31c 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.tasks.download; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/ArrayUtils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/ArrayUtils.java index 75f99fd4e..ccee9222e 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/ArrayUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/ArrayUtils.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; 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 95101f552..b2dc1d33b 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/CollectionUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/CollectionUtils.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; 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 46b7748fd..fd5639ff2 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/DoubleOutputStream.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/DoubleOutputStream.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; 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 50a98accf..46b6bf61e 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Event.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Event.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/EventHandler.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/EventHandler.java index 9d3055854..3048ba5a6 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/EventHandler.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/EventHandler.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; 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 fda09cc75..b9ee35dab 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/LauncherPrintStream.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/LauncherPrintStream.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/LogWindowOutputStream.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/LogWindowOutputStream.java index bfa5c8320..f088f5f03 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/LogWindowOutputStream.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/LogWindowOutputStream.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; 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 57d203986..7f274bfd3 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/MathUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/MathUtils.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/MessageBox.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/MessageBox.java similarity index 88% rename from HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/MessageBox.java rename to HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/MessageBox.java index 68bae67b8..9df71981e 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/MessageBox.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/MessageBox.java @@ -1,20 +1,21 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ -package org.jackhuang.hellominecraft.utils.system; +package org.jackhuang.hellominecraft.utils; import javax.swing.JOptionPane; import org.jackhuang.hellominecraft.C; 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 58d62cbbe..99ef7df79 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/NetUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/NetUtils.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; 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 74699f6f9..f1ed387a0 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Pair.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Pair.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; 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 440c42ec3..9129e7178 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/StrUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/StrUtils.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/SwingUtils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/SwingUtils.java index 415ca3436..2e50afa3d 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/SwingUtils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/SwingUtils.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/UpdateChecker.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/UpdateChecker.java index d84c93505..23f741452 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/UpdateChecker.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/UpdateChecker.java @@ -1,23 +1,23 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; import java.util.Map; -import org.jackhuang.hellominecraft.utils.system.MessageBox; import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.HMCLog; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Utils.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Utils.java index bfdb06a84..11d0af561 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Utils.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/Utils.java @@ -1,32 +1,30 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; import com.sun.management.OperatingSystemMXBean; import java.awt.Desktop; import java.awt.Image; import java.awt.Toolkit; import java.awt.datatransfer.StringSelection; import java.io.File; -import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.management.ManagementFactory; -import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URI; @@ -55,25 +53,6 @@ public final class Utils { return urlStrings; } - public static void addDir(String s) throws IOException { - try { - Field field = ClassLoader.class.getDeclaredField("usr_paths"); - field.setAccessible(true); - String[] paths = (String[]) field.get(null); - for (String path : paths) - if (s.equals(path)) - return; - String[] tmp = new String[paths.length + 1]; - System.arraycopy(paths, 0, tmp, 0, paths.length); - tmp[paths.length] = s; - field.set(null, tmp); - } catch (IllegalAccessException e) { - throw new IOException("Failed to get permissions to set library path"); - } catch (NoSuchFieldException e) { - throw new IOException("Failed to get field handle to set library path"); - } - } - public static int getSuggestedMemorySize() { try { OperatingSystemMXBean osmb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); 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 08c0ea415..285d501ad 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/VersionNumber.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/VersionNumber.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils; 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 6390260d4..dcf959f92 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.code; 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 59279ca4d..08ac8c999 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.code; 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 6f2224180..a8f3b58fa 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.code; 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 17ae667e7..c06577ad2 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.code; 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 aa7a5c620..e04298187 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.functions; 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 f712f7f9b..7db06c3b5 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.functions; 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 c72276a1e..a014b4f22 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.functions; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/FalseFunction.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/FalseFunction.java deleted file mode 100644 index 12008a769..000000000 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/FalseFunction.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 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 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. - */ -package org.jackhuang.hellominecraft.utils.functions; - -/** - * - * @author huangyuhui - */ -public class FalseFunction implements NonFunction { - - @Override - public Boolean apply() { - return Boolean.FALSE; - } - -} 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 ae5d65f5c..dc5e21415 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.functions; 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 1e8f0cada..af9810754 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.functions; 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 c0283975c..f9dc1bfe4 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.functions; 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 76577ae59..a5e7f9c9c 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.functions; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/TrueFunction.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/TrueFunction.java deleted file mode 100644 index 44eb688e7..000000000 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/functions/TrueFunction.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 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 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. - */ -package org.jackhuang.hellominecraft.utils.functions; - -/** - * - * @author huangyuhui - */ -public class TrueFunction implements NonFunction { - - public static final TrueFunction instance = new TrueFunction(); - - private TrueFunction() { - } - - @Override - public Boolean apply() { - return Boolean.TRUE; - } - -} 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 7e1545ba7..928334edc 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; 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 e7a63fd63..0bb561e19 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; 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 f4cd8fb7c..685de775f 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; 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 f3cdda42d..f38aab164 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; 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 ab3babd0c..d01c9fae7 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JavaProcessMonitor.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JavaProcessMonitor.java index c28cb4814..e221c66b6 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JavaProcessMonitor.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/JavaProcessMonitor.java @@ -1,21 +1,23 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; +import org.jackhuang.hellominecraft.utils.MessageBox; import java.util.Arrays; import java.util.HashSet; import org.jackhuang.hellominecraft.C; 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 23170daeb..7c578ea29 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/OS.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/OS.java index 997f47664..7caf0c133 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/OS.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/system/OS.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; 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 ed16e62fd..ab7075f69 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; 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 5bd091f3f..bdab99b68 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; @@ -24,19 +25,19 @@ import java.util.HashSet; */ public class ProcessManager { - private static final HashSet gameProcesses = new HashSet(); + private static final HashSet GAME_PROCESSES = new HashSet(); public void registerProcess(JavaProcess jp) { - gameProcesses.add(jp); + GAME_PROCESSES.add(jp); } public void stopAllProcesses() { - for (JavaProcess jp : gameProcesses) + for (JavaProcess jp : GAME_PROCESSES) jp.stop(); - gameProcesses.clear(); + GAME_PROCESSES.clear(); } public void onProcessStopped(JavaProcess p) { - gameProcesses.remove(p); + GAME_PROCESSES.remove(p); } } 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 e3fec450b..a3831e065 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; 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 59edbd9f1..da4ca7ca2 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.utils.system; 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 d62b1da1c..b0f5e16e7 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteLatestVersion.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteLatestVersion.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.version; 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 a9bb56d96..601c3efe0 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersion.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersion.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.version; 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 5369812d0..a830287a6 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersions.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftRemoteVersions.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.version; 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 a82fdbb2b..755f9c94a 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftVersionRequest.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/version/MinecraftVersionRequest.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.version; @@ -23,35 +24,35 @@ import org.jackhuang.hellominecraft.C; */ public class MinecraftVersionRequest { - public static final int Unkown = 0, Invaild = 1, InvaildJar = 2, - Modified = 3, OK = 4, NotFound = 5, NotReadable = 6, NotAFile = 7; + public static final int UNKOWN = 0, INVALID = 1, INVALID_JAR = 2, + 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.Invaild: + case MinecraftVersionRequest.INVALID: text = C.i18n("minecraft.invalid"); break; - case MinecraftVersionRequest.InvaildJar: + case MinecraftVersionRequest.INVALID_JAR: text = C.i18n("minecraft.invalid_jar"); break; - case MinecraftVersionRequest.NotAFile: + case MinecraftVersionRequest.NOT_FILE: text = C.i18n("minecraft.not_a_file"); break; - case MinecraftVersionRequest.NotFound: + case MinecraftVersionRequest.NOT_FOUND: text = C.i18n("minecraft.not_found"); break; - case MinecraftVersionRequest.NotReadable: + case MinecraftVersionRequest.UNREADABLE: text = C.i18n("minecraft.not_readable"); break; - case MinecraftVersionRequest.Modified: + case MinecraftVersionRequest.MODIFIED: text = C.i18n("minecraft.modified") + " "; case MinecraftVersionRequest.OK: text += minecraftVersion.version; break; - case MinecraftVersionRequest.Unkown: + case MinecraftVersionRequest.UNKOWN: default: text = "???"; break; 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 d9715f8f1..b66d2c5cd 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/AbstractFilter.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/AbstractFilter.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.views; 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 38797e434..aedce9ec9 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/BasicColors.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/BasicColors.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.views; 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 af6292849..04a48f4d9 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/DropShadowBorder.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/DropShadowBorder.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.views; 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 1029e7c66..ac8a740db 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/FastBlurFilter.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/FastBlurFilter.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.views; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/LogWindow.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/LogWindow.java index c7b1e937d..ef2b2077f 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/LogWindow.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/LogWindow.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.views; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/Selector.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/Selector.java index 68ac63219..c2c1b394e 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/Selector.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/Selector.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.views; 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 f54bf7841..06e058df1 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/TintablePanel.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/views/TintablePanel.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.views; diff --git a/HMCLAPI/src/main/java/rx/Notification.java b/HMCLAPI/src/main/java/rx/Notification.java new file mode 100644 index 000000000..08c6113ec --- /dev/null +++ b/HMCLAPI/src/main/java/rx/Notification.java @@ -0,0 +1,161 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx; + +/** + * An object representing a notification sent to an {@link Observable}. + * + * For the Microsoft Rx equivalent see: http://msdn.microsoft.com/en-us/library/hh229462(v=vs.103).aspx + */ +public class Notification { + + private final Kind kind; + private final Exception exception; + private final T value; + + /** + * A constructor used to represent an onNext notification. + * + * @param value + * The data passed to the onNext method. + */ + public Notification(T value) { + this.value = value; + this.exception = null; + this.kind = Kind.OnNext; + } + + /** + * A constructor used to represent an onError notification. + * + * @param exception + * The exception passed to the onError notification. + */ + public Notification(Exception exception) { + this.exception = exception; + this.value = null; + this.kind = Kind.OnError; + } + + /** + * A constructor used to represent an onCompleted notification. + */ + public Notification() { + this.exception = null; + this.value = null; + this.kind = Kind.OnCompleted; + } + + /** + * Retrieves the exception associated with an onError notification. + * + * @return The exception associated with an onError notification. + */ + public Exception getException() { + return exception; + } + + /** + * Retrieves the data associated with an onNext notification. + * + * @return The data associated with an onNext notification. + */ + public T getValue() { + return value; + } + + /** + * Retrieves a value indicating whether this notification has a value. + * + * @return a value indicating whether this notification has a value. + */ + public boolean hasValue() { + return isOnNext() && value != null; + } + + /** + * Retrieves a value indicating whether this notification has an exception. + * + * @return a value indicating whether this notification has an exception. + */ + public boolean hasException() { + return isOnError() && exception != null; + } + + /** + * The kind of notification: OnNext, OnError, OnCompleted + * + * @return + */ + public Kind getKind() { + return kind; + } + + public boolean isOnError() { + return getKind() == Kind.OnError; + } + + public boolean isOnCompleted() { + return getKind() == Kind.OnCompleted; + } + + public boolean isOnNext() { + return getKind() == Kind.OnNext; + } + + public static enum Kind { + OnNext, OnError, OnCompleted + } + + @Override + public String toString() { + StringBuilder str = new StringBuilder("[").append(super.toString()).append(" ").append(getKind()); + if (hasValue()) + str.append(" ").append(getValue()); + if (hasException()) + str.append(" ").append(getException().getMessage()); + str.append("]"); + return str.toString(); + } + + @Override + public int hashCode() { + int hash = getKind().hashCode(); + if (hasValue()) + hash = hash * 31 + getValue().hashCode(); + if (hasException()) + hash = hash * 31 + getException().hashCode(); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) + return false; + if (this == obj) + return true; + if (obj.getClass() != getClass()) + return false; + Notification notification = (Notification) obj; + if (notification.getKind() != getKind()) + return false; + if (hasValue() && !getValue().equals(notification.getValue())) + return false; + if (hasException() && !getException().equals(notification.getException())) + return false; + return true; + } +} diff --git a/HMCLAPI/src/main/java/rx/Observable.java b/HMCLAPI/src/main/java/rx/Observable.java new file mode 100644 index 000000000..a460f1ab7 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/Observable.java @@ -0,0 +1,3273 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +import rx.observables.GroupedObservable; +import rx.operators.OperationAll; +import rx.operators.OperationConcat; +import rx.operators.OperationDefer; +import rx.operators.OperationDematerialize; +import rx.operators.OperationFilter; +import rx.operators.OperationFinally; +import rx.operators.OperationMap; +import rx.operators.OperationMaterialize; +import rx.operators.OperationMerge; +import rx.operators.OperationMergeDelayError; +import rx.operators.OperationMostRecent; +import rx.operators.OperationNext; +import rx.operators.OperationObserveOn; +import rx.operators.OperationOnErrorResumeNextViaFunction; +import rx.operators.OperationOnErrorResumeNextViaObservable; +import rx.operators.OperationOnErrorReturn; +import rx.operators.OperationScan; +import rx.operators.OperationSkip; +import rx.operators.OperationSubscribeOn; +import rx.operators.OperationSynchronize; +import rx.operators.OperationTake; +import rx.operators.OperationTakeLast; +import rx.operators.OperationTakeWhile; +import rx.operators.OperationToObservableFuture; +import rx.operators.OperationToObservableIterable; +import rx.operators.OperationToObservableList; +import rx.operators.OperationToObservableSortedList; +import rx.operators.OperationWhere; +import rx.operators.OperationZip; +import rx.operators.OperatorGroupBy; +import rx.operators.OperatorTakeUntil; +import rx.operators.OperatorToIterator; +import rx.plugins.RxJavaErrorHandler; +import rx.plugins.RxJavaObservableExecutionHook; +import rx.plugins.RxJavaPlugins; +import rx.subscriptions.Subscriptions; +import rx.util.AtomicObservableSubscription; +import rx.util.AtomicObserver; +import rx.util.Range; +import rx.util.functions.Action0; +import rx.util.functions.Action1; +import rx.util.functions.Func0; +import rx.util.functions.Func1; +import rx.util.functions.Func2; +import rx.util.functions.Func3; +import rx.util.functions.Func4; +import rx.util.functions.FuncN; +import rx.util.functions.Function; +import rx.util.functions.FunctionLanguageAdaptor; +import rx.util.functions.Functions; + +/** + * The Observable interface that implements the Reactive Pattern. + *

+ * It provides overloaded methods for subscribing as well as delegate methods to the various operators. + *

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

+ * + *

+ * For more information see the RxJava Wiki + * + * @param + */ +public class Observable { + + private final static RxJavaObservableExecutionHook HOOK = RxJavaPlugins.getInstance().getObservableExecutionHook(); + + private final Func1, Subscription> onSubscribe; + + protected Observable() { + this(null); + } + + /** + * Construct an Observable with Function to execute when subscribed to. + *

+ * 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. + */ + protected Observable(Func1, Subscription> onSubscribe) { + this.onSubscribe = onSubscribe; + } + + /** + * 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 + * subscribe method does the following: + *

+ * It stores a reference to the Observer in a collection object, such as a 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. + *

+ * 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. + *

+ * For more information see the RxJava Wiki + * + * + * @param observer + * @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 + Func1, Subscription> onSubscribeFunction = HOOK.onSubscribeStart(this, onSubscribe); + // validate and proceed + if (onSubscribeFunction == null) { + throw new IllegalStateException("onSubscribe function can not be null."); + // the subscribe function can also be overridden but generally that's not the appropriate approach so I won't mention that in the exception + } + try { + /** + * See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + */ + if (isInternalImplementation(observer)) { + Subscription s = onSubscribeFunction.call(observer); + if (s == null) { + // this generally shouldn't be the case on a 'trusted' onSubscribe but in case it happens + // we want to gracefully handle it the same as AtomicObservableSubscription does + return HOOK.onSubscribeReturn(this, Subscriptions.empty()); + } else { + return HOOK.onSubscribeReturn(this, s); + } + } else { + AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + subscription.wrap(onSubscribeFunction.call(new AtomicObserver<>(subscription, observer))); + return HOOK.onSubscribeReturn(this, subscription); + } + } catch (Exception e) { + // if an unhandled error occurs executing the onSubscribe we will propagate it + try { + observer.onError(HOOK.onSubscribeError(this, e)); + } catch (Exception e2) { + // if this happens it means the onError itself failed (perhaps an invalid function implementation) + // so we are unable to propagate the error correctly and will just throw + RuntimeException r = new RuntimeException("Error occurred attempting to subscribe [" + e.getMessage() + "] and then again while trying to pass to onError.", e2); + HOOK.onSubscribeError(this, r); + throw r; + } + return Subscriptions.empty(); + } + } + + /** + * 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 + * subscribe method does the following: + *

+ * It stores a reference to the Observer in a collection object, such as a 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. + *

+ * 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. + *

+ * For more information see the RxJava Wiki + * + * + * @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 + */ + public Subscription subscribe(Observer observer, Scheduler scheduler) { + return subscribeOn(scheduler).subscribe(observer); + } + + /** + * Used for protecting against errors being thrown from Observer implementations and ensuring onNext/onError/onCompleted contract compliance. + *

+ * See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + */ + private Subscription protectivelyWrapAndSubscribe(Observer o) { + AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + return subscription.wrap(subscribe(new AtomicObserver<>(subscription, o))); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Subscription subscribe(final Map callbacks) { + // lookup and memoize onNext + Object _onNext = callbacks.get("onNext"); + if (_onNext == null) { + throw new RuntimeException("onNext must be implemented"); + } + final FuncN onNext = Functions.from(_onNext); + + /** + * Wrapping since raw functions provided by the user are being invoked. + * + * See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + */ + return protectivelyWrapAndSubscribe(new Observer() { + + @Override + public void onCompleted() { + Object onComplete = callbacks.get("onCompleted"); + if (onComplete != null) { + Functions.from(onComplete).call(); + } + } + + @Override + public void onError(Exception e) { + handleError(e); + Object onError = callbacks.get("onError"); + if (onError != null) { + Functions.from(onError).call(e); + } + } + + @Override + public void onNext(Object args) { + onNext.call(args); + } + + }); + } + + public Subscription subscribe(final Map callbacks, Scheduler scheduler) { + return subscribeOn(scheduler).subscribe(callbacks); + } + + @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. + return subscribe((Observer) o); + } + + // lookup and memoize onNext + if (o == null) { + throw new RuntimeException("onNext must be implemented"); + } + final FuncN onNext = Functions.from(o); + + /** + * Wrapping since raw functions provided by the user are being invoked. + * + * See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + */ + return protectivelyWrapAndSubscribe(new Observer() { + + @Override + public void onCompleted() { + // do nothing + } + + @Override + public void onError(Exception e) { + handleError(e); + // no callback defined + } + + @Override + public void onNext(Object args) { + onNext.call(args); + } + + }); + } + + public Subscription subscribe(final Object o, Scheduler scheduler) { + return subscribeOn(scheduler).subscribe(o); + } + + public Subscription subscribe(final Action1 onNext) { + + /** + * Wrapping since raw functions provided by the user are being invoked. + * + * See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + */ + return protectivelyWrapAndSubscribe(new Observer() { + + @Override + public void onCompleted() { + // do nothing + } + + @Override + public void onError(Exception e) { + handleError(e); + // no callback defined + } + + @Override + public void onNext(T args) { + if (onNext == null) { + throw new RuntimeException("onNext must be implemented"); + } + onNext.call(args); + } + + }); + } + + public Subscription subscribe(final Action1 onNext, Scheduler scheduler) { + return subscribeOn(scheduler).subscribe(onNext); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Subscription subscribe(final Object onNext, final Object onError) { + // lookup and memoize onNext + if (onNext == null) { + throw new RuntimeException("onNext must be implemented"); + } + final FuncN onNextFunction = Functions.from(onNext); + + /** + * Wrapping since raw functions provided by the user are being invoked. + * + * See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + */ + return protectivelyWrapAndSubscribe(new Observer() { + + @Override + public void onCompleted() { + // do nothing + } + + @Override + public void onError(Exception e) { + handleError(e); + if (onError != null) { + Functions.from(onError).call(e); + } + } + + @Override + public void onNext(Object args) { + onNextFunction.call(args); + } + + }); + } + + public Subscription subscribe(final Object onNext, final Object onError, Scheduler scheduler) { + return subscribeOn(scheduler).subscribe(onNext, onError); + } + + public Subscription subscribe(final Action1 onNext, final Action1 onError) { + + /** + * Wrapping since raw functions provided by the user are being invoked. + * + * See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + */ + return protectivelyWrapAndSubscribe(new Observer() { + + @Override + public void onCompleted() { + // do nothing + } + + @Override + public void onError(Exception e) { + handleError(e); + if (onError != null) { + onError.call(e); + } + } + + @Override + public void onNext(T args) { + if (onNext == null) { + throw new RuntimeException("onNext must be implemented"); + } + onNext.call(args); + } + + }); + } + + public Subscription subscribe(final Action1 onNext, final Action1 onError, Scheduler scheduler) { + return subscribeOn(scheduler).subscribe(onNext, onError); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Subscription subscribe(final Object onNext, final Object onError, final Object onComplete) { + // lookup and memoize onNext + if (onNext == null) { + throw new RuntimeException("onNext must be implemented"); + } + final FuncN onNextFunction = Functions.from(onNext); + + /** + * Wrapping since raw functions provided by the user are being invoked. + * + * See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + */ + return protectivelyWrapAndSubscribe(new Observer() { + + @Override + public void onCompleted() { + if (onComplete != null) { + Functions.from(onComplete).call(); + } + } + + @Override + public void onError(Exception e) { + handleError(e); + if (onError != null) { + Functions.from(onError).call(e); + } + } + + @Override + public void onNext(Object args) { + onNextFunction.call(args); + } + + }); + } + + public Subscription subscribe(final Object onNext, final Object onError, final Object onComplete, Scheduler scheduler) { + return subscribeOn(scheduler).subscribe(onNext, onError, onComplete); + } + + public Subscription subscribe(final Action1 onNext, final Action1 onError, final Action0 onComplete) { + + /** + * Wrapping since raw functions provided by the user are being invoked. + * + * See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + */ + return protectivelyWrapAndSubscribe(new Observer() { + + @Override + public void onCompleted() { + onComplete.call(); + } + + @Override + public void onError(Exception e) { + handleError(e); + if (onError != null) { + onError.call(e); + } + } + + @Override + public void onNext(T args) { + if (onNext == null) { + throw new RuntimeException("onNext must be implemented"); + } + onNext.call(args); + } + + }); + } + + public Subscription subscribe(final Action1 onNext, final Action1 onError, final Action0 onComplete, Scheduler scheduler) { + return subscribeOn(scheduler).subscribe(onNext, onError, onComplete); + } + + /** + * Invokes an action for each element in the observable sequence, and blocks until the sequence is terminated. + *

+ * NOTE: This will block even if the Observable is asynchronous. + *

+ * This is similar to {@link #subscribe(Observer)} but blocks. Because it blocks it does not need the {@link Observer#onCompleted()} or {@link Observer#onError(Exception)} methods. + * + * @param onNext + * {@link Action1} + * @throws RuntimeException + * if error occurs + */ + public void forEach(final Action1 onNext) { + final CountDownLatch latch = new CountDownLatch(1); + final AtomicReference exceptionFromOnError = new AtomicReference<>(); + + /** + * Wrapping since raw functions provided by the user are being invoked. + * + * See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + */ + protectivelyWrapAndSubscribe(new Observer() { + @Override + public void onCompleted() { + latch.countDown(); + } + + @Override + public void onError(Exception e) { + /* + * 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. + */ + exceptionFromOnError.set(e); + latch.countDown(); + } + + @Override + public void onNext(T args) { + onNext.call(args); + } + }); + // block until the subscription completes and then return + try { + latch.await(); + } catch (InterruptedException e) { + // set the interrupted flag again so callers can still get it + // for more information see https://github.com/Netflix/RxJava/pull/147#issuecomment-13624780 + Thread.currentThread().interrupt(); + // using Runtime so it is not checked + throw new RuntimeException("Interrupted while waiting for subscription to complete.", e); + } + + if (exceptionFromOnError.get() != null) { + if (exceptionFromOnError.get() instanceof RuntimeException) { + throw (RuntimeException) exceptionFromOnError.get(); + } else { + throw new RuntimeException(exceptionFromOnError.get()); + } + } + } + + /** + * Invokes an action for each element in the observable sequence, and blocks until the sequence is terminated. + *

+ * NOTE: This will block even if the Observable is asynchronous. + *

+ * This is similar to {@link #subscribe(Observer)} but blocks. Because it blocks it does not need the {@link Observer#onCompleted()} or {@link Observer#onError(Exception)} methods. + * + * @param o + * {@link Action1} + * @throws RuntimeException + * if error occurs + */ + @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. + forEach((Action1) o); + } + + // lookup and memoize onNext + if (o == null) { + throw new RuntimeException("onNext must be implemented"); + } + final FuncN onNext = Functions.from(o); + + forEach(onNext::call); + } + + /** + * Returns the only element of an observable sequence and throws an exception if there is not exactly one element in the observable sequence. + * + * @return The single element in the observable sequence. + */ + public T single() { + return single(this); + } + + /** + * Returns the only element of an observable sequence that matches the 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. + * @return The single element in the observable sequence. + */ + public T single(Func1 predicate) { + return single(this, predicate); + } + + /** + * Returns the only element of an observable sequence that matches the 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. + * @return The single element in the observable sequence. + */ + public T single(Object predicate) { + return single(this, predicate); + } + + /** + * 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. + * @return The single element in the observable sequence, or a default value if no value is found. + */ + public T singleOrDefault(T defaultValue) { + return singleOrDefault(this, defaultValue); + } + + /** + * 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. + * @return The single element in the observable sequence, or a default value if no value is found. + */ + public T singleOrDefault(T defaultValue, Func1 predicate) { + return singleOrDefault(this, defaultValue, predicate); + } + + /** + * 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. + * @return The single element in the observable sequence, or a default value if no value is found. + */ + public T singleOrDefault(T defaultValue, Object predicate) { + return singleOrDefault(this, defaultValue, predicate); + } + + /** + * Allow the {@link RxJavaErrorHandler} to receive the exception from onError. + * + * @param e + */ + private void handleError(Exception e) { + // onError should be rare so we'll only fetch when needed + RxJavaPlugins.getInstance().getErrorHandler().handleError(e); + } + + /** + * An Observable that never sends any information to an {@link Observer}. + * + * This Observable is useful primarily for testing purposes. + * + * @param + * the type of item emitted by the Observable + */ + private static class NeverObservable extends Observable { + public NeverObservable() { + super((Observer t1) -> Subscriptions.empty()); + } + } + + /** + * an Observable that calls {@link Observer#onError(Exception)} when the Observer subscribes. + * + * @param + * the type of object returned by the Observable + */ + private static class ThrowObservable extends Observable { + + public ThrowObservable(final Exception exception) { + /** + * Accepts an {@link Observer} and calls its onError method. + * + * @param observer + * an {@link Observer} of this Observable + * @return a reference to the subscription + */ + super((Observer observer) -> { + observer.onError(exception); + return Subscriptions.empty(); + }); + } + + } + + /** + * Creates an Observable that will execute the given function when a {@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. + *

+ * A well-formed Observable must call either the {@link Observer}'s onCompleted method exactly once or its onError method exactly once. + *

+ * 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) + * @return an Observable that, when an {@link Observer} subscribes to it, will execute the given function + */ + public static Observable create(Func1, Subscription> func) { + return new Observable<>(func); + } + + /** + * Creates an Observable that will execute the given function when a {@link Observer} subscribes to it. + *

+ * This method accept {@link Object} to allow different languages to pass in 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. + *

+ * A well-formed Observable must call either the {@link Observer}'s onCompleted method exactly once or its onError method exactly once. + *

+ * 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) + * @return an Observable that, when an {@link Observer} subscribes to it, will execute the given function + */ + public static Observable create(final Object func) { + final FuncN _f = Functions.from(func); + return create((Observer t1) -> (Subscription) _f.call(t1)); + } + + /** + * Returns an Observable that returns no data to the {@link Observer} and immediately invokes its onCompleted method. + *

+ * + * + * @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 + */ + public static Observable empty() { + return toObservable(new ArrayList()); + } + + /** + * Returns an Observable that calls onError when an {@link Observer} subscribes to it. + *

+ * + * @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 + */ + public static Observable error(Exception exception) { + return new ThrowObservable<>(exception); + } + + /** + * Filters an Observable by discarding any of its emissions that do not meet some test. + *

+ * + * + * @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 + */ + public static Observable filter(Observable that, Func1 predicate) { + return create(OperationFilter.filter(that, predicate)); + } + + /** + * Filters an Observable by discarding any of its emissions that do not meet some test. + *

+ * + * + * @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 + */ + public static Observable filter(Observable that, final Object function) { + final FuncN _f = Functions.from(function); + return filter(that, (T t1) -> (Boolean) _f.call(t1)); + } + + /** + * Filters an Observable by discarding any of its emissions that do not meet some test. + *

+ * + * + * @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 + */ + public static Observable where(Observable that, Func1 predicate) { + return create(OperationWhere.where(that, predicate)); + } + + /** + * 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 + * @return an Observable that emits each item in the source {@link Iterable} sequence + * @see {@link #toObservable(Iterable)} + */ + public static Observable from(Iterable iterable) { + return toObservable(iterable); + } + + /** + * 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 + * @return an Observable that emits each item in the source Array + * @see {@link #toObservable(Object...)} + */ + public static Observable from(T... items) { + return toObservable(items); + } + + /** + * 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. + * + * @return An observable sequence that contains a range of sequential integral numbers. + * + * @see Observable.Range Method (Int32, Int32) + */ + public static Observable range(int start, int count) { + return from(Range.createWithCount(start, count)); + } + + /** + * 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. + * @return the source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. + */ + public static Observable subscribeOn(Observable source, Scheduler scheduler) { + return create(OperationSubscribeOn.subscribeOn(source, scheduler)); + } + + /** + * 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. + * @return the source sequence whose observations happen on the specified scheduler. + */ + public static Observable observeOn(Observable source, Scheduler scheduler) { + return create(OperationObserveOn.observeOn(source, scheduler)); + } + + /** + * 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. + * + * @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. + */ + public static Observable defer(Func0> observableFactory) { + return create(OperationDefer.defer(observableFactory)); + } + + /** + * 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. + * + * @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. + */ + public static Observable defer(Object observableFactory) { + final FuncN _f = Functions.from(observableFactory); + + return create(OperationDefer.defer(() -> (Observable) _f.call())); + } + + /** + * Returns an Observable that notifies an {@link Observer} of a single value and then completes. + *

+ * To convert any object into an Observable that emits that object, pass 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. + *

+ * + * + * @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 + */ + public static Observable just(T value) { + List list = new ArrayList<>(); + list.add(value); + + return toObservable(list); + } + + /** + * Returns the last element of an observable sequence with a specified source. + * + * @param that + * the source Observable + * @return the last element in the observable sequence. + */ + public static T last(final Observable that) { + T result = null; + for (T value : that.toIterable()) { + result = value; + } + return result; + } + + /** + * 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. + * @return the last element in the observable sequence. + */ + public static T last(final Observable that, final Func1 predicate) { + return last(that.filter(predicate)); + } + + /** + * 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. + * @return the last element in the observable sequence. + */ + public static T last(final Observable that, final Object predicate) { + return last(that.filter(predicate)); + } + + /** + * 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. + * @return the last element of an observable sequence that matches the predicate, or a default value if no value is found. + */ + public static T lastOrDefault(Observable source, T defaultValue) { + boolean found = false; + T result = null; + + for (T value : source.toIterable()) { + found = true; + result = value; + } + + if (!found) { + return defaultValue; + } + + return result; + } + + /** + * 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. + * @return the last element of an observable sequence that matches the predicate, or a default value if no value is found. + */ + public static T lastOrDefault(Observable source, T defaultValue, Func1 predicate) { + return lastOrDefault(source.filter(predicate), defaultValue); + } + + /** + * 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. + * @return the last element of an observable sequence that matches the predicate, or a default value if no value is found. + */ + public static T lastOrDefault(Observable source, T defaultValue, Object predicate) { + final FuncN _f = Functions.from(predicate); + + return lastOrDefault(source, defaultValue, (T args) -> (Boolean) _f.call(args)); + } + + /** + * Applies a function of your choosing to every notification emitted by an Observable, and returns + * this transformation as a new Observable sequence. + *

+ * + * + * @param sequence + * 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 + * @return an Observable that is the result of applying the transformation 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)); + } + + /** + * Applies a function of your choosing to every notification emitted by an Observable, and returns + * this transformation as a new Observable sequence. + *

+ * + * + * @param sequence + * 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 + * @return an Observable that is the result of applying the transformation 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); + return map(sequence, (T t1) -> (R) _f.call(t1)); + } + + /** + * 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 + * 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 + * @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 + */ + public static Observable mapMany(Observable sequence, Func1> func) { + return create(OperationMap.mapMany(sequence, func)); + } + + /** + * 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 + * 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 + * @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 + */ + public static Observable mapMany(Observable sequence, final Object func) { + final FuncN _f = Functions.from(func); + return mapMany(sequence, (T t1) -> (Observable) _f.call(t1)); + } + + /** + * 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 MSDN: Observable.Materialize + */ + public static Observable> materialize(final Observable sequence) { + return create(OperationMaterialize.materialize(sequence)); + } + + /** + * 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 MSDN: Observable.Dematerialize + */ + public static Observable dematerialize(final Observable> sequence) { + return create(OperationDematerialize.dematerialize(sequence)); + } + + /** + * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Merge + */ + public static Observable merge(List> source) { + return create(OperationMerge.merge(source)); + } + + /** + * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Merge Method + */ + public static Observable merge(Observable> source) { + return create(OperationMerge.merge(source)); + } + + /** + * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Merge Method + */ + public static Observable merge(Observable... source) { + return create(OperationMerge.merge(source)); + } + + /** + * 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) { + return OperatorTakeUntil.takeUntil(source, other); + } + + /** + * Combines the objects emitted by two or more Observables, and emits the result as a single Observable, + * by using the concat method. + *

+ * + * + * @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 + * @see MSDN: Observable.Concat Method + */ + public static Observable concat(Observable... source) { + return create(OperationConcat.concat(source)); + } + + /** + * 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. + * @return an Observable that emits the same objects, then calls the action. + * @see MSDN: Observable.Finally Method + */ + public static Observable finallyDo(Observable source, Action0 action) { + return create(OperationFinally.finallyDo(source, action)); + } + + /** + * 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. + * @return an observable of observable groups, each of which corresponds to 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)); + } + + /** + * 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. + * @return an observable of observable groups, each of which corresponds to 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)); + } + + /** + * Same functionality as merge except that errors received to onError will be held until all sequences have finished (onComplete/onError) before sending the error. + *

+ * Only the first onError received will be sent. + *

+ * This enables receiving all successes from merged sequences without one onError from one sequence causing all onNext calls to be prevented. + *

+ * + * + * @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 + * @see MSDN: Observable.Merge Method + */ + public static Observable mergeDelayError(List> source) { + return create(OperationMergeDelayError.mergeDelayError(source)); + } + + /** + * Same functionality as merge except that errors received to onError will be held until all sequences have finished (onComplete/onError) before sending the error. + *

+ * Only the first onError received will be sent. + *

+ * This enables receiving all successes from merged sequences without one onError from one sequence causing all onNext calls to be prevented. + *

+ * + * + * @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 + * @see MSDN: Observable.Merge Method + */ + public static Observable mergeDelayError(Observable> source) { + return create(OperationMergeDelayError.mergeDelayError(source)); + } + + /** + * Same functionality as merge except that errors received to onError will be held until all sequences have finished (onComplete/onError) before sending the error. + *

+ * Only the first onError received will be sent. + *

+ * This enables receiving all successes from merged sequences without one onError from one sequence causing all onNext calls to be prevented. + *

+ * + * + * @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 + * @see MSDN: Observable.Merge Method + */ + public static Observable mergeDelayError(Observable... source) { + return create(OperationMergeDelayError.mergeDelayError(source)); + } + + /** + * Returns an Observable that never sends any information to an {@link Observer}. + * + * This observable is useful primarily for testing purposes. + * + * @param + * the type of item (not) emitted by the Observable + * @return an Observable that never sends any information to an {@link Observer} + */ + public static Observable never() { + return new NeverObservable<>(); + } + + /** + * Instruct an Observable to pass control to another Observable (the return 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. + *

+ * 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 + * @return the source Observable, with its behavior modified as described + */ + public static Observable onErrorResumeNext(final Observable that, final Func1> resumeFunction) { + return create(OperationOnErrorResumeNextViaFunction.onErrorResumeNextViaFunction(that, resumeFunction)); + } + + /** + * Instruct an Observable to pass control to another Observable (the return 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. + *

+ * 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 + * @return the source Observable, with its behavior modified as described + */ + public static Observable onErrorResumeNext(final Observable that, final Object resumeFunction) { + final FuncN _f = Functions.from(resumeFunction); + return onErrorResumeNext(that, (Exception e) -> (Observable) _f.call(e)); + } + + /** + * Instruct an Observable to pass control to another Observable 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. + *

+ * 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 + * @return the source Observable, with its behavior modified as described + */ + public static Observable onErrorResumeNext(final Observable that, final Observable resumeSequence) { + return create(OperationOnErrorResumeNextViaObservable.onErrorResumeNextViaObservable(that, resumeSequence)); + } + + /** + * Instruct an Observable to emit a particular item to its Observer's 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 + * 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 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 + * @return the source Observable, with its behavior modified as described + */ + public static Observable onErrorReturn(final Observable that, Func1 resumeFunction) { + return create(OperationOnErrorReturn.onErrorReturn(that, resumeFunction)); + } + + /** + * 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. + *

+ * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Aggregate + * @see Wikipedia: Fold (higher-order function) + */ + public static Observable reduce(Observable sequence, Func2 accumulator) { + return takeLast(create(OperationScan.scan(sequence, accumulator)), 1); + } + + /** + * 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. + *

+ * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Aggregate + * @see Wikipedia: Fold (higher-order function) + */ + public static Observable reduce(final Observable sequence, final Object accumulator) { + final FuncN _f = Functions.from(accumulator); + return reduce(sequence, (T t1, T t2) -> (T) _f.call(t1, t2)); + } + + /** + * 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. + *

+ * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Aggregate + * @see Wikipedia: Fold (higher-order function) + */ + public static Observable reduce(Observable sequence, T initialValue, Func2 accumulator) { + return takeLast(create(OperationScan.scan(sequence, initialValue, accumulator)), 1); + } + + /** + * 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. + *

+ * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Aggregate + * @see Wikipedia: Fold (higher-order function) + */ + public static Observable reduce(final Observable sequence, final T initialValue, final Object accumulator) { + final FuncN _f = Functions.from(accumulator); + return reduce(sequence, initialValue, (T t1, T t2) -> (T) _f.call(t1, t2)); + } + + /** + * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Scan + */ + public static Observable scan(Observable sequence, Func2 accumulator) { + return create(OperationScan.scan(sequence, accumulator)); + } + + /** + * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Scan + */ + public static Observable scan(final Observable sequence, final Object accumulator) { + final FuncN _f = Functions.from(accumulator); + return scan(sequence, (T t1, T t2) -> (T) _f.call(t1, t2)); + } + + /** + * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Scan + */ + public static Observable scan(Observable sequence, T initialValue, Func2 accumulator) { + return create(OperationScan.scan(sequence, initialValue, accumulator)); + } + + /** + * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Scan + */ + public static Observable scan(final Observable sequence, final T initialValue, final Object accumulator) { + final FuncN _f = Functions.from(accumulator); + return scan(sequence, initialValue, (T t1, T t2) -> (T) _f.call(t1, t2)); + } + + /** + * 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. + * @return true if all elements of an observable sequence satisfies a condition; otherwise, false. + */ + public static Observable all(final Observable sequence, final Func1 predicate) { + return create(OperationAll.all(sequence, predicate)); + } + + /** + * 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. + * @return true if all elements of an observable sequence satisfies a condition; otherwise, false. + */ + public static Observable all(final Observable sequence, Object predicate) { + final FuncN _f = Functions.from(predicate); + return all(sequence, (T t) -> (Boolean) _f.call(t)); + } + + /** + * 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. + *

+ * + * + * @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 + * @see MSDN: Observable.Skip Method + */ + public static Observable skip(final Observable items, int num) { + return create(OperationSkip.skip(items, num)); + } + + /** + * Accepts an Observable and wraps it in another Observable that ensures that the resulting + * Observable is chronologically 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 + * 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 + */ + public static Observable synchronize(Observable observable) { + return create(OperationSynchronize.synchronize(observable)); + } + + /** + * Returns an Observable that emits the first num items emitted 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. + *

+ * + * + * @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 + */ + public static Observable take(final Observable items, final int num) { + return create(OperationTake.take(items, num)); + } + + /** + * Returns an Observable that emits the last count items 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 + * @return an Observable that only emits the last count items emitted by the source + * Observable + */ + public static Observable takeLast(final Observable items, final int count) { + return create(OperationTakeLast.takeLast(items, count)); + } + + /** + * 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 + * @return + */ + public static Observable takeWhile(final Observable items, Func1 predicate) { + return create(OperationTakeWhile.takeWhile(items, predicate)); + } + + /** + * 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 + * @return + */ + public static Observable takeWhile(final Observable items, Object predicate) { + final FuncN _f = Functions.from(predicate); + + return takeWhile(items, (T t) -> (Boolean) _f.call(t)); + } + + /** + * 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. + * @return + */ + public static Observable takeWhileWithIndex(final Observable items, Func2 predicate) { + return create(OperationTakeWhile.takeWhileWithIndex(items, predicate)); + } + + public static Observable takeWhileWithIndex(final Observable items, Object predicate) { + final FuncN _f = Functions.from(predicate); + + return create(OperationTakeWhile.takeWhileWithIndex(items, (T t, Integer integer) -> (Boolean) _f.call(t, integer))); + } + + /** + * Returns an Observable that emits a single item, a list composed of all 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. + *

+ * + * + * @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 + */ + public static Observable> toList(final Observable that) { + return create(OperationToObservableList.toObservableList(that)); + } + + /** + * Converts an observable sequence to an Iterable. + * + * @param that + * the source Observable + * @return Observable converted to Iterable. + */ + public static Iterable toIterable(final Observable that) { + + return new Iterable() { + @Override + public Iterator iterator() { + return getIterator(that); + } + }; + } + + /** + * 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. + */ + public static Iterator getIterator(Observable that) { + return OperatorToIterator.toIterator(that); + } + + /** + * Samples the next value (blocking without buffering) from in an observable sequence. + * + * @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. + */ + public static Iterable next(Observable items) { + return OperationNext.next(items); + } + + /** + * 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. + * @return the iterable that returns the last sampled element upon each iteration. + */ + public static Iterable mostRecent(Observable source, T initialValue) { + return OperationMostRecent.mostRecent(source, initialValue); + } + + /** + * 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 + * @return The single 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); + } + + /** + * Returns the only element of an observable sequence that matches the 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. + * @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 + */ + public static T single(Observable that, Func1 predicate) { + return single(that.filter(predicate)); + } + + /** + * Returns the only element of an observable sequence that matches the 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. + * @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 + */ + public static T single(Observable that, Object predicate) { + final FuncN _f = Functions.from(predicate); + + return single(that, (T t) -> (Boolean) _f.call(t)); + } + + /** + * 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. + * @return The single element in the observable sequence, or a default value if no value is found. + */ + public static T singleOrDefault(Observable that, T defaultValue) { + return singleOrDefault(that, true, defaultValue); + } + + /** + * 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. + * @return The single element in the observable sequence, or a default value if no value is found. + */ + public static T singleOrDefault(Observable that, T defaultValue, Func1 predicate) { + return singleOrDefault(that.filter(predicate), defaultValue); + } + + /** + * 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. + * @return The single element in the observable sequence, or a default value if no value is found. + */ + public static T singleOrDefault(Observable that, T defaultValue, Object predicate) { + final FuncN _f = Functions.from(predicate); + + return singleOrDefault(that, defaultValue, (T t) -> (Boolean) _f.call(t)); + } + + private static T singleOrDefault(Observable that, boolean hasDefault, T defaultVal) { + Iterator it = that.toIterable().iterator(); + + if (!it.hasNext()) { + if (hasDefault) { + return defaultVal; + } + throw new IllegalStateException("Expected single entry. Actually empty stream."); + } + + T result = it.next(); + + if (it.hasNext()) { + throw new IllegalStateException("Expected single entry. Actually more than one entry."); + } + + return result; + } + + /** + * 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. + *

+ * + * + * @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 + */ + public static Observable toObservable(Iterable iterable) { + return create(OperationToObservableIterable.toObservableIterable(iterable)); + } + + /** + * 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. + *

+ * 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 + * @return an Observable that emits the item from the source Future + */ + public static Observable toObservable(Future future) { + return create(OperationToObservableFuture.toObservableFuture(future)); + } + + /** + * 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. + * 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 + * @return an Observable that emits the item from the source Future + */ + public static Observable toObservable(Future future, long timeout, TimeUnit unit) { + return create(OperationToObservableFuture.toObservableFuture(future, timeout, unit)); + } + + /** + * 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. + *

+ * + * + * @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) { + return toObservable(Arrays.asList(items)); + } + + /** + * Sort T objects by their natural order (object must implement Comparable). + *

+ * + * + * @param sequence + * @throws ClassCastException + * if T objects do not implement Comparable + * @return + */ + public static Observable> toSortedList(Observable sequence) { + return create(OperationToObservableSortedList.toSortedList(sequence)); + } + + /** + * Sort T objects using the defined sort function. + *

+ * + * + * @param sequence + * @param sortFunction + * @return + */ + public static Observable> toSortedList(Observable sequence, Func2 sortFunction) { + return create(OperationToObservableSortedList.toSortedList(sequence, sortFunction)); + } + + /** + * Sort T objects using the defined sort function. + *

+ * + * + * @param sequence + * @param sortFunction + * @return + */ + public static Observable> toSortedList(Observable sequence, final Object sortFunction) { + final FuncN _f = Functions.from(sortFunction); + return create(OperationToObservableSortedList.toSortedList(sequence, (T t1, T t2) -> (Integer) _f.call(t1, t2))); + } + + /** + * 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. + *

+ * 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. + *

+ * 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. + *

+ * + * + * @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) { + return create(OperationZip.zip(w0, w1, reduceFunction)); + } + + /** + * 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 + * @return sequence of booleans, true if two sequences are equal by comparing the elements pairwise; otherwise, false. + */ + public static Observable sequenceEqual(Observable first, Observable second) { + return sequenceEqual(first, second, Object::equals); + } + + /** + * 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 + * @return sequence of booleans, true if two sequences are equal by comparing the elements pairwise; otherwise, false. + */ + public static Observable sequenceEqual(Observable first, Observable second, Func2 equality) { + return zip(first, second, equality); + } + + /** + * 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 + * @return sequence of booleans, true if two sequences are equal by comparing the elements pairwise; otherwise, false. + */ + public static Observable sequenceEqual(Observable first, Observable second, Object equality) { + return zip(first, second, equality); + } + + /** + * 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. + *

+ * 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. + *

+ * 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. + *

+ * + * + * @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) { + final FuncN _f = Functions.from(function); + return zip(w0, w1, (T0 t0, T1 t1) -> (R) _f.call(t0, t1)); + } + + /** + * 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. + *

+ * 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. + *

+ * 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. + *

+ * + * + * @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) { + return create(OperationZip.zip(w0, w1, w2, function)); + } + + /** + * 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. + *

+ * 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. + *

+ * 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. + *

+ * + * + * @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) { + final FuncN _f = Functions.from(function); + return zip(w0, w1, w2, (T0 t0, T1 t1, T2 t2) -> (R) _f.call(t0, t1, t2)); + } + + /** + * 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. + *

+ * 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. + *

+ * 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. + *

+ * + * + * @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) { + return create(OperationZip.zip(w0, w1, w2, w3, reduceFunction)); + } + + /** + * 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. + *

+ * 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. + *

+ * 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. + *

+ * + * + * @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) { + final FuncN _f = Functions.from(function); + return zip(w0, w1, w2, w3, (T0 t0, T1 t1, T2 t2, T3 t3) -> (R) _f.call(t0, t1, t2, t3)); + } + + /** + * Filters an Observable by discarding any of its emissions that do not meet some test. + *

+ * + * + * @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 + */ + public Observable filter(Func1 predicate) { + return filter(this, predicate); + } + + /** + * 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. + * @return an Observable that emits the same objects as this observable, then calls the action. + * @see MSDN: Observable.Finally Method + */ + public Observable finallyDo(Action0 action) { + return create(OperationFinally.finallyDo(this, action)); + } + + /** + * Filters an Observable by discarding any of its emissions that do not meet some test. + *

+ * + * + * @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" + */ + public Observable filter(final Object callback) { + final FuncN _f = Functions.from(callback); + return filter(this, (T t1) -> (Boolean) _f.call(t1)); + } + + /** + * Filters an Observable by discarding any of its emissions that do not meet some test. + *

+ * + * + * @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 + */ + public Observable where(Func1 predicate) { + return where(this, predicate); + } + + /** + * Returns the last element of an observable sequence with a specified source. + * + * @return the last element in the observable sequence. + */ + public T last() { + return last(this); + } + + /** + * Returns the last element of an observable sequence that matches the predicate. + * + * @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) { + return last(this, predicate); + } + + /** + * Returns the last element of an observable sequence that matches the predicate. + * + * @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) { + final FuncN _f = Functions.from(predicate); + + return last(this, (T args) -> (Boolean) _f.call(args)); + } + + /** + * 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. + * @return the last element of an observable sequence that matches the predicate, or a default value if no value is found. + */ + public T lastOrDefault(T defaultValue) { + return lastOrDefault(this, defaultValue); + } + + /** + * 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. + * @return the last element of an observable sequence that matches the predicate, or a default value if no value is found. + */ + public T lastOrDefault(T defaultValue, Func1 predicate) { + return lastOrDefault(this, defaultValue, predicate); + } + + /** + * 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. + * @return the last element of an observable sequence that matches the predicate, or a default value if no value is found. + */ + public T lastOrDefault(T defaultValue, Object predicate) { + return lastOrDefault(this, defaultValue, predicate); + } + + /** + * Applies a function of your choosing to every item emitted by an Observable, and returns this + * transformation as a new Observable 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. + */ + public Observable map(Func1 func) { + return map(this, func); + } + + /** + * Applies a function of your choosing to every item emitted by an Observable, and returns this + * transformation as a new Observable 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. + */ + public Observable map(final Object callback) { + final FuncN _f = Functions.from(callback); + return map(this, (T t1) -> (R) _f.call(t1)); + } + + /** + * 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. + *

+ * + * + * @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. + */ + public Observable mapMany(Func1> func) { + return mapMany(this, func); + } + + /** + * 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. + *

+ * + * + * @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. + */ + public Observable mapMany(final Object callback) { + final FuncN _f = Functions.from(callback); + return mapMany(this, (T t1) -> (Observable) _f.call(t1)); + } + + /** + * Materializes the implicit notifications of this observable sequence as explicit notification values. + *

+ * + * + * @return An observable sequence whose elements are the result of materializing the notifications of the given sequence. + * @see MSDN: Observable.materialize + */ + public Observable> materialize() { + return materialize(this); + } + + /** + * Asynchronously subscribes and unsubscribes observers on the specified scheduler. + * + * @param scheduler + * the scheduler to perform subscription and unsubscription actions on. + * @return the source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. + */ + public Observable subscribeOn(Scheduler scheduler) { + return subscribeOn(this, scheduler); + } + + /** + * Asynchronously notify observers on the specified scheduler. + * + * @param scheduler + * the scheduler to notify observers on. + * @return the source sequence whose observations happen on the specified scheduler. + */ + public Observable observeOn(Scheduler scheduler) { + return observeOn(this, scheduler); + } + + /** + * Dematerializes the explicit notification values of an observable sequence as implicit notifications. + * + * @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 {@code Observable>}. + */ + public Observable dematerialize() { + return dematerialize((Observable>) this); + } + + /** + * Instruct an Observable to pass control to another Observable 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 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 + * 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. + *

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

+ * + * + * @param resumeFunction + * @return the original Observable, with appropriately modified behavior + */ + public Observable onErrorResumeNext(final Func1> resumeFunction) { + return onErrorResumeNext(this, resumeFunction); + } + + /** + * Instruct an Observable to emit a particular item 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 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 + * 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. + *

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

+ * + * + * @param resumeFunction + * @return the original Observable with appropriately modified behavior + */ + public Observable onErrorResumeNext(final Object resumeFunction) { + final FuncN _f = Functions.from(resumeFunction); + return onErrorResumeNext(this, (Exception e) -> (Observable) _f.call(e)); + } + + /** + * Instruct an Observable to pass control to another Observable 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 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 + * 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. + *

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

+ * + * + * @param resumeSequence + * @return the original Observable, with appropriately modified behavior + */ + public Observable onErrorResumeNext(final Observable resumeSequence) { + return onErrorResumeNext(this, resumeSequence); + } + + /** + * Instruct an Observable to emit a particular item rather than calling 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 + * (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 + * 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. + * + * @param resumeFunction + * @return the original Observable with appropriately modified behavior + */ + public Observable onErrorReturn(Func1 resumeFunction) { + return onErrorReturn(this, resumeFunction); + } + + /** + * Instruct an Observable to emit a particular item rather than calling 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 + * (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 + * 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. + * + * @param resumeFunction + * @return the original Observable with appropriately modified behavior + */ + public Observable onErrorReturn(final Object resumeFunction) { + final FuncN _f = Functions.from(resumeFunction); + return onErrorReturn(this, (Exception e) -> (T) _f.call(e)); + } + + /** + * 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. + *

+ * 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. + *

+ * + * + * @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. + * @see MSDN: Observable.Aggregate + * @see Wikipedia: Fold (higher-order function) + */ + public Observable reduce(Func2 accumulator) { + return reduce(this, accumulator); + } + + /** + * 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. + *

+ * 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. + *

+ * + * + * @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. + * @see MSDN: Observable.Aggregate + * @see Wikipedia: Fold (higher-order function) + */ + public Observable reduce(Object accumulator) { + return reduce(this, accumulator); + } + + /** + * 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. + *

+ * 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. + *

+ * + * + * @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. + * @see MSDN: Observable.Aggregate + * @see Wikipedia: Fold (higher-order function) + */ + public Observable reduce(T initialValue, Func2 accumulator) { + return reduce(this, initialValue, accumulator); + } + + /** + * 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. + *

+ * 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. + *

+ * + * + * @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. + * @see MSDN: Observable.Aggregate + * @see Wikipedia: Fold (higher-order function) + */ + public Observable reduce(T initialValue, Object accumulator) { + return reduce(this, initialValue, accumulator); + } + + /** + * 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. + *

+ * + * + * @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. + * @see MSDN: Observable.Scan + */ + public Observable scan(Func2 accumulator) { + return scan(this, accumulator); + } + + /** + * 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. + *

+ * + * + * @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. + * @see MSDN: Observable.Scan + */ + public Observable scan(final Object accumulator) { + return scan(this, accumulator); + } + + /** + * 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. + *

+ * + * + * @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. + * @see MSDN: Observable.Scan + */ + public Observable scan(T initialValue, Func2 accumulator) { + return scan(this, initialValue, accumulator); + } + + /** + * 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 + * 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. + *

+ * + * + * @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. + * @see MSDN: Observable.Scan + */ + public Observable scan(final T initialValue, final Object accumulator) { + return scan(this, initialValue, accumulator); + } + + /** + * Determines whether all elements of an observable sequence satisfies 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. + */ + public Observable all(Func1 predicate) { + return all(this, predicate); + } + + /** + * Determines whether all elements of an observable sequence satisfies 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. + */ + public Observable all(Object predicate) { + return all(this, predicate); + } + + /** + * 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. + *

+ * + * + * @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. + */ + public Observable skip(int num) { + return skip(this, num); + } + + /** + * Returns an Observable that emits the first num items emitted 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. + *

+ * + * + * @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. + */ + public Observable take(final int num) { + return take(this, num); + } + + /** + * 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 + * @return + */ + public Observable takeWhile(final Func1 predicate) { + return takeWhile(this, predicate); + } + + /** + * 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 + * @return + */ + public Observable takeWhile(final Object predicate) { + return takeWhile(this, predicate); + } + + /** + * 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. + * @return + */ + public Observable takeWhileWithIndex(final Func2 predicate) { + return takeWhileWithIndex(this, predicate); + } + + /** + * 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. + * @return + */ + public Observable takeWhileWithIndex(final Object predicate) { + return takeWhileWithIndex(this, predicate); + } + + /** + * Returns an Observable that emits the last count items emitted by 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 + */ + public Observable takeLast(final int count) { + return takeLast(this, count); + } + + /** + * 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. + * @return An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation. + */ + public Observable takeUntil(Observable other) { + return takeUntil(this, other); + } + + /** + * Returns an Observable that emits a single item, a list composed of all 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. + *

+ * + * + * @return an Observable that emits a single item: a List containing all of the items emitted by + * the source Observable. + */ + public Observable> toList() { + return toList(this); + } + + /** + * Sort T objects by their natural order (object must implement Comparable). + *

+ * + * + * @throws ClassCastException + * if T objects do not implement Comparable + * @return + */ + public Observable> toSortedList() { + return toSortedList(this); + } + + /** + * Sort T objects using the defined sort function. + *

+ * + * + * @param sortFunction + * @return + */ + public Observable> toSortedList(Func2 sortFunction) { + return toSortedList(this, sortFunction); + } + + /** + * Sort T objects using the defined sort function. + *

+ * + * + * @param sortFunction + * @return + */ + public Observable> toSortedList(final Object sortFunction) { + return toSortedList(this, sortFunction); + } + + /** + * Converts an observable sequence to an Iterable. + * + * @return Observable converted to Iterable. + */ + public Iterable toIterable() { + return toIterable(this); + } + + @SuppressWarnings("unchecked") + public Observable startWith(T... values) { + return concat(Observable. from(values), this); + } + + /** + * 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. + * @return an observable of observable groups, each of which corresponds to 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); + } + + /** + * 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. + * @return an observable of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + */ + public Observable> groupBy(final Func1 keySelector) { + return groupBy(this, keySelector); + } + + /** + * Returns an iterator that iterates all values of the observable. + * + * @return the iterator that could be used to iterate over the elements of the observable. + */ + public Iterator getIterator() { + return getIterator(this); + } + + /** + * Samples the next value (blocking without buffering) from in an observable sequence. + * + * @return iterable that blocks upon each iteration until the next element in the observable source sequence becomes available. + */ + public Iterable next() { + return next(this); + } + + /** + * 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. + * @return the iterable that returns the last sampled element upon each iteration. + */ + public Iterable mostRecent(T initialValue) { + return mostRecent(this, initialValue); + } + + /** + * Whether a given {@link Function} is an internal implementation inside rx.* packages or not. + *

+ * For why this is being used see https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator" + * + * NOTE: If strong reasons for not depending on package names comes up then the implementation of this method can change to looking for a marker interface. + * + * @param f + * @return + */ + private boolean isInternalImplementation(Object o) { + if (o == null) { + return true; + } + // prevent double-wrapping (yeah it happens) + if (o instanceof AtomicObserver) + return true; + // we treat the following package as "internal" and don't wrap it + return o.getClass().getPackage().getName().startsWith("rx.operators"); + } + +} diff --git a/HMCLAPI/src/main/java/rx/Observer.java b/HMCLAPI/src/main/java/rx/Observer.java new file mode 100644 index 000000000..dc12c8e97 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/Observer.java @@ -0,0 +1,57 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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. + *

+ * For more information see the RxJava Wiki + * + * @param + */ +public interface Observer { + + /** + * 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. + */ + public void onCompleted(); + + /** + * 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. + * + * @param e + */ + public void onError(Exception e); + + /** + * 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} 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 new file mode 100644 index 000000000..74fe274b3 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/Scheduler.java @@ -0,0 +1,69 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx; + +import java.util.concurrent.TimeUnit; + +import rx.util.functions.Action0; +import rx.util.functions.Func0; + +/** + * Represents an object that schedules units of work. + */ +public interface Scheduler { + + /** + * Schedules a cancelable action to be executed. + * + * @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 + * @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 + * @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 + * @return a subscription to be able to unsubscribe from action. + */ + Subscription schedule(Func0 action, long dueTime, TimeUnit unit); + + /** + * Returns the scheduler's notion of current time. + */ + long now(); + +} diff --git a/HMCLAPI/src/main/java/rx/Subscription.java b/HMCLAPI/src/main/java/rx/Subscription.java new file mode 100644 index 000000000..e2347257c --- /dev/null +++ b/HMCLAPI/src/main/java/rx/Subscription.java @@ -0,0 +1,34 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx; + +import rx.subscriptions.Subscriptions; + +/** + * Subscription returns from {@link Observable#subscribe(Observer)} to allow unsubscribing. + *

+ * 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. + *

+ * 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 new file mode 100644 index 000000000..e6fc87ebd --- /dev/null +++ b/HMCLAPI/src/main/java/rx/concurrency/AbstractScheduler.java @@ -0,0 +1,53 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.concurrency; + +import java.util.concurrent.TimeUnit; + +import rx.Scheduler; +import rx.Subscription; +import rx.subscriptions.Subscriptions; +import rx.util.functions.Action0; +import rx.util.functions.Func0; + +/* package */abstract class AbstractScheduler implements Scheduler { + + @Override + public Subscription schedule(Action0 action) { + return schedule(asFunc0(action)); + } + + @Override + public Subscription schedule(Action0 action, long dueTime, TimeUnit unit) { + return schedule(asFunc0(action), dueTime, unit); + } + + @Override + public long now() { + return System.nanoTime(); + } + + private static Func0 asFunc0(final Action0 action) { + return new Func0() { + @Override + public Subscription call() { + action.call(); + return Subscriptions.empty(); + } + }; + } + +} diff --git a/HMCLAPI/src/main/java/rx/concurrency/CurrentThreadScheduler.java b/HMCLAPI/src/main/java/rx/concurrency/CurrentThreadScheduler.java new file mode 100644 index 000000000..0fd634523 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/concurrency/CurrentThreadScheduler.java @@ -0,0 +1,71 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.concurrency; + +import java.util.LinkedList; +import java.util.Queue; +import java.util.concurrent.TimeUnit; + +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. + */ +public class CurrentThreadScheduler extends AbstractScheduler { + private static final CurrentThreadScheduler INSTANCE = new CurrentThreadScheduler(); + + public static CurrentThreadScheduler getInstance() { + return INSTANCE; + } + + private static final ThreadLocal> QUEUE = new ThreadLocal<>(); + + private CurrentThreadScheduler() { + } + + @Override + public Subscription schedule(Func0 action) { + DiscardableAction discardableAction = new DiscardableAction(action); + enqueue(discardableAction); + return discardableAction; + } + + @Override + public Subscription schedule(Func0 action, long dueTime, TimeUnit unit) { + return schedule(new SleepingAction(action, this, dueTime, unit)); + } + + private void enqueue(DiscardableAction action) { + Queue queue = QUEUE.get(); + boolean exec = queue == null; + + if (exec) { + queue = new LinkedList<>(); + QUEUE.set(queue); + } + + queue.add(action); + + if (exec) { + 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 new file mode 100644 index 000000000..bf036befd --- /dev/null +++ b/HMCLAPI/src/main/java/rx/concurrency/DiscardableAction.java @@ -0,0 +1,52 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.concurrency; + +import java.util.concurrent.atomic.AtomicBoolean; + +import rx.Subscription; +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. + */ +/* package */class DiscardableAction implements Func0, Subscription { + private final Func0 underlying; + + private final AtomicObservableSubscription wrapper = new AtomicObservableSubscription(); + private final AtomicBoolean ready = new AtomicBoolean(true); + + public DiscardableAction(Func0 underlying) { + this.underlying = underlying; + } + + @Override + public Subscription call() { + if (ready.compareAndSet(true, false)) { + Subscription subscription = underlying.call(); + wrapper.wrap(subscription); + return subscription; + } + return wrapper; + } + + @Override + public void unsubscribe() { + ready.set(false); + wrapper.unsubscribe(); + } +} diff --git a/HMCLAPI/src/main/java/rx/concurrency/ExecutorScheduler.java b/HMCLAPI/src/main/java/rx/concurrency/ExecutorScheduler.java new file mode 100644 index 000000000..133f77288 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/concurrency/ExecutorScheduler.java @@ -0,0 +1,126 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.concurrency; + +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import rx.Scheduler; +import rx.Subscription; +import rx.util.functions.Func0; + +/** + * A {@link Scheduler} implementation that uses an {@link Executor} or {@link ScheduledExecutorService} implementation. + *

+ * Note that if an {@link Executor} implementation is used instead of {@link ScheduledExecutorService} then a system-wide Timer will be used to handle delayed events. + */ +public class ExecutorScheduler extends AbstractScheduler { + private final Executor executor; + + /** + * Setup a ScheduledExecutorService that we can use if someone provides an Executor instead of ScheduledExecutorService. + */ + private final static ScheduledExecutorService SYSTEM_SCHEDULED_EXECUTOR; + static { + int count = Runtime.getRuntime().availableProcessors(); + if (count > 8) { + count = count / 2; + } + // we don't need more than 8 to handle just scheduling and doing no work + if (count > 8) { + count = 8; + } + SYSTEM_SCHEDULED_EXECUTOR = Executors.newScheduledThreadPool(count, new ThreadFactory() { + + final AtomicInteger counter = new AtomicInteger(); + + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r, "RxScheduledExecutorPool-" + counter.incrementAndGet()); + t.setDaemon(true); + return t; + } + + }); + + } + + public ExecutorScheduler(Executor executor) { + this.executor = executor; + } + + public ExecutorScheduler(ScheduledExecutorService executor) { + this.executor = executor; + } + + @Override + public Subscription schedule(Func0 action, long dueTime, TimeUnit unit) { + final DiscardableAction discardableAction = new DiscardableAction(action); + + if (executor instanceof ScheduledExecutorService) { + ((ScheduledExecutorService) executor).schedule(new Runnable() { + @Override + public void run() { + discardableAction.call(); + } + }, dueTime, unit); + } else { + if (dueTime == 0) { + // no delay so put on the thread-pool right now + return (schedule(action)); + } else { + // there is a delay and this isn't a ScheduledExecutorService so we'll use a system-wide ScheduledExecutorService + // to handle the scheduling and once it's ready then execute on this Executor + SYSTEM_SCHEDULED_EXECUTOR.schedule(new Runnable() { + + @Override + public void run() { + // now execute on the real Executor + executor.execute(new Runnable() { + + @Override + public void run() { + discardableAction.call(); + } + + }); + } + }, dueTime, unit); + } + } + return discardableAction; + } + + @Override + public Subscription schedule(Func0 action) { + final DiscardableAction discardableAction = new DiscardableAction(action); + + executor.execute(new Runnable() { + @Override + public void run() { + discardableAction.call(); + } + }); + + return discardableAction; + + } + +} diff --git a/HMCLAPI/src/main/java/rx/concurrency/ImmediateScheduler.java b/HMCLAPI/src/main/java/rx/concurrency/ImmediateScheduler.java new file mode 100644 index 000000000..1b5febe2d --- /dev/null +++ b/HMCLAPI/src/main/java/rx/concurrency/ImmediateScheduler.java @@ -0,0 +1,46 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.concurrency; + +import java.util.concurrent.TimeUnit; + +import rx.Subscription; +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() { + return INSTANCE; + } + + private ImmediateScheduler() { + } + + @Override + public Subscription schedule(Func0 action) { + return action.call(); + } + + @Override + public Subscription schedule(Func0 action, long dueTime, TimeUnit unit) { + return schedule(new SleepingAction(action, this, dueTime, unit)); + } + +} diff --git a/HMCLAPI/src/main/java/rx/concurrency/NewThreadScheduler.java b/HMCLAPI/src/main/java/rx/concurrency/NewThreadScheduler.java new file mode 100644 index 000000000..b9f1606b1 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/concurrency/NewThreadScheduler.java @@ -0,0 +1,49 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.concurrency; + +import java.util.concurrent.TimeUnit; + +import rx.Subscription; +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() { + return INSTANCE; + } + + @Override + public Subscription schedule(Func0 action) { + final DiscardableAction discardableAction = new DiscardableAction(action); + + Thread t = new Thread(discardableAction::call, "RxNewThreadScheduler"); + + t.start(); + + return discardableAction; + } + + @Override + public Subscription schedule(Func0 action, long dueTime, TimeUnit unit) { + return schedule(new SleepingAction(action, this, dueTime, unit)); + } + +} diff --git a/HMCLAPI/src/main/java/rx/concurrency/Schedulers.java b/HMCLAPI/src/main/java/rx/concurrency/Schedulers.java new file mode 100644 index 000000000..1b27b9bf0 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/concurrency/Schedulers.java @@ -0,0 +1,143 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.concurrency; + +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + +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(); + + private Schedulers() { + + } + + /** + * {@link Scheduler} that executes work immediately on the current thread. + * + * @return {@link ImmediateScheduler} instance + */ + public static Scheduler immediate() { + return ImmediateScheduler.getInstance(); + } + + /** + * {@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() { + return CurrentThreadScheduler.getInstance(); + } + + /** + * {@link Scheduler} that creates a new {@link Thread} for each unit of work. + * + * @return {@link NewThreadScheduler} instance + */ + public static Scheduler newThread() { + return NewThreadScheduler.getInstance(); + } + + /** + * {@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) { + return new ExecutorScheduler(executor); + } + + /** + * {@link Scheduler} that queues work on an {@link ScheduledExecutorService}. + * + * @return {@link ExecutorScheduler} instance + */ + public static Scheduler executor(ScheduledExecutorService executor) { + return new ExecutorScheduler(executor); + } + + /** + * {@link Scheduler} intended for computational work. + *

+ * 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. + *

+ * Do not perform IO-bound work on this scheduler. Use {@link #threadPoolForComputation()} instead. + * + * @return {@link ExecutorScheduler} for computation-bound work. + */ + public static Scheduler threadPoolForComputation() { + return executor(COMPUTATION_EXECUTOR); + } + + /** + * {@link Scheduler} intended for IO-bound work. + *

+ * 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. + * + * @return {@link ExecutorScheduler} for IO-bound work. + */ + public static Scheduler threadPoolForIO() { + return executor(IO_EXECUTOR); + } + + private static ScheduledExecutorService createComputationExecutor() { + int cores = Runtime.getRuntime().availableProcessors(); + return Executors.newScheduledThreadPool(cores, new ThreadFactory() { + final AtomicInteger counter = new AtomicInteger(); + + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r, "RxComputationThreadPool-" + counter.incrementAndGet()); + t.setDaemon(true); + return t; + } + }); + } + + private static Executor createIOExecutor() { + Executor result = Executors.newCachedThreadPool(new ThreadFactory() { + final AtomicLong counter = new AtomicLong(); + + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r, "RxIOThreadPool-" + counter.incrementAndGet()); + t.setDaemon(true); + return t; + } + }); + + return result; + } +} diff --git a/HMCLAPI/src/main/java/rx/concurrency/SleepingAction.java b/HMCLAPI/src/main/java/rx/concurrency/SleepingAction.java new file mode 100644 index 000000000..a57fd9046 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/concurrency/SleepingAction.java @@ -0,0 +1,49 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.concurrency; + +import java.util.concurrent.TimeUnit; + +import rx.Scheduler; +import rx.Subscription; +import rx.util.functions.Func0; + +/* package */class SleepingAction implements Func0 { + private final Func0 underlying; + private final Scheduler scheduler; + private final long execTime; + + public SleepingAction(Func0 underlying, Scheduler scheduler, long timespan, TimeUnit timeUnit) { + this.underlying = underlying; + this.scheduler = scheduler; + this.execTime = scheduler.now() + timeUnit.toMillis(timespan); + } + + @Override + public Subscription call() { + 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/concurrency/package-info.java b/HMCLAPI/src/main/java/rx/concurrency/package-info.java new file mode 100644 index 000000000..e0657722f --- /dev/null +++ b/HMCLAPI/src/main/java/rx/concurrency/package-info.java @@ -0,0 +1,19 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Rx Schedulers + */ +package rx.concurrency; \ No newline at end of file diff --git a/HMCLAPI/src/main/java/rx/observables/GroupedObservable.java b/HMCLAPI/src/main/java/rx/observables/GroupedObservable.java new file mode 100644 index 000000000..28ee67de4 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/observables/GroupedObservable.java @@ -0,0 +1,43 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.observables; + +import rx.Observable; +import rx.Observer; +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()}

+ * + * @see {@link Observable#groupBy(Observable, Func1)} + * + * @param + * @param + */ +public class GroupedObservable extends Observable { + private final K key; + + public GroupedObservable(K key, Func1, Subscription> onSubscribe) { + super(onSubscribe); + this.key = key; + } + + public K getKey() { + return key; + } + +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationAll.java b/HMCLAPI/src/main/java/rx/operators/OperationAll.java new file mode 100644 index 000000000..01af295c7 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationAll.java @@ -0,0 +1,61 @@ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +import rx.util.functions.Func1; + +import java.util.concurrent.atomic.AtomicBoolean; + +public class OperationAll { + + public static Func1, Subscription> all(Observable sequence, Func1 predicate) { + return new AllObservable<>(sequence, predicate); + } + + 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() { + @Override + public void onCompleted() { + if (status.get()) { + observer.onNext(true); + observer.onCompleted(); + } + } + + @Override + public void onError(Exception e) { + observer.onError(e); + } + + @Override + public void onNext(T args) { + boolean result = predicate.call(args); + boolean changed = status.compareAndSet(true, result); + + if (changed && !result) { + observer.onNext(false); + observer.onCompleted(); + subscription.unsubscribe(); + } + } + })); + } + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationCombineLatest.java b/HMCLAPI/src/main/java/rx/operators/OperationCombineLatest.java new file mode 100644 index 000000000..f9c077cf5 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationCombineLatest.java @@ -0,0 +1,273 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.functions.Func1; +import rx.util.functions.Func2; +import rx.util.functions.Func3; +import rx.util.functions.Func4; +import rx.util.functions.FuncN; +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. + */ + public static Func1, Subscription> combineLatest(Observable w0, Observable w1, Func2 combineLatestFunction) { + Aggregator a = new Aggregator<>(Functions.fromFunc(combineLatestFunction)); + a.addObserver(new CombineObserver(a, w0)); + a.addObserver(new CombineObserver(a, w1)); + return a; + } + + /** + * @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)); + a.addObserver(new CombineObserver(a, w0)); + a.addObserver(new CombineObserver(a, w1)); + a.addObserver(new CombineObserver(a, w2)); + return a; + } + + /** + * @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)); + a.addObserver(new CombineObserver(a, w0)); + a.addObserver(new CombineObserver(a, w1)); + a.addObserver(new CombineObserver(a, w2)); + a.addObserver(new CombineObserver(a, w3)); + return a; + } + + private static class CombineObserver implements Observer { + final Observable w; + final Aggregator a; + private Subscription subscription; + + public CombineObserver(Aggregator a, Observable w) { + this.a = a; + this.w = w; + } + + public synchronized void startWatching() { + if (subscription != null) { + throw new RuntimeException("This should only be called once."); + } + subscription = w.subscribe(this); + } + + @Override + public void onCompleted() { + a.complete(this); + } + + @Override + public void onError(Exception e) { + a.error(e); + } + + @Override + public void onNext(T args) { + a.next(this, args); + } + } + + /** + * 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> { + + private Observer observer; + + private final FuncN combineLatestFunction; + private final AtomicBoolean running = new AtomicBoolean(true); + + // 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. + * */ + private final Set> completed = new HashSet<>(); + + /** + * The latest value from each observer + *

+ * 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. + * */ + 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. + */ + private final List> observers = new LinkedList<>(); + + public Aggregator(FuncN combineLatestFunction) { + this.combineLatestFunction = combineLatestFunction; + } + + /** + * Receive notification of a Observer starting (meaning we should require it for aggregation) + * + * @param w The observer to add. + */ + void addObserver(CombineObserver w) { + observers.add(w); + } + + /** + * Receive notification of a Observer completing its iterations. + * + * @param w The observer that has completed. + */ + void complete(CombineObserver w) { + 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 (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. + */ + void error(Exception e) { + observer.onError(e); + /* 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. + * + * @param w + * @param arg + */ + void next(CombineObserver w, T arg) { + 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()) { + return; + } + + // define here so the variable is out of the synchronized scope + Object[] argsToCombineLatest = new Object[observers.size()]; + + // we synchronize everything that touches latest values + 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)) { + // 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) { + 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 + // this 'next' method while another thread finishes calling this combineLatestFunction + observer.onNext(combineLatestFunction.call(argsToCombineLatest)); + } + + @Override + public Subscription call(Observer observer) { + 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) { + rw.startWatching(); + } + + return new Subscription() { + @Override + public void unsubscribe() { + stop(); + } + }; + } + + private void stop() { + /* tell ourselves to stop processing onNext events */ + running.set(false); + /* 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 new file mode 100644 index 000000000..a5ee11d6c --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationConcat.java @@ -0,0 +1,126 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +import rx.util.functions.Action1; +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. + */ + public static Func1, Subscription> concat(final Observable... sequences) { + return new Func1, Subscription>() { + + @Override + public Subscription call(Observer observer) { + return new Concat(sequences).call(observer); + } + }; + } + + public static Func1, Subscription> concat(final List> sequences) { + @SuppressWarnings("unchecked") + Observable[] o = sequences.toArray((Observable[]) Array.newInstance(Observable.class, sequences.size())); + return concat(o); + } + + public static Func1, Subscription> concat(final Observable> sequences) { + final List> list = new ArrayList>(); + sequences.toList().subscribe(new Action1>>() { + @Override + public void call(List> t1) { + list.addAll(t1); + } + + }); + + return concat(list); + } + + private static class Concat implements Func1, Subscription> { + private final Observable[] sequences; + private int num = 0; + private int count = 0; + private Subscription s; + + Concat(final Observable... sequences) { + this.sequences = sequences; + this.num = sequences.length - 1; + } + + private final AtomicObservableSubscription Subscription = new AtomicObservableSubscription(); + + private final Subscription actualSubscription = new Subscription() { + + @Override + public void unsubscribe() { + if (null != s) + s.unsubscribe(); + } + }; + + public Subscription call(Observer observer) { + s = sequences[count].subscribe(new ConcatObserver(observer)); + + return Subscription.wrap(actualSubscription); + } + + private class ConcatObserver implements Observer { + private final Observer observer; + + ConcatObserver(Observer observer) { + this.observer = observer; + } + + @Override + public void onCompleted() { + if (num == count) + observer.onCompleted(); + else { + count++; + s = sequences[count].subscribe(this); + } + } + + @Override + public void onError(Exception e) { + observer.onError(e); + + } + + @Override + public void onNext(T args) { + observer.onNext(args); + + } + } + } +} \ 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 new file mode 100644 index 000000000..66b31b50e --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationDefer.java @@ -0,0 +1,30 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.functions.Func0; +import rx.util.functions.Func1; + +public final class OperationDefer { + + public static Func1, Subscription> defer(final Func0> observableFactory) { + return observableFactory.call()::subscribe; + } + +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationDematerialize.java b/HMCLAPI/src/main/java/rx/operators/OperationDematerialize.java new file mode 100644 index 000000000..535da7bfa --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationDematerialize.java @@ -0,0 +1,78 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Notification; +import rx.Observable; +import rx.Observer; +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. + */ +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. + * @see http://msdn.microsoft.com/en-us/library/hh229047(v=vs.103).aspx + */ + public static Func1, Subscription> dematerialize(final Observable> sequence) { + return new DematerializeObservable<>(sequence); + } + + private static class DematerializeObservable implements Func1, Subscription> { + + private final Observable> sequence; + + public DematerializeObservable(Observable> sequence) { + this.sequence = sequence; + } + + @Override + public Subscription call(final Observer observer) { + return sequence.subscribe(new Observer>() { + @Override + public void onCompleted() { + } + + @Override + public void onError(Exception e) { + } + + @Override + public void onNext(Notification value) { + switch (value.getKind()) { + case OnNext: + observer.onNext(value.getValue()); + break; + case OnError: + observer.onError(value.getException()); + break; + case OnCompleted: + observer.onCompleted(); + break; + } + } + }); + } + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationFilter.java b/HMCLAPI/src/main/java/rx/operators/OperationFilter.java new file mode 100644 index 000000000..b6c2f23e1 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationFilter.java @@ -0,0 +1,70 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +import rx.util.functions.Func1; + +public final class OperationFilter { + + public static Func1, Subscription> filter(Observable that, Func1 predicate) { + return new Filter<>(that, predicate); + } + + private static class Filter implements Func1, Subscription> { + + private final Observable that; + private final Func1 predicate; + private final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + + public Filter(Observable that, Func1 predicate) { + this.that = that; + this.predicate = predicate; + } + + @Override + public Subscription call(final Observer observer) { + return subscription.wrap(that.subscribe(new Observer() { + @Override + public void onNext(T value) { + try { + 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); + } + + @Override + public void onCompleted() { + observer.onCompleted(); + } + })); + } + + } +} \ 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 new file mode 100644 index 000000000..9b1b98796 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationFinally.java @@ -0,0 +1,91 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.functions.Action0; +import rx.util.functions.Func1; + +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 + * 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 + */ + 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; + + Finally(final Observable sequence, Action0 finalAction) { + this.sequence = sequence; + this.finalAction = finalAction; + } + + @Override + public Subscription call(Observer observer) { + return sequence.subscribe(new FinallyObserver(observer)); + } + + private class FinallyObserver implements Observer { + private final Observer observer; + + FinallyObserver(Observer observer) { + this.observer = observer; + } + + @Override + public void onCompleted() { + try { + observer.onCompleted(); + } finally { + finalAction.call(); + } + } + + @Override + public void onError(Exception e) { + try { + observer.onError(e); + } finally { + finalAction.call(); + } + } + + @Override + public void onNext(T args) { + observer.onNext(args); + } + } + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationMap.java b/HMCLAPI/src/main/java/rx/operators/OperationMap.java new file mode 100644 index 000000000..62431b105 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationMap.java @@ -0,0 +1,124 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +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. + */ + 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. + *

+ * 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. + */ + 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. + */ + private static class MapObservable implements Func1, Subscription> { + public MapObservable(Observable sequence, Func1 func) { + this.sequence = sequence; + this.func = func; + } + + private final Observable sequence; + + private final Func1 func; + + @Override + public Subscription call(Observer observer) { + return sequence.subscribe(new MapObserver<>(observer, func)); + } + } + + /** + * 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; + } + + Observer observer; + + Func1 func; + + @Override + public void onNext(T value) { + try { + observer.onNext(func.call(value)); + } catch (Exception ex) { + observer.onError(ex); + } + } + + @Override + public void onError(Exception ex) { + observer.onError(ex); + } + + @Override + public void onCompleted() { + observer.onCompleted(); + } + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationMaterialize.java b/HMCLAPI/src/main/java/rx/operators/OperationMaterialize.java new file mode 100644 index 000000000..c1f3a850a --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationMaterialize.java @@ -0,0 +1,78 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Notification; +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.functions.Func1; + +/** + * 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. + *

+ * 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. + * @see http://msdn.microsoft.com/en-us/library/hh229453(v=VS.103).aspx + */ + public static Func1>, Subscription> materialize(final Observable sequence) { + return new MaterializeObservable<>(sequence); + } + + private static class MaterializeObservable implements Func1>, Subscription> { + + private final Observable sequence; + + public MaterializeObservable(Observable sequence) { + this.sequence = sequence; + } + + @Override + public Subscription call(final Observer> observer) { + return sequence.subscribe(new Observer() { + + @Override + public void onCompleted() { + observer.onNext(new Notification<>()); + observer.onCompleted(); + } + + @Override + public void onError(Exception e) { + observer.onNext(new Notification<>(e)); + observer.onCompleted(); + } + + @Override + public void onNext(T value) { + observer.onNext(new Notification<>(value)); + } + + }); + } + + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationMerge.java b/HMCLAPI/src/main/java/rx/operators/OperationMerge.java new file mode 100644 index 000000000..3f3d4a194 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationMerge.java @@ -0,0 +1,255 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +import rx.util.SynchronizedObserver; +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. + * @see http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx + */ + public static Func1, Subscription> merge(final Observable> source) { + // wrap in a Func so that if a chain is built up, then asynchronously subscribed to twice we will have 2 instances of Take rather than 1 handing both, which is not thread-safe. + return new MergeObservable(source)::call; + } + + public static Func1, Subscription> merge(final Observable... sequences) { + return merge(Arrays.asList(sequences)); + } + + public static Func1, Subscription> merge(final List> sequences) { + return merge(Observable.create(new Func1>, Subscription>() { + + private volatile boolean unsubscribed = false; + + @Override + public Subscription call(Observer> observer) { + for (Observable o : sequences) { + if (!unsubscribed) { + observer.onNext(o); + } else { + // break out of the loop if we are unsubscribed + break; + } + } + if (!unsubscribed) { + observer.onCompleted(); + } + + return () -> { + unsubscribed = true; + }; + } + })); + } + + /** + * 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. + *

+ * 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. + * + * @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); + private volatile boolean parentCompleted = false; + private final ConcurrentHashMap childObservers = new ConcurrentHashMap<>(); + private final ConcurrentHashMap childSubscriptions = new ConcurrentHashMap<>(); + + private MergeObservable(Observable> sequences) { + this.sequences = sequences; + } + + @Override + public Subscription call(Observer actualObserver) { + + /** + * 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. + *

+ * Bug report: https://github.com/Netflix/RxJava/issues/200 + */ + AtomicObservableSubscription subscription = new AtomicObservableSubscription(ourSubscription); + SynchronizedObserver synchronizedObserver = new SynchronizedObserver<>(actualObserver, subscription); + + /** + * Subscribe to the parent Observable to get to the children Observables + */ + sequences.subscribe(new ParentObserver(synchronizedObserver)); + + /* 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. + *

+ * 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 { + + @Override + public void unsubscribe() { + stop(); + } + + public boolean stop() { + // try setting to false unless another thread beat us + 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()) { + _s.unsubscribe(); + } + return true; + } else { + // another thread beat us + return false; + } + } + } + + /** + * 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) { + this.actualObserver = actualObserver; + } + + @Override + public void onCompleted() { + parentCompleted = true; + // this *can* occur before the children are done, so if it does we won't send onCompleted + // 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()) { + actualObserver.onCompleted(); + } + } + } + } + + @Override + public void onError(Exception e) { + actualObserver.onError(e); + } + + @Override + public void onNext(Observable childObservable) { + if (stopped.get()) { + // we won't act on any further items + return; + } + + 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. + *

+ * 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); + Subscription _subscription = childObservable.subscribe(_w); + // remember this Observer and the subscription from it + childSubscriptions.put(_w, _subscription); + } + } + + /** + * Subscribe to each child Observable and forward their sequence of data to the actualObserver + * + */ + private class ChildObserver implements Observer { + + private final Observer actualObserver; + + public ChildObserver(Observer actualObserver) { + this.actualObserver = actualObserver; + } + + @Override + public void onCompleted() { + // remove self from map of Observers + 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()) { + // 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()) { + // 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()) { + actualObserver.onNext(args); + } + } + + } + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationMergeDelayError.java b/HMCLAPI/src/main/java/rx/operators/OperationMergeDelayError.java new file mode 100644 index 000000000..38ab323d2 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationMergeDelayError.java @@ -0,0 +1,327 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicBoolean; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +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. + *

+ * 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. + */ +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. + * @see http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx + */ + public static Func1, Subscription> mergeDelayError(final Observable> sequences) { + // wrap in a Func so that if a chain is built up, then asynchronously subscribed to twice we will have 2 instances of Take rather than 1 handing both, which is not thread-safe. + return new Func1, Subscription>() { + + @Override + public Subscription call(Observer observer) { + return new MergeDelayErrorObservable(sequences).call(observer); + } + }; + } + + public static Func1, Subscription> mergeDelayError(final Observable... sequences) { + return mergeDelayError(Observable.create(new Func1>, Subscription>() { + private volatile boolean unsubscribed = false; + + @Override + public Subscription call(Observer> observer) { + for (Observable o : sequences) { + if (!unsubscribed) { + observer.onNext(o); + } else { + // break out of the loop if we are unsubscribed + break; + } + } + if (!unsubscribed) { + observer.onCompleted(); + } + return new Subscription() { + + @Override + public void unsubscribe() { + unsubscribed = true; + } + + }; + } + })); + } + + public static Func1, Subscription> mergeDelayError(final List> sequences) { + return mergeDelayError(Observable.create(new Func1>, Subscription>() { + + private volatile boolean unsubscribed = false; + + @Override + public Subscription call(Observer> observer) { + for (Observable o : sequences) { + if (!unsubscribed) { + observer.onNext(o); + } else { + // break out of the loop if we are unsubscribed + break; + } + } + if (!unsubscribed) { + observer.onCompleted(); + } + + return new Subscription() { + + @Override + public void unsubscribe() { + unsubscribed = true; + } + + }; + } + })); + } + + /** + * 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. + *

+ * 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. + * + * @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); + private volatile boolean parentCompleted = false; + private final ConcurrentHashMap childObservers = new ConcurrentHashMap(); + private final ConcurrentHashMap childSubscriptions = new ConcurrentHashMap(); + // onErrors we received that will be delayed until everything is completed and then sent + private ConcurrentLinkedQueue onErrorReceived = new ConcurrentLinkedQueue(); + + private MergeDelayErrorObservable(Observable> sequences) { + this.sequences = sequences; + } + + public Subscription call(Observer actualObserver) { + /** + * Subscribe to the parent Observable to get to the children Observables + */ + sequences.subscribe(new ParentObserver(actualObserver)); + + /* 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. + *

+ * 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 { + + @Override + public void unsubscribe() { + stop(); + } + + public boolean stop() { + // try setting to false unless another thread beat us + 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()) { + _s.unsubscribe(); + } + return true; + } else { + // another thread beat us + return false; + } + } + } + + /** + * 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) { + this.actualObserver = actualObserver; + } + + @Override + public void onCompleted() { + parentCompleted = true; + // this *can* occur before the children are done, so if it does we won't send onCompleted + // 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) { + // 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) { + // an onError was received from more than 1 ChildObserver so we now send it as a delayed error + actualObserver.onError(new CompositeException(onErrorReceived)); + } else { + // no delayed error so send onCompleted + actualObserver.onCompleted(); + } + } + } + } + } + + @Override + public void onError(Exception e) { + actualObserver.onError(e); + } + + @Override + public void onNext(Observable childObservable) { + if (stopped.get()) { + // we won't act on any further items + return; + } + + 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. + *

+ * 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); + Subscription _subscription = childObservable.subscribe(_w); + // remember this Observer and the subscription from it + childSubscriptions.put(_w, _subscription); + } + } + + /** + * Subscribe to each child Observable and forward their sequence of data to the actualObserver + * + */ + private class ChildObserver implements Observer { + + private final Observer actualObserver; + private volatile boolean finished = false; + + public ChildObserver(Observer actualObserver) { + this.actualObserver = actualObserver; + } + + @Override + public void onCompleted() { + // remove self from map of Observers + 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()) { + finishObserver(); + } + } + + @Override + public void onError(Exception e) { + if (!stopped.get()) { + onErrorReceived.add(e); + // mark this ChildObserver as done + childObservers.remove(this); + // but do NOT forward to actualObserver as we want other ChildObservers to continue until completion + // and we'll delay the sending of onError until all others are done + + // we mark finished==true as a safety to ensure that if further calls to onNext occur we ignore them + finished = true; + + // check for whether the parent is completed and if so then perform the 'finishing' actions + finishObserver(); + } + } + + /** + * 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. + *

+ * TestCase testErrorDelayed4WithThreading specifically tests this use case. + */ + private void finishObserver() { + 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) { + // 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) { + // an onError was received from more than 1 ChildObserver so we now send it as a delayed error + actualObserver.onError(new CompositeException(onErrorReceived)); + } 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) { + actualObserver.onNext(args); + } + } + + } + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationMostRecent.java b/HMCLAPI/src/main/java/rx/operators/OperationMostRecent.java new file mode 100644 index 000000000..7cb4c3139 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationMostRecent.java @@ -0,0 +1,106 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.Iterator; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; + +import rx.Observable; +import rx.Observer; +import rx.util.Exceptions; + +/** + * Samples the most recent value in an observable sequence. + */ +public final class OperationMostRecent { + + public static Iterable mostRecent(final Observable source, T initialValue) { + + MostRecentObserver mostRecentObserver = new MostRecentObserver<>(initialValue); + MostRecentIterator nextIterator = new MostRecentIterator<>(mostRecentObserver); + + source.subscribe(mostRecentObserver); + + return () -> nextIterator; + + } + + private static class MostRecentIterator implements Iterator { + + private final MostRecentObserver observer; + + private MostRecentIterator(MostRecentObserver observer) { + this.observer = observer; + } + + @Override + public boolean hasNext() { + return !observer.isCompleted(); + } + + @Override + public T next() { + if (observer.getException() != null) { + throw Exceptions.propagate(observer.getException()); + } + return observer.getRecentValue(); + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Read only iterator"); + } + } + + private static class MostRecentObserver implements Observer { + private final AtomicBoolean completed = new AtomicBoolean(false); + private final AtomicReference value; + private final AtomicReference exception = new AtomicReference<>(); + + private MostRecentObserver(T value) { + this.value = new AtomicReference<>(value); + } + + @Override + public void onCompleted() { + completed.set(true); + } + + @Override + public void onError(Exception e) { + exception.set(e); + } + + @Override + public void onNext(T args) { + value.set(args); + } + + public boolean isCompleted() { + return completed.get(); + } + + public Exception getException() { + return exception.get(); + } + + public T getRecentValue() { + return value.get(); + } + + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationNext.java b/HMCLAPI/src/main/java/rx/operators/OperationNext.java new file mode 100644 index 000000000..11495fcd5 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationNext.java @@ -0,0 +1,148 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.Iterator; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.atomic.AtomicBoolean; + +import rx.Notification; +import rx.Observable; +import rx.Observer; +import rx.util.Exceptions; + +/** + * Samples the next value (blocking without buffering) from in an observable sequence. + */ +public final class OperationNext { + + public static Iterable next(final Observable items) { + + NextObserver nextObserver = new NextObserver<>(); + final NextIterator nextIterator = new NextIterator<>(nextObserver); + + items.materialize().subscribe(nextObserver); + + return () -> nextIterator; + + } + + private static class NextIterator implements Iterator { + + private final NextObserver observer; + + private NextIterator(NextObserver observer) { + this.observer = observer; + } + + @Override + public boolean hasNext() { + return !observer.isCompleted(false); + } + + @Override + public T next() { + if (observer.isCompleted(true)) { + throw new IllegalStateException("Observable is completed"); + } + + observer.await(); + + try { + return observer.takeNext(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw Exceptions.propagate(e); + } + + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Read only iterator"); + } + } + + private static class NextObserver implements Observer> { + private final BlockingQueue> buf = new ArrayBlockingQueue<>(1); + private final AtomicBoolean waiting = new AtomicBoolean(false); + + @Override + public void onCompleted() { + // ignore + } + + @Override + public void onError(Exception e) { + // ignore + } + + @Override + public void onNext(Notification args) { + + if (waiting.getAndSet(false) || !args.isOnNext()) { + Notification toOffer = args; + while (!buf.offer(toOffer)) { + Notification concurrentItem = buf.poll(); + + // in case if we won race condition with onComplete/onError method + if (!concurrentItem.isOnNext()) { + toOffer = concurrentItem; + } + } + } + + } + + public void await() { + waiting.set(true); + } + + public boolean isCompleted(boolean rethrowExceptionIfExists) { + Notification lastItem = buf.peek(); + if (lastItem == null) { + return false; + } + + if (lastItem.isOnError()) { + if (rethrowExceptionIfExists) { + throw Exceptions.propagate(lastItem.getException()); + } else { + return true; + } + } + + return lastItem.isOnCompleted(); + } + + public T takeNext() throws InterruptedException { + Notification next = buf.take(); + + if (next.isOnError()) { + throw Exceptions.propagate(next.getException()); + } + + 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 new file mode 100644 index 000000000..e3a344586 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationObserveOn.java @@ -0,0 +1,44 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Scheduler; +import rx.Subscription; +import rx.util.functions.Func1; + +public class OperationObserveOn { + + public static Func1, Subscription> observeOn(Observable source, Scheduler scheduler) { + return new ObserveOn<>(source, scheduler); + } + + private static class ObserveOn implements Func1, Subscription> { + private final Observable source; + private final Scheduler scheduler; + + public ObserveOn(Observable source, Scheduler scheduler) { + this.source = source; + this.scheduler = scheduler; + } + + @Override + public Subscription call(final Observer observer) { + return source.subscribe(new ScheduledObserver<>(observer, scheduler)); + } + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaFunction.java b/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaFunction.java new file mode 100644 index 000000000..021fcf920 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaFunction.java @@ -0,0 +1,99 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +import rx.util.CompositeException; +import rx.util.functions.Func1; + +public final class OperationOnErrorResumeNextViaFunction { + + public static Func1, Subscription> onErrorResumeNextViaFunction(Observable originalSequence, Func1> resumeFunction) { + return new OnErrorResumeNextViaFunction<>(originalSequence, resumeFunction); + } + + private static class OnErrorResumeNextViaFunction implements Func1, Subscription> { + + private final Func1> resumeFunction; + private final Observable originalSequence; + + public OnErrorResumeNextViaFunction(Observable originalSequence, Func1> resumeFunction) { + this.resumeFunction = resumeFunction; + this.originalSequence = originalSequence; + } + + @Override + public Subscription call(final Observer observer) { + // AtomicReference since we'll be accessing/modifying this across threads so we can switch it if needed + final AtomicReference subscriptionRef = new AtomicReference<>(new AtomicObservableSubscription()); + + // subscribe to the original Observable and remember the subscription + subscriptionRef.get().wrap(new AtomicObservableSubscription(originalSequence.subscribe(new Observer() { + @Override + public void onNext(T value) { + // forward the successful calls + observer.onNext(value); + } + + /** + * 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 */ + AtomicObservableSubscription currentSubscription = subscriptionRef.get(); + // check that we have not been unsubscribed before we can process the error + if (currentSubscription != null) { + try { + Observable resumeSequence = resumeFunction.call(ex); + /* 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 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 + public void onCompleted() { + // forward the successful calls + observer.onCompleted(); + } + }))); + + return () -> { + // this will get either the original, or the resumeSequence one and unsubscribe on it + Subscription s = subscriptionRef.getAndSet(null); + if (s != null) + s.unsubscribe(); + }; + } + } +} \ 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 new file mode 100644 index 000000000..7b3302000 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationOnErrorResumeNextViaObservable.java @@ -0,0 +1,91 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.concurrent.atomic.AtomicReference; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +import rx.util.functions.Func1; + +public final class OperationOnErrorResumeNextViaObservable { + + public static Func1, Subscription> onErrorResumeNextViaObservable(Observable originalSequence, Observable resumeSequence) { + return new OnErrorResumeNextViaObservable<>(originalSequence, resumeSequence); + } + + private static class OnErrorResumeNextViaObservable implements Func1, Subscription> { + + private final Observable resumeSequence; + private final Observable originalSequence; + + public OnErrorResumeNextViaObservable(Observable originalSequence, Observable resumeSequence) { + this.resumeSequence = resumeSequence; + this.originalSequence = originalSequence; + } + + public Subscription call(final Observer observer) { + final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + + // AtomicReference since we'll be accessing/modifying this across threads so we can switch it if needed + final AtomicReference subscriptionRef = new AtomicReference<>(subscription); + + // subscribe to the original Observable and remember the subscription + subscription.wrap(originalSequence.subscribe(new Observer() { + @Override + public void onNext(T value) { + // forward the successful calls + observer.onNext(value); + } + + /** + * 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 */ + 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' */ + 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 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(); + } + } + } + + @Override + public void onCompleted() { + // forward the successful calls + observer.onCompleted(); + } + })); + + return () -> { + // this will get either the original, or the resumeSequence one and unsubscribe on it + Subscription s = subscriptionRef.getAndSet(null); + if (s != null) + s.unsubscribe(); + }; + } + } +} \ 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 new file mode 100644 index 000000000..096ad1ea3 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationOnErrorReturn.java @@ -0,0 +1,108 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +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. + */ +public final class OperationOnErrorReturn { + + public static Func1, Subscription> onErrorReturn(Observable originalSequence, Func1 resumeFunction) { + return new OnErrorReturn<>(originalSequence, resumeFunction); + } + + private static class OnErrorReturn implements Func1, Subscription> { + private final Func1 resumeFunction; + private final Observable originalSequence; + + public OnErrorReturn(Observable originalSequence, Func1 resumeFunction) { + this.resumeFunction = resumeFunction; + this.originalSequence = originalSequence; + } + + @Override + public Subscription call(final Observer observer) { + final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + + // AtomicReference since we'll be accessing/modifying this across threads so we can switch it if needed + final AtomicReference subscriptionRef = new AtomicReference<>(subscription); + + // subscribe to the original Observable and remember the subscription + subscription.wrap(originalSequence.subscribe(new Observer() { + @Override + public void onNext(T value) { + // forward the successful calls + observer.onNext(value); + } + + /** + * 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 */ + AtomicObservableSubscription currentSubscription = subscriptionRef.get(); + // check that we have not been unsubscribed before we can process the error + if (currentSubscription != null) { + try { + /* 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 now completed */ + onCompleted(); + + /* 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 + public void onCompleted() { + // forward the successful calls + observer.onCompleted(); + } + })); + + return () -> { + // this will get either the original, or the resumeSequence one and unsubscribe on it + Subscription s = subscriptionRef.getAndSet(null); + if (s != null) + s.unsubscribe(); + }; + } + } +} \ 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 new file mode 100644 index 000000000..9cd50b3a2 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationScan.java @@ -0,0 +1,130 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +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. + * @see http://msdn.microsoft.com/en-us/library/hh211665(v=vs.103).aspx + */ + public static Func1, Subscription> scan(Observable sequence, T initialValue, Func2 accumulator) { + return new Accumulator<>(sequence, initialValue, accumulator); + } + + /** + * 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) { + return new Accumulator<>(sequence, null, accumulator); + } + + private static class Accumulator implements Func1, Subscription> { + private final Observable sequence; + private final T initialValue; + private final Func2 accumlatorFunction; + private final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + + private Accumulator(Observable sequence, T initialValue, Func2 accumulator) { + this.sequence = sequence; + this.initialValue = initialValue; + this.accumlatorFunction = accumulator; + } + + @Override + public Subscription call(final Observer observer) { + + return subscription.wrap(sequence.subscribe(new Observer() { + private T acc = initialValue; + 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 + */ + @Override + public synchronized void onNext(T value) { + if (acc == null) { + // we assume that acc is not allowed to be returned from accumulatorValue + // so it's okay to check null as being the state we initialize on + acc = value; + // this is all we do for this first value if we didn't have an initialValue + return; + } + if (!hasSentInitialValue) { + hasSentInitialValue = true; + observer.onNext(acc); + } + + try { + + acc = accumlatorFunction.call(acc, value); + if (acc == null) { + onError(new IllegalArgumentException("Null is an unsupported return value for an accumulator.")); + return; + } + observer.onNext(acc); + } 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); + } + + // synchronized because we access 'hasSentInitialValue' + @Override + public synchronized void onCompleted() { + // if only one sequence value existed, we send it without any accumulation + 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 new file mode 100644 index 000000000..36c3b3f3c --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationSkip.java @@ -0,0 +1,98 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.concurrent.atomic.AtomicInteger; + +import rx.Observable; +import rx.Observer; +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. + */ +public final class OperationSkip { + + /** + * 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) { + // wrap in a Observable so that if a chain is built up, then asynchronously subscribed to twice we will have 2 instances of Take rather than 1 handing both, which is not thread-safe. + return new Skip<>(items, num)::call; + } + + /** + * 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. + * + * @param + */ + private static class Skip implements Func1, Subscription> { + private final int num; + private final Observable items; + + Skip(final Observable items, final int num) { + this.num = num; + this.items = items; + } + + @Override + public Subscription call(Observer observer) { + return items.subscribe(new ItemObserver(observer)); + } + + /** + * Used to subscribe to the 'items' Observable sequence and forward to the actualObserver up to 'num' count. + */ + private class ItemObserver implements Observer { + + private AtomicInteger counter = new AtomicInteger(); + private final Observer observer; + + public ItemObserver(Observer observer) { + this.observer = observer; + } + + @Override + public void onCompleted() { + observer.onCompleted(); + } + + @Override + public void onError(Exception e) { + observer.onError(e); + } + + @Override + public void onNext(T args) { + // skip them until we reach the 'num' value + if (counter.incrementAndGet() > num) { + observer.onNext(args); + } + } + + } + + } +} \ No newline at end of file diff --git a/HMCLAPI/src/main/java/rx/operators/OperationSubscribeOn.java b/HMCLAPI/src/main/java/rx/operators/OperationSubscribeOn.java new file mode 100644 index 000000000..68e9fa4b7 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationSubscribeOn.java @@ -0,0 +1,67 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Scheduler; +import rx.Subscription; +import rx.util.functions.Action0; +import rx.util.functions.Func1; + + +public class OperationSubscribeOn { + + public static Func1, Subscription> subscribeOn(Observable source, Scheduler scheduler) { + return new SubscribeOn<>(source, scheduler); + } + + private static class SubscribeOn implements Func1, Subscription> { + private final Observable source; + private final Scheduler scheduler; + + public SubscribeOn(Observable source, Scheduler scheduler) { + this.source = source; + this.scheduler = scheduler; + } + + @Override + public Subscription call(final Observer observer) { + return scheduler.schedule(() -> new ScheduledSubscription(source.subscribe(observer), scheduler)); + } + } + + private static class ScheduledSubscription implements Subscription { + private final Subscription underlying; + private final Scheduler scheduler; + + private ScheduledSubscription(Subscription underlying, Scheduler scheduler) { + this.underlying = underlying; + this.scheduler = scheduler; + } + + @Override + public void unsubscribe() { + scheduler.schedule(new Action0() { + @Override + public void call() { + underlying.unsubscribe(); + } + }); + } + } + +} \ 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 new file mode 100644 index 000000000..a011ff011 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationSynchronize.java @@ -0,0 +1,72 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +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 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. + */ +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. + * + * @param observable + * @param + * @return + */ + public static Func1, Subscription> synchronize(Observable observable) { + return new Synchronize<>(observable); + } + + private static class Synchronize implements Func1, Subscription> { + + public Synchronize(Observable innerObservable) { + this.innerObservable = innerObservable; + } + + private final Observable innerObservable; + private SynchronizedObserver atomicObserver; + + @Override + public Subscription call(Observer observer) { + AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + atomicObserver = new SynchronizedObserver<>(observer, subscription); + return subscription.wrap(innerObservable.subscribe(atomicObserver)); + } + + } +} \ 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 new file mode 100644 index 000000000..4cd79a425 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationTake.java @@ -0,0 +1,132 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.concurrent.atomic.AtomicInteger; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.subscriptions.Subscriptions; +import rx.util.AtomicObservableSubscription; +import rx.util.functions.Func1; + +/** + * 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. + * + * @param items + * @param num + * @return + */ + public static Func1, Subscription> take(final Observable items, final int num) { + // wrap in a Func so that if a chain is built up, then asynchronously subscribed to twice we will have 2 instances of Take rather than 1 handing both, which is not thread-safe. + return new Take<>(items, num)::call; + } + + /** + * 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. + *

+ * 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. + * + * @param + */ + private static class Take implements Func1, Subscription> { + private final AtomicInteger counter = new AtomicInteger(); + private final Observable items; + private final int num; + private final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + + private Take(Observable items, int num) { + this.items = items; + this.num = num; + } + + @Override + public Subscription call(Observer observer) { + if (num < 1) { + items.subscribe(new Observer() + { + @Override + public void onCompleted() + { + } + + @Override + public void onError(Exception e) + { + } + + @Override + public void onNext(T args) + { + } + }).unsubscribe(); + observer.onCompleted(); + return Subscriptions.empty(); + } + + return subscription.wrap(items.subscribe(new ItemObserver(observer))); + } + + private class ItemObserver implements Observer { + private final Observer observer; + + public ItemObserver(Observer observer) { + this.observer = observer; + } + + @Override + public void onCompleted() { + if (counter.getAndSet(num) < num) { + observer.onCompleted(); + } + } + + @Override + public void onError(Exception e) { + if (counter.getAndSet(num) < num) { + observer.onError(e); + } + } + + @Override + public void onNext(T args) { + final int count = counter.incrementAndGet(); + if (count <= num) { + observer.onNext(args); + if (count == num) { + observer.onCompleted(); + } + } + 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 new file mode 100644 index 000000000..697a526c4 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationTakeLast.java @@ -0,0 +1,84 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.Iterator; +import java.util.concurrent.LinkedBlockingDeque; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +import rx.util.functions.Func1; + +/** + * Returns a specified number of contiguous elements from the end of an observable sequence. + */ +public final class OperationTakeLast { + + public static Func1, Subscription> takeLast(final Observable items, final int count) { + return new TakeLast<>(items, count)::call; + } + + private static class TakeLast implements Func1, Subscription> { + private final int count; + private final Observable items; + private final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + + TakeLast(final Observable items, final int count) { + this.count = count; + this.items = items; + } + + @Override + public Subscription call(Observer observer) { + return subscription.wrap(items.subscribe(new ItemObserver(observer))); + } + + private class ItemObserver implements Observer { + + private LinkedBlockingDeque deque = new LinkedBlockingDeque<>(count); + private final Observer observer; + + public ItemObserver(Observer observer) { + this.observer = observer; + } + + @Override + public void onCompleted() { + Iterator reverse = deque.descendingIterator(); + while (reverse.hasNext()) { + observer.onNext(reverse.next()); + } + observer.onCompleted(); + } + + @Override + public void onError(Exception e) { + observer.onError(e); + } + + @Override + public void onNext(T 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 new file mode 100644 index 000000000..dbb68a56f --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationTakeWhile.java @@ -0,0 +1,131 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.concurrent.atomic.AtomicInteger; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +import rx.util.AtomicObserver; +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. + */ +public final class OperationTakeWhile { + + /** + * 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 + * @return + */ + public static Func1, Subscription> takeWhile(final Observable items, final Func1 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. + * + * @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. + * @return + */ + public static Func1, Subscription> takeWhileWithIndex(final Observable items, final Func2 predicate) { + // wrap in a Func so that if a chain is built up, then asynchronously subscribed to twice we will have 2 instances of Take rather than 1 handing both, which is not thread-safe. + return new TakeWhile(items, predicate)::call; + } + + private static Func2 skipIndex(final Func1 underlying) { + return (T input, Integer index) -> underlying.call(input); + } + + /** + * 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. + *

+ * 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. + * + * @param + */ + private static class TakeWhile implements Func1, Subscription> { + private final AtomicInteger counter = new AtomicInteger(); + private final Observable items; + private final Func2 predicate; + private final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + + private TakeWhile(Observable items, Func2 predicate) { + this.items = items; + this.predicate = predicate; + } + + @Override + public Subscription call(Observer observer) { + return subscription.wrap(items.subscribe(new ItemObserver(observer))); + } + + private class ItemObserver implements Observer { + private final Observer observer; + + public ItemObserver(Observer observer) { + // Using AtomicObserver because the unsubscribe, onCompleted, onError and error handling behavior + // needs "isFinished" logic to not send duplicated events + // The 'testTakeWhile1' and 'testTakeWhile2' tests fail without this. + this.observer = new AtomicObserver<>(subscription, observer); + } + + @Override + public void onCompleted() { + observer.onCompleted(); + } + + @Override + public void onError(Exception e) { + observer.onError(e); + } + + @Override + public void onNext(T args) { + Boolean isSelected; + try { + isSelected = predicate.call(args, counter.getAndIncrement()); + } catch (Exception e) { + observer.onError(e); + return; + } + if (isSelected) { + observer.onNext(args); + } 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 new file mode 100644 index 000000000..9ba541db7 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationToObservableFuture.java @@ -0,0 +1,70 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +import rx.Observer; +import rx.Subscription; +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; + + public ToObservableFuture(Future that) { + this.that = that; + this.time = null; + this.unit = null; + } + + public ToObservableFuture(Future that, long time, TimeUnit unit) { + this.that = that; + this.time = time; + this.unit = unit; + } + + @Override + public Subscription call(Observer observer) { + try { + T value = (time == null) ? that.get() : that.get(time, unit); + + if (!that.isCancelled()) { + observer.onNext(value); + } + observer.onCompleted(); + } catch (Exception e) { + observer.onError(e); + } + + // the get() has already completed so there is no point in + // giving the user a way to cancel. + return Subscriptions.empty(); + } + } + + public static Func1, Subscription> toObservableFuture(final Future that) { + return new ToObservableFuture<>(that); + } + + public static Func1, Subscription> toObservableFuture(final Future that, long time, TimeUnit unit) { + return new ToObservableFuture<>(that, time, unit); + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationToObservableIterable.java b/HMCLAPI/src/main/java/rx/operators/OperationToObservableIterable.java new file mode 100644 index 000000000..20d30eb2c --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationToObservableIterable.java @@ -0,0 +1,40 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observer; +import rx.Subscription; +import rx.subscriptions.Subscriptions; +import rx.util.functions.Func1; + +/** + * Accepts an Iterable object and exposes it as an Observable. + * + * @param + * The type of the Iterable sequence. + */ +public final class OperationToObservableIterable { + + public static Func1, Subscription> toObservableIterable(Iterable iterable) { + return (Observer observer) -> { + for (T item : iterable) + observer.onNext(item); + observer.onCompleted(); + + 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 new file mode 100644 index 000000000..3bf8811bb --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationToObservableList.java @@ -0,0 +1,78 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentLinkedQueue; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.functions.Func1; + +public final class OperationToObservableList { + + public static Func1>, Subscription> toObservableList(Observable that) { + return new ToObservableList<>(that); + } + + private static class ToObservableList implements Func1>, Subscription> { + + private final Observable that; + + public ToObservableList(Observable that) { + this.that = that; + } + + @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 + list.add(value); + } + + @Override + public void onError(Exception ex) { + observer.onError(ex); + } + + @Override + public void onCompleted() { + try { + // copy from LinkedQueue to List since ConcurrentLinkedQueue does not implement the List interface + ArrayList l = new ArrayList<>(list.size()); + for (T t : list) + l.add(t); + + // benjchristensen => I want to make this list immutable but some clients are sorting this + // instead of using toSortedList() and this change breaks them until we migrate their code. + // observer.onNext(Collections.unmodifiableList(l)); + observer.onNext(l); + observer.onCompleted(); + } catch (Exception e) { + onError(e); + } + + } + }); + } + } +} \ 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 new file mode 100644 index 000000000..d5a74bd6d --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationToObservableSortedList.java @@ -0,0 +1,130 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ConcurrentLinkedQueue; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +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. + * + * @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 + * @return + */ + public static Func1>, Subscription> toSortedList(Observable sequence) { + return new ToObservableSortedList<>(sequence); + } + + /** + * Sort T objects using the defined sort function. + * + * @param sequence + * @param sortFunction + * @return + */ + public static Func1>, Subscription> toSortedList(Observable sequence, Func2 sortFunction) { + return new ToObservableSortedList<>(sequence, sortFunction); + } + + private static class ToObservableSortedList implements Func1>, Subscription> { + + private final Observable that; + private final ConcurrentLinkedQueue list = new ConcurrentLinkedQueue<>(); + private final Func2 sortFunction; + + // unchecked as we're support Object for the default + @SuppressWarnings("unchecked") + private ToObservableSortedList(Observable that) { + this(that, defaultSortFunction); + } + + private ToObservableSortedList(Observable that, Func2 sortFunction) { + this.that = that; + this.sortFunction = sortFunction; + } + + @Override + public Subscription call(final Observer> observer) { + return that.subscribe(new Observer() { + @Override + public void onNext(T value) { + // onNext can be concurrently executed so list must be thread-safe + list.add(value); + } + + @Override + public void onError(Exception ex) { + observer.onError(ex); + } + + @Override + public void onCompleted() { + try { + // copy from LinkedQueue to List since ConcurrentLinkedQueue does not implement the List interface + ArrayList l = new ArrayList<>(list.size()); + for (T t : list) { + l.add(t); + } + + // sort the list before delivery + Collections.sort(l, (T o1, T o2) -> sortFunction.call(o1, o2)); + + observer.onNext(Collections.unmodifiableList(l)); + observer.onCompleted(); + } catch (Exception e) { + onError(e); + } + + } + }); + } + + // raw because we want to support Object for this default + @SuppressWarnings("rawtypes") + private static Func2 defaultSortFunction = new DefaultComparableFunction(); + + private static class DefaultComparableFunction implements Func2 { + + // unchecked because we want to support Object for this default + @SuppressWarnings("unchecked") + @Override + public Integer call(Object t1, Object t2) { + Comparable c1 = (Comparable) t1; + Comparable c2 = (Comparable) t2; + return c1.compareTo(c2); + } + + } + + } +} \ No newline at end of file diff --git a/HMCLAPI/src/main/java/rx/operators/OperationWhere.java b/HMCLAPI/src/main/java/rx/operators/OperationWhere.java new file mode 100644 index 000000000..4e08aa70c --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationWhere.java @@ -0,0 +1,28 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.functions.Func1; + +public final class OperationWhere { + + public static Func1, Subscription> where(Observable that, Func1 predicate) { + return OperationFilter.filter(that, predicate); + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperationZip.java b/HMCLAPI/src/main/java/rx/operators/OperationZip.java new file mode 100644 index 000000000..15f43523e --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperationZip.java @@ -0,0 +1,259 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicBoolean; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +import rx.util.SynchronizedObserver; +import rx.util.functions.Func1; +import rx.util.functions.Func2; +import rx.util.functions.Func3; +import rx.util.functions.Func4; +import rx.util.functions.FuncN; +import rx.util.functions.Functions; + +public final class OperationZip { + + public static Func1, Subscription> zip(Observable w0, Observable w1, Func2 zipFunction) { + Aggregator a = new Aggregator<>(Functions.fromFunc(zipFunction)); + a.addObserver(new ZipObserver<>(a, w0)); + a.addObserver(new ZipObserver<>(a, w1)); + return a; + } + + public static Func1, Subscription> zip(Observable w0, Observable w1, Observable w2, Func3 zipFunction) { + Aggregator a = new Aggregator<>(Functions.fromFunc(zipFunction)); + a.addObserver(new ZipObserver<>(a, w0)); + a.addObserver(new ZipObserver<>(a, w1)); + a.addObserver(new ZipObserver<>(a, w2)); + return a; + } + + public static Func1, Subscription> zip(Observable w0, Observable w1, Observable w2, Observable w3, Func4 zipFunction) { + Aggregator a = new Aggregator<>(Functions.fromFunc(zipFunction)); + a.addObserver(new ZipObserver<>(a, w0)); + a.addObserver(new ZipObserver<>(a, w1)); + a.addObserver(new ZipObserver<>(a, w2)); + a.addObserver(new ZipObserver<>(a, w3)); + return a; + } + + /* + * ThreadSafe + */ + private static class ZipObserver implements Observer { + final Observable w; + final Aggregator a; + private final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + private final AtomicBoolean subscribed = new AtomicBoolean(false); + + public ZipObserver(Aggregator a, Observable w) { + this.a = a; + this.w = w; + } + + public void startWatching() { + if (subscribed.compareAndSet(false, true)) { + // only subscribe once even if called more than once + subscription.wrap(w.subscribe(this)); + } + } + + @Override + public void onCompleted() { + a.complete(this); + } + + @Override + public void onError(Exception e) { + a.error(this, e); + } + + @Override + public void onNext(T args) { + try { + a.next(this, args); + } catch (Exception e) { + onError(e); + } + } + } + + /** + * 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> { + + private volatile SynchronizedObserver observer; + private final FuncN zipFunction; + private final AtomicBoolean started = new AtomicBoolean(false); + 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 */ + 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 */ + private final ConcurrentLinkedQueue> observers = new ConcurrentLinkedQueue<>(); + + public Aggregator(FuncN zipFunction) { + this.zipFunction = zipFunction; + } + + /** + * 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. + * + * @param w + */ + private void addObserver(ZipObserver w) { + // initialize this ZipObserver + observers.add(w); + receivedValuesPerObserver.put(w, new ConcurrentLinkedQueue<>()); + } + + /** + * 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)) { + // 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. + * + * @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 */ + stop(); + } + } + + /** + * 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. + * + * @param w + * @param arg + */ + void next(ZipObserver w, Object arg) { + 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()) { + 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); + + // 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 */ + 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) { + // 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) { + 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 + // this 'next' method while another thread finishes calling this zipFunction + observer.onNext(zipFunction.call(argsToZip)); + } + + @Override + public Subscription call(Observer observer) { + if (started.compareAndSet(false, true)) { + AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + this.observer = new SynchronizedObserver<>(observer, subscription); + /* start the Observers */ + for (ZipObserver rw : observers) { + rw.startWatching(); + } + + return subscription.wrap(this::stop); + } 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 + * and result in deadlocks. (http://jira/browse/API-4060) + * + * 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) { + o.subscription.unsubscribe(); + } + } + } + } + + } + +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperatorGroupBy.java b/HMCLAPI/src/main/java/rx/operators/OperatorGroupBy.java new file mode 100644 index 000000000..6bfe50480 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperatorGroupBy.java @@ -0,0 +1,116 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import java.util.concurrent.ConcurrentHashMap; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.observables.GroupedObservable; +import rx.util.functions.Func1; +import rx.util.functions.Functions; + +public final class OperatorGroupBy { + + public static Func1>, Subscription> groupBy(Observable source, final Func1 keySelector, final Func1 elementSelector) { + + final Observable> keyval = source.map(new Func1>() { + @Override + public KeyValue call(T t) { + K key = keySelector.call(t); + R value = elementSelector.call(t); + + return new KeyValue(key, value); + } + }); + + return new GroupBy(keyval); + } + + public static Func1>, Subscription> groupBy(Observable source, final Func1 keySelector) { + return groupBy(source, keySelector, Functions. identity()); + } + + private static class GroupBy implements Func1>, Subscription> { + private final Observable> source; + private final ConcurrentHashMap keys = new ConcurrentHashMap(); + + private GroupBy(Observable> source) { + this.source = source; + } + + @Override + public Subscription call(final Observer> observer) { + + return source.subscribe(new Observer>() { + + @Override + public void onCompleted() { + observer.onCompleted(); + } + + @Override + public void onError(Exception e) { + observer.onError(e); + } + + @Override + public void onNext(final KeyValue args) { + K key = args.key; + boolean newGroup = keys.putIfAbsent(key, true) == null; + if (newGroup) { + observer.onNext(buildObservableFor(source, key)); + } + } + + }); + } + } + + private static GroupedObservable buildObservableFor(Observable> source, final K key) { + final Observable observable = source.filter(new Func1, Boolean>() { + @Override + public Boolean call(KeyValue pair) { + return key.equals(pair.key); + } + }).map(new Func1, R>() { + @Override + public R call(KeyValue pair) { + return pair.value; + } + }); + return new GroupedObservable(key, new Func1, Subscription>() { + + @Override + public Subscription call(Observer observer) { + return observable.subscribe(observer); + } + + }); + } + + private static class KeyValue { + private final K key; + private final V value; + + private KeyValue(K key, V value) { + this.key = key; + this.value = value; + } + } + +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperatorTakeUntil.java b/HMCLAPI/src/main/java/rx/operators/OperatorTakeUntil.java new file mode 100644 index 000000000..ca954aef5 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperatorTakeUntil.java @@ -0,0 +1,137 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +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. + */ + public static Observable takeUntil(final Observable source, final Observable other) { + Observable> s = Observable.create(new SourceObservable(source)); + Observable> o = Observable.create(new OtherObservable(other)); + + @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 + */ + Observable> result = Observable.merge(s, o); + + return result.takeWhile(new Func1, Boolean>() { + @Override + public Boolean call(Notification notification) { + return !notification.halt; + } + }).map(new Func1, T>() { + @Override + public T call(Notification notification) { + return notification.value; + } + }); + } + + private static class Notification { + private final boolean halt; + private final T value; + + public static Notification value(T value) { + return new Notification(false, value); + } + + public static Notification halt() { + return new Notification(true, null); + } + + private Notification(boolean halt, T value) { + this.halt = halt; + this.value = value; + } + + } + + private static class SourceObservable implements Func1>, Subscription> { + private final Observable sequence; + + private SourceObservable(Observable sequence) { + this.sequence = sequence; + } + + @Override + public Subscription call(final Observer> notificationObserver) { + return sequence.subscribe(new Observer() { + @Override + public void onCompleted() { + notificationObserver.onNext(Notification. halt()); + } + + @Override + public void onError(Exception e) { + notificationObserver.onError(e); + } + + @Override + public void onNext(T args) { + notificationObserver.onNext(Notification.value(args)); + } + }); + } + } + + private static class OtherObservable implements Func1>, Subscription> { + private final Observable sequence; + + private OtherObservable(Observable sequence) { + this.sequence = sequence; + } + + @Override + public Subscription call(final Observer> notificationObserver) { + return sequence.subscribe(new Observer() { + @Override + public void onCompleted() { + // Ignore + } + + @Override + public void onError(Exception e) { + notificationObserver.onError(e); + } + + @Override + public void onNext(E args) { + notificationObserver.onNext(Notification. halt()); + } + }); + } + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/OperatorToIterator.java b/HMCLAPI/src/main/java/rx/operators/OperatorToIterator.java new file mode 100644 index 000000000..53b0b8156 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/OperatorToIterator.java @@ -0,0 +1,85 @@ +package rx.operators; + +import java.util.Iterator; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +import rx.Notification; +import rx.Observable; +import rx.Observer; +import rx.util.Exceptions; + +/** + * @see https://github.com/Netflix/RxJava/issues/50 + */ +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. + */ + public static Iterator toIterator(Observable that) { + final BlockingQueue> notifications = new LinkedBlockingQueue>(); + + Observable.materialize(that).subscribe(new Observer>() { + @Override + public void onCompleted() { + // ignore + } + + @Override + public void onError(Exception e) { + // ignore + } + + @Override + public void onNext(Notification args) { + notifications.offer(args); + } + }); + + return new Iterator() { + private Notification buf; + + @Override + public boolean hasNext() { + if (buf == null) { + buf = take(); + } + return !buf.isOnCompleted(); + } + + @Override + public T next() { + if (buf == null) { + buf = take(); + } + if (buf.isOnError()) { + throw Exceptions.propagate(buf.getException()); + } + + T result = buf.getValue(); + buf = null; + return result; + } + + private Notification take() { + try { + return notifications.take(); + } catch (InterruptedException e) { + throw Exceptions.propagate(e); + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Read-only iterator"); + } + }; + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/ScheduledObserver.java b/HMCLAPI/src/main/java/rx/operators/ScheduledObserver.java new file mode 100644 index 000000000..ab2ba33db --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/ScheduledObserver.java @@ -0,0 +1,60 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.operators; + +import rx.Observer; +import rx.Scheduler; +import rx.util.functions.Action0; + +/* package */class ScheduledObserver implements Observer { + private final Observer underlying; + private final Scheduler scheduler; + + public ScheduledObserver(Observer underlying, Scheduler scheduler) { + this.underlying = underlying; + this.scheduler = scheduler; + } + + @Override + public void onCompleted() { + scheduler.schedule(new Action0() { + @Override + public void call() { + underlying.onCompleted(); + } + }); + } + + @Override + public void onError(final Exception e) { + scheduler.schedule(new Action0() { + @Override + public void call() { + underlying.onError(e); + } + }); + } + + @Override + public void onNext(final T args) { + scheduler.schedule(new Action0() { + @Override + public void call() { + underlying.onNext(args); + } + }); + } +} diff --git a/HMCLAPI/src/main/java/rx/operators/package.html b/HMCLAPI/src/main/java/rx/operators/package.html new file mode 100644 index 000000000..80ba7542b --- /dev/null +++ b/HMCLAPI/src/main/java/rx/operators/package.html @@ -0,0 +1,23 @@ + + +

Operators that allow composing Observables to transform and + manipulate data in an asynchronous, functional and thread-safe manner.

+

The operators are all exposed via the ObservableExtensions class

+ + \ No newline at end of file diff --git a/HMCLAPI/src/main/java/rx/package-info.java b/HMCLAPI/src/main/java/rx/package-info.java new file mode 100644 index 000000000..67d687027 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/package-info.java @@ -0,0 +1,45 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + *

Rx Observables

+ * + *

A library that enables subscribing to and composing asynchronous events and + * callbacks.

+ *

The Observable/Observer interfaces and associated operators (in + * the .operations package) are inspired by and attempt to conform to the + * Reactive Rx library in Microsoft .Net.

+ *

+ * More information can be found at http://msdn.microsoft.com/en-us/data/gg577609. + *

+ * + * + *

Compared with the Microsoft implementation: + *

    + *
  • Observable == IObservable
  • + *
  • Observer == IObserver
  • + *
  • Subscription == IDisposable
  • + *
  • ObservableExtensions == Observable
  • + *
+ *

+ *

Services which intend on exposing data asynchronously and wish + * to allow reactive processing and composition can implement the + * Watchable interface which then allows Watchers to subscribe to them + * and receive events.

+ *

Usage examples can be found on the Watchable and Watcher + * classes.

+ */ +package rx; \ No newline at end of file diff --git a/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandler.java b/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandler.java new file mode 100644 index 000000000..042d59a8a --- /dev/null +++ b/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandler.java @@ -0,0 +1,41 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.plugins; + +import rx.Observable; +import rx.Observer; + +/** + * 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. + *

+ * 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 + */ + 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 new file mode 100644 index 000000000..fd997e48c --- /dev/null +++ b/HMCLAPI/src/main/java/rx/plugins/RxJavaErrorHandlerDefault.java @@ -0,0 +1,31 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.plugins; + +/** + * Default implementation of {@link RxJavaErrorHandler} that does nothing. + * + * @ExcludeFromJavadoc + */ +public class RxJavaErrorHandlerDefault extends RxJavaErrorHandler { + + private static RxJavaErrorHandlerDefault INSTANCE = new RxJavaErrorHandlerDefault(); + + public static RxJavaErrorHandler getInstance() { + return INSTANCE; + } + +} diff --git a/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java b/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java new file mode 100644 index 000000000..6ded46ed5 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java @@ -0,0 +1,88 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.plugins; + +import rx.Observable; +import rx.Observer; +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. + *

+ * 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. + *

+ * 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. + *

+ * 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 + return onSubscribe; + } + + /** + * 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. + */ + public Subscription onSubscribeReturn(Observable observableInstance, Subscription subscription) { + // pass-thru by default + return subscription; + } + + /** + * 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. + */ + public Exception onSubscribeError(Observable observableInstance, Exception e) { + // pass-thru by default + return e; + } + +} diff --git a/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java b/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java new file mode 100644 index 000000000..7f17c5491 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java @@ -0,0 +1,29 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.plugins; + +/** + * Default no-op implementation of {@link RxJavaObservableExecutionHook} + */ +/* package */class RxJavaObservableExecutionHookDefault extends RxJavaObservableExecutionHook { + + private static RxJavaObservableExecutionHookDefault INSTANCE = new RxJavaObservableExecutionHookDefault(); + + public static RxJavaObservableExecutionHook getInstance() { + return INSTANCE; + } + +} diff --git a/HMCLAPI/src/main/java/rx/plugins/RxJavaPlugins.java b/HMCLAPI/src/main/java/rx/plugins/RxJavaPlugins.java new file mode 100644 index 000000000..69b08e6f5 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/plugins/RxJavaPlugins.java @@ -0,0 +1,147 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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: + *

    + *
  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. default implementation
  6. + *
+ * 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(); + private final AtomicReference observableExecutionHook = new AtomicReference(); + + private RxJavaPlugins() { + + } + + public static RxJavaPlugins getInstance() { + return INSTANCE; + } + + /** + * 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. + * + * @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 { + // 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) + */ + public void registerErrorHandler(RxJavaErrorHandler 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. + *

+ * 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 { + // 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) + */ + public void registerObservableExecutionHook(RxJavaObservableExecutionHook impl) { + if (!observableExecutionHook.compareAndSet(null, impl)) { + throw new IllegalStateException("Another strategy was already registered."); + } + } + + private static Object getPluginImplementationViaProperty(Class pluginClass) { + String classSimpleName = pluginClass.getSimpleName(); + /* + * Check system properties for plugin class. + *

+ * 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) { + try { + Class cls = Class.forName(implementingClass); + // narrow the scope (cast) to the type we're expecting + cls = cls.asSubclass(pluginClass); + return cls.newInstance(); + } catch (ClassCastException e) { + throw new RuntimeException(classSimpleName + " implementation is not an instance of " + classSimpleName + ": " + implementingClass); + } catch (ClassNotFoundException e) { + throw new RuntimeException(classSimpleName + " implementation class not found: " + implementingClass, e); + } catch (InstantiationException e) { + throw new RuntimeException(classSimpleName + " implementation not able to be instantiated: " + implementingClass, e); + } catch (IllegalAccessException e) { + throw new RuntimeException(classSimpleName + " implementation not able to be accessed: " + implementingClass, e); + } + } else { + return null; + } + } +} diff --git a/HMCLAPI/src/main/java/rx/subjects/Subject.java b/HMCLAPI/src/main/java/rx/subjects/Subject.java new file mode 100644 index 000000000..741671490 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/subjects/Subject.java @@ -0,0 +1,65 @@ +package rx.subjects; + +import java.util.concurrent.ConcurrentHashMap; +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.util.AtomicObservableSubscription; +import rx.util.SynchronizedObserver; +import rx.util.functions.Func1; + +public class Subject extends Observable implements Observer { + public static Subject create() { + final ConcurrentHashMap> observers = new ConcurrentHashMap>(); + + Func1, Subscription> onSubscribe = new Func1, Subscription>() { + @Override + public Subscription call(Observer observer) { + final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); + + subscription.wrap(new Subscription() { + @Override + public void unsubscribe() { + // on unsubscribe remove it from the map of outbound observers to notify + observers.remove(subscription); + } + }); + + // on subscribe add it to the map of outbound observers to notify + observers.put(subscription, new SynchronizedObserver(observer, subscription)); + return subscription; + } + }; + + return new Subject(onSubscribe, observers); + } + + private final ConcurrentHashMap> observers; + + protected Subject(Func1, Subscription> onSubscribe, ConcurrentHashMap> observers) { + super(onSubscribe); + this.observers = observers; + } + + @Override + public void onCompleted() { + for (Observer observer : observers.values()) { + observer.onCompleted(); + } + } + + @Override + public void onError(Exception e) { + for (Observer observer : observers.values()) { + observer.onError(e); + } + } + + @Override + public void onNext(T args) { + for (Observer observer : observers.values()) { + observer.onNext(args); + } + } + +} diff --git a/HMCLAPI/src/main/java/rx/subscriptions/BooleanSubscription.java b/HMCLAPI/src/main/java/rx/subscriptions/BooleanSubscription.java new file mode 100644 index 000000000..0ad92e1d0 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/subscriptions/BooleanSubscription.java @@ -0,0 +1,26 @@ +package rx.subscriptions; + +import java.util.concurrent.atomic.AtomicBoolean; + +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 + */ +public class BooleanSubscription implements Subscription { + + private final AtomicBoolean unsubscribed = new AtomicBoolean(false); + + public boolean isUnsubscribed() { + return unsubscribed.get(); + } + + @Override + public void unsubscribe() { + unsubscribed.set(true); + } + +} diff --git a/HMCLAPI/src/main/java/rx/subscriptions/Subscriptions.java b/HMCLAPI/src/main/java/rx/subscriptions/Subscriptions.java new file mode 100644 index 000000000..4c79ce7bf --- /dev/null +++ b/HMCLAPI/src/main/java/rx/subscriptions/Subscriptions.java @@ -0,0 +1,58 @@ +package rx.subscriptions; + +import rx.Subscription; +import rx.util.functions.Action0; +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() { + return EMPTY; + } + + /** + * A {@link Subscription} implemented via a Func + * + * @return {@link Subscription} + */ + public static Subscription create(final Action0 unsubscribe) { + return new Subscription() { + + @Override + public void unsubscribe() { + unsubscribe.call(); + } + + }; + } + + /** + * A {@link Subscription} implemented via an anonymous function (such as closures from other languages). + * + * @return {@link Subscription} + */ + public static Subscription create(final Object unsubscribe) { + final FuncN f = Functions.from(unsubscribe); + return new Subscription() { + + @Override + public void unsubscribe() { + f.call(); + } + + }; + } + + /** + * A {@link Subscription} that does nothing when its unsubscribe method is called. + */ + private static Subscription EMPTY = new Subscription() { + public void unsubscribe() { + } + }; +} diff --git a/HMCLAPI/src/main/java/rx/util/AtomicObservableSubscription.java b/HMCLAPI/src/main/java/rx/util/AtomicObservableSubscription.java new file mode 100644 index 000000000..50233586c --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/AtomicObservableSubscription.java @@ -0,0 +1,74 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.util; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; + +import rx.Subscription; + +/** + * Thread-safe wrapper around Observable Subscription that ensures unsubscribe can be called only once. + *

+ * Also used to: + *

+ *

    + *
  • allow the AtomicObserver to have access to the subscription in asynchronous execution for checking if unsubscribed occurred without onComplete/onError.
  • + *
  • handle both synchronous and asynchronous subscribe() execution flows
  • + *
+ */ +public final class AtomicObservableSubscription implements Subscription { + + private AtomicReference actualSubscription = new AtomicReference(); + private AtomicBoolean unsubscribed = new AtomicBoolean(false); + + public AtomicObservableSubscription() { + + } + + public AtomicObservableSubscription(Subscription actualSubscription) { + this.actualSubscription.set(actualSubscription); + } + + /** + * Wraps the actual subscription once it exists (if it wasn't available when constructed) + * + * @param actualSubscription + * @throws IllegalStateException + * if trying to set more than once (or use this method after setting via constructor) + */ + public AtomicObservableSubscription wrap(Subscription actualSubscription) { + if (!this.actualSubscription.compareAndSet(null, actualSubscription)) { + throw new IllegalStateException("Can not set subscription more than once."); + } + return this; + } + + @Override + public void unsubscribe() { + // get the real thing and set to null in an atomic operation so we will only ever call unsubscribe once + Subscription actual = actualSubscription.getAndSet(null); + // if it's not null we will unsubscribe + if (actual != null) { + actual.unsubscribe(); + unsubscribed.set(true); + } + } + + public boolean isUnsubscribed() { + return unsubscribed.get(); + } +} diff --git a/HMCLAPI/src/main/java/rx/util/AtomicObserver.java b/HMCLAPI/src/main/java/rx/util/AtomicObserver.java new file mode 100644 index 000000000..24519dc27 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/AtomicObserver.java @@ -0,0 +1,97 @@ +package rx.util; + +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicBoolean; + +import rx.Observer; +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 + *

+ * 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).
  • + *
+ *

+ * It will not synchronize onNext execution. Use the {@link SynchronizedObserver} to do that. + * + * @param + */ +public class AtomicObserver implements Observer { + + private final Observer actual; + private final AtomicBoolean isFinished = new AtomicBoolean(false); + private final AtomicObservableSubscription subscription; + + public AtomicObserver(AtomicObservableSubscription subscription, Observer actual) { + this.subscription = subscription; + this.actual = actual; + } + + @Override + public void onCompleted() { + if (isFinished.compareAndSet(false, true)) { + try { + actual.onCompleted(); + } catch (Exception e) { + // handle errors if the onCompleted implementation fails, not just if the Observable fails + onError(e); + } + // auto-unsubscribe + subscription.unsubscribe(); + } + } + + @Override + public void onError(Exception e) { + if (isFinished.compareAndSet(false, true)) { + try { + actual.onError(e); + } catch (Exception e2) { + // if the onError itself fails then pass to the plugin + // see https://github.com/Netflix/RxJava/issues/216 for further discussion + RxJavaPlugins.getInstance().getErrorHandler().handleError(e); + RxJavaPlugins.getInstance().getErrorHandler().handleError(e2); + // and throw exception despite that not being proper for Rx + // https://github.com/Netflix/RxJava/issues/198 + throw new RuntimeException("Error occurred when trying to propagate error to Observer.onError", new CompositeException(Arrays.asList(e, e2))); + } + // auto-unsubscribe + subscription.unsubscribe(); + } + } + + @Override + public void onNext(T args) { + try { + 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/CompositeException.java b/HMCLAPI/src/main/java/rx/util/CompositeException.java new file mode 100644 index 000000000..c19a5f5ff --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/CompositeException.java @@ -0,0 +1,65 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +/** + * Exception that is a composite of 1 or more other exceptions. + *

+ * The getMessage() will return a concatenation of the composite exceptions. + */ +public class CompositeException extends RuntimeException { + + private static final long serialVersionUID = 3026362227162912146L; + + private final List exceptions; + private final String message; + + public CompositeException(String messagePrefix, Collection errors) { + StringBuilder _message = new StringBuilder(); + if (messagePrefix != null) { + _message.append(messagePrefix).append(" => "); + } + + List _exceptions = new ArrayList(); + for (Exception e : errors) { + _exceptions.add(e); + if (_message.length() > 0) { + _message.append(", "); + } + _message.append(e.getClass().getSimpleName()).append(":").append(e.getMessage()); + } + this.exceptions = Collections.unmodifiableList(_exceptions); + this.message = _message.toString(); + } + + public CompositeException(Collection errors) { + this(null, errors); + } + + public List getExceptions() { + return exceptions; + } + + @Override + public String getMessage() { + return message; + } +} \ No newline at end of file diff --git a/HMCLAPI/src/main/java/rx/util/Exceptions.java b/HMCLAPI/src/main/java/rx/util/Exceptions.java new file mode 100644 index 000000000..6fb97f1d1 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/Exceptions.java @@ -0,0 +1,31 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.util; + +public class Exceptions { + private Exceptions() { + + } + + public static RuntimeException propagate(Throwable t) { + if (t instanceof RuntimeException) { + throw (RuntimeException) t; + } 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 new file mode 100644 index 000000000..5f7418b21 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/Range.java @@ -0,0 +1,75 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.util; + +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; + + public static Range createWithCount(int start, int count) { + return create(start, start + count); + } + + public static Range create(int start, int end) { + return new Range(start, end, 1); + } + + public static Range createWithStep(int start, int end, int step) { + return new Range(start, end, step); + } + + private Range(int start, int end, int step) { + this.start = start; + this.end = end; + this.step = step; + } + + @Override + public Iterator iterator() { + return new Iterator() { + private int current = start; + + @Override + public boolean hasNext() { + return current < end; + } + + @Override + public Integer next() { + if (!hasNext()) { + throw new NoSuchElementException("No more elements"); + } + int result = current; + current += step; + return result; + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Read only iterator"); + } + }; + } + + @Override + 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 new file mode 100644 index 000000000..c75cac2a6 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/SynchronizedObserver.java @@ -0,0 +1,108 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.util; + +import rx.Observer; + +/** + * A thread-safe Observer for transitioning states in operators. + *

+ * 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.
  • + *
+ * + * @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 + */ + + private final Observer observer; + private final AtomicObservableSubscription subscription; + private volatile boolean finishRequested = false; + private volatile boolean finished = false; + + public SynchronizedObserver(Observer Observer, AtomicObservableSubscription subscription) { + this.observer = Observer; + this.subscription = subscription; + } + + @Override + public void onNext(T arg) { + 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 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()) { + // 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()) { + return; + } + observer.onError(e); + finished = true; + } + } + + @Override + public void onCompleted() { + 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()) { + 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 new file mode 100644 index 000000000..62d57bd56 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Action0.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..14fa7ced8 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Action1.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..8a17875a9 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Action2.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..2b613b621 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Action3.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..4e7d39703 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Func0.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..3eb17e625 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Func1.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..ab2a04442 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Func2.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..fc1dfb49b --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Func3.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..09d738ff7 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Func4.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..b6550ef0b --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Func5.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..a241d5553 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Func6.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..972cc405d --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Func7.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..5cbd10c1f --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Func8.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..8f2e546e4 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Func9.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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 new file mode 100644 index 000000000..7b1b48763 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/FuncN.java @@ -0,0 +1,20 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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/Function.java b/HMCLAPI/src/main/java/rx/util/functions/Function.java new file mode 100644 index 000000000..cfe85a221 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Function.java @@ -0,0 +1,10 @@ +package rx.util.functions; + +/** + * All Func and Action interfaces extend from this. + *

+ * Marker interface to allow isntanceof checks. + */ +public interface Function { + +} diff --git a/HMCLAPI/src/main/java/rx/util/functions/FunctionLanguageAdaptor.java b/HMCLAPI/src/main/java/rx/util/functions/FunctionLanguageAdaptor.java new file mode 100644 index 000000000..6ec87f358 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/FunctionLanguageAdaptor.java @@ -0,0 +1,39 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.util.functions; + +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); + + /** + * The Class of the Function that this adaptor serves. + *

+ * 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 new file mode 100644 index 000000000..d93270089 --- /dev/null +++ b/HMCLAPI/src/main/java/rx/util/functions/Functions.java @@ -0,0 +1,579 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.util.functions; + +import java.util.Collection; +import java.util.concurrent.ConcurrentHashMap; +import org.jackhuang.hellominecraft.logging.logger.Logger; + +/** + * Allows execution of functions from multiple different languages. + *

+ * Language support is provided via implementations of {@link FunctionLanguageAdaptor}. + *

+ * This class will dynamically look for known language adaptors on the classpath at startup or new ones can be registered using {@link #registerLanguageAdaptor(Class[], FunctionLanguageAdaptor)}. + */ +public class Functions { + + private static final Logger logger = new Logger("Functions"); + + private final static ConcurrentHashMap, FunctionLanguageAdaptor> languageAdaptors = new ConcurrentHashMap, FunctionLanguageAdaptor>(); + + static { + /* optimistically look for supported languages if they are in the classpath */ + loadLanguageAdaptor("Groovy"); + loadLanguageAdaptor("JRuby"); + loadLanguageAdaptor("Clojure"); + loadLanguageAdaptor("Scala"); + // as new languages arise we can add them here but this does not prevent someone from using 'registerLanguageAdaptor' directly + } + + private static boolean loadLanguageAdaptor(String name) { + String className = "rx.lang." + name.toLowerCase() + "." + name + "Adaptor"; + try { + Class c = Class.forName(className); + FunctionLanguageAdaptor a = (FunctionLanguageAdaptor) c.newInstance(); + registerLanguageAdaptor(a.getFunctionClass(), a); + logger.info("Successfully loaded function language adaptor: " + name + " with path: " + className); + } catch (ClassNotFoundException e) { + logger.info("Could not find function language adaptor: " + name + " with path: " + className); + return false; + } catch (Exception e) { + logger.error("Failed trying to initialize function language adaptor: " + className, e); + return false; + } + return true; + } + + public static void registerLanguageAdaptor(Class[] functionClasses, FunctionLanguageAdaptor adaptor) { + for (Class functionClass : functionClasses) { + if (functionClass.getPackage().getName().startsWith("java.")) { + throw new IllegalArgumentException("FunctionLanguageAdaptor implementations can not specify java.lang.* classes."); + } + languageAdaptors.put(functionClass, adaptor); + } + } + + public static void removeLanguageAdaptor(Class functionClass) { + languageAdaptors.remove(functionClass); + } + + public static Collection getRegisteredLanguageAdaptors() { + return languageAdaptors.values(); + } + + /** + * Utility method for determining the type of closure/function and executing it. + * + * @param function + */ + @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 */ + if (function instanceof Function) { + return fromFunction((Function) function); + } else { + /* not an Rx Function so try language adaptors */ + + // check for language adaptor + for (final Class c : languageAdaptors.keySet()) { + if (c.isInstance(function)) { + final FunctionLanguageAdaptor la = languageAdaptors.get(c); + // found the language adaptor so wrap in FuncN and return + return new FuncN() { + + @Override + public Object call(Object... args) { + return la.call(function, args); + } + + }; + } + } + // no language adaptor found + } + + // no support found + throw new RuntimeException("Unsupported closure type: " + function.getClass().getSimpleName()); + } + + // + // @SuppressWarnings("unchecked") + // private static R executionRxFunction(Function function, Object... args) { + // // check Func* classes + // if (function instanceof Func0) { + // Func0 f = (Func0) function; + // if (args.length != 0) { + // throw new RuntimeException("The closure was Func0 and expected no arguments, but we received: " + args.length); + // } + // return (R) f.call(); + // } else if (function instanceof Func1) { + // Func1 f = (Func1) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Func1 and expected 1 argument, but we received: " + args.length); + // } + // return f.call(args[0]); + // } else if (function instanceof Func2) { + // Func2 f = (Func2) function; + // if (args.length != 2) { + // throw new RuntimeException("The closure was Func2 and expected 2 arguments, but we received: " + args.length); + // } + // return f.call(args[0], args[1]); + // } else if (function instanceof Func3) { + // Func3 f = (Func3) function; + // if (args.length != 3) { + // throw new RuntimeException("The closure was Func3 and expected 3 arguments, but we received: " + args.length); + // } + // return (R) f.call(args[0], args[1], args[2]); + // } else if (function instanceof Func4) { + // Func4 f = (Func4) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Func4 and expected 4 arguments, but we received: " + args.length); + // } + // return f.call(args[0], args[1], args[2], args[3]); + // } else if (function instanceof Func5) { + // Func5 f = (Func5) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Func5 and expected 5 arguments, but we received: " + args.length); + // } + // return f.call(args[0], args[1], args[2], args[3], args[4]); + // } else if (function instanceof Func6) { + // Func6 f = (Func6) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Func6 and expected 6 arguments, but we received: " + args.length); + // } + // return f.call(args[0], args[1], args[2], args[3], args[4], args[5]); + // } else if (function instanceof Func7) { + // Func7 f = (Func7) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Func7 and expected 7 arguments, but we received: " + args.length); + // } + // return f.call(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + // } else if (function instanceof Func8) { + // Func8 f = (Func8) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Func8 and expected 8 arguments, but we received: " + args.length); + // } + // return f.call(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); + // } else if (function instanceof Func9) { + // Func9 f = (Func9) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Func9 and expected 9 arguments, but we received: " + args.length); + // } + // return f.call(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]); + // } else if (function instanceof FuncN) { + // FuncN f = (FuncN) function; + // return f.call(args); + // } else if (function instanceof Action0) { + // Action0 f = (Action0) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Action0 and expected 0 arguments, but we received: " + args.length); + // } + // f.call(); + // return null; + // } else if (function instanceof Action1) { + // Action1 f = (Action1) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Action1 and expected 1 argument, but we received: " + args.length); + // } + // f.call(args[0]); + // return null; + // } else if (function instanceof Action2) { + // Action2 f = (Action2) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Action2 and expected 2 argument, but we received: " + args.length); + // } + // f.call(args[0], args[1]); + // return null; + // } else if (function instanceof Action3) { + // Action3 f = (Action3) function; + // if (args.length != 1) { + // throw new RuntimeException("The closure was Action1 and expected 1 argument, but we received: " + args.length); + // } + // f.call(args[0], args[1], args[2]); + // return null; + // } + // + // throw new RuntimeException("Unknown implementation of Function: " + function.getClass().getSimpleName()); + // } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private static FuncN fromFunction(Function function) { + // check Func* classes + if (function instanceof Func0) { + return fromFunc((Func0) function); + } else if (function instanceof Func1) { + return fromFunc((Func1) function); + } else if (function instanceof Func2) { + return fromFunc((Func2) function); + } else if (function instanceof Func3) { + return fromFunc((Func3) function); + } else if (function instanceof Func4) { + return fromFunc((Func4) function); + } else if (function instanceof Func5) { + return fromFunc((Func5) function); + } else if (function instanceof Func6) { + return fromFunc((Func6) function); + } else if (function instanceof Func7) { + return fromFunc((Func7) function); + } else if (function instanceof Func8) { + return fromFunc((Func8) function); + } else if (function instanceof Func9) { + return fromFunc((Func9) function); + } else if (function instanceof FuncN) { + return (FuncN) function; + } else if (function instanceof Action0) { + return fromAction((Action0) function); + } else if (function instanceof Action1) { + return fromAction((Action1) function); + } else if (function instanceof Action2) { + return fromAction((Action2) function); + } else if (function instanceof Action3) { + return fromAction((Action3) function); + } + + throw new RuntimeException("Unknown implementation of Function: " + function.getClass().getSimpleName()); + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromFunc(final Func0 f) { + return new FuncN() { + + @Override + public R call(Object... args) { + if (args.length != 0) { + throw new RuntimeException("Func0 expecting 0 arguments."); + } + return f.call(); + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromFunc(final Func1 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public R call(Object... args) { + if (args.length != 1) { + throw new RuntimeException("Func1 expecting 1 argument."); + } + return f.call((T0) args[0]); + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromFunc(final Func2 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public R call(Object... args) { + if (args.length != 2) { + throw new RuntimeException("Func2 expecting 2 arguments."); + } + return f.call((T0) args[0], (T1) args[1]); + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromFunc(final Func3 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public R call(Object... args) { + if (args.length != 3) { + throw new RuntimeException("Func3 expecting 3 arguments."); + } + return f.call((T0) args[0], (T1) args[1], (T2) args[2]); + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromFunc(final Func4 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public R call(Object... args) { + if (args.length != 4) { + throw new RuntimeException("Func4 expecting 4 arguments."); + } + return f.call((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]); + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromFunc(final Func5 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public R call(Object... args) { + if (args.length != 5) { + throw new RuntimeException("Func5 expecting 5 arguments."); + } + return f.call((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]); + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromFunc(final Func6 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public R call(Object... args) { + if (args.length != 6) { + throw new RuntimeException("Func6 expecting 6 arguments."); + } + return f.call((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]); + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromFunc(final Func7 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public R call(Object... args) { + if (args.length != 7) { + throw new RuntimeException("Func7 expecting 7 arguments."); + } + return f.call((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5], (T6) args[6]); + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromFunc(final Func8 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public R call(Object... args) { + if (args.length != 8) { + throw new RuntimeException("Func8 expecting 8 arguments."); + } + return f.call((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5], (T6) args[6], (T7) args[7]); + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromFunc(final Func9 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public R call(Object... args) { + if (args.length != 9) { + throw new RuntimeException("Func9 expecting 9 arguments."); + } + return f.call((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5], (T6) args[6], (T7) args[7], (T8) args[8]); + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromAction(final Action0 f) { + return new FuncN() { + + @Override + public Void call(Object... args) { + if (args.length != 0) { + throw new RuntimeException("Action0 expecting 0 arguments."); + } + f.call(); + return null; + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromAction(final Action1 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public Void call(Object... args) { + if (args.length != 1) { + throw new RuntimeException("Action1 expecting 1 argument."); + } + f.call((T0) args[0]); + return null; + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromAction(final Action2 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public Void call(Object... args) { + if (args.length != 2) { + throw new RuntimeException("Action3 expecting 2 arguments."); + } + f.call((T0) args[0], (T1) args[1]); + return null; + } + + }; + } + + /** + * Convert a function to FuncN to allow heterogeneous handling of functions with different arities. + * + * @param f + * @return {@link FuncN} + */ + public static FuncN fromAction(final Action3 f) { + return new FuncN() { + + @SuppressWarnings("unchecked") + @Override + public Void call(Object... args) { + if (args.length != 3) { + throw new RuntimeException("Action3 expecting 3 arguments."); + } + f.call((T0) args[0], (T1) args[1], (T2) args[2]); + return null; + } + + }; + } + + @SuppressWarnings("unchecked") + public static Func1 alwaysTrue() { + return (Func1) AlwaysTrue.INSTANCE; + } + + @SuppressWarnings("unchecked") + public static Func1 identity() { + return (Func1) Identity.INSTANCE; + } + + private enum AlwaysTrue implements Func1 { + INSTANCE; + + @Override + public Boolean call(Object o) { + return true; + } + } + + private enum Identity implements Func1 { + INSTANCE; + + @Override + public Object call(Object o) { + return o; + } + } + +} diff --git a/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N.properties b/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N.properties index 32d5d3745..157043a74 100644 --- a/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N.properties +++ b/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N.properties @@ -1,17 +1,18 @@ -# Copyright 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 2 of the License, or -# (at your option) any later version. +# 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 +# (at your option) any later version. +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License -# along with this program. +# along with this program. If not, see {http://www.gnu.org/licenses/}. launch.failed=\u542f\u52a8\u5931\u8d25 launch.failed_creating_process=\u542f\u52a8\u5931\u8d25\uff0c\u5728\u521b\u5efa\u65b0\u8fdb\u7a0b\u65f6\u53d1\u751f\u9519\u8bef\uff0c\u53ef\u80fd\u662fJava\u8def\u5f84\u9519\u8bef\u3002 launch.failed_sh_permission=\u4e3a\u542f\u52a8\u6587\u4ef6\u6dfb\u52a0\u6743\u9650\u65f6\u53d1\u751f\u9519\u8bef @@ -239,7 +240,7 @@ mainwindow.enter_script_name=\u8f93\u5165\u8981\u751f\u6210\u811a\u672c\u7684\u6 mainwindow.make_launch_succeed=\u542f\u52a8\u811a\u672c\u5df2\u751f\u6210\u5b8c\u6bd5: mainwindow.no_version=\u672a\u627e\u5230\u4efb\u4f55\u7248\u672c\uff0c\u662f\u5426\u8fdb\u5165\u6e38\u620f\u4e0b\u8f7d\uff1f -launcher.about=\u9ed8\u8ba4\u80cc\u666f\u56fe\u6765\u81eaLiberty Dome\u670d\u52a1\u5668\u3002
\u5173\u4e8e\u4f5c\u8005\uff1a
\n\u767e\u5ea6ID\uff1ahuanghongxun20
\nmcbbs\uff1ahuanghongxun
\n\u90ae\u7bb1\uff1ahuanghongxun2008@126.com
\nMinecraft Forum ID: klkl6523
\n\u6b22\u8fce\u63d0\u4ea4Bug\u54e6
\nCopyright (c) 2013-2015 huangyuhui.
\u514d\u8d23\u58f0\u660e\uff1aMinecraft\u8f6f\u4ef6\u7248\u6743\u5f52Mojang AB\u6240\u6709\uff0c\u6e38\u620f\u7531\u4e8e\u8bef\u64cd\u4f5c\u672c\u542f\u52a8\u5668\u800c\u4e22\u5931\u6570\u636e\u7684\u6982\u4e0d\u8d1f\u8d23\u3002 +launcher.about=\u9ed8\u8ba4\u80cc\u666f\u56fe\u6765\u81eaLiberty Dome\u670d\u52a1\u5668\u3002
\u5173\u4e8e\u4f5c\u8005\uff1a
\n\u767e\u5ea6ID\uff1ahuanghongxun20
\nmcbbs\uff1ahuanghongxun
\n\u90ae\u7bb1\uff1ahuanghongxun2008@126.com
\nMinecraft Forum ID: klkl6523
\n\u6b22\u8fce\u63d0\u4ea4Bug\u54e6
\nCopyright (c) 2013-2015 huangyuhui.
\u514d\u8d23\u58f0\u660e\uff1aMinecraft\u8f6f\u4ef6\u7248\u6743\u5f52Mojang AB\u6240\u6709\uff0c\u6e38\u620f\u7531\u4e8e\u8bef\u64cd\u4f5c\u672c\u542f\u52a8\u5668\u800c\u4e22\u5931\u6570\u636e\u7684\u6982\u4e0d\u8d1f\u8d23\u3002
\u672c\u542f\u52a8\u5668\u5728GPLv2\u534f\u8bae\u4e0b\u5f00\u6e90:http://github.com/huanghongxun/HMCL/ launcher.download_source=\u4e0b\u8f7d\u6e90 launcher.background_location=\u80cc\u666f\u5730\u5740 launcher.exit_failed=\u5f3a\u5236\u9000\u51fa\u5931\u8d25\uff0c\u53ef\u80fd\u662fForge 1.7.10\u53ca\u66f4\u9ad8\u7248\u672c\u5bfc\u81f4\u7684\uff0c\u65e0\u6cd5\u89e3\u51b3\u3002 diff --git a/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_en.properties b/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_en.properties index fc6bb513f..ee0a0edbc 100644 --- a/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_en.properties +++ b/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_en.properties @@ -1,17 +1,18 @@ -# Copyright 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 2 of the License, or -# (at your option) any later version. +# 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 +# (at your option) any later version. +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License -# along with this program. +# along with this program. If not, see {http://www.gnu.org/licenses/}. launch.failed=Failed to launch launch.failed_creating_process=Failed to create process, maybe your java path is wrong, please modify your java path. launch.failed_sh_permission=Failed to add permission to the launch script @@ -239,7 +240,7 @@ mainwindow.enter_script_name=Enter the script name. mainwindow.make_launch_succeed=Finished script creation. mainwindow.no_version=No version found. Switch to Game Downloads Tab? -launcher.about=About Author
\nEmail\uff1ahuanghongxun2008@126.com
\nMinecraft Forum ID: klkl6523
\nCopyright (c) 2013 huangyuhui +launcher.about=About Author
\nEmail\uff1ahuanghongxun2008@126.com
\nMinecraft Forum ID: klkl6523
\nCopyright (c) 2013 huangyuhui
Opened source under GPL v2 licence:http://github.com/huanghongxun/HMCL/ launcher.download_source=Download Source launcher.background_location=Background Location launcher.exit_failed=Failed to shutdown. diff --git a/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_zh.properties b/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_zh.properties index eac685a3a..6775e082e 100644 --- a/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_zh.properties +++ b/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_zh.properties @@ -1,17 +1,18 @@ -# Copyright 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 2 of the License, or -# (at your option) any later version. +# 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 +# (at your option) any later version. +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License -# along with this program. +# along with this program. If not, see {http://www.gnu.org/licenses/}. launch.failed=\u555f\u52d5\u5931\u6557 launch.failed_creating_process=\u555f\u52d5\u5931\u6557\uff0c\u5728\u5275\u5efa\u65b0\u9032\u7a0b\u6642\u767c\u751f\u932f\u8aa4\uff0c\u53ef\u80fd\u662fJava\u8def\u5f91\u932f\u8aa4\u3002 launch.failed_sh_permission=\u70ba\u555f\u52d5\u6587\u4ef6\u6dfb\u52a0\u6b0a\u9650\u6642\u767c\u751f\u932f\u8aa4 @@ -239,7 +240,7 @@ mainwindow.enter_script_name=\u8f38\u5165\u8981\u751f\u6210\u8173\u672c\u7684\u6 mainwindow.make_launch_succeed=\u555f\u52d5\u8173\u672c\u5df2\u751f\u6210\u5b8c\u7562: mainwindow.no_version=\u672a\u627e\u5230\u4efb\u4f55\u7248\u672c\uff0c\u662f\u5426\u9032\u5165\u904a\u6232\u4e0b\u8f09\uff1f -launcher.about=\u9ed8\u8a8d\u80cc\u666f\u5716\u4f86\u81eaLiberty Dome\u670d\u52d9\u5668\u3002
\u95dc\u65bc\u4f5c\u8005\uff1a
\n\u767e\u5ea6ID\uff1ahuanghongxun20
\nmcbbs\uff1ahuanghongxun
\n\u90f5\u7bb1\uff1ahuanghongxun2008@126.com
\nMinecraft Forum ID: klkl6523
\n\u6b61\u8fce\u63d0\u4ea4Bug\u54e6
\nCopyright (c) 2013 huangyuhui +launcher.about=\u9ed8\u8a8d\u80cc\u666f\u5716\u4f86\u81eaLiberty Dome\u670d\u52d9\u5668\u3002
\u95dc\u65bc\u4f5c\u8005\uff1a
\n\u767e\u5ea6ID\uff1ahuanghongxun20
\nmcbbs\uff1ahuanghongxun
\n\u90f5\u7bb1\uff1ahuanghongxun2008@126.com
\nMinecraft Forum ID: klkl6523
\n\u6b61\u8fce\u63d0\u4ea4Bug\u54e6
\nCopyright (c) 2013-2015 huangyuhui.
\u514d\u8cac\u8072\u660e\uff1aMinecraft\u8edf\u4ef6\u7248\u6b0a\u6b78Mojang AB\u6240\u6709\uff0c\u904a\u6232\u7531\u65bc\u8aa4\u64cd\u4f5c\u672c\u555f\u52d5\u5668\u800c\u4e1f\u5931\u6578\u64da\u7684\u6982\u4e0d\u8ca0\u8cac\u3002
\u672c\u555f\u52d5\u5668\u5728GPLv2\u5354\u8b70\u4e0b\u958b\u6e90:http://github.com/huanghongxun/HMCL/ launcher.download_source=\u4e0b\u8f09\u6e90 launcher.background_location=\u80cc\u666f\u5730\u5740 launcher.exit_failed=\u5f37\u5236\u9000\u51fa\u5931\u6557\uff0c\u53ef\u80fd\u662fForge 1.7.10\u53ca\u66f4\u9ad8\u7248\u672c\u5c0e\u81f4\u7684\uff0c\u7121\u6cd5\u89e3\u6c7a\u3002 diff --git a/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_zh_CN.properties b/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_zh_CN.properties index efaa70568..199a50bf5 100644 --- a/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_zh_CN.properties +++ b/HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_zh_CN.properties @@ -1,17 +1,18 @@ -# Copyright 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 2 of the License, or -# (at your option) any later version. +# 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 +# (at your option) any later version. +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License -# along with this program. +# along with this program. If not, see {http://www.gnu.org/licenses/}. launch.failed=\u542f\u52a8\u5931\u8d25 launch.failed_creating_process=\u542f\u52a8\u5931\u8d25\uff0c\u5728\u521b\u5efa\u65b0\u8fdb\u7a0b\u65f6\u53d1\u751f\u9519\u8bef\uff0c\u53ef\u80fd\u662fJava\u8def\u5f84\u9519\u8bef\u3002 launch.failed_sh_permission=\u4e3a\u542f\u52a8\u6587\u4ef6\u6dfb\u52a0\u6743\u9650\u65f6\u53d1\u751f\u9519\u8bef @@ -236,7 +237,7 @@ mainwindow.enter_script_name=\u8f93\u5165\u8981\u751f\u6210\u811a\u672c\u7684\u6 mainwindow.make_launch_succeed=\u542f\u52a8\u811a\u672c\u5df2\u751f\u6210\u5b8c\u6bd5: mainwindow.no_version=\u672a\u627e\u5230\u4efb\u4f55\u7248\u672c\uff0c\u662f\u5426\u8fdb\u5165\u6e38\u620f\u4e0b\u8f7d\uff1f -launcher.about=\u9ed8\u8ba4\u80cc\u666f\u56fe\u6765\u81eaLiberty Dome\u670d\u52a1\u5668\u3002
\u5173\u4e8e\u4f5c\u8005\uff1a
\n\u767e\u5ea6ID\uff1ahuanghongxun20
\nmcbbs\uff1ahuanghongxun
\n\u90ae\u7bb1\uff1ahuanghongxun2008@126.com
\nMinecraft Forum ID: klkl6523
\n\u6b22\u8fce\u63d0\u4ea4Bug\u54e6
\nCopyright (c) 2013-2015 huangyuhui.
\u514d\u8d23\u58f0\u660e\uff1aMinecraft\u8f6f\u4ef6\u7248\u6743\u5f52Mojang AB\u6240\u6709\uff0c\u6e38\u620f\u7531\u4e8e\u8bef\u64cd\u4f5c\u672c\u542f\u52a8\u5668\u800c\u4e22\u5931\u6570\u636e\u7684\u6982\u4e0d\u8d1f\u8d23\u3002 +launcher.about=\u9ed8\u8ba4\u80cc\u666f\u56fe\u6765\u81eaLiberty Dome\u670d\u52a1\u5668\u3002
\u5173\u4e8e\u4f5c\u8005\uff1a
\n\u767e\u5ea6ID\uff1ahuanghongxun20
\nmcbbs\uff1ahuanghongxun
\n\u90ae\u7bb1\uff1ahuanghongxun2008@126.com
\nMinecraft Forum ID: klkl6523
\n\u6b22\u8fce\u63d0\u4ea4Bug\u54e6
\nCopyright (c) 2013-2015 huangyuhui.
\u514d\u8d23\u58f0\u660e\uff1aMinecraft\u8f6f\u4ef6\u7248\u6743\u5f52Mojang AB\u6240\u6709\uff0c\u6e38\u620f\u7531\u4e8e\u8bef\u64cd\u4f5c\u672c\u542f\u52a8\u5668\u800c\u4e22\u5931\u6570\u636e\u7684\u6982\u4e0d\u8d1f\u8d23\u3002
\u672c\u542f\u52a8\u5668\u5728GPLv2\u534f\u8bae\u4e0b\u5f00\u6e90:http://github.com/huanghongxun/HMCL/ launcher.download_source=\u4e0b\u8f7d\u6e90 launcher.background_location=\u80cc\u666f\u5730\u5740 launcher.exit_failed=\u5f3a\u5236\u9000\u51fa\u5931\u8d25\uff0c\u53ef\u80fd\u662fForge 1.7.10\u53ca\u66f4\u9ad8\u7248\u672c\u5bfc\u81f4\u7684\uff0c\u65e0\u6cd5\u89e3\u51b3\u3002 diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/Main.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/Main.java index cdfa98649..50ce86670 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/Main.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/Main.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr; @@ -30,7 +31,7 @@ import org.jackhuang.hellominecraft.utils.UpdateChecker; import org.jackhuang.hellominecraft.svrmgr.views.MainWindow; import org.jackhuang.hellominecraft.utils.VersionNumber; import org.jackhuang.hellominecraft.lookandfeel.HelloMinecraftLookAndFeel; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; /** * diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/BukkitPlugin.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/BukkitPlugin.java index a947d4b11..60544151d 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/BukkitPlugin.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/BukkitPlugin.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.cbplugins; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/Category.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/Category.java index 814c78967..c82628817 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/Category.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/Category.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.cbplugins; 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 ccd654753..582c5e1c6 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.cbplugins; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginInformation.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginInformation.java index 3dcd444c9..f2921eb17 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginInformation.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginInformation.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.cbplugins; 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 68e6477be..1bfcd5927 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.cbplugins; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginVersion.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginVersion.java index f95f556eb..ba1de49a3 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginVersion.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/cbplugins/PluginVersion.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.cbplugins; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/bukkit/BukkitFormatThread.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/bukkit/BukkitFormatThread.java index 8fb5ffbe4..63304fac0 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/bukkit/BukkitFormatThread.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/bukkit/BukkitFormatThread.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.installer.bukkit; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/bukkit/BukkitVersion.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/bukkit/BukkitVersion.java index 0c1ce5ca5..4a33a7100 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/bukkit/BukkitVersion.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/bukkit/BukkitVersion.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.installer.bukkit; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeFormatThread.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeFormatThread.java index 8bcbbfca3..6c6eb60c3 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeFormatThread.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeFormatThread.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron; 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 d4a37d65c..41a8958c0 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron; @@ -39,7 +40,7 @@ import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.code.DigestUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.tasks.TaskWindow; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeVersion.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeVersion.java index a089ddb6f..7516d0fdc 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeVersion.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/ForgeVersion.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/Install.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/Install.java index d832d7520..9277627a6 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/Install.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/Install.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/InstallProfile.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/InstallProfile.java index c0c546ca1..c3020867d 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/InstallProfile.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/InstallProfile.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/MinecraftLibrary.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/MinecraftLibrary.java index 04edb44c3..155e20ab8 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/MinecraftLibrary.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/installer/cauldron/MinecraftLibrary.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron; 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 cf1e6d51e..884d16fd0 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron; 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 ff7d25784..49b14e86a 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/Server.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/Server.java index 98dfb3ee8..5af51775c 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/Server.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/Server.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server; @@ -36,7 +37,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.system.IOUtils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.Pair; import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.svrmgr.settings.Schedule; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/ServerChecker.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/ServerChecker.java index d05dbb789..f8c79febc 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/ServerChecker.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/ServerChecker.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/backups/BackupManager.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/backups/BackupManager.java index 15938a6e7..a0ba1bde3 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/backups/BackupManager.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/backups/BackupManager.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server.backups; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/download/ServerDownloadPackage.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/download/ServerDownloadPackage.java index f20bafa13..9258c29e8 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/download/ServerDownloadPackage.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/download/ServerDownloadPackage.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server.download; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoBackupSchedule.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoBackupSchedule.java index 7bee06c16..4af03cab4 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoBackupSchedule.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoBackupSchedule.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server.schedules; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoBroadcastSchedule.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoBroadcastSchedule.java index d9bb539f8..da5be419c 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoBroadcastSchedule.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoBroadcastSchedule.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server.schedules; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoExecuteSchedule.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoExecuteSchedule.java index 71dea9ac8..75e6ae3d7 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoExecuteSchedule.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoExecuteSchedule.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server.schedules; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoRestartSchedule.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoRestartSchedule.java index f10061040..6e6afcf92 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoRestartSchedule.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoRestartSchedule.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server.schedules; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSaveSchedule.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSaveSchedule.java index e510929b5..a9b870abc 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSaveSchedule.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSaveSchedule.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server.schedules; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSchedule.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSchedule.java index 2e21cbf69..b2a8dca82 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSchedule.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSchedule.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server.schedules; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSendCommandSchedule.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSendCommandSchedule.java index 5b94aeb9c..c249d6dc6 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSendCommandSchedule.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/server/schedules/AutoSendCommandSchedule.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.server.schedules; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/BannedPlayers.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/BannedPlayers.java index 404bb3efa..ff0a698c7 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/BannedPlayers.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/BannedPlayers.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.settings; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Op.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Op.java index c6c0850a5..cea309a58 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Op.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/Op.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.settings; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/PlayerList.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/PlayerList.java index 6f4107693..122f32054 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/PlayerList.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/PlayerList.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.settings; 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 e4d30df70..9f48ed716 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.settings; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/ServerProperties.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/ServerProperties.java index 9b60a8f5b..18cde295b 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/ServerProperties.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/ServerProperties.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.settings; 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 7ced5a6f8..bca3a07cf 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.settings; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/SettingsManager.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/SettingsManager.java index 7f4363f26..c0b5b3bb9 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/SettingsManager.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/SettingsManager.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.settings; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/WhiteList.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/WhiteList.java index b8637aabf..d97ca347c 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/WhiteList.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/settings/WhiteList.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.settings; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/threads/MonitorThread.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/threads/MonitorThread.java index 4a0865293..67247ead6 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/threads/MonitorThread.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/threads/MonitorThread.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.threads; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/threads/WaitForThread.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/threads/WaitForThread.java index 19496aa73..70fda57b2 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/threads/WaitForThread.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/threads/WaitForThread.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.threads; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/FolderOpener.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/FolderOpener.java index 808eeef08..b0dcdc8dd 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/FolderOpener.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/FolderOpener.java @@ -1,23 +1,24 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.utils; import java.io.File; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; /** * diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/IMonitorService.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/IMonitorService.java index fa1ad7c28..fc5852452 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/IMonitorService.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/IMonitorService.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.utils; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/IPGet.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/IPGet.java index 7e7c0f6c2..260129f35 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/IPGet.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/IPGet.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.utils; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/ModType.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/ModType.java index 5570451ef..404cdd0bd 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/ModType.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/ModType.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.utils; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/MonitorInfoBean.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/MonitorInfoBean.java index 1ed3cf103..93dee9e4f 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/MonitorInfoBean.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/MonitorInfoBean.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.utils; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/MonitorServiceImpl.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/MonitorServiceImpl.java index baf1b85a4..27b642ef6 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/MonitorServiceImpl.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/MonitorServiceImpl.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.utils; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/Utilities.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/Utilities.java index 3780bf74a..e491ef900 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/Utilities.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/utils/Utilities.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.utils; diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/CommandsWindow.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/CommandsWindow.java index fa9fd71bf..1434b543c 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/CommandsWindow.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/CommandsWindow.java @@ -1,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.views; 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 41b8a7fe9..9c7abcee7 100644 --- 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,25 +1,25 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.views; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.GroupLayout; import javax.swing.JLabel; 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 6f2b48cac..ba7252550 100644 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/MainWindow.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/views/MainWindow.java @@ -54,7 +54,7 @@ import org.jackhuang.hellominecraft.tasks.download.HTTPGetTask; import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.svrmgr.utils.IMonitorService; import org.jackhuang.hellominecraft.utils.system.IOUtils; -import org.jackhuang.hellominecraft.utils.system.MessageBox; +import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.svrmgr.utils.ModType; import org.jackhuang.hellominecraft.svrmgr.utils.MonitorInfoBean; import org.jackhuang.hellominecraft.svrmgr.utils.MonitorServiceImpl; 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 633565ad5..893035421 100644 --- 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,18 +1,19 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ package org.jackhuang.hellominecraft.svrmgr.views; diff --git a/LICENSE b/LICENSE index dc5241db1..074b814ad 100644 --- a/LICENSE +++ b/LICENSE @@ -1,123 +1,674 @@ -The GNU General Public License (GPL-2.0) -Version 2, June 1991 -Copyright (C) 1989, 1991 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. + Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/} + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. -Preamble + Preamble -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + The GNU General Public License is a free, copyleft license for +software and other kinds of works. -When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. -To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. -For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. -We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. -Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. -Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. -The precise terms and conditions for copying, distribution and modification follow. + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. -0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + The precise terms and conditions for copying, distribution and +modification follow. -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + TERMS AND CONDITIONS -1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + 0. Definitions. -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + "This License" refers to version 3 of the GNU General Public License. -2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. -a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. -b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. -c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + A "covered work" means either the unmodified Program or a work based +on the Program. -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. -In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. -3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + 1. Source Code. -a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. -b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. -c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. -The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. -If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. -4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + The Corresponding Source for a work in source code form is that +same work. -5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + 2. Basic Permissions. -6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. -7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. -8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. -9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + 4. Conveying Verbatim Copies. -Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. -10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. -NO WARRANTY + 5. Conveying Modified Source Versions. -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. -END OF TERMS AND CONDITIONS + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". -How to Apply These Terms to Your New Programs + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. -If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. -To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. -One line to give the program's name and a brief idea of what it does. -Copyright (C) + 6. Conveying Non-Source Forms. -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 2 of the License, or (at your option) any later version. + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: -This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. -You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + Hello Minecraft! Launcher, a Minecraft Launcher which is easy to use. + Copyright (C) 2014 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see {http://www.gnu.org/licenses/}. Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: -Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + Hello Minecraft! Launcher Copyright (C) 2014 huangyuhui + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. -The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +{http://www.gnu.org/licenses/}. -Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. - -signature of Ty Coon, 1 April 1989 -Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. \ No newline at end of file + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +{http://www.gnu.org/philosophy/why-not-lgpl.html}. \ No newline at end of file diff --git a/license-header.txt b/license-header.txt index 866f225d9..15cd12760 100644 --- a/license-header.txt +++ b/license-header.txt @@ -1,16 +1,17 @@ /* - * Copyright 2013 huangyuhui + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. + * along with this program. If not, see {http://www.gnu.org/licenses/}. */ \ No newline at end of file