本文整理匯總了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();
}