Search in sources :

Example 71 with CapReqBuilder

use of aQute.bnd.osgi.resource.CapReqBuilder in project bndtools by bndtools.

the class PackageSearchPanel method validate.

private void validate() {
    try {
        String filter = null;
        if (packageName == null || packageName.trim().isEmpty()) {
            setError(null);
            setRequirement(null);
            return;
        }
        VersionRange versionRange = null;
        if (versionRangeStr != null && versionRangeStr.trim().length() > 0) {
            try {
                versionRange = new VersionRange(versionRangeStr);
            } catch (Exception e) {
                throw new IllegalArgumentException("Invalid version range: " + e.getMessage());
            }
        }
        filter = formatPackageRequirement(packageName, versionRange);
        if (filter != null)
            setRequirement(new CapReqBuilder(PackageNamespace.PACKAGE_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter).buildSyntheticRequirement());
        setError(null);
    } catch (Exception e) {
        setError(e.getMessage());
        setRequirement(null);
    }
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) VersionRange(aQute.bnd.version.VersionRange)

Example 72 with CapReqBuilder

use of aQute.bnd.osgi.resource.CapReqBuilder in project bndtools by bndtools.

the class ServiceSearchPanel method validate.

public void validate() {
    if (serviceClass == null || serviceClass.trim().isEmpty()) {
        setError(null);
        setRequirement(null);
    } else {
        String filter = String.format("(%s=%s)", ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE, serviceClass);
        Requirement requirement = new CapReqBuilder(ServiceNamespace.SERVICE_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter).buildSyntheticRequirement();
        setError(null);
        setRequirement(requirement);
    }
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Requirement(org.osgi.resource.Requirement)

Aggregations

CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)72 Requirement (org.osgi.resource.Requirement)53 Capability (org.osgi.resource.Capability)35 BndEditModel (aQute.bnd.build.model.BndEditModel)32 MockRegistry (test.lib.MockRegistry)28 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)23 Resource (org.osgi.resource.Resource)18 ArrayList (java.util.ArrayList)11 Collection (java.util.Collection)10 HashMap (java.util.HashMap)9 Repository (org.osgi.service.repository.Repository)9 ResourceBuilder (aQute.bnd.osgi.resource.ResourceBuilder)8 AndFilter (aQute.libg.filters.AndFilter)7 SimpleFilter (aQute.libg.filters.SimpleFilter)7 File (java.io.File)7 List (java.util.List)7 Attrs (aQute.bnd.header.Attrs)6 Filter (aQute.libg.filters.Filter)6 LiteralFilter (aQute.libg.filters.LiteralFilter)6 Parameters (aQute.bnd.header.Parameters)5