KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > unitTests > store > T_RawStoreRow


1 /*
2
3    Derby - Class org.apache.derbyTesting.unitTests.store.T_RawStoreRow
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derbyTesting.unitTests.store;
23
24 import org.apache.derby.iapi.store.raw.*;
25
26 import org.apache.derby.iapi.store.access.*;
27 import org.apache.derby.iapi.types.SQLChar;
28
29 import org.apache.derby.iapi.types.DataValueDescriptor;
30
31 import java.io.*;
32
33 /*
34  * Implements a row of N columns of strings, or objects.
35  * Used for testing raw store functionality.
36  */

37 public class T_RawStoreRow {
38
39     DataValueDescriptor[] col;
40
41     public T_RawStoreRow(int numberOfColumns) {
42         super();
43         col = new DataValueDescriptor[numberOfColumns];
44     }
45
46     public T_RawStoreRow(String JavaDoc data) {
47         this(1);
48         col[0] = data == null ? new SQLChar() : new SQLChar(data);
49     }
50
51     public DataValueDescriptor[] getRow() {
52         return col;
53     }
54
55     public void setColumn(int columnId, String JavaDoc data)
56     {
57         col[columnId] = data == null ? new SQLChar() : new SQLChar(data);
58     }
59
60     public void setColumn(int columnId, int stringLen, String JavaDoc data)
61     {
62         // in store it will take (stringLen * 2) bytes
63
col[columnId] = new SQLChar(T_Util.getStringFromData(data, stringLen));
64     }
65
66     public void setColumn(int columnId, DataValueDescriptor data)
67     {
68         col[columnId] = data;
69     }
70
71     public DataValueDescriptor getStorableColumn(int columnId) {
72
73         return col[columnId];
74     }
75
76     public DataValueDescriptor getColumn(int columnId) {
77
78         return col[columnId];
79     }
80
81     public void setStorableColumn(int columnId, DataValueDescriptor value) {
82
83         col[columnId] = value;
84     }
85
86     public int nColumns() {
87         return col.length;
88     }
89
90     public String JavaDoc toString() {
91         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("");
92         for (int i = 0; i < nColumns(); i++) {
93             sb.append(col[i].toString());
94             if (i < (nColumns() - 1))
95                 sb.append(",");
96         }
97         sb.append("");
98
99         return sb.toString();
100     }
101 }
102
103
Popular Tags