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


Java Name類代碼示例

本文整理匯總了Java中java.util.jar.Attributes.Name的典型用法代碼示例。如果您正苦於以下問題:Java Name類的具體用法?Java Name怎麽用?Java Name使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: isPackageSealed

import java.util.jar.Attributes.Name; //導入依賴的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.Attributes.Name; //導入依賴的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: getClassPath

import java.util.jar.Attributes.Name; //導入依賴的package包/類
URL[] getClassPath() throws IOException {
    if (index != null) {
        return null;
    }

    if (metaIndex != null) {
        return null;
    }

    ensureOpen();
    parseExtensionsDependencies();
    if (SharedSecrets.javaUtilJarAccess().jarFileHasClassPathAttribute(jar)) { // Only get manifest when necessary
        Manifest man = jar.getManifest();
        if (man != null) {
            Attributes attr = man.getMainAttributes();
            if (attr != null) {
                String value = attr.getValue(Name.CLASS_PATH);
                if (value != null) {
                    return parseClassPath(csu, value);
                }
            }
        }
    }
    return null;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:26,代碼來源:URLClassPath.java

示例4: getClassPath

import java.util.jar.Attributes.Name; //導入依賴的package包/類
URL[] getClassPath() throws IOException {
    if (index != null) {
        return null;
    }

    if (metaIndex != null) {
        return null;
    }

    ensureOpen();
    parseExtensionsDependencies();

    if (SharedSecrets.javaUtilJarAccess().jarFileHasClassPathAttribute(jar)) { // Only get manifest when necessary
        Manifest man = jar.getManifest();
        if (man != null) {
            Attributes attr = man.getMainAttributes();
            if (attr != null) {
                String value = attr.getValue(Name.CLASS_PATH);
                if (value != null) {
                    return parseClassPath(csu, value);
                }
            }
        }
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:27,代碼來源:URLClassPath.java

示例5: isPackageSealed

import java.util.jar.Attributes.Name; //導入依賴的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

示例6: createAgent

import java.util.jar.Attributes.Name; //導入依賴的package包/類
public static File createAgent(Class<?> agent, Class<?>... resources) throws IOException {
    File jarFile = File.createTempFile("agent", ".jar");
    jarFile.deleteOnExit();
    Manifest manifest = new Manifest();
    Attributes mainAttributes = manifest.getMainAttributes();
    mainAttributes.put(Name.MANIFEST_VERSION, "1.0");
    mainAttributes.put(new Name("Agent-Class"), agent.getName());
    mainAttributes.put(new Name("Can-Retransform-Classes"), "true");
    mainAttributes.put(new Name("Can-Redefine-Classes"), "true");
    JarOutputStream jos = new JarOutputStream(new FileOutputStream(jarFile), manifest);
    jos.putNextEntry(new JarEntry(agent.getName().replace('.', '/') + ".class"));
    jos.write(getBytesFromStream(agent.getClassLoader().getResourceAsStream(unqualify(agent))));
    jos.closeEntry();
    for (Class<?> clazz : resources) {
        String name = unqualify(clazz);
        jos.putNextEntry(new JarEntry(name));
        jos.write(getBytesFromStream(clazz.getClassLoader().getResourceAsStream(name)));
        jos.closeEntry();
    }

    jos.close();
    return jarFile;
}
 
開發者ID:OmarAhmed04,項目名稱:Agent,代碼行數:24,代碼來源:Agent.java

示例7: getClassPath

import java.util.jar.Attributes.Name; //導入依賴的package包/類
@Override
URL[] getClassPath() throws IOException {
    if (index != null) {
        return null;
    }

    ensureOpen();

    // Only get manifest when necessary
    if (SharedSecrets.javaUtilJarAccess().jarFileHasClassPathAttribute(jar)) {
        Manifest man = jar.getManifest();
        if (man != null) {
            Attributes attr = man.getMainAttributes();
            if (attr != null) {
                String value = attr.getValue(Name.CLASS_PATH);
                if (value != null) {
                    return parseClassPath(csu, value);
                }
            }
        }
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:URLClassPath.java

示例8: isPackageSealed

import java.util.jar.Attributes.Name; //導入依賴的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

示例9: getClassPath

import java.util.jar.Attributes.Name; //導入依賴的package包/類
URL[] getClassPath() throws IOException {
    if (index != null) {
        return null;
    }

    ensureOpen();

    // Only get manifest when necessary
    if (SharedSecrets.javaUtilJarAccess().jarFileHasClassPathAttribute(jar)) {
        Manifest man = jar.getManifest();
        if (man != null) {
            Attributes attr = man.getMainAttributes();
            if (attr != null) {
                String value = attr.getValue(Name.CLASS_PATH);
                if (value != null) {
                    return parseClassPath(csu, value);
                }
            }
        }
    }
    return null;
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:23,代碼來源:URLClassPath.java

示例10: checkForSealedPackage

import java.util.jar.Attributes.Name; //導入依賴的package包/類
private void checkForSealedPackage(Package pkg, String packageName, Manifest manifest, URL jarFileURL) {
	if (pkg.isSealed() && !pkg.isSealed(jarFileURL))
		throw new SecurityException("The package '" + packageName + "' was previously loaded and is already sealed."); //$NON-NLS-1$ //$NON-NLS-2$

	String entryPath = packageName.replace('.', '/') + "/"; //$NON-NLS-1$
	Attributes entryAttributes = manifest.getAttributes(entryPath);
	String sealed = null;
	if (entryAttributes != null)
		sealed = entryAttributes.getValue(Name.SEALED);

	if (sealed == null) {
		Attributes mainAttributes = manifest.getMainAttributes();
		if (mainAttributes != null)
			sealed = mainAttributes.getValue(Name.SEALED);
	}
	if (Boolean.valueOf(sealed).booleanValue())
		throw new SecurityException("The package '" + packageName + "' was previously loaded unsealed. Cannot seal package."); //$NON-NLS-1$ //$NON-NLS-2$
}
 
開發者ID:openviglet,項目名稱:turing,代碼行數:19,代碼來源:CloseableURLClassLoader.java

示例11: readVersionInfo

import java.util.jar.Attributes.Name; //導入依賴的package包/類
/**
 * Pedantic method that requires the next attribute in the Manifest to be the
 * "Manifest-Version". This follows the Manifest spec closely but reject some
 * jar Manifest files out in the wild.
 */
private static void readVersionInfo(Attributes attr, BufferedReader br)
    throws IOException
{
  String version_header = Name.MANIFEST_VERSION.toString();
  try
    {
      String value = expectHeader(version_header, br);
      attr.putValue(MANIFEST_VERSION, value);
    }
  catch (IOException ioe)
    {
      throw new JarException("Manifest should start with a " + version_header
                             + ": " + ioe.getMessage());
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:21,代碼來源:JarUtils.java

示例12: printSection

import java.util.jar.Attributes.Name; //導入依賴的package包/類
private static void printSection(StringBuilder sb, Attributes attrs, int maxLineSize, Set<String> ignore) {
	Iterator<Entry<Object, Object>> it = attrs.entrySet().iterator();
	Entry<Object, Object> e;
	String name;
	String value;
	while(it.hasNext()){
		e = it.next();
		name=((Name)e.getKey()).toString();
		value=(String)e.getValue();
		if(StringUtil.isEmpty(value)) continue;
		//aprint.e("Export-Package:"+name+":"+("Export-Package".equals(name)));
		if("Import-Package".equals(name) || "Export-Package".equals(name) || "Require-Bundle".equals(name)) {
			value=splitByComma(value);
			
		}
		else if(value.length()>maxLineSize) value=split(value,maxLineSize);
		
		if(ignore!=null && ignore.contains(name)) continue;
		add(sb,name,value,null);
	}
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:22,代碼來源:ManifestUtil.java

示例13: logApplicationMetadata

import java.util.jar.Attributes.Name; //導入依賴的package包/類
/**
 * Method print all available information from the jar's manifest file. 
 */
private static void logApplicationMetadata() {
	LOG.trace("logApplicationMetadata()");
	InputStream manifestStream;
	String logMessage;
	//
	logMessage = "Application started";
	manifestStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/MANIFEST.MF");
	try {
		final Manifest manifest = new Manifest(manifestStream);
		final Attributes attributes = manifest.getMainAttributes();
		final Set<Object> keys = attributes.keySet();
		for (final Object object : keys) {
			if (object instanceof Name) {
				final Name key = (Name) object;
				logMessage += String.format("\n\t\t%s: %s",key,attributes.getValue(key));
			}
		}
		// add heap information
		logMessage += "\n\t\t" + heapSizeInformation();
	}
	catch(final IOException ex) {
		LOG.warn("Error while reading manifest file from application jar file: " + ex.getMessage());
	}
	LOG.info(logMessage);
}
 
開發者ID:52North,項目名稱:WeatherDataCollector,代碼行數:29,代碼來源:WeatherDataCollector.java

示例14: definePackage

import java.util.jar.Attributes.Name; //導入依賴的package包/類
/**
 * Reads attributes for the package and defines it.
 */
private Package definePackage(final String name,
                              final Resource res)
    throws FileSystemException
{
    // TODO - check for MANIFEST_ATTRIBUTES capability first
    final String specTitle = res.getPackageAttribute(Name.SPECIFICATION_TITLE);
    final String specVendor = res.getPackageAttribute(Attributes.Name.SPECIFICATION_VENDOR);
    final String specVersion = res.getPackageAttribute(Name.SPECIFICATION_VERSION);
    final String implTitle = res.getPackageAttribute(Name.IMPLEMENTATION_TITLE);
    final String implVendor = res.getPackageAttribute(Name.IMPLEMENTATION_VENDOR);
    final String implVersion = res.getPackageAttribute(Name.IMPLEMENTATION_VERSION);

    final URL sealBase;
    if (isSealed(res))
    {
        sealBase = res.getCodeSourceURL();
    }
    else
    {
        sealBase = null;
    }

    return definePackage(name, specTitle, specVersion, specVendor,
        implTitle, implVersion, implVendor, sealBase);
}
 
開發者ID:wso2,項目名稱:wso2-commons-vfs,代碼行數:29,代碼來源:VFSClassLoader.java

示例15: readMainClassAndFileNamesFromJar

import java.util.jar.Attributes.Name; //導入依賴的package包/類
String readMainClassAndFileNamesFromJar(File file, List<String> containedFileNames) throws IOException {
   JarFile jarFile = new JarFile(file);

   Manifest manifest = jarFile.getManifest();
   Attributes mainAttributes = manifest.getMainAttributes();
   String mainClassName = mainAttributes.getValue(Name.MAIN_CLASS);

   Enumeration<JarEntry> jarEntries = jarFile.entries();

   while (jarEntries.hasMoreElements()) {
      JarEntry jarEntry = jarEntries.nextElement();
      containedFileNames.add(jarEntry.getName());
   }

   return mainClassName;
}
 
開發者ID:jmockit,項目名稱:jmockit1,代碼行數:17,代碼來源:ClassLoadingAndJREMocksTest.java


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