1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package javax
.microedition
.swm
;
12 import cc
.squirreljme
.runtime
.cldc
.annotation
.Api
;
13 import cc
.squirreljme
.runtime
.cldc
.debug
.Debugging
;
14 import cc
.squirreljme
.runtime
.swm
.JarStreamSupplier
;
16 import net
.multiphasicapps
.collections
.IdentityLinkedHashSet
;
19 * This class is created when a suite is to be installed.
24 public final class SuiteInstaller
26 /** The supplier for the JAR data. */
27 final JarStreamSupplier _supplier
;
29 /** Listeners for suites. */
30 final Set
<SuiteInstallListener
> _listeners
=
31 new IdentityLinkedHashSet
<>();
36 * @param __sup The supplier for JAR files.
37 * @throws NullPointerException On null arguments.
40 SuiteInstaller(JarStreamSupplier __sup
)
41 throws NullPointerException
44 throw new NullPointerException("NARG");
46 this._supplier
= __sup
;
50 * Adds a suite installation listener which can be given status updates
51 * when a suite's installation status has changed.
53 * @param __sl The listener to add.
57 public final void addInstallationListener(SuiteInstallListener __sl
)
63 this._listeners
.add(__sl
);
67 * Cancels the current installation.
72 public final void cancel()
74 throw Debugging
.todo();
78 * Removes the given installation listener so that it no longer is notified
79 * of installation updates.
81 * @param __sl The listener to remove.
85 public final void removeInstallationListener(SuiteInstallListener __sl
)
91 this._listeners
.remove(__sl
);
95 * Starts installation of the given suite.
97 * If this is called twice then the next installation attempt is
98 * enqueued regardless if the previous installation has succeeded or
101 * If there is not enough permission to install the given suite then
102 * {@link InstallErrorCodes#UNAUTHORIZED_INSTALL} is set.
104 * @return The tracker for the given suite.
108 public final SuiteManagementTracker
start()
110 return new __SuiteTracker__(this);