Commit | Line | Data |
---|---|---|
d4514365 BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 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 | * Bernd Hufmann - Initial API and implementation | |
11 | **********************************************************************/ | |
12 | package org.eclipse.linuxtools.internal.lttng2.core.control.model.impl; | |
13 | ||
14 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo; | |
15 | ||
16 | /** | |
17 | * <p> | |
18 | * Implementation of the basic trace event interface (IEventInfo) to store event | |
19 | * related data. | |
20 | * </p> | |
21 | * | |
22 | * @author Bernd Hufmann | |
23 | */ | |
24 | public class FieldInfo extends TraceInfo implements IFieldInfo { | |
25 | ||
26 | // ------------------------------------------------------------------------ | |
27 | // Attributes | |
28 | // ------------------------------------------------------------------------ | |
29 | /** | |
30 | * The trace event type. | |
31 | */ | |
32 | private String fFieldType; | |
33 | ||
34 | // ------------------------------------------------------------------------ | |
35 | // Constructors | |
36 | // ------------------------------------------------------------------------ | |
37 | /** | |
38 | * Constructor | |
39 | * @param name - name of base event | |
40 | */ | |
41 | public FieldInfo(String name) { | |
42 | super(name); | |
43 | } | |
44 | ||
45 | /** | |
46 | * Copy constructor | |
47 | * @param other - the instance to copy | |
48 | */ | |
49 | public FieldInfo(FieldInfo other) { | |
50 | super(other); | |
51 | fFieldType = other.fFieldType; | |
52 | } | |
53 | ||
54 | // ------------------------------------------------------------------------ | |
55 | // Accessors | |
56 | // ------------------------------------------------------------------------ | |
57 | ||
58 | /* | |
59 | * (non-Javadoc) | |
60 | * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo#getFieldType() | |
61 | */ | |
62 | @Override | |
63 | public String getFieldType() { | |
64 | return fFieldType; | |
65 | } | |
66 | ||
67 | /* | |
68 | * (non-Javadoc) | |
69 | * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo#setFieldType(java.lang.String) | |
70 | */ | |
71 | @Override | |
72 | public void setFieldType(String fieldType) { | |
73 | fFieldType = fieldType; | |
74 | } | |
75 | ||
76 | /* | |
77 | * (non-Javadoc) | |
78 | * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo#hashCode() | |
79 | */ | |
80 | @Override | |
81 | public int hashCode() { | |
82 | final int prime = 31; | |
83 | int result = super.hashCode(); | |
84 | result = prime * result | |
85 | + ((fFieldType == null) ? 0 : fFieldType.hashCode()); | |
86 | return result; | |
87 | } | |
88 | ||
89 | /* | |
90 | * (non-Javadoc) | |
91 | * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo#equals(java.lang.Object) | |
92 | */ | |
93 | @Override | |
94 | public boolean equals(Object obj) { | |
95 | if (this == obj) { | |
96 | return true; | |
97 | } | |
98 | if (!super.equals(obj)) { | |
99 | return false; | |
100 | } | |
101 | if (getClass() != obj.getClass()) { | |
102 | return false; | |
103 | } | |
104 | FieldInfo other = (FieldInfo) obj; | |
105 | if (fFieldType == null) { | |
106 | if (other.fFieldType != null) { | |
107 | return false; | |
108 | } | |
109 | } else if (!fFieldType.equals(other.fFieldType)) { | |
110 | return false; | |
111 | } | |
112 | return true; | |
113 | } | |
114 | ||
115 | /* | |
116 | * (non-Javadoc) | |
117 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString() | |
118 | */ | |
119 | @SuppressWarnings("nls") | |
120 | @Override | |
121 | public String toString() { | |
122 | StringBuffer output = new StringBuffer(); | |
123 | output.append("[FieldInfo("); | |
124 | output.append(super.toString()); | |
125 | output.append(",type="); | |
126 | output.append(fFieldType); | |
127 | return output.toString(); | |
128 | } | |
129 | } |