本文整理汇总了Java中org.eclipse.emf.ecore.xmi.XMLResource.setEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java XMLResource.setEncoding方法的具体用法?Java XMLResource.setEncoding怎么用?Java XMLResource.setEncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.xmi.XMLResource
的用法示例。
在下文中一共展示了XMLResource.setEncoding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createResource
import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
/**
* Creates an instance of the resource. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public Resource createResource(URI uri) {
XMLResource result = new persistenceResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
result.setEncoding("UTF-8");
return result;
}
示例2: unmarshall
import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
public Graph unmarshall(final String content) throws IOException {
final XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://" + UUID.uuid() + ".xml"));
outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING,
"UTF-8");
outResource.setEncoding("UTF-8");
final Map<String, Object> options = new HashMap<String, Object>();
options.put(XMLResource.OPTION_ENCODING,
"UTF-8");
outResource.load(new BufferedInputStream(new ByteArrayInputStream(content.getBytes("UTF-8"))),
options);
final DocumentRoot root = (DocumentRoot) outResource.getContents().get(0);
final Definitions definitions = root.getDefinitions();
return unmarshall(definitions,
null);
}
示例3: 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();
}
示例4: parse
import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
protected Optional<Definitions> parse(FileUtils.ScanResult process) {
org.uberfire.java.nio.file.Path formPath = process.getFile();
try {
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put
(Resource.Factory.Registry.DEFAULT_EXTENSION,
new DroolsResourceFactoryImpl());
resourceSet.getPackageRegistry().put
(DroolsPackage.eNS_URI,
DroolsPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new Bpmn2ResourceFactoryImpl());
resourceSet.getPackageRegistry().put("http://www.omg.org/spec/BPMN/20100524/MODEL",
Bpmn2Package.eINSTANCE);
XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI(
"inputStream://dummyUriWithValidSuffix.xml"));
outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING,
"UTF-8");
outResource.setEncoding("UTF-8");
Map<String, Object> options = new HashMap<String, Object>();
options.put(XMLResource.OPTION_ENCODING,
"UTF-8");
outResource.load(ioService.newInputStream(formPath),
options);
DocumentRoot root = (DocumentRoot) outResource.getContents().get(0);
return Optional.of(root.getDefinitions());
} catch (Exception ex) {
logger.warn("Error reading process '" + process.getFile().getFileName(),
ex);
}
return Optional.empty();
}