本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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 ) );
}
示例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 ();
}
}
示例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 ) );
}
示例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();
}
}
示例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);
}
示例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 ) );
}
示例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;
}