Refactor TmfCheckpoint and dependencies
authorFrancois Chouinard <fchouinard@gmail.com>
Fri, 13 Apr 2012 20:13:19 +0000 (16:13 -0400)
committerFrancois Chouinard <fchouinard@gmail.com>
Fri, 13 Apr 2012 20:13:19 +0000 (16:13 -0400)
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngLocation.java
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngTimestamp.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfContextTest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfCheckpoint.java [new file with mode: 0644]
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/TmfContext.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfLocation.java

index c1865ac44f285b8d0b9550cf26b3fe40615f90db..4d693bfc423aadaac377c216b3189a98796951ae 100644 (file)
@@ -4,126 +4,126 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 
 
 public class LttngLocation implements ITmfLocation<LttngTimestamp>, Comparable<LttngLocation> {
-       
-       private final static long DEFAULT_CURR_TIME =  0L;
-       
-       private boolean isLastOperationParse = false ;
-       private boolean isLastOperationReadNext = false;
-       private boolean isLastOperationSeek = false;
-       
-       private LttngTimestamp operationTime = null;
-       
-       public LttngLocation() {
-               this( DEFAULT_CURR_TIME );
-       }
-       
-       public LttngLocation(long newCurrentTimestampValue) {
-               isLastOperationParse = false;
-               isLastOperationReadNext = false;
-               isLastOperationSeek = false;
-               operationTime = new LttngTimestamp(newCurrentTimestampValue);
-       }
-       
-       public LttngLocation(LttngTimestamp newCurrentTimestamp) {
-               isLastOperationParse = false;
-               isLastOperationReadNext = false;
-               isLastOperationSeek = false;
-               operationTime = new LttngTimestamp(newCurrentTimestamp);
-       }
-       
-       
-       public LttngLocation(LttngLocation oldLocation) {
-               this.isLastOperationParse = oldLocation.isLastOperationParse;
-               this.isLastOperationReadNext = oldLocation.isLastOperationReadNext;
-               this.isLastOperationSeek = oldLocation.isLastOperationSeek;
-               this.operationTime = oldLocation.operationTime;
-       }
-       
-       @Override
-       public LttngLocation clone() {
-               
-               LttngLocation newLocation = null;
-               
-               try {
-                       newLocation = (LttngLocation)super.clone();
-                       
-                       // *** IMPORTANT ***
-                       // Basic type in java are immutable!
-                       // Thus, using assignation ("=") on basic type is VALID.
-                       newLocation.isLastOperationParse = this.isLastOperationParse;
-                       newLocation.isLastOperationReadNext = this.isLastOperationReadNext;
-                       newLocation.isLastOperationSeek = this.isLastOperationSeek;
-                       
-                       // For other type, we need to create a new timestamp
-                       newLocation.operationTime  = new LttngTimestamp( this.operationTime );
-               } 
-               catch (CloneNotSupportedException e) {
-                       System.out.println("Cloning failed with : " + e.getMessage()); //$NON-NLS-1$
-               }
-
-               return newLocation;
-       }
-       
-       public LttngTimestamp getOperationTime() {
-               return operationTime;
-       }
-       
-       public long getOperationTimeValue() {
-               return operationTime.getValue();
-       }
-       
-       public void setOperationTime(LttngTimestamp newOperationTime) {
-               this.operationTime.setValue(newOperationTime.getValue());
-       }
-       
-       public void setOperationTime(Long newOperationTimeValue) {
-               this.operationTime.setValue(newOperationTimeValue);
-       }
-       
-       
-       public void setLastOperationParse() {
-               isLastOperationParse = true;
-               isLastOperationReadNext  = false;
-               isLastOperationSeek  = false;
-       }
-
-       public boolean isLastOperationParse() {
-               return isLastOperationParse;
-       }
-       
-       
-       public void setLastOperationReadNext() {
-               isLastOperationParse = false;
-               isLastOperationReadNext  = true;
-               isLastOperationSeek  = false;
-       }
-
-       public boolean isLastOperationReadNext() {
-               return isLastOperationReadNext;
-       }
-       
-       
-       public void setLastOperationSeek() {
-               isLastOperationParse = false;
-               isLastOperationReadNext  = false;
-               isLastOperationSeek  = true;
-       }
-
-       public boolean isLastOperationSeek() {
-               return isLastOperationSeek;
-       }
-       
-       public void resetLocationState() {
-               isLastOperationParse = false;
-               isLastOperationReadNext = false;
-               isLastOperationSeek = false;
-       }
-       
-       // ------------------------------------------------------------------------
-       // Object
-       // ------------------------------------------------------------------------
-
-       /* (non-Javadoc)
+
+    private final static long DEFAULT_CURR_TIME =  0L;
+
+    private boolean isLastOperationParse = false ;
+    private boolean isLastOperationReadNext = false;
+    private boolean isLastOperationSeek = false;
+
+    private LttngTimestamp operationTime = null;
+
+    public LttngLocation() {
+        this( DEFAULT_CURR_TIME );
+    }
+
+    public LttngLocation(final long newCurrentTimestampValue) {
+        isLastOperationParse = false;
+        isLastOperationReadNext = false;
+        isLastOperationSeek = false;
+        operationTime = new LttngTimestamp(newCurrentTimestampValue);
+    }
+
+    public LttngLocation(final LttngTimestamp newCurrentTimestamp) {
+        isLastOperationParse = false;
+        isLastOperationReadNext = false;
+        isLastOperationSeek = false;
+        operationTime = new LttngTimestamp(newCurrentTimestamp);
+    }
+
+
+    public LttngLocation(final LttngLocation oldLocation) {
+        this.isLastOperationParse = oldLocation.isLastOperationParse;
+        this.isLastOperationReadNext = oldLocation.isLastOperationReadNext;
+        this.isLastOperationSeek = oldLocation.isLastOperationSeek;
+        this.operationTime = oldLocation.operationTime;
+    }
+
+    @Override
+    public LttngLocation clone() {
+
+        LttngLocation newLocation = null;
+
+        try {
+            newLocation = (LttngLocation)super.clone();
+
+            // *** IMPORTANT ***
+            // Basic type in java are immutable!
+            // Thus, using assignation ("=") on basic type is VALID.
+            newLocation.isLastOperationParse = this.isLastOperationParse;
+            newLocation.isLastOperationReadNext = this.isLastOperationReadNext;
+            newLocation.isLastOperationSeek = this.isLastOperationSeek;
+
+            // For other type, we need to create a new timestamp
+            newLocation.operationTime  = new LttngTimestamp( this.operationTime );
+        }
+        catch (final CloneNotSupportedException e) {
+            System.out.println("Cloning failed with : " + e.getMessage()); //$NON-NLS-1$
+        }
+
+        return newLocation;
+    }
+
+    public LttngTimestamp getOperationTime() {
+        return operationTime;
+    }
+
+    public long getOperationTimeValue() {
+        return operationTime.getValue();
+    }
+
+    public void setOperationTime(final LttngTimestamp newOperationTime) {
+        this.operationTime.setValue(newOperationTime.getValue());
+    }
+
+    public void setOperationTime(final Long newOperationTimeValue) {
+        this.operationTime.setValue(newOperationTimeValue);
+    }
+
+
+    public void setLastOperationParse() {
+        isLastOperationParse = true;
+        isLastOperationReadNext  = false;
+        isLastOperationSeek  = false;
+    }
+
+    public boolean isLastOperationParse() {
+        return isLastOperationParse;
+    }
+
+
+    public void setLastOperationReadNext() {
+        isLastOperationParse = false;
+        isLastOperationReadNext  = true;
+        isLastOperationSeek  = false;
+    }
+
+    public boolean isLastOperationReadNext() {
+        return isLastOperationReadNext;
+    }
+
+
+    public void setLastOperationSeek() {
+        isLastOperationParse = false;
+        isLastOperationReadNext  = false;
+        isLastOperationSeek  = true;
+    }
+
+    public boolean isLastOperationSeek() {
+        return isLastOperationSeek;
+    }
+
+    public void resetLocationState() {
+        isLastOperationParse = false;
+        isLastOperationReadNext = false;
+        isLastOperationSeek = false;
+    }
+
+    // ------------------------------------------------------------------------
+    // Object
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
      * @see java.lang.Object#hashCode()
      */
     @Override
@@ -141,46 +141,43 @@ public class LttngLocation implements ITmfLocation<LttngTimestamp>, Comparable<L
      * @see java.lang.Object#equals(java.lang.Object)
      */
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
+    public boolean equals(final Object obj) {
+        if (this == obj)
             return true;
-        }
-        if (obj == null) {
+        if (obj == null)
             return false;
-        }
-        if (!(obj instanceof LttngLocation)) {
+        if (!(obj instanceof LttngLocation))
             return false;
-        }
-        LttngLocation o = (LttngLocation) obj;
+        final LttngLocation o = (LttngLocation) obj;
         return (operationTime.equals(o.operationTime))
-                        && (isLastOperationParse == o.isLastOperationParse)
-                        && (isLastOperationReadNext == o.isLastOperationReadNext)
-                        && (isLastOperationSeek == o.isLastOperationSeek);
+                && (isLastOperationParse == o.isLastOperationParse)
+                && (isLastOperationReadNext == o.isLastOperationReadNext)
+                && (isLastOperationSeek == o.isLastOperationSeek);
+    }
+
+    @Override
+    public String toString() {
+        //             return "\tLttngLocation[ P/R/S : "  + isLastOperationParse + "/" + isLastOperationReadNext + "/" + isLastOperationSeek + "  Current : " + operationTime + " ]";
+        return operationTime.toString();
+    }
+
+    // ------------------------------------------------------------------------
+    // ITmfLocation
+    // ------------------------------------------------------------------------
+
+    // @Override
+    public void setLocation(final LttngTimestamp location) {
+        operationTime  = location;
+    }
+
+    @Override
+    public LttngTimestamp getLocation() {
+        return new LttngTimestamp ( operationTime );
     }
 
     @Override
