Commit | Line | Data |
---|---|---|
8c8bf09f 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: | |
1f506a43 | 10 | * Francois Chouinard - Initial API and implementation |
8c8bf09f ASL |
11 | *******************************************************************************/ |
12 | ||
13 | package org.eclipse.linuxtools.tmf.event; | |
14 | ||
15 | /** | |
16 | * <b><u>TmfEventField</u></b> | |
17 | * <p> | |
18 | * A basic event field. | |
28b94d61 FC |
19 | * |
20 | * TODO: Add support for field hierarchy. | |
8c8bf09f | 21 | */ |
28b94d61 | 22 | public class TmfEventField implements Cloneable { |
8c8bf09f | 23 | |
4ab33d2b | 24 | // ======================================================================== |
8c8bf09f | 25 | // Attributes |
4ab33d2b | 26 | // ======================================================================== |
8c8bf09f | 27 | |
28b94d61 FC |
28 | private final TmfEventContent fParent; |
29 | private final String fFieldId; | |
30 | private Object fValue; | |
8c8bf09f | 31 | |
4ab33d2b | 32 | // ======================================================================== |
8c8bf09f | 33 | // Constructors |
4ab33d2b | 34 | // ======================================================================== |
8c8bf09f ASL |
35 | |
36 | /** | |
28b94d61 FC |
37 | * @param parent |
38 | * @param id | |
8c8bf09f ASL |
39 | * @param value |
40 | */ | |
28b94d61 FC |
41 | public TmfEventField(TmfEventContent parent, String id, Object value) { |
42 | fParent = parent; | |
43 | fFieldId = id; | |
44 | fValue = value; | |
45 | } | |
46 | ||
47 | /** | |
48 | * @param other | |
49 | */ | |
50 | public TmfEventField(TmfEventField other) { | |
51 | assert(other != null); | |
52 | fParent = other.fParent; | |
53 | fFieldId = other.fFieldId; | |
54 | fValue = other.fValue; | |
55 | } | |
56 | ||
57 | @SuppressWarnings("unused") | |
58 | private TmfEventField() { | |
59 | fParent = null; | |
60 | fFieldId = null; | |
61 | fValue = null; | |
8c8bf09f ASL |
62 | } |
63 | ||
4ab33d2b | 64 | // ======================================================================== |
8c8bf09f | 65 | // Accessors |
4ab33d2b | 66 | // ======================================================================== |
8c8bf09f | 67 | |
28b94d61 FC |
68 | /** |
69 | * @return | |
70 | */ | |
71 | public TmfEventContent getParent() { | |
72 | return fParent; | |
73 | } | |
74 | ||
75 | /** | |
76 | * @return | |
77 | */ | |
78 | public String getId() { | |
79 | return fFieldId; | |
80 | } | |
81 | ||
8c8bf09f ASL |
82 | /** |
83 | * @return | |
84 | */ | |
85 | public Object getValue() { | |
86 | return fValue; | |
87 | } | |
88 | ||
28b94d61 FC |
89 | /** |
90 | * @param value | |
91 | */ | |
92 | protected void setValue(Object value) { | |
93 | fValue = value; | |
94 | } | |
95 | ||
4ab33d2b AO |
96 | // ======================================================================== |
97 | // Operators | |
98 | // ======================================================================== | |
8c8bf09f | 99 | |
28b94d61 FC |
100 | /** |
101 | * Clone: shallow copy by default; override for deep copy. | |
102 | */ | |
103 | @Override | |
104 | public TmfEventField clone() { | |
105 | return new TmfEventField(this); | |
106 | } | |
107 | ||
82b08e62 FC |
108 | @Override |
109 | public String toString() { | |
28b94d61 | 110 | return "[TmfEventField(" + fFieldId + ":" + fValue.toString() + ")]"; |
8c8bf09f | 111 | } |
1f506a43 | 112 | |
28b94d61 | 113 | } |