592f56975cc21c65c6ec72edebb719b7a45c2e7f
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng / src / org / eclipse / linuxtools / lttng / event / LttngLocation.java
1 package org.eclipse.linuxtools.lttng.event;
2
3 import org.eclipse.linuxtools.tmf.trace.ITmfLocation;
4
5
6 public class LttngLocation implements ITmfLocation {
7
8 private final static Long DEFAULT_LAST_TIME = -1L;
9 private final static Long DEFAULT_CURR_TIME = 0L;
10
11 private Long lastReadTime = null;
12 private Long currentTime = null;
13
14
15
16 public LttngLocation() {
17 this(DEFAULT_LAST_TIME, DEFAULT_CURR_TIME);
18 }
19
20 // public LttngLocation(LttngTimestamp timestamp) {
21 // this(DEFAULT_LAST_TIME, timestamp.getValue());
22 // }
23
24 public LttngLocation(LttngLocation oldLocation) {
25 this(oldLocation.lastReadTime, oldLocation.currentTime);
26 }
27
28 public LttngLocation(Long newCurrentTimestamp) {
29 this(DEFAULT_LAST_TIME, newCurrentTimestamp);
30 }
31
32 public LttngLocation(Long newLastReadTime, Long newCurrentTimestamp) {
33 lastReadTime = newLastReadTime;
34 currentTime = newCurrentTimestamp;
35 }
36
37 @Override
38 public LttngLocation clone() {
39
40 LttngLocation newLocation = null;
41
42 try {
43 newLocation = (LttngLocation)super.clone();
44
45 // *** IMPORTANT ***
46 // Basic type in java are immutable!
47 // Thus, using assignation ("=") on basic type is VALID.
48 newLocation.currentTime = this.currentTime;
49 newLocation.lastReadTime = this.lastReadTime;
50 }
51 catch (CloneNotSupportedException e) {
52 System.out.println("Cloning failed with : " + e.getMessage());
53 }
54
55 return newLocation;
56 }
57
58
59 public void resetLocation() {
60 resetLocation(DEFAULT_CURR_TIME);
61 }
62
63 public void resetLocation(Long newCurrentTimestamp) {
64 lastReadTime = DEFAULT_LAST_TIME;
65 lastReadTime = DEFAULT_CURR_TIME;
66 }
67
68
69
70 public Long getLastReadTime() {
71 return lastReadTime;
72 }
73
74 public void setLastReadTime(Long newLastReadTime) {
75 this.lastReadTime = newLastReadTime;
76 }
77
78 public Long getCurrentTime() {
79 return currentTime;
80 }
81
82 public void setCurrentTime(Long newCurrentTime) {
83 this.currentTime = newCurrentTime;
84 }
85
86
87 @Override
88 public String toString() {
89 return "\tLttngLocation[ Last : " + lastReadTime + " Current : " + currentTime + " ]";
90 }
91
92 }
This page took 0.03238 seconds and 4 git commands to generate.