Search in sources :

Example 1 with SimpleFilter

use of aQute.libg.filters.SimpleFilter in project bnd by bndtools.

the class AbstractResolveContext method createIdentityRequirement.

public static Requirement createIdentityRequirement(String identity, String versionRange) {
    // Construct a filter & requirement to find matches
    Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, identity);
    if (versionRange != null)
        filter = new AndFilter().addChild(filter).addChild(new LiteralFilter(Filters.fromVersionRange(versionRange)));
    Requirement frameworkReq = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
    return frameworkReq;
}
Also used : LiteralFilter(aQute.libg.filters.LiteralFilter) CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) AndFilter(aQute.libg.filters.AndFilter) Requirement(org.osgi.resource.Requirement) SimpleFilter(aQute.libg.filters.SimpleFilter) AndFilter(aQute.libg.filters.AndFilter) Filter(aQute.libg.filters.Filter) LiteralFilter(aQute.libg.filters.LiteralFilter) SimpleFilter(aQute.libg.filters.SimpleFilter)

Example 2 with SimpleFilter

use of aQute.libg.filters.SimpleFilter in project bnd by bndtools.

the class CapReqBuilder method createPackageRequirement.

public static final CapReqBuilder createPackageRequirement(String pkgName, String range) {
    Filter filter;
    SimpleFilter pkgNameFilter = new SimpleFilter(PackageNamespace.PACKAGE_NAMESPACE, pkgName);
    if (range != null)
        filter = new AndFilter().addChild(pkgNameFilter).addChild(new LiteralFilter(Filters.fromVersionRange(range)));
    else
        filter = pkgNameFilter;
    return new CapReqBuilder(PackageNamespace.PACKAGE_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString());
}
Also used : LiteralFilter(aQute.libg.filters.LiteralFilter) AndFilter(aQute.libg.filters.AndFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) AndFilter(aQute.libg.filters.AndFilter) Filter(aQute.libg.filters.Filter) LiteralFilter(aQute.libg.filters.LiteralFilter) SimpleFilter(aQute.libg.filters.SimpleFilter)

Example 3 with SimpleFilter

use of aQute.libg.filters.SimpleFilter in project bnd by bndtools.

the class CapReqBuilder method createBundleRequirement.

public static CapReqBuilder createBundleRequirement(String bsn, String range) {
    Filter filter;
    SimpleFilter bsnFilter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bsn);
    if (range != null)
        filter = new AndFilter().addChild(bsnFilter).addChild(new LiteralFilter(Filters.fromVersionRange(range)));
    else
        filter = bsnFilter;
    return new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString());
}
Also used : LiteralFilter(aQute.libg.filters.LiteralFilter) AndFilter(aQute.libg.filters.AndFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) AndFilter(aQute.libg.filters.AndFilter) Filter(aQute.libg.filters.Filter) LiteralFilter(aQute.libg.filters.LiteralFilter) SimpleFilter(aQute.libg.filters.SimpleFilter)

Example 4 with SimpleFilter

use of aQute.libg.filters.SimpleFilter in project bndtools by bndtools.

the class RunBlacklistPart method createRequirement.

private static Requirement createRequirement(Object elem) {
    String bsn = null;
    Version version = null;
    if (elem instanceof RepositoryBundle) {
        bsn = ((RepositoryBundle) elem).getBsn();
    } else if (elem instanceof RepositoryBundleVersion) {
        RepositoryBundleVersion rbv = (RepositoryBundleVersion) elem;
        bsn = rbv.getBsn();
        version = rbv.getVersion();
    } else if (elem instanceof ProjectBundle) {
        bsn = ((ProjectBundle) elem).getBsn();
    }
    if (bsn != null) {
        Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bsn);
        if (version != null) {
            filter = new AndFilter().addChild(filter).addChild(new SimpleFilter("version", Operator.GreaterThanOrEqual, version.toString()));
        }
        Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
        return req;
    }
    return null;
}
Also used : RepositoryBundle(bndtools.model.repo.RepositoryBundle) ProjectBundle(bndtools.model.repo.ProjectBundle) CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) AndFilter(aQute.libg.filters.AndFilter) Requirement(org.osgi.resource.Requirement) RepositoryBundleVersion(bndtools.model.repo.RepositoryBundleVersion) Version(aQute.bnd.version.Version) RepositoryBundleVersion(bndtools.model.repo.RepositoryBundleVersion) SimpleFilter(aQute.libg.filters.SimpleFilter) AndFilter(aQute.libg.filters.AndFilter) Filter(aQute.libg.filters.Filter) LiteralFilter(aQute.libg.filters.LiteralFilter) SimpleFilter(aQute.libg.filters.SimpleFilter)

Example 5 with SimpleFilter

use of aQute.libg.filters.SimpleFilter in project bndtools by bndtools.

the class BndBuilderCapReqLoader method createVersionFilter.

private static final String createVersionFilter(String ns, String value, String rangeStr, String versionAttr) {
    SimpleFilter pkgNameFilter = new SimpleFilter(ns, value);
    Filter filter = pkgNameFilter;
    if (rangeStr != null) {
        VersionRange range = new VersionRange(rangeStr);
        Filter left;
        if (range.includeLow())
            left = new SimpleFilter(versionAttr, Operator.GreaterThanOrEqual, range.getLow().toString());
        else
            left = new NotFilter(new SimpleFilter(versionAttr, Operator.LessThanOrEqual, range.getLow().toString()));
        Filter right;
        if (!range.isRange())
            right = null;
        else if (range.includeHigh())
            right = new SimpleFilter(versionAttr, Operator.LessThanOrEqual, range.getHigh().toString());
        else
            right = new NotFilter(new SimpleFilter(versionAttr, Operator.GreaterThanOrEqual, range.getHigh().toString()));
        AndFilter combined = new AndFilter().addChild(pkgNameFilter).addChild(left);
        if (right != null)
            combined.addChild(right);
        filter = combined;
    }
    return filter.toString();
}
Also used : AndFilter(aQute.libg.filters.AndFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) NotFilter(aQute.libg.filters.NotFilter) AndFilter(aQute.libg.filters.AndFilter) Filter(aQute.libg.filters.Filter) SimpleFilter(aQute.libg.filters.SimpleFilter) NotFilter(aQute.libg.filters.NotFilter) VersionRange(aQute.bnd.version.VersionRange)

Aggregations

AndFilter (aQute.libg.filters.AndFilter)12 SimpleFilter (aQute.libg.filters.SimpleFilter)12 Filter (aQute.libg.filters.Filter)11 LiteralFilter (aQute.libg.filters.LiteralFilter)9 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)7 Requirement (org.osgi.resource.Requirement)6 VersionedClause (aQute.bnd.build.model.clauses.VersionedClause)3 ProjectBundle (bndtools.model.repo.ProjectBundle)3 RepositoryBundle (bndtools.model.repo.RepositoryBundle)3 RepositoryBundleVersion (bndtools.model.repo.RepositoryBundleVersion)3 Version (aQute.bnd.version.Version)2 VersionRange (aQute.bnd.version.VersionRange)2 NotFilter (aQute.libg.filters.NotFilter)2 RepoBundleSelectionWizard (bndtools.wizards.repo.RepoBundleSelectionWizard)2 LinkedHashSet (java.util.LinkedHashSet)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 Version (org.osgi.framework.Version)1 Capability (org.osgi.resource.Capability)1