- Minor modification of the FW API (better trace/parser integration)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng / src / org / eclipse / linuxtools / lttng / event / LttngEventContent.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 * William Bourque (wbourque@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.lttng.event;
14
15 import org.eclipse.linuxtools.tmf.event.TmfEventContent;
16
17 /**
18 * <b><u>LttngEventContent</u></b>
19 * <p>
20 * Lttng specific implementation of the TmfEventContent
21 * <p>
22 * Lttng LttngEventContent is very similar from TMF basic one. <br>
23 */
24 public class LttngEventContent extends TmfEventContent {
25
26 /**
27 * Constructor with parameters<br>
28 * <br>
29 * Content will be null as no parsed content is given.
30 *
31 * @param thisFormat The LttngEventFormat relative to the JniEvent
32 */
33 public LttngEventContent(LttngEventFormat thisFormat) {
34 super(null, thisFormat);
35 }
36
37 /**
38 * Constructor with parameters<br>
39 *
40 * @param thisFormat The LttngEventFormat relative to this JniEvent
41 * @param thisParsedContent The string content of the JniEvent, already parsed
42 *
43 */
44 public LttngEventContent(LttngEventFormat thisFormat, String thisParsedContent, LttngEventField[] thisFields) {
45 super(thisParsedContent, thisFormat);
46 setFields(thisFields);
47 }
48
49
50 /* (non-Javadoc)
51 * @see org.eclipse.linuxtools.tmf.event.TmfEventContent#getFields()
52 */
53 @Override
54 public LttngEventField[] getFields() {
55
56 // Request the field variable from the inherited class
57 LttngEventField[] fields = (LttngEventField[])super.getFields();
58
59 // Field may be null if the content hasn't been parse yet
60 // If that's the case, call the parsing function
61 if (fields == null) {
62 fields = ((LttngEventFormat) this.getFormat()).parse(this.getContent());
63 setFields(fields);
64 }
65 return fields;
66 }
67
68 /* (non-Javadoc)
69 * @see org.eclipse.linuxtools.tmf.event.TmfEventContent#getField(int)
70 */
71 @Override
72 public LttngEventField getField(int id) {
73 assert id >= 0 && id < this.getNbFields();
74
75 LttngEventField returnedField = null;
76 LttngEventField[] allFields = this.getFields();
77
78 if ( allFields != null ) {
79 returnedField = allFields[id];
80 }
81
82 return returnedField;
83 }
84
85 /**
86 * @param thisEvent
87 * @return
88 */
89 public LttngEventField[] getFields(LttngEvent thisEvent) {
90
91 // Request the field variable from the inherited class
92 LttngEventField[] fields = (LttngEventField[])super.getFields();
93
94 // Field may be null if the content hasn't been parse yet
95 // If that's the case, call the parsing function
96 if (fields == null) {
97 fields = ((LttngEventFormat)this.getFormat()).parse(thisEvent);
98 setFields(fields);
99 }
100 return fields;
101 }
102
103 /**
104 * @param id
105 * @param thisEvent
106 * @return
107 */
108 public LttngEventField getField(int id, LttngEvent thisEvent) {
109 assert id >= 0 && id < this.getNbFields();
110
111 LttngEventField returnedField = null;
112 LttngEventField[] allFields = this.getFields(thisEvent);
113
114 if ( allFields != null ) {
115 returnedField = allFields[id];
116 }
117
118 return returnedField;
119 }
120
121
122 /**
123 * basic toString() method.
124 *
125 * @return Attributes of the object concatenated in String
126 */
127 public String toString() {
128 return getContent().toString();
129 }
130 }
This page took 0.034174 seconds and 5 git commands to generate.