8970d1a8c472c5db5c6d4bbdc0bb3c10331e6e30
[portal/sdk.git] /
1 /*-
2  * ================================================================================
3  * eCOMP Portal SDK
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 package org.openecomp.portalsdk.analytics.view;
21
22 import java.util.*;
23
24 import org.openecomp.portalsdk.analytics.error.*;
25 import org.openecomp.portalsdk.analytics.system.*;
26 import org.openecomp.portalsdk.analytics.util.*;
27
28 public class CrossTabColumnValues extends org.openecomp.portalsdk.analytics.RaptorObject {
29         private String colId = null;
30
31         private Vector columnValues = null;
32
33         public CrossTabColumnValues(String colId, String loadValuesSQL, String dbInfo)
34                         throws RaptorException {
35                 this.colId = colId;
36                 DataSet ds = ConnectionUtils.getDataSet(loadValuesSQL, dbInfo);
37                 // DataSet ds = DbUtils.executeQuery(loadValuesSQL);
38                 columnValues = new Vector(ds.getRowCount());
39                 for (int i = 0; i < ds.getRowCount(); i++)
40                         columnValues.add(ds.getString(i, 0));
41         } // CrossTabColumnValues
42
43         public String getColId() {
44                 return colId;
45         }
46
47         public Vector getColumnValues() {
48                 return columnValues;
49         }
50
51         public int getValuesCount() {
52                 return columnValues.size();
53         }
54
55         public String getValueAt(int idx) {
56                 return (String) columnValues.get(idx);
57         }
58
59         public int getIndexOf(String value) {
60                 for (int i = 0; i < getValuesCount(); i++)
61                         if (value.equals(getValueAt(i)))
62                                 return i;
63
64                 return -1;
65         } // getIndexOf
66
67         public int getIndexOf(int value) {
68                 for (int i = 0; i < getValuesCount(); i++)
69                         if (value == new Integer(getValueAt(i)).intValue())
70                                 return i;
71
72                 return -1;
73         } // getIndexOf
74
75 } // CrossTabColumnValues