• 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
  • toclassname ';' FILES
    Macro

    Translate a list of relative file paths to class names. The files can either end with .class or .java

    static String	_toclassnameHelp	= "${classname;<list of class names>}, convert class paths to FQN class names ";
    
    public String _toclassname(String args[]) {
    	verifyCommand(args, _toclassnameHelp, null, 2, 2);
    	Collection<String> paths = Processor.split(args[1]);
    
    	List<String> names = new ArrayList<String>(paths.size());
    	for (String path : paths) {
    		if (path.endsWith(".class")) {
    			String name = path.substring(0, path.length() - 6).replace('/', '.');
    			names.add(name);
    		} else if (path.endsWith(".java")) {
    			String name = path.substring(0, path.length() - 5).replace('/', '.');
    			names.add(name);
    		} else {
    			domain.warning("in toclassname, " + args[1] + " is not a class path because it does not end in .class");
    		}
    	}
    	return Processor.join(names, ",");
    }
    
Search
    • Home