--- /dev/null
+package org.simantics.history;\r
+\r
+import org.simantics.databoard.accessor.StreamAccessor;\r
+import org.simantics.databoard.accessor.error.AccessorException;\r
+import org.simantics.history.util.StreamIterator;\r
+\r
+public class HistorySamplerItem implements Comparable<HistorySamplerItem> {\r
+ \r
+ Collector collector;\r
+ HistoryManager history; // History source for this item\r
+ String historyItemId;\r
+\r
+ // State data\r
+ StreamAccessor accessor; // Stream accessor\r
+ public StreamIterator iter;\r
+ public int chartDataId;\r
+ \r
+ public HistorySamplerItem(Collector collector, HistoryManager history, String historyItemId, int identityHashCode) {\r
+ this.collector = collector;\r
+ this.history = history;\r
+ this.historyItemId = historyItemId;\r
+ this.chartDataId = identityHashCode;\r
+ }\r
+ \r
+ public void open() throws HistoryException {\r
+ accessor = history.openStream(historyItemId, "r");\r
+ iter = new StreamIterator( accessor );\r
+ }\r
+ \r
+ public void close() {\r
+ if (accessor!=null) {\r
+ try {\r
+ accessor.close();\r
+ } catch (AccessorException e) {\r
+ }\r
+ }\r
+ accessor = null;\r
+ iter = null;\r
+ }\r
+\r
+ @Override\r
+ public int compareTo(HistorySamplerItem o) {\r
+ int i;\r
+ i = historyItemId.compareTo(o.historyItemId); \r
+ if (i!=0) return i;\r
+ return 0;\r
+ }\r
+ \r
+ @Override\r
+ public int hashCode() {\r
+ int code = 0x2304;\r
+ code = 13*code + historyItemId.hashCode();\r
+ code = 13*code + history.hashCode(); \r
+ return code;\r
+ }\r
+ \r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if ( obj == null ) return false;\r
+ if ( obj instanceof HistorySamplerItem == false ) return false;\r
+ HistorySamplerItem other = (HistorySamplerItem) obj; \r
+ if ( !other.history.equals(history) ) return false;\r
+ if ( !other.historyItemId.equals(historyItemId) ) return false;\r
+ return true;\r
+ }\r
+ \r
+}\r