Java Code Examples for org.eclipse.emf.ecore.EPackage.getNsURI()

The following are Jave code examples for showing how to use getNsURI() of the org.eclipse.emf.ecore.EPackage class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: JavaGraph   File: EcoreToType.java   View Source Code Vote up 5 votes
private void visitPackage(EPackage ePackage) {
    //required for namespace lookups when importing instance model
    String nsURI = ePackage.getNsURI();
    if (nsURI == null) {
        nsURI = ePackage.getName();
        ePackage.setNsURI(nsURI);
    }

    // register all packages we find in the ResourceSet
    this.rs.getPackageRegistry()
        .put(ePackage.getNsURI(), ePackage);
}
 
Example 2
Project: OCCI-Studio   File: GenUtils.java   View Source Code Vote up 5 votes
public static Extension resolveExtension(final EPackage ePackage) {
	Boolean put = true;
	Extension extension = null;

	String metamodelURI = ePackage.getNsURI();
	extension = namespace2extension.get(metamodelURI);
	// If extension not found then
	// System.out.println("beforeExtension "+namespace2extension);
	// System.out.println("beforeExtension "+extension);
	if (extension == null) {
		// Search URI of the extension into the OCCI extension registry.
		String scheme = Occi2Ecore.convertEcoreNamespace2OcciScheme(metamodelURI);
		String extensionURI = OcciRegistry.getInstance().getExtensionURI(scheme);
		// If extension URI not found then
		if (extensionURI == null) {
			// This is no way to resolve the kind of the given entity :-(
			// TODO: perhaps compute extensionURI of the ePackage of the entity's eClass.
			put = false;
			// Use OCCI Core resource, link or entity kind instances.
			extensionURI = OcciRegistry.getInstance().getExtensionURI(OcciCoreConstants.OCCI_CORE_SCHEME);
		}
		// Here extensionURI is set.
		assert (extensionURI != null);
		// Compute the resource set where loading the extension.
		ResourceSet resourceSet = new ResourceSetImpl();
		// Load the extension.
		Resource extensionResource = resourceSet.getResource(URI.createURI(extensionURI), true);
		extension = (Extension) extensionResource.getContents().get(0);
		// Map the metamodelURI to the found extension for optimizing next searches.
		if (put)
			namespace2extension.put(metamodelURI, extension);
	}
	// Return the found entity's kind.
	// System.out.println("afterExtension "+namespace2extension);
	// System.out.println("afterExtension "+extension);
	return extension;
}
 
Example 3
Project: OCCI-Studio   File: GenUtils.java   View Source Code Vote up 5 votes
public static Extension resolveExtension(final EPackage ePackage) {
	Boolean put = true;
	Extension extension = null;

	String metamodelURI = ePackage.getNsURI();
	extension = namespace2extension.get(metamodelURI);
	// If extension not found then
	// System.out.println("beforeExtension "+namespace2extension);
	// System.out.println("beforeExtension "+extension);
	if (extension == null) {
		// Search URI of the extension into the OCCI extension registry.
		String scheme = Occi2Ecore.convertEcoreNamespace2OcciScheme(metamodelURI);
		String extensionURI = OcciRegistry.getInstance().getExtensionURI(scheme);
		// If extension URI not found then
		if (extensionURI == null) {
			// This is no way to resolve the kind of the given entity :-(
			// TODO: perhaps compute extensionURI of the ePackage of the entity's eClass.
			put = false;
			// Use OCCI Core resource, link or entity kind instances.
			extensionURI = OcciRegistry.getInstance().getExtensionURI(OcciCoreConstants.OCCI_CORE_SCHEME);
		}
		// Here extensionURI is set.
		assert (extensionURI != null);
		// Compute the resource set where loading the extension.
		ResourceSet resourceSet = new ResourceSetImpl();
		// Load the extension.
		Resource extensionResource = resourceSet.getResource(URI.createURI(extensionURI), true);
		extension = (Extension) extensionResource.getContents().get(0);
		// Map the metamodelURI to the found extension for optimizing next searches.
		if (put)
			namespace2extension.put(metamodelURI, extension);
	}
	// Return the found entity's kind.
	// System.out.println("afterExtension "+namespace2extension);
	// System.out.println("afterExtension "+extension);
	return extension;
}