aQute.bnd.build.model.conversions.HeaderClauseListConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of biz.aQute.bndlib Show documentation
Show all versions of biz.aQute.bndlib Show documentation
bndlib: A Swiss Army Knife for OSGi
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;
}
}