Interface ModelRepository


@NonNullByDefault public interface ModelRepository
The model repository stores the configuration files (EMF models). It takes care of loading these resources and serving them to clients. By this abstraction, the clients do not need to know where the models come from.
Author:
Kai Kreuzer - Initial contribution, Laurent Garnier - Added methods generateFileFormat and createIsolatedModel
  • Method Details

    • getModel

      @Nullable org.eclipse.emf.ecore.EObject getModel(String name)
      Returns a model of a given name
      Parameters:
      name - name of the requested model
      Returns:
      the model or null, if not found
    • addOrRefreshModel

      boolean addOrRefreshModel(String name, InputStream inputStream)
      Adds a model to the repository or refreshes it if it already exists
      Parameters:
      name - the model name to add/refresh
      inputStream - an input stream with the model's content, optional if the file already exists
      Returns:
      true, if it was successfully processed, false otherwise
    • removeModel

      boolean removeModel(String name)
      Removes a model from the repository
      Parameters:
      name - the name of the model to remove
      Returns:
      true, if model was removed, false, if it did not exist
    • getAllModelNamesOfType

      Iterable<String> getAllModelNamesOfType(String modelType)
      Returns all names of models of a given type (file extension)
      Parameters:
      modelType - the model type to get the names for
      Returns:
      all names of available models
    • reloadAllModelsOfType

      void reloadAllModelsOfType(String modelType)
      Reload and parse all models of the given type
      Parameters:
      modelType - the model type to reload
    • removeAllModelsOfType

      Set<String> removeAllModelsOfType(String modelType)
      Remove all models of the given type
      Parameters:
      modelType - the model type to remove
      Returns:
      all names of the removed models
    • addModelRepositoryChangeListener

      void addModelRepositoryChangeListener(ModelRepositoryChangeListener listener)
      Adds a change listener
      Parameters:
      listener - the listener to add
    • removeModelRepositoryChangeListener

      void removeModelRepositoryChangeListener(ModelRepositoryChangeListener listener)
      Removes a change listener
      Parameters:
      listener - the listener to remove
    • createIsolatedModel

      @Nullable String createIsolatedModel(String modelType, InputStream inputStream, List<String> errors, List<String> warnings)
      Creates an isolated model in the repository An isolated model is a temporary model loaded without impacting any object registry.
      Parameters:
      modelType - the model type
      inputStream - an input stream with the model's content
      errors - the list to be used to fill the errors
      warnings - the list to be used to fill the warnings
      Returns:
      the created model name if it was successfully processed, null otherwise
    • generateFileFormat

      void generateFileFormat(OutputStream out, String modelType, org.eclipse.emf.ecore.EObject modelContent)
      Generate the DSL file format from a provided model type and model content.
      Parameters:
      out - the output stream to write the generated syntax to
      modelType - the model type
      modelContent - the content of the model