當前位置: 首頁>>代碼示例>>Java>>正文


Java Manifest.getAttributes方法代碼示例

本文整理匯總了Java中java.util.jar.Manifest.getAttributes方法的典型用法代碼示例。如果您正苦於以下問題:Java Manifest.getAttributes方法的具體用法?Java Manifest.getAttributes怎麽用?Java Manifest.getAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.jar.Manifest的用法示例。


在下文中一共展示了Manifest.getAttributes方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isPackageSealed

import java.util.jar.Manifest; //導入方法依賴的package包/類
/**
 * Returns true if the specified package name is sealed according to the
 * given manifest.
 */
protected boolean isPackageSealed(String name, Manifest man) {

    String path = name.replace('.', '/') + '/';
    Attributes attr = man.getAttributes(path);
    String sealed = null;
    if (attr != null) {
        sealed = attr.getValue(Name.SEALED);
    }
    if (sealed == null) {
        if ((attr = man.getMainAttributes()) != null) {
            sealed = attr.getValue(Name.SEALED);
        }
    }
    return "true".equalsIgnoreCase(sealed);

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:21,代碼來源:WebappClassLoaderBase.java

示例2: isPackageSealed

import java.util.jar.Manifest; //導入方法依賴的package包/類
/**
 * Returns true if the specified package name is sealed according to the
 * given manifest.
 */
protected boolean isPackageSealed(String name, Manifest man) {

    String path = name.replace('.', '/') + '/';
    Attributes attr = man.getAttributes(path); 
    String sealed = null;
    if (attr != null) {
        sealed = attr.getValue(Name.SEALED);
    }
    if (sealed == null) {
        if ((attr = man.getMainAttributes()) != null) {
            sealed = attr.getValue(Name.SEALED);
        }
    }
    return "true".equalsIgnoreCase(sealed);

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:WebappClassLoader.java

示例3: isPackageSealed

import java.util.jar.Manifest; //導入方法依賴的package包/類
/**
 * Returns true if the specified package name is sealed according to the
 * given manifest.
 */
protected boolean isPackageSealed(String name, Manifest man) {

    String path = name + "/";
    Attributes attr = man.getAttributes(path);
    String sealed = null;
    if (attr != null) {
        sealed = attr.getValue(Name.SEALED);
    }
    if (sealed == null) {
        if ((attr = man.getMainAttributes()) != null) {
            sealed = attr.getValue(Name.SEALED);
        }
    }
    return "true".equalsIgnoreCase(sealed);

}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:21,代碼來源:WebappClassLoader.java

示例4: isPackageSealed

import java.util.jar.Manifest; //導入方法依賴的package包/類
/**
 * Returns true if the specified package name is sealed according to the
 * given manifest.
 */
protected boolean isPackageSealed(String name, Manifest man) {

	String path = name.replace('.', '/') + '/';
	Attributes attr = man.getAttributes(path);
	String sealed = null;
	if (attr != null) {
		sealed = attr.getValue(Name.SEALED);
	}
	if (sealed == null) {
		if ((attr = man.getMainAttributes()) != null) {
			sealed = attr.getValue(Name.SEALED);
		}
	}
	return "true".equalsIgnoreCase(sealed);

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:21,代碼來源:WebappClassLoaderBase.java

示例5: isSealed

import java.util.jar.Manifest; //導入方法依賴的package包/類
private boolean isSealed(final String path, final Manifest manifest) {
    Attributes attributes = manifest.getAttributes(path);
    String sealed = null;
    if(attributes != null) {
        sealed = attributes.getValue(Name.SEALED);
    }

    if(sealed == null) {
        attributes = manifest.getMainAttributes();
        if(attributes != null) {
            sealed = attributes.getValue(Name.SEALED);
        }
    }
    return "true".equalsIgnoreCase(sealed);
}
 
開發者ID:Gogume1er,項目名稱:caoutchouc,代碼行數:16,代碼來源:CaoutchoucClassLoader.java

示例6: extractFromManifest

import java.util.jar.Manifest; //導入方法依賴的package包/類
private static String[] extractFromManifest(Manifest man, String path) {
    Attributes spec = man.getAttributes(path);
    Attributes main = man.getMainAttributes();
    String[] arr = new String[7];
    arr[0] = getAttr(spec, main, Attributes.Name.SPECIFICATION_TITLE);
    arr[1] = getAttr(spec, main, Attributes.Name.SPECIFICATION_VERSION);
    arr[2] = getAttr(spec, main, Attributes.Name.SPECIFICATION_VENDOR);
    arr[3] = getAttr(spec, main, Attributes.Name.IMPLEMENTATION_TITLE);
    arr[4] = getAttr(spec, main, Attributes.Name.IMPLEMENTATION_VERSION);
    arr[5] = getAttr(spec, main, Attributes.Name.IMPLEMENTATION_VENDOR);
    arr[6] = getAttr(spec, main, Attributes.Name.SEALED);
    return arr;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:PackageAttrsCache.java

示例7: isSealed

import java.util.jar.Manifest; //導入方法依賴的package包/類
private boolean isSealed(String name, Manifest man) {
    String path = name.replace('.', '/').concat("/");
    Attributes attr = man.getAttributes(path);
    String sealed = null;
    if (attr != null) {
        sealed = attr.getValue(Name.SEALED);
    }
    if (sealed == null) {
        if ((attr = man.getMainAttributes()) != null) {
            sealed = attr.getValue(Name.SEALED);
        }
    }
    return "true".equalsIgnoreCase(sealed);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:URLClassLoader.java

示例8: isSealed

import java.util.jar.Manifest; //導入方法依賴的package包/類
/**
 * Returns {@code true} if the specified package name is sealed according to
 * the given manifest.
 */
private boolean isSealed(String pn, Manifest man) {
    String path = pn.replace('.', '/').concat("/");
    Attributes attr = man.getAttributes(path);
    String sealed = null;
    if (attr != null)
        sealed = attr.getValue(Attributes.Name.SEALED);
    if (sealed == null && (attr = man.getMainAttributes()) != null)
        sealed = attr.getValue(Attributes.Name.SEALED);
    return "true".equalsIgnoreCase(sealed);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:BuiltinClassLoader.java

示例9: Package

import java.util.jar.Manifest; //導入方法依賴的package包/類
private Package(String name, Manifest man, URL url, ClassLoader loader) {
    String path = name.replace('.', '/').concat("/");
    String sealed = null;
    String specTitle= null;
    String specVersion= null;
    String specVendor= null;
    String implTitle= null;
    String implVersion= null;
    String implVendor= null;
    URL sealBase= null;
    Attributes attr = man.getAttributes(path);
    if (attr != null) {
        specTitle   = attr.getValue(Name.SPECIFICATION_TITLE);
        specVersion = attr.getValue(Name.SPECIFICATION_VERSION);
        specVendor  = attr.getValue(Name.SPECIFICATION_VENDOR);
        implTitle   = attr.getValue(Name.IMPLEMENTATION_TITLE);
        implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION);
        implVendor  = attr.getValue(Name.IMPLEMENTATION_VENDOR);
        sealed      = attr.getValue(Name.SEALED);
    }
    attr = man.getMainAttributes();
    if (attr != null) {
        if (specTitle == null) {
            specTitle = attr.getValue(Name.SPECIFICATION_TITLE);
        }
        if (specVersion == null) {
            specVersion = attr.getValue(Name.SPECIFICATION_VERSION);
        }
        if (specVendor == null) {
            specVendor = attr.getValue(Name.SPECIFICATION_VENDOR);
        }
        if (implTitle == null) {
            implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE);
        }
        if (implVersion == null) {
            implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION);
        }
        if (implVendor == null) {
            implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR);
        }
        if (sealed == null) {
            sealed = attr.getValue(Name.SEALED);
        }
    }
    if ("true".equalsIgnoreCase(sealed)) {
        sealBase = url;
    }
    pkgName = name;
    this.specTitle = specTitle;
    this.specVersion = specVersion;
    this.specVendor = specVendor;
    this.implTitle = implTitle;
    this.implVersion = implVersion;
    this.implVendor = implVendor;
    this.sealBase = sealBase;
    this.loader = loader;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:58,代碼來源:Package.java

示例10: definePackage

import java.util.jar.Manifest; //導入方法依賴的package包/類
/**
 * Defines a new package by name in this ClassLoader. The attributes
 * contained in the specified Manifest will be used to obtain package
 * version and sealing information. For sealed packages, the additional
 * URL specifies the code source URL from which the package was loaded.
 *
 * @param name  the package name
 * @param man   the Manifest containing package version and sealing
 *              information
 * @param url   the code source url for the package, or null if none
 * @exception   IllegalArgumentException if the package name duplicates
 *              an existing package either in this class loader or one
 *              of its ancestors
 * @return the newly defined Package object
 */
protected Package definePackage(String name, Manifest man, URL url)
    throws IllegalArgumentException
{
    String path = name.replace('.', '/').concat("/");
    String specTitle = null, specVersion = null, specVendor = null;
    String implTitle = null, implVersion = null, implVendor = null;
    String sealed = null;
    URL sealBase = null;

    Attributes attr = man.getAttributes(path);
    if (attr != null) {
        specTitle   = attr.getValue(Name.SPECIFICATION_TITLE);
        specVersion = attr.getValue(Name.SPECIFICATION_VERSION);
        specVendor  = attr.getValue(Name.SPECIFICATION_VENDOR);
        implTitle   = attr.getValue(Name.IMPLEMENTATION_TITLE);
        implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION);
        implVendor  = attr.getValue(Name.IMPLEMENTATION_VENDOR);
        sealed      = attr.getValue(Name.SEALED);
    }
    attr = man.getMainAttributes();
    if (attr != null) {
        if (specTitle == null) {
            specTitle = attr.getValue(Name.SPECIFICATION_TITLE);
        }
        if (specVersion == null) {
            specVersion = attr.getValue(Name.SPECIFICATION_VERSION);
        }
        if (specVendor == null) {
            specVendor = attr.getValue(Name.SPECIFICATION_VENDOR);
        }
        if (implTitle == null) {
            implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE);
        }
        if (implVersion == null) {
            implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION);
        }
        if (implVendor == null) {
            implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR);
        }
        if (sealed == null) {
            sealed = attr.getValue(Name.SEALED);
        }
    }
    if ("true".equalsIgnoreCase(sealed)) {
        sealBase = url;
    }
    return definePackage(name, specTitle, specVersion, specVendor,
                         implTitle, implVersion, implVendor, sealBase);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:65,代碼來源:URLClassLoader.java

