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

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

本文整理了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

/**
 * Returns the {@code Attributes} associated with the parameter entry
 * {@code name}.
 *
 * @param name
 *            the name of the entry to obtain {@code Attributes} from.
 * @return the Attributes for the entry or {@code null} if the entry does
 *         not exist.
 */
public Attributes getAttributes(String name) {
  return getEntries().get(name);
}

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

/**
 * Returns the hash code for this instance.
 *
 * @return this {@code Manifest}'s hashCode.
 */
@Override
public int hashCode() {
  return mainAttributes.hashCode() ^ getEntries().hashCode();
}

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

/**
 * Creates a new {@code Manifest} instance. The new instance will have the
 * same attributes as those found in the parameter {@code Manifest}.
 *
 * @param man
 *            {@code Manifest} instance to obtain attributes from.
 */
@SuppressWarnings("unchecked")
public Manifest(Manifest man) {
  mainAttributes = (Attributes) man.mainAttributes.clone();
  entries = (HashMap<String, Attributes>) ((HashMap<String, Attributes>) man
      .getEntries()).clone();
}

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

/**
 * Determines if the receiver is equal to the parameter object. Two {@code
 * Manifest}s are equal if they have identical main attributes as well as
 * identical entry attributes.
 *
 * @param o
 *            the object to compare against.
 * @return {@code true} if the manifests are equal, {@code false} otherwise
 */
@Override
public boolean equals(Object o) {
  if (o == null) {
    return false;
  }
  if (o.getClass() != this.getClass()) {
    return false;
  }
  if (!mainAttributes.equals(((Manifest) o).mainAttributes)) {
    return false;
  }
  return getEntries().equals(((Manifest) o).getEntries());
}

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

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

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

/**
 * 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;
}

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

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

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

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

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

/**
 * Retrieve all the extensions listed under a particular key
 * (Usually EXTENSION_LIST or OPTIONAL_EXTENSION_LIST).
 *
 * @param manifest the manifest to extract extensions from
 * @param listKey the key used to get list (Usually
 *        EXTENSION_LIST or OPTIONAL_EXTENSION_LIST)
 * @return the list of listed extensions
 */
private static Extension[] getListed(final Manifest manifest,
                   final Attributes.Name listKey) {
  final List<Extension> results = new ArrayList<>();
  final Attributes mainAttributes = manifest.getMainAttributes();
  if (null != mainAttributes) {
    getExtension(mainAttributes, results, listKey);
  }
  manifest.getEntries().values()
    .forEach(attributes -> getExtension(attributes, results, listKey));
  return results.toArray(new Extension[results.size()]);
}

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

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

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

/**
 * Return an array of <code>Package Specification</code> objects.
 * If there are no such optional packages, a zero-length array is returned.
 *
 * @param manifest Manifest to be parsed
 * @return the Package Specifications extensions in specified manifest
 * @throws ParseException if the attributes of the specifications cannot
 * be parsed according to their expected formats.
 */
public static Specification[] getSpecifications(final Manifest manifest)
  throws ParseException {
  if (null == manifest) {
    return new Specification[0];
  }
  final List<Specification> results = new ArrayList<>();
  for (Map.Entry<String, Attributes> e : manifest.getEntries().entrySet()) {
    Optional.ofNullable(getSpecification(e.getKey(), e.getValue()))
      .ifPresent(results::add);
  }
  return removeDuplicates(results)
    .toArray(new Specification[removeDuplicates(results).size()]);
}

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

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

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

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

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

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

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

/**
 * A parser for {@link Manifest} bean which generates {@link ManifestModel}s
 *
 * @param name the name to assign to the generated model
 * @param m the manifest bean to load
 * @return the generated model
 */
private static ManifestModel parseManifest(
    final String name,
    final Manifest manifest,
    final AttributesFilter<Map<String, String>> filter) {
  final ManifestModel m = new ManifestModel(name);
  // Main attributes
  try {
    m.putAllEntries(filter.filter(manifest.getMainAttributes()));
  } catch (Exception e1) {
    LOGGER.log(Level.FINER, e1.getMessage(), e1);
  }
  //
  Map<String, Attributes> attrs = manifest.getEntries();
  for (java.util.Map.Entry<String, Attributes> entry : attrs.entrySet()) {
    try {
      m.putAllEntries(filter.filter(entry.getValue()));
    } catch (Exception e) {
      LOGGER.log(Level.FINER, e.getMessage(), e);
    }
  }
  return m;
}

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

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

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

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

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

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

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

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

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

// Get Package Name
String packageName = ctx.getPackageName();

// Get classes.dex file signature
ApplicationInfo ai = ctx.getApplicationInfo();
String source = ai.sourceDir;

JarFile jar = new JarFile(source);
Manifest mf = jar.getManifest();

Map<String, Attributes> map = mf.getEntries();

Attributes a = map.get("classes.dex");
String sha1 = (String)a.getValue("SHA1-Digest");

相关文章