Debian Codegraph @

bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/MissingActionsException.java

raw
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 IBM Corporation and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.equinox.internal.p2.engine;
15
16 import org.eclipse.equinox.p2.core.ProvisionException;
17 import org.eclipse.osgi.util.NLS;
18
19 /**
20 * @since 2.0
21 */
22 public class MissingActionsException extends ProvisionException {
23
24 private static final long serialVersionUID = 8617693596359747490L;
25 private final MissingAction[] missingActions;
26
27 public MissingActionsException(MissingAction[] missingActions) {
28 super(getMissingActionsMessage(missingActions));
29 this.missingActions = missingActions;
30 }
31
32 private static String getMissingActionsMessage(MissingAction[] missingActions) {
33
34 if (missingActions.length == 0)
35 throw new IllegalArgumentException("Bad exception: No missing actions"); //$NON-NLS-1$
36
37 StringBuilder buffer = new StringBuilder();
38 for (int i = 0; i < missingActions.length; i++) {
39 MissingAction missingAction = missingActions[i];
40 buffer.append(missingAction.getActionId());
41 if (missingAction.getVersionRange() != null) {
42 buffer.append("/"); //$NON-NLS-1$
43 buffer.append(missingAction.getVersionRange().toString());
44 }
45 if (i + 1 != missingActions.length)
46 buffer.append(", "); //$NON-NLS-1$
47 }
48
49 return NLS.bind(Messages.actions_not_found, buffer.toString());
50 }
51
52 public MissingAction[] getMissingActions() {
53 return missingActions;
54 }
55 }