示例11: definePackage

import java.util.jar.Manifest; //導入方法依賴的package包/類
/**
 * Defines a new package by name in this {@code URLClassLoader}.
 * The attributes contained in the specified {@code Manifest}
 * will be used to obtain package version and sealing information.
 * For sealed packages, the additional URL specifies the code source URL
 * from which the package was loaded.
 *
 * @param name  the package name
 * @param man   the {@code Manifest} containing package version and sealing
 *              information
 * @param url   the code source url for the package, or null if none
 * @throws      IllegalArgumentException if the package name is
 *              already defined by this class loader
 * @return      the newly defined {@code Package} object
 *
 * @revised 9
 * @spec JPMS
 */
protected Package definePackage(String name, Manifest man, URL url) {
    String path = name.replace('.', '/').concat("/");
    String specTitle = null, specVersion = null, specVendor = null;
    String implTitle = null, implVersion = null, implVendor = null;
    String sealed = null;
    URL sealBase = null;

    Attributes attr = man.getAttributes(path);
    if (attr != null) {
        specTitle   = attr.getValue(Name.SPECIFICATION_TITLE);
        specVersion = attr.getValue(Name.SPECIFICATION_VERSION);
        specVendor  = attr.getValue(Name.SPECIFICATION_VENDOR);
        implTitle   = attr.getValue(Name.IMPLEMENTATION_TITLE);
        implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION);
        implVendor  = attr.getValue(Name.IMPLEMENTATION_VENDOR);
        sealed      = attr.getValue(Name.SEALED);
    }
    attr = man.getMainAttributes();
    if (attr != null) {
        if (specTitle == null) {
            specTitle = attr.getValue(Name.SPECIFICATION_TITLE);
        }
        if (specVersion == null) {
            specVersion = attr.getValue(Name.SPECIFICATION_VERSION);
        }
        if (specVendor == null) {
            specVendor = attr.getValue(Name.SPECIFICATION_VENDOR);
        }
        if (implTitle == null) {
            implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE);
        }
        if (implVersion == null) {
            implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION);
        }
        if (implVendor == null) {
            implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR);
        }
        if (sealed == null) {
            sealed = attr.getValue(Name.SEALED);
        }
    }
    if ("true".equalsIgnoreCase(sealed)) {
        sealBase = url;
    }
    return definePackage(name, specTitle, specVersion, specVendor,
                         implTitle, implVersion, implVendor, sealBase);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:66,代碼來源:URLClassLoader.java

