KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > test > internal > performance > data > Sample


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.test.internal.performance.data;
12
13 import java.util.Map JavaDoc;
14 import java.util.Set JavaDoc;
15
16 import org.eclipse.test.performance.Dimension;
17
18 import junit.framework.Assert;
19
20 /**
21  * @since 3.1
22  */

23 public class Sample {
24     String JavaDoc fScenarioID;
25     long fStartTime;
26     Map JavaDoc fProperties;
27     DataPoint[] fDataPoints;
28     
29     boolean fIsSummary;
30     boolean fSummaryIsGlobal;
31     String JavaDoc fShortName;
32     Dimension[] fSummaryDimensions;
33     int fCommentType;
34     String JavaDoc fComment;
35     
36     
37     public Sample(String JavaDoc scenarioID, long starttime, Map JavaDoc properties, DataPoint[] dataPoints) {
38         Assert.assertTrue("scenarioID is null", scenarioID != null); //$NON-NLS-1$
39
fScenarioID= scenarioID;
40         fStartTime= starttime;
41         fProperties= properties;
42         fDataPoints= dataPoints;
43     }
44     
45     public Sample(DataPoint[] dataPoints) {
46         fDataPoints= dataPoints;
47     }
48     
49     public void tagAsSummary(boolean global, String JavaDoc shortName, Dimension[] summaryDimensions, int commentType, String JavaDoc comment) {
50         fIsSummary= true;
51         fSummaryIsGlobal= global;
52         fShortName= shortName;
53         fSummaryDimensions= summaryDimensions;
54         fCommentType= commentType;
55         fComment= comment;
56     }
57     
58     public String JavaDoc getScenarioID() {
59         return fScenarioID;
60     }
61     
62     public long getStartTime() {
63          return fStartTime;
64     }
65     
66     public String JavaDoc getProperty(String JavaDoc name) {
67         return (String JavaDoc) fProperties.get(name);
68     }
69     
70     public String JavaDoc[] getPropertyKeys() {
71         if (fProperties == null)
72             return new String JavaDoc[0];
73         Set JavaDoc set= fProperties.keySet();
74         return (String JavaDoc[]) set.toArray(new String JavaDoc[set.size()]);
75     }
76     
77     public DataPoint[] getDataPoints() {
78         DataPoint[] dataPoints= new DataPoint[fDataPoints.length];
79         System.arraycopy(fDataPoints, 0, dataPoints, 0, fDataPoints.length);
80         return dataPoints;
81     }
82     
83     public String JavaDoc toString() {
84         return "MeteringSession [scenarioID= " + fScenarioID + ", #datapoints: " + fDataPoints.length + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
85
}
86
87     public boolean isSummary() {
88         return fIsSummary;
89     }
90     
91     public boolean isGlobal() {
92         return fSummaryIsGlobal;
93     }
94     
95     public String JavaDoc getShortname() {
96         return fShortName;
97     }
98     
99     public Dimension[] getSummaryDimensions() {
100         return fSummaryDimensions;
101     }
102
103     public int getCommentType() {
104         return fCommentType;
105     }
106
107     public String JavaDoc getComment() {
108         return fComment;
109     }
110 }
111
Popular Tags