org.electrocodeogram.cpc.core.api.hub.event
Class EclipseEvent

java.lang.Object
  extended by org.electrocodeogram.cpc.core.api.hub.event.CPCEvent
      extended by org.electrocodeogram.cpc.core.api.hub.event.EclipseEvent
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<CPCEvent>
Direct Known Subclasses:
EclipseCodeDiffEvent, EclipseCutCopyPasteEvent, EclipseEditorPartEvent, EclipseFileAccessEvent, EclipseFileChangeEvent, EclipseFileModifiedEvent, EclipseResourcePersistenceEvent, EclipseTeamEvent

public abstract class EclipseEvent
extends CPCEvent

Abstract parent class for all CPC Events which are created by Eclipse sensors.

Author:
vw
See Also:
CPCEvent

Field Summary
protected  boolean fileLocatedInWorkspace
           
protected  boolean fileLocatedInWorkspaceCached
           
protected  java.lang.String filePath
           
protected  java.lang.String project
           
protected  boolean supportedFile
           
protected  boolean supportedFileCached
           
protected  java.lang.String user
           
 
Constructor Summary
EclipseEvent(java.lang.String user, java.lang.String project)
          Creates a new EclipseEvent instance.
 
Method Summary
 java.lang.String getFilePath()
          Retrieves the project relative file path for this event.
 java.lang.String getProject()
          Retrieves the project name for this event.
 java.lang.String getUser()
          Retrieves username of the currently logged in user.
 boolean isFileLocatedInWorkspace()
          Caching convenience method which yields the same result as CoreFileUtils.isFileLocatedInWorkspace(String, String).
 boolean isSupportedFile()
          Caching convenience method which yields the same result as CoreConfigurationUtils.isSupportedFile(String, String).
 boolean isValid()
          Checks if this event has been fully initialised.
 void setFilePath(java.lang.String filePath)
          Sets the project relative file path for this event.
protected  java.lang.String subToString()
          Can be called by sub classes in order to obtain a string which can be included in their toString() output.
 
Methods inherited from class org.electrocodeogram.cpc.core.api.hub.event.CPCEvent
checkSeal, clone, compareTo, getCreationTime, seal, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

user

protected java.lang.String user

project

protected java.lang.String project

filePath

protected java.lang.String filePath

supportedFile

protected boolean supportedFile

supportedFileCached

protected boolean supportedFileCached

fileLocatedInWorkspace

protected boolean fileLocatedInWorkspace

fileLocatedInWorkspaceCached

protected boolean fileLocatedInWorkspaceCached
Constructor Detail

EclipseEvent

public EclipseEvent(java.lang.String user,
                    java.lang.String project)
Creates a new EclipseEvent instance.

Parameters:
user - username of current user, never null.
project - name of project, never null.
Method Detail

getUser

public java.lang.String getUser()
Retrieves username of the currently logged in user.

Returns:
username of current user, never null.

getProject

public java.lang.String getProject()
Retrieves the project name for this event.

Returns:
project name, never null.

getFilePath

public java.lang.String getFilePath()
Retrieves the project relative file path for this event.

Returns:
path to file, relative to project, never null

setFilePath

public void setFilePath(java.lang.String filePath)
Sets the project relative file path for this event.

Parameters:
filePath - project relative file path, never null.

isSupportedFile

public boolean isSupportedFile()
Caching convenience method which yields the same result as CoreConfigurationUtils.isSupportedFile(String, String).
However, the value is only calculated once, on first call of this method and is than reused for all further calls.

This method is thread safe.

Returns:
true if the file is a supported source file, false otherwise.
See Also:
CoreConfigurationUtils.isSupportedFile(String, String)

isFileLocatedInWorkspace

public boolean isFileLocatedInWorkspace()
Caching convenience method which yields the same result as CoreFileUtils.isFileLocatedInWorkspace(String, String).
However, the value is only calculated once, on first call of this method and is than reused for all further calls.

Returns:
true if the file exists and is located within the workspace, false otherwise.
See Also:
CoreFileUtils.isFileLocatedInWorkspace(String, String)

isValid

public boolean isValid()
Description copied from class: CPCEvent
Checks if this event has been fully initialised.
Will return false if one of the mandatory fields of the event has not yet been filled out.

Subclasses should override this method but should never return true. Instead they should delegate to the super class implementation once all validity checks on their level have passed.

The CPCEvent.isValid() implementation always returns true.

Overrides:
isValid in class CPCEvent
Returns:
true if this event is valid, false otherwise.
See Also:
IEventHubRegistry.dispatch(CPCEvent)

subToString

protected java.lang.String subToString()
Can be called by sub classes in order to obtain a string which can be included in their toString() output.

Returns:
string representation of the values of this class, never null.