/* Only used for debugging, shouldn't be externalized */
@SuppressWarnings("nls")
private void preOrderPrint(PrintWriter writer, boolean printIntervals,
- HTNode currentNode, int curDepth) {
+ HTNode currentNode, int curDepth, long ts) {
writer.println(currentNode.toString());
- if (printIntervals) {
+ /* Print intervals only if timestamp is negative or within the range of the node */
+ if (printIntervals &&
+ (ts <= 0 ||
+ (ts >= currentNode.getNodeStart() && ts <= currentNode.getNodeEnd()))) {
currentNode.debugPrintIntervals(writer);
}
int extension = node.getExtensionSequenceNumber();
while (extension != -1) {
HTNode nextNode = fTreeIO.readNode(extension);
- preOrderPrint(writer, printIntervals, nextNode, curDepth);
+ preOrderPrint(writer, printIntervals, nextNode, curDepth, ts);
}
/* Print the child nodes */
writer.print(" ");
}
writer.print("+-");
- preOrderPrint(writer, printIntervals, nextNode, curDepth + 1);
+ preOrderPrint(writer, printIntervals, nextNode, curDepth + 1, ts);
}
} catch (ClosedChannelException e) {
Activator.getDefault().logError(e.getMessage());
* PrintWriter in which to write the output
* @param printIntervals
* Flag to enable full output of the interval information
+ * @param ts
+ * The timestamp that nodes have to intersect for intervals to be
+ * printed. A negative value will print intervals for all nodes.
+ * The timestamp only applies if printIntervals is true.
*/
- public void debugPrintFullTree(PrintWriter writer, boolean printIntervals) {
+ public void debugPrintFullTree(PrintWriter writer, boolean printIntervals, long ts) {
/* Only used for debugging, shouldn't be externalized */
- preOrderPrint(writer, false, fLatestBranch.get(0), 0);
+ preOrderPrint(writer, false, fLatestBranch.get(0), 0, ts);
if (printIntervals) {
- writer.println("\nDetails of intervals:"); //$NON-NLS-1$
- preOrderPrint(writer, true, fLatestBranch.get(0), 0);
+ preOrderPrint(writer, true, fLatestBranch.get(0), 0, ts);
}
writer.println('\n');
}
@Override
public void debugPrint(PrintWriter writer) {
/* By default don't print out all the intervals */
- debugPrint(writer, false);
+ debugPrint(writer, false, -1);
}
/**
* The PrintWriter to which the debug info will be written
* @param printIntervals
* Should we also print every contained interval individually?
+ * @param ts
+ * The timestamp that nodes have to intersect for intervals to be
+ * printed. A negative value will print intervals for all nodes.
+ * The timestamp only applies if printIntervals is true.
*/
- public void debugPrint(PrintWriter writer, boolean printIntervals) {
+ public void debugPrint(PrintWriter writer, boolean printIntervals, long ts) {
/* Only used for debugging, shouldn't be externalized */
writer.println("------------------------------"); //$NON-NLS-1$
writer.println("State History Tree:\n"); //$NON-NLS-1$
+ getAverageNodeUsage());
writer.println(""); //$NON-NLS-1$
- getSHT().debugPrintFullTree(writer, printIntervals);
+ getSHT().debugPrintFullTree(writer, printIntervals, ts);
}
}