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

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

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

/**
   * Read Manifest to get Selenium Version.
   * @param manifest manifest
   * @return Selenium Version detected
   */
  public static String getSeleniumVersionFromManifest(Manifest manifest) {
    String seleniumVersion = null;
    Attributes buildInfo = manifest.getAttributes("Build-Info");
    if (buildInfo != null) {
      seleniumVersion = buildInfo.getValue("Selenium-Version");
    }

    // Compatibility Selenium > 3.X
    if(seleniumVersion == null) {
      Attributes seleniumInfo = manifest.getAttributes("Selenium");
      if (seleniumInfo != null) {
        seleniumVersion = seleniumInfo.getValue("Selenium-Version");
      }
    }
    return seleniumVersion;
  }
}

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

private boolean isSealed(Manifest manifest, String dirName) {
  Attributes attributes = manifest.getAttributes(dirName);
  if (attributes != null) {
    String value = attributes.getValue(Attributes.Name.SEALED);
    if (value != null) {
      return value.equalsIgnoreCase("true");
    }
  }
  Attributes mainAttributes = manifest.getMainAttributes();
  String value = mainAttributes.getValue(Attributes.Name.SEALED);
  return (value != null && value.equalsIgnoreCase("true"));
}

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

/**
 * Returns the {@code Attributes} object associated with this entry or
 * {@code null} if none exists.
 *
 * @return the {@code Attributes} for this entry.
 * @exception IOException
 *                If an error occurs obtaining the {@code Attributes}.
 * @see Attributes
 */
public Attributes getAttributes() throws IOException {
  if (attributes != null || parentJar == null) {
    return attributes;
  }
  Manifest manifest = parentJar.getManifest();
  if (manifest == null) {
    return null;
  }
  return attributes = manifest.getAttributes(getName());
}

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

@Override
  protected ZipEntry createZipEntry(String name) {
    JarEntry entry = new JarEntry(name);
    if (manifest != null) {
      entry.setAttributes(manifest.getAttributes(name));
    }
    return entry;
  }
}

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

protected Object readAttribute(String name, String attrName) {
  if ("java.io.File".equals(attrName)) {
    return null;
  }
  Attributes attr1 = getManifest().getAttributes(name);
  try {
    return (attr1 == null) ? null : attr1.getValue(attrName);
  } catch (IllegalArgumentException iax) {
    return null;
  }
}

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

String getManifestAttribute(String name) {
 try {
  Manifest m = getManifest();
  if (m == null) {
   return "??";
  }
  Attributes attrs = m.getAttributes("beeline");
  if (attrs == null) {
   return "???";
  }
  String val = attrs.getValue(name);
  if (val == null || "".equals(val)) {
   return "????";
  }
  return val;
 } catch (Exception e) {
  e.printStackTrace(errorStream);
  return "?????";
 }
}

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

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

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

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

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

attr = input.getAttributes(name);

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

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

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

Attributes attributes = man.getAttributes(name);

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

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

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

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

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

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

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

protected Enumeration<String>  attributes(String name) {
  Attributes attr1 = getManifest().getAttributes(name);
  if (attr1 != null) {
    class ToString implements org.openide.util.Enumerations.Processor<Object, String> {
      public String process(Object obj, Collection<Object> ignore) {
        return obj.toString();
      }
    }
    return org.openide.util.Enumerations.convert(Collections.enumeration(attr1.keySet()), new ToString());
  } else {
    return org.openide.util.Enumerations.empty();
  }
}

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

final Attributes mainAttributes;
if (manifest != null) {
  fileAttributes = manifest.getAttributes(classResourceName);
  mainAttributes = manifest.getMainAttributes();
} else {

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

import java.util.jar.*;

...

JarFile myJar = new JarFile("nameOfJar.jar");    // various constructors available
Manifest manifest = myJar.getManifest();
Map<String,Attributes> manifestContents = manifest.getAttributes();

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

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

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

private boolean isSealed(Manifest manifest, String dirName) {
  Attributes attributes = manifest.getAttributes(dirName);
  if (attributes != null) {
    String value = attributes.getValue(Attributes.Name.SEALED);
    if (value != null) {
      return value.equalsIgnoreCase("true");
    }
  }
  Attributes mainAttributes = manifest.getMainAttributes();
  String value = mainAttributes.getValue(Attributes.Name.SEALED);
  return (value != null && value.equalsIgnoreCase("true"));
}

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

protected Attributes findManifestSection(String name) {
    try {
      URL inputStreamURL = this.getClass().getProtectionDomain().getCodeSource().getLocation();
      JarFile jarFile = new JarFile(inputStreamURL.getFile());
      java.util.jar.Manifest manifest = jarFile.getManifest();
      return manifest.getAttributes(name);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
}

相关文章