Package org.apache.felix.utils.resource
Class RequirementImpl
java.lang.Object
org.apache.felix.utils.resource.AbstractCapabilityRequirement
org.apache.felix.utils.resource.RequirementImpl
- All Implemented Interfaces:
org.osgi.resource.Requirement
public class RequirementImpl
extends AbstractCapabilityRequirement
implements org.osgi.resource.Requirement
Implementation of the OSGi Requirement interface.
-
Field Summary
FieldsFields inherited from class org.apache.felix.utils.resource.AbstractCapabilityRequirement
attributes, directives, namespace, resource
-
Constructor Summary
ConstructorsConstructorDescriptionRequirementImpl
(org.osgi.resource.Resource res, String ns, String filter) Create a requirement with a namespace and a filter.RequirementImpl
(org.osgi.resource.Resource res, String ns, Map<String, String> dirs, Map<String, Object> attrs) Create a requirement.RequirementImpl
(org.osgi.resource.Resource resource, String path, Map<String, String> dirs, Map<String, Object> attrs, SimpleFilter sf) RequirementImpl
(org.osgi.resource.Resource resource, org.osgi.resource.Requirement requirement) Create a requirement based on an existing requirement, providing the resource. -
Method Summary
Modifier and TypeMethodDescriptionprivate static SimpleFilter
static SimpleFilter
getFilter
(org.osgi.resource.Requirement requirement) Utility method to obtain a SimpleFilter from a given requirement.boolean
static boolean
isOptional
(org.osgi.resource.Requirement requirement) Utility method to check whether a requirement is optional.boolean
matches
(org.osgi.resource.Capability cap) Methods inherited from class org.apache.felix.utils.resource.AbstractCapabilityRequirement
getAttributes, getDirectives, getNamespace, getResource, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.osgi.resource.Requirement
equals, getAttributes, getDirectives, getNamespace, getResource, hashCode
-
Field Details
-
filter
-
optional
private final boolean optional
-
-
Constructor Details
-
RequirementImpl
public RequirementImpl(org.osgi.resource.Resource res, String ns, Map<String, String> dirs, Map<String, Object> attrs) Create a requirement.- Parameters:
res
- The resource associated with the requirement.ns
- The namespace of the requirement.dirs
- The directives of the requirement.attrs
- The attributes of the requirement.
-
RequirementImpl
Create a requirement with a namespace and a filter. This is a convenience method that creates a requirement with an empty attributes map and a single 'filter' directive.- Parameters:
res
- The resource associated with the requirement.ns
- The namespace for the requirement.filter
- The filter.
-
RequirementImpl
public RequirementImpl(org.osgi.resource.Resource resource, org.osgi.resource.Requirement requirement) Create a requirement based on an existing requirement, providing the resource. The namespace, attributes and directives are copied from the provided requirement.- Parameters:
resource
- The resource to be associated with the requirementrequirement
- The requirement to base the new requirement on.
-
RequirementImpl
-
-
Method Details
-
matches
public boolean matches(org.osgi.resource.Capability cap) -
isOptional
public boolean isOptional() -
getFilter
-
isOptional
public static boolean isOptional(org.osgi.resource.Requirement requirement) Utility method to check whether a requirement is optional. This method works with any object implementing the requirement interface.- Parameters:
requirement
- A requirement- Returns:
true
if the requirement it optional,false
otherwise.
-
getFilter
Utility method to obtain a SimpleFilter from a given requirement. If the requirement contains aConstants.FILTER_DIRECTIVE
directive, it will be used, else, the filter will be derived from the attributes.- Parameters:
requirement
- A requirement- Returns:
- a valid filter, never
null
.
-
getFilter
-