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 java.util.*; |
11 |
13 Sep 07 |
nicklas |
25 |
|
11 |
13 Sep 07 |
nicklas |
/** This class defines a data container for the generic file header */ |
11 |
13 Sep 07 |
nicklas |
27 |
public class FileHeader { |
11 |
13 Sep 07 |
nicklas |
28 |
|
11 |
13 Sep 07 |
nicklas |
/** The magic number for calvin files. */ |
11 |
13 Sep 07 |
nicklas |
30 |
static private final byte MAGIC_NUM = 59; |
11 |
13 Sep 07 |
nicklas |
31 |
|
11 |
13 Sep 07 |
nicklas |
/** The version number for calvin files. */ |
11 |
13 Sep 07 |
nicklas |
33 |
static private final byte VERSION = 1; |
11 |
13 Sep 07 |
nicklas |
34 |
|
11 |
13 Sep 07 |
nicklas |
/** Creates a new instance of FileHeader */ |
11 |
13 Sep 07 |
nicklas |
36 |
public FileHeader() { |
11 |
13 Sep 07 |
nicklas |
37 |
magic = MAGIC_NUM; |
11 |
13 Sep 07 |
nicklas |
38 |
version = VERSION; |
11 |
13 Sep 07 |
nicklas |
39 |
} |
11 |
13 Sep 07 |
nicklas |
40 |
|
11 |
13 Sep 07 |
nicklas |
/** filename */ |
11 |
13 Sep 07 |
nicklas |
42 |
private String filename; |
11 |
13 Sep 07 |
nicklas |
43 |
|
11 |
13 Sep 07 |
nicklas |
44 |
private byte magic; |
11 |
13 Sep 07 |
nicklas |
45 |
|
11 |
13 Sep 07 |
nicklas |
46 |
private byte version; |
11 |
13 Sep 07 |
nicklas |
47 |
|
11 |
13 Sep 07 |
nicklas |
48 |
private Vector /*DataGroupHdr*/ dataGroupHdrs; |
11 |
13 Sep 07 |
nicklas |
49 |
|
11 |
13 Sep 07 |
nicklas |
50 |
private GenericDataHeader genericHdr; |
11 |
13 Sep 07 |
nicklas |
51 |
|
11 |
13 Sep 07 |
nicklas |
/** Number of data dataGroups in the file */ |
11 |
13 Sep 07 |
nicklas |
53 |
private int numDataGroups; |
11 |
13 Sep 07 |
nicklas |
54 |
|
11 |
13 Sep 07 |
nicklas |
/** Position of the first DataGroup. */ |
11 |
13 Sep 07 |
nicklas |
56 |
private int firstDataGroupFilePos; |
11 |
13 Sep 07 |
nicklas |
57 |
|
11 |
13 Sep 07 |
nicklas |
58 |
public void clear() { |
11 |
13 Sep 07 |
nicklas |
59 |
dataGroupHdrs=null; |
11 |
13 Sep 07 |
nicklas |
60 |
genericHdr=null; |
11 |
13 Sep 07 |
nicklas |
61 |
numDataGroups = 0; |
11 |
13 Sep 07 |
nicklas |
62 |
firstDataGroupFilePos = 0; |
11 |
13 Sep 07 |
nicklas |
63 |
} |
11 |
13 Sep 07 |
nicklas |
64 |
|
11 |
13 Sep 07 |
nicklas |
65 |
public void setFilename(String p) { filename = p; } |
11 |
13 Sep 07 |
nicklas |
66 |
|
11 |
13 Sep 07 |
nicklas |
67 |
public String getFilename() { return filename; } |
11 |
13 Sep 07 |
nicklas |
68 |
|
11 |
13 Sep 07 |
nicklas |
69 |
public byte getMagicNumber() { return magic; } |
11 |
13 Sep 07 |
nicklas |
70 |
|
11 |
13 Sep 07 |
nicklas |
71 |
public byte getVersion() { return version; } |
11 |
13 Sep 07 |
nicklas |
72 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the number of DataGroupHeaders added */ |
11 |
13 Sep 07 |
nicklas |
74 |
public int getDataGroupCnt() { |
11 |
13 Sep 07 |
nicklas |
75 |
if (dataGroupHdrs != null) |
11 |
13 Sep 07 |
nicklas |
76 |
return dataGroupHdrs.size(); |
11 |
13 Sep 07 |
nicklas |
77 |
return 0; |
11 |
13 Sep 07 |
nicklas |
78 |
} |
11 |
13 Sep 07 |
nicklas |
79 |
|
11 |
13 Sep 07 |
nicklas |
80 |
public void addDataGroupHdr(DataGroupHeader p) { |
11 |
13 Sep 07 |
nicklas |
81 |
if (dataGroupHdrs == null) |
11 |
13 Sep 07 |
nicklas |
82 |
dataGroupHdrs = new Vector(); |
11 |
13 Sep 07 |
nicklas |
83 |
dataGroupHdrs.add(p); |
11 |
13 Sep 07 |
nicklas |
84 |
} |
11 |
13 Sep 07 |
nicklas |
85 |
|
11 |
13 Sep 07 |
nicklas |
/** Get a DataGroupHeader by index. Max index < GetDataGroupCnt */ |
11 |
13 Sep 07 |
nicklas |
87 |
public DataGroupHeader getDataGroup(int index) { |
11 |
13 Sep 07 |
nicklas |
88 |
if (dataGroupHdrs != null) |
11 |
13 Sep 07 |
nicklas |
89 |
return (DataGroupHeader) dataGroupHdrs.elementAt(index); |
11 |
13 Sep 07 |
nicklas |
90 |
return null; |
11 |
13 Sep 07 |
nicklas |
91 |
} |
11 |
13 Sep 07 |
nicklas |
92 |
|
11 |
13 Sep 07 |
nicklas |
93 |
public void setGenericDataHdr(GenericDataHeader p) { genericHdr = p; } |
11 |
13 Sep 07 |
nicklas |
94 |
|
11 |
13 Sep 07 |
nicklas |
95 |
public GenericDataHeader getGenericDataHdr() { return genericHdr; } |
11 |
13 Sep 07 |
nicklas |
96 |
|
11 |
13 Sep 07 |
nicklas |
/** Finds a DataGroupHeader by name. |
11 |
13 Sep 07 |
nicklas |
* @param name The name of the DataGroup |
11 |
13 Sep 07 |
nicklas |
* @return A pointer to the DataGroupHeader. If not found, the return is 0. |
11 |
13 Sep 07 |
nicklas |
100 |
*/ |
11 |
13 Sep 07 |
nicklas |
101 |
public DataGroupHeader findDataGroupHeader(String name) { |
11 |
13 Sep 07 |
nicklas |
102 |
int n = getDataGroupCnt(); |
11 |
13 Sep 07 |
nicklas |
103 |
for (int i=0; i<n; i++) |
11 |
13 Sep 07 |
nicklas |
104 |
{ |
11 |
13 Sep 07 |
nicklas |
105 |
DataGroupHeader h = getDataGroup(i); |
11 |
13 Sep 07 |
nicklas |
106 |
if (name.compareTo(h.getName()) == 0) |
11 |
13 Sep 07 |
nicklas |
107 |
return h; |
11 |
13 Sep 07 |
nicklas |
108 |
} |
11 |
13 Sep 07 |
nicklas |
109 |
return null; |
11 |
13 Sep 07 |
nicklas |
110 |
} |
11 |
13 Sep 07 |
nicklas |
111 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the number of DataGroups in a file.*/ |
11 |
13 Sep 07 |
nicklas |
113 |
public int getNumDataGroups() { return numDataGroups; } |
11 |
13 Sep 07 |
nicklas |
114 |
|
11 |
13 Sep 07 |
nicklas |
/** Set the number of DataGroups. Set when reading a file */ |
11 |
13 Sep 07 |
nicklas |
116 |
public void setNumDataGroups(int value) { numDataGroups = value; } |
11 |
13 Sep 07 |
nicklas |
117 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the file position to the first DataGroup */ |
11 |
13 Sep 07 |
nicklas |
119 |
public int getFirstDataGroupFilePos() { return firstDataGroupFilePos; } |
11 |
13 Sep 07 |
nicklas |
120 |
|
11 |
13 Sep 07 |
nicklas |
/** Set the file postion to the first DataGroup. Method should be protected. It is set when the object is being read. */ |
11 |
13 Sep 07 |
nicklas |
122 |
public void setFirstDataGroupFilePos(int value) { firstDataGroupFilePos = value; } |
11 |
13 Sep 07 |
nicklas |
123 |
} |