-       public String toString() {
-//             return "\tLttngLocation[ P/R/S : "  + isLastOperationParse + "/" + isLastOperationReadNext + "/" + isLastOperationSeek + "  Current : " + operationTime + " ]";
-               return operationTime.toString();
-       }
-       
-       // ------------------------------------------------------------------------
-       // ITmfLocation
-       // ------------------------------------------------------------------------
-
-//     @Override
-       public void setLocation(LttngTimestamp location) {
-               operationTime  = (LttngTimestamp)location;
-       }
-
-       @Override
-       public LttngTimestamp getLocation() {
-               return new LttngTimestamp ( operationTime );
-       }
-
-       @Override
-       public int compareTo(LttngLocation o) {
-               return operationTime.compareTo(o.operationTime);
-       }
-       
+    public int compareTo(final LttngLocation o) {
+        return operationTime.compareTo(o.operationTime);
+    }
+
 }
index e53aa0829ad006684eee59f126980f042b8d01c9..5d6380843dff710e64ade845b424cf49a9970e2a 100644 (file)
@@ -23,108 +23,106 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
  * The Lttng implementation is the same as the basic Tmf Implementation but allow construction with a TmfTimestamp or a long.
  */
 public class LttngTimestamp extends TmfTimestamp {
-    
+
     /**
      * Default Constructor.<p>
      * 
      */
-       public LttngTimestamp() {
-           this(Long.MIN_VALUE);
-       }
-       
-       /**
+    public LttngTimestamp() {
+        this(Long.MIN_VALUE);
+    }
+
+    /**
      * Constructor with parameters.<p>
      * 
      * @param newEventTime    Time as long, unit expected to be nanoseconds
      */
-    public LttngTimestamp(long newEventTime) {
+    public LttngTimestamp(final long newEventTime) {
         super(newEventTime, -9, 0);
     }
-    
+
     /**
      * Copy Constructor.<p>
      * 
      * @param oldEventTime    The timestamp object we want to copy from
      */
-    public LttngTimestamp(ITmfTimestamp oldEventTime) {
+    public LttngTimestamp(final ITmfTimestamp oldEventTime) {
         this(oldEventTime.getValue());
     }
-    
-    public void setValue(long newValue) {
+
+    public void setValue(final long newValue) {
         fValue = newValue;
     }
-    
-       /**
-        * Get the second part in timestamp.<p>
-        
-        * Note : We do not use scale and assumes contents to be in nano seconds.
-        
-        * @return Seconds in the object, in string.
-        */
-       public String getSeconds() {
-               return formatSecs(fValue);
-       }
-
-       /**
+
+    /**
+     * Get the second part in timestamp.<p>
+     * 
+     * Note : We do not use scale and assumes contents to be in nano seconds.
+     * 
+     * @return Seconds in the object, in string.
+     */
+    public String getSeconds() {
+        return formatSecs(fValue);
+    }
+
+    /**
      * Get the nanosecond part in timestamp.<p>
      * 
      * Note : We do not use scale and assumes contents to be in nanoseconds.
-        * 
-        * @return Seconds in the object, in string.
-        */
-       public String getNanoSeconds() {
-               return formatNs(fValue);
-       }
-       
-       /*
-        * Use the exponent to format the second in the correct format.
-        */
-       private String formatSecs(long time) {
-               long sec = (long) (time * 1E-9);
-               return String.valueOf(sec);
-       }
-
-       /*
-        * Obtains the remainder fraction on unit Seconds of the entered value in
-        * nanoseconds. e.g. input: 1241207054171080214 ns.
-        * The number of fraction seconds can be obtained by removing the last 9 digits: 
-        * In 1241207054, the fractional portion of seconds, expressed in ns is: 171080214
-        */
-       private String formatNs(long time) {
-               boolean neg = time < 0;
-               if (neg) {
-                       time = -time;
-               }
-               // The following approach could be used although performance
-               // decreases in half.
-               // String strVal = String.format("%09d", time);
-               // String tmp = strVal.substring(strVal.length() - 9)
-               StringBuffer temp = new StringBuffer();
-               long ns = time;
-               ns %= 1000000000;
-               if (ns < 10) {
-                       temp.append("00000000"); //$NON-NLS-1$
-               } else if (ns < 100) {
-                       temp.append("0000000"); //$NON-NLS-1$
-               } else if (ns < 1000) {
-                       temp.append("000000"); //$NON-NLS-1$
-               } else if (ns < 10000) {
-                       temp.append("00000"); //$NON-NLS-1$
-               } else if (ns < 100000) {
-                       temp.append("0000"); //$NON-NLS-1$
-               } else if (ns < 1000000) {
-                       temp.append("000"); //$NON-NLS-1$
-               } else if (ns < 10000000) {
-                       temp.append("00"); //$NON-NLS-1$
-               } else if (ns < 100000000) {
-                       temp.append("0"); //$NON-NLS-1$
-               }
-
-               temp.append(ns);
-               return temp.toString();
-       }
-
-       
+     * 
+     * @return Seconds in the object, in string.
+     */
+    public String getNanoSeconds() {
+        return formatNs(fValue);
+    }
+
+    /*
+     * Use the exponent to format the second in the correct format.
+     */
+    private String formatSecs(final long time) {
+        final long sec = (long) (time * 1E-9);
+        return String.valueOf(sec);
+    }
+
+    /*
+     * Obtains the remainder fraction on unit Seconds of the entered value in
+     * nanoseconds. e.g. input: 1241207054171080214 ns.
+     * The number of fraction seconds can be obtained by removing the last 9 digits:
+     * In 1241207054, the fractional portion of seconds, expressed in ns is: 171080214
+     */
+    private String formatNs(long time) {
+        final boolean neg = time < 0;
+        if (neg)
+            time = -time;
+        // The following approach could be used although performance
+        // decreases in half.
+        // String strVal = String.format("%09d", time);
+        // String tmp = strVal.substring(strVal.length() - 9)
+        final StringBuffer temp = new StringBuffer();
+        long ns = time;
+        ns %= 1000000000;
+        if (ns < 10)
+            temp.append("00000000"); //$NON-NLS-1$
+        else if (ns < 100)
+            temp.append("0000000"); //$NON-NLS-1$
+        else if (ns < 1000)
+            temp.append("000000"); //$NON-NLS-1$
+        else if (ns < 10000)
+            temp.append("00000"); //$NON-NLS-1$
+        else if (ns < 100000)
+            temp.append("0000"); //$NON-NLS-1$
+        else if (ns < 1000000)
+            temp.append("000"); //$NON-NLS-1$
+        else if (ns < 10000000)
+            temp.append("00"); //$NON-NLS-1$
+        else if (ns < 100000000)
+            temp.append("0"); //$NON-NLS-1$
+
+        temp.append(ns);
+        return temp.toString();
+    }
+
+
     /**
      * toString() method.
      * 
@@ -132,45 +130,42 @@ public class LttngTimestamp extends TmfTimestamp {
      */
     @Override
     @SuppressWarnings("nls")
-       public String toString() {
+    public String toString() {
 
         long value = fValue;
-        if (fValue < 0) {
-            value = -fValue; 
-        }
-        
-        StringBuilder sb = new StringBuilder(String.valueOf(value));
+        if (fValue < 0)
+            value = -fValue;
+
+        final StringBuilder sb = new StringBuilder(String.valueOf(value));
 
         // Prepend the correct number of "0" so we can insert a "." at the right location
-        int nbZeroes = (-fScale) - sb.length() + 1;  
-        for (int i = 0; i < nbZeroes; i++) {
+        final int nbZeroes = (-fScale) - sb.length() + 1;
+        for (int i = 0; i < nbZeroes; i++)
             sb.insert(i, "0");
-        }
         sb.insert(sb.length() + fScale, ".");
-        
+
         // Prepend "-" if negative
-        if (fValue < 0) {
+        if (fValue < 0)
             sb.insert(0, "-");
-        }
-        
+
         return sb.toString();
     }
 
     @Override
     public LttngTimestamp clone() {
-       return (LttngTimestamp) super.clone();
+        return (LttngTimestamp) super.clone();
     }
 
     /**
      * Compute the delta between two timestamps (adjusted to scale of current timestamp).
      * 
      * @param reference the reference timestamp to synchronize with
-     * @return the delta timestamp 
+     * @return the delta timestamp
      * @throws ArithmeticException
      */
     @Override
-    public LttngTimestamp getDelta(ITmfTimestamp other) {
-        TmfTimestamp delta = (TmfTimestamp) super.getDelta(other);
-        return new LttngTimestamp(delta); 
+    public LttngTimestamp getDelta(final ITmfTimestamp other) {
+        final TmfTimestamp delta = (TmfTimestamp) super.getDelta(other);
+        return new LttngTimestamp(delta);
     }
 }
index 2589e83ed4e5d964af616c868894724928fbc9d8..5e15ffd749f5fa0eb582ea22831b092f699348cf 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * Copyright (c) 2009, 2010, 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
@@ -27,158 +27,192 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
 @SuppressWarnings("nls")
 public class TmfCheckpointTest extends TestCase {
 
-       // ------------------------------------------------------------------------
-       // Variables
-       // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Variables
+    // ------------------------------------------------------------------------
+
+    ITmfTimestamp fTimestamp1 = new TmfTimestamp();
+    ITmfTimestamp fTimestamp2 = TmfTimestamp.BIG_BANG;
+    ITmfTimestamp fTimestamp3 = TmfTimestamp.BIG_CRUNCH;
 
-       ITmfTimestamp fTimestamp1 = new TmfTimestamp();
-       ITmfTimestamp fTimestamp2 = TmfTimestamp.BIG_BANG;
-       ITmfTimestamp fTimestamp3 = TmfTimestamp.BIG_CRUNCH;
+    Long aLong1 = 12345L;
+    Long aLong2 = 23456L;
+    Long aLong3 = 34567L;
+    TmfLocation<Long> fLocation1 = new TmfLocation<Long>(aLong1);
+    TmfLocation<Long> fLocation2 = new TmfLocation<Long>(aLong2);
+    TmfLocation<Long> fLocation3 = new TmfLocation<Long>(aLong3);
 
-       Long aLong1 = 12345L;
-       Long aLong2 = 23456L;
-       Long aLong3 = 34567L;
-       TmfLocation<Long> fLocation1 = new TmfLocation<Long>(aLong1);
-       TmfLocation<Long> fLocation2 = new TmfLocation<Long>(aLong2);
-       TmfLocation<Long> fLocation3 = new TmfLocation<Long>(aLong3);
+    TmfCheckpoint fCheckpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1);
+    TmfCheckpoint fCheckpoint2 = new TmfCheckpoint(fTimestamp2, fLocation2);
+    TmfCheckpoint fCheckpoint3 = new TmfCheckpoint(fTimestamp3, fLocation3);
 
-       TmfCheckpoint fCheckpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1);
-       TmfCheckpoint fCheckpoint2 = new TmfCheckpoint(fTimestamp2, fLocation2);
-       TmfCheckpoint fCheckpoint3 = new TmfCheckpoint(fTimestamp3, fLocation3);
-       
     // ------------------------------------------------------------------------
     // Housekeeping
     // ------------------------------------------------------------------------
 
-       /**
-        * @param name the test name
-        */
-       public TmfCheckpointTest(String name) {
-               super(name);
-       }
+    /**
+     * @param name the test name
+     */
+    public TmfCheckpointTest(final String name) {
+        super(name);
+    }
 
-       @Override
-       protected void setUp() throws Exception {
-               super.setUp();
-       }
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
 
-       @Override
-       protected void tearDown() throws Exception {
-               super.tearDown();
-       }
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
 
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
 
-       public void testTmfCheckpoint() {
-               assertEquals("TmfCheckpoint", fTimestamp1, fCheckpoint1.getTimestamp());
-               assertEquals("TmfCheckpoint", fLocation1,  fCheckpoint1.getLocation());
-       }
+    public void testTmfCheckpoint() {
+        assertEquals("TmfCheckpoint", fTimestamp1, fCheckpoint1.getTimestamp());
+        assertEquals("TmfCheckpoint", fLocation1,  fCheckpoint1.getLocation());
+    }
+
+    public void testTmfLocationCopy() {
+        final TmfCheckpoint checkpoint = new TmfCheckpoint(fCheckpoint1);
+
+        assertEquals("TmfCheckpoint", fTimestamp1, checkpoint.getTimestamp());
+        assertEquals("TmfCheckpoint", fLocation1,  checkpoint.getLocation());
+    }
+
+    public void testTmfLocationCopy2() throws Exception {
+        try {
+            new TmfCheckpoint(null);
+            fail("null copy");
+        }
+        catch (final IllegalArgumentException e) {
+            // Success
+        }
+        catch (final Exception e) {
+            fail("wrong exception");
+        }
+    }
 
-       public void testTmfLocationCopy() {
-               TmfCheckpoint checkpoint = new TmfCheckpoint(fCheckpoint1);
-
-               assertEquals("TmfCheckpoint", fTimestamp1, checkpoint.getTimestamp());
-               assertEquals("TmfCheckpoint", fLocation1,  checkpoint.getLocation());
-       }
+    // ------------------------------------------------------------------------
+    // clone
+    // ------------------------------------------------------------------------
 
-       public void testTmfLocationCopy2() throws Exception {
-               try {
-                       new TmfCheckpoint(null);
-                       fail("null copy");
-               }
-               catch (IllegalArgumentException e) {
-                       // Success
-               }
-       }
+    public void testClone() {
+        try {
+            TmfCheckpoint checkpoint1 = fCheckpoint1.clone();
+            TmfCheckpoint checkpoint2 = fCheckpoint1.clone();
+            TmfCheckpoint checkpoint3 = fCheckpoint1.clone();
+
+            assertEquals("clone", checkpoint1, fCheckpoint1);
+            assertEquals("clone", checkpoint2, fCheckpoint1);
+            assertEquals("clone", checkpoint3, fCheckpoint1);
+
+            checkpoint1 = new TmfCheckpoint(fTimestamp1, null);
+            checkpoint2 = checkpoint1.clone();
+            assertEquals("clone", checkpoint1, checkpoint2);
+            assertNull(checkpoint1.getLocation());
+            assertNull(checkpoint2.getLocation());
+
+            checkpoint1 = new TmfCheckpoint(null, fLocation1);
+            checkpoint3 = checkpoint1.clone();
+            assertEquals("clone", checkpoint1, checkpoint3);
+            assertNull(checkpoint1.getTimestamp());
+            assertNull(checkpoint3.getTimestamp());
+
+        } catch (final InternalError e) {
+            fail("clone()");
+        }
+    }
 
     // ------------------------------------------------------------------------
     // equals
     // ------------------------------------------------------------------------
 
-       public void testEqualsReflexivity() throws Exception {
-               assertTrue("equals", fCheckpoint1.equals(fCheckpoint1));
-               assertTrue("equals", fCheckpoint2.equals(fCheckpoint2));
-
-               assertTrue("equals", !fCheckpoint1.equals(fCheckpoint2));
-               assertTrue("equals", !fCheckpoint2.equals(fCheckpoint1));
-       }
-       
-       public void testEqualsSymmetry() throws Exception {
-               TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
-               TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
-
-               assertTrue("equals", checkpoint1.equals(fCheckpoint1));
-               assertTrue("equals", fCheckpoint1.equals(checkpoint1));
-
-               assertTrue("equals", checkpoint2.equals(fCheckpoint2));
-               assertTrue("equals", fCheckpoint2.equals(checkpoint2));
-       }
-       
-       public void testEqualsTransivity() throws Exception {
-               TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
-               TmfCheckpoint checkpoint2 = new TmfCheckpoint(checkpoint1);
-               TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint2);
-
-               assertTrue("equals", checkpoint1.equals(checkpoint2));
-               assertTrue("equals", checkpoint2.equals(checkpoint3));
-               assertTrue("equals", checkpoint1.equals(checkpoint3));
-       }
-       
-       public void testEqualsNull() throws Exception {
-               assertTrue("equals", !fCheckpoint1.equals(null));
-               assertTrue("equals", !fCheckpoint2.equals(null));
-       }
-       
-       // ------------------------------------------------------------------------
-       // hashCode
-       // ------------------------------------------------------------------------
-
-       public void testHashCode() throws Exception {
-               TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
-               TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
-
-               assertTrue("hashCode", fCheckpoint1.hashCode() == checkpoint1.hashCode());
-               assertTrue("hashCode", fCheckpoint2.hashCode() == checkpoint2.hashCode());
-
-               assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
-               assertTrue("hashCode", fCheckpoint2.hashCode() != checkpoint1.hashCode());
-       }
-       
+    public void testEqualsReflexivity() throws Exception {
+        assertTrue("equals", fCheckpoint1.equals(fCheckpoint1));
+        assertTrue("equals", fCheckpoint2.equals(fCheckpoint2));
+
+        assertTrue("equals", !fCheckpoint1.equals(fCheckpoint2));
+        assertTrue("equals", !fCheckpoint2.equals(fCheckpoint1));
+    }
+
+    public void testEqualsSymmetry() throws Exception {
+        final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
+        final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
+
+        assertTrue("equals", checkpoint1.equals(fCheckpoint1));
+        assertTrue("equals", fCheckpoint1.equals(checkpoint1));
+
+        assertTrue("equals", checkpoint2.equals(fCheckpoint2));
+        assertTrue("equals", fCheckpoint2.equals(checkpoint2));
+    }
+
+    public void testEqualsTransivity() throws Exception {
+        final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
+        final TmfCheckpoint checkpoint2 = new TmfCheckpoint(checkpoint1);
+        final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint2);
+
+        assertTrue("equals", checkpoint1.equals(checkpoint2));
+        assertTrue("equals", checkpoint2.equals(checkpoint3));
+        assertTrue("equals", checkpoint1.equals(checkpoint3));
+    }
+
+    public void testEqualsNull() throws Exception {
+        assertTrue("equals", !fCheckpoint1.equals(null));
+        assertTrue("equals", !fCheckpoint2.equals(null));
+    }
+
+    // ------------------------------------------------------------------------
+    // hashCode
+    // ------------------------------------------------------------------------
+
+    public void testHashCode() throws Exception {
+        final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
+        final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
+
+        assertTrue("hashCode", fCheckpoint1.hashCode() == checkpoint1.hashCode());
+        assertTrue("hashCode", fCheckpoint2.hashCode() == checkpoint2.hashCode());
+
+        assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
+        assertTrue("hashCode", fCheckpoint2.hashCode() != checkpoint1.hashCode());
+    }
+
     // ------------------------------------------------------------------------
     // toString
     // ------------------------------------------------------------------------
 
-       public void testToString() {
-               String expected1 = "[TmfCheckpoint(" + fCheckpoint1.getTimestamp() +  "," + 
-                       fCheckpoint1.getLocation() + ")]";
-               String expected2 = "[TmfCheckpoint(" + fCheckpoint2.getTimestamp() +  "," + 
-                       fCheckpoint2.getLocation() + ")]";
-               String expected3 = "[TmfCheckpoint(" + fCheckpoint3.getTimestamp() +  "," + 
-                       fCheckpoint3.getLocation() + ")]";
+    public void testToString() {
+        final String expected1 = "TmfCheckpoint [fLocation=" + fCheckpoint1.getLocation() +
+                ", fTimestamp=" + fCheckpoint1.getTimestamp() + "]";
+        final String expected2 = "TmfCheckpoint [fLocation=" + fCheckpoint2.getLocation() +
+                ", fTimestamp=" + fCheckpoint2.getTimestamp() + "]";
+        final String expected3 = "TmfCheckpoint [fLocation=" + fCheckpoint3.getLocation() +
+                ", fTimestamp=" + fCheckpoint3.getTimestamp() + "]";
 
-               assertEquals("toString", expected1, fCheckpoint1.toString());
-               assertEquals("toString", expected2, fCheckpoint2.toString());
-               assertEquals("toString", expected3, fCheckpoint3.toString());
-       }
+        assertEquals("toString", expected1, fCheckpoint1.toString());
+        assertEquals("toString", expected2, fCheckpoint2.toString());
+        assertEquals("toString", expected3, fCheckpoint3.toString());
+    }
 
     // ------------------------------------------------------------------------
     // compareTo
     // ------------------------------------------------------------------------
 
-       public void testCompareTo() {
-               assertEquals("compareTo",  0, fCheckpoint1.compareTo(fCheckpoint1));
-               assertEquals("compareTo",  1, fCheckpoint1.compareTo(fCheckpoint2));
-               assertEquals("compareTo", -1, fCheckpoint1.compareTo(fCheckpoint3));
+    public void testCompareTo() {
+        assertEquals("compareTo",  0, fCheckpoint1.compareTo(fCheckpoint1));
+        assertEquals("compareTo",  1, fCheckpoint1.compareTo(fCheckpoint2));
+        assertEquals("compareTo", -1, fCheckpoint1.compareTo(fCheckpoint3));
 
-               assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint1));
-               assertEquals("compareTo",  0, fCheckpoint2.compareTo(fCheckpoint2));
-               assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint3));
+        assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint1));
+        assertEquals("compareTo",  0, fCheckpoint2.compareTo(fCheckpoint2));
+        assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint3));
 
