tmf: Make TmfTimestamp and TmfTimeRange immutable
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 1 Oct 2012 21:45:51 +0000 (17:45 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 1 Nov 2012 16:56:12 +0000 (12:56 -0400)
Mark the fields in TmfTimestamp/TmfTimeRange final, to ensure they
do not get modified after the object is created. The setter methods
didn't seem to be used anywhere so the impacts are minimal.

Change-Id: I693ffef78588e9e68fa3b22516cf93b3f98c6613
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/7278
Tested-by: Hudson CI
22 files changed:
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfSimpleTimestampTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimeRangeTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampTest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTimestamp.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfTimestamp.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfLostEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfCheckpoint.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfCheckpointIndexer.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/TmfAsyncSequenceDiagramEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/TmfSyncSequenceDiagramEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/DrawableToolTip.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessage.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicFrame.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ExecutionOccurrence.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SyncMessage.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java

index 84b3bba2052d06bb3590d8583273b279e2ace361..e2a6ce7f6bbc38e6daab3f0b86c4ce33016f4980 100644 (file)
@@ -94,63 +94,11 @@ public class TmfSimpleTimestampTest extends TestCase {
      *
      */
     public void testCopyBadTimestamp() {
-        final ITmfTimestamp ts0a = new TmfTimestamp(0, 100, 0);
-
         try {
             new TmfSimpleTimestamp(null);
             fail("TmfSimpleTimestamp: null argument");
-        } catch (final IllegalArgumentException e) {
-        }
-
-        try {
-            new TmfSimpleTimestamp(ts0a);
-            fail("TmfSimpleTimestamp: bad scale");
-        } catch (final ArithmeticException e) {
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // clone
-    // ------------------------------------------------------------------------
-
-    private static class MyTimestamp extends TmfSimpleTimestamp {
-
-        @Override
-        public boolean equals(final Object other) {
-            return super.equals(other);
+        } catch (final NullPointerException e) {
         }
-
-        @Override
-        public MyTimestamp clone() {
-            return (MyTimestamp) super.clone();
-        }
-    }
-
-    /**
-     *
-     */
-    public void testClone() {
-        final ITmfTimestamp clone = ts0.clone();
-
-        assertTrue("clone", ts0.clone().equals(ts0));
-        assertTrue("clone", clone.clone().equals(clone));
-
-        assertEquals("clone", clone, ts0);
-        assertEquals("clone", ts0, clone);
-    }
-
-    /**
-     *
-     */
-    public void testClone2() {
-        final MyTimestamp timestamp = new MyTimestamp();
-        final MyTimestamp clone = timestamp.clone();
-
-        assertTrue("clone", timestamp.clone().equals(timestamp));
-        assertTrue("clone", clone.clone().equals(clone));
-
-        assertEquals("clone", clone, timestamp);
-        assertEquals("clone", timestamp, clone);
     }
 
     // ------------------------------------------------------------------------
index 875d89b64a0603a6d4a9d066bf430ca59e5cc995..1bc295f8d9560d48d7384940b4622953b431c4c9 100644 (file)
@@ -144,28 +144,6 @@ public class TmfTimeRangeTest extends TestCase {
         }
     }
 
-    // ------------------------------------------------------------------------
-    // clone
-    // ------------------------------------------------------------------------
-
-    /**
-     * @throws CloneNotSupportedException cloning problem
-     */
-    public void testClone() throws CloneNotSupportedException {
-        final ITmfTimestamp ts1 = new TmfTimestamp(12345);
-        final ITmfTimestamp ts2 = new TmfTimestamp(12350);
-
-        final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
-        final TmfTimeRange clone = range.clone();
-
-        assertTrue("clone", range.clone().equals(range));
-        assertTrue("clone", clone.clone().equals(clone));
-
-        assertEquals("clone", range, clone);
-        assertEquals("clone", ts1, clone.getStartTime());
-        assertEquals("clone", ts2, clone.getEndTime());
-    }
-
     // ------------------------------------------------------------------------
     // hashCode
     // ------------------------------------------------------------------------
index d4a842788572c879459c0cbe4033afac1d321004..ef20328ed95f5d296f6e3373be135e4a4a114e00 100644 (file)
@@ -152,50 +152,6 @@ public class TmfTimestampTest extends TestCase {
         assertEquals("getPrecision", TmfTimestamp.ZERO.getPrecision(), ts.getPrecision());
     }
 
-    // ------------------------------------------------------------------------
-    // clone
-    // ------------------------------------------------------------------------
-
-    private static class MyTimestamp extends TmfTimestamp {
-
-        @Override
-        public boolean equals(final Object other) {
-            return super.equals(other);
-        }
-
-        @Override
-        public MyTimestamp clone() {
-            return (MyTimestamp) super.clone();
-        }
-    }
-
-    /**
-     *
-     */
-    public void testClone() {
-        final ITmfTimestamp clone = ts0.clone();
-
-        assertTrue("clone", ts0.clone().equals(ts0));
-        assertTrue("clone", clone.clone().equals(clone));
-
-        assertEquals("clone", clone, ts0);
-        assertEquals("clone", ts0, clone);
-    }
-
-    /**
-     *
-     */
-    public void testClone2() {
-        final MyTimestamp timestamp = new MyTimestamp();
-        final MyTimestamp clone = timestamp.clone();
-
-        assertTrue("clone", timestamp.clone().equals(timestamp));
-        assertTrue("clone", clone.clone().equals(clone));
-
-        assertEquals("clone", clone, timestamp);
-        assertEquals("clone", timestamp, clone);
-    }
-
     // ------------------------------------------------------------------------
     // hashCode
     // ------------------------------------------------------------------------
index 644e217951ce88d85a4620cfacdf2eb1443201a2..ad13421b1858eb6b638834ffec697eaeb491a811 100644 (file)
@@ -50,7 +50,7 @@ public class CtfTmfTimestamp extends TmfTimestamp {
      * @param timestamp long
      */
     public CtfTmfTimestamp(long timestamp) {
-        setValue(timestamp, ITmfTimestamp.NANOSECOND_SCALE, 0);
+        super(timestamp, ITmfTimestamp.NANOSECOND_SCALE, 0);
         type = TimestampType.DAY;
     }
 
index 33db5a4ccc278cdd78a5027cdadbcb2b55f756e2..469c9fff7c136e2fcf0f19e37984b5e530c08829 100644 (file)
@@ -113,11 +113,6 @@ public interface ITmfTimestamp extends Comparable<ITmfTimestamp> {
      */
     public ITmfTimestamp getDelta(ITmfTimestamp ts);
 
-    /**
-     * @return a clone of the timestamp
-     */
-    public ITmfTimestamp clone();
-
     // ------------------------------------------------------------------------
     // Comparable
     // ------------------------------------------------------------------------
index bdeec02cbceda00a84123357202154f06b62b2c1..04c0b92485d94fd6aa9dc16a6a29a9ec3a713dae 100644 (file)
@@ -244,7 +244,7 @@ public class TmfEvent implements ITmfEvent, IAdaptable, Cloneable {
             clone = (TmfEvent) super.clone();
             clone.fTrace = fTrace;
             clone.fRank = fRank;
-            clone.fTimestamp = fTimestamp != null ? fTimestamp.clone() : null;
+            clone.fTimestamp = fTimestamp;
             clone.fSource = fSource;
             clone.fType = fType != null ? fType.clone() : null;
             clone.fContent = fContent != null ? fContent.clone() : null;
index 0190602aa66bfe72bf2d0a51afe5c610f8e7dbb7..ce9b938b12aabbef9d420f46277ea32075950237 100644 (file)
@@ -132,12 +132,9 @@ public class TmfLostEvent extends TmfEvent implements ITmfLostEvent {
     @Override
     public TmfLostEvent clone() {
         TmfLostEvent clone = null;
-        try {
-            clone = (TmfLostEvent) super.clone();
-            clone.fTimeRange = fTimeRange.clone();
-            clone.fNbLostEvents = fNbLostEvents;
-        } catch (CloneNotSupportedException e) {
-        }
+        clone = (TmfLostEvent) super.clone();
+        clone.fTimeRange = fTimeRange;
+        clone.fNbLostEvents = fNbLostEvents;
         return clone;
     }
 
index 1922e59db987c24e4003c0659a97524091971afd..dc23ce6a99a22480ef047f75e6d3e4a08f80541c 100644 (file)
@@ -42,17 +42,16 @@ public class TmfSimpleTimestamp extends TmfTimestamp {
     }
 
     /**
-     * Copy constructor
+     * Copy constructor.
      *
-     * @param timestamp the timestamp to copy or scale to 0
-     * @throws IllegalArgumentException if timestamp is null
-     * @throws ArithmeticException if timestamp can't be scaled to 0
+     * If the parameter is not a TmfSimpleTimestamp, the timestamp will be
+     * scaled to seconds, and the precision will be discarded.
+     *
+     * @param timestamp
+     *            The timestamp to copy
      */
     public TmfSimpleTimestamp(final ITmfTimestamp timestamp) {
-        if (timestamp == null) {
-            throw new IllegalArgumentException();
-        }
-        setValue(timestamp.normalize(0, 0).getValue(), 0, 0);
+        super(timestamp.normalize(0, ITmfTimestamp.SECOND_SCALE).getValue(), 0, 0);
     }
 
     // ------------------------------------------------------------------------
@@ -93,18 +92,6 @@ public class TmfSimpleTimestamp extends TmfTimestamp {
         return super.getDelta(ts);
     }
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.event.TmfTimestamp#clone()
-     */
-    @Override
-    public TmfSimpleTimestamp clone() {
-        return (TmfSimpleTimestamp) super.clone();
-    }
-
     // ------------------------------------------------------------------------
     // Object
     // ------------------------------------------------------------------------
index 71886dbbd2c8247ae160d76fa48e7e6d91baff37..556122c48270f2f409ffbe29f9fbb902bef07e81 100644 (file)
@@ -1,11 +1,11 @@
 /*******************************************************************************
  * Copyright (c) 2009, 2012 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:
  *   Francois Chouinard - Initial API and implementation
  *   Francois Chouinard - Updated as per TMF Event Model 1.0
@@ -15,13 +15,13 @@ package org.eclipse.linuxtools.tmf.core.event;
 
 /**
  * A utility class to define and manage time ranges.
- * 
+ *
  * @version 1.0
  * @author Francois Chouinard
- * 
+ *
  * @see ITmfTimestamp
  */
-public final class TmfTimeRange implements Cloneable {
+public final class TmfTimeRange {
 
     // ------------------------------------------------------------------------
     // Constants
@@ -36,15 +36,14 @@ public final class TmfTimeRange implements Cloneable {
     /**
      * The null time range
      */
-    public static final TmfTimeRange NULL_RANGE =
-            new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_BANG);
+    public static final TmfTimeRange NULL_RANGE = new TmfTimeRange();
 
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
 
-    private ITmfTimestamp fStartTime;
-    private ITmfTimestamp fEndTime;
+    private final ITmfTimestamp fStartTime;
+    private final ITmfTimestamp fEndTime;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -53,13 +52,14 @@ public final class TmfTimeRange implements Cloneable {
     /**
      * Default constructor
      */
-    @SuppressWarnings("unused")
     private TmfTimeRange() {
+        fStartTime = TmfTimestamp.BIG_BANG;
+        fEndTime = TmfTimestamp.BIG_BANG;
     }
 
     /**
      * Full constructor
-     * 
+     *
      * @param startTime start of the time range
      * @param endTime end of the time range
      */
@@ -73,7 +73,7 @@ public final class TmfTimeRange implements Cloneable {
 
     /**
      * Copy constructor
-     * 
+     *
      * @param range the other time range
      */
     public TmfTimeRange(final TmfTimeRange range) {
@@ -108,7 +108,7 @@ public final class TmfTimeRange implements Cloneable {
 
     /**
      * Check if the timestamp is within the time range
-     * 
+     *
      * @param ts the timestamp to check
      * @return true if [startTime] <= [ts] <= [endTime]
      */
@@ -122,7 +122,7 @@ public final class TmfTimeRange implements Cloneable {
 
     /**
      * Check if the time range is within the time range
-     * 
+     *
      * @param range the other time range
      * @return true if [range] is fully contained
      */
@@ -138,7 +138,7 @@ public final class TmfTimeRange implements Cloneable {
 
     /**
      * Get intersection of two time ranges
-     * 
+     *
      * @param range the other time range
      * @return the intersection time range, or null if no intersection exists
      */
@@ -147,33 +147,13 @@ public final class TmfTimeRange implements Cloneable {
             return null; // no intersection
         }
 
-        return new TmfTimeRange(fStartTime.compareTo(range.fStartTime, true) < 0 
-                ? range.fStartTime 
-                : fStartTime, fEndTime.compareTo(range.fEndTime, true) > 0 
-                        ? range.fEndTime 
+        return new TmfTimeRange(fStartTime.compareTo(range.fStartTime, true) < 0
+                ? range.fStartTime
+                : fStartTime, fEndTime.compareTo(range.fEndTime, true) > 0
+                        ? range.fEndTime
                         : fEndTime);
     }
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
-    /* (non-Javadoc)
-     * @see java.lang.Object#clone()
-     */
-    @Override
-    public TmfTimeRange clone() throws CloneNotSupportedException {
-        TmfTimeRange clone = null;
-        try {
-            clone = (TmfTimeRange) super.clone();
-            clone.fStartTime = fStartTime.clone();
-            clone.fEndTime = fEndTime.clone();
-        }
-        catch (final CloneNotSupportedException e) {
-        }
-        return clone;
-    }
-
     // ------------------------------------------------------------------------
     // Object
     // ------------------------------------------------------------------------
index 37b74b50d2b9025d43847f40dc0c6d75e6bb175e..ca057599cbe7d516af057cb0a0d37907700835e2 100644 (file)
@@ -23,7 +23,7 @@ package org.eclipse.linuxtools.tmf.core.event;
  * @version 1.1
  * @author Francois Chouinard
  */
-public class TmfTimestamp implements ITmfTimestamp, Cloneable {
+public class TmfTimestamp implements ITmfTimestamp {
 
     // ------------------------------------------------------------------------
     // Constants
@@ -66,17 +66,17 @@ public class TmfTimestamp implements ITmfTimestamp, Cloneable {
     /**
      * The timestamp raw value (mantissa)
      */
-    private long fValue;
+    private final long fValue;
 
     /**
      * The timestamp scale (magnitude)
      */
-    private int fScale;
+    private final int fScale;
 
     /**
      * The value precision (tolerance)
      */
-    private int fPrecision;
+    private final int fPrecision;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -135,16 +135,6 @@ public class TmfTimestamp implements ITmfTimestamp, Cloneable {
         fPrecision = timestamp.getPrecision();
     }
 
-    // ------------------------------------------------------------------------
-    // Setters
-    // ------------------------------------------------------------------------
-
-    protected void setValue(long value, int scale, int precision) {
-        fValue = value;
-        fScale = scale;
-        fPrecision = precision;
-    }
-
     // ------------------------------------------------------------------------
     // ITmfTimestamp
     // ------------------------------------------------------------------------
@@ -206,7 +196,7 @@ public class TmfTimestamp implements ITmfTimestamp, Cloneable {
 
         // Handle the trivial case
         if (fScale == scale && offset == 0) {
-            return new TmfTimestamp(this);
+            return this;
         }
 
         // In case of big bang and big crunch just return this (no need to normalize)
@@ -300,26 +290,6 @@ public class TmfTimestamp implements ITmfTimestamp, Cloneable {
         return new TmfTimestamp(value, fScale, fPrecision + nts.getPrecision());
     }
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
-    /* (non-Javadoc)
-     * @see java.lang.Object#clone()
-     */
-    @Override
-    public TmfTimestamp clone() {
-        TmfTimestamp clone = null;
-        try {
-            clone = (TmfTimestamp) super.clone();
-            clone.fValue = fValue;
-            clone.fScale = fScale;
-            clone.fPrecision = fPrecision;
-        } catch (final CloneNotSupportedException e) {
-        }
-        return clone;
-    }
-
     // ------------------------------------------------------------------------
     // Comparable
     // ------------------------------------------------------------------------
index c28d1ae7ed2961e36e9605a858cba2cf1e73dd60..a2135ec572add3cd2d52cd42da347f9df8031f1c 100644 (file)
@@ -85,7 +85,7 @@ public class TmfCheckpoint implements ITmfCheckpoint, Cloneable {
         try {
             clone = (TmfCheckpoint) super.clone();
             clone.fContext = (fContext != null) ? fContext.clone() : null;
-            clone.fTimestamp = (fTimestamp != null) ? fTimestamp.clone() : null;
+            clone.fTimestamp = fTimestamp;
         } catch (final CloneNotSupportedException e) {
         }
         return clone;
index 0dcfa9c18b4f26370771cd7b29914f7b658d29c6..3e212807eee3fec13f74c98c7dcdcb0f8bfa3947 100644 (file)
@@ -238,7 +238,7 @@ public class TmfCheckpointIndexer implements ITmfTraceIndexer {
             final long position = rank / fCheckpointInterval;
             // Add new entry at proper location (if empty)
             if (fTraceIndex.size() == position) {
-                fTraceIndex.add(new TmfCheckpoint(timestamp.clone(), saveContext(context)));
+                fTraceIndex.add(new TmfCheckpoint(timestamp, saveContext(context)));
             }
         }
     }
index 7fdbb8460eb92c6a0f4ef97e9d34aa0040a4054f..eb08d538d9acdbfba36c89c7b7b45d5f2947977f 100644 (file)
@@ -447,7 +447,7 @@ public class TmfExperiment extends TmfTrace implements ITmfEventParser {
             if (event == null) {
                 return;
             }
-            final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp().clone(), TmfTimestamp.BIG_CRUNCH);
+            final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp(), TmfTimestamp.BIG_CRUNCH);
             final TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(this, this, timeRange);
 
             // Broadcast in separate thread to prevent deadlock
index 803590e6a0f49659963b112a68690ec09c8dfd1d..11290be95f33682723e0c49cc17a71cd47bceb67 100644 (file)
@@ -380,7 +380,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
      */
     @Override
     public ITmfTimestamp getStartTime() {
-        return fStartTime.clone();
+        return fStartTime;
     }
 
     /* (non-Javadoc)
@@ -388,7 +388,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
      */
     @Override
     public ITmfTimestamp getEndTime() {
-        return fEndTime.clone();
+        return fEndTime;
     }
 
     // ------------------------------------------------------------------------
@@ -420,8 +420,8 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
      * @param range the new time range
      */
     protected void setTimeRange(final TmfTimeRange range) {
-        fStartTime = range.getStartTime().clone();
-        fEndTime = range.getEndTime().clone();
+        fStartTime = range.getStartTime();
+        fEndTime = range.getEndTime();
     }
 
     /**
@@ -430,7 +430,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
      * @param startTime the new first event timestamp
      */
     protected void setStartTime(final ITmfTimestamp startTime) {
-        fStartTime = startTime.clone();
+        fStartTime = startTime;
     }
 
     /**
@@ -439,7 +439,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
      * @param endTime the new last event timestamp
      */
     protected void setEndTime(final ITmfTimestamp endTime) {
-        fEndTime = endTime.clone();
+        fEndTime = endTime;
     }
 
     /**
@@ -570,10 +570,10 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
      */
     protected synchronized void updateAttributes(final ITmfContext context, final ITmfTimestamp timestamp) {
         if (fStartTime.equals(TmfTimestamp.BIG_BANG) || (fStartTime.compareTo(timestamp, false) > 0)) {
-            fStartTime = timestamp.clone();
+            fStartTime = timestamp;
         }
         if (fEndTime.equals(TmfTimestamp.BIG_CRUNCH) || (fEndTime.compareTo(timestamp, false) < 0)) {
-            fEndTime = timestamp.clone();
+            fEndTime = timestamp;
         }
         if (context.hasValidRank()) {
             long rank = context.getRank();
index 2ef28a4697aa7bcd4d3bd1f87e2c7e3b6e99ffb7..2b48bee3d62996b62c05bdbb5c3f1f3f73d0ed76 100644 (file)
@@ -50,7 +50,7 @@ public class TmfAsyncSequenceDiagramEvent extends TmfSyncSequenceDiagramEvent im
         if (endEvent == null) {
             throw new IllegalArgumentException("TmfAsyncSequenceDiagramEvent constructor: endEvent=null"); //$NON-NLS-1$
         }
-        fEndTime = endEvent.getTimestamp().clone();
+        fEndTime = endEvent.getTimestamp();
     }
 
     // ------------------------------------------------------------------------
index ab34f9582cd80127dc045d3d45d9ef3f7e866762..bf1656353d1c190cc326d4839d02bbb909f23b84 100644 (file)
@@ -65,7 +65,7 @@ public class TmfSyncSequenceDiagramEvent implements ITmfSyncSequenceDiagramEvent
                     (name == null ? ", name=null" : "")); //$NON-NLS-1$ //$NON-NLS-2$
         }
 
-        fStartTime = startEvent.getTimestamp().clone();
+        fStartTime = startEvent.getTimestamp();
 
         fSender = sender;
         fReceiver = receiver;
index f2f93bf6d129f0bd7a69ebee89f5b5c85078f0db..5deaee658a503c8a74ed52dc9e49bca1c0b5c738 100755 (executable)
@@ -215,8 +215,8 @@ public class DrawableToolTip implements PaintListener {
      * @param max the scale max
      */
     public void showToolTip(ITmfTimestamp value, ITmfTimestamp min, ITmfTimestamp max) {
-        fMinMaxRange = new TmfTimeRange(min.clone(), max.clone());
-        fCurrentValue = value.clone();
+        fMinMaxRange = new TmfTimeRange(min, max);
+        fCurrentValue = value;
 
         int w = fToolTipShell.getBounds().width;
         int h = fToolTipShell.getBounds().height;
index beaf711cc4688633e274241e2da529bd30c6ea3f..c1fc48d81b9071c1a108c4e6e13eb39d15cb1ef9 100755 (executable)
@@ -399,7 +399,7 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
      * @param time the time when the message end
      */
     public void setEndTime(ITmfTimestamp time) {
-        fEndTime = time.clone();
+        fEndTime = time;
         fHasTime = true;
         if (getStartLifeline() != null && getStartLifeline().getFrame() != null) {
             getStartLifeline().getFrame().setHasTimeInfo(true);
@@ -414,7 +414,7 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
      * @param time the time when the message start
      */
     public void setStartTime(ITmfTimestamp time) {
-        fStartTime = time.clone();
+        fStartTime = time;
         fHasTime = true;
         if (getStartLifeline() != null && getStartLifeline().getFrame() != null) {
             getStartLifeline().getFrame().setHasTimeInfo(true);
index 47ba4d0d544bcd1c38397d0d598975ac80360e53..5fcd27c5e786bb03907e2bfaedac583e270d7f8b 100755 (executable)
@@ -525,20 +525,20 @@ public class BasicFrame extends GraphNode {
     protected void updateMinMax(SDTimeEvent m1, SDTimeEvent m2) {
         ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
         if (fComputeMinMax) {
-            fMinTime = delta.clone();
+            fMinTime = delta;
             if (fMinTime.compareTo(TmfTimestamp.ZERO, false) < 0) {
                 fMinTime = new TmfTimestamp(0, m1.getTime().getScale(), m1.getTime().getPrecision());
             }
-            fMaxTime = fMinTime.clone();
+            fMaxTime = fMinTime;
             fComputeMinMax = false;
         }
 
         if ((delta.compareTo(fMinTime, true) < 0) && (delta.compareTo(TmfTimestamp.ZERO, false) > 0)) {
-            fMinTime = delta.clone();
+            fMinTime = delta;
         }
 
         if ((delta.compareTo(fMaxTime, true) > 0) && (delta.compareTo(TmfTimestamp.ZERO, false) > 0)) {
-            fMaxTime = delta.clone();
+            fMaxTime = delta;
         }
     }
 
index 1373c3af8db1a64859bc7753fbdc88975b8793f9..012b0c87616c0c7b8328d29852eb3251b25f6301 100755 (executable)
@@ -133,7 +133,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi
      * @param time the time when the execution occurrence starts
      */
     public void setStartTime(ITmfTimestamp time) {
-        fStartTime = time.clone();
+        fStartTime = time;
         fHasTimeInfo = true;
         if (fLifeline != null) {
             fLifeline.setTimeInfo(true);
@@ -146,7 +146,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi
      * @param time the time when the execution occurrence ends
      */
     public void setEndTime(ITmfTimestamp time) {
-        fEndTime = time.clone();
+        fEndTime = time;
         fHasTimeInfo = true;
         if (fLifeline != null) {
             fLifeline.setTimeInfo(true);
index 0092bbfc4984c797cb01cced2300c4acfbb9557c..3016cb18326bf6985190c831bbb731b0e55cfa37 100755 (executable)
@@ -1,13 +1,13 @@
 /**********************************************************************
  * Copyright (c) 2005, 2006 IBM Corporation and others.
  * Copyright (c) 2011, 2012 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:
  * IBM - Initial API and implementation
  * Bernd Hufmann - Updated for TMF
  **********************************************************************/
@@ -29,12 +29,12 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SortSyncMessageComparator
  * <br>
  * <br>
  * Usage example:
- * 
+ *
  * <pre>
  * Frame frame;
  * Lifeline lifeLine1;
  * Lifeline lifeLine2;
- * 
+ *
  * SyncMessage message = new SyncMessage();
  * // Create a new event occurrence on each lifeline
  * lifeline1.getNewOccurrenceIndex();
@@ -46,11 +46,11 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SortSyncMessageComparator
  * // add the message to the frame
  * frame.addMessage(message);
  * </pre>
- * 
+ *
  * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
  * @version 1.0
  * @author sveyrier
- * 
+ *
  */
 public class SyncMessage extends BaseMessage implements ITimeRange {
 
@@ -117,7 +117,7 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
      * SyncMessage must occur at the same event occurrence on both lifeline, this method is responsible to synchronize the
      * event occurrence on each lifeline (the greater value will be used).<br>
      * This synchronization is only done if the end lifeline has already been set.
-     * 
+     *
      * @param lifeline the message sender
      */
     public void autoSetStartLifeline(Lifeline lifeline) {
@@ -131,7 +131,7 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
      * SyncMessage must occur at the same event occurrence on both lifeline, this method is responsible to synchronize the
      * event occurrence on each lifeline (the greater value will be used).<br>
      * This synchronization is only done if the start lifeline has already been set.
-     * 
+     *
      * @param lifeline the message receiver
      */
     public void autoSetEndLifeline(Lifeline lifeline) {
@@ -144,7 +144,7 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
      * SyncMessage must occur at the same event occurrence on both lifeline, this method is responsible to synchronize the
      * event occurrence on each lifeline (the greater value will be used).<br>
      * This synchronization is only done if the start lifeline has already been set.
-     * 
+     *
      * @param lifeline the message receiver
      */
     @Override
@@ -162,7 +162,7 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
      * SyncMessage must occur at the same event occurrence on both lifelines, this method is responsible to synchronize the
      * event occurrence on each lifeline (the greater value will be used).<br>
      * This synchronization is only done if the start lifeline has already been set.
-     * 
+     *
      * @param lifeline the message receiver
      */
     @Override
@@ -177,7 +177,7 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
 
     /**
      * Set the event occurrence when this message occurs.<br>
-     * 
+     *
      * @param occurrence the event occurrence to assign to this message.<br>
      * @see Lifeline Lifeline for more event occurence details
      */
@@ -189,7 +189,7 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
 
     /**
      * Set the message return associated with this message.
-     * 
+     *
      * @param message the message return to associate
      */
     protected void setMessageReturn(SyncMessageReturn message) {
@@ -198,7 +198,7 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
 
     /**
      * Returns the syncMessageReturn associated to this syncMessage
-     * 
+     *
      * @return the message return
      */
     public SyncMessageReturn getMessageReturn() {
@@ -207,11 +207,11 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
 
     /**
      * Set the time when the message occurs
-     * 
+     *
      * @param time the time when the message occurs
      */
     public void setTime(ITmfTimestamp time) {
-        fEventTime = time.clone();
+        fEventTime = time;
         fHasTimeInfo = true;
         if (getStartLifeline() != null && getStartLifeline().getFrame() != null) {
             getStartLifeline().getFrame().setHasTimeInfo(true);
@@ -232,7 +232,7 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
     /*
      * (non-Javadoc)
      * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getStartTime()
-     */ 
+     */
     @Override
     public ITmfTimestamp getStartTime() {
         return fEventTime;
@@ -241,7 +241,7 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
     /*
      * (non-Javadoc)
      * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#hasTimeInfo()
-     */ 
+     */
     @Override
     public boolean hasTimeInfo() {
         return fHasTimeInfo;
index ab528339dcfa49cd4e4443e89ba821be40eae4df..ec3ffb96a4986422f1871ab38fab134869d938ba 100644 (file)
@@ -237,7 +237,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
         fLock.lock();
         try {
             if (fCurrentTime != null) {
-                return fCurrentTime.clone();
+                return fCurrentTime;
             }
             return null;
         } finally {
@@ -307,10 +307,10 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
                         ++fNbSeqEvents;
 
                         if (fFirstTime == null) {
-                            fFirstTime = event.getTimestamp().clone();
+                            fFirstTime = event.getTimestamp();
                         }
 
-                        fLastTime = event.getTimestamp().clone();
+                        fLastTime = event.getTimestamp();
 
                         if ((fNbSeqEvents % MAX_NUM_OF_MSG) == 0) {
                             fLock.lock();
@@ -1190,7 +1190,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
                 return false;
             }
 
-            TmfTimeRange window = new TmfTimeRange(fCheckPoints.get(nextPage).getStartTime().clone(), fCheckPoints.get(fCheckPoints.size()-1).getEndTime().clone());
+            TmfTimeRange window = new TmfTimeRange(fCheckPoints.get(nextPage).getStartTime(), fCheckPoints.get(fCheckPoints.size()-1).getEndTime());
             fFindJob = new SearchJob(findCriteria, window);
             fFindJob.schedule();
             fView.toggleWaitCursorAsync(true);
@@ -1422,20 +1422,20 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
 
                 if (fCriteria.isLifeLineSelected()) {
                     if (fCriteria.matches(sdEvent.getSender())) {
-                        fFoundTime = event.getTimestamp().clone();
+                        fFoundTime = event.getTimestamp();
                         fIsFound = true;
                         super.cancel();
                     }
 
                     if (fCriteria.matches(sdEvent.getReceiver())) {
-                        fFoundTime = event.getTimestamp().clone();
+                        fFoundTime = event.getTimestamp();
                         fIsFound = true;
                         super.cancel();
                     }
                 }
 
                 if (fCriteria.isSyncMessageSelected() && fCriteria.matches(sdEvent.getName())) {
-                    fFoundTime = event.getTimestamp().clone();
+                    fFoundTime = event.getTimestamp();
                     fIsFound = true;
                     super.cancel();
                 }
This page took 0.043528 seconds and 5 git commands to generate.