Refactor TmfTrace and dependencies - move parseEvent to ITmfEventParser
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui.tests / stubs / org / eclipse / linuxtools / internal / lttng / stubs / LTTngEventParserStub.java
CommitLineData
6040f86c
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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
2e5e79d5 13package org.eclipse.linuxtools.internal.lttng.stubs;
6040f86c
ASL
14
15import java.io.IOException;
16
5945cec9 17import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
72f1e62a 18import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
a1440d1f 19import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
7e6347b0 20import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
6040f86c
ASL
21
22/**
23 * <b><u>TmfEventParserStub</u></b>
24 * <p>
25 * TODO: Implement me. Please.
26 */
72f1e62a 27public class LTTngEventParserStub implements ITmfEventParser<LttngEvent> {
6040f86c 28
72f1e62a
FC
29 /* (non-Javadoc)
30 * @see org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser#parseNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfTrace, org.eclipse.linuxtools.tmf.core.trace.TmfContext)
31 */
32 @Override
7e6347b0 33 public ITmfEvent parseEvent(ITmfContext context) {
72f1e62a
FC
34 // TODO Auto-generated method stub
35 return null;
36 }
6040f86c
ASL
37
38// // ========================================================================
39// // Attributes
40// // ========================================================================
41//
42// private final int NB_FORMATS = 10;
43// private final TmfEventFormat[] fFormats;
44//
45// // ========================================================================
46// // Constructors
47// // ========================================================================
48//
49// public LTTngEventParserStub() {
50// fFormats = new TmfEventFormat[NB_FORMATS];
51// for (int i = 0; i < NB_FORMATS; i++) {
52// Vector<String> format = new Vector<String>();
53// for (int j = 1; j <= i; j++) {
54// format.add(new String("Fmt-" + i + "-Fld-" + j));
55// }
56// String[] fields = new String[i];
57// fFormats[i] = new TmfEventFormat(format.toArray(fields));
58// }
59// }
60//
61// // ========================================================================
62// // Accessors
63// // ========================================================================
64//
65// // ========================================================================
66// // Operators
67// // ========================================================================
68//
69// /* (non-Javadoc)
70// * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
71// */
72// static final String typePrefix = "Type-";
73// public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfTraceContext context) throws IOException {
74//
75// if (! (eventStream instanceof LTTngTraceStub)) {
76// return null;
77// }
78//
79// // Highly inefficient...
80// RandomAccessFile stream = ((LTTngTraceStub) eventStream).getStream();
81// String name = eventStream.getName();
82// name = name.substring(name.lastIndexOf('/') + 1);
83//
84// synchronized(stream) {
85// long location = 0;
86// if (context != null)
87// location = (Long) (context.getLocation());
88// stream.seek(location);
89//
90// try {
91// // Read the individual fields
92// long ts = stream.readLong();
93// String source = stream.readUTF();
94// String type = stream.readUTF();
95// @SuppressWarnings("unused")
96// int reference = stream.readInt();
97//
98// // Read the event parts
99// int typeIndex = Integer.parseInt(type.substring(typePrefix.length()));
100// String[] fields = new String[typeIndex];
101// for (int i = 0; i < typeIndex; i++) {
102// fields[i] = stream.readUTF();
103// }
104//
105// // Format the content from the individual fields
106// String content = "[";
107// if (typeIndex > 0) {
108// content += fields[0];
109// }
110// for (int i = 1; i < typeIndex; i++) {
111// content += ", " + fields[i];
112// }
113// content += "]";
114//
115// // Update the context
116// context.setLocation(stream.getFilePointer());
117// context.incrIndex();
118// try {
119// long ts2 = stream.readLong();
120// context.setTimestamp(new LTTngTimestampStub(ts2));
121// } catch (EOFException e) {
122// context.setTimestamp(null);
123// }
124//
125// // Create the event
126// TmfEvent event = new TmfEvent(
127// new LTTngTimestampStub(ts),
128// new TmfEventSource(source),
129// new TmfEventType(type, fFormats[typeIndex]),
130// new TmfEventContent(content, fFormats[typeIndex]),
131// new TmfEventReference(name));
132//
133// return event;
134//
135// } catch (EOFException e) {
136// context.setTimestamp(null);
137// }
138// }
139// return null;
140// }
141
142}
This page took 0.033696 seconds and 5 git commands to generate.