本文整理匯總了Java中org.eclipse.emf.ecore.resource.impl.ResourceSetImpl類的典型用法代碼示例。如果您正苦於以下問題:Java ResourceSetImpl類的具體用法?Java ResourceSetImpl怎麽用?Java ResourceSetImpl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ResourceSetImpl類屬於org.eclipse.emf.ecore.resource.impl包,在下文中一共展示了ResourceSetImpl類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getProfile
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的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: Validate
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的package包/類
public Validate()
{
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("calender", new XMIResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
Resource r = rs.getResource(URI.createFileURI("model/mynew.calender"), true);
EObject root = r.getContents().get(0);
Iterator<EObject> i = r.getAllContents();
while(i.hasNext())
System.out.println(i.next());
}
示例3: isModel
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的package包/類
protected boolean isModel(IAdaptable receiver){
IFile modelFile = (IFile)(receiver).getAdapter(IFile.class);
if(modelFile !=null){
ResourceSet rs = new ResourceSetImpl();
URI modelURI = URI.createURI("platform:/resource/"+modelFile.getFullPath().toString());
try{
Resource resource = rs.getResource(modelURI, true);
if (resource != null) {
return true;
}
} catch (Exception e){
// not a valid model, simply ignore
return false;
}
}
return false;
}
示例4: loadGenmodel
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的package包/類
private GenModel loadGenmodel(String path) {
try {
if (!EPackage.Registry.INSTANCE.containsKey(GenModelPackage.eNS_URI))
EPackage.Registry.INSTANCE.put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("genmodel", new XMIResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
URI uri = URI.createURI(path);
Resource pkg = rs.getResource(uri, true);
return (GenModel) pkg.getContents().get(0);
} catch (Exception e) {
// ...
}
return null;
}
示例5: setChartConfiguration
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的package包/類
public void setChartConfiguration ( final Chart chart )
{
if ( chart == null )
{
this.viewer.setInput ( null );
}
else
{
if ( chart.eResource () == null )
{
final ResourceSetImpl rs = new ResourceSetImpl ();
final Resource r = rs.createResource ( URI.createURI ( "urn:dummy" ) );
r.getContents ().add ( chart );
}
if ( chart.eResource ().getURI () == null )
{
chart.eResource ().setURI ( URI.createURI ( "urn:dummy" ) );
}
this.viewer.setInput ( chart.eResource () );
}
}
示例6: loadConfiguraton
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的package包/類
public static Chart loadConfiguraton ( final String configurationUri )
{
if ( configurationUri == null || configurationUri.isEmpty () )
{
return null;
}
// load
ChartPackage.eINSTANCE.eClass ();
final ResourceSet resourceSet = new ResourceSetImpl ();
resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMIResourceFactoryImpl () ); //$NON-NLS-1$
final Resource resource = resourceSet.getResource ( URI.createURI ( configurationUri ), true );
for ( final EObject o : resource.getContents () )
{
if ( o instanceof Chart )
{
return (Chart)o;
}
}
return null;
}
示例7: load
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的package包/類
private void load ()
{
logger.info ( "Loading: {}", this.uri ); //$NON-NLS-1$
final ResourceSet resourceSet = new ResourceSetImpl ();
resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMIResourceFactoryImpl () ); //$NON-NLS-1$
final URI file = URI.createURI ( this.uri );
final Resource resource = resourceSet.getResource ( file, true );
for ( final EObject o : resource.getContents () )
{
if ( o instanceof View )
{
createView ( (View)o );
}
}
}
示例8: startServer
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的package包/類
public Collection<? extends ServerDescriptor> startServer ( final URI exporterFileUri, final String locationLabel ) throws CoreException
{
final ResourceSetImpl resourceSet = new ResourceSetImpl ();
resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ExporterResourceFactoryImpl () );
final Resource resource = resourceSet.createResource ( exporterFileUri );
try
{
resource.load ( null );
}
catch ( final IOException e )
{
throw new CoreException ( StatusHelper.convertStatus ( HivesPlugin.PLUGIN_ID, "Failed to load configuration", e ) );
}
final DocumentRoot root = (DocumentRoot)EcoreUtil.getObjectByType ( resource.getContents (), ExporterPackage.Literals.DOCUMENT_ROOT );
if ( root == null )
{
throw new CoreException ( new Status ( IStatus.ERROR, HivesPlugin.PLUGIN_ID, "Failed to locate exporter configuration in: " + exporterFileUri ) );
}
return startServer ( root, locationLabel );
}
示例9: getProfile
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的package包/類
/**
* @generated NOT
*/
@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;
}
示例10: patchProfile
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的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 );
}
示例11: load
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的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 ) );
}
示例12: getProfile
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的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;
}
示例13: parse
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的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 ();
}
}
示例14: getEcoreModel
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的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;
}
示例15: EcoreResource
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //導入依賴的package包/類
public EcoreResource(File typeTarget, File instanceTarget) {
this.m_resourceSet = new ResourceSetImpl();
this.m_resourceSet.getResourceFactoryRegistry()
.getExtensionToFactoryMap()
.put("*", new XMIResourceFactoryImpl());
this.m_typeFile = typeTarget;
this.m_instanceFile = instanceTarget;
if (this.m_typeFile == this.m_instanceFile || this.m_typeFile == null
|| this.m_instanceFile == null) {
this.relPath = "";
} else {
this.relPath =
groove.io.Util.getRelativePath(new File(this.m_instanceFile.getAbsoluteFile()
.getParent()), this.m_typeFile.getAbsoluteFile())
.toString();
}
}