Class CompileEvent

  • All Implemented Interfaces:
    ExtensionEvent

    public class CompileEvent
    extends java.lang.Object
    implements ExtensionEvent
    This class encapsulates compiler events. It allows an extension writer to know when a compilation starts and finishes, whether it succeeds or fails, and what warnings or errors are generated.
    Author:
    Damiano Bolla, University of Kent at Canterbury, 2003
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  CompileEvent.EventType
      Types of compilation events.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getErrorLineNumber()
      Returns the line number where the compilation error occurs.
      java.lang.String getErrorMessage()
      Returns the error message generated by the compiler.
      int[] getErrorPosition()
      Gets the error position.
      CompileEvent.EventType getEventType()
      Returns the eventType associated with this CompileEvent
      java.io.File[] getFiles()
      Returns the files related to this event.
      boolean isUserGeneratedCompilation()
      Returns an indicator for user or BlueJ generated compilation.
      void setErrorLineNumber​(int aLineNumber)
      Sets the line number where an error or warning occurred.
      void setErrorMessage​(java.lang.String anErrorMessage)
      Sets the error message for an error or warning event.
      void setErrorPosition​(int[] errorPosition)
      Sets the error position.
      java.lang.String toString()
      Returns a meaningful description of this event.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CompileEvent

        public CompileEvent​(CompileEvent.EventType eventType,
                            java.io.File[] aFileNames)
        Constructor to use for user-generated compilations.
        Parameters:
        eventType - one of the CompileEvent.EventType values for this CompileEvent.
        aFileNames - an array of File objects referring to the compiled files.
      • CompileEvent

        public CompileEvent​(CompileEvent.EventType eventType,
                            boolean isUserGeneratedCompilation,
                            java.io.File[] aFileNames)
        Parameters:
        eventType - one of the CompileEvent.EventType values for this CompileEvent.
        isUserGeneratedCompilation - a boolean indicating whether the compilation was triggered by the user (true) or by BlueJ (false).
        aFileNames - an array of File objects referring the compiled files.
    • Method Detail

      • getFiles

        public java.io.File[] getFiles()
        Returns the files related to this event. The array can be empty if no file are related to this event.
        Returns:
        The array of File objects referring to the compiled files related to this event.
      • setErrorLineNumber

        public void setErrorLineNumber​(int aLineNumber)
        Sets the line number where an error or warning occurred.
        Parameters:
        aLineNumber - a Line number to be associated with this CompileEvent.
      • setErrorPosition

        public void setErrorPosition​(int[] errorPosition)
        Sets the error position.
        Parameters:
        errorPosition - an array of four integers for this CompileEvent, containing the error position information: beginning line [0] and column [1], ending line [2] and column [3].
      • getErrorLineNumber

        public int getErrorLineNumber()
        Returns the line number where the compilation error occurs. Only valid in the case of an error or warning event.
      • getErrorPosition

        public int[] getErrorPosition()
        Gets the error position.
        Returns:
        An array of four integers containing the error position information: beginning line [0] and column [1], ending line [2] and column [3].
      • setErrorMessage

        public void setErrorMessage​(java.lang.String anErrorMessage)
        Sets the error message for an error or warning event.
        Parameters:
        anErrorMessage - an error message for this CompileEvent.
      • getErrorMessage

        public java.lang.String getErrorMessage()
        Returns the error message generated by the compiler. Only valid in the case of an error or warning event.
      • isUserGeneratedCompilation

        public boolean isUserGeneratedCompilation()
        Returns an indicator for user or BlueJ generated compilation. Two types of compilation can occur when using BlueJ. One is BlueJ-generated, an internal automatic check for errors, which does a full compilation (and thus will trigger these compile events), but discards the resulting class files. The other is a user-generated proper compilations which compile and keep the class files. This method lets the extension distinguish between the two.
        Returns:
        The boolean value indicating whether the compilation associated with this CompileEvent is user-generated (true) or BlueJ-generated (false).
      • toString

        public java.lang.String toString()
        Returns a meaningful description of this event.
        Overrides:
        toString in class java.lang.Object