Package aQute.bnd.differ
Class XmlRepoDiffer
java.lang.Object
aQute.bnd.differ.XmlRepoDiffer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classUsed to find the comparator key attribute in thefilterdirectiveprivate static classUsed to prepare a map containing relevant informations from afilterdirective -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.osgi.resource.CapabilityaddMissingAttributes(org.osgi.resource.Capability capability, org.osgi.resource.Resource resource) Adds the missing attributes to the specified capability of the specified resourceprivate static org.osgi.resource.RequirementaddPlaceholderAttributes(org.osgi.resource.Requirement requirement, org.osgi.resource.Resource resource) Adds specific attributes to the specified requirement of the specified resourcecreateFilterElement(String filter) Creates list ofElements for the associated filterprivate static ElementextractElement(Map<String, Object> attributes, Map<String, ? extends Object> directives, String namespace, Type type, boolean expandFilter) Creates a singleElementcomprising the specified attributes and directives which are associated with the specified namespace and differ typeprivate static StringformatComparatorKey(Map<String, Object> attributes, String namespace) Returns the formatted comparator key for the specified attributes associating the specified namespacemapToElements(Map<String, ? extends Object> entries, Type type, boolean expandFilter) Creates list ofElements associating the specified entriesremoveKeyAttribute(Map<String, ? extends Object> attributes, String namespace) Removes the attribute from the attributes list which has been used as comparator key for comparison.static ElementReturns the differElementfor comparisonstatic ElementReturns the differElementfor comparisonIterates over a map of entries and if any of entry has a value which is of typeList, new entries get created for every element containing in the value.
-
Field Details
-
KEY_DELIMITER
- See Also:
-
ATTRIBUTE_DIRECTIVE_DELIMITER
- See Also:
-
COMPARATOR_ATTRIBUTES
-
-
Constructor Details
-
XmlRepoDiffer
private XmlRepoDiffer()
-
-
Method Details
-
resource
Returns the differElementfor comparisonNote that, the
filterdirectives will not be expanded -
resource
Returns the differElementfor comparisonNote that, the
filterdirectives will be expanded ifexpandFilteris set totrue -
formatComparatorKey
Returns the formatted comparator key for the specified attributes associating the specified namespace- Parameters:
attributes- the attributesnamespace- the namespace- Returns:
- the formatted comparator key
-
addPlaceholderAttributes
private static org.osgi.resource.Requirement addPlaceholderAttributes(org.osgi.resource.Requirement requirement, org.osgi.resource.Resource resource) Adds specific attributes to the specified requirement of the specified resourceNote that, the attributes are added to ease the comparison between same resources in two XML resource repositories
Also note that, the
COMPARATOR_ATTRIBUTEScomprises the map of namespaces and attributes denoting which attribute of the namespace will be added as placeholders- Parameters:
requirement- the requirementresource- the resource- Returns:
- the updated requirement comprising the attributes as specified in
COMPARATOR_ATTRIBUTES
-
addMissingAttributes
private static org.osgi.resource.Capability addMissingAttributes(org.osgi.resource.Capability capability, org.osgi.resource.Resource resource) Adds the missing attributes to the specified capability of the specified resourceFor example, the
osgi.wiring.packagenamespace must include the following attributes which are, according to specification, mandatory butXMLResourceGeneratordoes not add these attributes.- bundle-symbolic-name
- bundle-version
- Parameters:
capability- the capabilityresource- the resource- Returns:
- the updated capability comprising the missing attributes
-
extractElement
private static Element extractElement(Map<String, Object> attributes, Map<String, ? extends Object> directives, String namespace, Type type, boolean expandFilter) Creates a singleElementcomprising the specified attributes and directives which are associated with the specified namespace and differ type- Parameters:
attributes- the attributesdirectives- the directivesnamespace- the namespace to associatetype- the differ type for comparisonexpandFilter- the flag to expandfilterdirectives- Returns:
- the
Element
-
mapToElements
public static List<Element> mapToElements(Map<String, ? extends Object> entries, Type type, boolean expandFilter) Creates list ofElements associating the specified entries- Parameters:
entries- the entries to associatetype- the type to use for comparisonexpandFilter- the flag to expandfilterdirectives- Returns:
- the list of
Elements
-
validate
Iterates over a map of entries and if any of entry has a value which is of typeList, new entries get created for every element containing in the value. This is required for attributes and directive of typeList- Parameters:
entries- the map of entries (attributes or directives)- Returns:
- the new map of entries
-
removeKeyAttribute
private static Map<String,? extends Object> removeKeyAttribute(Map<String, ? extends Object> attributes, String namespace) Removes the attribute from the attributes list which has been used as comparator key for comparison.- Parameters:
attributes- the attributes from which the key attribute is removednamespace- the namespace to check for the key attribute name- Returns:
- the final map of attributes without the key attribute
-
createFilterElement
Creates list ofElements for the associated filter- Parameters:
filter- the filter- Returns:
- the list of
Element
-