• 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
  • foreach ';' MACRO (';' LIST)*
    Macro

    Iterator over a list, calling a macro with the value and index

    /**
     * Map a value from a list to a new value, providing the value and the index
     */
    
    static String	_foreach	= "${foreach;<macro>[;<list>...]}";
    public String _foreach(String args[]) throws Exception {
    	verifyCommand(args, _foreach, null, 2, Integer.MAX_VALUE);
    	String macro = args[1];
    	List<String> list = toList(args,2, args.length);
    	List<String> result = new ArrayList<String>();
    	
    	int n = 0;
    	for ( String s : list) {
    		String invoc = process("${" + macro +";" + s +";" + n++ +"}");
    		result.add(invoc);
    	}
    
    	return Processor.join(result);
    }
    
Search
    • Home