Class XmlRepoDiffer

java.lang.Object
aQute.bnd.differ.XmlRepoDiffer

public final class XmlRepoDiffer extends Object
  • Field Details

  • Constructor Details

    • XmlRepoDiffer

      private XmlRepoDiffer()
  • Method Details

    • resource

      public static Element resource(File file) throws Exception
      Returns the differ Element for comparison

      Note that, the filter directives will not be expanded

      Parameters:
      file - the XML resource repository
      Returns:
      the differ Element
      Throws:
      Exception - for any discrepancy
      See Also:
    • resource

      public static Element resource(File file, boolean expandFilter) throws Exception
      Returns the differ Element for comparison

      Note that, the filter directives will be expanded if expandFilter is set to true

      Parameters:
      file - the XML resource repository
      expandFilter - the flag to expand filter directives
      Returns:
      the differ Element
      Throws:
      Exception - for any discrepancy
      See Also:
    • formatComparatorKey

      private static String formatComparatorKey(Map<String,Object> attributes, String namespace)
      Returns the formatted comparator key for the specified attributes associating the specified namespace
      Parameters:
      attributes - the attributes
      namespace - 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 resource

      Note 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 requirement
      resource - 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 resource

      For example, the osgi.wiring.package namespace must include the following attributes which are, according to specification, mandatory but XMLResourceGenerator does not add these attributes.

      • bundle-symbolic-name
      • bundle-version
      Parameters:
      capability - the capability
      resource - 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 single Element comprising the specified attributes and directives which are associated with the specified namespace and differ type
      Parameters:
      attributes - the attributes
      directives - the directives
      namespace - the namespace to associate
      type - the differ type for comparison
      expandFilter - the flag to expand filter directives
      Returns:
      the Element
    • mapToElements

      public static List<Element> mapToElements(Map<String,? extends Object> entries, Type type, boolean expandFilter)
      Creates list of Elements associating the specified entries
      Parameters:
      entries - the entries to associate
      type - the type to use for comparison
      expandFilter - the flag to expand filter directives
      Returns:
      the list of Elements
    • validate

      private static Map<String,? extends Object> validate(Map<String,? extends Object> entries)
      Iterates over a map of entries and if any of entry has a value which is of type List, new entries get created for every element containing in the value. This is required for attributes and directive of type List
      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 removed
      namespace - the namespace to check for the key attribute name
      Returns:
      the final map of attributes without the key attribute
    • createFilterElement

      private static List<Element> createFilterElement(String filter)
      Creates list of Elements for the associated filter
      Parameters:
      filter - the filter
      Returns:
      the list of Element