Commit | Line | Data |
---|---|---|
5d10d135 ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 Ericsson | |
3 | * | |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * William Bourque (wbourque@gmail.com) - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.lttng.event; | |
14 | ||
28b94d61 | 15 | import org.eclipse.linuxtools.tmf.event.TmfEventContent; |
3fbd810a | 16 | import org.eclipse.linuxtools.tmf.event.TmfEventField; |
5d10d135 ASL |
17 | |
18 | /** | |
07d9e2ee FC |
19 | * <b><u>LttngEventField</u></b><p> |
20 | * | |
21 | * Lttng specific implementation of the TmfEventField.<p> | |
22 | * | |
23 | * LttngEventField add a "name" attribute to the Tmf implementation This | |
3fbd810a | 24 | * mean the fields will have a name and a value. |
5d10d135 | 25 | */ |
3fbd810a | 26 | public class LttngEventField extends TmfEventField { |
07d9e2ee | 27 | |
28b94d61 FC |
28 | /** |
29 | * Constructor with parameters.<p> | |
30 | * | |
31 | * @param parent Parent content for this field | |
32 | * @param id Name (label) of this field | |
33 | */ | |
34 | public LttngEventField(TmfEventContent parent, String id) { | |
35 | super(parent, id, null); | |
36 | } | |
37 | ||
3fbd810a | 38 | /** |
28b94d61 | 39 | * Constructor with parameters with optional value.<p> |
3fbd810a | 40 | * |
28b94d61 FC |
41 | * @param parent Parent content for this field |
42 | * @param id Name (label) of this field | |
43 | * @param value Parsed value (payload) of this field | |
3fbd810a | 44 | */ |
28b94d61 FC |
45 | public LttngEventField(TmfEventContent parent, String id, Object value) { |
46 | super(parent, id, value); | |
3fbd810a | 47 | } |
07d9e2ee | 48 | |
3fbd810a | 49 | /** |
07d9e2ee | 50 | * Copy constructor.<p> |
3fbd810a | 51 | * |
07d9e2ee | 52 | * @param oldField the field to copy from |
3fbd810a FC |
53 | */ |
54 | public LttngEventField(LttngEventField oldField) { | |
28b94d61 | 55 | this(oldField.getParent(), oldField.getId(), oldField.getValue()); |
3fbd810a | 56 | } |
07d9e2ee | 57 | |
3fbd810a | 58 | @Override |
3b38ea61 | 59 | @SuppressWarnings("nls") |
3fbd810a | 60 | public String toString() { |
1a971e96 FC |
61 | Object value = getValue(); |
62 | return getId() + ":" + ((value != null) ? value.toString() : "null"); | |
63 | } | |
64 | ||
65 | @Override | |
66 | public LttngEventField clone() { | |
67 | LttngEventField clone = (LttngEventField) super.clone(); | |
68 | clone.fValue = fValue; | |
69 | return clone; | |
3fbd810a | 70 | } |
28b94d61 | 71 | |
3fbd810a | 72 | } |