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
.event
;
17 * <b><u>TmfEventContent</u></b>
21 public class TmfEventContent
implements Cloneable
{
23 // ========================================================================
25 // ========================================================================
27 protected TmfEvent fParentEvent
= null;
28 protected Object fRawContent
= null;
29 protected Object
[] fFields
= null;
31 // ========================================================================
33 // ========================================================================
39 public TmfEventContent(TmfEvent parent
, Object content
) {
40 fParentEvent
= parent
;
41 fRawContent
= content
;
47 public TmfEventContent(TmfEventContent other
) {
48 assert(other
!= null);
49 fParentEvent
= other
.fParentEvent
;
50 fRawContent
= other
.fRawContent
;
51 fFields
= other
.fFields
;
54 @SuppressWarnings("unused")
55 private TmfEventContent() {
58 // ========================================================================
60 // ========================================================================
63 * @return the parent (containing) event
65 public TmfEvent
getEvent() {
70 * @return the event type
72 public TmfEventType
getType() {
73 return fParentEvent
.getType();
77 * @return the raw content
79 public Object
getContent() {
84 * Returns the list of fields in the same order as TmfEventType.getLabels()
86 * @return the ordered set of fields (optional fields might be null)
88 public Object
[] getFields() {
89 if (fFields
== null) {
99 public Object
getField(String id
) throws TmfNoSuchFieldException
{
100 if (fFields
== null) {
103 return fFields
[getType().getFieldIndex(id
)];
110 public Object
getField(int n
) {
111 if (fFields
== null) {
114 if (n
>= 0 && n
< fFields
.length
)
119 // ========================================================================
121 // ========================================================================
124 * Should be overridden (all fields are null by default)
126 protected void parseContent() {
127 fFields
= new Object
[1];
128 fFields
[0] = fRawContent
;
132 * Clone: shallow copy by default; override for deep copy.
135 public TmfEventContent
clone() {
136 return new TmfEventContent(this);
140 public String
toString() {
141 Object
[] fields
= getFields();
142 String result
= "[TmfEventContent(";
143 for (int i
= 0; i
< fields
.length
; i
++) {
144 result
+= fields
[i
].toString() + ",";
This page took 0.034113 seconds and 6 git commands to generate.