| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2009, 2015 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 |
* Cloudsmith Inc. - converted into expression based query |
| 14 |
*******************************************************************************/ |
| 15 |
package org.eclipse.equinox.p2.engine.query; |
| 16 |
|
| 17 |
import org.eclipse.equinox.p2.engine.IProfile; |
| 18 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
| 19 |
|
| 20 |
/** |
| 21 |
* A query matching all the {@link IInstallableUnit}s that are marked visible to the user. |
| 22 |
* @since 2.0 |
| 23 |
*/ |
| 24 |
public class UserVisibleRootQuery extends IUProfilePropertyQuery { |
| 25 |
|
| 26 |
/** |
| 27 |
* Creates a new query that will match all installable units marked visible to the user. |
| 28 |
*/ |
| 29 |
public UserVisibleRootQuery() { |
| 30 |
super(IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString()); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Test if the {@link IInstallableUnit}, in the context of a {@link IProfile} is visible to the user |
| 35 |
* @param iu the element being tested. |
| 36 |
* @param profile the context in which the iu is tested |
| 37 |
* @return <code>true</code> if the element is visible to the user. |
| 38 |
*/ |
| 39 |
public static boolean isUserVisible(IInstallableUnit iu, IProfile profile) { |
| 40 |
String value = profile.getInstallableUnitProperty(iu, IProfile.PROP_PROFILE_ROOT_IU); |
| 41 |
return Boolean.parseBoolean(value); |
| 42 |
} |
| 43 |
} |