lttng: fix JUnit tests failures introduced by commit 44908fc1
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.core / src / org / eclipse / linuxtools / internal / lttng2 / core / control / model / impl / ChannelInfo.java
index f9b2fc5a2fe815be5f96bd4eadaea226f2f149d0..b0d0299fe92df6d483dd4b25b458760f0c3564cb 100644 (file)
@@ -1,13 +1,14 @@
 /**********************************************************************
- * Copyright (c) 2012 Ericsson
- * 
+ * Copyright (c) 2012, 2013 Ericsson
+ *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors: 
+ *
+ * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Simon Delisle - Updated for support of LTTng Tools 2.2
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.core.control.model.impl;
 
@@ -20,11 +21,12 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement;
 
 /**
- * <b><u>ChannelInfo</u></b>
  * <p>
  * Implementation of the trace channel interface (IChannelInfo) to store channel
- * related data. 
+ * related data.
  * </p>
+ *
+ * @author Bernd Hufmann
  */
 public class ChannelInfo extends TraceInfo implements IChannelInfo {
 
@@ -62,9 +64,21 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo {
     /**
      * The events information of the channel.
      */
-    private List<IEventInfo> fEvents = new ArrayList<IEventInfo>();
+    private final List<IEventInfo> fEvents = new ArrayList<IEventInfo>();
+    /**
+     * The maximum size of trace files
+     */
+    private int fMaxSizeTraceFiles;
+    /**
+     * The maximum number of trace files
+     */
+    private int fMaxNumberTraceFiles;
+    /**
+     * The value of buffer type
+     */
+    private BufferType fBufferType = BufferType.BUFFER_TYPE_UNKNOWN;
+
 
-    
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -87,6 +101,9 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo {
         fNumberOfSubBuffers = other.fNumberOfSubBuffers;
         fSwitchTimer = other.fSwitchTimer;
         fReadTimer = other.fReadTimer;
+        fMaxSizeTraceFiles = other.fMaxSizeTraceFiles;
+        fMaxNumberTraceFiles = other.fMaxNumberTraceFiles;
+        fBufferType = other.fBufferType;
         fOutputType = (other.fOutputType == null ? null : String.valueOf(other.fOutputType));
         fState = other.fState;
         for (Iterator<IEventInfo> iterator = other.fEvents.iterator(); iterator.hasNext();) {
@@ -102,137 +119,77 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo {
     // ------------------------------------------------------------------------
     // Accessors
     // ------------------------------------------------------------------------
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getOverwriteMode()
-     */
+
     @Override
     public boolean isOverwriteMode() {
         return fOverwriteMode;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setOverwriteMode(boolean)
-     */
     @Override
     public void setOverwriteMode(boolean mode) {
         fOverwriteMode = mode;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getSubBufferSize()
-     */
     @Override
     public long getSubBufferSize() {
         return fSubBufferSize;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setSubBufferSize(long)
-     */
     @Override
     public void setSubBufferSize(long bufferSize) {
         fSubBufferSize = bufferSize;
-
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getNumberOfSubBuffers()
-     */
     @Override
     public int getNumberOfSubBuffers() {
         return fNumberOfSubBuffers;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setNumberOfSubBuffers(int)
-     */
     @Override
     public void setNumberOfSubBuffers(int numberOfSubBuffers) {
         fNumberOfSubBuffers = numberOfSubBuffers;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getSwitchTimer()
-     */
     @Override
     public long getSwitchTimer() {
         return fSwitchTimer;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setSwitchTimer(long)
-     */
     @Override
     public void setSwitchTimer(long timer) {
         fSwitchTimer = timer;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getReadTimer()
-     */
     @Override
     public long getReadTimer() {
         return fReadTimer;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setReadTimer(long)
-     */
     @Override
     public void setReadTimer(long timer) {
         fReadTimer = timer;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getOutputType()
-     */
     @Override
     public String getOutputType() {
         return fOutputType;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setOutputType(java.lang.String)
-     */
     @Override
     public void setOutputType(String type) {
         fOutputType = type;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getState()
-     */
     @Override
     public TraceEnablement getState() {
         return fState;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement)
-     */
     @Override
     public void setState(TraceEnablement state) {
         fState = state;
     }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setState(java.lang.String)
-     */
+
     @Override
     public void setState(String stateName) {
         fState = TraceEnablement.ENABLED;
@@ -242,46 +199,31 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo {
             fState = TraceEnablement.ENABLED;
         }
     }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getEvents()
-     */
+
     @Override
     public IEventInfo[] getEvents() {
         return fEvents.toArray(new IEventInfo[fEvents.size()]);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setEvents(java.util.List)
-     */
     @Override
     public void setEvents(List<IEventInfo> events) {
+        fEvents.clear();
         for (Iterator<IEventInfo> iterator = events.iterator(); iterator.hasNext();) {
-            IEventInfo eventInfo = (IEventInfo) iterator.next();
+            IEventInfo eventInfo = iterator.next();
             fEvents.add(eventInfo);
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#addEvent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo)
-     */
     @Override
     public void addEvent(IEventInfo channel) {
         fEvents.add(channel);
     }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
-     */
+
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result + ((fEvents == null) ? 0 : fEvents.hashCode());
+        result = prime * result + fEvents.hashCode();
         result = prime * result + fNumberOfSubBuffers;
         result = prime * result + ((fOutputType == null) ? 0 : fOutputType.hashCode());
         result = prime * result + (fOverwriteMode ? 1231 : 1237);
@@ -289,13 +231,10 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo {
         result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
         result = prime * result + (int) (fSubBufferSize ^ (fSubBufferSize >>> 32));
         result = prime * result + (int) (fSwitchTimer ^ (fSwitchTimer >>> 32));
+        result = prime * result + ((fBufferType == null) ? 0 : (fBufferType.ordinal() + 1));
         return result;
-    }  
+    }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
-     */
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
@@ -308,11 +247,7 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo {
             return false;
         }
         ChannelInfo other = (ChannelInfo) obj;
-        if (fEvents == null) {
-            if (other.fEvents != null) {
-                return false;
-            }
-        } else if (!fEvents.equals(other.fEvents)) {
+        if (!fEvents.equals(other.fEvents)) {
             return false;
         }
         if (fNumberOfSubBuffers != other.fNumberOfSubBuffers) {
@@ -340,13 +275,12 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo {
         if (fSwitchTimer != other.fSwitchTimer) {
             return false;
         }
+        if (fBufferType != other.fBufferType) {
+            return false;
+        }
         return true;
     }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
-     */
+
     @SuppressWarnings("nls")
     @Override
     public String toString() {
@@ -367,12 +301,16 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo {
             output.append(fReadTimer);
             output.append(",output=");
             output.append(fOutputType);
+            if ((fBufferType != null) && !fBufferType.equals(BufferType.BUFFER_TYPE_UNKNOWN) && !fBufferType.equals(BufferType.BUFFER_SHARED)) {
+                output.append(",BufferType=");
+                output.append(fBufferType);
+            }
             output.append(",Events=");
             if (fEvents.isEmpty()) {
                 output.append("None");
             } else {
                 for (Iterator<IEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
-                    IEventInfo event = (IEventInfo) iterator.next();
+                    IEventInfo event = iterator.next();
                     output.append(event.toString());
                 }
             }
@@ -380,5 +318,33 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo {
             return output.toString();
     }
 
+    @Override
+    public void setMaxSizeTraceFiles(int maxSizeTraceFiles) {
+        fMaxSizeTraceFiles = maxSizeTraceFiles;
+    }
+
+    @Override
+    public void setMaxNumberTraceFiles(int maxNumberTraceFiles) {
+        fMaxNumberTraceFiles = maxNumberTraceFiles;
+    }
+
+    @Override
+    public int getMaxSizeTraceFiles() {
+        return fMaxSizeTraceFiles;
+    }
+
+    @Override
+    public int getMaxNumberTraceFiles() {
+        return fMaxNumberTraceFiles;
+    }
 
-}
\ No newline at end of file
+    @Override
+    public void setBufferType(BufferType bufferType) {
+        fBufferType = bufferType;
+    }
+
+    @Override
+    public BufferType getBufferType() {
+        return fBufferType;
+    }
+}
This page took 0.029044 seconds and 5 git commands to generate.