Refine search
private int compareVersions(Capability cap1, Capability cap2, String attribute) { Version v1 = (!cap1.getAttributes().containsKey(attribute)) ? Version.emptyVersion : (Version) cap1.getAttributes().get(attribute); Version v2 = (!cap2.getAttributes().containsKey(attribute)) ? Version.emptyVersion : (Version) cap2.getAttributes().get(attribute); // Compare these in reverse order, since we want // highest version to have priority. return v2.compareTo(v1); }
@Override public String toString() { for (Capability cap : caps) { if (IdentityNamespace.IDENTITY_NAMESPACE.equals(cap.getNamespace())) { return cap.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE) + "/" + cap.getAttributes().get(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE); } } return "Unidentified resource"; }
/** * Create a capability based on an existing capability, providing the resource. * The namespace, attributes and directives are copied from the provided capability. * @param capability The capability to base the new requirement on. * @param resource The resource to be associated with the capability */ public CapabilityImpl(Resource resource, Capability capability) { this(resource, capability.getNamespace(), capability.getDirectives(), capability.getAttributes()); }
@Override public String toString() { for (Capability cap : caps) { if (IdentityNamespace.IDENTITY_NAMESPACE.equals(cap.getNamespace())) { return cap.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE) + "/" + cap.getAttributes().get(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE); } } return "Unidentified resource"; }
public static String getIdentity(Capability identityCapability) throws IllegalArgumentException { String id = (String) identityCapability.getAttributes() .get(IdentityNamespace.IDENTITY_NAMESPACE); if (id == null) throw new IllegalArgumentException("Resource identity capability has missing identity attribute"); return id; }
/** * Create a capability based on an existing capability, providing the resource. * The namespace, attributes and directives are copied from the provided capability. * @param capability The capability to base the new requirement on. * @param resource The resource to be associated with the capability */ public CapabilityImpl(Resource resource, Capability capability) { this(resource, capability.getNamespace(), capability.getDirectives(), capability.getAttributes()); }
public static String getType(Resource resource) { List<Capability> caps = resource.getCapabilities(null); for (Capability cap : caps) { if (cap.getNamespace().equals(IDENTITY_NAMESPACE)) { return cap.getAttributes().get(CAPABILITY_TYPE_ATTRIBUTE).toString(); } } return null; }
public static String getIdentity(Capability identityCapability) throws IllegalArgumentException { String id = (String) identityCapability.getAttributes() .get(IdentityNamespace.IDENTITY_NAMESPACE); if (id == null) throw new IllegalArgumentException("Resource identity capability has missing identity attribute"); return id; }
private boolean equalsCap(Capability other) { if (!Objects.equals(namespace, other.getNamespace())) return false; if (!Objects.equals(attributes, other.getAttributes())) return false; if (!Objects.equals(directives, other.getDirectives())) return false; return Objects.equals(resource, other.getResource()); }
public static String getUri(Resource resource) { List<Capability> caps = resource.getCapabilities(null); for (Capability cap : caps) { if (cap.getNamespace().equals(CONTENT_NAMESPACE)) { return cap.getAttributes().get(CAPABILITY_URL_ATTRIBUTE).toString(); } } return null; }
@Override public String toString() { return m_cap.getResource() + "." + m_cap.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE) + (((m_reqs == null) || m_reqs.isEmpty()) ? " NO BLAME" : " BLAMED ON " + m_reqs); }
private boolean equalsCap(Capability other) { if (!Objects.equals(namespace, other.getNamespace())) return false; if (!Objects.equals(attributes, other.getAttributes())) return false; if (!Objects.equals(directives, other.getDirectives())) return false; return Objects.equals(resource, other.getResource()); }
private static boolean isFragment(Resource resource) { for (Capability cap : resource.getCapabilities(null)) { if (IdentityNamespace.IDENTITY_NAMESPACE.equals(cap.getNamespace())) { return IdentityNamespace.TYPE_FRAGMENT .equals(cap.getAttributes().get(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE)); } } return false; }
@Override public String toString() { return m_cap.getResource() + "." + m_cap.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE) + (((m_reqs == null) || m_reqs.isEmpty()) ? " NO BLAME" : " BLAMED ON " + m_reqs); }
private static String createOSGiCapability(Capability cap) { Map<String, Object> attributes = new HashMap<String, Object>(cap.getAttributes()); Map<String, String> directives = cap.getDirectives(); String name = (String) attributes.remove(cap.getNamespace()); return name + ModuleRevision.toString(attributes, false, true) + ModuleRevision.toString(directives, true, true); }
public static String getSymbolicName(Resource resource) { List<Capability> caps = resource.getCapabilities(null); for (Capability cap : caps) { if (cap.getNamespace().equals(IdentityNamespace.IDENTITY_NAMESPACE)) { return cap.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE).toString(); } } return null; }
@Override public String toString() { return m_cap.getResource() + "." + m_cap.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE) + (((m_reqs == null) || m_reqs.isEmpty()) ? " NO BLAME" : " BLAMED ON " + m_reqs); }
private static String createOSGiCapability(Capability cap) { Map<String, Object> attributes = new HashMap<>(cap.getAttributes()); Map<String, String> directives = cap.getDirectives(); String name = (String) attributes.remove(cap.getNamespace()); return name + ModuleRevision.toString(attributes, false, true) + ModuleRevision.toString(directives, true, true); }
public static String getSymbolicName(Resource resource) { List<Capability> caps = resource.getCapabilities(null); for (Capability cap : caps) { if (cap.getNamespace().equals(IdentityNamespace.IDENTITY_NAMESPACE)) { return cap.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE).toString(); } } return null; }
protected static Capability findFrameworkContractCapability(Resource resource) { List<Capability> contractCaps = resource.getCapabilities(CONTRACT_NAMESPACE); if (contractCaps != null) for (Capability cap : contractCaps) { if (CONTRACT_OSGI_FRAMEWORK.equals(cap.getAttributes() .get(CONTRACT_NAMESPACE))) return cap; } return null; }