本文整理汇总了Java中org.eclipse.emf.ecore.resource.Resource.Factory.Registry类的典型用法代码示例。如果您正苦于以下问题:Java Registry类的具体用法?Java Registry怎么用?Java Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Registry类属于org.eclipse.emf.ecore.resource.Resource.Factory包,在下文中一共展示了Registry类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAdapterFactory
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; //导入依赖的package包/类
public static AdapterFactory getAdapterFactory(Object object) {
EditingDomain domain = null;
if (object instanceof EditingDomain) {
domain = (EditingDomain) object;
} else {
domain = AdapterFactoryEditingDomain.getEditingDomainFor(object);
}
if (domain instanceof AdapterFactoryEditingDomain) {
AdapterFactoryEditingDomain aDomain = (AdapterFactoryEditingDomain) domain;
AdapterFactory adapterFactory = aDomain.getAdapterFactory();
if (adapterFactory != null) {
return adapterFactory;
}
}
return new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:EMFUtils.java
示例2: load
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; //导入依赖的package包/类
public static Programme load(final String path) {
try {
Programme _xblockexpression = null;
{
ResourceSetImpl _resourceSetImpl = new ResourceSetImpl();
final ResourceSetImpl rs = _resourceSetImpl;
RobotPackage.eINSTANCE.eClass();
Map<String,Object> _extensionToFactoryMap = Registry.INSTANCE.getExtensionToFactoryMap();
XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl();
_extensionToFactoryMap.put("*", _xMIResourceFactoryImpl);
URI _createURI = URI.createURI(path);
final Resource res = rs.getResource(_createURI, true);
Map<Object,Object> _emptyMap = Collections.<Object, Object>emptyMap();
res.load(_emptyMap);
EList<EObject> _contents = res.getContents();
Iterable<Programme> _filter = Iterables.<Programme>filter(_contents, Programme.class);
Programme _head = IterableExtensions.<Programme>head(_filter);
_xblockexpression = (_head);
}
return _xblockexpression;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
开发者ID:damien-cremilleux,项目名称:TP4INFO,代码行数:25,代码来源:Main.java
示例3: FactoryWrapper
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; //导入依赖的package包/类
public FactoryWrapper(Registry registry) {
super();
this.fileExtensions = FileExtensionRegistry.getInstance().getFileExtensions();
this.registry = registry;
for (String fileExtension : fileExtensions) {
registry.getExtensionToFactoryMap().put(fileExtension, new TextbasedCDOResourceFactoryImpl());
registry.getExtensionToFactoryMap().put(
String.format("%s.%s", fileExtension, TextbasedCDOResourceFactoryImpl.getAdditionalFileExtension()),
new TextbasedCDOResourceFactoryImpl());
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:12,代码来源:FactoryWrapper.java
示例4: convertToXML
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; //导入依赖的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
示例5: createFromXML
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; //导入依赖的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
示例6: copy
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; //导入依赖的package包/类
public static Resource copy(final Resource resource) {
final ResourceSet set = resource.getResourceSet();
final Registry registry;
if (set != null)
registry = set.getResourceFactoryRegistry();
else
registry = Registry.INSTANCE;
final Factory factory = registry.getFactory(resource.getURI());
if (factory == null)
throw new RuntimeException("No resource factory found for URI '" + resource.getURI() + "'");
return copy(factory, resource);
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:13,代码来源:EMFUtils.java
示例7: doGenerate
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; //导入依赖的package包/类
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
System.out.println("Starting XMI generation...");
final Registry registery = Registry.INSTANCE;
final Map<String,Object> map = registery.getExtensionToFactoryMap();
XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl();
final XMIResourceFactoryImpl xmiRes = _xMIResourceFactoryImpl;
map.put(LanguageGenerator.LANGUAGE_EXTENSION, xmiRes);
ResourceSetImpl _resourceSetImpl = new ResourceSetImpl();
final ResourceSetImpl resSet = _resourceSetImpl;
String _plus = (LanguageGenerator.GEN_PATH + File.separator);
String _plus_1 = (_plus + LanguageGenerator.FILE_NAME);
final URI uri = URI.createURI(_plus_1);
final Resource res = resSet.createResource(uri);
String _plus_2 = ("Resource created at \"" + LanguageGenerator.GEN_PATH);
String _plus_3 = (_plus_2 + File.separator);
String _plus_4 = (_plus_3 + LanguageGenerator.FILE_NAME);
String _plus_5 = (_plus_4 + "\"");
System.out.println(_plus_5);
EList<EObject> _contents = res.getContents();
EList<EObject> _contents_1 = resource.getContents();
_contents.addAll(_contents_1);
try {
res.save(Collections.EMPTY_MAP);
} catch (final Throwable _t) {
if (_t instanceof IOException) {
final IOException e = (IOException)_t;
e.printStackTrace();
} else {
throw Exceptions.sneakyThrow(_t);
}
}
System.out.println("Generation completed");
}
开发者ID:nemolovich,项目名称:MDEProject,代码行数:34,代码来源:LanguageGenerator.java
示例8: createFactoryWrapper
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; //导入依赖的package包/类
public static FactoryWrapper createFactoryWrapper(Registry registry) {
return new FactoryWrapper(registry);
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:4,代码来源:CDOResourceHandler.java
示例9: finalizeDynamicModel
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; //导入依赖的package包/类
/**
* Invoke this after creating a dynamic package and all its classes to
* ensure that:
*
* a) all feature IDs are set before CDO creates parallel CDOFeatures for
* them
*
* b) the package is registered globally so that it is available for sharing
*
* This fixes the -1 ArrayIndexOutOfBoundsException problem when sharing
* your model
*/
public static void finalizeDynamicModel(EPackage pkg) {
try {
ReflectionUtils.invoke(pkg, "fixEClassifiers");
} catch (Throwable t) {
if (!CommonPlugin.isJunitRunning()) {
LogUtil.error("error in finalization", t);
}
}
EPackage.Registry.INSTANCE.put(pkg.getNsURI(), pkg);
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:23,代码来源:EMFUtils.java
注:本文中的org.eclipse.emf.ecore.resource.Resource.Factory.Registry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论