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

    /**
     * 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();
    }
    
    • GitHub