當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。