-               assertEquals("compareTo",  1, fCheckpoint3.compareTo(fCheckpoint1));
-               assertEquals("compareTo",  1, fCheckpoint3.compareTo(fCheckpoint2));
-               assertEquals("compareTo",  0, fCheckpoint3.compareTo(fCheckpoint3));
-       }
+        assertEquals("compareTo",  1, fCheckpoint3.compareTo(fCheckpoint1));
+        assertEquals("compareTo",  1, fCheckpoint3.compareTo(fCheckpoint2));
+        assertEquals("compareTo",  0, fCheckpoint3.compareTo(fCheckpoint3));
+    }
 
 }
index 558211dd7ff2ad61d8742954bbaf191d71aa06e8..9eb3db9115c96930128d2e0509ab38eeedeb9ec6 100644 (file)
@@ -117,6 +117,19 @@ public class TmfContextTest extends TestCase {
         assertEquals("getRank", fRank3, context3.getRank());
     }
 
+    public void testTmfContextCopy2() {
+        try {
+            new TmfContext((TmfContext) null);
+            fail("Copy constructor: no exception");
+        }
+        catch (final IllegalArgumentException e) {
+            // pass
+        }
+        catch (final Exception e) {
+            fail("Copy constructor: wrong exception");
+        }
+    }
+
     // ------------------------------------------------------------------------
     // equals
     // ------------------------------------------------------------------------
