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


Java XMIResourceImpl类代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl的典型用法代码示例。如果您正苦于以下问题:Java XMIResourceImpl类的具体用法?Java XMIResourceImpl怎么用?Java XMIResourceImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XMIResourceImpl类属于org.eclipse.emf.ecore.xmi.impl包,在下文中一共展示了XMIResourceImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createService

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
@Override
protected Entry<ComponentFactory> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception
{
    final ConfigurationDataHelper cfg = new ConfigurationDataHelper ( parameters );
    final String xml = cfg.getStringNonEmpty ( "configuration" );

    final XMIResource xmi = new XMIResourceImpl ();
    final Map<?, ?> options = new HashMap<Object, Object> ();
    final InputSource is = new InputSource ( new StringReader ( xml ) );
    xmi.load ( is, options );

    final Object c = EcoreUtil.getObjectByType ( xmi.getContents (), ParserPackage.Literals.COMPONENT );
    if ( ! ( c instanceof Component ) )
    {
        throw new RuntimeException ( String.format ( "Configuration did not contain an object of type %s", Component.class.getName () ) );
    }

    final ComponentFactoryWrapper wrapper = new ComponentFactoryWrapper ( this.executor, (Component)c );

    final Dictionary<String, ?> properties = new Hashtable<> ();
    final ServiceRegistration<ComponentFactory> handle = context.registerService ( ComponentFactory.class, wrapper, properties );

    return new Entry<ComponentFactory> ( configurationId, wrapper, handle );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:FactoryImpl.java

示例2: testNestedPackage

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
@Test public void testNestedPackage() throws Exception {
	Resource resource = new XMIResourceImpl();
	EPackage parent = EcoreFactory.eINSTANCE.createEPackage();
	parent.setName("parent");
	parent.setNsURI("http://parent");
	EPackage child = EcoreFactory.eINSTANCE.createEPackage();
	child.setName("child");
	child.setNsURI("http://child");
	EClass eClass = EcoreFactory.eINSTANCE.createEClass();
	eClass.setName("Test");
	child.getEClassifiers().add(eClass);
	parent.getESubpackages().add(child);
	resource.getContents().add(parent);
	Map<QualifiedName, IEObjectDescription> index = createIndex(resource);
	checkEntry(index, parent, false, "parent");
	checkEntry(index, child, false, "parent", "child");
	checkEntry(index, eClass, false, "parent", "child", "Test");
	checkEntry(index, parent, true, "http://parent");
	checkEntry(index, child, true, "http://child");
	checkEntry(index, eClass, true, "http://child", "Test");
	assertEquals(6,index.size());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:EcoreResourceDescriptionManagerTest.java

示例3: testMissingMiddleName

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
@Test public void testMissingMiddleName() {
	Resource resource = new XMIResourceImpl();
	EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
	ePackage.setName("test");
	ePackage.setNsURI("http://test");
	EClass unnamedEClass = EcoreFactory.eINSTANCE.createEClass();
	EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute();
	eAttribute.setName("test");
	unnamedEClass.getEStructuralFeatures().add(eAttribute);
	ePackage.getEClassifiers().add(unnamedEClass);
	resource.getContents().add(ePackage);
	Map<QualifiedName, IEObjectDescription> index = createIndex(resource);
	checkEntry(index, ePackage, false, "test");
	checkEntry(index, ePackage, true, "http://test");
	assertEquals(2,index.size());
	
	unnamedEClass.setName("Test");
	index = createIndex(resource);
	checkEntry(index, ePackage, false, "test");
	checkEntry(index, ePackage, true, "http://test");
	checkEntry(index, unnamedEClass, false, "test", "Test");
	checkEntry(index, unnamedEClass, true, "http://test", "Test");
	checkEntry(index, eAttribute, false, "test", "Test", "test");
	checkEntry(index, eAttribute, true, "http://test", "Test", "test");
	assertEquals(6,index.size());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:EcoreResourceDescriptionManagerTest.java

示例4: beforeClass

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws CoreException, IOException {
	final NullProgressMonitor monitor = new NullProgressMonitor();

	final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("TestProject");
	project.create(monitor);
	project.open(monitor);

	final IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(
			"TestProject/TestFolder"));
	folder.create(true, true, monitor);

	final Resource resource = new XMIResourceImpl(URI.createPlatformResourceURI(
			"TestProject/TestFolder/TestFile.xmi", true));
	resource.getContents().add(EcorePackage.eINSTANCE.getEcoreFactory().createEClass());
	resource.getContents().add(EcorePackage.eINSTANCE.getEcoreFactory().createEClass());
	resource.getContents().add(EcorePackage.eINSTANCE.getEcoreFactory().createEClass());
	resource.save(null);
}
 
开发者ID:ModelWriter,项目名称:Source,代码行数:20,代码来源:EObjectFileConnectorDelegateTests.java

示例5: getContainerEObject

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
@Test
public void getContainerEObject() throws IOException, CoreException {
	final EObjectContainerProvider provider = new EObjectContainerProvider();

	final EObject element = MappingPackage.eINSTANCE.getMappingFactory().createBase();
	final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
			EObjectContainerProviderTests.class.getCanonicalName());
	project.create(new NullProgressMonitor());
	project.open(new NullProgressMonitor());
	final IFile file = project.getFile(new Path("test.xmi"));

	final Resource resource = new XMIResourceImpl(URI.createPlatformResourceURI(file.getFullPath()
			.toString(), true));
	resource.getContents().add(element);
	resource.save(null);
	final Object result = provider.getContainer(element);

	assertEquals(file, result);
}
 
开发者ID:ModelWriter,项目名称:Source,代码行数:20,代码来源:EObjectContainerProviderTests.java

示例6: updateSavedURIFragment

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
/**
 * Updates {@link IEObjectLocation#getSavedURIFragment() saved URI fragment}.
 * 
 * @param container
 *            the {@link ILocationContainer}
 * @param eObjectContainer
 *            the {@link IEObjectContainer}
 * @param newResource
 *            the new {@link Resource}
 * @throws Exception
 *             if the XMI serialization failed or elements couldn't be created
 */
private static void updateSavedURIFragment(ILocationContainer container,
		IEObjectContainer eObjectContainer, Resource newResource) throws Exception {
	final IBase base = MappingUtils.getBase(container);

	final Copier copier = new Copier();
	final Collection<EObject> copiedContents = copier.copyAll(newResource.getContents());
	copier.copyReferences();
	final XMIResourceImpl newXMIResource = new XMIResourceImpl();
	newXMIResource.getContents().addAll(copiedContents);

	for (Entry<EObject, EObject> entry : copier.entrySet()) {
		final EObject newEObject = entry.getKey();
		final EObject savedEObject = entry.getValue();
		final ICouple couple = base.getFactory().createElement(ICouple.class);
		couple.setKey(newResource.getURIFragment(newEObject));
		couple.setValue(newXMIResource.getURIFragment(savedEObject));
		eObjectContainer.getSavedURIFragments().add(couple);
	}
}
 
开发者ID:ModelWriter,项目名称:Source,代码行数:32,代码来源:EObjectConnector.java

示例7: testParsingOnLoad

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
@Test
public void testParsingOnLoad() throws Exception {
	File tmpFile = File.createTempFile("SCTResource", "test.test");
	tmpFile.deleteOnExit();
	URI uri = URI.createFileURI(tmpFile.getPath().toString());
	Resource resource = new XMIResourceImpl(uri);
	Statechart statechart = createStatechart("internal: event Event1");
	resource.getContents().add(statechart);
	Transition transition = createTransition("Event1 [true] / 3 * 3");
	resource.getContents().add(transition);
	resource.save(Collections.EMPTY_MAP);

	res.setURI(uri);
	res.load(Collections.EMPTY_MAP);
	statechart = (Statechart) res.getContents().get(0);
	transition = (Transition) res.getContents().get(1);

	assertEquals("" + res.getErrors(), 0, res.getErrors().size());
	ReactionTrigger trigger = (ReactionTrigger) transition.getTrigger();
	RegularEventSpec eventSpec = (RegularEventSpec) trigger.getTriggers().get(0);
	ElementReferenceExpression expression = (ElementReferenceExpression) eventSpec.getEvent();
	EventDefinition reference = (EventDefinition) expression.getReference();
	assertNotNull(reference);
	assertEquals("Event1", reference.getName());
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:26,代码来源:SCTResourceTest.java

示例8: xmi2NativeArduino

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
private static String xmi2NativeArduino(String xmiPath) throws IOException{
       // register ArduinoML
	ResourceSet resourceSet = new ResourceSetImpl();
    Map<String, Object> packageRegistry = resourceSet.getPackageRegistry();
       packageRegistry.put(arduinoML.ArduinoMLPackage.eNS_URI, arduinoML.ArduinoMLPackage.eINSTANCE);
	
       // load the xmi file
	XMIResource resource = new XMIResourceImpl(URI.createURI("file:"+xmiPath));
	resource.load(null);
	
	// get the root of the model
	App app = (App) resource.getContents().get(0);
	
	// Launch the visitor on the root
	ArduinoMLSwitchPrinter visitor = new ArduinoMLSwitchPrinter();
	return visitor.doSwitch(app);
}
 
开发者ID:mosser,项目名称:ArduinoML-kernel,代码行数:18,代码来源:Main.java

示例9: execute

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if ( editor instanceof AtlEditorExt ) {
		AtlEditorExt atlEditor = (AtlEditorExt) editor;
		IFile file = (IFile) atlEditor.getUnderlyingResource();
		
		AnalysisResult r = AnalysisIndex.getInstance().getAnalysis(file);

		for (MetamodelNamespace ns : r.getNamespace().getMetamodels()) {
			MetamodelPrunner prunner = new MetamodelPrunner(r.getATLModel(), ns);
			
			XMIResourceImpl res = new XMIResourceImpl();
			prunner.extractSource(res, ns.getName(), ns.getName() + "/prunned", ns.getName());
			try {
				res.save(new FileOutputStream(file.getLocation().removeLastSegments(1).append(ns.getName() + ".ecore").toOSString()), null);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}
	
	return null;
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:27,代码来源:SliceTransformationMetmodelsHandler.java

示例10: createGenModel

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
public static void createGenModel(final EPackage rootPackage, final IPath ecorePath, final IResource genmodelResource) {

		GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
		genModel.setComplianceLevel(GenJDKLevel.JDK60_LITERAL);
		genModel.setModelDirectory(ecorePath.removeLastSegments(1).toString());
		genModel.getForeignModel().add(ecorePath.lastSegment());
		genModel.setModelName(rootPackage.getName());
		genModel.setRootExtendsInterface("");
		genModel.initialize(Collections.singleton(rootPackage));

		GenPackage genPackage = (GenPackage) genModel.getGenPackages().get(0);
		genPackage.setPrefix("");

		try {
			URI genModelURI = URI.createURI(genmodelResource.getLocationURI().toString());
			final XMIResourceImpl genModelResource = new XMIResourceImpl(genModelURI);
			genModelResource.getContents().add(genModel);
			genModelResource.save(Collections.EMPTY_MAP);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:23,代码来源:MACLModelUtils.java

示例11: saveModel

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
private void saveModel(List<Package> pkgs) throws IOException {

        // Create a resource-set to contain the resource(s) that we are saving
        ResourceSet resourceSet = new ResourceSetImpl();

        // Initialize registrations of resource factories, library models,
        // profiles, Ecore metadata, and other dependencies required for
        // serializing and working with UML resources. This is only necessary in
        // applications that are not hosted in the Eclipse platform run-time, in
        // which case these registrations are discovered automatically from
        // Eclipse extension points.
        UMLResourcesUtil.init(resourceSet);

        // Create the output resource and add our model package to it.
//        Resource resource = resourceSet.createResource(uri);
        Resource resource = new XMIResourceImpl();
        for (Package pkg : pkgs) {
            resource.getContents().add(pkg);
        }

        // And save.
        Map<?, ?> options = null;   // No save options needed.
        resource.save(outputStream, options);
        outputStream.close();
    }
 
开发者ID:Apelon-VA,项目名称:ISAAC,代码行数:26,代码来源:FHIMExporter.java

示例12: getNewEMFResource

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
/**
 * Used by updateEMFResource and emfResourceChanged to load the new resource.
 * 
 * @return new Resource.
 */
private Resource getNewEMFResource() {
	if (resource == null) {
		getEMFResource();
	}
	Diagram d = getDiagramTypeProvider().getDiagram();

	URI uri = d.eResource().getURI();
	uri = uri.trimFragment();
	uri = uri.trimFileExtension();
	uri = uri.appendFileExtension(BLOCKS_FILE_EXTENSION);

	Resource newResource = new XMIResourceImpl(uri);
	try {
		newResource.load(null);
	} catch (IOException e) {
		e.printStackTrace();
	}
	return newResource;
}
 
开发者ID:DesignAndDeploy,项目名称:dnd,代码行数:25,代码来源:FeatureProvider.java

示例13: loadInput

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
/**
 * Loads the given data flow graph. The file given in the editor input must be a valid graph. Its function block
 * models are loaded into a list and returned.
 * 
 * @param input
 *            the input of the editor
 * @return a collection of FunctionBlockModels that were defined in the model
 * @throws IOException
 *             if reading fails
 */
private Collection<FunctionBlockModel> loadInput(final FileEditorInput input) throws IOException {
	LOGGER.entry(input);
	Collection<FunctionBlockModel> blockModelList = new ArrayList<FunctionBlockModel>();
	graphicsManager.setAppName(input.getFile().getName()
			.replaceAll("\\.blocks", Messages.DEPLOYGRAPHICS_EMPTYSTRING)); //$NON-NLS-1$ //$NON-NLS-2$

	URI uri = URI.createURI(input.getURI().toASCIIString());
	resource = new XMIResourceImpl(uri);
	resource.setTrackingModification(true);
	resource.load(null);
	for (EObject object : resource.getContents()) {
		if (object instanceof FunctionBlockModel) {
			LOGGER.trace("found FunctionBlockModel {}", object); //$NON-NLS-1$
			FunctionBlockModel blockmodel = (FunctionBlockModel) object;
			blockModelList.add(blockmodel);
		}
	}
	return blockModelList;
}
 
开发者ID:DesignAndDeploy,项目名称:dnd,代码行数:30,代码来源:DeployEditor.java

示例14: loadBlocks

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
public void loadBlocks() {
	Collection<FunctionBlockModel> functionBlocks = new ArrayList<FunctionBlockModel>();

	ModelFactory.eINSTANCE.eClass();

	URI uri = URI.createURI(new File(path).toURI().toASCIIString());

	Resource resource = new XMIResourceImpl(uri);

	try {
		resource.load(null);
	} catch (IOException e) {
		System.out.println("Loading blocks failed.");
		e.printStackTrace();
	}
	for (EObject object : resource.getContents()) {
		if (object instanceof FunctionBlockModel) {
			FunctionBlockModel blockmodel = (FunctionBlockModel) object;
			functionBlocks.add(blockmodel);
			System.out.println(blockmodel.getBlockName());
		}
	}
	blocks = functionBlocks;
}
 
开发者ID:DesignAndDeploy,项目名称:dnd,代码行数:25,代码来源:FunctionBlockLoader.java

示例15: getResource

import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入依赖的package包/类
private <T extends QObjectNameable> Resource getResource(String repository, Class<T> klass) {

		String resourceKey = repository+"/"+klass.getName();
		
		Resource resource = resources.get(resourceKey);
		if(resource == null) {
			XMIResourceImpl xmiResource = (XMIResourceImpl) resourceSet.createResource(URI.createURI(basePath+repository+"/"+klass.getSimpleName()+".xmi"));
			xmiResource.setEncoding("UTF-8");
			resource = xmiResource;
			try {
				resource.load(Collections.EMPTY_MAP);
			} catch (IOException e) {			
				// first load
				try {
					resource.save(Collections.EMPTY_MAP);
				} catch (IOException e1) {
					throw new OperatingSystemRuntimeException(e);
				}
			}
			resources.put(resourceKey, resource);
		}
		return resource;
	}
 
开发者ID:asupdev,项目名称:asup,代码行数:24,代码来源:E4ResourceProviderImpl.java


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