temporary re-factoring project
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng / src / org / eclipse / linuxtools / lttng / trace / LTTngTextTrace.java
CommitLineData
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
13package org.eclipse.linuxtools.lttng.trace;
14
15import java.io.BufferedReader;
16import java.io.FileReader;
17import java.io.IOException;
88144d4a 18import java.util.Collections;
5d10d135
ASL
19import java.util.HashMap;
20
21import org.eclipse.linuxtools.lttng.event.LttngEvent;
22import org.eclipse.linuxtools.lttng.event.LttngEventContent;
23import org.eclipse.linuxtools.lttng.event.LttngEventField;
24import org.eclipse.linuxtools.lttng.event.LttngEventReference;
25import org.eclipse.linuxtools.lttng.event.LttngEventSource;
26import org.eclipse.linuxtools.lttng.event.LttngEventType;
27import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
28import org.eclipse.linuxtools.lttng.jni.JniEvent;
88144d4a 29import org.eclipse.linuxtools.tmf.event.TmfEvent;
5d10d135 30import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
88144d4a
ASL
31import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
32import org.eclipse.linuxtools.tmf.request.ITmfRequestHandler;
5d10d135 33import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
5d10d135 34import org.eclipse.linuxtools.tmf.trace.TmfTrace;
88144d4a
ASL
35import org.eclipse.linuxtools.tmf.trace.TmfTraceCheckpoint;
36import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
5d10d135 37
88144d4a 38public class LTTngTextTrace extends TmfTrace implements ITmfTrace, ITmfRequestHandler<TmfEvent> {
5d10d135
ASL
39 private LttngTimestamp eventTimestamp = null;
40 private LttngEventSource eventSource = null;
41 private LttngEventType eventType = null;
42 private TextLttngEventContent eventContent = null;
43 private LttngEventReference eventReference = null;
44 // The actual event
45 private TextLttngEvent currentLttngEvent = null;
46
47 private HashMap<String, LttngEventType> traceTypes = null;
48
49 private String tracepath = "";
50 private FileReader fr = null;
51 private BufferedReader br = null;
52 private Long nbCharRead = 0L;
53
54 private int cpuNumber = -1;
55
56 private boolean showDebug = false;
57
58 public LTTngTextTrace(String path) throws Exception {
59 this(path, false);
60 }
61
62 public LTTngTextTrace(String path, boolean skipIndexing) throws Exception {
88144d4a 63 super(path, 1, true);
5d10d135
ASL
64
65 tracepath = path;
66 traceTypes = new HashMap<String, LttngEventType>();
67
68 eventTimestamp = new LttngTimestamp();
69 eventSource = new LttngEventSource();
70 eventType = new LttngEventType();
71 eventContent = new TextLttngEventContent(currentLttngEvent);
72 eventReference = new LttngEventReference(this.getName());
73
88144d4a 74 currentLttngEvent = new TextLttngEvent(eventTimestamp, eventSource, eventType, eventContent, eventReference);
5d10d135
ASL
75 eventContent.setEvent(currentLttngEvent);
76
77 if ( positionToFirstEvent() == false ) {
78 throw new IOException("Fail to position to the beginning of the trace");
79 }
80 else {
88144d4a 81 fCacheSize = 1000;
5d10d135
ASL
82
83 // Skip indexing if asked
88144d4a
ASL
84 if ( skipIndexing == true ) {
85 fCheckpoints.add(new TmfTraceCheckpoint(new LttngTimestamp(0L), 0L));
86 }
87 else {
88 indexStream();
89 }
5d10d135
ASL
90
91 Long endTime = currentLttngEvent.getTimestamp().getValue();
92 positionToFirstEvent();
93
88144d4a 94 getNextEvent(new TmfTraceContext(null, null, 0));
5d10d135
ASL
95 Long starTime = currentLttngEvent.getTimestamp().getValue();
96 positionToFirstEvent();
97
98 setTimeRange( new TmfTimeRange( new LttngTimestamp(starTime),
99 new LttngTimestamp(endTime)
100 ) );
101 }
102 }
103
104
88144d4a
ASL
105 private LTTngTextTrace(LTTngTrace oldStream) throws Exception {
106 super(null);
107 throw new Exception("Copy constructor should never be use with a LTTngTrace!");
5d10d135
ASL
108 }
109
88144d4a
ASL
110 @Override
111 public void indexStream() {
112 // Position the trace at the beginning
113 TmfTraceContext context = seekLocation(null);
114
115 long nbEvents=1L;
116 fCheckpoints.add(new TmfTraceCheckpoint(new LttngTimestamp(0L), 0L));
117
118 LttngTimestamp startTime = null;
119 LttngTimestamp lastTime = new LttngTimestamp();
120 LttngTimestamp timestamp = null;
121 Long previousCharRead = 0L;
122
123 TextLttngEvent tmpEvent = (TextLttngEvent)getNextEvent(context);
124
125 while ( tmpEvent != null) {
126 timestamp = (LttngTimestamp)context.getTimestamp();
127 previousCharRead = nbCharRead;
128
129 if ( startTime == null ) {
130 startTime = new LttngTimestamp(timestamp.getValue());
131 }
132
133 if ((++nbEvents % fCacheSize) == 0) {
134 fCheckpoints.add(new TmfTraceCheckpoint(new LttngTimestamp(timestamp.getValue()), previousCharRead));
135 }
136
137 tmpEvent = (TextLttngEvent)getNextEvent(context);
138 }
139
140 if (timestamp != null) {
141 lastTime.setValue(timestamp.getValue());
142
143 setTimeRange( new TmfTimeRange(startTime, lastTime) );
144 notifyListeners(getTimeRange());
145 }
146
147 fNbEvents = nbEvents;
148
149 if ( showDebug == true ) {
150 for ( int pos=0; pos < fCheckpoints.size(); pos++) {
151 System.out.print(pos + ": " + "\t");
152 System.out.print( fCheckpoints.get(pos).getTimestamp() + "\t" );
153 System.out.println( fCheckpoints.get(pos).getLocation() );
154 }
155 }
156
157 }
5d10d135
ASL
158
159 private boolean positionToFirstEvent() {
160
161 boolean isSuccessful = true;
162
163 try {
164 if ( br != null ) {
165 br.close();
166 fr.close();
167 }
168
169 fr = new FileReader(tracepath);
170 br = new BufferedReader(fr);
171
172 // Skip the 2 lines header
173 br.readLine();
174 br.readLine();
175
176 // Make sure the event time is consistent
177 eventTimestamp.setValue(0L);
178 }
179 catch (Exception e) {
180 isSuccessful = false;
181 }
182
183 return isSuccessful;
184 }
185
88144d4a 186 private void skipToPosition(Long skipPosition) {
5d10d135 187 try {
5d10d135
ASL
188 if ( showDebug == true ) {
189 System.out.println("skipToPosition(Long skipPosition)");
190 System.out.println("\tSkipping to : " + skipPosition);
191 System.out.println();
192 }
193 positionToFirstEvent();
88144d4a 194 br.skip(skipPosition);
5d10d135
ASL
195
196 nbCharRead = skipPosition;
197 }
198 catch (Exception e) {
199 e.printStackTrace();
200 }
201 }
202
88144d4a 203 public TmfTraceContext seekLocation(Object location) {
5d10d135 204 if (location == null) {
88144d4a 205 location = 0L;
5d10d135 206 }
88144d4a
ASL
207
208 TmfTraceContext tmpTraceContext = new TmfTraceContext(nbCharRead, (LttngTimestamp)currentLttngEvent.getTimestamp(), 0L);
209 Long previousCharRead = nbCharRead;
210 Long previousTimestamp = currentLttngEvent.getTimestamp().getValue();
211 Long tmploc = (Long)location;
212
213 if ( showDebug == true ) {
214 System.out.println("seekLocation(Object location)");
215 System.out.println("\ttimestamp: " + (LttngTimestamp)currentLttngEvent.getTimestamp());
216 System.out.println("\tnbCharRead:" + nbCharRead);
217 System.out.println("\tlocation: " + location);
218 System.out.println();
5d10d135 219 }
88144d4a
ASL
220
221 if ( tmploc < nbCharRead ) {
222 skipToPosition(tmploc);
223 }
224
225 if ( tmploc > nbCharRead ) {
226 while ( tmploc > nbCharRead ) {
227 previousCharRead = nbCharRead;
228 previousTimestamp = currentLttngEvent.getTimestamp().getValue();
229 getNextEvent(tmpTraceContext);
230 }
231 }
232
233 tmpTraceContext.setTimestamp(new LttngTimestamp(previousTimestamp));
234 tmpTraceContext.setLocation(previousCharRead);
5d10d135
ASL
235
236 return tmpTraceContext;
237 }
238
88144d4a
ASL
239
240 @Override
241 public TmfTraceContext seekEvent(TmfTimestamp timestamp) {
242
243 if (timestamp == null) {
244 timestamp = getStartTime();
245 }
246
247 int index = Collections.binarySearch(fCheckpoints, new TmfTraceCheckpoint(timestamp, 0));
248
249 if (index < 0) {
250 index = 0;
251 }
252
253 Object location = (index < fCheckpoints.size()) ? fCheckpoints.elementAt(index).getLocation() : null;
254
255 if ( showDebug == true ) {
256 System.out.println("seekEvent(TmfTimestamp timestamp)");
257 System.out.println("\ttimestamp: " + timestamp.getValue());
258 System.out.println("\tindex: " + index);
259 System.out.println("\tlocation: " + location);
260 System.out.println();
261 }
262
263 // *** HACK ***
264 // We only know the timestamp AFTER we read the actual event
265 // For this reason, we save the current "position" in byte (nbCharRead) and we seek back 1 event after we find our event
266 TmfTraceContext currentEventContext = seekLocation(location);
267
268 Long previousCharRead = nbCharRead;
269 Long previousTimestamp = currentLttngEvent.getTimestamp().getValue();
270 TmfEvent event = getNextEvent(currentEventContext);
271
272 while ( (event != null) && (event.getTimestamp().getValue() < timestamp.getValue()) ) {
273 previousCharRead = nbCharRead;
274 previousTimestamp = currentLttngEvent.getTimestamp().getValue();
275 event = getNextEvent(currentEventContext);
276 }
277
278 if ( event != null ) {
279 skipToPosition(previousCharRead);
280 currentEventContext.setLocation(previousCharRead);
281 currentEventContext.setTimestamp(new LttngTimestamp(previousTimestamp));
282 }
283
284 return currentEventContext;
285 }
286
287 @Override
288 public TmfTraceContext seekEvent(long position) {
289
290 int checkPointPos = ((int)position / fCacheSize);
291
292 Object location;
293 location = ( checkPointPos < fCheckpoints.size()) ? fCheckpoints.elementAt(checkPointPos).getLocation() : null;
294
295 long index = ((position / fCacheSize)*fCacheSize)-1;
296
297 if ( index < 0) {
298 index = 0;
299 }
300
301 if ( showDebug == true ) {
302 System.out.println("seekEvent(long position)");
303 System.out.println("\tposition: " + position);
304 System.out.println("\tindex: " + index);
305 System.out.println("\tlocation: " + location);
306 System.out.println();
307 }
308 TmfTraceContext currentEventContext = seekLocation(location);
309 Long previousCharRead = (Long)currentEventContext.getLocation();
310 Long previousTimestamp = currentEventContext.getTimestamp().getValue();
311
312 TmfEvent event = null;
313 while (index < position) {
314 event = getNextEvent(currentEventContext);
315 previousCharRead = nbCharRead;
316 previousTimestamp = currentLttngEvent.getTimestamp().getValue();
317 index++;
318 }
319
320 if ( event != null ) {
321 skipToPosition(previousCharRead);
322 currentEventContext.setLocation(previousCharRead);
323 currentEventContext.setTimestamp(new LttngTimestamp(previousTimestamp));
324 }
325
326 return currentEventContext;
327 }
328
329 @Override
330 public TmfEvent getNextEvent(TmfTraceContext context) {
5d10d135
ASL
331
332 // All parsing variables declared here so to be able to print them into the catch if needed
333 String tmpContent = null;
334 int tmpCurIndex = 0;
335 int tmpPrevIndex = 0;
336
337 String tracefile = "";
338 long tmpCpu = 0;
339 String marker = "";
340
341 long tmpSecond = 0;
342 long tmpNanosecond = 0;
343
344 String parsedPayload = "";
345 String markerName = "";
346 Object payload = "";
347
348 HashMap<String, LttngEventField> fieldsMap = null;
349
350 LttngEvent returnedEvent = null;
351
352 try {
353 tmpContent = br.readLine();
354
355 if (tmpContent != null) {
356 // *** NOTE :
357 // -1 is the skip the end of line (\n)
358 nbCharRead += (tmpContent.length()+1);
359
360 if ( (currentLttngEvent != null) && (currentLttngEvent.getContent().getRawContent() != null) ) {
361 currentLttngEvent.getContent().emptyContent();
362 }
363
364 // EventSource is always the same for now :
365 eventSource.setSourceId("Kernel Core");
366
367
368 // Tracefile and marker are first in the file
369 // Sound like :
370 // kernel.syscall_entry:
371 tmpCurIndex = tmpContent.indexOf(".", tmpPrevIndex);
372
373 // *** HACK ***
374 // Evil exit case here : the two last line of the text dump does not contain "."
88144d4a 375 // We should check in a better way (string comparaison and such) but it make the whole process to weight a lot more
5d10d135
ASL
376 // Conclusion : this is ugly but fast.
377 if ( tmpCurIndex < 0 ) {
378 if ( showDebug == true ) {
379 System.out.println("END OF FILE.");
380 System.out.println();
381 }
88144d4a 382 return returnedEvent;
5d10d135
ASL
383 }
384
385 tracefile = tmpContent.substring(tmpPrevIndex, tmpCurIndex ).trim();
386 /*System.out.println(tracefile);*/
387
388 tmpPrevIndex = tmpCurIndex;
389 tmpCurIndex = tmpContent.indexOf(":", tmpPrevIndex);
390 marker = tmpContent.substring(tmpPrevIndex+1, tmpCurIndex ).trim();
391 /*System.out.println(marker);*/
392
393 // Timestamp is next but is presented in second.milisecond format, we have to split them
394 // Sound like :
395 // 952.162637168
396 tmpPrevIndex = tmpCurIndex+1;
397 tmpCurIndex = tmpContent.indexOf(".", tmpPrevIndex);
398 tmpSecond = Long.parseLong( tmpContent.substring(tmpPrevIndex, tmpCurIndex ).trim() );
399 /*System.out.println(tmpSecond);*/
400
401 tmpPrevIndex = tmpCurIndex+1;
402 tmpCurIndex = tmpContent.indexOf(" ", tmpPrevIndex);
403 tmpNanosecond = Long.parseLong( tmpContent.substring(tmpPrevIndex, tmpCurIndex ).trim() );
404 /*System.out.println(tmpNanosecond);*/
405
406 // We have enough information here to set the timestamp
407 eventTimestamp.setValue( (tmpSecond * 1000000000) + tmpNanosecond );
408 /*System.out.println(eventTimestamp.toString());*/
409
410 // Next field is the reference
411 // A long string enclosed by parenthesis and ending with a comma
412 // (/home/william/workspace/org.eclipse.linuxtools.lttng.tests/traceset/trace-618339events-1293lost-1cpu/kernel_0),
413 tmpPrevIndex = tmpCurIndex+1;
414 tmpCurIndex = tmpContent.indexOf("(", tmpPrevIndex);
415 tmpPrevIndex = tmpCurIndex+1;
416 tmpCurIndex = tmpContent.indexOf("),", tmpPrevIndex);
417 String fullTracePath = tmpContent.substring(tmpPrevIndex, tmpCurIndex ).trim();
418 /*System.out.println(fullTracePath);*/
419
420 eventReference.setValue(fullTracePath);
421 String traceName = fullTracePath.substring(fullTracePath.lastIndexOf("/")+1).trim();
422 /*System.out.println(traceName);*/
423 eventReference.setTracepath(traceName);
424
425
426 // The next few fields are relatives to the state system (pid, ppid, etc...) we need to skip them.
427 // They should be like the following :
428 // 4175, 4175, hal-acl-tool, , 4168,
429
430 // 1st comma
431 tmpPrevIndex = tmpCurIndex+1;
432 tmpCurIndex = tmpContent.indexOf(",", tmpPrevIndex);
433 // 2nd comma
434 tmpPrevIndex = tmpCurIndex+1;
435 tmpCurIndex = tmpContent.indexOf(",", tmpPrevIndex);
436 // 3rd comma
437 tmpPrevIndex = tmpCurIndex+1;
438 tmpCurIndex = tmpContent.indexOf(",", tmpPrevIndex);
439 // 4th comma
440 tmpPrevIndex = tmpCurIndex+1;
441 tmpCurIndex = tmpContent.indexOf(",", tmpPrevIndex);
442 // 5th comma
443 tmpPrevIndex = tmpCurIndex+1;
444 tmpCurIndex = tmpContent.indexOf(",", tmpPrevIndex);
445 // 6th comma
446 tmpPrevIndex = tmpCurIndex+1;
447 tmpCurIndex = tmpContent.indexOf(",", tmpPrevIndex);
448
449 // The next field is the CPU, in hexadecimal format
450 // Should be like :
451 // 0x0,
452 tmpPrevIndex = tmpCurIndex+1;
453 tmpCurIndex = tmpContent.indexOf("0x", tmpPrevIndex);
454 tmpPrevIndex = tmpCurIndex+2;
455
456 tmpCurIndex = tmpContent.indexOf(",", tmpPrevIndex);
457 tmpCpu = Long.parseLong( tmpContent.substring(tmpPrevIndex, tmpCurIndex ).trim() );
458
459 // Set the cpu number of trace if we found a "new" cpu
460 if ( cpuNumber < (tmpCpu + 1) ) {
461 cpuNumber = (int)(tmpCpu+1);
462 }
463 /*System.out.println(tmpCpu);*/
464
465
466 // The last field is the parsed content
467 // It is enclosed by { }
468 // Look like :
469 // SYSCALL { ip = 0xb7f05422, syscall_id = 221 [sys_fcntl64+0x0/0x79] }
470 //
471 // NOTE : it seems some state system events do not respect this format as they have no payload.
472 // We will create empty payload then.
473 int tmpIndex = tmpContent.indexOf("{", tmpPrevIndex);
474 if ( tmpIndex != -1 ) {
475 tmpPrevIndex = tmpCurIndex+1;
476 tmpCurIndex = tmpIndex;
477 tmpPrevIndex = tmpCurIndex+1;
478 tmpCurIndex = tmpContent.indexOf("}", tmpPrevIndex);
479 parsedPayload = tmpContent.substring(tmpPrevIndex, tmpCurIndex ).trim();
480
481 // Now add each LttngField
482 boolean isDone = false;
483 int tmpIndexBegin = 0;
484 int tmpIndexEqual = 0;
485 int tmpIndexEnd = 0;
486
487 fieldsMap = new HashMap<String, LttngEventField>();
488
489 while ( isDone == false ) {
490 tmpIndexEqual = parsedPayload.indexOf("=", (int)tmpIndexBegin);
491 tmpIndexEnd = parsedPayload.indexOf(", ", (int)tmpIndexEqual);
492 if ( tmpIndexEnd == -1 ) {
493 tmpIndexEnd = parsedPayload.length();
494 isDone = true;
495 }
496
497 markerName = parsedPayload.substring((int)tmpIndexBegin, (int)tmpIndexEqual-1 ).trim();
498 payload = ((String)parsedPayload.substring((int)tmpIndexEqual+1, (int)tmpIndexEnd )).replace("\"", " ").trim();
499
500 // Try to cast the payload into the correct type
501 try {
502 payload = Long.parseLong((String)payload);
503 }
504 catch (NumberFormatException e) { }
505
506 LttngEventField tmpField = new LttngEventField(eventContent, markerName, payload);
507 fieldsMap.put(markerName, tmpField);
508
509 tmpIndexBegin = tmpIndexEnd+1;
510 }
511 }
512 else {
513 fieldsMap = new HashMap<String, LttngEventField>();
514
515 markerName = "";
516 payload = "";
517
518 LttngEventField tmpField = new LttngEventField(eventContent, markerName, payload);
519 fieldsMap.put(markerName, tmpField);
520 }
521
522 eventContent = new TextLttngEventContent(currentLttngEvent, fieldsMap);
523
524 // We now have what we need for the type
525 String tmpTypeKey = tracefile + "/" + tmpCpu + "/" + marker;
526 if ( traceTypes.get(tmpTypeKey) == null ) {
527 traceTypes.put(tmpTypeKey, new LttngEventType(tracefile, tmpCpu, marker, fieldsMap.keySet().toArray(new String[fieldsMap.size()] )) );
528 }
529
530 currentLttngEvent.setContent(eventContent);
531 currentLttngEvent.setType(traceTypes.get(tmpTypeKey));
532
88144d4a
ASL
533 context.setTimestamp(eventTimestamp);
534 context.setLocation(nbCharRead);
535
5d10d135
ASL
536 returnedEvent = currentLttngEvent;
537 }
538 else if ( showDebug == true ) {
539 System.out.println("NULL READING");
540 System.out.println();
541 returnedEvent = null;
542 }
543 }
544 catch (Exception e) {
545 System.out.println("Pos is :" + nbCharRead);
546 if ( tmpContent != null ) {
547 System.out.println("Erroneous content is :" + tmpContent);
548 }
549
550 tmpContent = null;
551 e.printStackTrace();
552 returnedEvent = null;
553 }
554
555 return returnedEvent;
556 }
557
558 @Override
88144d4a
ASL
559 public Object getCurrentLocation() {
560 return nbCharRead;
5d10d135
ASL
561 }
562
88144d4a
ASL
563 @Override
564 public LttngEvent parseEvent(TmfTraceContext context) {
565 Long location = null;
566 LttngEvent returnedEvent = null;
567
568 if ( (currentLttngEvent!= null) && (! currentLttngEvent.getTimestamp().equals(context.getTimestamp()) ) ) {
569 seekEvent(context.getTimestamp());
570 getNextEvent(context);
571 }
572
573 if ( currentLttngEvent != null ) {
574 returnedEvent = currentLttngEvent;
575 }
5d10d135 576
88144d4a
ASL
577 location = (Long)getCurrentLocation();
578
579 context.setLocation(location);
580 context.setTimestamp(currentLttngEvent.getTimestamp());
581 context.incrIndex();
582
583 return returnedEvent;
5d10d135
ASL
584 }
585
88144d4a 586 public int getCpuNumber() {
5d10d135
ASL
587 return cpuNumber;
588 }
589}
590
591
592// Redefine event to override method we know won't work with a Text tracefile
593class TextLttngEvent extends LttngEvent {
594
88144d4a 595 public TextLttngEvent( LttngTimestamp timestamp,
5d10d135
ASL
596 LttngEventSource source,
597 LttngEventType type,
598 LttngEventContent content,
599 LttngEventReference reference)
600 {
88144d4a 601 super(timestamp, source, type, content, reference, null);
5d10d135
ASL
602 }
603
604 public TextLttngEvent(TextLttngEvent oldEvent) {
605 this(
5d10d135
ASL
606 (LttngTimestamp)oldEvent.getTimestamp(),
607 (LttngEventSource)oldEvent.getSource(),
608 (LttngEventType)oldEvent.getType(),
609 (LttngEventContent)oldEvent.getContent(),
610 (LttngEventReference)oldEvent.getReference()
611 );
612 }
613
614 @Override
615 public JniEvent convertEventTmfToJni() {
616 System.out.println("WARNING : Cannot use convertEventTmfToJni() on a trace in text format.");
617 return null;
618 }
619
620 @Override
621 public void updateJniEventReference(JniEvent newJniEventReference) {
622 System.out.println("WARNING : Cannot use updateJniEventReference on a trace in text format. Using null.");
623 }
624}
625
626
627class TextLttngEventContent extends LttngEventContent {
628
629 public TextLttngEventContent() {
630 super();
631 }
632
633 public TextLttngEventContent(TextLttngEvent thisParent) {
634 super(thisParent, null);
635 }
636
637 public TextLttngEventContent(TextLttngEvent thisParent, HashMap<String, LttngEventField> thisContent) {
638 super(thisParent, thisContent);
639 }
640
641 public TextLttngEventContent(TextLttngEventContent oldContent) {
642 this( (TextLttngEvent)oldContent.fParentEvent, oldContent.getRawContent());
643 }
644
645 @Override
646 public LttngEventField[] getFields() {
647 return getRawContent().values().toArray(new LttngEventField[getRawContent().size()]);
648 }
649
650 @Override
651 public LttngEventField getField(String name) {
652 LttngEventField returnedField = getRawContent().get(name);
653
654 return returnedField;
655 }
656
657 @Override
658 public LttngEventField getField(int position) {
659 LttngEventField returnedField = null;
88144d4a
ASL
660 String label = fParentEvent.getType().getLabel(position);
661
662 if ( label != null ) {
663 returnedField = this.getField(label);
664 }
5d10d135
ASL
665
666 return returnedField;
667 }
88144d4a 668}
This page took 0.05196 seconds and 5 git commands to generate.