1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made 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
10 * William Bourque (wbourque@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.lttng
.core
.event
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.event
.*;
18 * <b><u>LttngEventType</u></b><p>
20 * Lttng specific implementation of the TmfEventType.<p>
22 * This implementation add some attributes to the basic Tmf object.
24 public class LttngEventType
extends TmfEventType
{
26 private static final String DEFAULT_CONTEXT
= "Kernel Trace"; //$NON-NLS-1$
27 private static final String DEFAULT_TYPE_ID
= "Kernel Trace"; //$NON-NLS-1$
28 // These should match the column names in LTTng Events Table
29 public static final String TIMESTAMP_LABEL
= "Timestamp"; //$NON-NLS-1$
30 public static final String TRACE_LABEL
= "Trace"; //$NON-NLS-1$
31 public static final String MARKER_LABEL
= "Marker"; //$NON-NLS-1$
32 public static final String CONTENT_LABEL
= "Content"; //$NON-NLS-1$
33 private static final String
[] DEFAULT_LABELS
= {
34 TIMESTAMP_LABEL
, TRACE_LABEL
, MARKER_LABEL
, CONTENT_LABEL
36 public static final LttngEventType DEFAULT_EVENT_TYPE
= new LttngEventType(DEFAULT_TYPE_ID
, DEFAULT_LABELS
);
38 private String tracefileName
= null;
39 private Long cpuId
= null;
40 private String markerName
= null;
41 private int markerId
= -1;
44 * Default Constructor.<p>
47 public LttngEventType() {
52 * Default Constructor.<p>
55 public LttngEventType(String typeId
, String
[] labels
) {
56 super(DEFAULT_CONTEXT
, typeId
, TmfEventField
.makeRoot(labels
));
60 * Constructor with parameters.<p>
62 * @param thisTracefileName Tracefile (channel) name in Ltt
63 * @param thisMarkerName Marker name in LTT
64 * @param thisMarkerfieldsName MarkerFields related to this marker
66 public LttngEventType(String thisTracefileName
, Long thisCpuId
, String thisMarkerName
, int thisMarkerId
, String
[] thisMarkerfieldsName
) {
67 super(DEFAULT_CONTEXT
, thisTracefileName
+ "/" + thisCpuId
+ "/" + thisMarkerName
, TmfEventField
.makeRoot(thisMarkerfieldsName
)); //$NON-NLS-1$ //$NON-NLS-2$
69 tracefileName
= thisTracefileName
;
71 markerName
= thisMarkerName
;
72 markerId
= thisMarkerId
;
76 * Copy constructor.<p>
78 * @param oldType Type we want to copy from
80 public LttngEventType(LttngEventType oldType
) {
81 this(oldType
.tracefileName
, oldType
.cpuId
, oldType
.markerName
, oldType
.markerId
, oldType
.getFieldNames());
85 public String
getTracefileName() {
89 public Long
getCpuId() {
93 public String
getMarkerName() {
97 public int getMarkerId() {
104 * @return TypeId (channel/marker) of the object
107 @SuppressWarnings("nls")
108 public String
toString() {
110 // This is used as-it in the events view, so we won't change its format.
111 // ...but maybe we should?
112 return tracefileName
+ "/" + cpuId
.toString() + "/" + markerName
;
116 public LttngEventType
clone() {
117 LttngEventType clone
= (LttngEventType
) super.clone();
118 clone
.tracefileName
= tracefileName
;
119 clone
.cpuId
= Long
.valueOf(cpuId
);
120 clone
.markerName
= markerName
;
121 clone
.markerId
= markerId
;
126 * @see java.lang.Object#hashCode()
129 public int hashCode() {
130 final int prime
= 31;
131 int result
= super.hashCode();
132 result
= prime
* result
+ ((cpuId
== null) ?
0 : cpuId
.hashCode());
133 result
= prime
* result
+ markerId
;
134 result
= prime
* result
+ ((markerName
== null) ?
0 : markerName
.hashCode());
135 result
= prime
* result
+ ((tracefileName
== null) ?
0 : tracefileName
.hashCode());
140 * @see java.lang.Object#equals(java.lang.Object)
143 public boolean equals(Object obj
) {
147 if (!super.equals(obj
)) {
150 if (!(obj
instanceof LttngEventType
)) {
153 LttngEventType other
= (LttngEventType
) obj
;
155 if (other
.cpuId
!= null) {
158 } else if (!cpuId
.equals(other
.cpuId
)) {
161 if (markerId
!= other
.markerId
) {
164 if (markerName
== null) {
165 if (other
.markerName
!= null) {
168 } else if (!markerName
.equals(other
.markerName
)) {
171 if (tracefileName
== null) {
172 if (other
.tracefileName
!= null) {
175 } else if (!tracefileName
.equals(other
.tracefileName
)) {