java.util.jar.Manifest.getEntries()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(194)

本文整理了Java中java.util.jar.Manifest.getEntries()方法的一些代码示例,展示了Manifest.getEntries()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Manifest.getEntries()方法的具体详情如下:
包路径:java.util.jar.Manifest
类名称:Manifest
方法名:getEntries

Manifest.getEntries介绍

[英]Returns a map containing the Attributes for each entry in the Manifest.
[中]返回包含清单中每个项的属性的映射。

代码示例

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns the {@code Attributes} associated with the parameter entry
  3. * {@code name}.
  4. *
  5. * @param name
  6. * the name of the entry to obtain {@code Attributes} from.
  7. * @return the Attributes for the entry or {@code null} if the entry does
  8. * not exist.
  9. */
  10. public Attributes getAttributes(String name) {
  11. return getEntries().get(name);
  12. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns the hash code for this instance.
  3. *
  4. * @return this {@code Manifest}'s hashCode.
  5. */
  6. @Override
  7. public int hashCode() {
  8. return mainAttributes.hashCode() ^ getEntries().hashCode();
  9. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Creates a new {@code Manifest} instance. The new instance will have the
  3. * same attributes as those found in the parameter {@code Manifest}.
  4. *
  5. * @param man
  6. * {@code Manifest} instance to obtain attributes from.
  7. */
  8. @SuppressWarnings("unchecked")
  9. public Manifest(Manifest man) {
  10. mainAttributes = (Attributes) man.mainAttributes.clone();
  11. entries = (HashMap<String, Attributes>) ((HashMap<String, Attributes>) man
  12. .getEntries()).clone();
  13. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Determines if the receiver is equal to the parameter object. Two {@code
  3. * Manifest}s are equal if they have identical main attributes as well as
  4. * identical entry attributes.
  5. *
  6. * @param o
  7. * the object to compare against.
  8. * @return {@code true} if the manifests are equal, {@code false} otherwise
  9. */
  10. @Override
  11. public boolean equals(Object o) {
  12. if (o == null) {
  13. return false;
  14. }
  15. if (o.getClass() != this.getClass()) {
  16. return false;
  17. }
  18. if (!mainAttributes.equals(((Manifest) o).mainAttributes)) {
  19. return false;
  20. }
  21. return getEntries().equals(((Manifest) o).getEntries());
  22. }

代码示例来源:origin: org.apache.ant/ant

  1. /**
  2. * Return an array of <code>Extension</code> objects representing optional
  3. * packages that are available in the JAR file associated with the
  4. * specified <code>Manifest</code>. If there are no such optional
  5. * packages, a zero-length array is returned.
  6. *
  7. * @param manifest Manifest to be parsed
  8. * @return the "available" extensions in specified manifest
  9. */
  10. public static Extension[] getAvailable(final Manifest manifest) {
  11. if (null == manifest) {
  12. return new Extension[0];
  13. }
  14. return Stream
  15. .concat(Optional.ofNullable(manifest.getMainAttributes())
  16. .map(Stream::of).orElse(Stream.empty()),
  17. manifest.getEntries().values().stream())
  18. .map(attrs -> getExtension("", attrs)).filter(Objects::nonNull)
  19. .toArray(Extension[]::new);
  20. }

代码示例来源:origin: apache/ignite

  1. /**
  2. * Gets all signed files from the manifest.
  3. * <p>
  4. * It scans all manifest entries and their attributes. If there is an attribute
  5. * name which ends with "-DIGEST" we are assuming that manifest entry name is a
  6. * signed file name.
  7. *
  8. * @param manifest JAR file manifest.
  9. * @return Either empty set if none found or set of signed file names.
  10. */
  11. private static Set<String> getSignedFiles(Manifest manifest) {
  12. Set<String> fileNames = new HashSet<>();
  13. Map<String, Attributes> entries = manifest.getEntries();
  14. if (entries != null && entries.size() > 0) {
  15. for (Map.Entry<String, Attributes> entry : entries.entrySet()) {
  16. Attributes attrs = entry.getValue();
  17. for (Map.Entry<Object, Object> attrEntry : attrs.entrySet()) {
  18. if (attrEntry.getKey().toString().toUpperCase().endsWith("-DIGEST")) {
  19. fileNames.add(entry.getKey());
  20. break;
  21. }
  22. }
  23. }
  24. }
  25. return fileNames;
  26. }

代码示例来源:origin: pxb1988/dex2jar

  1. Manifest mf = new Manifest(in);
  2. mf.getMainAttributes().put(new Name("X-NOTICE"), "Modified");
  3. mf.getEntries().clear();

代码示例来源:origin: pxb1988/dex2jar

  1. int num;
  2. Map<String, Attributes> entries = manifest.getEntries();
  3. List<String> names = new ArrayList<>(entries.keySet());
  4. Collections.sort(names);

代码示例来源:origin: org.apache.ant/ant

  1. /**
  2. * Retrieve all the extensions listed under a particular key
  3. * (Usually EXTENSION_LIST or OPTIONAL_EXTENSION_LIST).
  4. *
  5. * @param manifest the manifest to extract extensions from
  6. * @param listKey the key used to get list (Usually
  7. * EXTENSION_LIST or OPTIONAL_EXTENSION_LIST)
  8. * @return the list of listed extensions
  9. */
  10. private static Extension[] getListed(final Manifest manifest,
  11. final Attributes.Name listKey) {
  12. final List<Extension> results = new ArrayList<>();
  13. final Attributes mainAttributes = manifest.getMainAttributes();
  14. if (null != mainAttributes) {
  15. getExtension(mainAttributes, results, listKey);
  16. }
  17. manifest.getEntries().values()
  18. .forEach(attributes -> getExtension(attributes, results, listKey));
  19. return results.toArray(new Extension[results.size()]);
  20. }

代码示例来源:origin: pxb1988/dex2jar

  1. output.getEntries().put(name, attr);

代码示例来源:origin: org.apache.ant/ant

  1. /**
  2. * Return an array of <code>Package Specification</code> objects.
  3. * If there are no such optional packages, a zero-length array is returned.
  4. *
  5. * @param manifest Manifest to be parsed
  6. * @return the Package Specifications extensions in specified manifest
  7. * @throws ParseException if the attributes of the specifications cannot
  8. * be parsed according to their expected formats.
  9. */
  10. public static Specification[] getSpecifications(final Manifest manifest)
  11. throws ParseException {
  12. if (null == manifest) {
  13. return new Specification[0];
  14. }
  15. final List<Specification> results = new ArrayList<>();
  16. for (Map.Entry<String, Attributes> e : manifest.getEntries().entrySet()) {
  17. Optional.ofNullable(getSpecification(e.getKey(), e.getValue()))
  18. .ifPresent(results::add);
  19. }
  20. return removeDuplicates(results)
  21. .toArray(new Specification[removeDuplicates(results).size()]);
  22. }

代码示例来源:origin: xalan/xalan

  1. atrs.put(java.util.jar.Attributes.Name.MANIFEST_VERSION,"1.2");
  2. final Map map = manifest.getEntries();

代码示例来源:origin: plutext/docx4j

  1. for(String key : manifest.getEntries().keySet() ) {

代码示例来源:origin: robovm/robovm

  1. Iterator<String> i = manifest.getEntries().keySet().iterator();
  2. while (i.hasNext()) {
  3. String key = i.next();

代码示例来源:origin: geoserver/geoserver

  1. /**
  2. * A parser for {@link Manifest} bean which generates {@link ManifestModel}s
  3. *
  4. * @param name the name to assign to the generated model
  5. * @param m the manifest bean to load
  6. * @return the generated model
  7. */
  8. private static ManifestModel parseManifest(
  9. final String name,
  10. final Manifest manifest,
  11. final AttributesFilter<Map<String, String>> filter) {
  12. final ManifestModel m = new ManifestModel(name);
  13. // Main attributes
  14. try {
  15. m.putAllEntries(filter.filter(manifest.getMainAttributes()));
  16. } catch (Exception e1) {
  17. LOGGER.log(Level.FINER, e1.getMessage(), e1);
  18. }
  19. //
  20. Map<String, Attributes> attrs = manifest.getEntries();
  21. for (java.util.Map.Entry<String, Attributes> entry : attrs.entrySet()) {
  22. try {
  23. m.putAllEntries(filter.filter(entry.getValue()));
  24. } catch (Exception e) {
  25. LOGGER.log(Level.FINER, e.getMessage(), e);
  26. }
  27. }
  28. return m;
  29. }

代码示例来源:origin: pxb1988/dex2jar

  1. Map<String, Attributes> entries = manifest.getEntries();
  2. sf.getEntries().put(entry.getKey(), sfAttr);

代码示例来源:origin: jeremylong/DependencyCheck

  1. for (Map.Entry<String, Attributes> item : manifest.getEntries().entrySet()) {
  2. final String name = item.getKey();
  3. source = "manifest: " + name;

代码示例来源:origin: stackoverflow.com

  1. for(Map.Entry<String, Attributes> entry: man.getEntries().entrySet()) {
  2. for(Object attrkey: entry.getValue().keySet()) {
  3. if (attrkey instanceof Attributes.Name &&

代码示例来源:origin: org.codehaus.plexus/plexus-archiver

  1. for ( Map.Entry<String, Attributes> o : other.getEntries().entrySet() )
  2. target.getEntries().put( o.getKey(), (Attributes) otherSection.clone() );

代码示例来源:origin: stackoverflow.com

  1. // Get Package Name
  2. String packageName = ctx.getPackageName();
  3. // Get classes.dex file signature
  4. ApplicationInfo ai = ctx.getApplicationInfo();
  5. String source = ai.sourceDir;
  6. JarFile jar = new JarFile(source);
  7. Manifest mf = jar.getManifest();
  8. Map<String, Attributes> map = mf.getEntries();
  9. Attributes a = map.get("classes.dex");
  10. String sha1 = (String)a.getValue("SHA1-Digest");

相关文章