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 - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.trace
;
15 import java
.io
.EOFException
;
16 import java
.io
.IOException
;
17 import java
.io
.RandomAccessFile
;
18 import java
.util
.Vector
;
20 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
21 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEventContent
;
22 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEventFormat
;
23 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEventReference
;
24 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEventSource
;
25 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEventType
;
26 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimestamp
;
29 * <b><u>TmfEventParserStub</u></b>
31 * TODO: Implement me. Please.
33 public class TmfEventParserStub
implements ITmfEventParser
{
35 // ========================================================================
37 // ========================================================================
39 private final int NB_FORMATS
= 10;
40 private final TmfEventFormat
[] fFormats
;
42 // ========================================================================
44 // ========================================================================
46 public TmfEventParserStub() {
47 fFormats
= new TmfEventFormat
[NB_FORMATS
];
48 for (int i
= 0; i
< NB_FORMATS
; i
++) {
49 Vector
<String
> format
= new Vector
<String
>();
50 for (int j
= 1; j
<= i
; j
++) {
51 format
.add(new String("Fmt-" + i
+ "-Fld-" + j
));
53 String
[] fields
= new String
[i
];
54 fFormats
[i
] = new TmfEventFormat(format
.toArray(fields
));
58 // ========================================================================
60 // ========================================================================
63 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
65 static final String typePrefix
= "Type-";
66 public TmfEvent
getNextEvent(ITmfTrace eventStream
) throws IOException
{
68 if (! (eventStream
instanceof TmfEventStreamStub
)) {
72 RandomAccessFile stream
= ((TmfEventStreamStub
) eventStream
).getStream();
75 long ts
= stream
.readLong();
76 String source
= stream
.readUTF();
77 String type
= stream
.readUTF();
78 int reference
= stream
.readInt();
79 int typeIndex
= Integer
.parseInt(type
.substring(typePrefix
.length()));
80 String
[] fields
= new String
[typeIndex
];
81 for (int i
= 0; i
< typeIndex
; i
++) {
82 fields
[i
] = stream
.readUTF();
85 for (int i
= 0; i
< typeIndex
- 1; i
++) {
86 content
+= fields
[i
] + ", ";
90 TmfEvent event
= new TmfEvent(
91 new TmfTimestamp(ts
, (byte) -3, 0), // millisecs
92 new TmfEventSource(source
),
93 new TmfEventType(type
, fFormats
[typeIndex
]),
94 new TmfEventContent(content
, fFormats
[typeIndex
]),
95 new TmfEventReference(reference
));
97 } catch (EOFException e
) {
This page took 0.034121 seconds and 6 git commands to generate.