org.eclipse.mylyn.monitor.core_3.7.1.v20120425-0100

16:46:46.243 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.monitor.core_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.monitor.core;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;

public abstract class AbstractMonitorLog
{
  protected File outputFile;
  protected FileOutputStream outputStream;
  protected boolean started = false;
  
  public void startMonitoring()
  {
    synchronized (this)
    {
      if (started) {
        return;
      }
      started = true;
    }
    try
    {
      if (!outputFile.exists()) {
        outputFile.createNewFile();
      }
      outputStream = new FileOutputStream(outputFile, true);
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.monitor.core", "Could not log to file: " + 
        outputFile.getAbsolutePath(), e));
    }
  }
  
  public void stopMonitoring()
  {
    try
    {
      if (outputStream != null)
      {
        outputStream.flush();
        outputStream.close();
      }
      started = false;
    }
    catch (IOException e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.monitor.core", 
        "Could not close interaction event stream", e));
    }
  }
  
  public File moveOutputFile(String newPath)
  {
    stopMonitoring();
    File newFile = new File(newPath);
    try
    {
      if ((outputFile.exists()) && (!newFile.exists()))
      {
        outputFile.renameTo(newFile);
      }
      else if (!newFile.exists())
      {
        newFile.createNewFile();
        outputFile.delete();
      }
      else
      {
        outputFile.delete();
      }
      outputFile = newFile;
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.monitor.core", 
        "Could not set logger output file", e));
    }
    startMonitoring();
    return newFile;
  }
  
  public File getOutputFile()
  {
    return outputFile;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.monitor.core.AbstractMonitorLog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.monitor.core;

public abstract interface IInteractionEventListener
{
  public abstract void interactionObserved(InteractionEvent paramInteractionEvent);
  
  public abstract void startMonitoring();
  
  public abstract void stopMonitoring();
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.monitor.core.IInteractionEventListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.monitor.core;

import java.util.Calendar;
import java.util.Date;
import org.eclipse.core.runtime.Assert;

public class InteractionEvent
{
  private final Kind kind;
  private final Date date;
  private final Date endDate;
  private final String originId;
  private final String structureKind;
  private final String structureHandle;
  private final String navigation;
  private final String delta;
  private final float interestContribution;
  public static final String ID_UNKNOWN = "?";
  
  public static enum Kind
  {
    SELECTION,  EDIT,  COMMAND,  PREFERENCE,  PREDICTION,  PROPAGATION,  MANIPULATION,  ATTENTION;
    
    public boolean isUserEvent()
    {
      return (this == SELECTION) || (this == EDIT) || (this == COMMAND) || (this == PREFERENCE);
    }
    
    public String toString()
    {
      switch (this)
      {
      case ATTENTION: 
        return "selection";
      case COMMAND: 
        return "edit";
      case EDIT: 
        return "command";
      case MANIPULATION: 
        return "preference";
      case PREDICTION: 
        return "prediction";
      case PREFERENCE: 
        return "propagation";
      case PROPAGATION: 
        return "manipulation";
      case SELECTION: 
        return "attention";
      }
      return "null";
    }
    
    public static Kind fromString(String string)
    {
      if (string == null) {
        return null;
      }
      if (string.equals("selection")) {
        return SELECTION;
      }
      if (string.equals("edit")) {
        return EDIT;
      }
      if (string.equals("command")) {
        return COMMAND;
      }
      if (string.equals("preference")) {
        return PREFERENCE;
      }
      if (string.equals("prediction")) {
        return PREDICTION;
      }
      if (string.equals("propagation")) {
        return PROPAGATION;
      }
      if (string.equals("manipulation")) {
        return MANIPULATION;
      }
      if (string.equals("attention")) {
        return ATTENTION;
      }
      return null;
    }
  }
  
  public InteractionEvent(Kind kind, String structureKind, String handle, String originId)
  {
    this(kind, structureKind, handle, originId, 1.0F);
  }
  
  public InteractionEvent(Kind kind, String structureKind, String handle, String originId, String navigatedRelation)
  {
    this(kind, structureKind, handle, originId, navigatedRelation, "null", 1.0F);
  }
  
  public InteractionEvent(Kind kind, String structureKind, String handle, String originId, String navigatedRelation, float interestContribution)
  {
    this(kind, structureKind, handle, originId, navigatedRelation, "null", interestContribution);
  }
  
  public static InteractionEvent makeCommand(String originId, String delta)
  {
    return new InteractionEvent(Kind.COMMAND, "null", "null", originId, "null", delta, 1.0F);
  }
  
  public static InteractionEvent makeCopy(InteractionEvent originalEvent, float newInterestContribution)
  {
    return new InteractionEvent(originalEvent.getKind(), originalEvent.getStructureKind(), 
      originalEvent.getStructureHandle(), originalEvent.getOriginId(), originalEvent.getNavigation(), 
      originalEvent.getDelta(), newInterestContribution, originalEvent.getDate(), originalEvent.getEndDate());
  }
  
  public static InteractionEvent makePreference(String originId, String delta)
  {
    return new InteractionEvent(Kind.PREFERENCE, "null", "null", originId, "null", delta, 1.0F);
  }
  
  public InteractionEvent(Kind kind, String structureKind, String handle, String originId, float interestContribution)
  {
    this(kind, structureKind, handle, originId, "null", "null", interestContribution);
  }
  
  public InteractionEvent(Kind kind, String structureKind, String handle, String originId, String navigatedRelation, String delta, float interestContribution)
  {
    this(kind, structureKind, handle, originId, navigatedRelation, delta, interestContribution, Calendar.getInstance().getTime());
  }
  
  private InteractionEvent(Kind kind, String structureKind, String handle, String originId, String navigatedRelation, String delta, float interestContribution, Date startDate)
  {
    this(kind, structureKind, handle, originId, navigatedRelation, delta, interestContribution, startDate, startDate);
  }
  
  public InteractionEvent(Kind kind, String structureKind, String handle, String originId, String navigatedRelation, String delta, float interestContribution, Date startDate, Date endDate)
  {
    Assert.isNotNull(kind);
    Assert.isNotNull(originId);
    Assert.isNotNull(startDate);
    Assert.isNotNull(endDate);
    this.kind = kind;
    this.structureKind = (structureKind != null ? structureKind.intern() : null);
    structureHandle = (handle != null ? handle.intern() : null);
    this.originId = originId.intern();
    navigation = (navigatedRelation != null ? navigatedRelation.intern() : null);
    this.delta = (delta != null ? delta.intern() : null);
    this.interestContribution = interestContribution;
    date = startDate;
    this.endDate = endDate;
  }
  
  public boolean equals(Object object)
  {
    if ((object == null) || (!(object instanceof InteractionEvent))) {
      return false;
    }
    InteractionEvent event = (InteractionEvent)object;
    
    return (date == null ? date == null : date.equals(date)) && (endDate == null ? endDate == null : endDate.equals(endDate)) && (kind == null ? kind == null : kind.equals(kind)) && (structureKind == null ? structureKind == null : structureKind.equals(structureKind)) && (structureHandle == null ? structureHandle == null : structureHandle.equals(structureHandle)) && (originId == null ? originId == null : originId.equals(originId)) && (navigation == null ? navigation == null : navigation.equals(navigation)) && (delta == null ? delta == null : delta.equals(delta)) && (interestContribution == interestContribution);
  }
  
  public int hashCode()
  {
    int hashCode = 0;
    if (date != null) {
      hashCode += date.hashCode();
    }
    if (endDate != null) {
      hashCode += endDate.hashCode();
    }
    if (kind != null) {
      hashCode += kind.hashCode();
    }
    if (structureKind != null) {
      hashCode += structureKind.hashCode();
    }
    if (structureHandle != null) {
      hashCode += structureHandle.hashCode();
    }
    if (originId != null) {
      hashCode += originId.hashCode();
    }
    if (navigation != null) {
      hashCode += navigation.hashCode();
    }
    if (delta != null) {
      hashCode += delta.hashCode();
    }
    hashCode += new Float(interestContribution).hashCode();
    return hashCode;
  }
  
  public String toString()
  {
    return 
      "(date: " + date + ", kind: " + kind + ", sourceHandle: " + structureHandle + ", origin: " + originId + ", delta: " + delta + ")";
  }
  
  public boolean isValidStructureHandle()
  {
    return (structureHandle != null) && (!structureHandle.equals("null")) && (!structureHandle.trim().equals("?"));
  }
  
  public String getStructureHandle()
  {
    return structureHandle;
  }
  
  public String getStructureKind()
  {
    return structureKind;
  }
  
  public Date getDate()
  {
    return date;
  }
  
  public String getDelta()
  {
    return delta;
  }
  
  public Kind getKind()
  {
    return kind;
  }
  
  public String getOriginId()
  {
    return originId;
  }
  
  public float getInterestContribution()
  {
    return interestContribution;
  }
  
  public Date getEndDate()
  {
    return endDate;
  }
  
  public String getNavigation()
  {
    return navigation;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.monitor.core.InteractionEvent
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.monitor.core;

public enum InteractionEvent$Kind
{
  SELECTION,  EDIT,  COMMAND,  PREFERENCE,  PREDICTION,  PROPAGATION,  MANIPULATION,  ATTENTION;
  
  public boolean isUserEvent()
  {
    return (this == SELECTION) || (this == EDIT) || (this == COMMAND) || (this == PREFERENCE);
  }
  
  public String toString()
  {
    switch (this)
    {
    case ATTENTION: 
      return "selection";
    case COMMAND: 
      return "edit";
    case EDIT: 
      return "command";
    case MANIPULATION: 
      return "preference";
    case PREDICTION: 
      return "prediction";
    case PREFERENCE: 
      return "propagation";
    case PROPAGATION: 
      return "manipulation";
    case SELECTION: 
      return "attention";
    }
    return "null";
  }
  
  public static Kind fromString(String string)
  {
    if (string == null) {
      return null;
    }
    if (string.equals("selection")) {
      return SELECTION;
    }
    if (string.equals("edit")) {
      return EDIT;
    }
    if (string.equals("command")) {
      return COMMAND;
    }
    if (string.equals("preference")) {
      return PREFERENCE;
    }
    if (string.equals("prediction")) {
      return PREDICTION;
    }
    if (string.equals("propagation")) {
      return PROPAGATION;
    }
    if (string.equals("manipulation")) {
      return MANIPULATION;
    }
    if (string.equals("attention")) {
      return ATTENTION;
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.monitor.core.InteractionEvent.Kind
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.monitor.core.InteractionEvent;

public class DataOverviewCollector
  implements IUsageCollector
{
  private static long FIVEMININMS = 300000L;
  private final Map<Integer, Integer> interactionHistorySizes = new HashMap();
  private final Map<Integer, List<Date>> interactionHistoryRanges = new HashMap();
  private final Map<Integer, Long> interactionHistoryActiveDuration = new HashMap();
  private int currentUser = -1;
  private InteractionEvent lastUserEvent;
  private static int startDatePosition = 0;
  private static int endDatePosition = 1;
  private String filePrefix = "";
  
  public DataOverviewCollector(String prefix)
  {
    filePrefix = prefix;
  }
  
  public String getReportTitle()
  {
    return Messages.DataOverviewCollector_Data_Overview;
  }
  
  public void consumeEvent(InteractionEvent event, int userId)
  {
    if (!interactionHistorySizes.containsKey(Integer.valueOf(userId))) {
      interactionHistorySizes.put(Integer.valueOf(userId), Integer.valueOf(0));
    }
    interactionHistorySizes.put(Integer.valueOf(userId), Integer.valueOf(((Integer)interactionHistorySizes.get(Integer.valueOf(userId))).intValue() + 1));
    if (!interactionHistoryRanges.containsKey(Integer.valueOf(userId)))
    {
      List<Date> dateRange = new ArrayList(2);
      interactionHistoryRanges.put(Integer.valueOf(userId), dateRange);
    }
    List<Date> dateRange = (List)interactionHistoryRanges.get(Integer.valueOf(userId));
    if (dateRange.size() == 0) {
      dateRange.add(event.getDate());
    } else if (dateRange.size() == 1) {
      dateRange.add(event.getDate());
    } else {
      dateRange.set(endDatePosition, event.getDate());
    }
    if ((currentUser == -1) || (currentUser != userId))
    {
      lastUserEvent = event;
      currentUser = userId;
    }
    long elapsed = event.getDate().getTime() - lastUserEvent.getDate().getTime();
    if (elapsed < FIVEMININMS)
    {
      if (!interactionHistoryActiveDuration.containsKey(Integer.valueOf(userId))) {
        interactionHistoryActiveDuration.put(Integer.valueOf(userId), new Long(0L));
      }
      interactionHistoryActiveDuration.put(Integer.valueOf(userId), Long.valueOf(((Long)interactionHistoryActiveDuration.get(Integer.valueOf(userId))).longValue() + elapsed));
    }
    lastUserEvent = event;
  }
  
  public List<String> getReport()
  {
    List<String> report = new ArrayList();
    report.add(Messages.DataOverviewCollector__h4_Data_Overview_h4_);
    report.add(Messages.DataOverviewCollector_Number_of_Users_ + interactionHistorySizes.keySet().size() + "<br>");
    for (Map.Entry<Integer, Integer> entry : interactionHistorySizes.entrySet())
    {
      report.add(entry.getKey() + ": " + entry.getValue() + Messages.DataOverviewCollector_events);
      report.add(InteractionEventClassifier.formatDuration(((Long)interactionHistoryActiveDuration.get(entry.getKey())).longValue()) + 
        Messages.DataOverviewCollector_active_use);
      List<Date> dateRange = (List)interactionHistoryRanges.get(entry.getKey());
      long duration = ((Date)dateRange.get(endDatePosition)).getTime() - ((Date)dateRange.get(startDatePosition)).getTime();
      report.add(MessageFormat.format(Messages.DataOverviewCollector_TO_PERIOD_OF_HOURS, new Object[] {
        dateRange.get(startDatePosition), dateRange.get(endDatePosition), 
        InteractionEventClassifier.formatDuration(duration) }));
      
      report.add("<br><br>");
    }
    return report;
  }
  
  public void exportAsCSVFile(String directory)
  {
    String filename = directory + File.separator + filePrefix + "baseLine.csv";
    try
    {
      BufferedWriter writer = new BufferedWriter(new FileWriter(new File(filename)));
      
      writer.write(Messages.DataOverviewCollector_CSV_USER);
      writer.write(",");
      writer.write(Messages.DataOverviewCollector_CSV_EVENTS);
      writer.write(",");
      writer.write(Messages.DataOverviewCollector_CSV_START);
      writer.write(",");
      writer.write(Messages.DataOverviewCollector_CSV_END);
      writer.write(",");
      writer.write(Messages.DataOverviewCollector_CSV_ACTIVE_USE);
      writer.write(",");
      writer.write(Messages.DataOverviewCollector_CSV_ELAPSED_USE);
      writer.newLine();
      for (Map.Entry<Integer, Integer> entry : interactionHistorySizes.entrySet())
      {
        writer.write(((Integer)entry.getKey()).toString());
        writer.write(",");
        writer.write(((Integer)entry.getValue()).toString());
        writer.write(",");
        List<Date> dateRange = (List)interactionHistoryRanges.get(entry.getKey());
        writer.write(((Date)dateRange.get(startDatePosition)).toString());
        writer.write(",");
        writer.write(((Date)dateRange.get(endDatePosition)).toString());
        writer.write(",");
        long elapsed = ((Long)interactionHistoryActiveDuration.get(entry.getKey())).longValue();
        writer.write(InteractionEventClassifier.formatDuration(elapsed));
        writer.write(",");
        long duration = ((Date)dateRange.get(endDatePosition)).getTime() - ((Date)dateRange.get(startDatePosition)).getTime();
        writer.write(InteractionEventClassifier.formatDuration(duration));
        writer.newLine();
      }
      writer.flush();
      writer.close();
    }
    catch (IOException e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.monitor.core", "Unable to write CVS file <" + 
        filename + ">", e));
    }
  }
  
  public long getActiveUseOfUser(int userid)
  {
    if (interactionHistoryActiveDuration.containsKey(Integer.valueOf(userid))) {
      return ((Long)interactionHistoryActiveDuration.get(Integer.valueOf(userid))).longValue();
    }
    return -1L;
  }
  
  public int getNumberOfUsers()
  {
    return interactionHistorySizes.size();
  }
  
  public long getDurationUseOfUser(int userid)
  {
    if (interactionHistoryRanges.containsKey(Integer.valueOf(userid)))
    {
      List<Date> dateRange = (List)interactionHistoryRanges.get(Integer.valueOf(userid));
      return ((Date)dateRange.get(endDatePosition)).getTime() - ((Date)dateRange.get(startDatePosition)).getTime();
    }
    return -1L;
  }
  
  public int getSizeOfHistory(int userid)
  {
    if (interactionHistorySizes.containsKey(Integer.valueOf(userid))) {
      return ((Integer)interactionHistorySizes.get(Integer.valueOf(userid))).intValue();
    }
    return -1;
  }
  
  public List<String> getPlainTextReport()
  {
    List<String> report = new ArrayList();
    report.add(Messages.DataOverviewCollector_Data_Overview);
    report.add(Messages.DataOverviewCollector_Number_of_Users_ + interactionHistorySizes.keySet().size());
    for (Map.Entry<Integer, Integer> entry : interactionHistorySizes.entrySet())
    {
      report.add(entry.getKey() + ": " + entry.getValue() + Messages.DataOverviewCollector_events);
      report.add(InteractionEventClassifier.formatDuration(((Long)interactionHistoryActiveDuration.get(entry.getKey())).longValue()) + 
        Messages.DataOverviewCollector_active_use);
      List<Date> dateRange = (List)interactionHistoryRanges.get(entry.getKey());
      long duration = ((Date)dateRange.get(endDatePosition)).getTime() - ((Date)dateRange.get(startDatePosition)).getTime();
      report.add(MessageFormat.format(Messages.DataOverviewCollector_TO_PERIOD_OF_HOURS, new Object[] {
        dateRange.get(startDatePosition), dateRange.get(endDatePosition), 
        InteractionEventClassifier.formatDuration(duration) }));
    }
    return report;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.DataOverviewCollector
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.mylyn.monitor.core.InteractionEvent;

public class DelegatingUsageCollector
  implements IUsageCollector
{
  protected List<IUsageScanner> scanners = new ArrayList();
  
  public void addScanner(IUsageScanner aScanner)
  {
    scanners.add(aScanner);
  }
  
  private List<IUsageCollector> delegates = new ArrayList();
  private String reportTitle = "";
  
  public List<IUsageCollector> getDelegates()
  {
    return delegates;
  }
  
  public void setDelegates(List<IUsageCollector> delegates)
  {
    this.delegates = delegates;
  }
  
  public void consumeEvent(InteractionEvent event, int userId)
  {
    for (IUsageCollector collector : delegates) {
      collector.consumeEvent(event, userId);
    }
  }
  
  public List<String> getReport()
  {
    List<String> combinedReports = new ArrayList();
    for (IUsageCollector collector : delegates)
    {
      combinedReports.add("<h3>" + collector.getReportTitle() + "</h3>");
      combinedReports.addAll(collector.getReport());
    }
    return combinedReports;
  }
  
  public void exportAsCSVFile(String directory) {}
  
  public String getReportTitle()
  {
    return reportTitle;
  }
  
  public void setReportTitle(String reportTitle)
  {
    this.reportTitle = reportTitle;
  }
  
  public List<String> getPlainTextReport()
  {
    List<String> combinedReports = new ArrayList();
    for (IUsageCollector collector : delegates)
    {
      combinedReports.add(collector.getReportTitle());
      combinedReports.addAll(collector.getPlainTextReport());
    }
    return combinedReports;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.DelegatingUsageCollector
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;

public class SummaryCollector
  implements IUsageCollector
{
  protected int numSelections = 0;
  protected int numEdits = 0;
  protected int numUserEvents = 0;
  protected Date leastRecentDate = new Date();
  protected Date mostRecentDate = new Date(0L);
  protected int numCommands = 0;
  protected int numPreference = 0;
  
  public void consumeEvent(InteractionEvent event, int userId)
  {
    if (mostRecentDate.compareTo(event.getDate()) == -1) {
      mostRecentDate = event.getDate();
    }
    if (leastRecentDate.compareTo(event.getDate()) == 1) {
      leastRecentDate = event.getDate();
    }
    if (event.getKind().equals(InteractionEvent.Kind.SELECTION)) {
      numSelections += 1;
    } else if (event.getKind().equals(InteractionEvent.Kind.EDIT)) {
      numEdits += 1;
    } else if (event.getKind().equals(InteractionEvent.Kind.COMMAND)) {
      numCommands += 1;
    } else if (event.getKind().equals(InteractionEvent.Kind.PREFERENCE)) {
      numPreference += 1;
    }
    numUserEvents += 1;
  }
  
  public List<String> getReport()
  {
    List<String> summaries = new ArrayList();
    
    summaries.add(Messages.SummaryCollector_Start_date_ + leastRecentDate + Messages.SummaryCollector_END_DATE + 
      mostRecentDate + "<br>");
    
    summaries.add(Messages.SummaryCollector_Number_of_events_ + numUserEvents + "<br>");
    summaries.add(Messages.SummaryCollector_Number_of_commands_ + numCommands + "<br>");
    summaries.add(Messages.SummaryCollector_Number_of_preference_changes + numPreference + "<br>");
    summaries.add(Messages.SummaryCollector_Number_of_selections_ + numSelections + "<br>");
    return summaries;
  }
  
  public String getReportTitle()
  {
    return Messages.SummaryCollector_Summary;
  }
  
  public void exportAsCSVFile(String directory) {}
  
  public List<String> getPlainTextReport()
  {
    List<String> summaries = new ArrayList();
    
    summaries.add(Messages.SummaryCollector_Start_date_ + leastRecentDate + Messages.SummaryCollector_END_DATE + 
      mostRecentDate);
    
    summaries.add(Messages.SummaryCollector_Number_of_events_ + numUserEvents);
    summaries.add(Messages.SummaryCollector_Number_of_commands_ + numCommands);
    summaries.add(Messages.SummaryCollector_Number_of_preference_changes + numPreference);
    summaries.add(Messages.SummaryCollector_Number_of_selections_ + numSelections);
    return summaries;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.SummaryCollector
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;

public class InteractionEventClassifier
{
  public static boolean isEdit(InteractionEvent event)
  {
    return (event.getKind().equals(InteractionEvent.Kind.EDIT)) || ((event.getKind().equals(InteractionEvent.Kind.SELECTION)) && (isSelectionInEditor(event)));
  }
  
  public static boolean isSelection(InteractionEvent event)
  {
    return (event.getKind().equals(InteractionEvent.Kind.SELECTION)) && (!isSelectionInEditor(event));
  }
  
  public static boolean isCommand(InteractionEvent event)
  {
    return event.getKind().equals(InteractionEvent.Kind.COMMAND);
  }
  
  public static boolean isJavaEdit(InteractionEvent event)
  {
    return (event.getKind().equals(InteractionEvent.Kind.EDIT)) && ((event.getOriginId().contains("java")) || (event.getOriginId().contains("jdt.ui")));
  }
  
  public static boolean isJDTEvent(InteractionEvent event)
  {
    return ((isEdit(event)) || (isSelection(event)) || (isCommand(event))) && (getCleanOriginId(event).contains("jdt"));
  }
  
  public static boolean isSelectionInEditor(InteractionEvent event)
  {
    return (event.getOriginId().contains("Editor")) || (event.getOriginId().contains("editor")) || (event.getOriginId().contains("source"));
  }
  
  public static String getCleanOriginId(InteractionEvent event)
  {
    String cleanOriginId = "";
    String originId = event.getOriginId();
    if (event.getKind().equals(InteractionEvent.Kind.COMMAND))
    {
      for (int i = 0; i < originId.length(); i++)
      {
        char curChar = originId.charAt(i);
        if (curChar != '&') {
          if (Character.getType(curChar) == 15) {
            cleanOriginId = cleanOriginId.concat(" ");
          } else {
            cleanOriginId = cleanOriginId.concat(String.valueOf(curChar));
          }
        }
      }
      return cleanOriginId;
    }
    return originId;
  }
  
  public static String formatDuration(long timeToFormatInms)
  {
    long timeInSeconds = timeToFormatInms / 1000L;
    
    long hours = timeInSeconds / 3600L;
    timeInSeconds -= hours * 3600L;
    long minutes = timeInSeconds / 60L;
    timeInSeconds -= minutes * 60L;
    return hours + "." + minutes;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.InteractionEventClassifier
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;

public class CommandUsageCollector
  implements IUsageCollector
{
  private final InteractionByTypeSummary commands = new InteractionByTypeSummary();
  private final Set<Integer> userIdSet = new HashSet();
  
  public void consumeEvent(InteractionEvent event, int userId)
  {
    userIdSet.add(Integer.valueOf(userId));
    if (event.getKind().equals(InteractionEvent.Kind.COMMAND)) {
      commands.setUserCount(userId, InteractionEventUtil.getCleanOriginId(event), 
        commands.getUserCount(userId, InteractionEventUtil.getCleanOriginId(event)) + 1);
    }
  }
  
  public List<String> getReport()
  {
    return Collections.emptyList();
  }
  
  public String getReportTitle()
  {
    return Messages.CommandUsageCollector_Command_Usage;
  }
  
  public void exportAsCSVFile(String directoryName) {}
  
  public InteractionByTypeSummary getCommands()
  {
    return commands;
  }
  
  public List<String> getPlainTextReport()
  {
    return Collections.emptyList();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.CommandUsageCollector
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;

public class ViewUsageCollector
  implements IUsageCollector
{
  protected Map<Integer, Integer> usersNumSelections = new HashMap();
  protected Map<Integer, Map<String, Integer>> usersNormalViewSelections = new HashMap();
  protected int maxViewsToReport = -1;
  
  public void consumeEvent(InteractionEvent event, int userId)
  {
    if (!usersNumSelections.containsKey(Integer.valueOf(userId))) {
      usersNumSelections.put(Integer.valueOf(userId), Integer.valueOf(0));
    }
    Map<String, Integer> normalViewSelections = (Map)usersNormalViewSelections.get(Integer.valueOf(userId));
    if (normalViewSelections == null)
    {
      normalViewSelections = new HashMap();
      usersNormalViewSelections.put(Integer.valueOf(userId), normalViewSelections);
    }
    if (event.getKind().equals(InteractionEvent.Kind.SELECTION))
    {
      if (!usersNumSelections.containsKey(Integer.valueOf(userId))) {
        usersNumSelections.put(Integer.valueOf(userId), Integer.valueOf(0));
      }
      int numEvents = ((Integer)usersNumSelections.get(Integer.valueOf(userId))).intValue() + 1;
      usersNumSelections.put(Integer.valueOf(userId), Integer.valueOf(numEvents));
      
      String viewId = event.getOriginId();
      if (!normalViewSelections.containsKey(viewId)) {
        normalViewSelections.put(viewId, Integer.valueOf(0));
      }
      int normal = ((Integer)normalViewSelections.get(viewId)).intValue() + 1;
      normalViewSelections.put(viewId, Integer.valueOf(normal));
    }
  }
  
  public List<String> getSummary(int userId, boolean html)
  {
    Map<String, Integer> normalViewSelections = (Map)usersNormalViewSelections.get(Integer.valueOf(userId));
    
    float numSelections = ((Integer)usersNumSelections.get(Integer.valueOf(userId))).intValue();
    
    List<String> summaries = new ArrayList();
    List<String> viewUsage = new ArrayList();
    float viewUse;
    for (String view : normalViewSelections.keySet())
    {
      viewUse = ((Integer)normalViewSelections.get(view)).intValue() / numSelections;
      String formattedViewUse = formatAsPercentage(viewUse);
      String ending = "";
      if (html) {
        ending = "<br>";
      }
      viewUsage.add(formattedViewUse + ": " + view + " (" + normalViewSelections.get(view) + ")" + ending);
    }
    Collections.sort(viewUsage, new PercentUsageComparator());
    int numViewsToReport = 0;
    for (String viewUsageSummary : viewUsage) {
      if ((maxViewsToReport == -1) || (numViewsToReport < maxViewsToReport) || (viewUsageSummary.contains("mylar")))
      {
        summaries.add(viewUsageSummary);
        numViewsToReport++;
      }
    }
    return summaries;
  }
  
  private String formatAsPercentage(float viewUse)
  {
    String formattedViewUse = viewUse * 100.0F;
    if (formattedViewUse.contains("E")) {
      return "0.00%";
    }
    int indexOf2ndDecimal = formattedViewUse.indexOf('.') + 3;
    if (indexOf2ndDecimal <= formattedViewUse.length()) {
      formattedViewUse = formattedViewUse.substring(0, indexOf2ndDecimal);
    }
    return formattedViewUse + "%";
  }
  
  public List<String> getReport()
  {
    List<String> summaries = new ArrayList();
    for (Iterator localIterator = usersNormalViewSelections.keySet().iterator(); localIterator.hasNext();)
    {
      int userId = ((Integer)localIterator.next()).intValue();
      summaries.addAll(getSummary(userId, true));
    }
    return summaries;
  }
  
  public String getReportTitle()
  {
    return Messages.ViewUsageCollector_View_Usage;
  }
  
  public void exportAsCSVFile(String directory) {}
  
  public Map<String, Integer> getNormalViewSelections()
  {
    Map<String, Integer> normalViewSelections = new HashMap();
    for (Iterator localIterator = usersNormalViewSelections.keySet().iterator(); localIterator.hasNext();)
    {
      int userId = ((Integer)localIterator.next()).intValue();
      normalViewSelections.putAll((Map)usersNormalViewSelections.get(Integer.valueOf(userId)));
    }
    return normalViewSelections;
  }
  
  public void setMaxViewsToReport(int maxViewsToReport)
  {
    this.maxViewsToReport = maxViewsToReport;
  }
  
  public Map<Integer, Map<String, Integer>> getUsersNormalViewSelections()
  {
    return usersNormalViewSelections;
  }
  
  public List<String> getPlainTextReport()
  {
    List<String> summaries = new ArrayList();
    for (Iterator localIterator = usersNormalViewSelections.keySet().iterator(); localIterator.hasNext();)
    {
      int userId = ((Integer)localIterator.next()).intValue();
      summaries.addAll(getSummary(userId, false));
    }
    return summaries;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.ViewUsageCollector
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import java.util.List;
import org.eclipse.mylyn.monitor.core.InteractionEvent;

public abstract interface IUsageCollector
{
  public abstract String getReportTitle();
  
  public abstract void consumeEvent(InteractionEvent paramInteractionEvent, int paramInt);
  
  public abstract List<String> getReport();
  
  public abstract List<String> getPlainTextReport();
  
  public abstract void exportAsCSVFile(String paramString);
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.IUsageCollector
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import java.util.Comparator;

public class PercentUsageComparator
  implements Comparator<String>
{
  public int compare(String o1, String o2)
  {
    int index1 = o1.indexOf('%');
    int index2 = o2.indexOf('%');
    if ((index1 != -1) && (index2 != -1))
    {
      String s1 = o1.substring(0, index1);
      String s2 = o2.substring(0, index2);
      return -1 * new Float(s1).compareTo(new Float(s2));
    }
    return 0;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.PercentUsageComparator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;

public class InteractionEventUtil
{
  public static String getCleanOriginId(InteractionEvent event)
  {
    String cleanOriginId = "";
    String originId = event.getOriginId();
    if (event.getKind().equals(InteractionEvent.Kind.COMMAND))
    {
      for (int i = 0; i < originId.length(); i++)
      {
        char curChar = originId.charAt(i);
        if (curChar != '&') {
          if (Character.getType(curChar) == 15) {
            cleanOriginId = cleanOriginId.concat(" ");
          } else {
            cleanOriginId = cleanOriginId.concat(String.valueOf(curChar));
          }
        }
      }
      return cleanOriginId;
    }
    return originId;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.InteractionEventUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import java.util.Set;
import org.eclipse.mylyn.monitor.core.InteractionEvent;

public abstract interface IUsageScanner
{
  public abstract void scanEvent(InteractionEvent paramInteractionEvent, int paramInt);
  
  public abstract boolean accept(int paramInt);
  
  public abstract Set<Integer> acceptedUsers();
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.IUsageScanner
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import java.util.HashSet;
import java.util.Set;

public class InteractionEventSummary
{
  private String type;
  private String name;
  private int usageCount;
  private float interestContribution;
  private String delta;
  private Set<Integer> userIds = new HashSet();
  
  public InteractionEventSummary(String type, String name, int usageCount)
  {
    this.type = type;
    this.name = name;
    this.usageCount = usageCount;
  }
  
  public InteractionEventSummary()
  {
    type = "";
    name = "";
    usageCount = 0;
  }
  
  public InteractionEventSummary(InteractionEventSummary another)
  {
    type = type;
    name = name;
    usageCount = usageCount;
    userIds.addAll(another.getUserIds());
  }
  
  public void combine(InteractionEventSummary another)
  {
    usageCount += another.getUsageCount();
    userIds.addAll(another.getUserIds());
  }
  
  public String getName()
  {
    return name;
  }
  
  public void setName(String name)
  {
    this.name = name;
  }
  
  public String getType()
  {
    return type;
  }
  
  public void setType(String type)
  {
    this.type = type;
  }
  
  public int getUsageCount()
  {
    return usageCount;
  }
  
  public void setUsageCount(int usageCount)
  {
    this.usageCount = usageCount;
  }
  
  public float getInterestContribution()
  {
    return interestContribution;
  }
  
  public void setInterestContribution(float interestContribution)
  {
    this.interestContribution = interestContribution;
  }
  
  public String getDelta()
  {
    if ("null".equals(delta)) {
      return "";
    }
    return delta;
  }
  
  public void setDelta(String delta)
  {
    this.delta = delta;
  }
  
  public Set<Integer> getUserIds()
  {
    return userIds;
  }
  
  public void setUserIds(Set<Integer> userIds)
  {
    this.userIds = userIds;
  }
  
  public void addUserId(int userId)
  {
    if (!userIds.contains(Integer.valueOf(userId))) {
      userIds.add(Integer.valueOf(userId));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.monitor.core.collection.InteractionEventSummary
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.monitor.core.collection;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class InteractionByTypeSummary
{
  HashMap<String, HashMap<Integer, Integer>> usageMap;
  
  public InteractionByTypeSummary()
  {
    usageMap = new HashMap();
  }
  
  public void setUserCount(int userId, String originId, int count)
  {
    if (!usageMap.containsKey(originId)) {
      usageMap.put(originId, new HashMap());
    }
    ((HashMap)usageMap.get(originId)).put(Integer.valueOf(userId), Integer.valueOf(count));
  }
  
  public int getUserCount(int userId, String originId)
  {
    if ((usageMap.containsKey(originId)) && (((HashMap)usageMap.get(originId)).containsKey(Integer.valueOf(userId)))) {
      return ((Integer)((HashMap)usageMap.get(originId)).get(Integer.valueOf(userId))).intValue();
    }
    return 0;
  }
  
  public int getTotalCount(String originId)
  {
    int count = 0;
    for (Integer userId : ((HashM
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd