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

x33g5p2x  于2022-01-15 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(137)

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

Attributes.get介绍

[英]Returns the value associated with the parameter key.
[中]返回与参数键关联的值。

代码示例

代码示例来源:origin: Netflix/eureka

String getManifestAttribute(String name, String defaultValue) {
  if (manifest == null) {
    return defaultValue;
  }
  Name attrName = new Name(name);
  Object value = manifest.getMainAttributes().get(attrName);
  return value == null ? defaultValue : value.toString();
}

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

if (attributes.get(Attributes.Name.SIGNATURE_VERSION) == null) {
  return;

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

Hashtable<String, String> env = new Hashtable<String, String>();

env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");

DirContext ictx = new InitialDirContext(env);

Attributes attrs = ictx.getAttributes(domainName, new String[] {"MX"});

Attribute attr = attrs.get("MX");

if (attr == null)
  // No MX record
else
  // If attr.size() > 0, there is an MX record

代码示例来源:origin: remkop/picocli

private static Object get(Attributes attributes, String key) {
    return attributes.get(new Attributes.Name(key));
  }
}

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

System.out.println(">>>>>>" + attrs.get("samAccountName"));

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

try {
    LdapContext ctx = new InitialLdapContext(env, null);
    ctx.setRequestControls(null);
    NamingEnumeration<?> namingEnum = ctx.search("ou=people,dc=example,dc=com", "(objectclass=user)", getSimpleSearchControls());
    while (namingEnum.hasMore ()) {
      SearchResult result = (SearchResult) namingEnum.next ();    
      Attributes attrs = result.getAttributes ();
      System.out.println(attrs.get("cn"));

    } 
    namingEnum.close();
  } catch (Exception e) {
    e.printStackTrace();
  }

private SearchControls getSimpleSearchControls() {
  SearchControls searchControls = new SearchControls();
  searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
  searchControls.setTimeLimit(30000);
  //String[] attrIDs = {"objectGUID"};
  //searchControls.setReturningAttributes(attrIDs);
  return searchControls;
}

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

Attribute dnAttr = attrs.get("distinguishedName");
String dn = (String) dnAttr.get();

代码示例来源:origin: remkop/picocli

private boolean isApplicableManifest(Manifest manifest) {
  Attributes attributes = manifest.getMainAttributes();
  return "picocli".equals(attributes.get(key("Implementation-Title")));
}
private static Attributes.Name key(String key) { return new Attributes.Name(key); }

代码示例来源:origin: remkop/picocli

public String[] getVersion() throws Exception {
  Enumeration<URL> resources = CommandLine.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
  while (resources.hasMoreElements()) {
    URL url = resources.nextElement();
    try {
      Manifest manifest = new Manifest(url.openStream());
      if (isApplicableManifest(manifest)) {
        Attributes attributes = manifest.getMainAttributes();
        return new String[] { attributes.get(key("Implementation-Title")) + " version \"" + attributes.get(key("Implementation-Version")) + "\"" };
      }
    } catch (IOException ex) {
      return new String[] { "Unable to read from " + url + ": " + ex };
    }
  }
  return new String[0];
}

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

Hashtable env = new Hashtable();
env.put("java.naming.factory.initial",
       "com.sun.jndi.dns.DnsContextFactory");
DirContext ictx = new InitialDirContext( env );
Attributes attrs = ictx.getAttributes
            ( hostName, new String[] { "MX" });
Attribute attr = attrs.get( "MX" );
if (( attr == null ) || ( attr.size() == 0 )) {
  attrs = ictx.getAttributes( hostName, new String[] { "A" });
  attr = attrs.get( "A" );
  if( attr == null )
     throw new NamingException
         ( "No match for name '" + hostName + "'" );
}

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

/**
 * Merge in another section
 *
 * @param target The target manifest of the merge
 * @param section the section to be merged with this one.
 */
