001: /*
002:
003: Derby - Class org.apache.derbyTesting.unitTests.store.T_RawStoreRow
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derbyTesting.unitTests.store;
023:
024: import org.apache.derby.iapi.store.raw.*;
025:
026: import org.apache.derby.iapi.store.access.*;
027: import org.apache.derby.iapi.types.SQLChar;
028:
029: import org.apache.derby.iapi.types.DataValueDescriptor;
030:
031: import java.io.*;
032:
033: /*
034: * Implements a row of N columns of strings, or objects.
035: * Used for testing raw store functionality.
036: */
037: public class T_RawStoreRow {
038:
039: DataValueDescriptor[] col;
040:
041: public T_RawStoreRow(int numberOfColumns) {
042: super ();
043: col = new DataValueDescriptor[numberOfColumns];
044: }
045:
046: public T_RawStoreRow(String data) {
047: this (1);
048: col[0] = data == null ? new SQLChar() : new SQLChar(data);
049: }
050:
051: public DataValueDescriptor[] getRow() {
052: return col;
053: }
054:
055: public void setColumn(int columnId, String data) {
056: col[columnId] = data == null ? new SQLChar()
057: : new SQLChar(data);
058: }
059:
060: public void setColumn(int columnId, int stringLen, String data) {
061: // in store it will take (stringLen * 2) bytes
062: col[columnId] = new SQLChar(T_Util.getStringFromData(data,
063: stringLen));
064: }
065:
066: public void setColumn(int columnId, DataValueDescriptor data) {
067: col[columnId] = data;
068: }
069:
070: public DataValueDescriptor getStorableColumn(int columnId) {
071:
072: return col[columnId];
073: }
074:
075: public DataValueDescriptor getColumn(int columnId) {
076:
077: return col[columnId];
078: }
079:
080: public void setStorableColumn(int columnId,
081: DataValueDescriptor value) {
082:
083: col[columnId] = value;
084: }
085:
086: public int nColumns() {
087: return col.length;
088: }
089:
090: public String toString() {
091: StringBuffer sb = new StringBuffer("");
092: for (int i = 0; i < nColumns(); i++) {
093: sb.append(col[i].toString());
094: if (i < (nColumns() - 1))
095: sb.append(",");
096: }
097: sb.append("");
098:
099: return sb.toString();
100: }
101: }
|