Renamed the bundle class.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.tests / stubs / org / eclipse / linuxtools / tmf / eventlog / TmfEventParserStub.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 * Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.eventlog;
14
15 import java.io.EOFException;
16 import java.io.IOException;
17
18 import org.eclipse.linuxtools.tmf.event.TmfEvent;
19 import org.eclipse.linuxtools.tmf.event.TmfEventContent;
20 import org.eclipse.linuxtools.tmf.event.TmfEventFormat;
21 import org.eclipse.linuxtools.tmf.event.TmfEventReference;
22 import org.eclipse.linuxtools.tmf.event.TmfEventSource;
23 import org.eclipse.linuxtools.tmf.event.TmfEventType;
24 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
25
26 /**
27 * <b><u>TmfEventParserStub</u></b>
28 * <p>
29 * TODO: Implement me. Please.
30 */
31 public class TmfEventParserStub implements ITmfEventParser {
32
33 // ========================================================================
34 // Attributes
35 // ========================================================================
36
37 private final TmfEventFormat[] fFormats;
38
39 // ========================================================================
40 // Constructors
41 // ========================================================================
42
43 public TmfEventParserStub() {
44 fFormats = new TmfEventFormat[] {
45 new TmfEventFormat(new String[] { "Fmt1-Fld-1" }),
46 new TmfEventFormat(new String[] { "Fmt2-Fld-1", "Fmt2-Fld-2" }),
47 new TmfEventFormat(new String[] { "Fmt3-Fld-1", "Fmt3-Fld-2", "Fmt3-Fld-3" }),
48 new TmfEventFormat(new String[] { "Fmt4-Fld-1", "Fmt4-Fld-2", "Fmt4-Fld-3", "Fmt4-Fld-4" }),
49 new TmfEventFormat(new String[] { "Fmt5-Fld-1", "Fmt5-Fld-2", "Fmt5-Fld-3", "Fmt5-Fld-4", "Fmt5-Fld-5" }),
50 };
51 }
52
53 // ========================================================================
54 // Accessors
55 // ========================================================================
56
57 // ========================================================================
58 // Operators
59 // ========================================================================
60
61 /* (non-Javadoc)
62 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
63 */
64 static final String typePrefix = "Type-";
65 public TmfEvent getNextEvent(TmfEventStream stream) throws IOException {
66 try {
67 long ts = stream.readLong();
68 String source = stream.readUTF();
69 String type = stream.readUTF();
70 int reference = stream.readInt();
71 int typeIndex = Integer.parseInt(type.substring(typePrefix.length()));
72 String[] content = new String[typeIndex];
73 for (int i = 0; i < typeIndex; i ++) {
74 content[i] = stream.readUTF();
75 }
76 TmfEvent event = new TmfEvent(
77 new TmfTimestamp(ts, (byte) 0, 0),
78 new TmfEventSource(source),
79 new TmfEventType(type, fFormats[typeIndex]),
80 new TmfEventContent(content, fFormats[typeIndex]),
81 new TmfEventReference(reference));
82 return event;
83 } catch (EOFException e) {
84 }
85 return null;
86 }
87
88 }
This page took 0.035145 seconds and 5 git commands to generate.