11 |
13 Sep 07 |
nicklas |
1 |
|
11 |
13 Sep 07 |
nicklas |
2 |
|
11 |
13 Sep 07 |
nicklas |
3 |
///////////////////////////////////////////////////////////////// |
11 |
13 Sep 07 |
nicklas |
4 |
// |
11 |
13 Sep 07 |
nicklas |
// Copyright (C) 2005 Affymetrix, Inc. |
11 |
13 Sep 07 |
nicklas |
6 |
// |
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 |
11 |
// |
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 |
16 |
// |
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 |
20 |
// |
11 |
13 Sep 07 |
nicklas |
21 |
///////////////////////////////////////////////////////////////// |
11 |
13 Sep 07 |
nicklas |
22 |
|
11 |
13 Sep 07 |
nicklas |
23 |
package affymetrix.calvin.parsers; |
11 |
13 Sep 07 |
nicklas |
24 |
|
11 |
13 Sep 07 |
nicklas |
25 |
import java.io.*; |
11 |
13 Sep 07 |
nicklas |
26 |
import affymetrix.calvin.data.*; |
11 |
13 Sep 07 |
nicklas |
27 |
import affymetrix.calvin.parameter.*; |
11 |
13 Sep 07 |
nicklas |
28 |
import affymetrix.calvin.utils.*; |
11 |
13 Sep 07 |
nicklas |
29 |
|
11 |
13 Sep 07 |
nicklas |
/** This class reads the GenericDataHeader from a file. */ |
11 |
13 Sep 07 |
nicklas |
31 |
public class GenericDataHeaderReader { |
11 |
13 Sep 07 |
nicklas |
32 |
|
11 |
13 Sep 07 |
nicklas |
/** Constructor |
11 |
13 Sep 07 |
nicklas |
* @param fis Open stream positioned at the start of the first GenericDataHeader. |
11 |
13 Sep 07 |
nicklas |
35 |
*/ |
15 |
17 Sep 07 |
nicklas |
36 |
public GenericDataHeaderReader(InputStream fis) { |
11 |
13 Sep 07 |
nicklas |
37 |
fileStream = fis; |
11 |
13 Sep 07 |
nicklas |
38 |
} |
11 |
13 Sep 07 |
nicklas |
39 |
|
11 |
13 Sep 07 |
nicklas |
/** Read the GenericDataHeader and all parent GenericDataHeaders from the input stream. |
11 |
13 Sep 07 |
nicklas |
* @param gdh Reference to the GenericDataHeader object to which to add the GenericDataHeader information. |
11 |
13 Sep 07 |
nicklas |
42 |
*/ |
11 |
13 Sep 07 |
nicklas |
43 |
public void read(GenericDataHeader gdh) { |
11 |
13 Sep 07 |
nicklas |
// Read data type identifier |
11 |
13 Sep 07 |
nicklas |
45 |
gdh.setFileTypeId(FileInput.ReadString8(fileStream)); |
11 |
13 Sep 07 |
nicklas |
46 |
|
11 |
13 Sep 07 |
nicklas |
// Read file identifier |
11 |
13 Sep 07 |
nicklas |
48 |
AffymetrixGuidType guid = new AffymetrixGuidType(); |
11 |
13 Sep 07 |
nicklas |
49 |
guid.setGuid(FileInput.ReadString8(fileStream)); |
11 |
13 Sep 07 |
nicklas |
50 |
gdh.setFileId(guid); |
11 |
13 Sep 07 |
nicklas |
51 |
|
11 |
13 Sep 07 |
nicklas |
// Read file creation time |
11 |
13 Sep 07 |
nicklas |
53 |
gdh.setFileCreationTime(FileInput.ReadString16(fileStream)); |
11 |
13 Sep 07 |
nicklas |
54 |
|
11 |
13 Sep 07 |
nicklas |
// Read locale |
11 |
13 Sep 07 |
nicklas |
56 |
gdh.setLocale(FileInput.ReadString16(fileStream)); |
11 |
13 Sep 07 |
nicklas |
57 |
|
11 |
13 Sep 07 |
nicklas |
// Read name value pairs |
11 |
13 Sep 07 |
nicklas |
59 |
int paramCount = FileInput.ReadUInt32(fileStream); |
11 |
13 Sep 07 |
nicklas |
60 |
for (int iparam = 0; iparam < paramCount; ++iparam) |
11 |
13 Sep 07 |
nicklas |
61 |
{ |
11 |
13 Sep 07 |
nicklas |
62 |
String name = FileInput.ReadString16(fileStream); |
11 |
13 Sep 07 |
nicklas |
63 |
byte[] mimeValue = FileInput.ReadBlob(fileStream); |
11 |
13 Sep 07 |
nicklas |
64 |
String type = FileInput.ReadString16(fileStream); |
11 |
13 Sep 07 |
nicklas |
65 |
ParameterNameValue nvt = new ParameterNameValue(name, mimeValue, mimeValue.length, type); |
11 |
13 Sep 07 |
nicklas |
66 |
gdh.addNameValParam(nvt); |
11 |
13 Sep 07 |
nicklas |
67 |
} |
11 |
13 Sep 07 |
nicklas |
68 |
|
11 |
13 Sep 07 |
nicklas |
// Read number of generic data parent header |
11 |
13 Sep 07 |
nicklas |
70 |
int numParents = FileInput.ReadUInt32(fileStream); |
11 |
13 Sep 07 |
nicklas |
71 |
|
11 |
13 Sep 07 |
nicklas |
// Read each parent header in turn - this needs to be recursive |
11 |
13 Sep 07 |
nicklas |
73 |
for (int iparent = 0; iparent < numParents; ++iparent) |
11 |
13 Sep 07 |
nicklas |
74 |
{ |
11 |
13 Sep 07 |
nicklas |
75 |
GenericDataHeader parentGDH = new GenericDataHeader(); |
11 |
13 Sep 07 |
nicklas |
76 |
read(parentGDH); |
11 |
13 Sep 07 |
nicklas |
77 |
gdh.addParent(parentGDH); |
11 |
13 Sep 07 |
nicklas |
78 |
} |
11 |
13 Sep 07 |
nicklas |
79 |
} |
11 |
13 Sep 07 |
nicklas |
80 |
|
11 |
13 Sep 07 |
nicklas |
/** A reference to the file stream. */ |
15 |
17 Sep 07 |
nicklas |
82 |
private InputStream fileStream; |
11 |
13 Sep 07 |
nicklas |
83 |
} |