本文整理汇总了Java中org.eclipse.emf.ecore.EPackage.Registry.getEPackage方法的典型用法代码示例。如果您正苦于以下问题:Java Registry.getEPackage方法的具体用法?Java Registry.getEPackage怎么用?Java Registry.getEPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.EPackage.Registry
的用法示例。
在下文中一共展示了Registry.getEPackage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExternalFormOfEReference
import org.eclipse.emf.ecore.EPackage.Registry; //导入方法依赖的package包/类
@Test public void testExternalFormOfEReference() throws Exception {
Registry registry = EPackage.Registry.INSTANCE;
Set<String> uris = Sets.newHashSet(registry.keySet());
for (String string : uris) {
EPackage ePackage = registry.getEPackage(string);
TreeIterator<Object> iterator = EcoreUtil.getAllProperContents(ePackage, true);
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof EReference) {
EReference ref = (EReference) next;
String externalForm = EcoreUtil2.toExternalForm(ref);
assertEquals(ref.toString() + " - " + externalForm, ref, EcoreUtil2.getEReferenceFromExternalForm(registry,externalForm));
}
}
}
}
示例2: getEClass
import org.eclipse.emf.ecore.EPackage.Registry; //导入方法依赖的package包/类
private static EClass getEClass(final String metamodelUri, final String typeName,
final Registry packageRegistry) {
final EPackage pkg = packageRegistry.getEPackage(metamodelUri);
if (pkg == null) {
throw new NoSuchElementException(String.format(
"Could not find EPackage with URI '%s' in the registry",
metamodelUri));
}
final EClassifier eClassifier = pkg.getEClassifier(typeName);
if (!(eClassifier instanceof EClass)) {
throw new NoSuchElementException(String.format(
"Received an element of type '%s', which is not an EClass",
eClassifier));
}
final EClass eClass = (EClass) eClassifier;
return eClass;
}
示例3: getEClass
import org.eclipse.emf.ecore.EPackage.Registry; //导入方法依赖的package包/类
private static EClass getEClass(final String metamodelUri, final String typeName,
final Registry packageRegistry) {
final EPackage pkg = packageRegistry.getEPackage(metamodelUri);
if (pkg == null) {
throw new NoSuchElementException(String.format(
"Could not find EPackage with URI '%s' in the registry %s",
metamodelUri, packageRegistry));
}
final EClassifier eClassifier = pkg.getEClassifier(typeName);
if (!(eClassifier instanceof EClass)) {
throw new NoSuchElementException(String.format(
"Received an element of type '%s', which is not an EClass",
eClassifier));
}
final EClass eClass = (EClass) eClassifier;
return eClass;
}
示例4: getAllEClasses
import org.eclipse.emf.ecore.EPackage.Registry; //导入方法依赖的package包/类
/**
* Iterates over all registered EPackages in order to retrieve all available
* EClasses, excluding abstract classes and interfaces, and returns them as
* a Set.
*
* @return a set of all EClasses that are contained in registered EPackages
* @see Registry
*/
public List<EClass> getAllEClasses() {
if (allEClasses == null) {
allEClasses = new ArrayList<EClass>();
Registry registry = EPackage.Registry.INSTANCE;
// for all registered EPackages
for (Entry<String, Object> entry : new LinkedHashSet<Entry<String, Object>>(registry.entrySet())) {
EPackage ePackage = registry.getEPackage(entry.getKey());
for (EClass eClass : getAllEClasses(ePackage)) {
// no abstracts or interfaces
if (canHaveInstance(eClass)) {
allEClasses.add(eClass);
}
}
}
}
return allEClasses;
}
示例5: getAllRootEPackages
import org.eclipse.emf.ecore.EPackage.Registry; //导入方法依赖的package包/类
/**
* Returns all EPackages on the root level that are currently registered in
* the registry.
*
* @return a Set of all root EPackages
* @see Registry
*/
public Set<EPackage> getAllRootEPackages() {
// were the root packages computed before?
if (rootModelPackages != null) {
return rootModelPackages;
}
rootModelPackages = new LinkedHashSet<EPackage>();
Registry registry = EPackage.Registry.INSTANCE;
for (Entry<String, Object> entry : registry.entrySet()) {
EPackage ePackage = registry.getEPackage(entry.getKey());
// is the current EPackage a root package?
if (ePackage.getESuperPackage() == null) {
rootModelPackages.add(ePackage);
}
}
return rootModelPackages;
}
示例6: getAllEClasses
import org.eclipse.emf.ecore.EPackage.Registry; //导入方法依赖的package包/类
/**
* Iterates over all registered EPackages in order to retrieve all available
* EClasses, excluding abstract classes and interfaces, and returns them as
* a Set.
*
* @return a set of all EClasses that are contained in registered EPackages
* @see Registry
*/
public List<EClass> getAllEClasses() {
// were all EClasses computed before?
if (allEClasses != null) {
return allEClasses;
}
allEClasses = new LinkedList<EClass>();
Registry registry = EPackage.Registry.INSTANCE;
// for all registered EPackages
for (Entry<String, Object> entry : registry.entrySet()) {
EPackage ePackage = registry.getEPackage(entry.getKey());
for (EClass eClass : getAllEClasses(ePackage)) {
// no abstracts or interfaces
if (canHaveInstance(eClass)) {
allEClasses.add(eClass);
}
}
}
return allEClasses;
}
示例7: modelElementAddition
import org.eclipse.emf.ecore.EPackage.Registry; //导入方法依赖的package包/类
@Override
public void modelElementAddition(VcsCommitItem s, IHawkObject element, IGraphNode elementNode, boolean isTransient) {
// new model elements are assumed to be roots unless proven otherwise
if (isTransient) return;
final IHawkClassifier type = element.getType();
final Registry packageRegistry = resource.getResourceSet().getPackageRegistry();
final EPackage ePackage = packageRegistry.getEPackage(type.getPackageNSURI());
final EClass eClass = (EClass)ePackage.getEClassifier(type.getName());
addedRootNodes.put(elementNode, eClass);
}