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

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

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

Manifest.getAttributes介绍

[英]Returns the Attributes associated with the parameter entry name.
[中]返回与参数项名称关联的属性。

代码示例

代码示例来源:origin: testcontainers/testcontainers-java

  1. /**
  2. * Read Manifest to get Selenium Version.
  3. * @param manifest manifest
  4. * @return Selenium Version detected
  5. */
  6. public static String getSeleniumVersionFromManifest(Manifest manifest) {
  7. String seleniumVersion = null;
  8. Attributes buildInfo = manifest.getAttributes("Build-Info");
  9. if (buildInfo != null) {
  10. seleniumVersion = buildInfo.getValue("Selenium-Version");
  11. }
  12. // Compatibility Selenium > 3.X
  13. if(seleniumVersion == null) {
  14. Attributes seleniumInfo = manifest.getAttributes("Selenium");
  15. if (seleniumInfo != null) {
  16. seleniumVersion = seleniumInfo.getValue("Selenium-Version");
  17. }
  18. }
  19. return seleniumVersion;
  20. }
  21. }

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

  1. private boolean isSealed(Manifest manifest, String dirName) {
  2. Attributes attributes = manifest.getAttributes(dirName);
  3. if (attributes != null) {
  4. String value = attributes.getValue(Attributes.Name.SEALED);
  5. if (value != null) {
  6. return value.equalsIgnoreCase("true");
  7. }
  8. }
  9. Attributes mainAttributes = manifest.getMainAttributes();
  10. String value = mainAttributes.getValue(Attributes.Name.SEALED);
  11. return (value != null && value.equalsIgnoreCase("true"));
  12. }

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

  1. /**
  2. * Returns the {@code Attributes} object associated with this entry or
  3. * {@code null} if none exists.
  4. *
  5. * @return the {@code Attributes} for this entry.
  6. * @exception IOException
  7. * If an error occurs obtaining the {@code Attributes}.
  8. * @see Attributes
  9. */
  10. public Attributes getAttributes() throws IOException {
  11. if (attributes != null || parentJar == null) {
  12. return attributes;
  13. }
  14. Manifest manifest = parentJar.getManifest();
  15. if (manifest == null) {
  16. return null;
  17. }
  18. return attributes = manifest.getAttributes(getName());
  19. }

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

  1. @Override
  2. protected ZipEntry createZipEntry(String name) {
  3. JarEntry entry = new JarEntry(name);
  4. if (manifest != null) {
  5. entry.setAttributes(manifest.getAttributes(name));
  6. }
  7. return entry;
  8. }
  9. }

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

  1. protected Object readAttribute(String name, String attrName) {
  2. if ("java.io.File".equals(attrName)) {
  3. return null;
  4. }
  5. Attributes attr1 = getManifest().getAttributes(name);
  6. try {
  7. return (attr1 == null) ? null : attr1.getValue(attrName);
  8. } catch (IllegalArgumentException iax) {
  9. return null;
  10. }
  11. }

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

  1. String getManifestAttribute(String name) {
  2. try {
  3. Manifest m = getManifest();
  4. if (m == null) {
  5. return "??";
  6. }
  7. Attributes attrs = m.getAttributes("beeline");
  8. if (attrs == null) {
  9. return "???";
  10. }
  11. String val = attrs.getValue(name);
  12. if (val == null || "".equals(val)) {
  13. return "????";
  14. }
  15. return val;
  16. } catch (Exception e) {
  17. e.printStackTrace(errorStream);
  18. return "?????";
  19. }
  20. }

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

  1. Attributes attributes = manifest.getAttributes(packageName.replace('.', '/').concat("/"));
  2. if (attributes != null) {
  3. for (Attributes.Name attributeName : ATTRIBUTE_NAMES) {

代码示例来源:origin: jenkinsci/jenkins

  1. URL sealBase = null;
  2. Attributes sectionAttributes = manifest.getAttributes(sectionName);
  3. if (sectionAttributes != null) {
  4. specificationTitle = sectionAttributes.getValue(Name.SPECIFICATION_TITLE);

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

  1. attr = input.getAttributes(name);

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

  1. if (manifest.getAttributes(entryName) != null || manifest.getAttributes("./" + entryName) != null ||
  2. manifest.getAttributes('/' + entryName) != null)
  3. inManifest = true;

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

  1. Attributes attributes = man.getAttributes(name);

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

  1. mainAttribs = manifest.getAttributes((String)key);

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

  1. Attributes mainAttributes = manifest.getMainAttributes();
  2. String dirName = packageName.replace('.', '/') + "/";
  3. Attributes packageAttributes = manifest.getAttributes(dirName);
  4. boolean noEntry = false;
  5. if (packageAttributes == null) {

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

  1. URL sealBase = null;
  2. final Attributes sectionAttributes = manifest.getAttributes(sectionName);
  3. if (sectionAttributes != null) {
  4. specificationTitle = sectionAttributes.getValue(Name.SPECIFICATION_TITLE);

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

  1. protected Enumeration<String> attributes(String name) {
  2. Attributes attr1 = getManifest().getAttributes(name);
  3. if (attr1 != null) {
  4. class ToString implements org.openide.util.Enumerations.Processor<Object, String> {
  5. public String process(Object obj, Collection<Object> ignore) {
  6. return obj.toString();
  7. }
  8. }
  9. return org.openide.util.Enumerations.convert(Collections.enumeration(attr1.keySet()), new ToString());
  10. } else {
  11. return org.openide.util.Enumerations.empty();
  12. }
  13. }

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

  1. final Attributes mainAttributes;
  2. if (manifest != null) {
  3. fileAttributes = manifest.getAttributes(classResourceName);
  4. mainAttributes = manifest.getMainAttributes();
  5. } else {

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

  1. import java.util.jar.*;
  2. ...
  3. JarFile myJar = new JarFile("nameOfJar.jar"); // various constructors available
  4. Manifest manifest = myJar.getManifest();
  5. Map<String,Attributes> manifestContents = manifest.getAttributes();

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

  1. Attributes ourSection = target.getAttributes( o.getKey() );
  2. Attributes otherSection = o.getValue();
  3. if ( ourSection == null )

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

  1. private boolean isSealed(Manifest manifest, String dirName) {
  2. Attributes attributes = manifest.getAttributes(dirName);
  3. if (attributes != null) {
  4. String value = attributes.getValue(Attributes.Name.SEALED);
  5. if (value != null) {
  6. return value.equalsIgnoreCase("true");
  7. }
  8. }
  9. Attributes mainAttributes = manifest.getMainAttributes();
  10. String value = mainAttributes.getValue(Attributes.Name.SEALED);
  11. return (value != null && value.equalsIgnoreCase("true"));
  12. }

代码示例来源:origin: zycgit/hasor

  1. protected Attributes findManifestSection(String name) {
  2. try {
  3. URL inputStreamURL = this.getClass().getProtectionDomain().getCodeSource().getLocation();
  4. JarFile jarFile = new JarFile(inputStreamURL.getFile());
  5. java.util.jar.Manifest manifest = jarFile.getManifest();
  6. return manifest.getAttributes(name);
  7. } catch (Exception e) {
  8. e.printStackTrace();
  9. }
  10. return null;
  11. }
  12. }

相关文章