- Minor modification of the FW API (better trace/parser integration)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / event / TmfEventContent.java
1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.event;
14
15 /**
16 * <b><u>TmfEventContent</u></b>
17 * <p>
18 * The event content.
19 */
20 public class TmfEventContent {
21
22 // ========================================================================
23 // Attributes
24 // ========================================================================
25
26 private final TmfEventFormat fFormat;
27 private final String fContent;
28 private final int fNbFields;
29 private TmfEventField[] fFields = null;
30
31 // ========================================================================
32 // Constructors
33 // ========================================================================
34
35 /**
36 * @param content
37 * @param format
38 */
39 public TmfEventContent(Object content, TmfEventFormat format) {
40 fFormat = format;
41 fContent = content.toString();
42 fNbFields = fFormat.getLabels().length;
43 }
44
45 // ========================================================================
46 // Accessors
47 // ========================================================================
48
49 /**
50 * @return
51 */
52 public String getContent() {
53 return fContent;
54 }
55
56 /**
57 * @return
58 */
59 public TmfEventFormat getFormat() {
60 return fFormat;
61 }
62
63 /**
64 * @return
65 */
66 public int getNbFields() {
67 return fNbFields;
68 }
69
70 /**
71 * @return
72 */
73 public TmfEventField[] getFields() {
74 if (fFields == null) {
75 fFields = fFormat.parse(fContent);
76 }
77 return fFields;
78 }
79
80 /**
81 * @param id
82 * @return
83 */
84 public TmfEventField getField(int id) {
85 assert id >= 0 && id < fNbFields;
86 if (fFields == null) {
87 fFields = fFormat.parse(fContent);
88 }
89 return fFields[id];
90 }
91
92 /**
93 * @return
94 */
95 public void setFields(TmfEventField[] fields) {
96 fFields = fields;
97 }
98
99 }
This page took 0.033058 seconds and 6 git commands to generate.