Commit | Line | Data |
---|---|---|
b0f9e44d MK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2012 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are made | |
5 | * available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: Matthew Khouzam - Initial API and implementation | |
10 | *******************************************************************************/ | |
11 | ||
ce2388e0 FC |
12 | package org.eclipse.linuxtools.tmf.core.ctfadaptor; |
13 | ||
b0f9e44d | 14 | import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; |
ce2388e0 FC |
15 | import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; |
16 | ||
b1baa808 | 17 | /** |
d09f973b | 18 | * The CTF adapter for the TMF timestamp |
9b749023 | 19 | * |
f8177ba2 | 20 | * @version 1.1 |
d09f973b | 21 | * @author Matthew khouzam |
b1baa808 | 22 | */ |
929acb4f | 23 | public class CtfTmfTimestamp extends TmfTimestamp { |
ce2388e0 | 24 | |
b1baa808 MK |
25 | /** |
26 | */ | |
b0f9e44d | 27 | public enum TimestampType { |
9ac2eb62 MK |
28 | /** |
29 | * yyyy/mm/dd hh:mm:ss.nnnnnnnnnn | |
30 | */ | |
31 | FULL_DATE, | |
32 | /** | |
33 | * hh:mm:ss.nnnnnnnnnn | |
34 | */ | |
35 | DAY, | |
36 | /** | |
37 | * nnnnnnnnnnnnnnnnnnnnn ns | |
38 | */ | |
39 | NANOS, | |
40 | /** | |
41 | * ssssssssss.nnnnnnnnnn s | |
42 | */ | |
43 | SECONDS | |
b0f9e44d MK |
44 | } |
45 | ||
46 | private TimestampType type; | |
ce2388e0 | 47 | |
b1baa808 MK |
48 | /** |
49 | * Constructor for CtfTmfTimestamp. | |
50 | * @param timestamp long | |
51 | */ | |
b0f9e44d | 52 | public CtfTmfTimestamp(long timestamp) { |
4593bd5b | 53 | super(timestamp, ITmfTimestamp.NANOSECOND_SCALE, 0); |
b0f9e44d | 54 | type = TimestampType.DAY; |
ce2388e0 FC |
55 | } |
56 | ||
b1baa808 MK |
57 | /** |
58 | * Method setType. | |
59 | * @param value TimestampType | |
60 | */ | |
b0f9e44d MK |
61 | public void setType(TimestampType value) { |
62 | type = value; | |
63 | } | |
64 | ||
b1baa808 MK |
65 | /** |
66 | * Method getType. | |
67 | * @return TimestampType | |
68 | */ | |
b0f9e44d MK |
69 | public TimestampType getType() { |
70 | return type; | |
ce2388e0 FC |
71 | } |
72 | ||
b1baa808 MK |
73 | /* (non-Javadoc) |
74 | * @see java.lang.Object#hashCode() | |
75 | */ | |
76 | @Override | |
77 | public int hashCode() { | |
78 | final int prime = 31; | |
81c8e6f7 MK |
79 | int result = super.hashCode() * prime; |
80 | result += ((type == null) ? 0 : type.toString().hashCode()); | |
b1baa808 MK |
81 | return result; |
82 | } | |
83 | ||
84 | /* (non-Javadoc) | |
85 | * @see java.lang.Object#equals(java.lang.Object) | |
86 | */ | |
87 | @Override | |
88 | public boolean equals(Object obj) { | |
89 | if (this == obj) { | |
90 | return true; | |
91 | } | |
92 | if (!super.equals(obj)) { | |
93 | return false; | |
94 | } | |
95 | if (!(obj instanceof CtfTmfTimestamp)) { | |
96 | return false; | |
97 | } | |
98 | CtfTmfTimestamp other = (CtfTmfTimestamp) obj; | |
99 | if (type != other.type) { | |
100 | return false; | |
101 | } | |
102 | return true; | |
103 | } | |
104 | ||
ce2388e0 | 105 | } |