Search in sources :

Example 6 with Expression

use of aQute.bnd.osgi.resource.FilterParser.Expression in project bnd by bndtools.

the class FilterParserTest method testVoidRange.

public void testVoidRange() throws IOException {
    Expression exp = fp.parse("(&(osgi.wiring.package=package)(version>=0.0.0))");
    System.out.println(exp);
}
Also used : Expression(aQute.bnd.osgi.resource.FilterParser.Expression) WithRangeExpression(aQute.bnd.osgi.resource.FilterParser.WithRangeExpression)

Example 7 with Expression

use of aQute.bnd.osgi.resource.FilterParser.Expression in project bnd by bndtools.

the class FilterParserTest method testPackageRange.

public void testPackageRange() throws Exception {
    Expression expression = fp.parse("(&(osgi.wiring.package=A)(version>=1.0.0)(!(version>=2.0.0)))");
    assertTrue(expression instanceof WithRangeExpression);
    assertEquals("[1.0.0,2.0.0)", ((WithRangeExpression) expression).getRangeExpression().getRangeString());
}
Also used : Expression(aQute.bnd.osgi.resource.FilterParser.Expression) WithRangeExpression(aQute.bnd.osgi.resource.FilterParser.WithRangeExpression) WithRangeExpression(aQute.bnd.osgi.resource.FilterParser.WithRangeExpression)

Example 8 with Expression

use of aQute.bnd.osgi.resource.FilterParser.Expression in project bnd by bndtools.

the class FilterParserTest method testCache.

/**
	 * Since the filters are cached we need to get similar filters to check if
	 * this works.
	 * 
	 * @throws IOException
	 */
public void testCache() throws IOException {
    Expression exp = fp.parse("(&(osgi.wiring.package=a)(version>=1)(!(version>=2.0.0)))");
    Expression exp2 = fp.parse("(&(osgi.wiring.package=b)(version>=1.1)(!(version>=2.0.0)))");
    assertNotNull(exp2);
    assertNotNull(exp);
}
Also used : Expression(aQute.bnd.osgi.resource.FilterParser.Expression) WithRangeExpression(aQute.bnd.osgi.resource.FilterParser.WithRangeExpression)

Example 9 with Expression

use of aQute.bnd.osgi.resource.FilterParser.Expression in project bnd by bndtools.

the class FilterParserTest method testIdentity.

public void testIdentity() throws IOException {
    Expression exp = fp.parse("(&(osgi.identity=identity)(version>=0.0.0))");
    System.out.println(exp);
    exp = fp.parse("(&(osgi.identity=identity)(!(version>=2.0.0))(version>=1.0.0))");
    System.out.println(exp);
}
Also used : Expression(aQute.bnd.osgi.resource.FilterParser.Expression) WithRangeExpression(aQute.bnd.osgi.resource.FilterParser.WithRangeExpression)

Example 10 with Expression

use of aQute.bnd.osgi.resource.FilterParser.Expression in project bnd by bndtools.

the class NativeCodeHeaderTest method testNative.

public void testNative() throws Exception {
    ResourceBuilder rb = new ResourceBuilder();
    Requirement nativeCode = //
    rb.getNativeCode(//
    "f1;" + //
    "  osname=Windows95;" + //
    "  processor=x86;" + //
    "  selection-filter='(com.acme.windowing=win32)';" + //
    "  language=en;" + //
    "  osname=Windows98;" + //
    "  language=se, " + //
    "lib/solaris/libhttp.so;" + //
    "  osname=Solaris;" + //
    "  osname = SunOS ;" + //
    "  processor = sparc, " + //
    "lib/linux/libhttp.so ; " + //
    "  osname = Linux ; " + //
    "  processor = mips; " + //
    "  selection-filter = '(com.acme.windowing=gtk)'," + "*").synthetic();
    assertEquals(NativeNamespace.NATIVE_NAMESPACE, nativeCode.getNamespace());
    assertEquals("optional", nativeCode.getDirectives().get("resolution"));
    String filter = nativeCode.getDirectives().get("filter");
    assertEquals(null, Verifier.validateFilter(filter));
    FilterParser p = new FilterParser();
    Expression parse = p.parse(filter);
    assertEquals("(|(&(|(osgi.native.osname=Windows95)(osgi.native.osname=Windows98))(osgi.native.processor=x86)(|(osgi.native.language=en)(osgi.native.language=se))(com.acme.windowing=win32))(&(|(osgi.native.osname=Solaris)(osgi.native.osname=SunOS))(osgi.native.processor=sparc))(&(osgi.native.osname=Linux)(osgi.native.processor=mips)(com.acme.windowing=gtk)))", filter);
    System.out.println(nativeCode);
}
Also used : Requirement(org.osgi.resource.Requirement) ResourceBuilder(aQute.bnd.osgi.resource.ResourceBuilder) Expression(aQute.bnd.osgi.resource.FilterParser.Expression) FilterParser(aQute.bnd.osgi.resource.FilterParser)

Aggregations

Expression (aQute.bnd.osgi.resource.FilterParser.Expression)12 WithRangeExpression (aQute.bnd.osgi.resource.FilterParser.WithRangeExpression)7 FilterParser (aQute.bnd.osgi.resource.FilterParser)5 SimpleExpression (aQute.bnd.osgi.resource.FilterParser.SimpleExpression)2 Matcher (java.util.regex.Matcher)2 StyledString (org.eclipse.jface.viewers.StyledString)2 Requirement (org.osgi.resource.Requirement)2 Attrs (aQute.bnd.header.Attrs)1 PatternExpression (aQute.bnd.osgi.resource.FilterParser.PatternExpression)1 RangeExpression (aQute.bnd.osgi.resource.FilterParser.RangeExpression)1 ResourceBuilder (aQute.bnd.osgi.resource.ResourceBuilder)1 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)1 ProjectResolver (biz.aQute.resolve.ProjectResolver)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 Pattern (java.util.regex.Pattern)1 Capability (org.osgi.resource.Capability)1 Resource (org.osgi.resource.Resource)1