本文整理汇总了Java中org.eclipse.emf.ecore.EPackage.Registry类的典型用法代码示例。如果您正苦于以下问题:Java Registry类的具体用法?Java Registry怎么用?Java Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Registry类属于org.eclipse.emf.ecore.EPackage包,在下文中一共展示了Registry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: registSysMLPackages
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
/**
* Register all the SysML default packages
*
* @param packageRegistry
*/
private void registSysMLPackages(Registry packageRegistry) {
// Register all default SYSML packages
packageRegistry.put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
packageRegistry.put(ActivitiesPackage.eNS_URI, ActivitiesPackage.eINSTANCE);
packageRegistry.put(AllocationsPackage.eNS_URI, AllocationsPackage.eINSTANCE);
packageRegistry.put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
packageRegistry.put(ConstraintsPackage.eNS_URI, ConstraintsPackage.eINSTANCE);
packageRegistry.put(InteractionsPackage.eNS_URI, InteractionsPackage.eINSTANCE);
packageRegistry.put(ModelelementsPackage.eNS_URI, ModelelementsPackage.eINSTANCE);
packageRegistry.put(PortandflowsPackage.eNS_URI, PortandflowsPackage.eINSTANCE);
packageRegistry.put(RequirementsPackage.eNS_URI, RequirementsPackage.eINSTANCE);
packageRegistry.put(StatemachinesPackage.eNS_URI, StatemachinesPackage.eINSTANCE);
packageRegistry.put(UsecasesPackage.eNS_URI, UsecasesPackage.eINSTANCE);
packageRegistry.put(UsecasesPackage.eNS_URI, UsecasesPackage.eINSTANCE);
}
开发者ID:ZhengshuaiPENG,项目名称:org.lovian.eaxmireader,代码行数:21,代码来源:InitResourceSet.java
示例2: 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));
}
}
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:EcoreUtil2Test.java
示例3: testExternalFormOfEReferenceNoNPE
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
/**
* This test assumes that an EPackage with indexed references is no longer available.
*/
@Test public void testExternalFormOfEReferenceNoNPE() throws Exception {
EReference reference = EcorePackage.Literals.EATTRIBUTE__EATTRIBUTE_TYPE;
URI uri = EcoreUtil.getURI(reference);
String externalForm = uri.toString();
EReference foundReference = EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, externalForm);
assertSame(reference, foundReference);
String brokenExternalFrom = makeInvalid(externalForm);
assertNull(EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, brokenExternalFrom));
String shortExternalForm = EcoreUtil2.toExternalForm(reference);
foundReference = EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, shortExternalForm);
assertSame(reference, foundReference);
String brokenShortExternalFrom = makeInvalid(shortExternalForm);
assertNull(EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, brokenShortExternalFrom));
brokenShortExternalFrom = shortExternalForm.replace('A', 'a');
assertNull(EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, brokenShortExternalFrom));
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:EcoreUtil2Test.java
示例4: handle
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
private void handle(final HawkModelElementAdditionEvent ev) {
final Registry registry = getResourceSet().getPackageRegistry();
final EClass eClass = HawkResourceImpl.getEClass(ev.metamodelURI, ev.typeName, registry);
final EObject existing = nodeIdToEObjectMap.get(ev.id);
if (existing == null) {
final EObject eob = createInstance(eClass);
nodeIdToEObjectMap.put(ev.id, eob);
synchronized(classToEObjectsMap) {
final EList<EObject> instances = classToEObjectsMap.get(eClass);
if (instances != null) {
instances.add(eob);
}
}
addToResource(ev.vcsItem.repoURL, ev.vcsItem.path, eob);
LOGGER.debug("Added a new {} with ID {}", eob.eClass().getName(), ev.id);
instanceInserted(eob, eob.eClass());
} else {
LOGGER.warn("We already have a {} with ID {}: cannot create a {} there", existing.eClass().getName(), ev.id, eClass.getName());
}
}
开发者ID:mondo-project,项目名称:mondo-integration,代码行数:21,代码来源:HawkResourceImpl.java
示例5: 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;
}
开发者ID:mondo-project,项目名称:mondo-integration,代码行数:19,代码来源:HawkResourceImpl.java
示例6: 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;
}
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:19,代码来源:LocalHawkResourceImpl.java
示例7: registerEPackageFromEcore
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
/**
* Registers a EPackage in {@link Registry} according to its {@code prefix} and {@code uri}, from an Ecore file.
* <p>
* The targeted Ecore file must be present in {@code /resources/ecore}.
*/
protected static void registerEPackageFromEcore(String prefix, String uri) {
File file = getResourceFile(ECORE_PATH.replaceAll("\\{name\\}", prefix));
EPackage ePackage = null;
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(ECORE, new EcoreResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(rs.getPackageRegistry());
rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
Resource r = rs.getResource(URI.createFileURI(file.toString()), true);
EObject eObject = r.getContents().get(0);
if (eObject instanceof EPackage) {
ePackage = (EPackage) eObject;
rs.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
}
assertThat(ePackage).isNotNull(); // "EPackage does not exist"
Registry.INSTANCE.put(uri, ePackage);
}
开发者ID:atlanmod,项目名称:NeoEMF,代码行数:29,代码来源:AbstractInputTest.java
示例8: getAvailablePackages
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
/**
* Gets all available EPackages from the EPackageRegistry.
*
* @param filterKnown weather known packages should be filtered or not.
* @return the available packages
*
*/
public static Set<EPackage> getAvailablePackages(boolean filterKnown) {
Registry registry = EPackage.Registry.INSTANCE;
HashSet<Entry<String, Object>> entries = new LinkedHashSet<Entry<String, Object>>(registry.entrySet());
Set<EPackage> packages = new LinkedHashSet<EPackage>();
for (Entry<String, Object> entry : entries) {
if (!filterKnown || !isKnownPackage(entry.getKey())) {
try {
EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(entry.getKey());
packages.add(ePackage);
// BEGIN SUPRESS CATCH EXCEPTION
} catch (RuntimeException e) {
// END SUPRESS CATCH EXCEPTION
WorkspaceUtil.logWarning("Failed to load EPackage", e);
}
}
}
return packages;
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:27,代码来源:EPackageRegistryHelper.java
示例9: 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;
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:26,代码来源:ModelMutatorUtil.java
示例10: getAllModelElementEClasses
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
/**
* Retrieve all EClasses from the ECore package registry.
*
* @return a set of EClasses
*/
public static Set<EClass> getAllModelElementEClasses() {
if (registryEClasses != null) {
return new LinkedHashSet<EClass>(registryEClasses);
}
final Set<EClass> result = new LinkedHashSet<EClass>();
final Registry registry = EPackage.Registry.INSTANCE;
for (Entry<String, Object> entry : new LinkedHashSet<Entry<String, Object>>(registry.entrySet())) {
try {
final EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(entry.getKey());
result.addAll(getAllModelElementEClasses(ePackage));
}
// BEGIN SUPRESS CATCH EXCEPTION
catch (RuntimeException exception) {
Activator.getDefault().logException("Failed to load model package " + entry.getKey(), exception);
// END SUPRESS CATCH EXCEPTION
}
}
registryEClasses = result;
return result;
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:31,代码来源:CommonUtil.java
示例11: 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;
}
开发者ID:diverse-project,项目名称:k3,代码行数:25,代码来源:ModelGeneratorUtil.java
示例12: 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;
}
开发者ID:diverse-project,项目名称:k3,代码行数:28,代码来源:ModelGeneratorUtil.java
示例13: initResourceSet
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
/**
* Initialize the UML resourceSet and register all the packages by default
*
* @return resourceSet
* @throws IOException
*/
public ResourceSet initResourceSet() throws IOException {
String method = "InitResourceSet_initResourceSet(): ";
long startTime = System.currentTimeMillis();
MyLog.info(method + "start");
ResourceSet resourceSet = new ResourceSetImpl();
Registry packageRegistry = resourceSet.getPackageRegistry();
// Read the namespace configuration file
String namespaceConfigPath = FileLocator
.toFileURL(Activator.getDefault().getBundle().getEntry(NAMESPACE_CONFIG_FILE_PAHT)).getPath();
File namespaceConfigFile = new File(namespaceConfigPath);
Properties properties = new Properties();
properties.load(new FileInputStream(namespaceConfigFile));
// Load and register the self-definition namespaces
for (String key : properties.stringPropertyNames()) {
String value = properties.getProperty(key);
packageRegistry.put(value, UMLPackage.eINSTANCE);
}
registSysMLPackages(packageRegistry);
// Add the load option
resourceSet.getLoadOptions().put(XMIResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
// Define the extension to factory map
Map<String, Object> extensionToFactoryMap = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
UMLResourceFactoryImpl umlResourceFactory = new UMLResourceFactoryImpl();
extensionToFactoryMap.put(XMI2UMLResource.FILE_EXTENSION, umlResourceFactory);
MyLog.info(method + "end with " + (System.currentTimeMillis() - startTime) + " millisecond");
MyLog.info();
return resourceSet;
}
开发者ID:ZhengshuaiPENG,项目名称:org.lovian.eaxmireader,代码行数:43,代码来源:InitResourceSet.java
示例14: testClone
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
@Test public void testClone() throws Exception {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new XMIResourceFactoryImpl());
EPackage.Registry.INSTANCE.put(EcorePackage.eINSTANCE.getNsURI(), EcorePackage.eINSTANCE);
ResourceSetImpl rs = new ResourceSetImpl();
Resource r1 = rs.createResource(URI.createURI("foo.xmi"), ContentHandler.UNSPECIFIED_CONTENT_TYPE);
Resource r2 = rs.createResource(URI.createURI("bar.xmi"), ContentHandler.UNSPECIFIED_CONTENT_TYPE);
EClass a = EcoreFactory.eINSTANCE.createEClass();
a.setName("a");
EClass b = EcoreFactory.eINSTANCE.createEClass();
r1.getContents().add(a);
b.setName("b");
b.getESuperTypes().add(a);
r2.getContents().add(b);
ResourceSetImpl clone = EcoreUtil2.clone(new ResourceSetImpl(), rs);
EList<Resource> list = clone.getResources();
Resource resA = list.get(0);
assertEquals(URI.createURI("foo.xmi"),resA.getURI());
assertNotSame(resA, r1);
Resource resB = list.get(1);
assertEquals(URI.createURI("bar.xmi"),resB.getURI());
assertNotSame(resB, r2);
EClass a1 = (EClass)resA.getContents().get(0);
EClass b1 = (EClass)resB.getContents().get(0);
assertEquals("a", a1.getName());
assertNotSame(a, a1);
assertEquals("b", b1.getName());
assertNotSame(b, b1);
assertSame(b1.getESuperTypes().get(0),a1);
assertSame(b.getESuperTypes().get(0),a);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:37,代码来源:EcoreUtil2Test.java
示例15: createEObject
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
private EObject createEObject(final ModelElement me) throws IOException {
final Registry registry = getResourceSet().getPackageRegistry();
final EClass eClass = getEClass(me.metamodelUri, me.typeName, registry);
final EObject obj = createInstance(eClass);
if (me.isSetId()) {
nodeIdToEObjectMap.put(me.id, obj);
synchronized(classToEObjectsMap) {
final EList<EObject> instances = classToEObjectsMap.get(eClass);
if (instances != null) {
instances.add(obj);
}
}
}
if (me.isSetAttributes()) {
final EFactory factory = registry.getEFactory(eClass.getEPackage().getNsURI());
for (final AttributeSlot s : me.attributes) {
SlotDecodingUtils.setFromSlot(factory, eClass, obj, s);
}
} else if (!descriptor.getLoadingMode().isGreedyAttributes()) {
getLazyResolver().putLazyAttributes(me.id, obj);
}
return obj;
}
开发者ID:mondo-project,项目名称:mondo-integration,代码行数:28,代码来源:HawkResourceImpl.java
示例16: fillInReferences
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
private void fillInReferences(final List<ModelElement> elems, final TreeLoadingState state) throws IOException {
final Registry packageRegistry = getResourceSet().getPackageRegistry();
for (final ModelElement me : elems) {
final EObject sourceObj = state.meToEObject.remove(me);
fillInReferences(packageRegistry, me, sourceObj, state);
}
}
开发者ID:mondo-project,项目名称:mondo-integration,代码行数:9,代码来源:HawkResourceImpl.java
示例17: 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);
}
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:12,代码来源:LocalHawkResourceUpdater.java
示例18: BPMNMetaModelResourceFactory
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
public BPMNMetaModelResourceFactory() {
if (EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI) == null) {
EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI,
EcorePackage.eINSTANCE);
}
resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put("ecore", new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put("*", new XMIResourceFactoryImpl());
}
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:14,代码来源:BPMNMetaModelResourceFactory.java
示例19: checkRegistry
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
private LinkedList<String> checkRegistry() {
Registry globalRegistry = EPackage.Registry.INSTANCE;
LinkedList<String> missingPackages = new LinkedList<>();
if (!globalRegistry
.containsKey("http://www.eclipse.org/emf/2003/XMLType"))
missingPackages.add("http://www.eclipse.org/emf/2003/XMLType");
if (!globalRegistry
.containsKey("http://www.omg.org/spec/BPMN/20100524/MODEL-XMI"))
missingPackages
.add("http://www.omg.org/spec/BPMN/20100524/MODEL-XMI");
if (!globalRegistry
.containsKey("http://www.omg.org/spec/DD/20100524/DC-XMI"))
missingPackages.add("http://www.omg.org/spec/DD/20100524/DC-XMI");
if (!globalRegistry
.containsKey("http://www.eclipse.org/emf/2002/Ecore"))
missingPackages.add("http://www.eclipse.org/emf/2002/Ecore");
if (!globalRegistry
.containsKey("http://www.omg.org/spec/BPMN/20100524/DI-XMI"))
missingPackages.add("http://www.omg.org/spec/BPMN/20100524/DI-XMI");
if (!globalRegistry
.containsKey("http://www.omg.org/spec/DD/20100524/DI-XMI"))
missingPackages.add("http://www.omg.org/spec/DD/20100524/DI-XMI");
return missingPackages;
}
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:29,代码来源:BPMNMetaModelResourceFactory.java
示例20: resolveInstanceOf
import org.eclipse.emf.ecore.EPackage.Registry; //导入依赖的package包/类
/**
* Compute the {@link EClass} associated to the model element with the provided {@link Id}.
*
* @param id the {@link Id} of the model element to compute the {@link EClass} from
*
* @return an {@link EClass} representing the metaclass of the element
*/
private EClass resolveInstanceOf(Id id) {
try {
Result result = table.get(new Get(Bytes.toBytes(id.toString())));
String nsURI = Bytes.toString(result.getValue(TYPE_FAMILY, METAMODEL_QUALIFIER));
String className = Bytes.toString(result.getValue(TYPE_FAMILY, ECLASS_QUALIFIER));
if (nonNull(nsURI) && nonNull(className)) {
return (EClass) Registry.INSTANCE.getEPackage(nsURI).getEClassifier(className);
}
}
catch (IOException e) {
NeoLogger.error("Unable to get instance of information for {0}", id);
}
return null;
}
开发者ID:atlanmod,项目名称:NeoEMF,代码行数:22,代码来源:DirectWriteHBaseStore.java
注:本文中的org.eclipse.emf.ecore.EPackage.Registry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论