CtfLocation result = new CtfLocation(location);
assertNotNull(result);
- assertEquals(Long.valueOf(1), (Long)result.getLocationData().getTimestamp());
+ assertEquals(Long.valueOf(1), (Long)result.getLocationInfo().getTimestamp());
}
/**
CtfLocation result = new CtfLocation(timestamp);
assertNotNull(result);
- assertEquals(new Long(0L), (Long)result.getLocationData().getTimestamp());
+ assertEquals(new Long(0L), (Long)result.getLocationInfo().getTimestamp());
}
/**
CtfLocation result = fixture.clone();
assertNotNull(result);
- assertEquals(Long.valueOf(1), (Long)result.getLocationData().getTimestamp());
+ assertEquals(Long.valueOf(1), (Long)result.getLocationInfo().getTimestamp());
}
/**
*/
@Test
public void testGetLocation() {
- CtfLocationData location = fixture.getLocationData();
+ CtfLocationData location = fixture.getLocationInfo();
Long result = location.getTimestamp();
assertNotNull(result);
assertEquals("1", result.toString()); //$NON-NLS-1$
for (int i = 0; i < checkpoints.size(); i++) {
ITmfCheckpoint checkpoint = checkpoints.get(i);
TmfExperimentLocation expLocation = (TmfExperimentLocation) checkpoint.getLocation();
- TmfLocationArray locations = expLocation.getLocationData();
+ TmfLocationArray locations = expLocation.getLocationInfo();
ITmfContext[] trcContexts = new ITmfContext[2];
trcContexts[0] = new TmfContext(locations.getLocations()[0], (i * pageSize) / 2);
trcContexts[1] = new TmfContext(locations.getLocations()[1], (i * pageSize) / 2);
for (int i = 0; i < checkpoints.size(); i++) {
ITmfCheckpoint checkpoint = checkpoints.get(i);
TmfExperimentLocation expLocation = (TmfExperimentLocation) checkpoint.getLocation();
- TmfLocationArray locations = expLocation.getLocationData();
+ TmfLocationArray locations = expLocation.getLocationInfo();
ITmfContext[] trcContexts = new ITmfContext[2];
trcContexts[0] = new TmfContext(locations.getLocations()[0], (i * pageSize) / 2);
trcContexts[1] = new TmfContext(locations.getLocations()[1], (i * pageSize) / 2);
// ------------------------------------------------------------------------
public void testTmfLocation() {
- assertNull("TmfLocation", fLocation1.getLocationData());
- assertEquals("TmfLocation", aString, fLocation2.getLocationData());
- assertEquals("TmfLocation", aLong, fLocation3.getLocationData());
- assertEquals("TmfLocation", aTimestamp, fLocation4.getLocationData());
+ assertNull("TmfLocation", fLocation1.getLocationInfo());
+ assertEquals("TmfLocation", aString, fLocation2.getLocationInfo());
+ assertEquals("TmfLocation", aLong, fLocation3.getLocationInfo());
+ assertEquals("TmfLocation", aTimestamp, fLocation4.getLocationInfo());
}
public void testTmfLocationCopy() {
TmfLongLocation location3 = new TmfLongLocation(fLocation3);
TmfTimestampLocation location4 = new TmfTimestampLocation(fLocation4);
- assertNull("TmfLocation", location1.getLocationData());
- assertEquals("TmfLocation", aString, location2.getLocationData());
- assertEquals("TmfLocation", aLong, location3.getLocationData());
- assertEquals("TmfLocation", aTimestamp, location4.getLocationData());
+ assertNull("TmfLocation", location1.getLocationInfo());
+ assertEquals("TmfLocation", aString, location2.getLocationInfo());
+ assertEquals("TmfLocation", aLong, location3.getLocationInfo());
+ assertEquals("TmfLocation", aTimestamp, location4.getLocationInfo());
}
// ------------------------------------------------------------------------
assertEquals("clone", fLocation3, location3);
assertEquals("clone", fLocation4, location4);
- assertEquals("clone", fLocation1.getLocationData(), location1.getLocationData());
- assertEquals("clone", fLocation2.getLocationData(), location2.getLocationData());
- assertEquals("clone", fLocation3.getLocationData(), location3.getLocationData());
- assertEquals("clone", fLocation4.getLocationData(), location4.getLocationData());
+ assertEquals("clone", fLocation1.getLocationInfo(), location1.getLocationInfo());
+ assertEquals("clone", fLocation2.getLocationInfo(), location2.getLocationInfo());
+ assertEquals("clone", fLocation3.getLocationInfo(), location3.getLocationInfo());
+ assertEquals("clone", fLocation4.getLocationInfo(), location4.getLocationInfo());
- assertNull("clone", location1.getLocationData());
- assertEquals("clone", aString, location2.getLocationData());
- assertEquals("clone", aLong, location3.getLocationData());
- assertEquals("clone", aTimestamp, location4.getLocationData());
+ assertNull("clone", location1.getLocationInfo());
+ assertEquals("clone", aString, location2.getLocationInfo());
+ assertEquals("clone", aLong, location3.getLocationInfo());
+ assertEquals("clone", aTimestamp, location4.getLocationInfo());
} catch (InternalError e) {
fail("clone()");
}
}
public TmfStringLocation(TmfStringLocation other) {
- super(other.getLocationData());
+ super(other.getLocationInfo());
}
@Override
public TmfStringLocation clone() {
- return new TmfStringLocation((String) getLocationData());
+ return new TmfStringLocation((String) getLocationInfo());
}
}
long location = 0;
if (context != null && context.getLocation() != null) {
- location = (Long) context.getLocation().getLocationData();
+ location = (Long) context.getLocation().getLocationInfo();
try {
stream.seek(location);
long loc = 0;
long rank = 0;
if (location != null) {
- loc = (Long) location.getLocationData();
+ loc = (Long) location.getLocationInfo();
rank = ITmfContext.UNKNOWN_RANK;
}
if (loc != fTrace.getFilePointer()) {
fLock.lock();
try {
if (fTrace != null) {
- if (location.getLocationData() instanceof Long) {
- return (double) ((Long) location.getLocationData()) / fTrace.length();
+ if (location.getLocationInfo() instanceof Long) {
+ return (double) ((Long) location.getLocationInfo()) / fTrace.length();
}
}
} catch (final IOException e) {
* @param location the other experiment location
*/
public TmfExperimentLocation(TmfExperimentLocation location) {
- this(location.getLocationData());
+ this(location.getLocationInfo());
}
// ------------------------------------------------------------------------
@Override
public TmfExperimentLocation clone() {
// super.clone(); // To keep FindBugs happy
- TmfLocationArray array = getLocationData();
+ TmfLocationArray array = getLocationInfo();
TmfLocationArray clones = array.clone();
return new TmfExperimentLocation(clones);
}
@SuppressWarnings("nls")
public String toString() {
StringBuilder result = new StringBuilder("[TmfExperimentLocation");
- ITmfLocation[] locations = getLocationData().getLocations();
+ ITmfLocation[] locations = getLocationInfo().getLocations();
for (ITmfLocation location : locations) {
result.append("[" + location + "]");
}
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationData()
*/
@Override
- public TmfLocationArray getLocationData() {
+ public TmfLocationArray getLocationInfo() {
return fLocation;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public int compareTo(TmfLocationArray o) {
for (int i = 0; i < fLocations.length; i++) {
- Comparable l1 = fLocations[i].getLocationData();
- Comparable l2 = o.fLocations[i].getLocationData();
+ Comparable l1 = fLocations[i].getLocationInfo();
+ Comparable l2 = o.fLocations[i].getLocationInfo();
int result = l1.compareTo(l2);
if (result != 0) {
return result;
@Override
public CtfIterator clone() {
CtfIterator clone = null;
- clone = new CtfIterator(ctfTmfTrace, this.getLocation().getLocationData(), curRank);
+ clone = new CtfIterator(ctfTmfTrace, this.getLocation().getLocationInfo(), curRank);
return clone;
}
public void setLocation(final ITmfLocation location) {
// FIXME alex: isn't there a cleaner way than a cast here?
this.curLocation = (CtfLocation) location;
- seek(((CtfLocation) location).getLocationData());
+ seek(((CtfLocation) location).getLocationInfo());
}
/**
*/
@Override
public boolean advance() {
- long index = curLocation.getLocationData().getIndex();
- long timestamp = curLocation.getLocationData().getTimestamp();
+ long index = curLocation.getLocationInfo().getIndex();
+ long timestamp = curLocation.getLocationInfo().getTimestamp();
boolean ret = super.advance();
if (ret) {
*/
retVal = replaceRandomElement(context);
}
- final CtfLocationData location = (CtfLocationData) context.getLocation().getLocationData();
+ final CtfLocationData location = (CtfLocationData) context.getLocation().getLocationInfo();
retVal.seek( location);
}
return retVal;
* Get the Location Data of this location
*
* @return The CtfLocationData
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationData()
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationInfo()
* @since 2.0
*/
@Override
- public CtfLocationData getLocationData() {
+ public CtfLocationData getLocationInfo() {
return fLocation;
}
*/
@Override
public String toString() {
- if( this.getLocationData().equals(CtfLocation.INVALID_LOCATION )) {
+ if( this.getLocationInfo().equals(CtfLocation.INVALID_LOCATION )) {
return "CtfLocation: INVALID"; //$NON-NLS-1$
}
- return "CtfLocation: " + getLocationData().toString(); //$NON-NLS-1$
+ return "CtfLocation: " + getLocationInfo().toString(); //$NON-NLS-1$
}
@Override
public void setLocation(ITmfLocation location) {
curLocation = (CtfLocation) location;
- getIterator().seek(curLocation.getLocationData());
+ getIterator().seek(curLocation.getLocationInfo());
}
@Override
* @return success or not
*/
public synchronized boolean advance() {
- final CtfLocationData curLocationData = this.curLocation.getLocationData();
+ final CtfLocationData curLocationData = this.curLocation.getLocationInfo();
boolean retVal = getIterator().advance();
CtfTmfEvent currentEvent = getIterator().getCurrentEvent();
final CtfLocation curLocation = (CtfLocation) location;
final CtfTmfLightweightContext context = new CtfTmfLightweightContext(this);
context.setLocation(curLocation);
- context.seek(curLocation.getLocationData());
- final CtfLocationData currentTime = ((CtfLocationData)context.getLocation().getLocationData());
+ context.seek(curLocation.getLocationInfo());
+ final CtfLocationData currentTime = ((CtfLocationData)context.getLocation().getLocationInfo());
final long startTime = getIterator(this, context).getStartTime();
final long endTime = getIterator(this, context).getEndTime();
return ((double) currentTime.getTimestamp() - startTime)
currentLocation = new CtfLocation(new CtfLocationData(0L, 0L));
context.setRank(0);
}
- if (currentLocation.getLocationData() == CtfLocation.INVALID_LOCATION) {
+ if (currentLocation.getLocationInfo() == CtfLocation.INVALID_LOCATION) {
((CtfTmfTimestamp) getEndTime()).setType(TimestampType.NANOS);
currentLocation.setLocation(getEndTime().getValue() + 1, 0L);
}
public synchronized CtfTmfEvent getNext(final ITmfContext context) {
CtfTmfEvent event = null;
if (context instanceof CtfTmfLightweightContext) {
- if (CtfLocation.INVALID_LOCATION.equals(context.getLocation().getLocationData())) {
+ if (CtfLocation.INVALID_LOCATION.equals(context.getLocation().getLocationInfo())) {
return null;
}
CtfTmfLightweightContext ctfContext = (CtfTmfLightweightContext) context;
package org.eclipse.linuxtools.tmf.core.trace;
-
/**
* The generic trace location in TMF.
* <p>
* <p>
* This location is trace-specific and must be comparable.
*
- * @version 1.0
+ * @version 2.0
* @author Francois Chouinard
*/
public interface ITmfLocation {
// ------------------------------------------------------------------------
/**
- * @return the location
+ * Returns the concrete trace location information
+ *
+ * @return the location information
* @since 2.0
*/
- public Comparable<?> getLocationData();
+ public Comparable<?> getLocationInfo();
// ------------------------------------------------------------------------
// Operations
@SuppressWarnings({ "unchecked", "rawtypes" })
public int compareTo(final ITmfCheckpoint other) {
if (fTimestamp == null || other.getTimestamp() == null) {
- final Comparable location1 = getLocation().getLocationData();
- final Comparable location2 = other.getLocation().getLocationData();
+ final Comparable location1 = getLocation().getLocationInfo();
+ final Comparable location2 = other.getLocation().getLocationInfo();
return location1.compareTo(location2);
}
return fTimestamp.compareTo(other.getTimestamp(), false);
for (int i = 0; i < fTraces.length; i++) {
// Get the relevant trace attributes
- final ITmfLocation trcLocation = expLocation.getLocationData().getLocations()[i];
+ final ITmfLocation trcLocation = expLocation.getLocationInfo().getLocations()[i];
context.getContexts()[i] = fTraces[i].seekEvent(trcLocation);
- expLocation.getLocationData().getLocations()[i] = context.getContexts()[i].getLocation().clone();
+ expLocation.getLocationInfo().getLocations()[i] = context.getContexts()[i].getLocation().clone();
context.getEvents()[i] = fTraces[i].getNext(context.getContexts()[i]);
}
TmfExperimentLocation location = (TmfExperimentLocation) expContext.getLocation();
if (location != null) {
- location.getLocationData().getLocations()[trace] = traceContext.getLocation().clone();
+ location.getLocationInfo().getLocations()[trace] = traceContext.getLocation().clone();
}
fExperimentContext = expContext.clone();
package org.eclipse.linuxtools.tmf.core.trace;
/**
- * A convenience implementation on of ITmfLocation. The generic class (L) must
- * be comparable.
+ * A abstract implementation of ITmfLocation. The concrete classes must provide
+ * comparable location information.
*
- * @version 1.0
+ * @version 2.0
* @author Francois Chouinard
*/
public abstract class TmfLocation implements ITmfLocation, Cloneable {
// Attributes
// ------------------------------------------------------------------------
- private Comparable<?> fLocationData;
+ private Comparable<?> fLocationInfo;
// ------------------------------------------------------------------------
// Constructors
/**
* Standard constructor.
*
- * @param locationData the trace location
+ * @param locationInfo the concrete trace location
*/
- public TmfLocation(final Comparable<?> locationData) {
- fLocationData = locationData;
+ public TmfLocation(final Comparable<?> locationInfo) {
+ fLocationInfo = locationInfo;
}
/**
* Copy constructor
*
- * @param location the original location
+ * @param location the original trace location
*/
public TmfLocation(final TmfLocation location) {
- fLocationData = location.fLocationData;
+ fLocationInfo = location.fLocationInfo;
}
// ------------------------------------------------------------------------
// Getters
// ------------------------------------------------------------------------
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationInfo()
+ */
/**
* @since 2.0
*/
@Override
- public Comparable<?> getLocationData() {
- return fLocationData;
+ public Comparable<?> getLocationInfo() {
+ return fLocationInfo;
}
// ------------------------------------------------------------------------
// Cloneable
// ------------------------------------------------------------------------
+ /* (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
@Override
public abstract TmfLocation clone();
-// /* (non-Javadoc)
-// * @see java.lang.Object#clone()
-// */
-// @Override
-// @SuppressWarnings("unchecked")
-// public TmfLocation<L> clone() {
-// TmfLocation<L> clone = null;
-// try {
-// clone = (TmfLocation<L>) super.clone();
-// if (fLocationData != null) {
-// final Class<?> clazz = fLocationData.getClass();
-// final Method method = clazz.getMethod("clone", new Class[0]); //$NON-NLS-1$
-// final Object copy = method.invoke(this.fLocationData, new Object[0]);
-// clone.fLocationData = (L) copy;
-// } else {
-// clone.fLocationData = null;
-// }
-// } catch (final CloneNotSupportedException e) {
-// } catch (final NoSuchMethodException e) {
-// } catch (final Exception e) {
-// throw new InternalError(e.toString());
-// }
-// return clone;
-// }
-
// ------------------------------------------------------------------------
// Object
// ------------------------------------------------------------------------
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((fLocationData != null) ? fLocationData.hashCode() : 0);
+ result = prime * result + ((fLocationInfo != null) ? fLocationInfo.hashCode() : 0);
return result;
}
return false;
}
final TmfLocation other = (TmfLocation) obj;
- if (fLocationData == null) {
- if (other.fLocationData != null) {
+ if (fLocationInfo == null) {
+ if (other.fLocationInfo != null) {
return false;
}
- } else if (!fLocationData.equals(other.fLocationData)) {
+ } else if (!fLocationInfo.equals(other.fLocationInfo)) {
return false;
}
return true;
@Override
@SuppressWarnings("nls")
public String toString() {
- return "TmfLocation [fLocation=" + fLocationData + "]";
+ return "TmfLocation [fLocation=" + fLocationInfo + "]";
}
}
* @param other the other location
*/
public TmfLongLocation(TmfLongLocation other) {
- super(other.getLocationData());
+ super(other.getLocationInfo());
}
@Override
public TmfLongLocation clone() {
- return new TmfLongLocation((Long) getLocationData());
+ return new TmfLongLocation((Long) getLocationInfo());
}
}
* @param other the other location
*/
public TmfTimestampLocation(TmfTimestampLocation other) {
- super(other.getLocationData());
+ super(other.getLocationInfo());
}
@Override
public TmfTimestampLocation clone() {
- return new TmfTimestampLocation((ITmfTimestamp) getLocationData());
+ return new TmfTimestampLocation((ITmfTimestamp) getLocationInfo());
}
}
long location = 0;
if (context != null) {
- location = (Long) context.getLocation().getLocationData();
+ location = (Long) context.getLocation().getLocationInfo();
}
try {
try {\r
if (location == null) {\r
fFile.seek(0);\r
- } else if (location.getLocationData() instanceof Long) {\r
- fFile.seek((Long) location.getLocationData());\r
+ } else if (location.getLocationInfo() instanceof Long) {\r
+ fFile.seek((Long) location.getLocationInfo());\r
}\r
String line;\r
long rawPos = fFile.getFilePointer();\r
return 0;\r
}\r
try {\r
- if (location.getLocationData() instanceof Long) {\r
- return (double) ((Long) location.getLocationData()) / fFile.length();\r
+ if (location.getLocationInfo() instanceof Long) {\r
+ return (double) ((Long) location.getLocationInfo()) / fFile.length();\r
}\r
} catch (final IOException e) {\r
Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$\r
}\r
\r
final CustomTxtTraceContext context = (CustomTxtTraceContext) tmfContext;\r
- if (!(context.getLocation().getLocationData() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {\r
+ if (!(context.getLocation().getLocationInfo() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {\r
return null;\r
}\r
\r
try {\r
if (location == null) {\r
fFile.seek(0);\r
- } else if (location.getLocationData() instanceof Long) {\r
- fFile.seek((Long) location.getLocationData());\r
+ } else if (location.getLocationInfo() instanceof Long) {\r
+ fFile.seek((Long) location.getLocationInfo());\r
}\r
String line;\r
final String recordElementStart = "<" + fRecordInputElement.elementName; //$NON-NLS-1$\r
return 0;\r
}\r
try {\r
- if (location.getLocationData() instanceof Long) {\r
- return (double) ((Long) location.getLocationData()) / fFile.length();\r
+ if (location.getLocationInfo() instanceof Long) {\r
+ return (double) ((Long) location.getLocationInfo()) / fFile.length();\r
}\r
} catch (final IOException e) {\r
Activator.getDefault().logError("Error getting location ration. File: " + getPath(), e); //$NON-NLS-1$\r
}\r
\r
final CustomXmlTraceContext context = (CustomXmlTraceContext) tmfContext;\r
- if (!(context.getLocation().getLocationData() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {\r
+ if (!(context.getLocation().getLocationInfo() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {\r
return null;\r
}\r
\r
CustomXmlEvent event = null;\r
try {\r
- if (fFile.getFilePointer() != (Long)context.getLocation().getLocationData() + 1)\r
+ if (fFile.getFilePointer() != (Long)context.getLocation().getLocationInfo() + 1)\r
{\r
- fFile.seek((Long)context.getLocation().getLocationData() + 1); // +1 is for the <\r
+ fFile.seek((Long)context.getLocation().getLocationInfo() + 1); // +1 is for the <\r
}\r
final StringBuffer elementBuffer = new StringBuffer("<"); //$NON-NLS-1$\r
readElement(elementBuffer, fFile);\r