~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfEventParserStub.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-13 21:43:22 UTC
  • mfrom: (1.2.1) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130513214322-6frgd9du1n0w2uo7
Tags: 1.2.1-1
* Team upload.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*******************************************************************************
2
2
 * Copyright (c) 2009 Ericsson
3
 
 * 
 
3
 *
4
4
 * All rights reserved. This program and the accompanying materials are
5
5
 * made available under the terms of the Eclipse Public License v1.0 which
6
6
 * accompanies this distribution, and is available at
7
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 
 * 
 
8
 *
9
9
 * Contributors:
10
10
 *   Francois Chouinard - Initial API and implementation
11
11
 *******************************************************************************/
32
32
 * <p>
33
33
 * TODO: Implement me. Please.
34
34
 */
35
 
@SuppressWarnings("nls")
 
35
@SuppressWarnings({"nls","javadoc"})
36
36
public class TmfEventParserStub implements ITmfEventParser<TmfEvent> {
37
37
 
38
38
    // ------------------------------------------------------------------------
68
68
 
69
69
    static final String typePrefix = "Type-";
70
70
    @Override
71
 
    @SuppressWarnings("unchecked")
72
71
    public TmfEvent parseEvent(final ITmfContext context) {
73
72
 
74
 
        if (! (fEventStream instanceof TmfTraceStub))
 
73
        if (! (fEventStream instanceof TmfTraceStub)) {
75
74
            return null;
 
75
        }
76
76
 
77
77
        // Highly inefficient...
78
78
        final RandomAccessFile stream = ((TmfTraceStub) fEventStream).getStream();
93
93
                final Integer reference  = stream.readInt();
94
94
                final int typeIndex  = Integer.parseInt(type.substring(typePrefix.length()));
95
95
                final String[] fields = new String[typeIndex];
96
 
                for (int i = 0; i < typeIndex; i++)
 
96
                for (int i = 0; i < typeIndex; i++) {
97
97
                    fields[i] = stream.readUTF();
 
98
                }
98
99
 
99
100
                final StringBuffer content = new StringBuffer("[");
100
 
                if (typeIndex > 0)
 
101
                if (typeIndex > 0) {
101
102
                    content.append(fields[0]);
102
 
                for (int i = 1; i < typeIndex; i++)
 
103
                }
 
104
                for (int i = 1; i < typeIndex; i++) {
103
105
                    content.append(", ").append(fields[i]);
 
106
                }
104
107
                content.append("]");
105
108
 
106
109
                final TmfEventField root = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content.toString());