1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
*******************************************************************************/
package org.eclipse.linuxtools.internal.systemtap.graphing.ui.wizards.filter;
import org.eclipse.linuxtools.internal.systemtap.graphing.ui.Localization;
import org.eclipse.linuxtools.systemtap.graphing.core.aggregates.AverageAggregate;
import org.eclipse.linuxtools.systemtap.graphing.core.aggregates.CountAggregate;
import org.eclipse.linuxtools.systemtap.graphing.core.aggregates.IDataAggregate;
import org.eclipse.linuxtools.systemtap.graphing.core.aggregates.MaxAggregate;
import org.eclipse.linuxtools.systemtap.graphing.core.aggregates.MinAggregate;
import org.eclipse.linuxtools.systemtap.graphing.core.aggregates.SumAggregate;
public final class AggregateFactory {
private AggregateFactory() {}
private static String[] AGGREGATE_NAMES = new String[] {
Localization.getString("AggregateFactory.AverageAggregate"), //$NON-NLS-1$
Localization.getString("AggregateFactory.CountAggregate"), //$NON-NLS-1$
Localization.getString("AggregateFactory.MaxAggregate"), //$NON-NLS-1$
Localization.getString("AggregateFactory.MinAggregate"), //$NON-NLS-1$
Localization.getString("AggregateFactory.SumAggregate") //$NON-NLS-1$
};
private static String[] AGGREGATION_DESCRIPTIONS = new String[] {
Localization.getString("AggregateFactory.AverageDescription"), //$NON-NLS-1$
Localization.getString("AggregateFactory.CountDescription"), //$NON-NLS-1$
Localization.getString("AggregateFactory.MaxDescription"), //$NON-NLS-1$
Localization.getString("AggregateFactory.MinDescription"), //$NON-NLS-1$
Localization.getString("AggregateFactory.SumDescription") //$NON-NLS-1$
};
static String[] AGGREGATES = new String[] {
AverageAggregate.ID,
CountAggregate.ID,
MaxAggregate.ID,
MinAggregate.ID,
SumAggregate.ID
};
public static String getAggregateName(String id) {
int index = getIndex(id);
if(index >= 0) {
return AGGREGATE_NAMES[index];
}
return null;
}
public static String getAggregateDescription(String id) {
int index = getIndex(id);
if(index >= 0) {
return AGGREGATION_DESCRIPTIONS[index];
}
return null;
}
private static int getIndex(String id) {
for(int i=0; i< AGGREGATES.length; i++) {
if(id.equals(AGGREGATES[i])) {
return i;
}
}
return -1;
}
public static IDataAggregate createAggregate(String id) {
switch(getIndex(id)) {
case 0:
return new AverageAggregate();
case 1:
return new CountAggregate();
case 2:
return new MaxAggregate();
case 3:
return new MinAggregate();
case 4:
return new SumAggregate();
}
return null;
}
}
|