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


Java XMLResourceFactoryImpl类代码示例

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

示例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();
	}
	
}
 
开发者ID:SOM-Research,项目名称:EMFtoCSP,代码行数:23,代码来源:EmfModelBuilder.java

示例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 );
  }
}
 
开发者ID:opitzconsulting,项目名称:orcas,代码行数:25,代码来源:ModelWriter.java

示例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 );
}
 
开发者ID:opitzconsulting,项目名称:orcas,代码行数:25,代码来源:XtextFileLoader.java

示例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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:14,代码来源:ChartActionBarContributor.java

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

示例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();
}
 
开发者ID:viatra,项目名称:java-refactoring-ttc-viatra,代码行数:8,代码来源:EMFBuilder.java

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

示例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);
		}
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:35,代码来源:EMFUtils.java

示例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);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:13,代码来源:EMFUtils.java

示例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);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:12,代码来源:EPlanElementImpl.java

示例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);
}
 
开发者ID:markus1978,项目名称:citygml4emf,代码行数:15,代码来源:LoadAModelMain.java

示例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);
	}
}
 
开发者ID:opensourceBIM,项目名称:BIMserver,代码行数:14,代码来源:Express2EMF.java

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

示例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));
	}	
}
 
开发者ID:markus1978,项目名称:clickwatch,代码行数:34,代码来源:XmlModelRepositoryTest.java


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