Rename xxx.lttng to xxx.lttng.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / event / TmfEventField.java
CommitLineData
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
13package 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 */
1a971e96 22public class TmfEventField implements Cloneable {
8c8bf09f 23
cbd4ad82 24 // ------------------------------------------------------------------------
8c8bf09f 25 // Attributes
cbd4ad82 26 // ------------------------------------------------------------------------
8c8bf09f 27
1a971e96
FC
28 protected TmfEventContent fParent;
29 protected String fFieldId;
30 protected Object fValue;
8c8bf09f 31
cbd4ad82 32 // ------------------------------------------------------------------------
8c8bf09f 33 // Constructors
cbd4ad82
FC
34 // ------------------------------------------------------------------------
35
36 @SuppressWarnings("unused")
37 private TmfEventField() {
38 throw new AssertionError();
39 }
8c8bf09f
ASL
40
41 /**
28b94d61
FC
42 * @param parent
43 * @param id
8c8bf09f
ASL
44 * @param value
45 */
28b94d61 46 public TmfEventField(TmfEventContent parent, String id, Object value) {
cbd4ad82
FC
47 if (id == null) {
48 throw new IllegalArgumentException();
49 }
28b94d61
FC
50 fParent = parent;
51 fFieldId = id;
52 fValue = value;
53 }
54
55 /**
56 * @param other
57 */
58 public TmfEventField(TmfEventField other) {
cbd4ad82
FC
59 if (other == null)
60 throw new IllegalArgumentException();
28b94d61
FC
61 fParent = other.fParent;
62 fFieldId = other.fFieldId;
63 fValue = other.fValue;
64 }
65
cbd4ad82 66 // ------------------------------------------------------------------------
8c8bf09f 67 // Accessors
cbd4ad82 68 // ------------------------------------------------------------------------
8c8bf09f 69
28b94d61
FC
70 /**
71 * @return
72 */
73 public TmfEventContent getParent() {
74 return fParent;
75 }
76
77 /**
78 * @return
79 */
80 public String getId() {
81 return fFieldId;
82 }
83
8c8bf09f
ASL
84 /**
85 * @return
86 */
87 public Object getValue() {
88 return fValue;
89 }
90
28b94d61 91 /**
cbd4ad82 92 * @param value new field value
28b94d61
FC
93 */
94 protected void setValue(Object value) {
95 fValue = value;
96 }
97
cbd4ad82
FC
98 // ------------------------------------------------------------------------
99 // Object
100 // ------------------------------------------------------------------------
8c8bf09f 101
28b94d61 102 @Override
cbd4ad82 103 public int hashCode() {
2fb2eb37
FC
104 int result = 17;
105 result = 37 * result + fFieldId.hashCode();
106 result = 37 * result + fValue.hashCode();
107 return result;
cbd4ad82
FC
108 }
109
110 @Override
111 public boolean equals(Object other) {
112 if (!(other instanceof TmfEventField))
113 return false;
114 TmfEventField o = (TmfEventField) other;
115 return fParent.equals(o.fParent) && fFieldId.equals(o.fFieldId) && fValue.equals(o.fValue);
28b94d61
FC
116 }
117
82b08e62 118 @Override
3b38ea61 119 @SuppressWarnings("nls")
82b08e62 120 public String toString() {
28b94d61 121 return "[TmfEventField(" + fFieldId + ":" + fValue.toString() + ")]";
8c8bf09f 122 }
1a971e96
FC
123 @Override
124 public TmfEventField clone() {
125 TmfEventField clone = null;
126 try {
127 clone = (TmfEventField) super.clone();
128 clone.fParent = fParent;
129 clone.fFieldId = new String(fFieldId);
130 clone.fValue = null;
131 } catch (CloneNotSupportedException e) {
132 e.printStackTrace();
133 }
134 return clone;
135 }
136
1f506a43 137
28b94d61 138}
This page took 0.037331 seconds and 5 git commands to generate.