示例12: definePackage

import java.util.jar.Manifest; //導入方法依賴的package包/類
/**
 * Defines a new package in this ClassLoader. The attributes in the specified
 * Manifest are use to get the package version and sealing information.
 *
 * @throws IllegalArgumentException if the package name duplicates an
 * existing package either in this class loader or one of its ancestors
 */
private Package definePackage(String pn, Manifest man, URL url) {
    String specTitle = null;
    String specVersion = null;
    String specVendor = null;
    String implTitle = null;
    String implVersion = null;
    String implVendor = null;
    String sealed = null;
    URL sealBase = null;

    if (man != null) {
        Attributes attr = man.getAttributes(pn.replace('.', '/').concat("/"));
        if (attr != null) {
            specTitle = attr.getValue(Attributes.Name.SPECIFICATION_TITLE);
            specVersion = attr.getValue(Attributes.Name.SPECIFICATION_VERSION);
            specVendor = attr.getValue(Attributes.Name.SPECIFICATION_VENDOR);
            implTitle = attr.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
            implVersion = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
            implVendor = attr.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);
            sealed = attr.getValue(Attributes.Name.SEALED);
        }

        attr = man.getMainAttributes();
        if (attr != null) {
            if (specTitle == null)
                specTitle = attr.getValue(Attributes.Name.SPECIFICATION_TITLE);
            if (specVersion == null)
                specVersion = attr.getValue(Attributes.Name.SPECIFICATION_VERSION);
            if (specVendor == null)
                specVendor = attr.getValue(Attributes.Name.SPECIFICATION_VENDOR);
            if (implTitle == null)
                implTitle = attr.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
            if (implVersion == null)
                implVersion = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
            if (implVendor == null)
                implVendor = attr.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);
            if (sealed == null)
                sealed = attr.getValue(Attributes.Name.SEALED);
        }

        // package is sealed
        if ("true".equalsIgnoreCase(sealed))
            sealBase = url;
    }
    return definePackage(pn,
            specTitle,
            specVersion,
            specVendor,
            implTitle,
            implVersion,
            implVendor,
            sealBase);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:61,代碼來源:BuiltinClassLoader.java

