1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 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 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Event Model 1.0
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.core
.event
;
17 * A basic implementation of ITmfEventType.
20 * @author Francois Chouinard
25 public class TmfEventType
implements ITmfEventType
{
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
31 private final String fContext
;
32 private final String fTypeId
;
33 private final ITmfEventField fRootField
;
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
42 public TmfEventType() {
43 this(DEFAULT_CONTEXT_ID
, DEFAULT_TYPE_ID
, null);
49 * @param context the type context
50 * @param typeId the type name
51 * @param root the root field
53 public TmfEventType(final String context
, final String typeId
, final ITmfEventField root
) {
54 if (context
== null || typeId
== null) {
55 throw new IllegalArgumentException();
61 // Register to the event type manager
62 TmfEventTypeManager
.getInstance().add(context
, this);
68 * @param type the other type
70 public TmfEventType(final ITmfEventType type
) {
72 throw new IllegalArgumentException();
74 fContext
= type
.getContext();
75 fTypeId
= type
.getName();
76 fRootField
= type
.getRootField();
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 public String
getContext() {
89 public String
getName() {
94 public ITmfEventField
getRootField() {
99 public String
[] getFieldNames() {
100 return (fRootField
!= null) ? fRootField
.getFieldNames() : new String
[0];
104 public String
getFieldName(final int index
) {
105 return (fRootField
!= null) ? fRootField
.getFieldName(index
) : null;
108 // ------------------------------------------------------------------------
110 // ------------------------------------------------------------------------
113 public int hashCode() {
114 final int prime
= 31;
116 result
= prime
* result
+ fContext
.hashCode();
117 result
= prime
* result
+ fTypeId
.hashCode();
122 public boolean equals(final Object obj
) {
129 if (!(obj
instanceof TmfEventType
)) {
132 final TmfEventType other
= (TmfEventType
) obj
;
133 if (!fContext
.equals(other
.fContext
)) {
136 if (!fTypeId
.equals(other
.fTypeId
)) {
143 @SuppressWarnings("nls")
144 public String
toString() {
145 return "TmfEventType [fContext=" + fContext
+ ", fTypeId=" + fTypeId
+ "]";