Java 8 Attributes - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Attributes class.

This code example shows how to use the following methods:getValue
     * does not bundle any extensions 
     */ 
    private ArrayList getAvailableExtensions(Manifest manifest) {
 
        Attributes attributes = manifest.getMainAttributes();
        String name = attributes.getValue("Extension-Name");
        if (name == null)
            return null; 
 
        ArrayList extensionList = new ArrayList();
 
        Extension extension = new Extension();
        extension.setExtensionName(name);
        extension.setImplementationURL(
            attributes.getValue("Implementation-URL"));
        extension.setImplementationVendor(
            attributes.getValue("Implementation-Vendor"));
        extension.setImplementationVendorId(
            attributes.getValue("Implementation-Vendor-Id"));
        extension.setImplementationVersion(

7
CodeRank
This code example shows how to use the following methods:put, putAll
import java.util.jar.Attributes; 
import java.util.HashMap; 
 
public class PutAndPutAll { 
    public static void main(String[] args) throws Exception {
        Attributes at = new Attributes();
        try{ 
            at.put("this is not an Attributes.Name", "value");
            throw new Exception("put should check for non Attributes.Name names");
        } catch (ClassCastException e) {
        } 
 
        try{ 
            at.put(new Attributes.Name("name"), new Integer(0));
            throw new Exception("put should check for non String values");
        } catch (ClassCastException e) {
        } 
 
        try { 
            at.putAll(new HashMap());

7
CodeRank
This code example shows how to use the following methods:getValue
     * does not bundle any extensions 
     */ 
    private ArrayList<Extension> getAvailableExtensions(Manifest manifest) {
 
        Attributes attributes = manifest.getMainAttributes();
        String name = attributes.getValue("Extension-Name");
        if (name == null)
            return null; 
 
        ArrayList<Extension> extensionList = new ArrayList<Extension>();
 
        Extension extension = new Extension();
        extension.setExtensionName(name);
        extension.setImplementationURL(
            attributes.getValue("Implementation-URL"));
        extension.setImplementationVendor(
            attributes.getValue("Implementation-Vendor"));
        extension.setImplementationVendorId(
            attributes.getValue("Implementation-Vendor-Id"));
        extension.setImplementationVersion(

7
CodeRank
This code example shows how to use the following methods:getValue
 
    public static String getMainAttributeValue(Manifest manifest, String attribute) {
        String result = null;
        if (manifest != null && attribute != null) {
            Attributes attributes = manifest.getMainAttributes();
            result = attributes.getValue(attribute);
        } 
        return result;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:put
    } 
 
    @Override 
    void includeAttribute(Name attribute, String value) {
        Map<String, Attributes> entries = manifest.getEntries();
        Attributes attributes = entries.containsKey(entryName) ? manifest.getAttributes(entryName) : new Attributes();
        attributes.put(attribute, value);
        entries.put(entryName, attributes);
    } 
 
    @Override 
    String findAttribute(Name name) {
        Map<String, Attributes> entries = manifest.getEntries();
        if (entries.containsKey(entryName))
            return manifest.getAttributes(entryName).getValue(name);
 
        return null; 
    } 
 
    @Override 
6
CodeRank
This code example shows how to use the following methods:putValue
        try { 
            Node node = archive.get(JarFile.MANIFEST_NAME);
            if (node == null) {
                manifest = new Manifest();
                Attributes attributes = manifest.getMainAttributes();
                attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
            } else { 
                manifest = new Manifest(node.getAsset().openStream());
            } 
            return manifest;
        } catch (Exception ex) {
            throw new IllegalStateException("Cannot obtain manifest", ex);
        } 
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:putValue
public class OldAttributesTest extends TestCase {
    private Attributes a;
 
    @Override 
    protected void setUp() { 
        a = new Attributes();
        a.putValue("1", "one");
        a.putValue("2", "two");
        a.putValue("3", "three");
        a.putValue("4", "four");
    } 
 
    public void test_getLjava_lang_Object() { 
 
        try { 
            a.getValue("IllegalArgumentException expected");
        } catch (IllegalArgumentException ee) {
            // expected 
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:putValue
        try { 
            Node node = archive.get(JarFile.MANIFEST_NAME);
            if (node == null) {
                manifest = new Manifest();
                Attributes attributes = manifest.getMainAttributes();
                attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
            } else if (create) {
                manifest = new Manifest(node.getAsset().openStream());
            } 
            return manifest;
        } catch (Exception ex) {
            throw new IllegalStateException("Cannot obtain manifest", ex);
        } 
    } 
 
    public static Manifest getOrCreateManifest(Archive<?> archive) {
        Manifest manifest;
        try { 
            Node node = archive.get(JarFile.MANIFEST_NAME);
            if (node == null) {
7
CodeRank
This code example shows how to use the following methods:put, putAll
import java.util.jar.Attributes;
import java.util.HashMap;
 
public class PutAndPutAll { 
    public static void main(String[] args) throws Exception {
        Attributes at = new Attributes();
        try{ 
            at.put("this is not an Attributes.Name", "value");
            throw new Exception("put should check for non Attributes.Name names");
        } catch (ClassCastException e) {
        } 
 
        try{ 
            at.put(new Attributes.Name("name"), new Integer(0));
            throw new Exception("put should check for non String values");
        } catch (ClassCastException e) {
        } 
 
        try { 
            at.putAll(new HashMap());

6
CodeRank
This code example shows how to use the following methods:put, putAll
import java.util.jar.Attributes; 
import java.util.HashMap; 
 
public class PutAndPutAll { 
    public static void main(String[] args) throws Exception {
        Attributes at = new Attributes();
        try{ 
            at.put("this is not an Attributes.Name", "value");
            throw new Exception("put should check for non Attributes.Name names");
        } catch (ClassCastException e) {
        } 
 
        try{ 
            at.put(new Attributes.Name("name"), new Integer(0));
            throw new Exception("put should check for non String values");
        } catch (ClassCastException e) {
        } 
 
        try { 
            at.putAll(new HashMap());

6
CodeRank
See Code Examples for Java 8 Attributes Methods: