当前位置: 首页>>代码示例>>Java>>正文


Java ResourceSet.createResource方法代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.resource.ResourceSet.createResource方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceSet.createResource方法的具体用法?Java ResourceSet.createResource怎么用?Java ResourceSet.createResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.emf.ecore.resource.ResourceSet的用法示例。


在下文中一共展示了ResourceSet.createResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createExtendedTosca

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
public static void createExtendedTosca() {
	ResourceSet resSet = new ResourceSetImpl();
	URI modelURI = URI
			.createURI("file:/C:/Users/schallit/workspace-tosca2/plugins/org.eclipse.cmf.occi.tosca.extended/model/extendedTosca.occie");
	resource = resSet.createResource(modelURI);
	Extension extension = OCCIFactory.eINSTANCE.createExtension();
	extension.setDescription("Extended TOSCA");
	extension.setScheme("http://org.occi/extendedTosca#");
	extension.setName("extendedTosca");
	Extension toscaExtension = OcciHelper.loadExtension("http://org.occi/tosca#");
	extension.getImport().add(extensionsPerName.get("core"));
	extension.getImport().add(extensionsPerName.get("infrastructure"));
	extension.getImport().add(extensionsPerName.get("platform"));
	extension.getImport().add(extensionsPerName.get("sla"));
	extension.getImport().add(toscaExtension);
	copy(toscaExtension);
	extensionsPerName.replace("tosca", toscaExtension);
	resource.getContents().add(extension);
	extensionsPerName.put("extendedTosca", extension);
	currentExtensionToBeBuild = extension;
}
 
开发者ID:occiware,项目名称:TOSCA-Studio,代码行数:22,代码来源:ExtensionsManager.java

示例2: getProfile

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
@Override
public Profile getProfile ()
{
    if ( this.profile == null )
    {
        final ResourceSet rs = new ResourceSetImpl ();
        final Resource r = rs.createResource ( URI.createURI ( DEFAULT_URI ), "org.eclipse.scada.configuration.world.osgi.profile" );
        try
        {
            r.load ( null );
        }
        catch ( final IOException e )
        {
            throw new RuntimeException ( e );
        }
        this.profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE );
        if ( this.profile == null )
        {
            throw new IllegalStateException ( String.format ( "Resource loaded from %s does not contain an object of type %s", DEFAULT_URI, Profile.class.getName () ) );
        }
    }

    return this.profile;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:DefaultValueArchiveServerImpl.java

