private void fixupOldStyleVersions(Attrs attrs) { if (attrs.containsKey(SPECIFICATION_VERSION) && attrs.getVersion() == null) { attrs.put("version", attrs.get(SPECIFICATION_VERSION)); attrs.remove(SPECIFICATION_VERSION); } }
public Attrs toAttrs() { Attrs attrs = new Attrs(); if (attributes != null) { for (Entry<String, Object> e : attributes.entrySet()) { Object value = e.getValue(); if (e.getKey() .equals("version") || value instanceof Version) value = toBndVersions(value); attrs.putTyped(e.getKey(), value); } } if (directives != null) for (Entry<String, String> e : directives.entrySet()) { attrs.put(e.getKey() + ":", e.getValue()); } return attrs; }
private void directivesAndVersion(Attrs attrs, String... directives) { for (String directive : directives) { String s = attrs.remove(directive); if (s != null) { attrs.put(directive + ":", s); } } String remove = attrs.remove(Constants.VERSION_ATTRIBUTE); if (remove != null) { attrs.putTyped("version", Version.parseVersion(remove)); } }
/** * Merge the attributes */ public void mergeWith(Attrs other, boolean override) { for (Map.Entry<String, String> e : other.entrySet()) { String key = e.getKey(); if (override || !containsKey(key)) { map.put(key, e.getValue()); Type t = other.getType(key); if (t != Type.STRING) { types.put(key, t); } else { types.remove(key); } } } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HeaderClause other = (HeaderClause) obj; if (attribs == null) { if (other.attribs != null) return false; } else if (!attribs.isEqual(other.attribs)) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return true; }
@Override public String toString() { StringBuilder sb = new StringBuilder(getName()); if (isProvided()) sb.append(";") .append("provided:=true"); if (getAttribs().containsKey("version")) sb.append(";version=") .append(getAttribs().get("version")); return sb.toString(); }
public String get(String key, String deflt) { String s = get(key); if (s == null) return deflt; return s; }
private Attrs getAttributes(Annotation a, String... ignores) { Attrs attrs = new Attrs(); outer: for (Entry<String, Object> entry : a.entrySet()) { String key = entry.getKey(); for (String ignore : ignores) { if (key.equals(ignore)) continue outer; } attrs.putTyped(key, entry.getValue()); } return attrs; }
private MetaAnnotationCollector(Clazz c, Annotation annotation, Set<String> processed, Attrs baseAttrs) { this.c = c; this.annotation = annotation; this.processed = processed; this.attributesAndDirectives = new Attrs(baseAttrs); }
private void handleAttributeOrDirective(Annotation a) { Object o = annotation.get(lastMethodSeen); if (o != null) { String attributeName = a.get("value"); if (attributeName == null) { attributeName = lastMethodSeen; } if (STD_DIRECTIVE.equals(a.getName() .getFQN())) { attributeName += ":"; } if (!attributesAndDirectives.containsKey(attributeName)) { attributesAndDirectives.putTyped(attributeName, o); } } }
public void append(StringBuilder sb) { String del = ""; for (Map.Entry<String,String> e : entrySet()) { sb.append(del); sb.append(e.getKey()); sb.append("="); sb.append(e.getValue()); del = ";"; } }
public void putAllTyped(Map<String, Object> attrs) { for (Map.Entry<String, Object> entry : attrs.entrySet()) { Object value = entry.getValue(); String key = entry.getKey(); putTyped(key, value); } }