本文整理汇总了Java中org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl类的典型用法代码示例。如果您正苦于以下问题:Java EcoreResourceFactoryImpl类的具体用法?Java EcoreResourceFactoryImpl怎么用?Java EcoreResourceFactoryImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EcoreResourceFactoryImpl类属于org.eclipse.emf.ecore.xmi.impl包,在下文中一共展示了EcoreResourceFactoryImpl类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadPackage
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
/**
* Laods the package and any sub-packages from their serialized form.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void loadPackage() {
if (isLoaded)
return;
isLoaded = true;
URL url = getClass().getResource(packageFilename);
if (url == null) {
throw new RuntimeException("Missing serialized package: " + packageFilename);
}
URI uri = URI.createURI(url.toString());
Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
try {
resource.load(null);
} catch (IOException exception) {
throw new WrappedException(exception);
}
initializeFromLoadedEPackage(this, (EPackage) resource.getContents().get(0));
createResource(eNS_URI);
}
示例2: loadPackage
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
/**
* Laods the package and any sub-packages from their serialized form.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void loadPackage() {
if (isLoaded) return;
isLoaded = true;
URL url = getClass().getResource(packageFilename);
if (url == null) {
throw new RuntimeException("Missing serialized package: " + packageFilename);
}
URI uri = URI.createURI(url.toString());
Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
try {
resource.load(null);
}
catch (IOException exception) {
throw new WrappedException(exception);
}
initializeFromLoadedEPackage(this, (EPackage)resource.getContents().get(0));
createResource(eNS_URI);
}
示例3: createInjectorAndDoEMFRegistration
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
@Override
public Injector createInjectorAndDoEMFRegistration() {
// register default ePackages
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"ecore", new EcoreResourceFactoryImpl());
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"xmi", new XMIResourceFactoryImpl());
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"xtextbin", new BinaryGrammarResourceFactoryImpl());
if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI))
EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE);
Injector injector = createInjector();
register(injector);
return injector;
}
示例4: loadSurveyModel
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
private static Survey loadSurveyModel(String modulePath) {
// Initialize the model
QueryITPackage.eINSTANCE.eClass();
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
m.put("ecore", new EcoreResourceFactoryImpl());
// Obtain a new resource set
ResourceSet resSet = new ResourceSetImpl();
// Get the resource
//Resource resource = resSet.getResource(URI.createFileURI(modulePath), true);
Resource resource = resSet.getResource(URI.createURI(modulePath), true);
// Get the first model element and cast it to the right type, in my
// example everything is included in this first node
Survey s = (Survey) resource.getContents().get(0);
return s;
}
示例5: setUp
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
resourceSet = new XtextResourceSet();
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this);
resourceSet.setClasspathURIContext(getClasspathURIContext());
}
示例6: setUp
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
EcoreResourceFactoryImpl resFactory = new EcoreResourceFactoryImpl();
set.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put("ecore", resFactory);
aRes = (XMIResource) set.createResource(URI.createPlatformResourceURI(
"/myProject/main/src/some/package/a.ecore", true));
InputStream stream = new ByteArrayInputStream(
aResContent.getBytes("US-ASCII"));
aRes.load(stream, set.getLoadOptions());
stream.close();
bRes = (XMIResource) set.createResource(URI.createPlatformResourceURI(
"/myProject/model/b.ecore", true));
stream = new ByteArrayInputStream(
bResContent.getBytes("US-ASCII"));
bRes.load(stream, set.getLoadOptions());
stream.close();
}
示例7: loadModel
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
public static Resource loadModel(URL modelURL) {
ResourceSet resSet = new ResourceSetImpl();
resSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new XMIResourceFactoryImpl());
EcoreResourceFactoryImpl ecoreResFact = new EcoreResourceFactoryImpl();
URI fileName = BasicTestCase.getURI(modelURL);
LOGGER.info("Trying to load " + fileName);
Resource ecoreRes = ecoreResFact.createResource(fileName);
try {
ecoreRes.load(null);
} catch (IOException e) {
fail("Could not load " + Files.EXAMPLEMODEL_ECORE.getFile() + ". Reason: " + e);
}
resSet.getResources().add(ecoreRes);
return ecoreRes;
}
示例8: createPackage
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
private List<EObject> createPackage(GeneratedMetamodel generatedMetamodel, ILeafNode text) {
final String nsURI = getMetamodelNsURI(text);
final URI uri = URI.createURI(nsURI);
if (uri == null || isReferencedByUsedGrammar(generatedMetamodel, nsURI))
return Collections.emptyList();
EPackage pack = ((GeneratedMetamodelImpl)generatedMetamodel).basicGetEPackage();
if (pack != null && !pack.eIsProxy())
return singletonList((EObject)pack);
final EPackage generatedEPackage = EcoreFactory.eINSTANCE.createEPackage();
generatedEPackage.setName(generatedMetamodel.getName());
generatedEPackage.setNsPrefix(generatedMetamodel.getName());
generatedEPackage.setNsURI(nsURI);
final Resource generatedPackageResource = new EcoreResourceFactoryImpl().createResource(uri);
XtextResourceSet resourceSet = (XtextResourceSet) generatedMetamodel.eResource().getResourceSet();
if (!resourceSet.getURIResourceMap().containsKey(generatedPackageResource.getURI())) {
generatedMetamodel.eResource().getResourceSet().getResources().add(generatedPackageResource);
} else {
generatedPackageResource.setURI(URI.createURI(nsURI+"_"+generatedMetamodel.hashCode()));
generatedMetamodel.eResource().getResourceSet().getResources().add(generatedPackageResource);
}
generatedPackageResource.getContents().add(generatedEPackage);
return Collections.<EObject>singletonList(generatedEPackage);
}
示例9: setUp
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
EcoreResourceFactoryImpl resFactory = new EcoreResourceFactoryImpl();
set.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put("ecore", resFactory);
aRes = (XMIResource) set.createResource(URI.createPlatformResourceURI(
"/myProject/main/src/some/package/a.ecore", true));
InputStream stream = new ByteArrayInputStream(
aResContent.getBytes("US-ASCII"));
aRes.load(stream, set.getLoadOptions());
stream.close();
bRes = (XMIResource) set.createResource(URI.createPlatformResourceURI(
"/myProject/model/b.ecore", true));
stream = new ByteArrayInputStream(
bResContent.getBytes("US-ASCII"));
bRes.load(stream, set.getLoadOptions());
stream.close();
}
示例10: loadPackage
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
/**
* Laods the package and any sub-packages from their serialized form.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void loadPackage()
{
if (isLoaded) return;
isLoaded = true;
URL url = getClass().getResource(packageFilename);
if (url == null)
{
throw new RuntimeException("Missing serialized package: " + packageFilename);
}
URI uri = URI.createURI(url.toString());
Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
try
{
resource.load(null);
}
catch (IOException exception)
{
throw new WrappedException(exception);
}
initializeFromLoadedEPackage(this, (EPackage)resource.getContents().get(0));
createResource(eNS_URI);
}
示例11: lazyMetamodelRegistration
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
private String lazyMetamodelRegistration(String metamodelPath){
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
// Enables extended meta-data, weird we have to do this but well...
final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(EPackage.Registry.INSTANCE);
rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
Resource r = rs.getResource(URI.createFileURI(metamodelPath), true);
EObject eObject = r.getContents().get(0);
// A meta-model might have multiple packages we assume the main package is the first one listed
if (eObject instanceof EPackage) {
EPackage p = (EPackage)eObject;
System.out.println(p.getNsURI());
EPackage.Registry.INSTANCE.put(p.getNsURI(), p);
return p.getNsURI();
}
return null;
}
示例12: loadPackage
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
/**
* Laods the package and any sub-packages from their serialized form.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void loadPackage() {
if (isLoaded)
return;
isLoaded = true;
URL url = getClass().getResource(packageFilename);
if (url == null) {
throw new RuntimeException("Missing serialized package: "
+ packageFilename);
}
URI uri = URI.createURI(url.toString());
Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
try {
resource.load(null);
} catch (IOException exception) {
throw new WrappedException(exception);
}
initializeFromLoadedEPackage(this, (EPackage) resource.getContents()
.get(0));
createResource(eNS_URI);
}