@@ -232,6 +245,13 @@ public class TmfContextTest extends TestCase {
             assertEquals("clone", context1, fContext1);
             assertEquals("clone", context2, fContext2);
             assertEquals("clone", context3, fContext3);
+
+            context1.setLocation(null);
+            final TmfContext context4 = context1.clone();
+            assertEquals("clone", context1, context4);
+            assertNull(context1.getLocation());
+            assertNull(context4.getLocation());
+
         } catch (final InternalError e) {
             fail("clone()");
         }
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfCheckpoint.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfCheckpoint.java
new file mode 100644 (file)
index 0000000..ef4aec8
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+
+/**
+ * <b><u>ITmfCheckpoint</u></b>
+ * <p>
+ * The basic trace checkpoint structure in TMF. The purpose of the checkpoint is
+ * to associate a trace location to an event timestamp.
+ */
+public interface ITmfCheckpoint extends Cloneable, Comparable<ITmfCheckpoint> {
+
+    // ------------------------------------------------------------------------
+    // Getters
+    // ------------------------------------------------------------------------
+
+    /**
+     * @return the timestamp of the event referred to by the context
+     */
+    public ITmfTimestamp getTimestamp();
+
+    /**
+     * @return the location of the event referred to by the context
+     */
+    public ITmfLocation<? extends Comparable<?>> getLocation();
+
+    // ------------------------------------------------------------------------
+    // Cloneable
+    // ------------------------------------------------------------------------
+
+    /**
+     * @return a clone of the checkpoint
+     */
+    public ITmfCheckpoint clone();
+
+    // ------------------------------------------------------------------------
+    // Comparable
+    // ------------------------------------------------------------------------
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Comparable#compareTo(java.lang.Object)
+     */
+    @Override
+    public int compareTo(ITmfCheckpoint checkpoint);
+
+}
index fb214d13abd25fdd9951b0cb93b7b557176a788c..370fc1c220678940f6ab052052e808f4fbd3657f 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009 Ericsson
+ * 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
@@ -8,7 +8,8 @@
  * 
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
+ *   Francois Chouinard - Updated as per TMF Trace Model 1.0
+ ******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.trace;
 
