Package aQute.bnd.differ
Class XmlRepoDiffer
java.lang.Object
aQute.bnd.differ.XmlRepoDiffer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Used to find the comparator key attribute in thefilter
directiveprivate static class
Used to prepare a map containing relevant informations from afilter
directive -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate 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 resourceprivate 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 resourcecreateFilterElement
(String filter) Creates list ofElement
s for the associated filterprivate static Element
extractElement
(Map<String, Object> attributes, Map<String, ? extends Object> directives, String namespace, Type type, boolean expandFilter) Creates a singleElement
comprising the specified attributes and directives which are associated with the specified namespace and differ typeprivate static String
formatComparatorKey
(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 ofElement
s 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 Element
Returns the differElement
for comparisonstatic Element
Returns the differElement
for 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 differElement
for comparisonNote that, the
filter
directives will not be expanded -
resource
Returns the differElement
for comparisonNote that, the
filter
directives will be expanded ifexpandFilter
is 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_ATTRIBUTES
comprises 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.package
namespace must include the following attributes which are, according to specification, mandatory butXMLResourceGenerator
does 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 singleElement
comprising 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 expandfilter
directives- Returns:
- the
Element
-
mapToElements
public static List<Element> mapToElements(Map<String, ? extends Object> entries, Type type, boolean expandFilter) Creates list ofElement
s associating the specified entries- Parameters:
entries
- the entries to associatetype
- the type to use for comparisonexpandFilter
- the flag to expandfilter
directives- Returns:
- the list of
Element
s
-
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 ofElement
s for the associated filter- Parameters:
filter
- the filter- Returns:
- the list of
Element
-