当前位置: 首页>>代码示例>>Java>>正文


Java JarPackageData.areGeneratedFilesExported方法代码示例

本文整理汇总了Java中org.eclipse.jdt.ui.jarpackager.JarPackageData.areGeneratedFilesExported方法的典型用法代码示例。如果您正苦于以下问题:Java JarPackageData.areGeneratedFilesExported方法的具体用法?Java JarPackageData.areGeneratedFilesExported怎么用?Java JarPackageData.areGeneratedFilesExported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.ui.jarpackager.JarPackageData的用法示例。


在下文中一共展示了JarPackageData.areGeneratedFilesExported方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readXML

import org.eclipse.jdt.ui.jarpackager.JarPackageData; //导入方法依赖的package包/类
public JarPackageData readXML(JarPackageData jarPackage) throws IOException, SAXException {
  	DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
   	factory.setValidating(false);
	DocumentBuilder parser= null;

	try {
		parser= factory.newDocumentBuilder();
	} catch (ParserConfigurationException ex) {
		throw new IOException(ex.getLocalizedMessage());
	} finally {
		// Note: Above code is OK since clients are responsible to close the stream
	}
	parser.setErrorHandler(new DefaultHandler());
	Element xmlJarDesc= parser.parse(new InputSource(fInputStream)).getDocumentElement();
	if (!xmlJarDesc.getNodeName().equals(JarPackagerUtil.DESCRIPTION_EXTENSION)) {
		throw new IOException(JarPackagerMessages.JarPackageReader_error_badFormat);
	}
	NodeList topLevelElements= xmlJarDesc.getChildNodes();
	for (int i= 0; i < topLevelElements.getLength(); i++) {
		Node node= topLevelElements.item(i);
		if (node.getNodeType() != Node.ELEMENT_NODE)
			continue;
		Element element= (Element)node;
		xmlReadJarLocation(jarPackage, element);
		xmlReadOptions(jarPackage, element);
		xmlReadRefactoring(jarPackage, element);
		xmlReadSelectedProjects(jarPackage, element);
		if (jarPackage.areGeneratedFilesExported())
			xmlReadManifest(jarPackage, element);
		xmlReadSelectedElements(jarPackage, element);
	}
	return jarPackage;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:JarPackageReader.java

示例2: writeXML

import org.eclipse.jdt.ui.jarpackager.JarPackageData; //导入方法依赖的package包/类
/**
 * Writes a XML representation of the JAR specification to to the underlying stream.
 * 
 * @param jarPackage the JAR package data
 * @exception IOException if writing to the underlying stream fails
 */
public void writeXML(JarPackageData jarPackage) throws IOException {
	Assert.isNotNull(jarPackage);
	DocumentBuilder docBuilder= null;
	DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
	factory.setValidating(false);
	try {
    	docBuilder= factory.newDocumentBuilder();
	} catch (ParserConfigurationException ex) {
		throw new IOException(JarPackagerMessages.JarWriter_error_couldNotGetXmlBuilder);
	}
	Document document= docBuilder.newDocument();

	// Create the document
	Element xmlJarDesc= document.createElement(JarPackagerUtil.DESCRIPTION_EXTENSION);
	document.appendChild(xmlJarDesc);
	xmlWriteJarLocation(jarPackage, document, xmlJarDesc);
	xmlWriteOptions(jarPackage, document, xmlJarDesc);
	xmlWriteRefactoring(jarPackage, document, xmlJarDesc);
	xmlWriteSelectedProjects(jarPackage, document, xmlJarDesc);
	if (jarPackage.areGeneratedFilesExported())
		xmlWriteManifest(jarPackage, document, xmlJarDesc);
	xmlWriteSelectedElements(jarPackage, document, xmlJarDesc);

	try {
		// Write the document to the stream
		Transformer transformer=TransformerFactory.newInstance().newTransformer();
		transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
		transformer.setOutputProperty(OutputKeys.ENCODING, fEncoding);
		transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
		transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","4"); //$NON-NLS-1$ //$NON-NLS-2$
		DOMSource source = new DOMSource(document);
		StreamResult result = new StreamResult(fOutputStream);
		transformer.transform(source, result);
	} catch (TransformerException e) {
		throw new IOException(JarPackagerMessages.JarWriter_error_couldNotTransformToXML);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:44,代码来源:JarPackageWriter.java


注:本文中的org.eclipse.jdt.ui.jarpackager.JarPackageData.areGeneratedFilesExported方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。