fProperties.put(CREATIONDATE, fCreationDate);
try {
- // DateFormats are inherently unsafe for multithreaded use so we can't make this a field. Just in case.
+ // DateFormats are inherently unsafe for multithreaded use
+ // so we can't make this a field. Just in case.
final SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); //$NON-NLS-1$
Date dateTime = ISO8601DATEFORMAT.parse(fCreationDate);
fTsOffset = dateTime.getTime() * MICROSECONDS_IN_A_SECOND;
}
final TmfContext context = (TmfContext) tmfContext;
- if (context.getLocation() == null
- || !(context.getLocation().getLocationInfo() instanceof Long)
- || NULL_LOCATION.equals(context.getLocation())) {
+ ITmfLocation location = context.getLocation();
+ if (location == null
+ || !(location.getLocationInfo() instanceof Long)
+ || NULL_LOCATION.equals(location)) {
return null;
}
* @return the event from a given line
*/
private ITmfEvent parseLine(TmfContext context) {
- try {
- if (!context.getLocation().getLocationInfo().equals(fFileInput.getFilePointer())) {
- seekEvent(context.getLocation());
+ ITmfLocation location = context.getLocation();
+ if (location != null) {
+ try {
+ if (!location.getLocationInfo().equals(fFileInput.getFilePointer())) {
+ seekEvent(location);
+ }
+ } catch (IOException e1) {
+ seekEvent(location);
}
- } catch (IOException e1) {
- seekEvent(context.getLocation());
- }
- String line;
- try {
- line = fFileInput.readLine();
- return parseLine(context.getRank(), line);
+ String line;
+ try {
+ line = fFileInput.readLine();
+ return parseLine(context.getRank(), line);
- } catch (IOException e) {
+ } catch (IOException e) {
+ Activator.logError(e.getMessage(), e);
+ }
}
-
return null;
}
if (signal.getTrace() == this) {
try {
synchronized (this) {
- // Reset the file handle in case it has reached the end of the
- // file already. Otherwise, it will not be able to read new data
- // pass the previous end.
+ /*
+ * Reset the file handle in case it has reached the end of
+ * the file already. Otherwise, it will not be able to read
+ * new data pass the previous end.
+ */
initFile();
}
} catch (TmfTraceException e) {
}
final CustomTxtTraceContext context = (CustomTxtTraceContext) tmfContext;
- if (context.getLocation() == null || !(context.getLocation().getLocationInfo() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {
+ ITmfLocation location = context.getLocation();
+ if (location == null || !(location.getLocationInfo() instanceof Long) || NULL_LOCATION.equals(location)) {
return null;
}
}
final CustomXmlTraceContext context = (CustomXmlTraceContext) tmfContext;
- if (context.getLocation() == null || !(context.getLocation().getLocationInfo() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {
+ ITmfLocation location = context.getLocation();
+ if (location == null || !(location.getLocationInfo() instanceof Long) || NULL_LOCATION.equals(location)) {
return null;
}
CustomXmlEvent event = null;
try {
// Below +1 for the <
- if (fFile.getFilePointer() != (Long) context.getLocation().getLocationInfo() + 1) {
- fFile.seek((Long) context.getLocation().getLocationInfo() + 1);
+ if (fFile.getFilePointer() != (Long) location.getLocationInfo() + 1) {
+ fFile.seek((Long) location.getLocationInfo() + 1);
}
final StringBuffer elementBuffer = new StringBuffer("<"); //$NON-NLS-1$
readElement(elementBuffer, fFile);
package org.eclipse.tracecompass.tmf.core.trace;
+import java.util.Objects;
+
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
/**
// ------------------------------------------------------------------------
// The trace location
- private ITmfLocation fLocation;
+ private @Nullable ITmfLocation fLocation;
// The event rank
private long fRank;
// ------------------------------------------------------------------------
@Override
- public ITmfLocation getLocation() {
+ public @Nullable ITmfLocation getLocation() {
return fLocation;
}
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fLocation == null) ? 0 : fLocation.hashCode());
- result = prime * result + (int) (fRank ^ (fRank >>> 32));
- return result;
+ return Objects.hash(fRank, fLocation);
}
@Override
return false;
}
final TmfContext other = (TmfContext) obj;
- if (fLocation == null) {
- if (other.fLocation != null) {
- return false;
- }
- } else if (!fLocation.equals(other.fLocation)) {
+ if (fRank != other.fRank) {
return false;
}
- if (fRank != other.fRank) {
+ if (!Objects.equals(fLocation, other.fLocation)) {
return false;
}
return true;
int length = getNbChildren();
// Initialize the location array if necessary
- TmfLocationArray locationArray = ((location == null) ?
- new TmfLocationArray(length) :
- ((TmfExperimentLocation) location).getLocationInfo());
+ TmfLocationArray locationArray = ((location == null) ? new TmfLocationArray(length) : ((TmfExperimentLocation) location).getLocationInfo());
ITmfLocation[] locations = locationArray.getLocations();
long[] ranks = locationArray.getRanks();
}
// Update the experiment location
- TmfLocationArray locationArray = new TmfLocationArray(
- ((TmfExperimentLocation) expContext.getLocation()).getLocationInfo(),
- trace, traceContext.getLocation(), traceContext.getRank());
- expContext.setLocation(new TmfExperimentLocation(locationArray));
+ ITmfLocation location = expContext.getLocation();
+ if (location instanceof TmfExperimentLocation) {
+ TmfLocationArray locationArray = new TmfLocationArray(
+ ((TmfExperimentLocation) location).getLocationInfo(),
+ trace, traceContext.getLocation(), traceContext.getRank());
+ expContext.setLocation(new TmfExperimentLocation(locationArray));
+ }
}
}
}
safeTimestamp = endTimestamp;
if (timeRange != null) {
- final TmfTraceRangeUpdatedSignal signal =
- new TmfTraceRangeUpdatedSignal(TmfExperiment.this, TmfExperiment.this, timeRange);
+ final TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(TmfExperiment.this, TmfExperiment.this, timeRange);
broadcast(signal);
}
}
return null;
}
TextTraceContext context = tmfContext;
- if (context.getLocation() == null || !(context.getLocation().getLocationInfo() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {
+ ITmfLocation location = context.getLocation();
+ if (location == null || !(location.getLocationInfo() instanceof Long) || NULL_LOCATION.equals(location)) {
return null;
}