to be consistent with the base classes.
Change-Id: I4df517752773d7ceb0d1a5444832ab178464bace
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/10239
Tested-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationData;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
@Before
public void setUp() throws TmfTraceException {
fixture = new CtfIterator(createTrace());
- CtfLocation ctfLocation = new CtfLocation(new CtfLocationData(1, 0));
+ CtfLocation ctfLocation = new CtfLocation(new CtfLocationInfo(1, 0));
fixture.setLocation(ctfLocation);
fixture.increaseRank();
}
CtfTmfTrace trace = createTrace();
long timestampValue = 1L;
long rank = 1L;
- CtfIterator result = new CtfIterator(trace, new CtfLocationData(timestampValue, 0), rank);
+ CtfIterator result = new CtfIterator(trace, new CtfLocationInfo(timestampValue, 0), rank);
assertNotNull(result);
}
@Test
public void testEquals_other() throws TmfTraceException {
CtfIterator obj = new CtfIterator(createTrace());
- CtfLocation ctfLocation1 = new CtfLocation(new CtfLocationData(1, 0));
+ CtfLocation ctfLocation1 = new CtfLocation(new CtfLocationInfo(1, 0));
obj.setLocation(ctfLocation1);
obj.increaseRank();
*/
@Test
public void testSetLocation() {
- CtfLocation location = new CtfLocation(new CtfLocationData(1, 0));
+ CtfLocation location = new CtfLocation(new CtfLocationInfo(1, 0));
fixture.setLocation(location);
}
}
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationData;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
import org.junit.Before;
import org.junit.Test;
/**
- * Collection of tests for the {@link CtfLocationData}
+ * Collection of tests for the {@link CtfLocationInfo}
*
* @author alexmont
*/
public class CtfLocationDataTest {
- private CtfLocationData fixture;
+ private CtfLocationInfo fixture;
/**
* Perform pre-test initialization.
*/
@Before
public void setUp() {
- fixture = new CtfLocationData(1, 0);
+ fixture = new CtfLocationInfo(1, 0);
}
/**
*/
@Test
public void testEquals() {
- CtfLocationData same = new CtfLocationData(1, 0);
- CtfLocationData diff1 = new CtfLocationData(100, 0);
- CtfLocationData diff2 = new CtfLocationData(1, 10);
+ CtfLocationInfo same = new CtfLocationInfo(1, 0);
+ CtfLocationInfo diff1 = new CtfLocationInfo(100, 0);
+ CtfLocationInfo diff2 = new CtfLocationInfo(1, 10);
assertTrue(fixture.equals(same));
assertFalse(fixture.equals(diff1));
*/
@Test
public void testCompareTo() {
- CtfLocationData same = new CtfLocationData(1, 0);
- CtfLocationData smaller = new CtfLocationData(0, 0);
- CtfLocationData bigger1 = new CtfLocationData(1000, 500);
- CtfLocationData bigger2 = new CtfLocationData(1, 1);
+ CtfLocationInfo same = new CtfLocationInfo(1, 0);
+ CtfLocationInfo smaller = new CtfLocationInfo(0, 0);
+ CtfLocationInfo bigger1 = new CtfLocationInfo(1000, 500);
+ CtfLocationInfo bigger2 = new CtfLocationInfo(1, 1);
assertEquals(0, same.compareTo(fixture));
assertEquals(-1, smaller.compareTo(fixture));
import static org.junit.Assert.assertNotNull;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationData;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.junit.Before;
*/
@Before
public void setUp() {
- fixture = new CtfLocation(new CtfLocationData(1, 0));
+ fixture = new CtfLocation(new CtfLocationInfo(1, 0));
}
/**
*/
@Test
public void testCtfLocation_long() {
- CtfLocationData location = new CtfLocationData(1, 0);
+ CtfLocationInfo location = new CtfLocationInfo(1, 0);
CtfLocation result = new CtfLocation(location);
assertNotNull(result);
*/
@Test
public void testGetLocation() {
- CtfLocationData location = fixture.getLocationInfo();
+ CtfLocationInfo location = fixture.getLocationInfo();
Long result = location.getTimestamp();
assertNotNull(result);
assertEquals("1", result.toString()); //$NON-NLS-1$
*/
@Test
public void testSetLocation() {
- CtfLocationData location = new CtfLocationData(1337, 7331);
+ CtfLocationInfo location = new CtfLocationInfo(1337, 7331);
fixture = new CtfLocation(location);
}
*/
@Test
public void testToString_valid(){
- CtfLocation fixture2 = new CtfLocation(new CtfLocationData(1337, 7331));
+ CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(1337, 7331));
assertEquals("CtfLocation: Element [1337/7331]",fixture2.toString()); //$NON-NLS-1$
}
*/
@Test
public void testToString_invalid(){
- CtfLocation fixture2 = new CtfLocation(new CtfLocationData(-1, -1));
+ CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(-1, -1));
assertEquals("CtfLocation: INVALID",fixture2.toString()); //$NON-NLS-1$
}
}
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationData;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
*/
@Test
public void testGetLocationRatio() {
- final CtfLocationData location2 = new CtfLocationData(1, 0);
+ final CtfLocationInfo location2 = new CtfLocationInfo(1, 0);
CtfLocation location = new CtfLocation(location2);
double result = fixture.getLocationRatio(location);
*/
@Test
public void testSeekEvent_location() {
- final CtfLocationData location2 = new CtfLocationData(1L, 0L);
+ final CtfLocationInfo location2 = new CtfLocationInfo(1L, 0L);
CtfLocation ctfLocation = new CtfLocation(location2);
ITmfContext result = fixture.seekEvent(ctfLocation);
assertNotNull(result);
* @since 2.0
*/
public CtfIterator(final CtfTmfTrace trace,
- final CtfLocationData ctfLocationData, final long rank) {
+ final CtfLocationInfo ctfLocationData, final long rank) {
super(trace.getCTFTrace());
this.ctfTmfTrace = trace;
*/
@Override
public boolean seek(long timestamp) {
- return seek(new CtfLocationData(timestamp, 0));
+ return seek(new CtfLocationInfo(timestamp, 0));
}
/**
* @return boolean
* @since 2.0
*/
- public boolean seek(final CtfLocationData ctfLocationData) {
+ public boolean seek(final CtfLocationInfo ctfLocationData) {
boolean ret = false;
/* Adjust the timestamp depending on the trace's offset */
}
/* Seek the current location accordingly */
if (ret) {
- curLocation = new CtfLocation(new CtfLocationData(getCurrentEvent().getTimestamp().getValue(), index));
+ curLocation = new CtfLocation(new CtfLocationInfo(getCurrentEvent().getTimestamp().getValue(), index));
} else {
curLocation = NULL_LOCATION;
}
retVal = replaceRandomElement(context);
}
if (context.getLocation() != null) {
- final CtfLocationData location = (CtfLocationData) context.getLocation().getLocationInfo();
+ final CtfLocationInfo location = (CtfLocationInfo) context.getLocation().getLocationInfo();
retVal.seek(location);
}
}
*/
public final class CtfLocation implements ITmfLocation {
- private final CtfLocationData fLocation;
+ private final CtfLocationInfo fLocation;
/**
* An invalid location
*/
- public static final CtfLocationData INVALID_LOCATION = new CtfLocationData(-1, -1);
+ public static final CtfLocationInfo INVALID_LOCATION = new CtfLocationInfo(-1, -1);
/**
* Constructor for CtfLocation. Uses a default index of 0.
* @since 2.0
*/
public CtfLocation(final long timestampValue, final long index) {
- this(new CtfLocationData(timestampValue, index));
+ this(new CtfLocationInfo(timestampValue, index));
}
/**
* Other location to copy
* @since 2.0
*/
- public CtfLocation(final CtfLocationData location) {
+ public CtfLocation(final CtfLocationInfo location) {
fLocation = location;
}
* @since 2.0
*/
@Override
- public CtfLocationData getLocationInfo() {
+ public CtfLocationInfo getLocationInfo() {
return fLocation;
}
@Override
public CtfLocation clone() {
- return new CtfLocation(new CtfLocationData(fLocation.getTimestamp(), fLocation.getIndex()));
+ return new CtfLocation(new CtfLocationInfo(fLocation.getTimestamp(), fLocation.getIndex()));
}
+++ /dev/null
-/*******************************************************************************
- * 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: Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.tmf.core.ctfadaptor;
-
-/**
- * CtfLocationData, the data in a CTF location.
- *
- * @author Matthew Khouzam
- * @since 2.0
- */
-public class CtfLocationData implements Comparable<CtfLocationData> {
-
- private final long timestamp;
- private final long index;
-
- /**
- * @param ts
- * Timestamp
- * @param index
- * Index of this event (if there are N elements with the same
- * timestamp, which one is it.)
- */
- public CtfLocationData(long ts, long index) {
- this.timestamp = ts;
- this.index = index;
- }
-
- /**
- * @return The timestamp
- */
- public long getTimestamp() {
- return timestamp;
- }
-
- /**
- * @return The index of the element
- */
- public long getIndex() {
- return index;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = (prime * result) + (int) (index ^ (index >>> 32));
- result = (prime * result) + (int) (timestamp ^ (timestamp >>> 32));
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof CtfLocationData)) {
- return false;
- }
- CtfLocationData other = (CtfLocationData) obj;
- if (index != other.index) {
- return false;
- }
- if (timestamp != other.timestamp) {
- return false;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "Element [" + timestamp + '/' + index + ']'; //$NON-NLS-1$
- }
-
- @Override
- public int compareTo(CtfLocationData other) {
- if (this.timestamp > other.getTimestamp()) {
- return 1;
- }
- if (this.timestamp < other.getTimestamp()) {
- return -1;
- }
- if (this.index > other.getIndex()) {
- return 1;
- }
- if (this.index < other.getIndex()) {
- return -1;
- }
- return 0;
- }
-
-}
--- /dev/null
+/*******************************************************************************
+ * 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: Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.tmf.core.ctfadaptor;
+
+/**
+ * The data object to go in a {@link CtfLocation}.
+ *
+ * @author Matthew Khouzam
+ * @since 2.0
+ */
+public class CtfLocationInfo implements Comparable<CtfLocationInfo> {
+
+ private final long timestamp;
+ private final long index;
+
+ /**
+ * @param ts
+ * Timestamp
+ * @param index
+ * Index of this event (if there are N elements with the same
+ * timestamp, which one is it.)
+ */
+ public CtfLocationInfo(long ts, long index) {
+ this.timestamp = ts;
+ this.index = index;
+ }
+
+ /**
+ * @return The timestamp
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * @return The index of the element
+ */
+ public long getIndex() {
+ return index;
+ }
+
+ // ------------------------------------------------------------------------
+ // Object
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + (int) (index ^ (index >>> 32));
+ result = (prime * result) + (int) (timestamp ^ (timestamp >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof CtfLocationInfo)) {
+ return false;
+ }
+ CtfLocationInfo other = (CtfLocationInfo) obj;
+ if (index != other.index) {
+ return false;
+ }
+ if (timestamp != other.timestamp) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Element [" + timestamp + '/' + index + ']'; //$NON-NLS-1$
+ }
+
+ // ------------------------------------------------------------------------
+ // Comparable
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int compareTo(CtfLocationInfo other) {
+ if (this.timestamp > other.getTimestamp()) {
+ return 1;
+ }
+ if (this.timestamp < other.getTimestamp()) {
+ return -1;
+ }
+ if (this.index > other.getIndex()) {
+ return 1;
+ }
+ if (this.index < other.getIndex()) {
+ return -1;
+ }
+ return 0;
+ }
+
+}
*/
public CtfTmfContext(CtfTmfTrace ctfTmfTrace) {
fTrace = ctfTmfTrace;
- curLocation = new CtfLocation(new CtfLocationData(0, 0));
+ curLocation = new CtfLocation(new CtfLocationInfo(0, 0));
}
// -------------------------------------------
* @return success or not
*/
public synchronized boolean advance() {
- final CtfLocationData curLocationData = this.curLocation.getLocationInfo();
+ final CtfLocationInfo curLocationData = this.curLocation.getLocationInfo();
boolean retVal = getIterator().advance();
CtfTmfEvent currentEvent = getIterator().getCurrentEvent();
* @return success or not
* @since 2.0
*/
- public synchronized boolean seek(final CtfLocationData location) {
+ public synchronized boolean seek(final CtfLocationInfo location) {
curLocation = new CtfLocation(location);
return getIterator().seek(location);
}
final CtfTmfContext context = new CtfTmfContext(this);
context.setLocation(curLocation);
context.seek(curLocation.getLocationInfo());
- final CtfLocationData currentTime = ((CtfLocationData)context.getLocation().getLocationInfo());
+ final CtfLocationInfo currentTime = ((CtfLocationInfo)context.getLocation().getLocationInfo());
final long startTime = getIterator(this, context).getStartTime();
final long endTime = getIterator(this, context).getEndTime();
return ((double) currentTime.getTimestamp() - startTime)
* by rank for now.
*/
if (currentLocation == null) {
- currentLocation = new CtfLocation(new CtfLocationData(0L, 0L));
+ currentLocation = new CtfLocation(new CtfLocationInfo(0L, 0L));
context.setRank(0);
}
if (currentLocation.getLocationInfo() == CtfLocation.INVALID_LOCATION) {