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


Java XMLResource.setEncoding方法代码示例

本文整理汇总了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;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:24,代码来源:persistenceResourceFactoryImpl.java

示例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);
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:19,代码来源:Bpmn2UnMarshaller.java

示例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();
}
 
开发者ID:KayErikMuench,项目名称:reqiftools,代码行数:16,代码来源:ReqIF10Compiler.java

示例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();
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:40,代码来源:BPMFinderServiceImpl.java


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