Class Message

java.lang.Object
net.ssehub.easy.basics.messages.Message
net.ssehub.easy.dslCore.translation.Message
All Implemented Interfaces:
net.ssehub.easy.basics.messages.IMessage

public class Message extends net.ssehub.easy.basics.messages.Message
Implements a message issues by the model translator (in order to provide feedback on multiple issues at once).
Author:
Holger Eichelberger
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    Represents an issue location.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private org.eclipse.emf.ecore.EObject
    Stores the ECore element causing the error.
    private org.eclipse.emf.ecore.EStructuralFeature
    Stores the (sub-)feature of cause.
    private int
    A code representing the message.
    static final int
    Defines the code used for messages which can be ignored.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Message(String message, net.ssehub.easy.basics.messages.Status status, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature, int code)
    Creates a message object.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static String
    fieldToString(Object obj, Class<?> cls, String field)
    Tries to obtain the value of the field field from obj as a String.
    private static String
    Tries to obtain the value of the field field from obj as a String.
    org.eclipse.emf.ecore.EObject
    Returns the cause of the message (in terms of the causing ECore element).
    org.eclipse.emf.ecore.EStructuralFeature
    Returns the causing feature (within getCause()).
    int
    Returns a code for the message.
     
    getLocationData(org.eclipse.emf.ecore.EObject obj, org.eclipse.emf.ecore.EStructuralFeature structuralFeature, int index)
    Returns the location for a given cause obj, structuralFeatue and index of the node within obj.
    getLocationForNode(org.eclipse.xtext.nodemodel.INode node)
    Returns the issue location for the given node.
    getLocationForNode(org.eclipse.xtext.nodemodel.INode node, int offset, int length)
    Computes the Message.IssueLocation for the given offset and length in the given node.
    boolean
    Returns whether this message can be ignored.

    Methods inherited from class net.ssehub.easy.basics.messages.Message

    containsError, getDescription, getStatus, toString

    Methods inherited from class java.lang.Object

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

    • CODE_IGNORE

      public static final int CODE_IGNORE
      Defines the code used for messages which can be ignored.
      See Also:
    • cause

      private org.eclipse.emf.ecore.EObject cause
      Stores the ECore element causing the error.
    • causingFeature

      private org.eclipse.emf.ecore.EStructuralFeature causingFeature
      Stores the (sub-)feature of cause.
    • code

      private int code
      A code representing the message.
      See Also:
  • Constructor Details

    • Message

      public Message(String message, net.ssehub.easy.basics.messages.Status status, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature, int code)
      Creates a message object.
      Parameters:
      message - the message text
      status - the message status
      cause - the ECore element causing the message
      causingFeature - the feature within cause
      code - a numerical code representing the message (see CODE_IGNORE)
  • Method Details

    • getCause

      public org.eclipse.emf.ecore.EObject getCause()
      Returns the cause of the message (in terms of the causing ECore element).
      Returns:
      the cause of the message
    • getCausingFeature

      public org.eclipse.emf.ecore.EStructuralFeature getCausingFeature()
      Returns the causing feature (within getCause()).
      Returns:
      the causing feature
    • getCode

      public int getCode()
      Returns a code for the message.
      Returns:
      the code
    • ignore

      public boolean ignore()
      Returns whether this message can be ignored.
      Returns:
      true if it can be ignored, false else
    • getDetailedDescription

      public String getDetailedDescription()
      Specified by:
      getDetailedDescription in interface net.ssehub.easy.basics.messages.IMessage
      Overrides:
      getDetailedDescription in class net.ssehub.easy.basics.messages.Message
    • getLocationForNode

      protected Message.IssueLocation getLocationForNode(org.eclipse.xtext.nodemodel.INode node)
      Returns the issue location for the given node.
      Parameters:
      node - the node to return the location for
      Returns:
      the issue location
    • getLocationForNode

      protected Message.IssueLocation getLocationForNode(org.eclipse.xtext.nodemodel.INode node, int offset, int length)
      Computes the Message.IssueLocation for the given offset and length in the given node.
      Parameters:
      node - the node
      offset - the text offset of the node
      length - the text length of the node
      Returns:
      the issue location
    • getLocationData

      protected Message.IssueLocation getLocationData(org.eclipse.emf.ecore.EObject obj, org.eclipse.emf.ecore.EStructuralFeature structuralFeature, int index)
      Returns the location for a given cause obj, structuralFeatue and index of the node within obj.
      Parameters:
      obj - the object to look into
      structuralFeature - the structural feature within obj
      index - the node index within obj, usually 0
      Returns:
      the location, may be the beginning of a document if the parse nodes cannot be found (may be null)
    • fieldToString

      private static String fieldToString(Object obj, String field)
      Tries to obtain the value of the field field from obj as a String.
      Parameters:
      obj - the object to query
      field - the name of the field to query
      Returns:
      the value of the field as String, may be null if field does not exist.
      See Also:
    • fieldToString

      private static String fieldToString(Object obj, Class<?> cls, String field)
      Tries to obtain the value of the field field from obj as a String.
      Parameters:
      obj - the object to query
      cls - the class of obj to use (immediate or parent)
      field - the name of the field to query
      Returns:
      the value of the field as String, may be null if field does not exist.