* <p>
* TODO: Implement me. Please.
*/
+@SuppressWarnings("nls")
public class TmfEventParserStub implements ITmfEventParser {
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
static final String typePrefix = "Type-";
- @SuppressWarnings("unchecked")
+ @Override
+ @SuppressWarnings("unchecked")
public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfContext context) throws IOException {
if (! (eventStream instanceof TmfTraceStub)) {
String name = eventStream.getName();
name = name.substring(name.lastIndexOf('/') + 1);
- synchronized(stream) {
- long location = 0;
- if (context != null)
- location = ((TmfLocation<Long>) (context.getLocation())).getValue();
- stream.seek(location);
-
- try {
- long ts = stream.readLong();
- String source = stream.readUTF();
- String type = stream.readUTF();
- @SuppressWarnings("unused")
- int reference = stream.readInt();
- int typeIndex = Integer.parseInt(type.substring(typePrefix.length()));
- String[] fields = new String[typeIndex];
- for (int i = 0; i < typeIndex; i++) {
- fields[i] = stream.readUTF();
- }
-
- String content = "[";
- if (typeIndex > 0) {
- content += fields[0];
- }
- for (int i = 1; i < typeIndex; i++) {
- content += ", " + fields[i];
- }
- content += "]";
-
- TmfEvent event = new TmfEvent(
- new TmfTimestamp(ts, (byte) -3, 0), // millisecs
- new TmfEventSource(source),
- fTypes[typeIndex],
- new TmfEventReference(name));
- TmfEventContent cnt = new TmfEventContent(event, content);
- event.setContent(cnt);
- return event;
- } catch (EOFException e) {
- }
- }
+ // no need to use synchronized since it's already cover by the calling method
+
+ long location = 0;
+ if (context != null)
+ location = ((TmfLocation<Long>) (context.getLocation())).getLocation();
+ stream.seek(location);
+
+ try {
+ long ts = stream.readLong();
+ String source = stream.readUTF();
+ String type = stream.readUTF();
+ @SuppressWarnings("unused")
+ int reference = stream.readInt();
+ int typeIndex = Integer.parseInt(type.substring(typePrefix.length()));
+ String[] fields = new String[typeIndex];
+ for (int i = 0; i < typeIndex; i++) {
+ fields[i] = stream.readUTF();
+ }
+
+ String content = "[";
+ if (typeIndex > 0) {
+ content += fields[0];
+ }
+ for (int i = 1; i < typeIndex; i++) {
+ content += ", " + fields[i];
+ }
+ content += "]";
+
+ TmfEvent event = new TmfEvent(
+ new TmfTimestamp(ts, (byte) -3, 0), // millisecs
+ new TmfEventSource(source),
+ fTypes[typeIndex],
+ new TmfEventReference(name));
+ TmfEventContent cnt = new TmfEventContent(event, content);
+ event.setContent(cnt);
+ return event;
+ } catch (EOFException e) {
+ }
return null;
}