Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 151267 Details for
Bug 287562
[TMF] Update the Event Model code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
TMF Event Update + JUnits
org.eclipse.linuxtools.tmf.patch (text/plain), 34.14 KB, created by
Francois Chouinard
on 2009-11-04 00:23:53 EST
(
hide
)
Description:
TMF Event Update + JUnits
Filename:
MIME Type:
Creator:
Francois Chouinard
Created:
2009-11-04 00:23:53 EST
Size:
34.14 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.linuxtools.tmf.ui >Index: src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java (working copy) >@@ -215,7 +215,7 @@ > event.getSource().getSourceId().toString(), > event.getType().getTypeId().toString(), > event.getReference().getValue().toString(), >- event.getContent().getContent() >+ event.getContent().toString() > }; > } > return fields; >@@ -292,4 +292,4 @@ > } > } > >-} >\ No newline at end of file >+} >#P org.eclipse.linuxtools.tmf.tests >Index: stubs/org/eclipse/linuxtools/tmf/event/TmfEventContentStub.java >=================================================================== >--- stubs/org/eclipse/linuxtools/tmf/event/TmfEventContentStub.java (revision 23558) >+++ stubs/org/eclipse/linuxtools/tmf/event/TmfEventContentStub.java (working copy) >@@ -12,6 +12,9 @@ > > package org.eclipse.linuxtools.tmf.event; > >+import java.util.HashMap; >+import java.util.Map; >+ > /** > * <b><u>TmfEventFormatStub</u></b> > * <p> >@@ -17,7 +20,7 @@ > * <p> > * TODO: Implement me. Please. > */ >-public class TmfEventFormatStub extends TmfEventFormat { >+public class TmfEventContentStub extends TmfEventContent { > > // ======================================================================== > // Attributes >@@ -23,17 +26,23 @@ > // Attributes > // ======================================================================== > >- // ======================================================================== >+ private static final String fTypeId = "typeId"; >+ private static final String[] fLabels = new String[] { "label1", "label2", "label3", "label4", "label5" }; >+ private static final TmfEventType fType = new TmfEventType(fTypeId, fLabels); >+ >+ private static final String[] fFields = new String[] { "Field1", "Field2", "Field3", "Field4", "Field5" }; >+ >+ // ======================================================================== > // Constructors > // ======================================================================== > >- public TmfEventFormatStub() { >- super(new String[] { "Field1", "Field2", "Field3", "Field4", "Field5" }); >+ public TmfEventContentStub() { >+ super(fType, fFields); > } > >- // ======================================================================== >- // Accessors >- // ======================================================================== >+ public TmfEventContentStub(TmfEventType type, Object content) { >+ super(type, content); >+ } > > // ======================================================================== > // Operators >@@ -39,17 +48,14 @@ > // Operators > // ======================================================================== > >- /* (non-Javadoc) >- * @see org.eclipse.linuxtools.tmf.event.TmfEventFormat#parse(java.lang.Object) >- */ >- @Override >- public TmfEventField[] parse(Object content) { >- TmfEventField field1 = new TmfEventField(1); >- TmfEventField field2 = new TmfEventField(-10); >- TmfEventField field3 = new TmfEventField(true); >- TmfEventField field4 = new TmfEventField("some string"); >- TmfEventField field5 = new TmfEventField(new TmfTimestamp(1, (byte) 2, 3)); >- return new TmfEventField[] { field1, field2, field3, field4, field5 }; >+ @Override >+ public Map<String, TmfEventField> parseContent() { >+ Map<String, TmfEventField> fields = new HashMap<String, TmfEventField>(); >+ for (int i = 0; i < fLabels.length; i++) { >+ TmfEventField field = new TmfEventField(this, fLabels[i], fFields[i]); >+ fields.put(fLabels[i], field); >+ } >+ return fields; > } > > // ======================================================================== >@@ -56,4 +62,4 @@ > // Helper functions > // ======================================================================== > >-} >+} >\ No newline at end of file >Index: stubs/org/eclipse/linuxtools/tmf/event/TmfEventFormatStub.java >=================================================================== >--- stubs/org/eclipse/linuxtools/tmf/event/TmfEventFormatStub.java (revision 23558) >+++ stubs/org/eclipse/linuxtools/tmf/event/TmfEventFormatStub.java (working copy) >@@ -1,59 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2009 Ericsson >- * >- * All rights reserved. This program and the accompanying materials are >- * made available under the terms of the Eclipse Public License v1.0 which >- * accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Francois Chouinard - Initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.linuxtools.tmf.event; >- >-/** >- * <b><u>TmfEventFormatStub</u></b> >- * <p> >- * TODO: Implement me. Please. >- */ >-public class TmfEventFormatStub extends TmfEventFormat { >- >- // ======================================================================== >- // Attributes >- // ======================================================================== >- >- // ======================================================================== >- // Constructors >- // ======================================================================== >- >- public TmfEventFormatStub() { >- super(new String[] { "Field1", "Field2", "Field3", "Field4", "Field5" }); >- } >- >- // ======================================================================== >- // Accessors >- // ======================================================================== >- >- // ======================================================================== >- // Operators >- // ======================================================================== >- >- /* (non-Javadoc) >- * @see org.eclipse.linuxtools.tmf.event.TmfEventFormat#parse(java.lang.Object) >- */ >- @Override >- public TmfEventField[] parse(Object content) { >- TmfEventField field1 = new TmfEventField(1); >- TmfEventField field2 = new TmfEventField(-10); >- TmfEventField field3 = new TmfEventField(true); >- TmfEventField field4 = new TmfEventField("some string"); >- TmfEventField field5 = new TmfEventField(new TmfTimestamp(1, (byte) 2, 3)); >- return new TmfEventField[] { field1, field2, field3, field4, field5 }; >- } >- >- // ======================================================================== >- // Helper functions >- // ======================================================================== >- >-} >Index: stubs/org/eclipse/linuxtools/tmf/trace/TmfEventParserStub.java >=================================================================== >--- stubs/org/eclipse/linuxtools/tmf/trace/TmfEventParserStub.java (revision 23558) >+++ stubs/org/eclipse/linuxtools/tmf/trace/TmfEventParserStub.java (working copy) >@@ -15,11 +15,9 @@ > import java.io.EOFException; > import java.io.IOException; > import java.io.RandomAccessFile; >-import java.util.Vector; > > import org.eclipse.linuxtools.tmf.event.TmfEvent; >-import org.eclipse.linuxtools.tmf.event.TmfEventContent; >-import org.eclipse.linuxtools.tmf.event.TmfEventFormat; >+import org.eclipse.linuxtools.tmf.event.TmfEventContentStub; > import org.eclipse.linuxtools.tmf.event.TmfEventReference; > import org.eclipse.linuxtools.tmf.event.TmfEventSource; > import org.eclipse.linuxtools.tmf.event.TmfEventType; >@@ -36,8 +34,8 @@ > // Attributes > // ======================================================================== > >- private final int NB_FORMATS = 10; >- private final TmfEventFormat[] fFormats; >+ private final int NB_TYPES = 10; >+ private final String[][] fFormats; > > // ======================================================================== > // Constructors >@@ -44,14 +42,12 @@ > // ======================================================================== > > public TmfEventParserStub() { >- fFormats = new TmfEventFormat[NB_FORMATS]; >- for (int i = 0; i < NB_FORMATS; i++) { >- Vector<String> format = new Vector<String>(); >+ fFormats = new String[NB_TYPES][]; >+ for (int i = 0; i < NB_TYPES; i++) { >+ fFormats[i] = new String[i]; > for (int j = 1; j <= i; j++) { >- format.add(new String("Fmt-" + i + "-Fld-" + j)); >+ fFormats[i][j] = "Fmt-" + i + "-Fld-" + j; > } >- String[] fields = new String[i]; >- fFormats[i] = new TmfEventFormat(format.toArray(fields)); > } > } > >@@ -105,11 +101,14 @@ > } > content += "]"; > >+ String[] labels = fFormats[typeIndex]; >+ TmfEventType eventType = new TmfEventType(type, labels); >+ > TmfEvent event = new TmfEvent( > new TmfTimestamp(ts, (byte) -3, 0), // millisecs > new TmfEventSource(source), >- new TmfEventType(type, fFormats[typeIndex]), >- new TmfEventContent(content, fFormats[typeIndex]), >+ eventType, >+ new TmfEventContentStub(eventType, labels), > new TmfEventReference(name)); > return event; > } catch (EOFException e) { >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java (working copy) >@@ -31,7 +31,6 @@ > public void testEmptyConstructor() { > TmfEventType type = new TmfEventType("", null); > assertEquals("getValue", "", type.getTypeId()); >- assertEquals("getFormat", null, type.getFormat()); > } > > @Test >@@ -36,10 +35,10 @@ > > @Test > public void testNormalConstructor() { >- TmfEventType type = new TmfEventType("Type", new TmfEventFormat(new String[] { "field1", "field2" })); >+ TmfEventType type = new TmfEventType("Type", new String[] { "field1", "field2" }); > assertEquals("getValue", "Type", type.getTypeId()); >- assertEquals("getFormat", "field1", type.getFormat().getLabels()[0]); >- assertEquals("getFormat", "field2", type.getFormat().getLabels()[1]); >+ assertEquals("getFormat", "field1", type.getLabels()[0]); >+ assertEquals("getFormat", "field2", type.getLabels()[1]); > } > > } >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java (working copy) >@@ -1,87 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2009 Ericsson >- * >- * All rights reserved. This program and the accompanying materials are >- * made available under the terms of the Eclipse Public License v1.0 which >- * accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Francois Chouinard - Initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.linuxtools.tmf.event; >- >-import static org.junit.Assert.assertEquals; >- >-import org.junit.Test; >- >-/** >- * <b><u>TmfEventFormatTest</u></b> >- * <p> >- * JUnit test suite for the TmfEventFormat class. >- */ >-public class TmfEventFormatTest { >- >- // ======================================================================== >- // Constructors >- // ======================================================================== >- >- @Test >- public void testBasicTmfEventFormat() { >- TmfEventFormat format = new TmfEventFormat(); >- assertEquals("getLabels", 1, format.getLabels().length); >- assertEquals("getValue", "Content", format.getLabels()[0]); >- } >- >- @Test >- public void testEmptyConstructor() { >- TmfEventFormat format = new TmfEventFormat(new String[] {}); >- assertEquals("getLabels", 0, format.getLabels().length); >- } >- >- @Test >- public void testNormalConstructor() { >- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2", "field3" }); >- assertEquals("getLabels", 3, format.getLabels().length); >- assertEquals("getLabels", "field1", format.getLabels()[0]); >- assertEquals("getLabels", "field2", format.getLabels()[1]); >- assertEquals("getLabels", "field3", format.getLabels()[2]); >- } >- >- @Test >- public void testExtendedConstructor() { >- TmfEventFormatStub format = new TmfEventFormatStub(); >- assertEquals("getLabels", 5, format.getLabels().length); >- assertEquals("getLabels", "Field1", format.getLabels()[0]); >- assertEquals("getLabels", "Field2", format.getLabels()[1]); >- assertEquals("getLabels", "Field3", format.getLabels()[2]); >- assertEquals("getLabels", "Field4", format.getLabels()[3]); >- assertEquals("getLabels", "Field5", format.getLabels()[4]); >- } >- >- // ======================================================================== >- // parse >- // ======================================================================== >- >- @Test >- public void testBasicParse() { >- TmfEventFormat format = new TmfEventFormat(); >- TmfEventField[] content = format.parse(new TmfTimestamp()); >- assertEquals("length", 1, content.length); >- assertEquals("getValue", "[TmfTimestamp:0,0,0]", content[0].toString()); >- } >- >- @Test >- public void testExtendedParse() { >- TmfEventFormatStub format = new TmfEventFormatStub(); >- TmfEventField[] content = format.parse(new TmfTimestamp()); >- assertEquals("length", 5, content.length); >- assertEquals("getValue", "1", content[0].toString()); >- assertEquals("getValue", "-10", content[1].toString()); >- assertEquals("getValue", "true", content[2].toString()); >- assertEquals("getValue", "some string", content[3].toString()); >- assertEquals("getValue", "[TmfTimestamp:1,2,3]", content[4].toString()); >- } >- >-} >Index: src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java (working copy) >@@ -29,11 +29,14 @@ > > @Test > public void testTmfTraceEvent() throws Exception { >- TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5); >+ >+ String[] labels = new String[] { "label1", "label2" }; >+ String[] fields = new String[] { "field1", "field2" }; >+ >+ TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5); > TmfEventSource source = new TmfEventSource("Source"); >- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" }); >- TmfEventType type = new TmfEventType("Type", format); >- TmfEventContent content = new TmfEventContent("Some content", format); >+ TmfEventType type = new TmfEventType("Type", labels); >+ TmfEventContent content = new TmfEventContentStub(type, fields); > TmfEventReference reference = new TmfEventReference("Reference"); > > // Create the trace event >@@ -53,13 +56,13 @@ > // Check the event type > TmfEventType evType = event.getType(); > assertEquals("getValue", "Type", evType.getTypeId()); >- assertEquals("getFormat", "field1", evType.getFormat().getLabels()[0]); >- assertEquals("getFormat", "field2", evType.getFormat().getLabels()[1]); >+ assertEquals("getFormat", "label1", evType.getLabels()[0]); >+ assertEquals("getFormat", "label2", evType.getLabels()[1]); > > // Check the event content > TmfEventContent evContent = event.getContent(); >- assertEquals("getField", 1, evContent.getFields().length); >- assertEquals("getField", "Some content", evContent.getField(0).toString()); >+ assertEquals("getField", 2, evContent.getFields().length); >+ assertEquals("getField", "[field:label1,value:Field1]", evContent.getField(evType.getLabels()[0]).toString()); > > // Check the event reference > TmfEventReference evRef = event.getReference(); >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java (working copy) >@@ -29,10 +29,12 @@ > > @Test > public void testTmfEventContent() { >- TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat()); >- assertEquals("getFormat", 1, content.getFormat().getLabels().length); >- assertEquals("getLabels", "Content", content.getFormat().getLabels()[0]); >- assertEquals("getContent", "Some content", content.getContent()); >+ TmfEventContent content = new TmfEventContentStub(); >+ assertEquals("getType", "typeId", content.getType().getTypeId()); >+ if (content.getContent() instanceof String) { >+ String value = (String) content.getContent(); >+ assertEquals("getContent", "Some content", value); >+ } > } > > // ======================================================================== >@@ -40,21 +42,14 @@ > // ======================================================================== > > @Test >- public void testBasicGetField() { >- TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat()); >- assertEquals("getField", 1, content.getFields().length); >- assertEquals("getField", "Some content", content.getField(0).toString()); >- } >- >- @Test >- public void testExtendedGetField() { >- TmfEventContent content = new TmfEventContent("", new TmfEventFormatStub()); >+ public void testGetField() { >+ TmfEventContent content = new TmfEventContentStub(); > assertEquals("getField", 5, content.getFields().length); >- assertEquals("getField", "1", content.getField(0).toString()); >- assertEquals("getField", "-10", content.getField(1).toString()); >- assertEquals("getField", "true", content.getField(2).toString()); >- assertEquals("getField", "some string", content.getField(3).toString()); >- assertEquals("getField", "[TmfTimestamp:1,2,3]", content.getField(4).toString()); >+ assertEquals("getField", "[field:label1,value:Field1]", content.getField("label1").toString()); >+ assertEquals("getField", "[field:label2,value:Field2]", content.getField("label2").toString()); >+ assertEquals("getField", "[field:label3,value:Field3]", content.getField("label3").toString()); >+ assertEquals("getField", "[field:label4,value:Field4]", content.getField("label4").toString()); >+ assertEquals("getField", "[field:label5,value:Field5]", content.getField("label5").toString()); > } > >-} >+} >\ No newline at end of file >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventTest.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventTest.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventTest.java (working copy) >@@ -29,11 +29,14 @@ > > @Test > public void testTmfEvent() { >+ >+ String[] labels = new String[] { "label1", "label2" }; >+ String[] fields = new String[] { "field1", "field2" }; >+ > TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5); > TmfEventSource source = new TmfEventSource("Source"); >- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" }); >- TmfEventType type = new TmfEventType("Type", format); >- TmfEventContent content = new TmfEventContent("Some content", format); >+ TmfEventType type = new TmfEventType("Type", labels); >+ TmfEventContent content = new TmfEventContentStub(type, fields); > TmfEventReference reference = new TmfEventReference("Reference"); > > // Create the event >@@ -58,13 +61,13 @@ > // Check the event type > TmfEventType tp = event.getType(); > assertEquals("getValue", "Type", tp.getTypeId()); >- assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]); >- assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]); >+ assertEquals("getFormat", "label1", tp.getLabels()[0]); >+ assertEquals("getFormat", "label2", tp.getLabels()[1]); > > // Check the event content > TmfEventContent cnt = event.getContent(); >- assertEquals("getField", 1, cnt.getFields().length); >- assertEquals("getField", "Some content", cnt.getField(0).toString()); >+ assertEquals("getField", 2, cnt.getFields().length); >+ assertEquals("getField", "[field:label1,value:Field1]", cnt.getField(tp.getLabels()[0]).toString()); > > // Check the event reference > TmfEventReference ref = event.getReference(); >@@ -73,12 +76,15 @@ > > @Test > public void testTmfEvent2() { >- TmfTimestamp original = new TmfTimestamp(12345, (byte) 2, 5); >+ >+ String[] labels = new String[] { "label1", "label2" }; >+ String[] fields = new String[] { "field1", "field2" }; >+ >+ TmfTimestamp original = new TmfTimestamp(12345, (byte) 2, 5); > TmfTimestamp effective = new TmfTimestamp(12350, (byte) 2, 5); > TmfEventSource source = new TmfEventSource("Source"); >- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" }); >- TmfEventType type = new TmfEventType("Type", format); >- TmfEventContent content = new TmfEventContent("Some content", format); >+ TmfEventType type = new TmfEventType("Type", labels); >+ TmfEventContent content = new TmfEventContentStub(type, fields); > TmfEventReference reference = new TmfEventReference("Reference"); > > // Create the event >@@ -103,13 +109,13 @@ > // Check the event type > TmfEventType tp = event.getType(); > assertEquals("getValue", "Type", tp.getTypeId()); >- assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]); >- assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]); >+ assertEquals("getFormat", "label1", tp.getLabels()[0]); >+ assertEquals("getFormat", "label2", tp.getLabels()[1]); > > // Check the event content > TmfEventContent cnt = event.getContent(); >- assertEquals("getField", 1, cnt.getFields().length); >- assertEquals("getField", "Some content", cnt.getField(0).toString()); >+ assertEquals("getField", 2, cnt.getFields().length); >+ assertEquals("getField", "[field:label1,value:Field1]", cnt.getField(tp.getLabels()[0]).toString()); > > // Check the event reference > TmfEventReference ref = event.getReference(); >Index: src/org/eclipse/linuxtools/tmf/event/AllEventTests.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/AllEventTests.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/AllEventTests.java (working copy) >@@ -20,7 +20,6 @@ > TmfTimestampTest.class, > TmfTimeRangeTest.class, > TmfEventTypeTest.class, >- TmfEventFormatTest.class, > TmfEventContentTest.class, > TmfEventTest.class, > TmfTraceEventTest.class >#P org.eclipse.linuxtools.tmf >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventType.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventType.java (revision 23628) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventType.java (working copy) >@@ -23,8 +23,8 @@ > // Attributes > // ======================================================================== > >- private final String fTypeId; >- private final TmfEventFormat fFormat; >+ private final String fTypeId; >+ private final String[] fFieldLabels; > > // ======================================================================== > // Constructors >@@ -34,9 +34,9 @@ > * @param type > * @param format > */ >- public TmfEventType(String typeID, TmfEventFormat format) { >+ public TmfEventType(String typeID, String[] labels) { > fTypeId = typeID; >- fFormat = format; >+ fFieldLabels = labels; > } > > // ======================================================================== >@@ -50,12 +50,12 @@ > return fTypeId; > } > >- /** >- * @return >- */ >- public TmfEventFormat getFormat() { >- return fFormat; >- } >+ /** >+ * @return >+ */ >+ public String[] getLabels() { >+ return fFieldLabels; >+ } > > // ======================================================================== > // Operators >@@ -63,7 +63,7 @@ > > @Override > public String toString() { >- return fTypeId.toString(); >+ return "[type:" + fTypeId + "]"; > } > >-} >+} >\ No newline at end of file >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventField.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventField.java (revision 23628) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventField.java (working copy) >@@ -16,6 +16,8 @@ > * <b><u>TmfEventField</u></b> > * <p> > * A basic event field. >+ * >+ * TODO: Add support for field hierarchy. > */ > public class TmfEventField { > >@@ -23,7 +25,9 @@ > // Attributes > // ======================================================================== > >- private final Object fValue; >+ private final TmfEventContent fParent; >+ private final String fId; >+ private Object fValue; > > // ======================================================================== > // Constructors >@@ -30,12 +34,32 @@ > // ======================================================================== > > /** >+ * @param parent >+ * @param id > * @param value > */ >- public TmfEventField(Object value) { >+ public TmfEventField(TmfEventContent parent, String id, Object value) { >+ fParent = parent; >+ fId = id; > fValue = value; > } > >+ /** >+ * @param other >+ */ >+ public TmfEventField(TmfEventField other) { >+ fParent = other.fParent; >+ fId = other.fId; >+ fValue = other.fValue; >+ } >+ >+ @SuppressWarnings("unused") >+ private TmfEventField() { >+ fParent = null; >+ fId = null; >+ fValue = null; >+ } >+ > // ======================================================================== > // Accessors > // ======================================================================== >@@ -43,6 +67,20 @@ > /** > * @return > */ >+ public TmfEventContent getContent() { >+ return fParent; >+ } >+ >+ /** >+ * @return >+ */ >+ public String getId() { >+ return fId; >+ } >+ >+ /** >+ * @return >+ */ > public Object getValue() { > return fValue; > } >@@ -47,6 +85,13 @@ > return fValue; > } > >+ /** >+ * @return >+ */ >+ protected void setValue(Object value) { >+ fValue = value; >+ } >+ > // ======================================================================== > // Operators > // ======================================================================== >@@ -56,7 +101,7 @@ > */ > @Override > public String toString() { >- return fValue.toString(); >+ return "[field:" + fId + ",value:" + fValue.toString() + "]"; > } > >-} >+} >\ No newline at end of file >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventContent.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventContent.java (revision 23628) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventContent.java (working copy) >@@ -12,6 +12,8 @@ > > package org.eclipse.linuxtools.tmf.event; > >+import java.util.Map; >+ > /** > * <b><u>TmfEventContent</u></b> > * <p> >@@ -17,7 +19,7 @@ > * <p> > * The event content. > */ >-public class TmfEventContent { >+public abstract class TmfEventContent { > > // ======================================================================== > // Attributes >@@ -23,10 +25,13 @@ > // Attributes > // ======================================================================== > >- private final TmfEventFormat fFormat; >- private final String fContent; >- private final int fNbFields; >- private TmfEventField[] fFields = null; >+ protected TmfEvent fParentEvent = null; >+ protected TmfEventType fEventType = null; >+ protected Object fRawContent = null; >+ >+ // The ordered list of field labels >+ protected String[] fFieldLabels = null; >+ protected Map<String, TmfEventField> fFields = null; > > // ======================================================================== > // Constructors >@@ -33,15 +38,31 @@ > // ======================================================================== > > /** >+ * @param parent >+ * @param type > * @param content >- * @param format > */ >- public TmfEventContent(Object content, TmfEventFormat format) { >- fFormat = format; >- fContent = content.toString(); >- fNbFields = fFormat.getLabels().length; >+ public TmfEventContent(TmfEventType type, Object content) { >+ fEventType = type; >+ fRawContent = content; >+ fFieldLabels = (type != null) ? fEventType.getLabels() : null; >+ fFields = parseContent(); > } > >+ /** >+ * @param other >+ */ >+ public TmfEventContent(TmfEventContent other) { >+ fParentEvent = other.fParentEvent; >+ fEventType = other.fEventType; >+ fRawContent = other.fRawContent; >+ fFieldLabels = other.fFieldLabels; >+ } >+ >+ @SuppressWarnings("unused") >+ private TmfEventContent() { >+ } >+ > // ======================================================================== > // Accessors > // ======================================================================== >@@ -47,34 +68,45 @@ > // ======================================================================== > > /** >- * @return >+ * @param event >+ */ >+ public void setEvent(TmfEvent event) { >+ fParentEvent = event; >+ } >+ >+ /** >+ * @return the parent (containing) event > */ >- public String getContent() { >- return fContent; >+ public TmfEvent getEvent() { >+ return fParentEvent; > } > > /** >- * @return >+ * @return the event type > */ >- public TmfEventFormat getFormat() { >- return fFormat; >+ public TmfEventType getType() { >+ return fEventType; > } > >- /** >- * @return >- */ >- public int getNbFields() { >- return fNbFields; >- } >+ /** >+ * @return the raw content >+ */ >+ public Object getContent() { >+ return fRawContent; >+ } > > /** >- * @return >+ * Returns the list of fields in the same order as TmfEventType.getLabels() >+ * >+ * @return the ordered set of fields (optional fields might be null) > */ > public TmfEventField[] getFields() { >- if (fFields == null) { >- fFields = fFormat.parse(fContent); >+ int nbFields = fFieldLabels.length; >+ TmfEventField[] fields = new TmfEventField[nbFields]; >+ for (int i = 0; i < nbFields; i++) { >+ fields[i] = fFields.get(fFieldLabels[i]); > } >- return fFields; >+ return fields; > } > > /** >@@ -81,19 +113,32 @@ > * @param id > * @return > */ >- public TmfEventField getField(int id) { >- assert id >= 0 && id < fNbFields; >- if (fFields == null) { >- fFields = fFormat.parse(fContent); >- } >- return fFields[id]; >+ public TmfEventField getField(String id) { >+ return fFields.get(id); > } > >+ // ======================================================================== >+ // Operators >+ // ======================================================================== >+ > /** >- * @return >+ * > */ >- public void setFields(TmfEventField[] fields) { >- fFields = fields; >- } >+ public abstract Map<String, TmfEventField> parseContent(); >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#toString() >+ */ >+ @Override >+ public String toString() { >+ TmfEventField[] fields = getFields(); >+ String result = "[content:"; >+ for (int i = 0; i < fields.length; i++) { >+ result += fields[i].toString(); >+ } >+ result += "]"; >+ >+ return result; >+ } > > } >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventFormat.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventFormat.java (revision 23628) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventFormat.java (working copy) >@@ -1,72 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2009 Ericsson >- * >- * All rights reserved. This program and the accompanying materials are >- * made available under the terms of the Eclipse Public License v1.0 which >- * accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Francois Chouinard - Initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.linuxtools.tmf.event; >- >-/** >- * <b><u>TmfEventFormat</u></b> >- * <p> >- * The basic event content format. >- */ >-public class TmfEventFormat implements ITmfContentParser { >- >- // ======================================================================== >- // Attributes >- // ======================================================================== >- >- private final String[] fLabels; >- >- // ======================================================================== >- // Constructors >- // ======================================================================== >- >- /** >- * >- */ >- public TmfEventFormat() { >- this(new String[] { "Content" }); >- } >- >- /** >- * @param labels >- */ >- public TmfEventFormat(String[] labels) { >- fLabels = labels; >- } >- >- // ======================================================================== >- // Accessors >- // ======================================================================== >- >- /** >- * @return >- */ >- public String[] getLabels() { >- return fLabels; >- } >- >- // ======================================================================== >- // Operators >- // ======================================================================== >- >- /** >- * The default content parser: returns a single field containing the whole >- * content. >- * >- * @param content >- * @return >- */ >- public TmfEventField[] parse(Object content) { >- return new TmfEventField[] { new TmfEventField(content.toString()) }; >- } >- >-}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 287562
:
145578
|
151266
|
151267
|
151666