(no commit message)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / event / TmfEventContent.java
CommitLineData
8c8bf09f
ASL
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:
4ab33d2b 10 * Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
8c8bf09f
ASL
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.event;
14
8c8bf09f
ASL
15/**
16 * <b><u>TmfEventContent</u></b>
17 * <p>
18 * The event content.
19 */
20public class TmfEventContent {
21
4ab33d2b 22 // ========================================================================
8c8bf09f 23 // Attributes
4ab33d2b 24 // ========================================================================
8c8bf09f 25
4ab33d2b
AO
26 private final TmfEventFormat fFormat;
27 private final String fContent;
28 private final int fNbFields;
29 private TmfEventField[] fFields = null;
8c8bf09f 30
4ab33d2b 31 // ========================================================================
8c8bf09f 32 // Constructors
4ab33d2b 33 // ========================================================================
8c8bf09f
ASL
34
35 /**
4ab33d2b
AO
36 * @param content
37 * @param format
8c8bf09f 38 */
4ab33d2b
AO
39 public TmfEventContent(Object content, TmfEventFormat format) {
40 fFormat = format;
41 fContent = content.toString();
42 fNbFields = fFormat.getLabels().length;
8c8bf09f
ASL
43 }
44
4ab33d2b 45 // ========================================================================
8c8bf09f 46 // Accessors
4ab33d2b 47 // ========================================================================
8c8bf09f
ASL
48
49 /**
4ab33d2b 50 * @return
8c8bf09f 51 */
4ab33d2b
AO
52 public String getContent() {
53 return fContent;
8c8bf09f
ASL
54 }
55
56 /**
4ab33d2b 57 * @return
8c8bf09f 58 */
4ab33d2b
AO
59 public TmfEventFormat getFormat() {
60 return fFormat;
8c8bf09f
ASL
61 }
62
4ab33d2b
AO
63 /**
64 * @return
65 */
66 public int getNbFields() {
67 return fNbFields;
68 }
8c8bf09f
ASL
69
70 /**
4ab33d2b 71 * @return
8c8bf09f 72 */
4ab33d2b
AO
73 public TmfEventField[] getFields() {
74 if (fFields == null) {
75 fFields = fFormat.parse(fContent);
76 }
8c8bf09f
ASL
77 return fFields;
78 }
79
80 /**
4ab33d2b
AO
81 * @param id
82 * @return
8c8bf09f 83 */
4ab33d2b
AO
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];
8c8bf09f
ASL
90 }
91
8c8bf09f 92}
This page took 0.027656 seconds and 5 git commands to generate.