1 package org
.eclipse
.linuxtools
.internal
.lttng
.core
.event
;
3 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfLocation
;
6 public class LttngLocation
implements ITmfLocation
<LttngTimestamp
>, Comparable
<LttngLocation
>, Cloneable
{
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(final long newCurrentTimestampValue
) {
21 isLastOperationParse
= false;
22 isLastOperationReadNext
= false;
23 isLastOperationSeek
= false;
24 operationTime
= new LttngTimestamp(newCurrentTimestampValue
);
27 public LttngLocation(final LttngTimestamp newCurrentTimestamp
) {
28 isLastOperationParse
= false;
29 isLastOperationReadNext
= false;
30 isLastOperationSeek
= false;
31 operationTime
= new LttngTimestamp(newCurrentTimestamp
);
35 public LttngLocation(final LttngLocation oldLocation
) {
36 this.isLastOperationParse
= oldLocation
.isLastOperationParse
;
37 this.isLastOperationReadNext
= oldLocation
.isLastOperationReadNext
;
38 this.isLastOperationSeek
= oldLocation
.isLastOperationSeek
;
39 this.operationTime
= oldLocation
.operationTime
.clone();
43 public LttngLocation
clone() {
44 LttngLocation newLocation
= new LttngLocation(this);
45 newLocation
.operationTime
= new LttngTimestamp( this.operationTime
);
49 public LttngTimestamp
getOperationTime() {
53 public long getOperationTimeValue() {
54 return operationTime
.getValue();
57 public void setOperationTime(final LttngTimestamp newOperationTime
) {
58 this.operationTime
.setValue(newOperationTime
.getValue());
61 public void setOperationTime(final Long newOperationTimeValue
) {
62 this.operationTime
.setValue(newOperationTimeValue
);
66 public void setLastOperationParse() {
67 isLastOperationParse
= true;
68 isLastOperationReadNext
= false;
69 isLastOperationSeek
= false;
72 public boolean isLastOperationParse() {
73 return isLastOperationParse
;
77 public void setLastOperationReadNext() {
78 isLastOperationParse
= false;
79 isLastOperationReadNext
= true;
80 isLastOperationSeek
= false;
83 public boolean isLastOperationReadNext() {
84 return isLastOperationReadNext
;
88 public void setLastOperationSeek() {
89 isLastOperationParse
= false;
90 isLastOperationReadNext
= false;
91 isLastOperationSeek
= true;
94 public boolean isLastOperationSeek() {
95 return isLastOperationSeek
;
98 public void resetLocationState() {
99 isLastOperationParse
= false;
100 isLastOperationReadNext
= false;
101 isLastOperationSeek
= false;
104 // ------------------------------------------------------------------------
106 // ------------------------------------------------------------------------
109 * @see java.lang.Object#hashCode()
112 public int hashCode() {
113 final int prime
= 31;
115 result
= prime
* result
+ (isLastOperationParse ?
1231 : 1237);
116 result
= prime
* result
+ (isLastOperationReadNext ?
1231 : 1237);
117 result
= prime
* result
+ (isLastOperationSeek ?
1231 : 1237);
118 result
= prime
* result
+ ((operationTime
== null) ?
0 : operationTime
.hashCode());
123 * @see java.lang.Object#equals(java.lang.Object)
126 public boolean equals(final Object obj
) {
131 if (!(obj
instanceof LttngLocation
))
133 final LttngLocation o
= (LttngLocation
) obj
;
134 return (operationTime
.equals(o
.operationTime
))
135 && (isLastOperationParse
== o
.isLastOperationParse
)
136 && (isLastOperationReadNext
== o
.isLastOperationReadNext
)
137 && (isLastOperationSeek
== o
.isLastOperationSeek
);
141 public String
toString() {
142 // return "\tLttngLocation[ P/R/S : " + isLastOperationParse + "/" + isLastOperationReadNext + "/" + isLastOperationSeek + " Current : " + operationTime + " ]";
143 return operationTime
.toString();
146 // ------------------------------------------------------------------------
148 // ------------------------------------------------------------------------
151 public void setLocation(final LttngTimestamp location
) {
152 operationTime
= location
;
156 public LttngTimestamp
getLocation() {
157 return new LttngTimestamp ( operationTime
);
161 public int compareTo(final LttngLocation o
) {
162 return operationTime
.compareTo(o
.operationTime
);