static SortedMap<String, String> getAttributesSortedByName(Attributes attributes) { Set<Map.Entry<Object, Object>> attributesEntries = attributes.entrySet(); SortedMap<String, String> namedAttributes = new TreeMap<String, String>(); for (Map.Entry<Object, Object> attribute : attributesEntries) { String attrName = attribute.getKey().toString(); String attrValue = attribute.getValue().toString(); namedAttributes.put(attrName, attrValue); } return namedAttributes; }
public Map<String, String> getManifest(final InputStream input) { final Map<String, String> retMap = new HashMap<String, String>(); try { Manifest manifest = new Manifest(); manifest.read(input); final Attributes attributes = manifest.getMainAttributes(); for (final Map.Entry attribute : attributes.entrySet()) { retMap.put(attribute.getKey().toString(), attribute.getValue().toString()); } } catch (final Exception ex) { logger.error( "Failed to load manifest ", ex); } return retMap; }
public Map<String, String> getManifest(final InputStream input) { final Map<String, String> retMap = new HashMap<String, String>(); try { Manifest manifest = new Manifest(); manifest.read(input); final Attributes attributes = manifest.getMainAttributes(); for (final Map.Entry attribute : attributes.entrySet()) { retMap.put(attribute.getKey().toString(), attribute.getValue().toString()); } } catch (final Exception ex) { logger.error("Failed to load manifest ", ex); } return retMap; } }
/** * Gets all signed files from the manifest. * <p> * It scans all manifest entries and their attributes. If there is an attribute * name which ends with "-DIGEST" we are assuming that manifest entry name is a * signed file name. * * @param manifest JAR file manifest. * @return Either empty set if none found or set of signed file names. */ private static Set<String> getSignedFiles(Manifest manifest) { Set<String> fileNames = new HashSet<>(); Map<String, Attributes> entries = manifest.getEntries(); if (entries != null && entries.size() > 0) { for (Map.Entry<String, Attributes> entry : entries.entrySet()) { Attributes attrs = entry.getValue(); for (Map.Entry<Object, Object> attrEntry : attrs.entrySet()) { if (attrEntry.getKey().toString().toUpperCase().endsWith("-DIGEST")) { fileNames.add(entry.getKey()); break; } } } } return fileNames; }
LOGGER.log(Level.FINE, "No includes: including all"); final Iterator<java.util.Map.Entry<Object, Object>> it = at.entrySet().iterator(); while (it.hasNext()) { java.util.Map.Entry<Object, Object> entry = it.next(); at.entrySet().iterator(); while (it.hasNext()) { java.util.Map.Entry<Object, Object> entry = it.next();
print.write(entry.getKey().getBytes(StandardCharsets.UTF_8)); print.write(EOL); for (Map.Entry<Object, Object> att : entry.getValue().entrySet()) { print.write(att.getKey().toString().getBytes(StandardCharsets.UTF_8)); print.write(COL);
boolean hasImplementationVersion = false; Attributes atts = manifest.getMainAttributes(); for (Entry<Object, Object> entry : atts.entrySet()) { String key = entry.getKey().toString(); String value = atts.getValue(key); source = "manifest: " + name; atts = item.getValue(); for (Entry<Object, Object> entry : atts.entrySet()) { final String key = entry.getKey().toString(); final String value = atts.getValue(key);
/** * Adds the source attributes to the destination map. */ private void addAll(final Attributes src, final Map<String, Object> dest) { for (final Entry<Object, Object> entry : src.entrySet()) { // final String name = entry.getKey().toString().toLowerCase(); final String name = entry.getKey().toString(); dest.put(name, entry.getValue()); } }
/** * Create a dictionary from manifest attributes. */ public HeaderDictionary(Attributes in) { headers = new Hashtable<Attributes.Name, String>(); for (final Entry<Object, Object> e : in.entrySet()) { headers.put((Attributes.Name)e.getKey(), (String)e.getValue()); } }
private static Map<String, String> getAttributes(final Manifest manifest) { Map<String, String> rv = new HashMap<String, String>(); for (Map.Entry<Object, Object> entry : manifest.getMainAttributes().entrySet()) { rv.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); } return Collections.unmodifiableMap(rv); }
private static Map<String, String> manifestToMap(Manifest manifest) { Attributes attributes = manifest.getMainAttributes(); Map<String, String> headers = new HashMap<String, String>(); for (Map.Entry<Object, Object> entry : attributes.entrySet()) { String key = entry.getKey().toString(); String value = entry.getValue().toString(); headers.put(key, value); } return headers; }
private static Map<String, String> getAttributes(Manifest manifest) { HashMap<String, String> rv = new HashMap<String, String>(); for (Map.Entry<Object, Object> entry : manifest.getMainAttributes().entrySet()) { rv.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); } return Collections.unmodifiableMap(rv); }
private static Optional<BrooklynFeature> newFeature(Attributes attrs) { // unfortunately Attributes is a Map<Object,Object> Dictionary<String,String> headers = new Hashtable<>(); for (Map.Entry<Object, Object> entry : attrs.entrySet()) { headers.put(entry.getKey().toString(), entry.getValue().toString()); } return newFeature(headers); }
/** * Read the manifest and complete the metadata. * @param manifest the given manifest to analyze */ protected void readManifest(final Manifest manifest) { // Now manifest is here, analyze it and populate metadata Attributes attributes = manifest.getMainAttributes(); Set<Map.Entry<Object, Object>> entries = attributes.entrySet(); for (Map.Entry<Object, Object> entry : entries) { archiveMetadata.put(entry.getKey().toString(), entry.getValue().toString()); } }
static ManifestDetails getDetails(Manifest manifest) { final Iterable<ManifestAttribute> manifestAttributeIterable = Iterables.transform(manifest.getMainAttributes().entrySet(), new Function<Map.Entry<Object, Object>, ManifestAttribute>() { public ManifestAttribute apply(@Nullable Map.Entry<Object, Object> mainAttributeEntry) { return ManifestAttribute.getAttribute((Attributes.Name) mainAttributeEntry.getKey(), (String) mainAttributeEntry.getValue()); } }); return new ManifestDetails(manifestAttributeIterable); } }
protected static Map<String, Map<String, String>> extractEntries(Manifest mf) { Map<String, Map<String, String>> mapMap = new HashMap<>(); Map<String, Attributes> entries = mf.getEntries(); for (Map.Entry<String, Attributes> entrySection : entries.entrySet()) { Map<String, String> map = new HashMap<>(); for (Map.Entry<Object, Object> entry : entrySection.getValue().entrySet()) { map.put(entry.getKey().toString(), entry.getValue().toString()); } mapMap.put(entrySection.getKey(), map); } return mapMap; }
private static StringBuilder appendAttributes(StringBuilder manifestEntry, Attributes attributes) { StringBuilder line = new StringBuilder(); if (attributes != null) { for (Map.Entry attr : attributes.entrySet()) { line.append(attr.getKey().toString()).append(": ").append((String) attr.getValue()); appendLine(manifestEntry, line); line.setLength(0); } } return manifestEntry.append("\r\n"); }
private void readSection(Attributes attributes, ManifestSectionDescriptor sectionDescriptor, Store store) { for (Map.Entry<Object, Object> entry : attributes.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); ManifestEntryDescriptor entryDescriptor = store.create(ManifestEntryDescriptor.class); entryDescriptor.setName(key != null ? key.toString() : null); entryDescriptor.setValue(value != null ? value.toString() : null); sectionDescriptor.getManifestEntries().add(entryDescriptor); } }
@Test public void testIterator() { ManifestIterator manifests = (ManifestIterator) appContext.getBean("manifestIterator"); for (Manifest manifest : manifests) { Attributes attributes = manifest.getMainAttributes(); for (Entry<?, ?> entry : attributes.entrySet()) { Name name = (Name) entry.getKey(); log.info(name + ": " + entry.getValue().toString()); } } }
@Test public void testIterator() { ManifestIterator manifests = (ManifestIterator) appContext.getBean("manifestIterator"); for (Manifest manifest : manifests) { Attributes attributes = manifest.getMainAttributes(); for (Entry<?, ?> entry : attributes.entrySet()) { Name name = (Name) entry.getKey(); log.info(name + ": " + entry.getValue().toString()); } } }