@@ -19,43 +20,69 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
  * <p>
  * This class maps an event timestamp to a generic location.
  */
-@SuppressWarnings("rawtypes")
-public class TmfCheckpoint implements Comparable<TmfCheckpoint>, Cloneable {
+public class TmfCheckpoint implements ITmfCheckpoint {
 
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
 
+    // The checkpoint location
+    private ITmfLocation<? extends Comparable<?>> fLocation;
+
+    // The checkpoint timestamp
     private ITmfTimestamp fTimestamp;
-    private ITmfLocation<? extends Comparable> fLocation;
 
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
 
+    /**
+     * Default constructor
+     */
     @SuppressWarnings("unused")
     private TmfCheckpoint() {
     }
 
     /**
-     * @param ts the checkpoint timestamp
+     * Full constructor
+     * 
+     * @param timestamp the checkpoint timestamp
      * @param location the corresponding trace location
      */
-    public TmfCheckpoint(final ITmfTimestamp ts, final ITmfLocation<? extends Comparable> location) {
-        fTimestamp = ts;
+    public TmfCheckpoint(final ITmfTimestamp timestamp, final ITmfLocation<? extends Comparable<?>> location) {
+        fTimestamp = timestamp;
         fLocation = location;
     }
 
     /**
-     * Deep copy constructor
+     * Copy constructor
      * 
      * @param other the other checkpoint
      */
     public TmfCheckpoint(final TmfCheckpoint other) {
         if (other == null)
             throw new IllegalArgumentException();
-        fTimestamp = other.fTimestamp.clone();
-        fLocation = other.fLocation.clone();
+        fTimestamp = other.fTimestamp;
+        fLocation = other.fLocation;
+    }
+
+    // ------------------------------------------------------------------------
+    // Cloneable
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#clone()
+     */
+    @Override
+    public TmfCheckpoint clone() {
+        TmfCheckpoint clone = null;
+        try {
+            clone = (TmfCheckpoint) super.clone();
+            clone.fLocation = (fLocation != null) ? fLocation.clone() : null;
+            clone.fTimestamp = (fTimestamp != null) ? fTimestamp.clone() : null;
+        } catch (final CloneNotSupportedException e) {
+        }
+        return clone;
     }
 
     // ------------------------------------------------------------------------
@@ -65,6 +92,7 @@ public class TmfCheckpoint implements Comparable<TmfCheckpoint>, Cloneable {
     /**
      * @return the checkpoint timestamp
      */
+    @Override
     public ITmfTimestamp getTimestamp() {
         return fTimestamp;
     }
@@ -72,57 +100,65 @@ public class TmfCheckpoint implements Comparable<TmfCheckpoint>, Cloneable {
     /**
      * @return the checkpoint stream location
      */
+    @Override
     public ITmfLocation<?> getLocation() {
         return fLocation;
     }
 
     // ------------------------------------------------------------------------
-    // Object
+    // Comparable
     // ------------------------------------------------------------------------
 
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     @Override
-    public TmfCheckpoint clone() {
-        TmfCheckpoint result = null;
-        try {
-            result = (TmfCheckpoint) super.clone();
-            result.fTimestamp = fTimestamp.clone();
-            result.fLocation = fLocation.clone();
-            return result;
-        } catch (final CloneNotSupportedException e) {
-            e.printStackTrace();
+    public int compareTo(final ITmfCheckpoint other) {
+        if (fTimestamp == null || other.getTimestamp() == null) {
+            final Comparable location1 = fLocation.getLocation();
+            final Comparable location2 = other.getLocation().getLocation();
+            return location1.compareTo(location2);
         }
-        return result;
+        return fTimestamp.compareTo(other.getTimestamp(), false);
     }
 
+    // ------------------------------------------------------------------------
+    // Object
+    // ------------------------------------------------------------------------
+
     @Override
     public int hashCode() {
-        return fTimestamp.hashCode();
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((fLocation == null) ? 0 : fLocation.hashCode());
+        result = prime * result + ((fTimestamp == null) ? 0 : fTimestamp.hashCode());
+        return result;
     }
 
     @Override
-    public boolean equals(final Object other) {
-        if (!(other instanceof TmfCheckpoint))
+    public boolean equals(final Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (!(obj instanceof TmfCheckpoint))
             return false;
-        final TmfCheckpoint o = (TmfCheckpoint) other;
-        return fTimestamp.equals(o.fTimestamp);
+        final TmfCheckpoint other = (TmfCheckpoint) obj;
+        if (fLocation == null) {
+            if (other.fLocation != null)
+                return false;
+        } else if (!fLocation.equals(other.fLocation))
+            return false;
+        if (fTimestamp == null) {
+            if (other.fTimestamp != null)
+                return false;
+        } else if (!fTimestamp.equals(other.fTimestamp))
+            return false;
+        return true;
     }
 
     @Override
     @SuppressWarnings("nls")
     public String toString() {
-        return "[TmfCheckpoint(" + fTimestamp + "," + fLocation + ")]";
-    }
-
-    // ------------------------------------------------------------------------
-    // Comparable
-    // ------------------------------------------------------------------------
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public int compareTo(final TmfCheckpoint other) {
-        if (fTimestamp == null || other.fTimestamp == null)
-            return fLocation.getLocation().compareTo(other.fLocation.getLocation());
-        return fTimestamp.compareTo(other.fTimestamp, false);
+        return "TmfCheckpoint [fLocation=" + fLocation + ", fTimestamp=" + fTimestamp + "]";
     }
 
 }
index 173a9b69da7495f33ed0976fbb690de09395043b..1b67039e5ad1d92dd9083969864e02fac1497650 100644 (file)
@@ -48,7 +48,7 @@ public class TmfContext implements ITmfContext, Cloneable {
      * 
      * @param location the event location
      */
-    public TmfContext(ITmfLocation<? extends Comparable<?>> location) {
+    public TmfContext(final ITmfLocation<? extends Comparable<?>> location) {
         this(location, UNKNOWN_RANK);
     }
 
@@ -58,7 +58,7 @@ public class TmfContext implements ITmfContext, Cloneable {
      * @param location the event location
      * @param rank the event rank
      */
-    public TmfContext(ITmfLocation<? extends Comparable<?>> location, long rank) {
+    public TmfContext(final ITmfLocation<? extends Comparable<?>> location, final long rank) {
         fLocation = location;
         fRank = rank;
     }
@@ -68,8 +68,11 @@ public class TmfContext implements ITmfContext, Cloneable {
      * 
      * @param context the other context
      */
-    public TmfContext(TmfContext context) {
-        this(context.fLocation, context.fRank);
+    public TmfContext(final TmfContext context) {
+        if (context == null)
+            throw new IllegalArgumentException();
+        fLocation = context.fLocation;
+        fRank = context.fRank;
     }
 
     // ------------------------------------------------------------------------
@@ -84,9 +87,9 @@ public class TmfContext implements ITmfContext, Cloneable {
         TmfContext clone = null;
         try {
             clone = (TmfContext) super.clone();
-            clone.fLocation = fLocation.clone();
+            clone.fLocation = (fLocation != null) ? fLocation.clone() : null;
             clone.fRank = fRank;
-        } catch (CloneNotSupportedException e) {
+        } catch (final CloneNotSupportedException e) {
         }
         return clone;
     }
@@ -107,7 +110,7 @@ public class TmfContext implements ITmfContext, Cloneable {
      * @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#setLocation(org.eclipse.linuxtools.tmf.core.trace.ITmfLocation)
      */
     @Override
-    public void setLocation(ITmfLocation<? extends Comparable<?>> location) {
+    public void setLocation(final ITmfLocation<? extends Comparable<?>> location) {
         fLocation = location;
     }
 
@@ -123,7 +126,7 @@ public class TmfContext implements ITmfContext, Cloneable {
      * @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#setRank(long)
      */
     @Override
-    public void setRank(long rank) {
+    public void setRank(final long rank) {
         fRank = rank;
     }
 
@@ -171,14 +174,14 @@ public class TmfContext implements ITmfContext, Cloneable {
      * @see java.lang.Object#equals(java.lang.Object)
      */
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj)
             return true;
         if (obj == null)
             return false;
         if (getClass() != obj.getClass())
             return false;
-        TmfContext other = (TmfContext) obj;
+        final TmfContext other = (TmfContext) obj;
         if (fLocation == null) {
             if (other.fLocation != null)
                 return false;
index 7b56b9c0de921b298e4a1e719245efc3d640a2b0..7b00f324ef7b7690d9218e8812efb7a795342f5d 100644 (file)
@@ -27,8 +27,11 @@ public class TmfLocation<L extends Comparable<L>> implements ITmfLocation<L> {
     // Constants
     // ------------------------------------------------------------------------
 
+    /**
+     * The 'null' location
+     */
     static public final TmfLocation<Boolean> NULL_LOCATION = new TmfLocation<Boolean>();
-    
+
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
@@ -51,7 +54,7 @@ public class TmfLocation<L extends Comparable<L>> implements ITmfLocation<L> {
      * 
      * @param location the trace location
      */
-    public TmfLocation(L location) {
+    public TmfLocation(final L location) {
         fLocation = location;
     }
 
@@ -60,7 +63,7 @@ public class TmfLocation<L extends Comparable<L>> implements ITmfLocation<L> {
      * 
      * @param other the original location
      */
-    public TmfLocation(TmfLocation<L> location) {
+    public TmfLocation(final TmfLocation<L> location) {
         fLocation = location.fLocation;
     }
 
@@ -90,16 +93,15 @@ public class TmfLocation<L extends Comparable<L>> implements ITmfLocation<L> {
         try {
             clone = (TmfLocation<L>) super.clone();
             if (fLocation != null) {
-                Class<?> clazz = fLocation.getClass();
-                Method method = clazz.getMethod("clone", new Class[0]); //$NON-NLS-1$
-                Object copy = method.invoke(this.fLocation, new Object[0]);
+                final Class<?> clazz = fLocation.getClass();
+                final Method method = clazz.getMethod("clone", new Class[0]); //$NON-NLS-1$
+                final Object copy = method.invoke(this.fLocation, new Object[0]);
                 clone.fLocation = (L) copy;
-            } else {
+            } else
                 clone.fLocation = null;
-            }
-        } catch (CloneNotSupportedException e) {
-        } catch (NoSuchMethodException e) {
-        } catch (Exception e) {
+        } catch (final CloneNotSupportedException e) {
+        } catch (final NoSuchMethodException e) {
+        } catch (final Exception e) {
             throw new InternalError(e.toString());
         }
         return clone;
@@ -125,14 +127,14 @@ public class TmfLocation<L extends Comparable<L>> implements ITmfLocation<L> {
      */
     @Override
     @SuppressWarnings("unchecked")
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj)
             return true;
         if (obj == null)
             return false;
         if (getClass() != obj.getClass())
             return false;
-        TmfLocation<L> other = (TmfLocation<L>) obj;
+        final TmfLocation<L> other = (TmfLocation<L>) obj;
         if (fLocation == null) {
             if (other.fLocation != null)
                 return false;
This page took 0.045497 seconds and 5 git commands to generate.