本文整理汇总了Java中org.eclipse.emf.ecore.xmi.XMLResource.save方法的典型用法代码示例。如果您正苦于以下问题:Java XMLResource.save方法的具体用法?Java XMLResource.save怎么用?Java XMLResource.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.xmi.XMLResource
的用法示例。
在下文中一共展示了XMLResource.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportNupnXMLAsText
import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
/**
* Returns the textual representation of a NUPN <toolspecific> model in XML.
* @param nupnModel the NUPN model to serialize
* @return the textual representation of its XML <toolspecific> construct.
* @throws IOException
*/
public static StringBuffer exportNupnXMLAsText(EObject nupnModel) throws IOException {
NupnResourceFactoryImpl npnrf = new NupnResourceFactoryImpl();
ResourceSet resSet = new ResourceSetImpl();
resSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put(Resource.Factory.Registry.DEFAULT_EXTENSION, npnrf);
// register your NupnPackage to the resource set so it has a reference
// to Nupn.ecore
NupnPackage ePackage = NupnPackage.eINSTANCE;
resSet.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
Resource resource = npnrf.createResource(URI.createFileURI(PNML_NS_URI));
XMLResource nupnRes = (XMLResource)resource;
nupnRes.getContents().add(nupnModel);
StringWriter sw = new StringWriter();
nupnRes.save(sw, nupnRes.getDefaultSaveOptions());
return sw.getBuffer();
}
示例2: serialize
import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
private String serialize(Marketplace rootElement) throws IOException {
Map<String, Object> saveOptions = new HashMap<String, Object>();
saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
// UTF-8 encoding is required per specification
saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8");
XMLResource resource = new XMLResourceImpl();
resource.getContents().add(rootElement);
StringWriter stringWriter = new StringWriter();
resource.save(new URIConverter.WriteableOutputStream(stringWriter, resource.getEncoding()), saveOptions);
return stringWriter.getBuffer().toString();
}
示例3: serialize
import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
public static String serialize(Node rootElement) throws IOException {
Map<String, Object> saveOptions = new HashMap<String, Object>();
saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8");
XMLResource resource = new XMLResourceImpl();
resource.getContents().add(rootElement);
StringWriter stringWriter = new StringWriter();
resource.save(new URIConverter.WriteableOutputStream(stringWriter, resource.getEncoding()), saveOptions);
return stringWriter.getBuffer().toString();
}
示例4: export
import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
public String export(String id) throws Exception {
this.createHeader(id);
ResourceFactoryImpl resourceFactory = new XMLPersistenceMappingResourceFactoryImpl();
URI emfURI = URI.createURI("http://kay-muench.de", true);
XMLResource resource = (XMLResource) resourceFactory
.createResource(emfURI);
resource.setEncoding("UTF-8");
resource.getContents().add(getReqIF());
OutputStream os = new ByteArrayOutputStream();
resource.save(os, null);
return os.toString();
}