當前位置: 首頁>>代碼示例>>Java>>正文


Java EcoreResourceFactoryImpl類代碼示例

本文整理匯總了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);
}
 
開發者ID:georghinkel,項目名稱:ttc2017smartGrids,代碼行數:26,代碼來源:Task2PackageImpl.java

示例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);
}
 
開發者ID:georghinkel,項目名稱:ttc2017smartGrids,代碼行數:26,代碼來源:GluemodelPackageImpl.java

示例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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:20,代碼來源:UnicodeStandaloneSetupGenerated.java

示例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;
}
 
開發者ID:TodorovicNikola,項目名稱:SurveyDSL,代碼行數:23,代碼來源:SurveyGenerator.java

示例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());
}
 
開發者ID:eclipse,項目名稱:xtext-extras,代碼行數:19,代碼來源:AbstractPortableURIsTest.java

示例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();

}
 
開發者ID:eclipse,項目名稱:xtext-extras,代碼行數:24,代碼來源:SrcSegmentsInUrisAreNotRemovedTests.java

示例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;
    }
 
開發者ID:vitruv-tools,項目名稱:Vitruv,代碼行數:21,代碼來源:Models.java

示例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);
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:24,代碼來源:XtextLinkingService.java

示例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();

}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:25,代碼來源:SrcSegmentsInUrisAreNotRemovedTests.java

示例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);
}
 
開發者ID:umple,項目名稱:umple,代碼行數:30,代碼來源:UmplePackageImpl.java

示例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;
}
 
開發者ID:guana,項目名稱:ATLauncher,代碼行數:21,代碼來源:ATLLauncher.java

示例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);
}
 
開發者ID:logicalhacking,項目名稱:SecureBPMN,代碼行數:28,代碼來源:Securebpmn2PackageImpl.java


注:本文中的org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。