11 |
13 Sep 07 |
nicklas |
1 |
///////////////////////////////////////////////////////////////// |
11 |
13 Sep 07 |
nicklas |
2 |
// |
11 |
13 Sep 07 |
nicklas |
// Copyright (C) 2005 Affymetrix, Inc. |
11 |
13 Sep 07 |
nicklas |
4 |
// |
11 |
13 Sep 07 |
nicklas |
// This library is free software; you can redistribute it and/or modify |
11 |
13 Sep 07 |
nicklas |
// it under the terms of the GNU Lesser General Public License as published |
11 |
13 Sep 07 |
nicklas |
// by the Free Software Foundation; either version 2.1 of the License, |
11 |
13 Sep 07 |
nicklas |
// or (at your option) any later version. |
11 |
13 Sep 07 |
nicklas |
9 |
// |
11 |
13 Sep 07 |
nicklas |
// This library is distributed in the hope that it will be useful, but |
11 |
13 Sep 07 |
nicklas |
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
11 |
13 Sep 07 |
nicklas |
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License |
11 |
13 Sep 07 |
nicklas |
// for more details. |
11 |
13 Sep 07 |
nicklas |
14 |
// |
11 |
13 Sep 07 |
nicklas |
// You should have received a copy of the GNU Lesser General Public License |
11 |
13 Sep 07 |
nicklas |
// along with this library; if not, write to the Free Software Foundation, Inc., |
11 |
13 Sep 07 |
nicklas |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
11 |
13 Sep 07 |
nicklas |
18 |
// |
11 |
13 Sep 07 |
nicklas |
19 |
///////////////////////////////////////////////////////////////// |
11 |
13 Sep 07 |
nicklas |
20 |
|
11 |
13 Sep 07 |
nicklas |
21 |
|
11 |
13 Sep 07 |
nicklas |
22 |
package affymetrix.calvin.data; |
11 |
13 Sep 07 |
nicklas |
23 |
|
11 |
13 Sep 07 |
nicklas |
24 |
import affymetrix.portability.*; |
11 |
13 Sep 07 |
nicklas |
25 |
|
11 |
13 Sep 07 |
nicklas |
/** Base class for the varous columns. */ |
11 |
13 Sep 07 |
nicklas |
27 |
public class ColumnInfo { |
11 |
13 Sep 07 |
nicklas |
28 |
|
11 |
13 Sep 07 |
nicklas |
/** Data dataSet column data types */ |
11 |
13 Sep 07 |
nicklas |
30 |
public static final int ByteColType=0; |
11 |
13 Sep 07 |
nicklas |
31 |
public static final int UByteColType=1; |
11 |
13 Sep 07 |
nicklas |
32 |
public static final int ShortColType=2; |
11 |
13 Sep 07 |
nicklas |
33 |
public static final int UShortColType=3; |
11 |
13 Sep 07 |
nicklas |
34 |
public static final int IntColType=4; |
11 |
13 Sep 07 |
nicklas |
35 |
public static final int UIntColType=5; |
11 |
13 Sep 07 |
nicklas |
36 |
public static final int FloatColType=6; |
11 |
13 Sep 07 |
nicklas |
37 |
public static final int ASCIICharColType=7; |
11 |
13 Sep 07 |
nicklas |
38 |
public static final int UnicodeCharColType=8; |
11 |
13 Sep 07 |
nicklas |
39 |
|
11 |
13 Sep 07 |
nicklas |
/** Name of the column. */ |
11 |
13 Sep 07 |
nicklas |
41 |
private String name; |
11 |
13 Sep 07 |
nicklas |
42 |
|
11 |
13 Sep 07 |
nicklas |
/** Type of data in this column */ |
11 |
13 Sep 07 |
nicklas |
44 |
private int type; |
11 |
13 Sep 07 |
nicklas |
45 |
|
11 |
13 Sep 07 |
nicklas |
/** size of an individual element in bytes */ |
11 |
13 Sep 07 |
nicklas |
47 |
private int size; |
11 |
13 Sep 07 |
nicklas |
48 |
|
11 |
13 Sep 07 |
nicklas |
/** number of elements in column */ |
11 |
13 Sep 07 |
nicklas |
50 |
private int len; |
11 |
13 Sep 07 |
nicklas |
51 |
|
11 |
13 Sep 07 |
nicklas |
/** overhead size in bytes */ |
11 |
13 Sep 07 |
nicklas |
53 |
private int overhead; |
11 |
13 Sep 07 |
nicklas |
54 |
|
11 |
13 Sep 07 |
nicklas |
/** Constructor - used only by dervied types |
11 |
13 Sep 07 |
nicklas |
* @param name_ Name of the column. |
11 |
13 Sep 07 |
nicklas |
* @param type_ Type of data in the column. |
11 |
13 Sep 07 |
nicklas |
* @param size_ Size of each element of in the column. |
11 |
13 Sep 07 |
nicklas |
* @param len_ Number of elements of type in the column. |
11 |
13 Sep 07 |
nicklas |
* @param overhead_ Number of extra bytes in the column |
11 |
13 Sep 07 |
nicklas |
61 |
*/ |
11 |
13 Sep 07 |
nicklas |
62 |
protected ColumnInfo(String name_, int type_, int size_, int len_, int overhead_) { |
11 |
13 Sep 07 |
nicklas |
63 |
name = name_; |
11 |
13 Sep 07 |
nicklas |
64 |
type = type_; |
11 |
13 Sep 07 |
nicklas |
65 |
size = size_; |
11 |
13 Sep 07 |
nicklas |
66 |
len = len_; |
11 |
13 Sep 07 |
nicklas |
67 |
overhead=overhead_; |
11 |
13 Sep 07 |
nicklas |
68 |
} |
11 |
13 Sep 07 |
nicklas |
69 |
|
11 |
13 Sep 07 |
nicklas |
/** Constructor - used by the file read operation |
11 |
13 Sep 07 |
nicklas |
* @param name_ Name of the column. |
11 |
13 Sep 07 |
nicklas |
* @param type_ Type of data in the column. |
11 |
13 Sep 07 |
nicklas |
* @param totalSize Total size of the colum in bytes. |
11 |
13 Sep 07 |
nicklas |
74 |
*/ |
11 |
13 Sep 07 |
nicklas |
75 |
public ColumnInfo(String name_, int type_, int totalSize) { |
11 |
13 Sep 07 |
nicklas |
76 |
name=name_; |
11 |
13 Sep 07 |
nicklas |
77 |
type=type_; |
11 |
13 Sep 07 |
nicklas |
78 |
size=totalSize; |
11 |
13 Sep 07 |
nicklas |
79 |
len=1; |
11 |
13 Sep 07 |
nicklas |
80 |
overhead=0; |
11 |
13 Sep 07 |
nicklas |
81 |
if (type == ASCIICharColType || type == UnicodeCharColType) |
11 |
13 Sep 07 |
nicklas |
82 |
{ |
11 |
13 Sep 07 |
nicklas |
83 |
overhead = 4; |
11 |
13 Sep 07 |
nicklas |
84 |
if (type == UnicodeCharColType) |
11 |
13 Sep 07 |
nicklas |
85 |
{ |
11 |
13 Sep 07 |
nicklas |
86 |
size = DataSizes.SHORT_SIZE; |
11 |
13 Sep 07 |
nicklas |
87 |
len = (totalSize-overhead)/size; |
11 |
13 Sep 07 |
nicklas |
88 |
} |
11 |
13 Sep 07 |
nicklas |
89 |
else if (type == ASCIICharColType) |
11 |
13 Sep 07 |
nicklas |
90 |
{ |
11 |
13 Sep 07 |
nicklas |
91 |
size = DataSizes.CHAR_SIZE; |
11 |
13 Sep 07 |
nicklas |
92 |
len = (totalSize-overhead)/size; |
11 |
13 Sep 07 |
nicklas |
93 |
} |
11 |
13 Sep 07 |
nicklas |
94 |
} |
11 |
13 Sep 07 |
nicklas |
95 |
} |
11 |
13 Sep 07 |
nicklas |
96 |
|
11 |
13 Sep 07 |
nicklas |
/** Equiality operator |
11 |
13 Sep 07 |
nicklas |
* @param p object to compare against |
11 |
13 Sep 07 |
nicklas |
99 |
*/ |
11 |
13 Sep 07 |
nicklas |
100 |
public boolean equals(ColumnInfo p) { return (name.compareTo(p.name) == 0 && type == p.type && size == p.size); } |
11 |
13 Sep 07 |
nicklas |
101 |
|
11 |
13 Sep 07 |
nicklas |
/** Returns the type of the data in the column |
11 |
13 Sep 07 |
nicklas |
* @return Returns the type of the data in the column |
11 |
13 Sep 07 |
nicklas |
104 |
*/ |
11 |
13 Sep 07 |
nicklas |
105 |
public int getColumnType() { return type; } |
11 |
13 Sep 07 |
nicklas |
106 |
|
11 |
13 Sep 07 |
nicklas |
/** Returns the total size of the column in bytes. |
11 |
13 Sep 07 |
nicklas |
* @return Size in bytes of the column |
11 |
13 Sep 07 |
nicklas |
109 |
*/ |
11 |
13 Sep 07 |
nicklas |
110 |
public int getSize() { return size*len + overhead; } |
11 |
13 Sep 07 |
nicklas |
111 |
|
11 |
13 Sep 07 |
nicklas |
/** Returns the number of elements of type in the column |
11 |
13 Sep 07 |
nicklas |
* @return Number of elements of type in the column |
11 |
13 Sep 07 |
nicklas |
114 |
*/ |
11 |
13 Sep 07 |
nicklas |
115 |
int getLength() { return len; } |
11 |
13 Sep 07 |
nicklas |
116 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the column name. |
11 |
13 Sep 07 |
nicklas |
* @return The column name. |
11 |
13 Sep 07 |
nicklas |
119 |
*/ |
11 |
13 Sep 07 |
nicklas |
120 |
public String getName() { return name; } |
11 |
13 Sep 07 |
nicklas |
121 |
} |
11 |
13 Sep 07 |
nicklas |
122 |
|
11 |
13 Sep 07 |
nicklas |
123 |
|
11 |
13 Sep 07 |
nicklas |
/** Byte column */ |
11 |
13 Sep 07 |
nicklas |
125 |
class ByteColumn extends ColumnInfo { |
11 |
13 Sep 07 |
nicklas |
126 |
public ByteColumn(String name_) { |
11 |
13 Sep 07 |
nicklas |
127 |
super(name_, ByteColType, DataSizes.CHAR_SIZE, 1, 0); |
11 |
13 Sep 07 |
nicklas |
128 |
} |
11 |
13 Sep 07 |
nicklas |
129 |
} |
11 |
13 Sep 07 |
nicklas |
130 |
|
11 |
13 Sep 07 |
nicklas |
/** Unsigned byte column */ |
11 |
13 Sep 07 |
nicklas |
132 |
class UByteColumn extends ColumnInfo { |
11 |
13 Sep 07 |
nicklas |
133 |
public UByteColumn(String name_) { |
11 |
13 Sep 07 |
nicklas |
134 |
super(name_, UByteColType, DataSizes.CHAR_SIZE, 1, 0); |
11 |
13 Sep 07 |
nicklas |
135 |
} |
11 |
13 Sep 07 |
nicklas |
136 |
} |
11 |
13 Sep 07 |
nicklas |
137 |
|
11 |
13 Sep 07 |
nicklas |
/** Short column */ |
11 |
13 Sep 07 |
nicklas |
139 |
class ShortColumn extends ColumnInfo { |
11 |
13 Sep 07 |
nicklas |
140 |
public ShortColumn(String name_) { |
11 |
13 Sep 07 |
nicklas |
141 |
super(name_, ShortColType, DataSizes.SHORT_SIZE, 1, 0); |
11 |
13 Sep 07 |
nicklas |
142 |
} |
11 |
13 Sep 07 |
nicklas |
143 |
} |
11 |
13 Sep 07 |
nicklas |
144 |
|
11 |
13 Sep 07 |
nicklas |
/** Unsigned short column */ |
11 |
13 Sep 07 |
nicklas |
146 |
class UShortColumn extends ColumnInfo { |
11 |
13 Sep 07 |
nicklas |
147 |
public UShortColumn(String name_) { |
11 |
13 Sep 07 |
nicklas |
148 |
super(name_, UShortColType, DataSizes.SHORT_SIZE, 1, 0); |
11 |
13 Sep 07 |
nicklas |
149 |
} |
11 |
13 Sep 07 |
nicklas |
150 |
} |
11 |
13 Sep 07 |
nicklas |
151 |
|
11 |
13 Sep 07 |
nicklas |
/** Int (int32_t) column */ |
11 |
13 Sep 07 |
nicklas |
153 |
class IntColumn extends ColumnInfo { |
11 |
13 Sep 07 |
nicklas |
154 |
public IntColumn(String name_) { |
11 |
13 Sep 07 |
nicklas |
155 |
super(name_, IntColType, DataSizes.INT_SIZE, 1, 0); |
11 |
13 Sep 07 |
nicklas |
156 |
} |
11 |
13 Sep 07 |
nicklas |
157 |
}; |
11 |
13 Sep 07 |
nicklas |
158 |
|
11 |
13 Sep 07 |
nicklas |
/** Unsigned int (u_int32_t) column */ |
11 |
13 Sep 07 |
nicklas |
160 |
class UIntColumn extends ColumnInfo { |
11 |
13 Sep 07 |
nicklas |
161 |
public UIntColumn(String name_) { |
11 |
13 Sep 07 |
nicklas |
162 |
super(name_, UIntColType, DataSizes.INT_SIZE, 1, 0); |
11 |
13 Sep 07 |
nicklas |
163 |
} |
11 |
13 Sep 07 |
nicklas |
164 |
}; |
11 |
13 Sep 07 |
nicklas |
165 |
|
11 |
13 Sep 07 |
nicklas |
/** Float column */ |
11 |
13 Sep 07 |
nicklas |
167 |
class FloatColumn extends ColumnInfo { |
11 |
13 Sep 07 |
nicklas |
168 |
public FloatColumn(String name_) { |
11 |
13 Sep 07 |
nicklas |
169 |
super(name_, FloatColType, DataSizes.FLOAT_SIZE, 1, 0); |
11 |
13 Sep 07 |
nicklas |
170 |
} |
11 |
13 Sep 07 |
nicklas |
171 |
}; |
11 |
13 Sep 07 |
nicklas |
172 |
|
11 |
13 Sep 07 |
nicklas |
/** ASCII string column */ |
11 |
13 Sep 07 |
nicklas |
174 |
class ASCIIColumn extends ColumnInfo { |
11 |
13 Sep 07 |
nicklas |
175 |
public ASCIIColumn(String name_, int maxLn) { |
11 |
13 Sep 07 |
nicklas |
176 |
super(name_, ASCIICharColType, DataSizes.CHAR_SIZE, maxLn, 4); |
11 |
13 Sep 07 |
nicklas |
177 |
} |
11 |
13 Sep 07 |
nicklas |
178 |
}; |
11 |
13 Sep 07 |
nicklas |
179 |
|
11 |
13 Sep 07 |
nicklas |
/* Unicode string column */ |
11 |
13 Sep 07 |
nicklas |
181 |
class UnicodeColumn extends ColumnInfo { |
11 |
13 Sep 07 |
nicklas |
182 |
public UnicodeColumn(String name_, int maxLn) { |
11 |
13 Sep 07 |
nicklas |
183 |
super(name_, UnicodeCharColType, DataSizes.SHORT_SIZE, maxLn, 4); |
11 |
13 Sep 07 |
nicklas |
184 |
} |
11 |
13 Sep 07 |
nicklas |
185 |
}; |
11 |
13 Sep 07 |
nicklas |
186 |
|