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


Java ResourceImpl类代码示例

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


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

示例1: testFindFeaturesByName_03

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
@Test public void testFindFeaturesByName_03() {
	JvmDeclaredType type = getObjectUnderTest();
	JvmGenericType superType = TypesFactory.eINSTANCE.createJvmGenericType();
	ResourceImpl resource = new ResourceImpl();
	resource.getContents().add(type);
	resource.getContents().add(superType);
	JvmOperation operation = TypesFactory.eINSTANCE.createJvmOperation();
	operation.setSimpleName("foo");
	superType.getMembers().add(operation);
	JvmParameterizedTypeReference reference = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
	reference.setType(superType);
	type.getSuperTypes().add(reference);
	Iterable<JvmFeature> iterable = type.findAllFeaturesByName("foo");
	Iterator<JvmFeature> iterator = iterable.iterator();
	assertTrue(iterator.hasNext());
	assertSame(operation, iterator.next());
	assertFalse(iterator.hasNext());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:JvmDeclaredTypeTest.java

示例2: testFindFeaturesByName_04

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
@Test public void testFindFeaturesByName_04() {
	JvmDeclaredType type = getObjectUnderTest();
	JvmGenericType superType = TypesFactory.eINSTANCE.createJvmGenericType();
	ResourceImpl resource = new ResourceImpl();
	resource.getContents().add(type);
	resource.getContents().add(superType);
	JvmOperation operation = TypesFactory.eINSTANCE.createJvmOperation();
	operation.setSimpleName("foo");
	superType.getMembers().add(operation);
	JvmParameterizedTypeReference reference = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
	reference.setType(superType);
	type.getSuperTypes().add(reference);
	type.findAllFeaturesByName("foo");
	operation.setSimpleName("bar");
	Iterable<JvmFeature> iterable = type.findAllFeaturesByName("bar");
	Iterator<JvmFeature> iterator = iterable.iterator();
	assertTrue(iterator.hasNext());
	assertSame(operation, iterator.next());
	assertFalse(iterator.hasNext());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:JvmDeclaredTypeTest.java

示例3: testGetAllFeatures_03

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
@Test public void testGetAllFeatures_03() {
	JvmDeclaredType type = getObjectUnderTest();
	JvmGenericType superType = TypesFactory.eINSTANCE.createJvmGenericType();
	ResourceImpl resource = new ResourceImpl();
	resource.getContents().add(type);
	resource.getContents().add(superType);
	JvmOperation operation = TypesFactory.eINSTANCE.createJvmOperation();
	superType.getMembers().add(operation);
	JvmParameterizedTypeReference reference = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
	reference.setType(superType);
	type.getSuperTypes().add(reference);
	Iterable<JvmFeature> iterable = type.getAllFeatures();
	Iterator<JvmFeature> iterator = iterable.iterator();
	assertTrue(iterator.hasNext());
	assertSame(operation, iterator.next());
	assertFalse(iterator.hasNext());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:JvmDeclaredTypeTest.java

示例4: testGetAllFeatures_04

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
@Test public void testGetAllFeatures_04() {
	JvmDeclaredType type = getObjectUnderTest();
	JvmGenericType superType = TypesFactory.eINSTANCE.createJvmGenericType();
	ResourceImpl resource = new ResourceImpl();
	resource.getContents().add(type);
	resource.getContents().add(superType);
	type.getAllFeatures();
	JvmOperation operation = TypesFactory.eINSTANCE.createJvmOperation();
	superType.getMembers().add(operation);
	JvmParameterizedTypeReference reference = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
	reference.setType(superType);
	type.getSuperTypes().add(reference);
	Iterable<JvmFeature> iterable = type.getAllFeatures();
	Iterator<JvmFeature> iterator = iterable.iterator();
	assertTrue(iterator.hasNext());
	assertSame(operation, iterator.next());
	assertFalse(iterator.hasNext());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:JvmDeclaredTypeTest.java

示例5: setUp

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	EObject copy = EcoreUtil.copy(EcorePackage.eINSTANCE);
	resource = new ResourceImpl();
	resource.getContents().add(copy);
	IQualifiedNameProvider nameProvider = new IQualifiedNameProvider.AbstractImpl() {
		@Override
		public QualifiedName getFullyQualifiedName(EObject obj) {
			if (obj instanceof ENamedElement)
				return QualifiedName.create(((ENamedElement) obj).getName());
			return null;
		}
	};
	DefaultResourceDescriptionStrategy descriptionStrategy = new DefaultResourceDescriptionStrategy();
	descriptionStrategy.setQualifiedNameProvider(nameProvider);
	resourceDescription = new DefaultResourceDescription(resource, descriptionStrategy) {
		@Override
		public Iterable<QualifiedName> getImportedNames() {
			return importedNames;
		}
	};
	manager = new DefaultResourceDescriptionManager();
	importedNames = Collections.emptySet();
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:DefaultResourceDescriptionManagerTest.java

示例6: testPathFragment

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
@Test public void testPathFragment() {
	EClass foo = EcoreFactory.eINSTANCE.createEClass();
	foo.setName("foo");
	EClass bar = EcoreFactory.eINSTANCE.createEClass();
	foo.setName("bar");
	EPackage p = EcoreFactory.eINSTANCE.createEPackage();
	bar.setName("p");
	p.getEClassifiers().add(foo);
	p.getEClassifiers().add(bar);
	
	assertEquals("/-1", EcoreUtil2.getFragmentPath(foo));
	assertEquals("/-1", EcoreUtil2.getFragmentPath(bar));
	assertEquals("/-1", EcoreUtil2.getFragmentPath(p));
	Resource resource = new ResourceImpl(URI.createURI("platform:/resource/res"));
	resource.getContents().add(p);
	assertEquals(URI.createURI("platform:/resource/res#//@eClassifiers.0"), EcoreUtil2.getFragmentPathURI(foo));
	assertEquals(URI.createURI("platform:/resource/res#//@eClassifiers.1"), EcoreUtil2.getFragmentPathURI(bar));
	assertEquals(URI.createURI("platform:/resource/res#/"), EcoreUtil2.getFragmentPathURI(p));
	assertEquals(resource.getEObject("//@eClassifiers.0"), foo);
	assertEquals(resource.getEObject("//@eClassifiers.1"), bar);
	assertEquals(resource.getEObject("/"), p);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:EcoreUtil2Test.java

示例7: testAdapterIsCleared

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
@Test public void testAdapterIsCleared() throws Exception {
	EcoreFactory factory = EcoreFactory.eINSTANCE;
	EClass eClass = factory.createEClass();
	Resource resource = new ResourceImpl();
	resource.getContents().add(eClass);
	CacheAdapter ca = new OnChangeEvictingCache().getOrCreate(resource);
	setValue(ca);
	EAttribute attribute = factory.createEAttribute();
	assertIsSet(ca);
	eClass.getEStructuralFeatures().add(attribute);
	assertIsNull(ca);
	setValue(ca);
	attribute.setName("Foo");
	assertIsNull(ca);
	setValue(ca);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:OnChangeEvictingCacheAdapterTest.java

示例8: testSingleValuedResolveProxiesReference

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
@Test public void testSingleValuedResolveProxiesReference() throws Exception {
	final EObject foo = newEObject("Foo");
	final EObject bar = newEObject("Bar");
	final Resource resource = new ResourceImpl(URI.createURI("http://foo/bar.ecore")) {
		@Override
		public EObject getEObject(String uriFragment) {
			return bar;
		}
	};
	resourceSet.getResources().add(resource);
	resource.getContents().add(foo);

	final EReference eReference = (EReference) foo.eClass().getEStructuralFeature("single");
	assertFalse(eReference.isResolveProxies());

	final INode leafNode = newCrossReferenceAssignmentNode(eReference.getName());
	final ICompositeNode adapter = newSimpleNodeAdapter(leafNode);
	foo.eAdapters().add((Adapter) adapter);
	linker.linkModel(foo, new ListBasedDiagnosticConsumer());
	assertEquals(bar, foo.eGet(eReference, false));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:LazyLinkerTest.java

示例9: testManyValuedResolveProxiesReference

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
@Test public void testManyValuedResolveProxiesReference() throws Exception {
	final EObject foo = newEObject("Foo");
	final List<EObject> bars = Lists.newArrayList(newEObject("Bar"), newEObject("Bar"));
	final Iterator<EObject> barsIterator = bars.iterator();
	final Resource resource = new ResourceImpl(URI.createURI("http://foo/bar.ecore")) {
		@Override
		public EObject getEObject(String uriFragment) {
			return barsIterator.next();
		}
	};
	resourceSet.getResources().add(resource);
	resource.getContents().add(foo);
	final EReference eReference = (EReference) foo.eClass().getEStructuralFeature("many");
	assertFalse(eReference.isResolveProxies());

	final INode leafNode = newCrossReferenceAssignmentNode(eReference.getName());
	final INode leafNode2 = newCrossReferenceAssignmentNode(eReference.getName());
	final ICompositeNode adapter = newSimpleNodeAdapter(leafNode, leafNode2);
	foo.eAdapters().add((Adapter) adapter);
	linker.linkModel(foo, new ListBasedDiagnosticConsumer());
	assertEquals(bars, foo.eGet(eReference, false));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:LazyLinkerTest.java

示例10: testLongFragment

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
@Test
@BugTest(value = "DSL-601")
public void testLongFragment() {
  int reps = 100;
  EObject root = EcoreUtil.create(testClass);
  EObject parent = root;
  for (int i = 0; i < reps; i++) {
    EObject child = EcoreUtil.create(testClass);
    parent.eSet(testReference, child);
    parent = child;
  }

  ResourceImpl resource = new ResourceImpl();
  resource.getContents().add(root);

  String fragment = fragmentProvider.getFragment(parent, fragmentFallback);
  Assert.assertEquals("/0*" + (reps + 1), fragment);

  Assert.assertEquals(parent, fragmentProvider.getEObject(resource, fragment, fragmentFallback));
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:21,代码来源:ShortFragmentProviderTest.java

示例11: serialize

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
private String serialize(EObject eObject) {
	ResourceImpl resource = new XMLResourceImpl();
	resource.getContents().add(eObject);
	
	final ByteArrayOutputStream baos = new ByteArrayOutputStream();
	final Map<Object, Object> options = new HashMap<Object, Object>();
	options.put(XMLResource.OPTION_KEEP_DEFAULT_CONTENT, Boolean.TRUE);
	options.put(XMLResource.OPTION_DECLARE_XML, Boolean.FALSE);
	try {
		resource.save(baos, options);
		return baos.toString();
	} catch (IOException e) {
		LogUtil.error(e);
	}
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:AbstractPatchTestWithAllFeatureTypes.java

示例12: getTreeNode

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
public Resource getTreeNode() {
	Resource ret = new ResourceImpl(URI.createURI("tree node resource"));
	
	TreeNode libraryNode = TreeFactory.eINSTANCE.createTreeNode();
	libraryNode.setData(library);
	
	ret.getContents().add(libraryNode);
	
	for (Item item : library.getStock()) {
		TreeNode itemNode = TreeFactory.eINSTANCE.createTreeNode();
		itemNode.setData(item);
		libraryNode.getChildren().add(itemNode);
		if (item instanceof Book) {
			TreeNode writerNode = TreeFactory.eINSTANCE.createTreeNode();
			writerNode.setData(((Book) item).getAuthor());
			itemNode.getChildren().add(writerNode);
		}
		
	}
	return ret;
	
}
 
开发者ID:mbarbero,项目名称:econ-na-2014-emf-edit,代码行数:23,代码来源:MyLibrary.java

示例13: getPreferences

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
protected Map<String,String> getPreferences() {
	Injector reqInjector = safeGetInjector(SadlActivator.COM_GE_RESEARCH_SADL_SADL);
	IPreferenceValuesProvider pvp = reqInjector.getInstance(IPreferenceValuesProvider.class);
	org.eclipse.emf.ecore.resource.Resource resource = new ResourceImpl();
	resource.setURI(org.eclipse.emf.common.util.URI.createFileURI("/"));

	IPreferenceValues preferenceValues = pvp.getPreferenceValues(resource);
	if (preferenceValues != null) {
		Map<String, String> map = new HashMap<String, String>();
		boolean bval = Boolean.parseBoolean(preferenceValues.getPreference(SadlPreferences.SHOW_TIMING_INFORMATION));
		if (bval) {
			map.put(SadlPreferences.SHOW_TIMING_INFORMATION.getId(), "true");
		}
		else {
			map.put(SadlPreferences.SHOW_TIMING_INFORMATION.getId(), "false");
		}
		bval = Boolean.parseBoolean(preferenceValues.getPreference(SadlPreferences.VALIDATE_BEFORE_TEST));
		if (bval) {
			map.put(SadlPreferences.VALIDATE_BEFORE_TEST.getId(), "true");
		}
		else {
			map.put(SadlPreferences.VALIDATE_BEFORE_TEST.getId(), "false");
		}			return map;
	}
	return null;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:27,代码来源:SadlActionHandler.java

示例14: eObjectToString

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
/**
 * Copies the given EObject and converts it to a string.
 * 
 * @param object
 *            the eObject
 * @return the string representation of the EObject
 * @throws SerializationException
 *             if a serialization problem occurs
 */
public static String eObjectToString(EObject object) throws SerializationException {

	if (object == null) {
		return null;
	}

	final ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
	resourceSetImpl.setResourceFactoryRegistry(new ResourceFactoryRegistry());
	final XMIResource res = (XMIResource) resourceSetImpl.createResource(VIRTUAL_URI);
	((ResourceImpl) res).setIntrinsicIDToEObjectMap(new HashMap<String, EObject>());

	EObject copy;
	if (object instanceof IdEObjectCollection) {
		copy = copyIdEObjectCollection((IdEObjectCollection) object, res);
	} else {
		copy = copyEObject(ModelUtil.getProject(object), object, res);
	}

	return copiedEObjectToString(copy, res);
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:30,代码来源:ModelUtil.java

示例15: computeChecksum

import org.eclipse.emf.ecore.resource.impl.ResourceImpl; //导入依赖的package包/类
/**
 * Computes the checksum for a given {@link IdEObjectCollection}.
 * The checksum for a collection is independent of the order of the
 * collection's elements at the root level.
 * 
 * @param collection
 *            the collection for which to compute a checksum
 * @return the computed checksum
 * 
 * @throws SerializationException
 *             in case any errors occur during computation of the checksum
 */
public static long computeChecksum(IdEObjectCollection collection) throws SerializationException {

	final ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
	// TODO: do we need to instantiate the factory registry each time?
	resourceSetImpl.setResourceFactoryRegistry(new ResourceFactoryRegistry());
	final XMIResource res = (XMIResource) resourceSetImpl.createResource(VIRTUAL_URI);
	((ResourceImpl) res).setIntrinsicIDToEObjectMap(new HashMap<String, EObject>());
	final IdEObjectCollection copy = copyIdEObjectCollection(collection, res);

	ECollections.sort(copy.getModelElements(), new Comparator<EObject>() {
		public int compare(EObject o1, EObject o2) {
			return copy.getModelElementId(o1).getId().compareTo(copy.getModelElementId(o2).getId());
		}
	});

	final String serialized = copiedEObjectToString(copy, res);
	return computeChecksum(serialized);
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:31,代码来源:ModelUtil.java


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