/** @since 3.0 */ @Override public synchronized ITmfContext seekEvent(final ITmfLocation location) { // Validate the location if (location != null && !(location instanceof TmfExperimentLocation)) { return null; // Throw an exception? } // Make sure we have something to read from if (fTraces == null) { return null; } // Initialize the location array if necessary TmfLocationArray locationArray = ((location == null) ? new TmfLocationArray(fTraces.length) : ((TmfExperimentLocation) location).getLocationInfo()); ITmfLocation[] locations = locationArray.getLocations(); long[] ranks = locationArray.getRanks(); // Create and populate the context's traces contexts final TmfExperimentContext context = new TmfExperimentContext(fTraces.length); // Position the traces long rank = 0; for (int i = 0; i < fTraces.length; i++) { // Get the relevant trace attributes final ITmfContext traceContext = fTraces[i].seekEvent(locations[i]); context.setContext(i, traceContext); traceContext.setRank(ranks[i]); locations[i] = traceContext.getLocation(); // update location after seek context.setEvent(i, fTraces[i].getNext(traceContext)); rank += ranks[i]; } // Finalize context context.setLocation(new TmfExperimentLocation(new TmfLocationArray(locations, ranks))); context.setLastTrace(TmfExperimentContext.NO_TRACE); context.setRank(rank); return context; }