• 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
  • findname ';' PATH ( ';' FILTER )
    Project

    A list of filtered by name resource paths with optional replacement

    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();
    }
    
Search
    • Home