Package aQute.bnd.osgi.resource
Class ResourceUtils
java.lang.Object
aQute.bnd.osgi.resource.ResourceUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Collection<org.osgi.resource.Requirement>
private static final Pattern
private static final Converter
static final org.osgi.resource.Resource
static final Comparator<? super org.osgi.resource.Resource>
A comparator that compares the identity versionsprivate static final Comparator<Comparable>
static final Comparator<org.osgi.resource.Requirement>
private static final Comparator<? super org.osgi.resource.Resource>
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends org.osgi.resource.Capability>
Tstatic <T extends org.osgi.resource.Requirement>
Tstatic <CAPABILITY extends org.osgi.resource.Capability,
COLLECTION extends Collection<CAPABILITY>>
voidcapabilitiesAccumulator
(COLLECTION collection, CAPABILITY capability) static <CAPABILITY extends org.osgi.resource.Capability,
COLLECTION extends Collection<CAPABILITY>>
COLLECTIONcapabilitiesCombiner
(COLLECTION leftCollection, COLLECTION rightCollection) static Stream<org.osgi.resource.Capability>
capabilityStream
(org.osgi.resource.Resource resource, String namespace) static <T extends org.osgi.resource.Capability>
Stream<T>capabilityStream
(org.osgi.resource.Resource resource, String namespace, Class<T> type) static int
compareTo
(org.osgi.resource.Resource a, org.osgi.resource.Resource b) Compare two resources.static org.osgi.resource.Requirement
static Map<org.osgi.resource.Requirement,
Collection<org.osgi.resource.Capability>> emptyProviders
(Collection<? extends org.osgi.resource.Requirement> requirements) static Predicate<org.osgi.resource.Capability>
filterMatcher
(org.osgi.resource.Requirement requirement) static Predicate<org.osgi.resource.Capability>
filterMatcher
(org.osgi.resource.Requirement requirement, Function<String, Predicate<Map<String, Object>>> filter) filterPredicate
(String filterString) static <CAPABILITY extends org.osgi.resource.Capability,
COLLECTION extends Collection<CAPABILITY>>
Map<org.osgi.resource.Requirement,Collection<org.osgi.resource.Capability>> findProviders
(Collection<? extends org.osgi.resource.Requirement> requirements, Function<? super org.osgi.resource.Requirement, COLLECTION> provider) static List<org.osgi.resource.Capability>
findProviders
(org.osgi.resource.Requirement requirement, Collection<? extends org.osgi.resource.Capability> capabilities) private static Object
static Set<org.osgi.resource.Resource>
getAllResources
(org.osgi.service.repository.Repository repository) Return all resources from a repository as returned by the wildcard requirement, seecreateWildcardRequirement()
static ResourceUtils.BundleCap
getBundleCapability
(org.osgi.resource.Resource resource) static BundleId
getBundleId
(org.osgi.resource.Resource resource) static List<ResourceUtils.ContentCapability>
getContentCapabilities
(org.osgi.resource.Resource resource) getContentCapability
(org.osgi.resource.Resource resource) static String
getEffective
(Map<String, String> directives) static String
getIdentity
(org.osgi.resource.Capability identityCapability) static String
getIdentity
(org.osgi.resource.Resource resource) getIdentityCapability
(org.osgi.resource.Resource resource) static String
getIdentityVersion
(org.osgi.resource.Resource resource) getIndexedByResource
(Collection<? extends org.osgi.resource.Capability> providers) getLocations
(org.osgi.resource.Resource resource) static ResolutionDirective
getResolution
(org.osgi.resource.Requirement requirement) static Set<org.osgi.resource.Resource>
getResources
(Collection<? extends org.osgi.resource.Capability> providers) private static Set<org.osgi.resource.Resource>
getResources
(Stream<? extends org.osgi.resource.Capability> providers) static URI
getURI
(org.osgi.resource.Capability contentCapability) getURI
(org.osgi.resource.Resource resource) private static Object
static Version
getVersion
(org.osgi.resource.Capability cap) static Version
getVersion
(org.osgi.resource.Resource resource) static String
getVersionAttributeForNamespace
(String namespace) static boolean
isEffective
(org.osgi.resource.Requirement r, org.osgi.resource.Capability c) static boolean
isFragment
(org.osgi.resource.Resource resource) static boolean
isInitialRequirement
(org.osgi.resource.Resource resource) static Predicate<org.osgi.resource.Capability>
matcher
(org.osgi.resource.Requirement requirement) static Predicate<org.osgi.resource.Capability>
matcher
(org.osgi.resource.Requirement requirement, Function<String, Predicate<Map<String, Object>>> filter) static boolean
matches
(org.osgi.resource.Requirement requirement, org.osgi.resource.Capability capability) static boolean
matches
(org.osgi.resource.Requirement requirement, org.osgi.resource.Resource resource) static List<org.osgi.resource.Resource>
sort
(Collection<org.osgi.resource.Resource> resources) static List<org.osgi.resource.Resource>
sortByNameVersion
(Collection<org.osgi.resource.Resource> resources) Sort the resources by symbolic name and versionstatic String
stripDirective
(String name) static <CAPABILITY extends org.osgi.resource.Capability>
Collector<CAPABILITY,List<CAPABILITY>, List<CAPABILITY>> static String
toProvideCapability
(org.osgi.resource.Capability capability) static String
toRequireCapability
(org.osgi.resource.Requirement requirement) static Version
static VersionedClause
toVersionClause
(org.osgi.resource.Resource resource) Create a VersionedClause by applying a version range mask to the resource! Masks are defined byMacro._range(String[])
.static VersionedClause
toVersionClause
(org.osgi.resource.Resource resource, String mask) static List<VersionedClause>
toVersionedClauses
(Collection<org.osgi.resource.Resource> resources)
-
Field Details
-
REQUIREMENT_COMPARATOR
-
IDENTITY_VERSION_COMPARATOR
A comparator that compares the identity versions -
RESOURCE_COMPARATOR
-
DUMMY_RESOURCE
public static final org.osgi.resource.Resource DUMMY_RESOURCE -
WORKSPACE_NAMESPACE
- See Also:
-
cnv
-
ATTR_NAME
-
all
-
nullsFirst
-
-
Constructor Details
-
ResourceUtils
public ResourceUtils()
-
-
Method Details
-
capabilityStream
-
capabilityStream
-
getContentCapability
public static ResourceUtils.ContentCapability getContentCapability(org.osgi.resource.Resource resource) -
getURI
-
getContentCapabilities
public static List<ResourceUtils.ContentCapability> getContentCapabilities(org.osgi.resource.Resource resource) -
getIdentityCapability
public static ResourceUtils.IdentityCapability getIdentityCapability(org.osgi.resource.Resource resource) -
getBundleId
-
getIdentityVersion
-
getBundleCapability
-
toVersion
-
getVersion
-
getURI
-
getVersionAttributeForNamespace
-
as
public static <T extends org.osgi.resource.Capability> T as(org.osgi.resource.Capability cap, Class<T> type) -
as
public static <T extends org.osgi.resource.Requirement> T as(org.osgi.resource.Requirement req, Class<T> type) -
get
private static Object get(Method method, Map<String, Object> attrs, Map<String, throws ExceptionString> directives, Object[] args) - Throws:
Exception
-
getValue
-
getResources
public static Set<org.osgi.resource.Resource> getResources(Collection<? extends org.osgi.resource.Capability> providers) -
getIndexedByResource
public static Map<org.osgi.resource.Resource,List<org.osgi.resource.Capability>> getIndexedByResource(Collection<? extends org.osgi.resource.Capability> providers) -
getResources
-
createWildcardRequirement
public static org.osgi.resource.Requirement createWildcardRequirement() -
isEffective
public static boolean isEffective(org.osgi.resource.Requirement r, org.osgi.resource.Capability c) -
filterPredicate
-
matches
public static boolean matches(org.osgi.resource.Requirement requirement, org.osgi.resource.Resource resource) -
matches
public static boolean matches(org.osgi.resource.Requirement requirement, org.osgi.resource.Capability capability) -
matcher
public static Predicate<org.osgi.resource.Capability> matcher(org.osgi.resource.Requirement requirement) -
matcher
-
filterMatcher
public static Predicate<org.osgi.resource.Capability> filterMatcher(org.osgi.resource.Requirement requirement) -
filterMatcher
-
getEffective
-
getResolution
-
toRequireCapability
public static String toRequireCapability(org.osgi.resource.Requirement requirement) throws Exception - Throws:
Exception
-
toProvideCapability
- Throws:
Exception
-
getLocations
-
findProviders
public static List<org.osgi.resource.Capability> findProviders(org.osgi.resource.Requirement requirement, Collection<? extends org.osgi.resource.Capability> capabilities) -
isFragment
public static boolean isFragment(org.osgi.resource.Resource resource) -
stripDirective
-
getIdentity
public static String getIdentity(org.osgi.resource.Capability identityCapability) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
getIdentity
public static String getIdentity(org.osgi.resource.Resource resource) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
getVersion
public static Version getVersion(org.osgi.resource.Resource resource) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
toVersionClause
Create a VersionedClause by applying a version range mask to the resource! Masks are defined byMacro._range(String[])
. If the resource should represent a project in the bnd workspace, then instead the VersionClause will refer to it as a snapshot version: e.g.;version=snapshot -
toVersionClause
-
toVersionedClauses
public static List<VersionedClause> toVersionedClauses(Collection<org.osgi.resource.Resource> resources) -
getAllResources
public static Set<org.osgi.resource.Resource> getAllResources(org.osgi.service.repository.Repository repository) Return all resources from a repository as returned by the wildcard requirement, seecreateWildcardRequirement()
- Parameters:
repository
- the repository to use- Returns:
- a set of resources from the repository.
-
compareTo
public static int compareTo(org.osgi.resource.Resource a, org.osgi.resource.Resource b) Compare two resources. This can be used to act as a comparator. The comparison is first done on name and then version.- Parameters:
a
- the left resourceb
- the right resource- Returns:
- 0 if equal bame and version, 1 if left has a higher name or same name and higher version, -1 otherwise
-
sort
public static List<org.osgi.resource.Resource> sort(Collection<org.osgi.resource.Resource> resources) -
sortByNameVersion
public static List<org.osgi.resource.Resource> sortByNameVersion(Collection<org.osgi.resource.Resource> resources) Sort the resources by symbolic name and version- Parameters:
resources
- the set of resources to sort- Returns:
- a sorted set of resources
-
isInitialRequirement
public static boolean isInitialRequirement(org.osgi.resource.Resource resource) -
toCapabilities
-
capabilitiesAccumulator
public static <CAPABILITY extends org.osgi.resource.Capability,COLLECTION extends Collection<CAPABILITY>> void capabilitiesAccumulator(COLLECTION collection, CAPABILITY capability) -
capabilitiesCombiner
public static <CAPABILITY extends org.osgi.resource.Capability,COLLECTION extends Collection<CAPABILITY>> COLLECTION capabilitiesCombiner(COLLECTION leftCollection, COLLECTION rightCollection) -
findProviders
public static <CAPABILITY extends org.osgi.resource.Capability,COLLECTION extends Collection<CAPABILITY>> Map<org.osgi.resource.Requirement,Collection<org.osgi.resource.Capability>> findProviders(Collection<? extends org.osgi.resource.Requirement> requirements, Function<? super org.osgi.resource.Requirement, COLLECTION> provider) -
emptyProviders
public static Map<org.osgi.resource.Requirement,Collection<org.osgi.resource.Capability>> emptyProviders(Collection<? extends org.osgi.resource.Requirement> requirements)
-