示例3: parse

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private static RootType parse ( final URI uri ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ConfigurationResourceFactoryImpl () );

    final Resource r = rs.createResource ( uri );
    r.load ( null );

    final DocumentRoot doc = (DocumentRoot)EcoreUtil.getObjectByType ( r.getContents (), ConfigurationPackage.Literals.DOCUMENT_ROOT );
    if ( doc == null )
    {
        return null;
    }
    else
    {
        return doc.getRoot ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:Hive.java

示例4: createConfiguration

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
public static void createConfiguration(String path) {
	String name = convertPathToConfigName(path);
	ResourceSet resSet = new ResourceSetImpl();
	URI modelURI = URI
			.createURI("file:/C:/Users/schallit/workspace-tosca2/plugins/org.eclipse.cmf.occi.tosca.examples/" + name + ".extendedTosca");
	resource = resSet.createResource(modelURI);
	Configuration configuration = OCCIFactory.eINSTANCE.createConfiguration();
	configuration.getUse().add(OcciHelper.loadExtension("http://schemas.ogf.org/occi/core#"));
	configuration.getUse().add(OcciHelper.loadExtension("http://schemas.ogf.org/occi/infrastructure#"));
	configuration.getUse().add(OcciHelper.loadExtension("http://schemas.ogf.org/occi/platform#"));
	configuration.getUse().add(OcciHelper.loadExtension("http://schemas.ogf.org/occi/sla#"));
	configuration.getUse().add(OcciHelper.loadExtension("http://org.occi/tosca#"));
	configuration.getUse().add(OcciHelper.loadExtension("http://org.occi/extendedTosca#"));
	resource.getContents().add(configuration);
	currentConfiguration = configuration;
}
 
开发者ID:occiware,项目名称:TOSCA-Studio,代码行数:17,代码来源:ConfigManager.java

示例5: saveResources

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public static void saveResources(final List<EObject> root, final URI uri) {
  final ResourceSet resourceSet = new ResourceSetImpl();
  resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
      .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMLResourceFactoryImpl());
  final Resource resource = resourceSet.createResource(uri);
  resource.getContents().addAll(root);

  final Map options = new HashMap();
  options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
  try {
    resource.save(options);
  } catch (final IOException e) {
    e.printStackTrace();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:17,代码来源:EcoreUtilities.java

示例6: patchProfile

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
 * Inject the CA bootstrap property to the profile
 *
 * @param file
 *            the profile.xml file in the package target
 * @throws IOException
 */
protected void patchProfile ( final String appName, final File file ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( URI.createFileURI ( file.toString () ) );
    r.load ( null );

    final Profile profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE );
    Profiles.addSystemProperty ( profile, "org.eclipse.scada.ca.file.provisionJsonUrl", "file:///usr/share/eclipsescada/ca.bootstrap/bootstrap." + appName + ".json" );
    r.save ( null );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:CommonPackageHandler.java

示例7: load

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
public T load ( final URI uri, final String contentTypeId ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( uri, contentTypeId );
    r.load ( null );

    for ( final Object o : r.getContents () )
    {
        if ( this.clazz.isAssignableFrom ( o.getClass () ) )
        {
            return this.clazz.cast ( o );
        }
    }

    throw new IllegalStateException ( String.format ( "Model %s does not contain an object of type %s", uri, this.clazz ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:ModelLoader.java

示例8: createGlueModel

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
public static Root createGlueModel(CIMRoot cim, Substandard substandard, COSEMRoot cosem) {
	Resource cimResource = cim.eResource();
	Resource cosemResource = cosem.eResource();

	ResourceSet rs = cimResource.getResourceSet();
	if (rs != cosemResource.getResourceSet()) {
		throw new RuntimeException("Different ResourceSets");
	}

	Resource fwdResource = rs.createResource(URI.createURI("fwd.src.xmi"));

	Root root = GluemodelFactory.eINSTANCE.createRoot();
	root.setCim(cim);
	root.setCosem(cosem);

	Hashtable<String, MeterAsset> allMeterAssets = getAllMeterAssets(cimResource);
	root.getAssets().addAll(allMeterAssets.values());


	cosem(cosemResource, root, allMeterAssets);

	if (substandard != null) {
		root.setSubstandard(substandard);
		substandard(substandard.eResource(), root, allMeterAssets);
	}

	fwdResource.getContents().add(root);
	return root;
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:30,代码来源:GlueModelCreator.java

示例9: saveCompany

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
 * Save a company EObject both in .xmi and .xml file
 */
public static void saveCompany(Company c, String s) throws IOException {
	
	ResourceSet resourceSet = getResourceSet();

	// Use XMI resource
	Resource xmiResource = resourceSet.createResource(URI.createFileURI(s + ".xmi"));
	xmiResource.getContents().add(c);
	xmiResource.save(null);

	// Use XML resource instead
	Resource xmlResource = resourceSet.createResource(URI.createFileURI(s + ".xml"));
	xmlResource.getContents().add(c);
	xmlResource.save(null);
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:18,代码来源:Serialization.java

示例10: parse

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private static RootType parse ( final URI uri ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();

    rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ConfigurationResourceFactoryImpl () );
    final Resource r = rs.createResource ( uri );
    r.load ( null );

    return (RootType)EcoreUtil.getObjectByType ( r.getContents (), ConfigurationPackage.Literals.ROOT_TYPE );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:11,代码来源:Hive.java

示例11: doSave

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private void doSave ( final String file ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();

    rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMLResourceFactoryImpl () ); //$NON-NLS-1$
    final URI fileUri = URI.createFileURI ( file );
    final Resource resource = rs.createResource ( fileUri );
    resource.getContents ().add ( this.chart );

    final Map<Object, Object> options = new HashMap<Object, Object> ();
    //             options.put ( XMIResource., value )
    resource.save ( options );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:14,代码来源:ChartActionBarContributor.java

示例12: createSelector

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private static Selector createSelector ( final IPath path ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( URI.createFileURI ( path.toString () ) );
    r.load ( bundleResource ( path ), null );
    return EcoreUtil.copy ( (Selector)r.getContents ().get ( 0 ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:8,代码来源:CreateProjectOperation.java

示例13: createAndLoadOCCIEcoreResource

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private Resource createAndLoadOCCIEcoreResource(String pathToDDLEcore) {
	// creating a proper URI is vitally important since this is how
	// referenced objects in the is ecore file will be found from the ecore
	// file that we produce.
	ResourceSet resSet = new ResourceSetImpl();
	final URI uri = URI.createPlatformPluginURI(pathToDDLEcore, true);
	Resource res = resSet.createResource(uri);
	try {
		res.load(Collections.emptyMap());
	} catch (IOException e) {
		e.printStackTrace();
	}
	return res;
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:15,代码来源:OCCIExtension2Ecore.java

示例14: parse

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private static DocumentRoot parse ( final URI uri ) throws ConfigurationException
{
    ExporterPackage.eINSTANCE.eClass ();

    /*
     * we do need to provide the current context classloader, otherwise there
     * seem to be problems finding services when run with jsvc. 
     */
    ServiceLoaderProcessor.initialize ( "emf", Thread.currentThread ().getContextClassLoader () );

    try
    {
        final ResourceSet rs = new ResourceSetImpl ();
        rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ExporterResourceFactoryImpl () );
        final Resource resource = rs.createResource ( uri );
        resource.load ( null );

        final DocumentRoot result = (DocumentRoot)EcoreUtil.getObjectByType ( resource.getContents (), ExporterPackage.Literals.DOCUMENT_ROOT );
        if ( result == null )
        {
            throw new IllegalStateException ( "Document does not contain a configuration" );
        }
        return result;
    }
    catch ( final Exception e )
    {
        throw new ConfigurationException ( "Failed to parse document", e );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:30,代码来源:Controller.java

示例15: doSaveDocument

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
@Override
protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite)
		throws CoreException {
	try {
		//System.out.println("doSaveDocument ");
		ResourceSet resourceSet = createResourceSet();
		XtextResource xtextResource = (XtextResource) resourceSet.createResource(URI.createURI("temp.occi"));
		InputStream is = new ByteArrayInputStream(document.get().getBytes());
		xtextResource.load(is, Collections.EMPTY_MAP);
		is.close();
		URI uri = URI.createPlatformResourceURI(
				((org.eclipse.ui.part.FileEditorInput) element).getFile().getFullPath().toString(), true);
		//resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
		//System.out.println("uriii "+uri);
		Resource xmiResource = resourceSet.getResource(uri, true);
		((XMLResource) xmiResource).getDefaultSaveOptions().put(XMLResource.OPTION_URI_HANDLER,
				new URIHandlerImpl.PlatformSchemeAware());
		xmiResource.getContents().clear();
		xmiResource.getContents().addAll(xtextResource.getContents());
		// SUPER IMPORTANT to avoid to have references to temp.occi
		EcoreUtil.resolveAll(xmiResource);			
		xmiResource.save(Collections.EMPTY_MAP);
	} catch (IOException e) {
		throw new CoreException(
				new Status(IStatus.ERROR, "org.occiware.clouddesigner.occi.xtext.ui", "Failed to save", e));
	}
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:28,代码来源:OCCIDocumentProvider.java


注:本文中的org.eclipse.emf.ecore.resource.ResourceSet.createResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。