Class ModelTranslator<E extends ExpressionTranslator>

java.lang.Object
net.ssehub.easy.dslCore.translation.MessageReceiver
net.ssehub.easy.dslCore.translation.ModelTranslator<E>
Type Parameters:
E - the specific type of expression translator to be used
All Implemented Interfaces:
IMessageReceiver

public abstract class ModelTranslator<E extends ExpressionTranslator> extends MessageReceiver
A basic implementation of a model translator, i.e., a basic class for translating individual model elements into model instances. This class relies on an associated ExpressionTranslator.
Author:
Holger Eichelberger
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private E
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModelTranslator(E expressionTranslator)
    Creates a new model translator.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a message.
    void
    collect(net.ssehub.easy.basics.messages.IMessage message, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature, int code)
    Receives an EASy message.
    static <T> List<T>
    copy(List<T> objects)
    Copies a set of objects.
    void
    error(String message, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature, int code)
    Receives an error message.
    void
    error(org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic)
    Adds a diagnostic error, typically from a standalone parser configuration.
    int
    Returns the number of errors.
    protected E
    Returns the associated expression translator.
    getMessage(int index)
    Returns the specified message.
    int
    Returns the number of messages.
    static <T extends org.eclipse.emf.ecore.EObject>
    List<T>
    select(List<? extends org.eclipse.emf.ecore.EObject> objects, Class<T> type)
    Selects the given objects by type.
    void
    warning(String message, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature, int code)
    Receives a warning message.

    Methods inherited from class net.ssehub.easy.dslCore.translation.MessageReceiver

    error

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ModelTranslator

      public ModelTranslator(E expressionTranslator)
      Creates a new model translator.
      Parameters:
      expressionTranslator - the associated expression translator
  • Method Details

    • select

      public static <T extends org.eclipse.emf.ecore.EObject> List<T> select(List<? extends org.eclipse.emf.ecore.EObject> objects, Class<T> type)
      Selects the given objects by type.
      Type Parameters:
      T - the actual type of list entries
      Parameters:
      objects - the objects to be considered
      type - the type as selection criterion
      Returns:
      the selected objects being instance of type
    • copy

      public static <T> List<T> copy(List<T> objects)
      Copies a set of objects.
      Type Parameters:
      T - the actual type of list entries
      Parameters:
      objects - the objects to be copied (may be null)
      Returns:
      the copied instance (null if object is null)
    • getExpressionTranslator

      protected E getExpressionTranslator()
      Returns the associated expression translator.
      Returns:
      the expression translator
    • getMessageCount

      public int getMessageCount()
      Description copied from class: MessageReceiver
      Returns the number of messages.
      Specified by:
      getMessageCount in class MessageReceiver
      Returns:
      the number of messages
    • getErrorCount

      public int getErrorCount()
      Description copied from class: MessageReceiver
      Returns the number of errors.
      Specified by:
      getErrorCount in class MessageReceiver
      Returns:
      the number of errors
    • getMessage

      public Message getMessage(int index)
      Description copied from class: MessageReceiver
      Returns the specified message.
      Specified by:
      getMessage in class MessageReceiver
      Parameters:
      index - the position of the message to be returned
      Returns:
      the specified message
    • error

      public void error(String message, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature, int code)
      Description copied from interface: IMessageReceiver
      Receives an error message.
      Parameters:
      message - the message
      cause - the cause (as instance of the EMF grammar model)
      causeFeature - the cause of the feature as an appropriate constant from the generated grammar
      code - a numerical identification of the error
    • warning

      public void warning(String message, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature, int code)
      Description copied from interface: IMessageReceiver
      Receives a warning message.
      Parameters:
      message - the message
      cause - the cause (as instance of the EMF grammar model)
      causeFeature - the cause of the feature as an appropriate constant from the generated grammar
      code - a numerical identification of the warning
    • collect

      public void collect(net.ssehub.easy.basics.messages.IMessage message, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature, int code)
      Description copied from interface: IMessageReceiver
      Receives an EASy message. This allows re-directing the message while keeping the relation to the original one, e.g., for cleaning up messages.
      Parameters:
      message - the message
      cause - the cause (as instance of the EMF grammar model)
      causeFeature - the cause of the feature as an appropriate constant from the generated grammar
      code - a numerical identification of the error
    • error

      public void error(org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic)
      Adds a diagnostic error, typically from a standalone parser configuration.
      Specified by:
      error in class MessageReceiver
      Parameters:
      diagnostic - the diagnostic to be added
    • addMessage

      public void addMessage(Message msg)
      Adds a message.
      Specified by:
      addMessage in class MessageReceiver
      Parameters:
      msg - the message to be added