Commit | Line | Data |
---|---|---|
5d10d135 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: | |
10 | * William Bourque (wbourque@gmail.com) - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.lttng.event; | |
14 | ||
5d10d135 | 15 | import org.eclipse.linuxtools.tmf.event.TmfEventContent; |
5d10d135 ASL |
16 | |
17 | /** | |
146a887c FC |
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> | |
5d10d135 ASL |
23 | */ |
24 | public class LttngEventContent extends TmfEventContent { | |
25 | ||
5d10d135 | 26 | /** |
146a887c FC |
27 | * Constructor with parameters<br> |
28 | * <br> | |
29 | * Content will be null as no parsed content is given. | |
5d10d135 | 30 | * |
146a887c | 31 | * @param thisFormat The LttngEventFormat relative to the JniEvent |
5d10d135 | 32 | */ |
146a887c FC |
33 | public LttngEventContent(LttngEventFormat thisFormat) { |
34 | super(null, thisFormat); | |
5d10d135 | 35 | } |
146a887c | 36 | |
5d10d135 | 37 | /** |
146a887c | 38 | * Constructor with parameters<br> |
5d10d135 | 39 | * |
146a887c FC |
40 | * @param thisFormat The LttngEventFormat relative to this JniEvent |
41 | * @param thisParsedContent The string content of the JniEvent, already parsed | |
5d10d135 | 42 | * |
5d10d135 | 43 | */ |
146a887c FC |
44 | public LttngEventContent(LttngEventFormat thisFormat, String thisParsedContent, LttngEventField[] thisFields) { |
45 | super(thisParsedContent, thisFormat); | |
46 | setFields(thisFields); | |
5d10d135 ASL |
47 | } |
48 | ||
49 | ||
146a887c FC |
50 | /* (non-Javadoc) |
51 | * @see org.eclipse.linuxtools.tmf.event.TmfEventContent#getFields() | |
5d10d135 ASL |
52 | */ |
53 | @Override | |
146a887c FC |
54 | public LttngEventField[] getFields() { |
55 | ||
56 | // Request the field variable from the inherited class | |
57 | LttngEventField[] fields = (LttngEventField[])super.getFields(); | |
5d10d135 | 58 | |
146a887c FC |
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; | |
5d10d135 | 66 | } |
146a887c FC |
67 | |
68 | /* (non-Javadoc) | |
69 | * @see org.eclipse.linuxtools.tmf.event.TmfEventContent#getField(int) | |
5d10d135 ASL |
70 | */ |
71 | @Override | |
146a887c FC |
72 | public LttngEventField getField(int id) { |
73 | assert id >= 0 && id < this.getNbFields(); | |
88144d4a | 74 | |
146a887c FC |
75 | LttngEventField returnedField = null; |
76 | LttngEventField[] allFields = this.getFields(); | |
88144d4a | 77 | |
146a887c FC |
78 | if ( allFields != null ) { |
79 | returnedField = allFields[id]; | |
5d10d135 | 80 | } |
146a887c FC |
81 | |
82 | return returnedField; | |
5d10d135 ASL |
83 | } |
84 | ||
85 | /** | |
146a887c FC |
86 | * @param thisEvent |
87 | * @return | |
5d10d135 | 88 | */ |
146a887c FC |
89 | public LttngEventField[] getFields(LttngEvent thisEvent) { |
90 | ||
91 | // Request the field variable from the inherited class | |
92 | LttngEventField[] fields = (LttngEventField[])super.getFields(); | |
88144d4a | 93 | |
146a887c FC |
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); | |
88144d4a | 99 | } |
146a887c | 100 | return fields; |
5d10d135 ASL |
101 | } |
102 | ||
103 | /** | |
146a887c FC |
104 | * @param id |
105 | * @param thisEvent | |
106 | * @return | |
5d10d135 | 107 | */ |
146a887c FC |
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); | |
5d10d135 | 113 | |
146a887c FC |
114 | if ( allFields != null ) { |
115 | returnedField = allFields[id]; | |
5d10d135 ASL |
116 | } |
117 | ||
118 | return returnedField; | |
119 | } | |
120 | ||
146a887c | 121 | |
5d10d135 | 122 | /** |
146a887c | 123 | * basic toString() method. |
5d10d135 | 124 | * |
146a887c | 125 | * @return Attributes of the object concatenated in String |
5d10d135 | 126 | */ |
5d10d135 | 127 | public String toString() { |
146a887c | 128 | return getContent().toString(); |
5d10d135 ASL |
129 | } |
130 | } |