• 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
    • Reference
    • Headers
    • Instruction Reference
    • Instruction Index
    • Macro Reference
    • Macro Index
    • Plugins
    • External Plugins
    • Settings
    • Errors
    • Warnings
    • Frequently Asked Questions
  • findname ';' PATH ( ';' FILTER )
    Project

    public String _findname(String args[]) {
    	return findPath("findname", args, false);
    }
    
    String findPath(String name, String[] args, boolean fullPathName) {
    	if (args.length > 3) {
    		warning("Invalid nr of arguments to " + name + " " + Arrays.asList(args) + ", syntax: ${" + name
    				+ " (; reg-expr (; replacement)? )? }");
    		return null;
    	}
    
    	String regexp = ".*";
    	String replace = null;
    
    	switch (args.length) {
    		case 3 :
    			replace = args[2];
    			//$FALL-THROUGH$
    		case 2 :
    			regexp = args[1];
    	}
    	StringBuilder sb = new StringBuilder();
    	String del = "";
    
    	Pattern expr = Pattern.compile(regexp);
    	for (Iterator<String> e = dot.getResources().keySet().iterator(); e.hasNext();) {
    		String path = e.next();
    		if (!fullPathName) {
    			int n = path.lastIndexOf('/');
    			if (n >= 0) {
    				path = path.substring(n + 1);
    			}
    		}
    
    		Matcher m = expr.matcher(path);
    		if (m.matches()) {
    			if (replace != null)
    				path = m.replaceAll(replace);
    
    			sb.append(del);
    			sb.append(path);
    			del = ", ";
    		}
    	}
    	return sb.toString();
    }
    
    • GitHub