1 package org
.eclipse
.linuxtools
.lttng
.event
;
3 import org
.eclipse
.linuxtools
.tmf
.trace
.ITmfLocation
;
6 public class LttngLocation
implements ITmfLocation
<LttngTimestamp
> {
8 private final static long DEFAULT_CURR_TIME
= 0L;
10 private boolean isLastOperationParse
= false ;
11 private boolean isLastOperationReadNext
= false;
12 private boolean isLastOperationSeek
= false;
14 private LttngTimestamp operationTime
= null;
16 public LttngLocation() {
17 this( DEFAULT_CURR_TIME
);
20 public LttngLocation(long newCurrentTimestampValue
) {
21 isLastOperationParse
= false;
22 isLastOperationReadNext
= false;
23 isLastOperationSeek
= false;
24 operationTime
= new LttngTimestamp(newCurrentTimestampValue
);
27 public LttngLocation(LttngTimestamp newCurrentTimestamp
) {
28 isLastOperationParse
= false;
29 isLastOperationReadNext
= false;
30 isLastOperationSeek
= false;
31 operationTime
= new LttngTimestamp(newCurrentTimestamp
);
35 public LttngLocation(LttngLocation oldLocation
) {
36 this.isLastOperationParse
= oldLocation
.isLastOperationParse
;
37 this.isLastOperationReadNext
= oldLocation
.isLastOperationReadNext
;
38 this.isLastOperationSeek
= oldLocation
.isLastOperationSeek
;
39 this.operationTime
= oldLocation
.operationTime
;
43 public LttngLocation
clone() {
45 LttngLocation newLocation
= null;
48 newLocation
= (LttngLocation
)super.clone();
51 // Basic type in java are immutable!
52 // Thus, using assignation ("=") on basic type is VALID.
53 newLocation
.isLastOperationParse
= this.isLastOperationParse
;
54 newLocation
.isLastOperationReadNext
= this.isLastOperationReadNext
;
55 newLocation
.isLastOperationSeek
= this.isLastOperationSeek
;
57 // For other type, we need to create a new timestamp
58 newLocation
.operationTime
= new LttngTimestamp( this.operationTime
);
60 catch (CloneNotSupportedException e
) {
61 System
.out
.println("Cloning failed with : " + e
.getMessage());
67 public LttngTimestamp
getOperationTime() {
71 public long getOperationTimeValue() {
72 return operationTime
.getValue();
75 public void setOperationTime(LttngTimestamp newOperationTime
) {
76 this.operationTime
.setValue(newOperationTime
.getValue());
79 public void setOperationTime(Long newOperationTimeValue
) {
80 this.operationTime
.setValue(newOperationTimeValue
);
84 public void setLastOperationParse() {
85 isLastOperationParse
= true;
86 isLastOperationReadNext
= false;
87 isLastOperationSeek
= false;
90 public boolean isLastOperationParse() {
91 return isLastOperationParse
;
95 public void setLastOperationReadNext() {
96 isLastOperationParse
= false;
97 isLastOperationReadNext
= true;
98 isLastOperationSeek
= false;
101 public boolean isLastOperationReadNext() {
102 return isLastOperationReadNext
;
106 public void setLastOperationSeek() {
107 isLastOperationParse
= false;
108 isLastOperationReadNext
= false;
109 isLastOperationSeek
= true;
112 public boolean isLastOperationSeek() {
113 return isLastOperationSeek
;
116 public void resetLocationState() {
117 isLastOperationParse
= false;
118 isLastOperationReadNext
= false;
119 isLastOperationSeek
= false;
122 // ------------------------------------------------------------------------
124 // ------------------------------------------------------------------------
127 public boolean equals(Object other
) {
128 if (!(other
instanceof LttngLocation
)) {
131 LttngLocation o
= (LttngLocation
) other
;
132 return (operationTime
.equals(o
.operationTime
)) && (isLastOperationParse
== o
.isLastOperationParse
) &&
133 (isLastOperationReadNext
== o
.isLastOperationReadNext
) && (isLastOperationSeek
== o
.isLastOperationSeek
);
137 public String
toString() {
138 // return "\tLttngLocation[ P/R/S : " + isLastOperationParse + "/" + isLastOperationReadNext + "/" + isLastOperationSeek + " Current : " + operationTime + " ]";
139 return operationTime
.toString();
142 // ------------------------------------------------------------------------
144 // ------------------------------------------------------------------------
147 public void setLocation(LttngTimestamp location
) {
148 operationTime
= (LttngTimestamp
)location
;
152 public LttngTimestamp
getLocation() {
153 return new LttngTimestamp ( operationTime
);