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

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

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

import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;

import aQute.bnd.build.model.clauses.HeaderClause;
import aQute.bnd.header.Attrs;
import aQute.bnd.header.Parameters;
import aQute.bnd.osgi.Processor;

public class HeaderClauseListConverter implements Converter,String> {

	private final Converter< ? extends R, ? super HeaderClause> itemConverter;

	public HeaderClauseListConverter(Converter< ? extends R, ? super HeaderClause> itemConverter) {
		this.itemConverter = itemConverter;
	}

	public List convert(String input) throws IllegalArgumentException {
		if (input == null)
			return null;

		List result = new ArrayList();

		Parameters header = new Parameters(input);
		for (Entry entry : header.entrySet()) {
			String key = Processor.removeDuplicateMarker(entry.getKey());
			HeaderClause clause = new HeaderClause(key, entry.getValue());
			result.add(itemConverter.convert(clause));
		}

		return result;
	}

	@Override
	public List error(String msg) {
		List l = new ArrayList();
		l.add(itemConverter.error(msg));
		return l;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy