• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • How to install bnd
      • Guided Tour
      • Guided Tour Workspace & Projects
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Introduction
      • Concepts
      • Best practices
    • Build and Development
      • Project Setup
      • Generating JARs
      • Versioning
      • Baselining
      • Service Components
      • Metatype
      • Contracts
      • Bundle Annotations
      • Accessor Properties
      • SPI Annotations
    • Dependency and Launching
      • Resolving Dependencies
      • Launching
      • Startlevels
    • Testing
      • Testing
      • Testing with Launchpad
    • Packaging and Distribution
      • Packaging Applications
      • JPMS Libraries
      • Wrapping Libraries to OSGi Bundles
    • Documentation and Tools
      • Generating Documentation
      • Commands
      • For Developers
      • Templates for Workspaces
      • Tips for Windows users
      • Tools bound to bnd
    • Reference Material
      • Reference
      • Headers
      • Instruction Reference
      • Instruction Index
      • Macro Reference
      • Macro Index
      • Plugins
      • External Plugins
    • Configuration and Troubleshooting
      • Settings
      • Errors
      • Warnings
  • frange ';' VERSION ( ';' BOOLEAN )?
    Analyzer

    a range expression for a filter from a version. By default this is based on consumer compatibility. You can specify a third argument (true) to get provider compatibility.

    /**
     * Return 
     * 
     * <pre>
     * ${frange;1.2.3}             -> (&(version>=1.2.3)(!(version>=1.3.0))
     * ${frange;1.2.3, true}       -> (&(version>=1.2.3)(!(version>=2.0.0))
     * </pre>
     */
    public String _frange(String[] args) {
    	if (args.length < 2 || args.length > 3) {
    		error("Invalid filter range, 2 or 3 args ${frange;<version>[;true|false]}");
    		return null;
    	}
    
    	String v = args[1];
    	if (!Verifier.isVersion(v)) {
    		error("Invalid version arg %s", v);
    		return null;
    	}
    
    	boolean isProvider = false;
    	if (args.length == 3)
    		isProvider = Processor.isTrue(args[2]);
    
    	Version low = new Version(v);
    	Version high;
    	if (isProvider)
    		high = new Version(low.getMajor(), low.getMinor() + 1, 0);
    	else
    		high = new Version(low.getMajor() + 1, 0, 0);
    
    	StringBuilder sb = new StringBuilder("(&(version>=").append(low.getWithoutQualifier()).append(")");
    	sb.append("(!(version>=").append(high.getWithoutQualifier()).append(")))");
    
    	return sb.toString();
    }
    
Search
    • Home