public static void mergeAttributes( java.util.jar.Attributes target, java.util.jar.Attributes section )
{
  for ( Object o : section.keySet() )
  {
    java.util.jar.Attributes.Name key = (Attributes.Name) o;
    final Object value = section.get( o );
    // the merge file always wins
    target.put( key, value );
  }
}

代码示例来源:origin: opensourceBIM/BIMserver

for (Object key : mainAttributes.keySet()) {
  if (key.toString().equals("Real-Main-Class")) {
    realMainClass = mainAttributes.get(key).toString();
    break;

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

Attributes attributes = dirContext.getAttributes( "", new String[]{"namingContexts"} );
Attribute attribute = attributes.get( "namingContexts" );
NamingEnumeration<?> all = attribute.getAll();
while(all.hasMore())
{
  String next = (String)all.next();
  System.out.println(next);
}

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

while(answer.hasMore()) {
  System.out.print("while loop11");
  SearchResult rslt = (SearchResult)answer.next();          
  Attributes attrs = rslt.getAttributes();           
  //System.out.println(attrs.get("uid"));
  System.out.println(attrs.get("cn"));
  ctx1.close(); 
  }

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

Attributes attrs = dirContext.getAttributes("paypal.com", new String[] { "TXT" });
Attribute txt = attrs.get("TXT");
NamingEnumeration e = txt.getAll();
while (e.hasMore()) {
   System.out.println(e.next());
}

代码示例来源:origin: org.glassfish.hk2/hk2-core

private void merge(Attributes target, Attributes source) {
  for (Object o : source.keySet()) {
    if (target.containsKey(o)) {
      String sep = mappings.containsKey(o.toString())?mappings.get(o.toString()):",";
      String newValue = target.get(o) + sep
          + source.get(o);
      target.put(o, newValue);
    } else {
      target.put(o, source.get(o));
    }
  }
}

代码示例来源:origin: org.glassfish.hk2/core

private void merge(Attributes target, Attributes source) {
  for (Object o : source.keySet()) {
    if (target.containsKey(o)) {
      String sep = mappings.containsKey(o.toString())?mappings.get(o.toString()):",";
      String newValue = target.get(o) + sep
          + source.get(o);
      target.put(o, newValue);
    } else {
      target.put(o, source.get(o));
    }
  }
}

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

DirContext ctx = new InitialLdapContext( env, null );

SearchControls searchControls = new SearchControls();
searchControls.setSearchScope( SearchControls.OBJECT_SCOPE );
searchControls.setReturningAttributes( new String[]
  { "objectClasses" } );
NamingEnumeration<SearchResult> results = ctx.search( "cn=schema", "(ObjectClass=*)", searchControls );

SearchResult result = results.next();
Attributes entry = result.getAttributes();

Attribute objectClasses = entry.get( "objectClasses" );
System.out.println( objectClasses );

代码示例来源:origin: org.codehaus.tycho/tycho-osgi-components

private static Properties manifestToProperties( Attributes d )
{
  Iterator iter = d.keySet().iterator();
  Properties result = new Properties();
  while ( iter.hasNext() )
  {
    Attributes.Name key = (Attributes.Name) iter.next();
    result.put( key.toString(), d.get( key ) );
  }
  return result;
}

代码示例来源:origin: org.jboss.shrinkwrap.descriptors/shrinkwrap-descriptors-impl-base

public ManifestAppletDefImpl(String descriptorName, ManifestModel manifest, String appletName) {
  super(descriptorName, manifest);
  this.appletName = appletName;
  Attributes mainAttributes = manifest.getMainAttributes();
  String extensionListValue = (mainAttributes.containsKey(Name.EXTENSION_LIST) ? String.valueOf(mainAttributes
    .get(Name.EXTENSION_LIST)) + " " + appletName : appletName);
  manifest.getMainAttributes().put(Name.EXTENSION_LIST, extensionListValue);
}

相关文章