All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aQute.bnd.build.model.conversions.PropertiesEntryFormatter Maven / Gradle / Ivy

There is a newer version: 7.0.0
Show newest version
package aQute.bnd.build.model.conversions;

import java.util.Map.Entry;

public class PropertiesEntryFormatter implements Converter> {
	public String convert(Entry entry) {
		StringBuilder buffer = new StringBuilder();

		String name = entry.getKey();
		buffer.append(name).append('=');

		String value = entry.getValue();
		if (value != null && value.length() > 0) {
			int quotableIndex = value.indexOf(',');
			if (quotableIndex == -1)
				quotableIndex = value.indexOf('=');

			if (quotableIndex >= 0) {
				buffer.append('\'').append(value).append('\'');
			} else {
				buffer.append(value);
			}
		}
		return buffer.toString();
	}

	@Override
	public String error(String msg) {
		return msg;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy