1
/*******************************************************************************
2
* Copyright (c) 2011 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
* Bernd Hufmann - Initial API and implementation
12
*******************************************************************************/
13
package org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.config;
15
import java.util.Collection;
16
import java.util.HashMap;
17
import java.util.Iterator;
21
import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.config.TraceChannel;
22
import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.config.TraceChannels;
25
* <b><u>TraceChannels</u></b>
27
* This models a collection of trace channels.
30
public class TraceChannels implements Map<String, TraceChannel>, Cloneable {
32
// ------------------------------------------------------------------------
34
// -----------------------------------------------------------------------
35
private Map<String, TraceChannel> fChannels = new HashMap<String, TraceChannel>();
37
// ------------------------------------------------------------------------
39
// ------------------------------------------------------------------------
41
// ------------------------------------------------------------------------
43
// ------------------------------------------------------------------------
47
* @see java.util.Map#size()
51
return fChannels.size();
56
* @see java.util.Map#isEmpty()
59
public boolean isEmpty() {
60
return fChannels.isEmpty();
65
* @see java.util.Map#containsKey(java.lang.Object)
68
public boolean containsKey(Object key) {
69
return fChannels.containsKey(key);
74
* @see java.util.Map#containsValue(java.lang.Object)
77
public boolean containsValue(Object value) {
78
return fChannels.containsValue(value);
83
* @see java.util.Map#get(java.lang.Object)
86
public TraceChannel get(Object key) {
87
return fChannels.get(key);
92
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
95
public TraceChannel put(String key, TraceChannel value) {
96
return fChannels.put(key, value);
101
* @see java.util.Map#remove(java.lang.Object)
104
public TraceChannel remove(Object key) {
105
return fChannels.remove(key);
110
* @see java.util.Map#putAll(java.util.Map)
113
public void putAll(Map<? extends String, ? extends TraceChannel> m) {
119
* @see java.util.Map#clear()
122
public void clear() {
128
* @see java.util.Map#keySet()
131
public Set<String> keySet() {
132
return fChannels.keySet();
137
* @see java.util.Map#values()
140
public Collection<TraceChannel> values() {
141
return fChannels.values();
146
* @see java.util.Map#entrySet()
149
public Set<java.util.Map.Entry<String, TraceChannel>> entrySet() {
150
return fChannels.entrySet();
154
* Creates trace channels with given names, put the to the map with a default
155
* trace channel object.
157
* @param channelNames
159
public void putAll(String[] channelNames) {
160
for (int i = 0; i < channelNames.length; i++) {
161
fChannels.put(channelNames[i], new TraceChannel(channelNames[i]));
167
* @see java.lang.Object#clone()
170
public TraceChannels clone() {
171
TraceChannels clone = null;
173
clone = (TraceChannels)super.clone();
175
clone.fChannels = new HashMap<String, TraceChannel>();
177
for (Iterator<String> iterator = fChannels.keySet().iterator(); iterator.hasNext();) {
178
String key = (String) iterator.next();
179
clone.fChannels.put(key, (fChannels.get(key)).clone());
182
} catch (CloneNotSupportedException e) {