325050b15fa742239e6d55a7e768bfa6ea5e583c
1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
10 * Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.eventlog
;
15 import java
.io
.EOFException
;
16 import java
.io
.IOException
;
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
;
27 * <b><u>TmfEventParserStub</u></b>
29 * TODO: Implement me. Please.
31 public class TmfEventParserStub
implements ITmfEventParser
{
33 // ========================================================================
35 // ========================================================================
37 private final TmfEventFormat
[] fFormats
;
39 // ========================================================================
41 // ========================================================================
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" }),
53 // ========================================================================
55 // ========================================================================
57 // ========================================================================
59 // ========================================================================
62 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
64 static final String typePrefix
= "Type-";
65 public TmfEvent
getNextEvent(TmfEventStream stream
) throws IOException
{
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();
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
));
83 } catch (EOFException e
) {
This page took 0.031373 seconds and 4 git commands to generate.