本文整理汇总了Java中org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl类的典型用法代码示例。如果您正苦于以下问题:Java XMLResourceFactoryImpl类的具体用法?Java XMLResourceFactoryImpl怎么用?Java XMLResourceFactoryImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XMLResourceFactoryImpl类属于org.eclipse.emf.ecore.xmi.impl包,在下文中一共展示了XMLResourceFactoryImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveResources
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public static void saveResources(final List<EObject> root, final URI uri) {
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMLResourceFactoryImpl());
final Resource resource = resourceSet.createResource(uri);
resource.getContents().addAll(root);
final Map options = new HashMap();
options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
try {
resource.save(options);
} catch (final IOException e) {
e.printStackTrace();
}
}
示例2: serializeInstance
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
private void serializeInstance(String fileName, Map<String, Boolean> options) {
ResourceSet rscSet = new ResourceSetImpl();
EPackage topPck= (EPackage) modelReader.getResource().getContents().get(0);
rscSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
"xmi", new XMLResourceFactoryImpl());
EPackage.Registry.INSTANCE.put(topPck.getNsURI(), topPck);
fileName+=".xmi";
Resource resource = rscSet.createResource(URI.createURI(fileName));
Iterator<EObject> objIt = objList.iterator();
while (objIt.hasNext()) {
EObject obj = objIt.next();
if (isRoot(obj))
resource.getContents().add(obj);
}
try{
resource.save(options);
}catch (IOException e) {
e.printStackTrace();
}
}
示例3: getSkriptXml
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
public static String getSkriptXml( Model pModel )
{
Resource.Factory.Registry lRegistry = Resource.Factory.Registry.INSTANCE;
Map<String,Object> lMap = lRegistry.getExtensionToFactoryMap();
lMap.put( "xml", new XMLResourceFactoryImpl() );
ResourceSet lResourceSet = new ResourceSetImpl();
Resource lResource = lResourceSet.createResource( URI.createFileURI( "*.xml" ) );
((XMLResource)lResource).getDefaultSaveOptions();
lResource.getContents().add( pModel );
try
{
ByteArrayOutputStream lByteArrayOutputStream = new ByteArrayOutputStream();
lResource.save( lByteArrayOutputStream, Collections.EMPTY_MAP );
return new String( lByteArrayOutputStream.toByteArray() );
}
catch( IOException e )
{
throw new RuntimeException( e );
}
}
示例4: loadModelXml
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
@SuppressWarnings( "unchecked" )
public T loadModelXml( String pFilename, String pNamespaceUri, EPackage pEPackage )
{
EPackage.Registry.INSTANCE.put( pNamespaceUri, pEPackage );
Resource.Factory.Registry lRegistry = Resource.Factory.Registry.INSTANCE;
Map<String, Object> lMap = lRegistry.getExtensionToFactoryMap();
lMap.put( "xml", new XMLResourceFactoryImpl() );
ResourceSet lResourceSet = new ResourceSetImpl();
Resource lResource = lResourceSet.createResource( URI.createFileURI( pFilename ) );
((XMLResource) lResource).getDefaultSaveOptions();
try
{
lResource.load( Collections.EMPTY_MAP );
}
catch( IOException e )
{
throw new RuntimeException( e );
}
return (T) lResource.getContents().get( 0 );
}
示例5: doSave
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
private void doSave ( final String file ) throws IOException
{
final ResourceSet rs = new ResourceSetImpl ();
rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMLResourceFactoryImpl () ); //$NON-NLS-1$
final URI fileUri = URI.createFileURI ( file );
final Resource resource = rs.createResource ( fileUri );
resource.getContents ().add ( this.chart );
final Map<Object, Object> options = new HashMap<Object, Object> ();
// options.put ( XMIResource., value )
resource.save ( options );
}
示例6: ResourceManager
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
/**
* Create the resource manager.
*/
public ResourceManager(EPackage... packageInstances)
{
setResourceSet(createResourceSet());
// register factories
Resource.Factory.Registry.INSTANCE
.getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl());
// Add them to the resourceSet
for (EPackage p : packageInstances)
resourceSet.getPackageRegistry().put(p.getNsURI(), p);
}
示例7: EMFBuilder
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
public EMFBuilder() {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("typegraphbasic", new XMLResourceFactoryImpl());
resourceSet = new ResourceSetImpl();
TypeGraphBasicPackage.eINSTANCE.eClass();
TypeGraphTracePackage.eINSTANCE.eClass();
}
示例8: registerResourceFactories
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
/**
* @generated NOT
*/
@Override
public void registerResourceFactories(ResourceSet resourceSet) {
System.out.println("@MyGenerator::registerResourceFactories");
super.registerResourceFactories(resourceSet);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
"xmi",
new org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
"ecore",
new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
IAcceleoConstants.EMTL_FILE_EXTENSION,
new EMtlResourceFactoryImpl());
if (QWT_SUPPORT_ENABLED){
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ui",
new Qt48XmlschemaQwtEnhancedResourceFactoryImpl());
}
else{
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ui",
new Qt48XmlschemaResourceFactoryImpl());
}
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xsd",
new XMLResourceFactoryImpl());
}
示例9: convertToXML
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
public static String convertToXML(EObject eObject, Map<String, Object> options) {
List<? extends EObject> contents = Collections.singletonList(eObject);
options.put(XMLResource.OPTION_ROOT_OBJECTS, contents);
boolean temporaryResource = false;
Resource resource = eObject.eResource();
EObject eRoot = null;
if (resource == null || !(resource instanceof XMLResource)) {
ResourceSet resourceSet = createResourceSet();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMLResourceFactoryImpl());
resource = resourceSet.createResource(URI.createURI(""));
temporaryResource = true;
eRoot = EcoreUtil.getRootContainer(eObject);
resource.getContents().add(eRoot);
}
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
resource.save(stream, options);
String string;
if (options.get(XMLResource.OPTION_ENCODING) != null) {
string = stream.toString(options.get(XMLResource.OPTION_ENCODING).toString());
} else {
string = stream.toString();
}
return string;
} catch (IOException e) {
throw new IllegalStateException("Error converting " + eObject + " to string", e);
}
} finally {
if (temporaryResource) {
resource.getContents().remove(eRoot);
}
}
}
示例10: createFromXML
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
public static EObject createFromXML(String xml) {
ResourceSet resourceSet = createResourceSet();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMLResourceFactoryImpl());
Resource resource = resourceSet.createResource(URI.createURI("createFromString.xml"));
InputStream stream = new ByteArrayInputStream(xml.getBytes());
try {
resource.load(stream, null);
} catch (IOException e) {
throw new IllegalStateException("Error creating EObject from string " + xml, e);
}
return resource.getContents().remove(0);
}
示例11: readExternal
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
ResourceSet resourceSet = EMFUtils.createResourceSet();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMLResourceFactoryImpl());
String string = (String)in.readObject();
ByteArrayInputStream stream = new ByteArrayInputStream(string.getBytes());
Resource resource = resourceSet.createResource(URI.createURI("EPlanElementImpl_readExternal.xmi"));
resource.load(stream, null);
EList<EObject> contents = resource.getContents();
@SuppressWarnings("unused")
EObject newThis = contents.get(0);
}
示例12: run
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
public void run() {
EPackage.Registry.INSTANCE.put(CitygmlPackage.eINSTANCE.getNsURI(), CitygmlPackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(EcorePackage.eINSTANCE.getNsURI(), EcorePackage.eINSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("gml", new XMLResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
Map<String, Object> saveOptions = new HashMap<String, Object>();
saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
rs.getLoadOptions().putAll(saveOptions);
rs.getResource(URI.createURI("models/waldbruecke_v1.0.0.gml"), true);
}
示例13: writeEMF
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
public void writeEMF(String fileName) {
ResourceSet metaResourceSet = new ResourceSetImpl();
metaResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMLResourceFactoryImpl());
URI resUri = URI.createURI(fileName);
Resource metaResource = metaResourceSet.createResource(resUri);
metaResource.getContents().add(schemaPack);
try {
metaResource.save(null);
} catch (Exception e) {
LOGGER.error("", e);
}
}
示例14: writeEMF
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
public void writeEMF(String fileName) {
ResourceSet metaResourceSet = new ResourceSetImpl();
metaResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMLResourceFactoryImpl());
URI resUri = URI.createURI(fileName);
Resource metaResource = metaResourceSet.createResource(resUri);
metaResource.getContents().add(ePackage);
try {
metaResource.save(null);
} catch (Exception e) {
e.printStackTrace();
}
}
示例15: testBasicXDS
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; //导入依赖的package包/类
@Test
public void testBasicXDS() {
Collection<EObject> xsd = new XSDEcoreBuilder().generate(URI.createFileURI(LINK_STAT_XSD));
Collection<EPackage> xsdPackages = Collections2.transform(xsd, new Function<EObject, EPackage>() {
@Override
public EPackage apply(EObject input) {
return (EPackage)input;
}
});
final ResourceSet rs = new ResourceSetImpl();
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl());
for (EPackage ePackage: xsdPackages) {
rs.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
}
Resource xmlResource = rs.createResource(URI.createFileURI(LINK_STAT_XML));
Map<String, Object> options = new HashMap<String, Object>();
options.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
options.put(XMLResource.OPTION_ENCODING, "UTF-8");
try {
xmlResource.load(options);
} catch (IOException e) {
e.printStackTrace();
}
EObject model = xmlResource.getContents().get(0);
Iterator<EObject> it = model.eAllContents();
while (it.hasNext()) {
assertTrue(! (it.next() instanceof AnyType));
}
}