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