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


Java Resource.load方法代码示例

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


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

示例1: getProfile

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
@Override
public Profile getProfile ()
{
    if ( this.profile == null )
    {
        final ResourceSet rs = new ResourceSetImpl ();
        final Resource r = rs.createResource ( URI.createURI ( DEFAULT_URI ) );
        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,代码来源:ArduinoDriverImpl.java

示例2: loadPackage

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的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

示例3: loadPackage

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的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,代码来源:COSEMPackageImpl.java

示例4: getProfile

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的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

示例5: read

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<T> read(final URI uri) throws IOException {
  final Resource res = this.getResourceSet().createResource(uri);

  if (res == null) {
    return new ArrayList<T>();
  }
  res.load(null);
  final EList<EObject> contents = res.getContents();

  final List<T> list = new ArrayList<T>();
  for (final EObject content : contents) {

    try {
      list.add((T) content);
    } catch (final Exception e) {
      throw new RuntimeException("Unexpected resource type.");
    }
  }

  return list;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:23,代码来源:ModelIO.java

示例6: getEcoreModel

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
protected ResourceSet getEcoreModel(File ecorefile) {

        ResourceSetImpl rs = new ResourceSetImpl();
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
        try {
            URI fileUri = URI.createFileURI(ecorefile.getCanonicalPath());
            Resource resource = rs.createResource(fileUri);
            resource.load(null);
            EcoreUtil.resolveAll(resource);
            rs.getResources().add(resource);
            EcoreUtil.resolveAll(rs);

        } catch (IOException e) {
            e.printStackTrace();
        }
        return rs;
    }
 
开发者ID:datathings,项目名称:greycat-idea-plugin,代码行数:18,代码来源:PrettyPrinter.java

示例7: load

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的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: handleChangedResources

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * Handles what to do with changed resources on activation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void handleChangedResources ()
{
    if ( !changedResources.isEmpty () && ( !isDirty () || handleDirtyConflict () ) )
    {
        if ( isDirty () )
        {
            changedResources.addAll ( editingDomain.getResourceSet ().getResources () );
        }
        editingDomain.getCommandStack ().flush ();

        updateProblemIndication = false;
        for ( Resource resource : changedResources )
        {
            if ( resource.isLoaded () )
            {
                resource.unload ();
                try
                {
                    resource.load ( Collections.EMPTY_MAP );
                }
                catch ( IOException exception )
                {
                    if ( !resourceToDiagnosticMap.containsKey ( resource ) )
                    {
                        resourceToDiagnosticMap.put ( resource, analyzeResourceProblems ( resource, exception ) );
                    }
                }
            }
        }

        if ( AdapterFactoryEditingDomain.isStale ( editorSelection ) )
        {
            setSelection ( StructuredSelection.EMPTY );
        }

        updateProblemIndication = true;
        updateProblemIndication ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:46,代码来源:SetupEditor.java

示例9: createPipeline

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
private static CustomizationPipeline createPipeline ( 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 ( (CustomizationPipeline)r.getContents ().get ( 0 ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:8,代码来源:CreateProjectOperation.java

示例10: handleChangedResources

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * Handles what to do with changed resources on activation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void handleChangedResources() {
	if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
		if (isDirty()) {
			changedResources.addAll(editingDomain.getResourceSet().getResources());
		}
		editingDomain.getCommandStack().flush();

		updateProblemIndication = false;
		for (Resource resource : changedResources) {
			if (resource.isLoaded()) {
				resource.unload();
				try {
					resource.load(Collections.EMPTY_MAP);
				}
				catch (IOException exception) {
					if (!resourceToDiagnosticMap.containsKey(resource)) {
						resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
					}
				}
			}
		}

		if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
			setSelection(StructuredSelection.EMPTY);
		}

		updateProblemIndication = true;
		updateProblemIndication();
	}
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:37,代码来源:PlatformEditor.java

示例11: loadCompany

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * Load a company EObject from an .xmi
 */
public static Company loadCompany(String s) throws IOException {
	
	ResourceSet resourceSet = getResourceSet();

	// Use XMI resource
	Resource xmiResource = resourceSet.createResource(URI.createFileURI(s + ".xmi"));
	xmiResource.load(null);
	return (Company)xmiResource.getContents().get(0);
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:13,代码来源:Serialization.java

示例12: createSelector

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的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: loadModelURI

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public static Resource loadModelURI(URI uri, ResourceSet rs) throws IOException {
	Resource res = rs.createResource(uri);
	res.load(null);
	EcoreUtil.resolveAll(rs);// IMPORTANT
	return res;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:7,代码来源:EMFUtil.java


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