示例13: updateDigests

import java.util.jar.Manifest; //導入方法依賴的package包/類
private boolean updateDigests(ZipEntry ze, ZipFile zf,
                              MessageDigest[] digests,
                              Manifest mf) throws IOException {
    boolean update = false;

    Attributes attrs = mf.getAttributes(ze.getName());
    String[] base64Digests = getDigests(ze, zf, digests);

    for (int i = 0; i < digests.length; i++) {
        // The entry name to be written into attrs
        String name = null;
        try {
            // Find if the digest already exists. An algorithm could have
            // different names. For example, last time it was SHA, and this
            // time it's SHA-1.
            AlgorithmId aid = AlgorithmId.get(digests[i].getAlgorithm());
            for (Object key : attrs.keySet()) {
                if (key instanceof Attributes.Name) {
                    String n = key.toString();
                    if (n.toUpperCase(Locale.ENGLISH).endsWith("-DIGEST")) {
                        String tmp = n.substring(0, n.length() - 7);
                        if (AlgorithmId.get(tmp).equals(aid)) {
                            name = n;
                            break;
                        }
                    }
                }
            }
        } catch (NoSuchAlgorithmException nsae) {
            // Ignored. Writing new digest entry.
        }

        if (name == null) {
            name = digests[i].getAlgorithm() + "-Digest";
            attrs.putValue(name, base64Digests[i]);
            update = true;
        } else {
            // compare digests, and replace the one in the manifest
            // if they are different
            String mfDigest = attrs.getValue(name);
            if (!mfDigest.equalsIgnoreCase(base64Digests[i])) {
                attrs.putValue(name, base64Digests[i]);
                update = true;
            }
        }
    }
    return update;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:49,代碼來源:JarSigner.java


注:本文中的java.util.jar.Manifest.getAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。