public boolean isEqual(Parameters other) { if (this == other) return true; if (size() != other.size()) return false; if (isEmpty()) return true; SortedList<String> l = new SortedList<String>(keySet()); SortedList<String> lo = new SortedList<String>(other.keySet()); if (!l.isEqual(lo)) return false; for (String key : keySet()) { if (!get(key).isEqual(other.get(key))) return false; } return true; }
/** * Standard OSGi header parser. * * @param value */ static public Parameters parseHeader(String value, Processor logger) { return new Parameters(value, logger); }
/** * Merge all attributes of the given parameters with this */ public void mergeWith(Parameters other, boolean override) { for (Map.Entry<String, Attrs> e : other.entrySet()) { Attrs existing = get(e.getKey()); if (existing == null) { put(e.getKey(), new Attrs(e.getValue())); } else existing.mergeWith(e.getValue(), override); } }
public void add(String key, Attrs attrs) { while (containsKey(key)) key += "~"; put(key, attrs); }
private void addPaths(String p, List<URI> index, URI base) { Parameters content = new Parameters(p); for (String path : content.keySet()) { if ("!".equals(path)) { break; } URI sub = base.resolve(path); index.add(sub); } } }
/** * Check if we need to calculate any checksums. * * @param dot * @throws Exception */ private void doDigests(Jar dot) throws Exception { Parameters ps = OSGiHeader.parseHeader(getProperty(DIGESTS)); if (ps.isEmpty()) return; trace("digests %s", ps); String[] digests = ps.keySet().toArray(new String[ps.size()]); dot.setDigestAlgorithms(digests); }
private void addExtenderRequirement(Set<String> requires, Version version) { Version next = version.bumpMajor(); Parameters p = new Parameters(); Attrs a = new Attrs(); a.put(Constants.FILTER_DIRECTIVE, "\"(&(" + ExtenderNamespace.EXTENDER_NAMESPACE + "=" + ComponentConstants.COMPONENT_CAPABILITY_NAME + ")(" + ExtenderNamespace.CAPABILITY_VERSION_ATTRIBUTE + ">=" + version + ")(!(" + ExtenderNamespace.CAPABILITY_VERSION_ATTRIBUTE + ">=" + next + ")))\""); p.put(ExtenderNamespace.EXTENDER_NAMESPACE, a); String s = p.toString(); requires.add(s); }
public void verifyBundleClasspath() { Parameters bcp = main.getBundleClassPath(); if (bcp.isEmpty() || bcp.containsKey(".")) return; for (String path : bcp.keySet()) { if (path.endsWith("/")) error("A Bundle-ClassPath entry must not end with '/': %s", path); if (dot.getDirectories().containsKey(path)) // We assume that any classes are in a directory // and therefore do not care when the bundle is included return; } for (String path : dot.getResources().keySet()) { if (path.endsWith(".class")) { warning("The Bundle-Classpath does not contain the actual bundle JAR (as specified with '.' in the Bundle-Classpath) but the JAR does contain classes. Is this intentional?"); return; } } }
public List<R> convert(String input) throws IllegalArgumentException { List<R> result = new ArrayList<R>(); Parameters header = new Parameters(input); for (Entry<String,Attrs> entry : header.entrySet()) { String key = Processor.removeDuplicateMarker(entry.getKey()); Pair<String,Attrs> pair = Pair.newInstance(key, entry.getValue()); result.add(itemConverter.convert(pair)); } return result; }
public List<String> keyList() { return keySet().stream() .map(Parameters::removeDuplicateMarker) .collect(toList()); }
public boolean verifyActivationPolicy(String policy) { Parameters map = parseHeader(policy); if (map.size() == 0) warning(Constants.BUNDLE_ACTIVATIONPOLICY + " is set but has no argument %s", policy); else if (map.size() > 1) warning(Constants.BUNDLE_ACTIVATIONPOLICY + " has too many arguments %s", policy); else { Map<String, String> s = map.get("lazy"); if (s == null) warning(Constants.BUNDLE_ACTIVATIONPOLICY + " set but is not set to lazy: %s", policy); else return true; } return false; }
private void constructBlacklist(Processor augments) throws Exception { Parameters blacklist = new Parameters(augments.mergeProperties(Constants.RUNBLACKLIST), project); blacklist.putAll(new Parameters(properties.mergeProperties(Constants.RUNBLACKLIST), project)); if (blacklist != null && !blacklist.isEmpty()) { List<Requirement> reject = CapReqBuilder.getRequirementsFrom(blacklist); setBlackList(reject); } }
public static List<Capability> getCapabilitiesFrom(Parameters rr) throws Exception { List<Capability> capabilities = new ArrayList<>(); for (Entry<String, Attrs> e : rr.entrySet()) { capabilities.add(getCapabilityFrom(Processor.removeDuplicateMarker(e.getKey()), e.getValue())); } return capabilities; }
Resource constructInputRequirements() throws Exception { ResourceBuilder resBuilder = new ResourceBuilder(); CapReqBuilder identity = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE) .addAttribute(IdentityNamespace.IDENTITY_NAMESPACE, IDENTITY_INITIAL_RESOURCE); resBuilder.addCapability(identity); Parameters inputRequirements = new Parameters(properties.mergeProperties(Constants.RUNREQUIRES), project); if (inputRequirements != null && !inputRequirements.isEmpty()) { List<Requirement> requires = CapReqBuilder.getRequirementsFrom(inputRequirements); resBuilder.addRequirements(requires); } return resBuilder.build(); }
/** * Add a gestalt to all workspaces. The gestalt is a set of parts describing * the environment. Each part has a name and optionally attributes. This * method adds a gestalt to the VM. Per workspace it is possible to augment * this. */ public static void addGestalt(String part, Attrs attrs) { Attrs already = overallGestalt.get(part); if (attrs == null) attrs = new Attrs(); if (already != null) { already.putAll(attrs); } else already = attrs; overallGestalt.put(part, already); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); append(sb); return sb.toString(); }
/** * Get the attrs for a gestalt part */ public Attrs getGestalt(String part) { return getGestalt().get(part); }
public Map<String, ? extends Map<String, String>> getSystemPackages() { return runsystempackages.asMapMap(); }
private void verifySymbolicName() { Parameters bsn = parseHeader(main.get(Analyzer.BUNDLE_SYMBOLICNAME)); if (!bsn.isEmpty()) { if (bsn.size() > 1) error("More than one BSN specified " + bsn); String name = bsn.keySet().iterator().next(); if (!isBsn(name)) { error("Symbolic Name has invalid format: " + name); } } }