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 |
import affymetrix.calvin.utils.*; |
11 |
13 Sep 07 |
nicklas |
26 |
import affymetrix.calvin.parameter.*; |
11 |
13 Sep 07 |
nicklas |
27 |
|
11 |
13 Sep 07 |
nicklas |
28 |
/** |
11 |
13 Sep 07 |
nicklas |
29 |
* |
11 |
13 Sep 07 |
nicklas |
* @author ljevon |
11 |
13 Sep 07 |
nicklas |
31 |
*/ |
11 |
13 Sep 07 |
nicklas |
32 |
public class GenericDataHeader { |
11 |
13 Sep 07 |
nicklas |
33 |
|
11 |
13 Sep 07 |
nicklas |
/** Creates a new instance of GenericDataHeader */ |
11 |
13 Sep 07 |
nicklas |
35 |
public GenericDataHeader() { |
11 |
13 Sep 07 |
nicklas |
36 |
clear(); |
11 |
13 Sep 07 |
nicklas |
37 |
} |
11 |
13 Sep 07 |
nicklas |
38 |
|
11 |
13 Sep 07 |
nicklas |
39 |
/** */ |
11 |
13 Sep 07 |
nicklas |
40 |
private String fileTypeId; |
11 |
13 Sep 07 |
nicklas |
41 |
/** */ |
11 |
13 Sep 07 |
nicklas |
42 |
private AffymetrixGuidType fileId; |
11 |
13 Sep 07 |
nicklas |
43 |
/** */ |
11 |
13 Sep 07 |
nicklas |
44 |
private String fileCreationTime; |
11 |
13 Sep 07 |
nicklas |
45 |
/** */ |
11 |
13 Sep 07 |
nicklas |
46 |
private String locale; |
11 |
13 Sep 07 |
nicklas |
47 |
/** */ |
11 |
13 Sep 07 |
nicklas |
48 |
private Vector /*ParameterNameValue*/ nameValParams; |
11 |
13 Sep 07 |
nicklas |
49 |
/** */ |
11 |
13 Sep 07 |
nicklas |
50 |
private Vector /*GenericDataHeader*/ genericDataHdrs; |
11 |
13 Sep 07 |
nicklas |
51 |
|
11 |
13 Sep 07 |
nicklas |
52 |
/** */ |
11 |
13 Sep 07 |
nicklas |
53 |
public void clear() { |
11 |
13 Sep 07 |
nicklas |
54 |
fileTypeId = ""; |
11 |
13 Sep 07 |
nicklas |
55 |
fileId = null; |
11 |
13 Sep 07 |
nicklas |
56 |
fileCreationTime = ""; |
11 |
13 Sep 07 |
nicklas |
57 |
nameValParams = null; |
11 |
13 Sep 07 |
nicklas |
58 |
genericDataHdrs= null; |
11 |
13 Sep 07 |
nicklas |
59 |
locale = AffymetrixParameterConsts.US_ENGLISH_LOCALE; |
11 |
13 Sep 07 |
nicklas |
60 |
} |
11 |
13 Sep 07 |
nicklas |
61 |
/** */ |
11 |
13 Sep 07 |
nicklas |
62 |
public void setFileTypeId(String p) { fileTypeId = p; } |
11 |
13 Sep 07 |
nicklas |
63 |
/** */ |
11 |
13 Sep 07 |
nicklas |
64 |
public String getFileTypeId() { return fileTypeId; } |
11 |
13 Sep 07 |
nicklas |
65 |
/** */ |
11 |
13 Sep 07 |
nicklas |
66 |
public void setFileId(AffymetrixGuidType p) { fileId = p; } |
11 |
13 Sep 07 |
nicklas |
67 |
/** */ |
11 |
13 Sep 07 |
nicklas |
68 |
public AffymetrixGuidType getFileId() { return fileId; } |
11 |
13 Sep 07 |
nicklas |
69 |
/** */ |
11 |
13 Sep 07 |
nicklas |
70 |
public void setFileCreationTime(String f) { fileCreationTime = f; } |
11 |
13 Sep 07 |
nicklas |
71 |
/** */ |
11 |
13 Sep 07 |
nicklas |
72 |
public String getFileCreationTime() { return fileCreationTime; } |
11 |
13 Sep 07 |
nicklas |
73 |
/** */ |
11 |
13 Sep 07 |
nicklas |
74 |
public void setLocale(String p) { locale = p; } |
11 |
13 Sep 07 |
nicklas |
75 |
/** */ |
11 |
13 Sep 07 |
nicklas |
76 |
public String getLocale() { return locale; } |
11 |
13 Sep 07 |
nicklas |
77 |
/** */ |
11 |
13 Sep 07 |
nicklas |
78 |
public void addNameValParam(ParameterNameValue p) { |
11 |
13 Sep 07 |
nicklas |
79 |
if (nameValParams == null) |
11 |
13 Sep 07 |
nicklas |
80 |
nameValParams = new Vector(); |
11 |
13 Sep 07 |
nicklas |
81 |
nameValParams.add(p); |
11 |
13 Sep 07 |
nicklas |
82 |
} |
11 |
13 Sep 07 |
nicklas |
83 |
/** */ |
11 |
13 Sep 07 |
nicklas |
84 |
public ParameterNameValue getNameValParam(int index) { |
11 |
13 Sep 07 |
nicklas |
85 |
if (nameValParams != null) |
11 |
13 Sep 07 |
nicklas |
86 |
return (ParameterNameValue) nameValParams.elementAt(index); |
11 |
13 Sep 07 |
nicklas |
87 |
return null; |
11 |
13 Sep 07 |
nicklas |
88 |
} |
11 |
13 Sep 07 |
nicklas |
89 |
/** */ |
11 |
13 Sep 07 |
nicklas |
90 |
public int getNameValParamCnt() { |
11 |
13 Sep 07 |
nicklas |
91 |
if (nameValParams != null) |
11 |
13 Sep 07 |
nicklas |
92 |
return nameValParams.size(); |
11 |
13 Sep 07 |
nicklas |
93 |
return 0; |
11 |
13 Sep 07 |
nicklas |
94 |
} |
11 |
13 Sep 07 |
nicklas |
95 |
/** */ |
11 |
13 Sep 07 |
nicklas |
96 |
public Vector getNameValParams() { return nameValParams; } |
11 |
13 Sep 07 |
nicklas |
97 |
/** */ |
11 |
13 Sep 07 |
nicklas |
98 |
public int getParentCnt() { |
11 |
13 Sep 07 |
nicklas |
99 |
if (genericDataHdrs != null) |
11 |
13 Sep 07 |
nicklas |
100 |
return genericDataHdrs.size(); |
11 |
13 Sep 07 |
nicklas |
101 |
return 0; |
11 |
13 Sep 07 |
nicklas |
102 |
} |
11 |
13 Sep 07 |
nicklas |
103 |
/** */ |
11 |
13 Sep 07 |
nicklas |
104 |
public void addParent(GenericDataHeader hdr) { |
11 |
13 Sep 07 |
nicklas |
105 |
if (genericDataHdrs == null) |
11 |
13 Sep 07 |
nicklas |
106 |
genericDataHdrs = new Vector(); |
11 |
13 Sep 07 |
nicklas |
107 |
genericDataHdrs.add(hdr); |
11 |
13 Sep 07 |
nicklas |
108 |
} |
11 |
13 Sep 07 |
nicklas |
109 |
/** */ |
11 |
13 Sep 07 |
nicklas |
110 |
public GenericDataHeader getParent(int index) { |
11 |
13 Sep 07 |
nicklas |
111 |
if (genericDataHdrs != null) |
11 |
13 Sep 07 |
nicklas |
112 |
return (GenericDataHeader) genericDataHdrs.elementAt(index); |
11 |
13 Sep 07 |
nicklas |
113 |
return null; |
11 |
13 Sep 07 |
nicklas |
114 |
} |
11 |
13 Sep 07 |
nicklas |
115 |
/** */ |
11 |
13 Sep 07 |
nicklas |
116 |
public Vector getParents() { return genericDataHdrs; } |
11 |
13 Sep 07 |
nicklas |
/** Finds a ParameterNameValue by name in the nameValPairs collection |
11 |
13 Sep 07 |
nicklas |
* @param name The name of the NameValPair to find |
11 |
13 Sep 07 |
nicklas |
* @return Reference to a ParameterNameValue with the found ParameterNameValue, null if not found. |
11 |
13 Sep 07 |
nicklas |
120 |
*/ |
11 |
13 Sep 07 |
nicklas |
121 |
public ParameterNameValue findNameValParam(String name) { |
11 |
13 Sep 07 |
nicklas |
122 |
int n = getNameValParamCnt(); |
11 |
13 Sep 07 |
nicklas |
123 |
for (int i=0; i<n; i++) |
11 |
13 Sep 07 |
nicklas |
124 |
{ |
11 |
13 Sep 07 |
nicklas |
125 |
ParameterNameValue param = getNameValParam(i); |
11 |
13 Sep 07 |
nicklas |
126 |
if (name.compareTo(param.getName()) == 0) |
11 |
13 Sep 07 |
nicklas |
127 |
return param; |
11 |
13 Sep 07 |
nicklas |
128 |
} |
11 |
13 Sep 07 |
nicklas |
129 |
return null; |
11 |
13 Sep 07 |
nicklas |
130 |
} |
11 |
13 Sep 07 |
nicklas |
/** Find an immediate parent GenericDataHeader based on file type id. Does not search grand-parents or above. |
11 |
13 Sep 07 |
nicklas |
* @param fileTypeId The fileTypeId of the parent header to find. |
11 |
13 Sep 07 |
nicklas |
* @return Returns a pointer to the parent GenericDataHeader if found, otherwise returns 0. |
11 |
13 Sep 07 |
nicklas |
134 |
*/ |
11 |
13 Sep 07 |
nicklas |
135 |
public GenericDataHeader findParent(String fileTypeId) { |
11 |
13 Sep 07 |
nicklas |
136 |
Vector parents = getParents(); |
11 |
13 Sep 07 |
nicklas |
137 |
for (int i=0; i<parents.size(); i++) |
11 |
13 Sep 07 |
nicklas |
138 |
{ |
11 |
13 Sep 07 |
nicklas |
139 |
GenericDataHeader p = (GenericDataHeader) parents.elementAt(i); |
11 |
13 Sep 07 |
nicklas |
140 |
if (fileTypeId.compareTo(p.getFileTypeId()) == 0) |
11 |
13 Sep 07 |
nicklas |
141 |
return p; |
11 |
13 Sep 07 |
nicklas |
142 |
} |
11 |
13 Sep 07 |
nicklas |
143 |
return null; |
11 |
13 Sep 07 |
nicklas |
144 |
} |
11 |
13 Sep 07 |
nicklas |
145 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets all ParameterNameValue where the name starts with a given string. |
11 |
13 Sep 07 |
nicklas |
* @param beginsWith The string that the beginning of the ParameterNameValue name needs to match. |
11 |
13 Sep 07 |
nicklas |
* @return A result vector of ParameterNameValues where the name begins with the beginsWith argument. |
11 |
13 Sep 07 |
nicklas |
149 |
*/ |
11 |
13 Sep 07 |
nicklas |
150 |
public Vector getNameValParamsBeginsWith(String beginsWith) { |
11 |
13 Sep 07 |
nicklas |
151 |
|
11 |
13 Sep 07 |
nicklas |
152 |
Vector p = null; |
11 |
13 Sep 07 |
nicklas |
153 |
int n = getNameValParamCnt(); |
11 |
13 Sep 07 |
nicklas |
154 |
for (int i=0; i<n; i++) |
11 |
13 Sep 07 |
nicklas |
155 |
{ |
11 |
13 Sep 07 |
nicklas |
156 |
ParameterNameValue param = getNameValParam(i); |
11 |
13 Sep 07 |
nicklas |
157 |
if (param.getName().startsWith(beginsWith) == true) |
11 |
13 Sep 07 |
nicklas |
158 |
{ |
11 |
13 Sep 07 |
nicklas |
159 |
if (p == null) |
11 |
13 Sep 07 |
nicklas |
160 |
p = new Vector(); |
11 |
13 Sep 07 |
nicklas |
161 |
p.add(param); |
11 |
13 Sep 07 |
nicklas |
162 |
} |
11 |
13 Sep 07 |
nicklas |
163 |
} |
11 |
13 Sep 07 |
nicklas |
164 |
return p; |
11 |
13 Sep 07 |
nicklas |
165 |
} |
11 |
13 Sep 07 |
nicklas |
166 |
|
11 |
13 Sep 07 |
nicklas |
167 |
} |