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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.event
;
15 import java
.util
.HashMap
;
19 * <b><u>TmfEventType</u></b>
23 public class TmfEventType
implements Cloneable
{
25 // ========================================================================
27 // ========================================================================
29 public static final String DEFAULT_TYPE_ID
= "TMF Default Type";
30 public static final String
[] DEFAULT_LABELS
= new String
[] { "Content" };
32 // ========================================================================
34 // ========================================================================
36 private final String fTypeId
;
37 private final String
[] fFieldLabels
;
38 private final int fNbFields
;
39 private final Map
<String
, Integer
> fFieldMap
;
41 // ========================================================================
43 // ========================================================================
48 public TmfEventType() {
49 this(DEFAULT_TYPE_ID
, DEFAULT_LABELS
);
56 public TmfEventType(String typeId
, String
[] labels
) {
57 assert(typeId
!= null);
58 assert(labels
!= null);
60 fFieldLabels
= labels
;
61 fNbFields
= fFieldLabels
.length
;
62 fFieldMap
= new HashMap
<String
, Integer
>();
63 for (int i
= 0; i
< fNbFields
; i
++) {
64 fFieldMap
.put(fFieldLabels
[i
], i
);
71 public TmfEventType(TmfEventType other
) {
72 assert(other
!= null);
73 fTypeId
= other
.fTypeId
;
74 fFieldLabels
= other
.fFieldLabels
;
75 fNbFields
= other
.fNbFields
;
76 fFieldMap
= other
.fFieldMap
;
79 // ========================================================================
81 // ========================================================================
86 public String
getTypeId() {
93 public int getNbFields() {
100 public int getFieldIndex(String id
) throws TmfNoSuchFieldException
{
101 Integer index
= fFieldMap
.get(id
);
103 throw(new TmfNoSuchFieldException(id
));
110 public String
[] getLabels() {
117 public String
getLabel(int i
) {
118 if (i
>= 0 && i
< fNbFields
)
119 return fFieldLabels
[i
];
123 // ========================================================================
125 // ========================================================================
128 public TmfEventType
clone() {
129 return new TmfEventType(this);
133 public String
toString() {
134 return "[TmfEventType:" + fTypeId
+ "]";
This page took 0.034545 seconds and 5 git commands to generate.