Implement TmfTimestampFormat
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfTimestamp.java
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
12 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
13
14 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
15 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
16
17 /**
18 * The CTF adapter for the TMF timestamp
19 *
20 * @version 1.1
21 * @author Matthew khouzam
22 */
23 public class CtfTmfTimestamp extends TmfTimestamp {
24
25 /**
26 */
27 public enum TimestampType {
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
44 }
45
46 private TimestampType type;
47
48 /**
49 * Constructor for CtfTmfTimestamp.
50 * @param timestamp long
51 */
52 public CtfTmfTimestamp(long timestamp) {
53 setValue(timestamp, ITmfTimestamp.NANOSECOND_SCALE, 0);
54 type = TimestampType.DAY;
55 }
56
57 /**
58 * Method setType.
59 * @param value TimestampType
60 */
61 public void setType(TimestampType value) {
62 type = value;
63 }
64
65 /**
66 * Method getType.
67 * @return TimestampType
68 */
69 public TimestampType getType() {
70 return type;
71 }
72
73 /* (non-Javadoc)
74 * @see java.lang.Object#hashCode()
75 */
76 @Override
77 public int hashCode() {
78 final int prime = 31;
79 int result = super.hashCode() * prime;
80 result += ((type == null) ? 0 : type.toString().hashCode());
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
105 }
This page took 0.033749 seconds and 6 git commands to generate.