public CapReqBuilder addDirectives(Attrs directives) { for (Entry<String, String> e : directives.entrySet()) { String key = Attrs.toDirective(e.getKey()); if (key != null) addDirective(key, e.getValue()); } return this; }
public CapReqBuilder(String ns, Attrs attrs) throws Exception { this.namespace = ns; for (Entry<String, String> entry : attrs.entrySet()) { String key = entry.getKey(); if (key.endsWith(":")) addDirective(key.substring(0, key.length() - 1), entry.getValue()); else addAttribute(key, entry.getValue()); } }
public static CapReqBuilder createCapReqBuilder(String namespace, Attrs attrs) throws Exception { CapReqBuilder builder = new CapReqBuilder(namespace); for (Entry<String, String> entry : attrs.entrySet()) { String key = entry.getKey(); if (key.endsWith(":")) { key = key.substring(0, key.length() - 1); builder.addDirective(key, entry.getValue()); } else { builder.addAttribute(key, entry.getValue()); } } return builder; }
/** * In bnd, we only use one map for both directives & attributes. This method will properly * dispatch them AND take care of typing * * @param attrs * @throws Exception */ public void addAttributesOrDirectives(Attrs attrs) throws Exception { for (Entry<String, String> e : attrs.entrySet()) { String directive = Attrs.toDirective(e.getKey()); if (directive != null) { addDirective(directive, e.getValue()); } else { Object typed = attrs.getTyped(e.getKey()); if (typed instanceof aQute.bnd.version.Version) { typed = new Version(typed.toString()); } addAttribute(e.getKey(), typed); } } }