org.eclipse.gmt.weaver.plugin.util
Class WeaverResourceUtil

java.lang.Object
  extended by org.eclipse.gmt.weaver.plugin.util.WeaverResourceUtil

public class WeaverResourceUtil
extends java.lang.Object

This class contains convenient static methods for managing resource

Since:
1.0

Constructor Summary
WeaverResourceUtil()
           
 
Method Summary
static java.io.InputStream addListOfStreams(java.util.List inputStreams)
          returns a unique stream starting from a list of stream
static java.io.InputStream addStream(java.io.InputStream stream1, java.io.InputStream stream2)
          Adds stream1 and stream2 and return stream result
static java.lang.String getFullPath(java.lang.String fileStr)
          returns the full path of a file, given its relative path
static int getModelFormat(java.lang.String filename)
          Returns the format (extension) of model file
static org.eclipse.emf.ecore.resource.ResourceSet initializeResourceSet(java.util.List resourceSets, org.eclipse.emf.common.util.URI uri)
          Initializes a resource using a uri The uri corresponds to the to the reference ou the ressource in the resource set
static org.eclipse.emf.ecore.resource.ResourceSet initializeResourceSet(org.eclipse.emf.ecore.resource.ResourceSet rsMM, org.eclipse.emf.ecore.resource.Resource resIfNul, java.lang.String file, org.eclipse.emf.common.util.URI uri)
          Initializes a resource with a file The uri corresponds to the to the reference ou the ressource in the resource set
static org.eclipse.emf.ecore.resource.ResourceSet initializeResourceSet(java.lang.String file, org.eclipse.emf.common.util.URI uri)
          Initializes a resource with a file The uri corresponds to the to the reference ou the ressource in the resource set
static org.eclipse.emf.ecore.resource.Resource initResource(org.eclipse.emf.ecore.resource.Resource resource)
          registers the package in the package registry and associates the instance class name for every primitive type
static org.eclipse.emf.ecore.resource.Resource km3Stream2EcoreResource(java.io.InputStream km3Stream, java.lang.String ecoreFile)
          Returns an associated xmi resource based on a KM3 file (make transformation)
static java.util.List loadKm3ExtensionStreamList(java.util.List extensionFiles, java.util.List localExtensionFiles)
          Returns a List of InputStream with all km3 files extension
static void refreshResourceFolder(org.eclipse.emf.ecore.resource.Resource res)
          Refreshes the folder of the resource.
static org.eclipse.emf.ecore.resource.Resource registerResource(org.eclipse.emf.ecore.resource.Resource resource)
          registers the package in the package registry
static void validateWeavingMetamodelSemantic(org.eclipse.emf.ecore.resource.Resource weavingMetaModel)
          Validate semantic of weaving metamodel if error found, throw an exception
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeaverResourceUtil

public WeaverResourceUtil()
Method Detail

getFullPath

public static java.lang.String getFullPath(java.lang.String fileStr)
returns the full path of a file, given its relative path

Parameters:
fileStr -
Returns:

registerResource

public static org.eclipse.emf.ecore.resource.Resource registerResource(org.eclipse.emf.ecore.resource.Resource resource)
registers the package in the package registry

Parameters:
resource -

initResource

public static org.eclipse.emf.ecore.resource.Resource initResource(org.eclipse.emf.ecore.resource.Resource resource)
registers the package in the package registry and associates the instance class name for every primitive type

Parameters:
resource -

initializeResourceSet

public static org.eclipse.emf.ecore.resource.ResourceSet initializeResourceSet(java.lang.String file,
                                                                               org.eclipse.emf.common.util.URI uri)
                                                                        throws java.io.IOException,
                                                                               WeaverException
Initializes a resource with a file The uri corresponds to the to the reference ou the ressource in the resource set

Parameters:
file -
uri -
Returns:
Throws:
java.io.IOException
WeaverException

initializeResourceSet

public static org.eclipse.emf.ecore.resource.ResourceSet initializeResourceSet(org.eclipse.emf.ecore.resource.ResourceSet rsMM,
                                                                               org.eclipse.emf.ecore.resource.Resource resIfNul,
                                                                               java.lang.String file,
                                                                               org.eclipse.emf.common.util.URI uri)
                                                                        throws java.io.IOException,
                                                                               WeaverException
Initializes a resource with a file The uri corresponds to the to the reference ou the ressource in the resource set

Parameters:
rsMM - the resource set of the metamodel
file -
uri -
Returns:
Throws:
java.io.IOException
WeaverException

initializeResourceSet

public static org.eclipse.emf.ecore.resource.ResourceSet initializeResourceSet(java.util.List resourceSets,
                                                                               org.eclipse.emf.common.util.URI uri)
                                                                        throws java.io.IOException,
                                                                               WeaverException
Initializes a resource using a uri The uri corresponds to the to the reference ou the ressource in the resource set

Parameters:
uri -
Returns:
Throws:
java.io.IOException
WeaverException

getModelFormat

public static int getModelFormat(java.lang.String filename)
Returns the format (extension) of model file

Parameters:
filename -
Returns:

addStream

public static java.io.InputStream addStream(java.io.InputStream stream1,
                                            java.io.InputStream stream2)
Adds stream1 and stream2 and return stream result

Parameters:
stream1 -
stream2 -
Returns:
a SequenceInputStream of stream1 and stream2

addListOfStreams

public static java.io.InputStream addListOfStreams(java.util.List inputStreams)
                                            throws WeaverException
returns a unique stream starting from a list of stream

Parameters:
inputStreams -
Returns:
Throws:
WeaverException
WeaverException

km3Stream2EcoreResource

public static org.eclipse.emf.ecore.resource.Resource km3Stream2EcoreResource(java.io.InputStream km3Stream,
                                                                              java.lang.String ecoreFile)
                                                                       throws WeaverException
Returns an associated xmi resource based on a KM3 file (make transformation)

Parameters:
km3Stream -
ecoreFile -
Returns:
Throws:
WeaverException

loadKm3ExtensionStreamList

public static java.util.List loadKm3ExtensionStreamList(java.util.List extensionFiles,
                                                        java.util.List localExtensionFiles)
                                                 throws WeaverException
Returns a List of InputStream with all km3 files extension

Parameters:
extensionFiles - the extensions of metamodel in the extension plugin
localExtensionFiles -
Returns:
the extensions of metamodel in the workspace
Throws:
WeaverException

validateWeavingMetamodelSemantic

public static void validateWeavingMetamodelSemantic(org.eclipse.emf.ecore.resource.Resource weavingMetaModel)
                                             throws WeaverException
Validate semantic of weaving metamodel if error found, throw an exception

Parameters:
weavingMetaModel -
Throws:
WeaverException

refreshResourceFolder

public static void refreshResourceFolder(org.eclipse.emf.ecore.resource.Resource res)
Refreshes the folder of the resource. Used when a new file is created in the folder of the current resource and when it does not appears immediately. for instance, the (amw.prop) property file

Parameters:
res - A resource