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.parameter; |
11 |
13 Sep 07 |
nicklas |
23 |
|
11 |
13 Sep 07 |
nicklas |
24 |
import java.util.*; |
11 |
13 Sep 07 |
nicklas |
25 |
import affymetrix.portability.*; |
11 |
13 Sep 07 |
nicklas |
26 |
import java.nio.*; |
11 |
13 Sep 07 |
nicklas |
27 |
|
11 |
13 Sep 07 |
nicklas |
/** A class to hold a name/value/type/default/required attributes. */ |
11 |
13 Sep 07 |
nicklas |
29 |
public class ParameterNameValueDefaultRequired extends ParameterNameValue { |
11 |
13 Sep 07 |
nicklas |
30 |
|
11 |
13 Sep 07 |
nicklas |
/** Not set. */ |
11 |
13 Sep 07 |
nicklas |
32 |
public static final int NoParameterType=0; |
11 |
13 Sep 07 |
nicklas |
33 |
|
11 |
13 Sep 07 |
nicklas |
/** Integer stored in the MIME value. */ |
11 |
13 Sep 07 |
nicklas |
35 |
public static final int IntegerParameterType=1; |
11 |
13 Sep 07 |
nicklas |
36 |
|
11 |
13 Sep 07 |
nicklas |
/** Floating point stored in the MIME value. */ |
11 |
13 Sep 07 |
nicklas |
38 |
public static final int FloatParameterType=2; |
11 |
13 Sep 07 |
nicklas |
39 |
|
11 |
13 Sep 07 |
nicklas |
/** Text stored in the MIME value. */ |
11 |
13 Sep 07 |
nicklas |
41 |
public static final int TextParameterType=3; |
11 |
13 Sep 07 |
nicklas |
42 |
|
11 |
13 Sep 07 |
nicklas |
/** Date stored in the MIME value as text. */ |
11 |
13 Sep 07 |
nicklas |
44 |
public static final int DateParameterType=4; |
11 |
13 Sep 07 |
nicklas |
45 |
|
11 |
13 Sep 07 |
nicklas |
/** Time stored in the MIME value as text. */ |
11 |
13 Sep 07 |
nicklas |
47 |
public static final int TimeParameterType=5; |
11 |
13 Sep 07 |
nicklas |
48 |
|
11 |
13 Sep 07 |
nicklas |
/** DateTime stored in the MIME value as text. */ |
11 |
13 Sep 07 |
nicklas |
50 |
public static final int DateTimeParameterType=6; |
11 |
13 Sep 07 |
nicklas |
51 |
|
11 |
13 Sep 07 |
nicklas |
/** Controlled single selection stored in the MIME value as text. */ |
11 |
13 Sep 07 |
nicklas |
53 |
public static final int ControlSingleParameterType=7; |
11 |
13 Sep 07 |
nicklas |
54 |
|
11 |
13 Sep 07 |
nicklas |
/** Controlled multi selection stored in the controlMulti vector. */ |
11 |
13 Sep 07 |
nicklas |
56 |
public static final int ControlMultiParameterType=8; |
11 |
13 Sep 07 |
nicklas |
57 |
|
11 |
13 Sep 07 |
nicklas |
/** Converts the type to a string. |
11 |
13 Sep 07 |
nicklas |
* @param t The type. |
11 |
13 Sep 07 |
nicklas |
* @return The string representation. |
11 |
13 Sep 07 |
nicklas |
61 |
*/ |
11 |
13 Sep 07 |
nicklas |
62 |
public static String ParameterValueTypeToString(int t) { |
11 |
13 Sep 07 |
nicklas |
63 |
switch (t) |
11 |
13 Sep 07 |
nicklas |
64 |
{ |
11 |
13 Sep 07 |
nicklas |
65 |
case NoParameterType: |
11 |
13 Sep 07 |
nicklas |
66 |
return ""; |
11 |
13 Sep 07 |
nicklas |
67 |
|
11 |
13 Sep 07 |
nicklas |
68 |
case IntegerParameterType: |
11 |
13 Sep 07 |
nicklas |
69 |
return "Int"; |
11 |
13 Sep 07 |
nicklas |
70 |
|
11 |
13 Sep 07 |
nicklas |
71 |
case FloatParameterType: |
11 |
13 Sep 07 |
nicklas |
72 |
return "Float"; |
11 |
13 Sep 07 |
nicklas |
73 |
|
11 |
13 Sep 07 |
nicklas |
74 |
case TextParameterType: |
11 |
13 Sep 07 |
nicklas |
75 |
return "String"; |
11 |
13 Sep 07 |
nicklas |
76 |
|
11 |
13 Sep 07 |
nicklas |
77 |
case DateParameterType: |
11 |
13 Sep 07 |
nicklas |
78 |
return "Date"; |
11 |
13 Sep 07 |
nicklas |
79 |
|
11 |
13 Sep 07 |
nicklas |
80 |
case TimeParameterType: |
11 |
13 Sep 07 |
nicklas |
81 |
return "Time"; |
11 |
13 Sep 07 |
nicklas |
82 |
|
11 |
13 Sep 07 |
nicklas |
83 |
case DateTimeParameterType: |
11 |
13 Sep 07 |
nicklas |
84 |
return "DateTime"; |
11 |
13 Sep 07 |
nicklas |
85 |
|
11 |
13 Sep 07 |
nicklas |
86 |
case ControlSingleParameterType: |
11 |
13 Sep 07 |
nicklas |
87 |
return "SingleControl"; |
11 |
13 Sep 07 |
nicklas |
88 |
|
11 |
13 Sep 07 |
nicklas |
89 |
case ControlMultiParameterType: |
11 |
13 Sep 07 |
nicklas |
90 |
return "MultiControl"; |
11 |
13 Sep 07 |
nicklas |
91 |
|
11 |
13 Sep 07 |
nicklas |
92 |
default: |
11 |
13 Sep 07 |
nicklas |
93 |
return null; |
11 |
13 Sep 07 |
nicklas |
94 |
} |
11 |
13 Sep 07 |
nicklas |
95 |
} |
11 |
13 Sep 07 |
nicklas |
96 |
|
11 |
13 Sep 07 |
nicklas |
/** Converts the string to a type. |
11 |
13 Sep 07 |
nicklas |
* @param str The string representation. |
11 |
13 Sep 07 |
nicklas |
* @return The type. |
11 |
13 Sep 07 |
nicklas |
100 |
*/ |
11 |
13 Sep 07 |
nicklas |
101 |
public static int ParameterValueTypeFromString(String str) { |
11 |
13 Sep 07 |
nicklas |
102 |
if (str.compareTo("Int") == 0) |
11 |
13 Sep 07 |
nicklas |
103 |
return IntegerParameterType; |
11 |
13 Sep 07 |
nicklas |
104 |
|
11 |
13 Sep 07 |
nicklas |
105 |
else if (str.compareTo("Float") == 0) |
11 |
13 Sep 07 |
nicklas |
106 |
return FloatParameterType; |
11 |
13 Sep 07 |
nicklas |
107 |
|
11 |
13 Sep 07 |
nicklas |
108 |
else if (str.compareTo("String") == 0) |
11 |
13 Sep 07 |
nicklas |
109 |
return TextParameterType; |
11 |
13 Sep 07 |
nicklas |
110 |
|
11 |
13 Sep 07 |
nicklas |
111 |
else if (str.compareTo("Date") == 0) |
11 |
13 Sep 07 |
nicklas |
112 |
return DateParameterType; |
11 |
13 Sep 07 |
nicklas |
113 |
|
11 |
13 Sep 07 |
nicklas |
114 |
else if (str.compareTo("Time") == 0) |
11 |
13 Sep 07 |
nicklas |
115 |
return TimeParameterType; |
11 |
13 Sep 07 |
nicklas |
116 |
|
11 |
13 Sep 07 |
nicklas |
117 |
else if (str.compareTo("DateTime") == 0) |
11 |
13 Sep 07 |
nicklas |
118 |
return DateTimeParameterType; |
11 |
13 Sep 07 |
nicklas |
119 |
|
11 |
13 Sep 07 |
nicklas |
120 |
else if (str.compareTo("SingleControl") == 0) |
11 |
13 Sep 07 |
nicklas |
121 |
return ControlSingleParameterType; |
11 |
13 Sep 07 |
nicklas |
122 |
|
11 |
13 Sep 07 |
nicklas |
123 |
else if (str.compareTo("MultiControl") == 0) |
11 |
13 Sep 07 |
nicklas |
124 |
return ControlMultiParameterType; |
11 |
13 Sep 07 |
nicklas |
125 |
|
11 |
13 Sep 07 |
nicklas |
126 |
else |
11 |
13 Sep 07 |
nicklas |
127 |
return NoParameterType; |
11 |
13 Sep 07 |
nicklas |
128 |
} |
11 |
13 Sep 07 |
nicklas |
129 |
|
11 |
13 Sep 07 |
nicklas |
/** The MIME value of the default parameter */ |
11 |
13 Sep 07 |
nicklas |
131 |
private MIMEValue defaultValue; |
11 |
13 Sep 07 |
nicklas |
132 |
|
11 |
13 Sep 07 |
nicklas |
/** A flag to indicate if a default exist. */ |
11 |
13 Sep 07 |
nicklas |
134 |
private boolean hasDefault; |
11 |
13 Sep 07 |
nicklas |
135 |
|
11 |
13 Sep 07 |
nicklas |
/** A flag to indicate if the parameter is required. */ |
11 |
13 Sep 07 |
nicklas |
137 |
private boolean required; |
11 |
13 Sep 07 |
nicklas |
138 |
|
11 |
13 Sep 07 |
nicklas |
/** A vector of parameter values for controlled vocabulary. */ |
11 |
13 Sep 07 |
nicklas |
140 |
private Vector /*String*/ controlled; |
11 |
13 Sep 07 |
nicklas |
141 |
|
11 |
13 Sep 07 |
nicklas |
/** A vector of multi-selected controlled values. */ |
11 |
13 Sep 07 |
nicklas |
143 |
private Vector /*String*/ controlMultiValues; |
11 |
13 Sep 07 |
nicklas |
144 |
|
11 |
13 Sep 07 |
nicklas |
/** The type of value stored. */ |
11 |
13 Sep 07 |
nicklas |
146 |
private int valueType; |
11 |
13 Sep 07 |
nicklas |
147 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the parameter type. */ |
11 |
13 Sep 07 |
nicklas |
149 |
private void setParameterType() { |
11 |
13 Sep 07 |
nicklas |
150 |
int paramType = getParameterType(); |
11 |
13 Sep 07 |
nicklas |
151 |
switch (paramType) |
11 |
13 Sep 07 |
nicklas |
152 |
{ |
11 |
13 Sep 07 |
nicklas |
153 |
case Int8Type: |
11 |
13 Sep 07 |
nicklas |
154 |
case UInt8Type: |
11 |
13 Sep 07 |
nicklas |
155 |
case Int16Type: |
11 |
13 Sep 07 |
nicklas |
156 |
case UInt16Type: |
11 |
13 Sep 07 |
nicklas |
157 |
case Int32Type: |
11 |
13 Sep 07 |
nicklas |
158 |
case UInt32Type: |
11 |
13 Sep 07 |
nicklas |
159 |
valueType = IntegerParameterType; |
11 |
13 Sep 07 |
nicklas |
160 |
break; |
11 |
13 Sep 07 |
nicklas |
161 |
|
11 |
13 Sep 07 |
nicklas |
162 |
case FloatType: |
11 |
13 Sep 07 |
nicklas |
163 |
valueType = FloatParameterType; |
11 |
13 Sep 07 |
nicklas |
164 |
break; |
11 |
13 Sep 07 |
nicklas |
165 |
|
11 |
13 Sep 07 |
nicklas |
166 |
case TextType: |
11 |
13 Sep 07 |
nicklas |
167 |
case AsciiType: |
11 |
13 Sep 07 |
nicklas |
168 |
valueType = TextParameterType; |
11 |
13 Sep 07 |
nicklas |
169 |
break; |
11 |
13 Sep 07 |
nicklas |
170 |
|
11 |
13 Sep 07 |
nicklas |
171 |
default: |
11 |
13 Sep 07 |
nicklas |
172 |
break; |
11 |
13 Sep 07 |
nicklas |
173 |
} |
11 |
13 Sep 07 |
nicklas |
174 |
} |
11 |
13 Sep 07 |
nicklas |
175 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets a vector of multi-selected controlled values. |
11 |
13 Sep 07 |
nicklas |
* @return The multi-selected controlled values. |
11 |
13 Sep 07 |
nicklas |
178 |
*/ |
11 |
13 Sep 07 |
nicklas |
179 |
public Vector /*String*/ getControlMultiValues() { return controlMultiValues; } |
11 |
13 Sep 07 |
nicklas |
180 |
|
11 |
13 Sep 07 |
nicklas |
/** The type of value stored. */ |
11 |
13 Sep 07 |
nicklas |
182 |
public int getValueType() { return valueType; } |
11 |
13 Sep 07 |
nicklas |
183 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets a vector of parameter values for controlled vocabulary. |
11 |
13 Sep 07 |
nicklas |
* @return The vector of parameter values for controlled vocabulary. |
11 |
13 Sep 07 |
nicklas |
186 |
*/ |
11 |
13 Sep 07 |
nicklas |
187 |
public Vector /*String*/ getControlledVocabulary() { return controlled; } |
11 |
13 Sep 07 |
nicklas |
188 |
|
11 |
13 Sep 07 |
nicklas |
/** Returns the mime value without interpretation. |
11 |
13 Sep 07 |
nicklas |
* @return MIME encoded string. |
11 |
13 Sep 07 |
nicklas |
191 |
*/ |
11 |
13 Sep 07 |
nicklas |
192 |
public MIMEValue getDefaultMIMEValue() { return defaultValue; } |
11 |
13 Sep 07 |
nicklas |
193 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the required flag. |
11 |
13 Sep 07 |
nicklas |
* @return The required flag. |
11 |
13 Sep 07 |
nicklas |
196 |
*/ |
11 |
13 Sep 07 |
nicklas |
197 |
public boolean getRequiredFlag() { return required; } |
11 |
13 Sep 07 |
nicklas |
198 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the required flag. |
11 |
13 Sep 07 |
nicklas |
* @param r The required flag. |
11 |
13 Sep 07 |
nicklas |
201 |
*/ |
11 |
13 Sep 07 |
nicklas |
202 |
public void setRequiredFlag(boolean r) { required=r; } |
11 |
13 Sep 07 |
nicklas |
203 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets a flag to indicate if a default exist. |
11 |
13 Sep 07 |
nicklas |
* @return The flag indicating if a default value exists. |
11 |
13 Sep 07 |
nicklas |
206 |
*/ |
11 |
13 Sep 07 |
nicklas |
207 |
public boolean getHasDefault() { return hasDefault; } |
11 |
13 Sep 07 |
nicklas |
208 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the flag to indicate if a default exist. |
11 |
13 Sep 07 |
nicklas |
* @param d The flag indicating if a default value exists. |
11 |
13 Sep 07 |
nicklas |
211 |
*/ |
11 |
13 Sep 07 |
nicklas |
212 |
public void setHasDefault(boolean d) { hasDefault=d; } |
11 |
13 Sep 07 |
nicklas |
213 |
|
11 |
13 Sep 07 |
nicklas |
/** Defaultructor */ |
11 |
13 Sep 07 |
nicklas |
215 |
public ParameterNameValueDefaultRequired() { |
11 |
13 Sep 07 |
nicklas |
216 |
super(); |
11 |
13 Sep 07 |
nicklas |
217 |
required = false; |
11 |
13 Sep 07 |
nicklas |
218 |
hasDefault = false; |
11 |
13 Sep 07 |
nicklas |
219 |
valueType = NoParameterType; |
11 |
13 Sep 07 |
nicklas |
220 |
} |
11 |
13 Sep 07 |
nicklas |
221 |
|
11 |
13 Sep 07 |
nicklas |
/** MIMEructor. Useful when reading in from a file |
11 |
13 Sep 07 |
nicklas |
* @param n Parameter name |
11 |
13 Sep 07 |
nicklas |
* @param mimeValue MIME encoded value in a buffer |
11 |
13 Sep 07 |
nicklas |
* @param mimeValueSize The size in bytes of the MIME encoded value. |
11 |
13 Sep 07 |
nicklas |
* @param mimeType The MIME type. |
11 |
13 Sep 07 |
nicklas |
* @param defaultMimeValue The default MIME encoded value in a buffer. |
11 |
13 Sep 07 |
nicklas |
* @param defaultMimeValueSize The size in bytes of the default MIME encoded value. |
11 |
13 Sep 07 |
nicklas |
* @param req Flag to indicate if the parameter is required. |
11 |
13 Sep 07 |
nicklas |
230 |
*/ |
11 |
13 Sep 07 |
nicklas |
231 |
public ParameterNameValueDefaultRequired(String n, byte[] mimeValue, int mimeValueSize, String mimeType, byte[] defaultMimeValue, int defaultMimeValueSize, boolean req) { |
11 |
13 Sep 07 |
nicklas |
232 |
valueType = NoParameterType; |
11 |
13 Sep 07 |
nicklas |
233 |
name = n; |
11 |
13 Sep 07 |
nicklas |
234 |
value = new MIMEValue(mimeValue, mimeValueSize); |
11 |
13 Sep 07 |
nicklas |
235 |
type = mimeType; |
11 |
13 Sep 07 |
nicklas |
236 |
defaultValue = new MIMEValue(defaultMimeValue, defaultMimeValueSize); |
11 |
13 Sep 07 |
nicklas |
237 |
hasDefault = true; |
11 |
13 Sep 07 |
nicklas |
238 |
required = req; |
11 |
13 Sep 07 |
nicklas |
239 |
setParameterType(); |
11 |
13 Sep 07 |
nicklas |
240 |
} |
11 |
13 Sep 07 |
nicklas |
241 |
|
11 |
13 Sep 07 |
nicklas |
/** MIMEructor. Useful when reading in from a file |
11 |
13 Sep 07 |
nicklas |
* @param n Parameter name |
11 |
13 Sep 07 |
nicklas |
* @param mimeValue MIME encoded value |
11 |
13 Sep 07 |
nicklas |
* @param mimeType The MIME type. |
11 |
13 Sep 07 |
nicklas |
* @param defaultMimeValue The default MIME encoded value in a buffer. |
11 |
13 Sep 07 |
nicklas |
* @param req Flag to indicate if the parameter is required. |
11 |
13 Sep 07 |
nicklas |
248 |
*/ |
11 |
13 Sep 07 |
nicklas |
249 |
public ParameterNameValueDefaultRequired(String n, MIMEValue mimeValue, String mimeType, MIMEValue defaultMimeValue, boolean req) { |
11 |
13 Sep 07 |
nicklas |
250 |
valueType = NoParameterType; |
11 |
13 Sep 07 |
nicklas |
251 |
name = n; |
11 |
13 Sep 07 |
nicklas |
252 |
value = mimeValue; |
11 |
13 Sep 07 |
nicklas |
253 |
type = mimeType; |
11 |
13 Sep 07 |
nicklas |
254 |
hasDefault = true; |
11 |
13 Sep 07 |
nicklas |
255 |
defaultValue = defaultMimeValue; |
11 |
13 Sep 07 |
nicklas |
256 |
required = req; |
11 |
13 Sep 07 |
nicklas |
257 |
setParameterType(); |
11 |
13 Sep 07 |
nicklas |
258 |
} |
11 |
13 Sep 07 |
nicklas |
259 |
|
11 |
13 Sep 07 |
nicklas |
/** Converts default value to a string |
11 |
13 Sep 07 |
nicklas |
* @return A string representation of the default value |
11 |
13 Sep 07 |
nicklas |
262 |
*/ |
11 |
13 Sep 07 |
nicklas |
263 |
public String defaultToString() { |
11 |
13 Sep 07 |
nicklas |
264 |
switch(getParameterType()) |
11 |
13 Sep 07 |
nicklas |
265 |
{ |
11 |
13 Sep 07 |
nicklas |
266 |
case Int8Type: |
11 |
13 Sep 07 |
nicklas |
267 |
return String.valueOf(getDefaultValueInt8()); |
11 |
13 Sep 07 |
nicklas |
268 |
|
11 |
13 Sep 07 |
nicklas |
269 |
case Int16Type: |
11 |
13 Sep 07 |
nicklas |
270 |
return String.valueOf(getDefaultValueInt16()); |
11 |
13 Sep 07 |
nicklas |
271 |
|
11 |
13 Sep 07 |
nicklas |
272 |
case Int32Type: |
11 |
13 Sep 07 |
nicklas |
273 |
return String.valueOf(getDefaultValueInt32()); |
11 |
13 Sep 07 |
nicklas |
274 |
|
11 |
13 Sep 07 |
nicklas |
275 |
case UInt8Type: |
11 |
13 Sep 07 |
nicklas |
276 |
return String.valueOf(getDefaultValueUInt8()); |
11 |
13 Sep 07 |
nicklas |
277 |
|
11 |
13 Sep 07 |
nicklas |
278 |
case UInt16Type: |
11 |
13 Sep 07 |
nicklas |
279 |
return String.valueOf(getDefaultValueUInt16()); |
11 |
13 Sep 07 |
nicklas |
280 |
|
11 |
13 Sep 07 |
nicklas |
281 |
case UInt32Type: |
11 |
13 Sep 07 |
nicklas |
282 |
return String.valueOf(getDefaultValueUInt32()); |
11 |
13 Sep 07 |
nicklas |
283 |
|
11 |
13 Sep 07 |
nicklas |
284 |
case FloatType: |
11 |
13 Sep 07 |
nicklas |
285 |
return String.valueOf(getDefaultValueFloat()); |
11 |
13 Sep 07 |
nicklas |
286 |
|
11 |
13 Sep 07 |
nicklas |
287 |
case TextType: |
11 |
13 Sep 07 |
nicklas |
288 |
return getDefaultValueText(); |
11 |
13 Sep 07 |
nicklas |
289 |
|
11 |
13 Sep 07 |
nicklas |
290 |
case AsciiType: |
11 |
13 Sep 07 |
nicklas |
291 |
return getDefaultValueAscii(); |
11 |
13 Sep 07 |
nicklas |
292 |
} |
11 |
13 Sep 07 |
nicklas |
293 |
return null; |
11 |
13 Sep 07 |
nicklas |
294 |
} |
11 |
13 Sep 07 |
nicklas |
295 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets default value as a byte |
11 |
13 Sep 07 |
nicklas |
* @return Value of the parameter as an byte |
11 |
13 Sep 07 |
nicklas |
* @exception affymetrix_calvin_exceptions::ParameterMismatchException Parameter is not an byte |
11 |
13 Sep 07 |
nicklas |
299 |
*/ |
11 |
13 Sep 07 |
nicklas |
300 |
public byte getDefaultValueInt8() { return (byte)valueToInt(defaultValue); } |
11 |
13 Sep 07 |
nicklas |
301 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the default value as a byte |
11 |
13 Sep 07 |
nicklas |
* @param v The value |
11 |
13 Sep 07 |
nicklas |
304 |
*/ |
11 |
13 Sep 07 |
nicklas |
305 |
public void setDefaultValueInt8(byte v) { |
11 |
13 Sep 07 |
nicklas |
306 |
hasDefault = true; |
11 |
13 Sep 07 |
nicklas |
307 |
type = MIMEValue.Int8MIMEType; |
11 |
13 Sep 07 |
nicklas |
308 |
defaultValue = new MIMEValue(); |
11 |
13 Sep 07 |
nicklas |
309 |
intToValue(v, defaultValue); |
11 |
13 Sep 07 |
nicklas |
310 |
} |
11 |
13 Sep 07 |
nicklas |
311 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the default value as a u_byte |
11 |
13 Sep 07 |
nicklas |
* @return Value of the parameter as an u_byte |
11 |
13 Sep 07 |
nicklas |
* @exception affymetrix_calvin_exceptions::ParameterMismatchException Parameter is not a u_byte |
11 |
13 Sep 07 |
nicklas |
315 |
*/ |
11 |
13 Sep 07 |
nicklas |
316 |
public byte getDefaultValueUInt8() { return (byte)valueToInt(defaultValue); } |
11 |
13 Sep 07 |
nicklas |
317 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the default value as a u_byte |
11 |
13 Sep 07 |
nicklas |
* @param v The value |
11 |
13 Sep 07 |
nicklas |
320 |
*/ |
11 |
13 Sep 07 |
nicklas |
321 |
public void setDefaultValueUInt8(byte v) { |
11 |
13 Sep 07 |
nicklas |
322 |
hasDefault = true; |
11 |
13 Sep 07 |
nicklas |
323 |
type = MIMEValue.UInt8MIMEType; |
11 |
13 Sep 07 |
nicklas |
324 |
defaultValue = new MIMEValue(); |
11 |
13 Sep 07 |
nicklas |
325 |
intToValue(v, defaultValue); |
11 |
13 Sep 07 |
nicklas |
326 |
} |
11 |
13 Sep 07 |
nicklas |
327 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the default value as a short |
11 |
13 Sep 07 |
nicklas |
* @return Value of the parameter as an short |
11 |
13 Sep 07 |
nicklas |
* @exception affymetrix_calvin_exceptions::ParameterMismatchException Parameter is not an short |
11 |
13 Sep 07 |
nicklas |
331 |
*/ |
11 |
13 Sep 07 |
nicklas |
332 |
public short getDefaultValueInt16() { return (short)valueToInt(defaultValue); } |
11 |
13 Sep 07 |
nicklas |
333 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the default value as an short |
11 |
13 Sep 07 |
nicklas |
* @param v The value |
11 |
13 Sep 07 |
nicklas |
336 |
*/ |
11 |
13 Sep 07 |
nicklas |
337 |
public void setDefaultValueInt16(short v) { |
11 |
13 Sep 07 |
nicklas |
338 |
hasDefault = true; |
11 |
13 Sep 07 |
nicklas |
339 |
type = MIMEValue.Int16MIMEType; |
11 |
13 Sep 07 |
nicklas |
340 |
defaultValue = new MIMEValue(); |
11 |
13 Sep 07 |
nicklas |
341 |
intToValue(v, defaultValue); |
11 |
13 Sep 07 |
nicklas |
342 |
} |
11 |
13 Sep 07 |
nicklas |
343 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the default value as a u_short |
11 |
13 Sep 07 |
nicklas |
* @return Value of the parameter as an u_short |
11 |
13 Sep 07 |
nicklas |
* @exception affymetrix_calvin_exceptions::ParameterMismatchException Parameter is not a u_short |
11 |
13 Sep 07 |
nicklas |
347 |
*/ |
11 |
13 Sep 07 |
nicklas |
348 |
public short getDefaultValueUInt16() { return (short)valueToInt(defaultValue); } |
11 |
13 Sep 07 |
nicklas |
349 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the default value as a u_short |
11 |
13 Sep 07 |
nicklas |
* @param v The value |
11 |
13 Sep 07 |
nicklas |
352 |
*/ |
11 |
13 Sep 07 |
nicklas |
353 |
public void setDefaultValueUInt16(short v) { |
11 |
13 Sep 07 |
nicklas |
354 |
hasDefault = true; |
11 |
13 Sep 07 |
nicklas |
355 |
type = MIMEValue.UInt16MIMEType; |
11 |
13 Sep 07 |
nicklas |
356 |
defaultValue = new MIMEValue(); |
11 |
13 Sep 07 |
nicklas |
357 |
intToValue(v, defaultValue); |
11 |
13 Sep 07 |
nicklas |
358 |
} |
11 |
13 Sep 07 |
nicklas |
359 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the default value as a int |
11 |
13 Sep 07 |
nicklas |
* @return Value of the parameter as an int |
11 |
13 Sep 07 |
nicklas |
* @exception affymetrix_calvin_exceptions::ParameterMismatchException Parameter is not an int |
11 |
13 Sep 07 |
nicklas |
363 |
*/ |
11 |
13 Sep 07 |
nicklas |
364 |
public int getDefaultValueInt32() { return (int)valueToInt(defaultValue); } |
11 |
13 Sep 07 |
nicklas |
365 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the default value as an int |
11 |
13 Sep 07 |
nicklas |
* @param v The value |
11 |
13 Sep 07 |
nicklas |
368 |
*/ |
11 |
13 Sep 07 |
nicklas |
369 |
public void setDefaultValueInt32(int v) { |
11 |
13 Sep 07 |
nicklas |
370 |
hasDefault = true; |
11 |
13 Sep 07 |
nicklas |
371 |
type = MIMEValue.Int32MIMEType; |
11 |
13 Sep 07 |
nicklas |
372 |
defaultValue = new MIMEValue(); |
11 |
13 Sep 07 |
nicklas |
373 |
intToValue(v, defaultValue); |
11 |
13 Sep 07 |
nicklas |
374 |
} |
11 |
13 Sep 07 |
nicklas |
375 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the default value as a int |
11 |
13 Sep 07 |
nicklas |
* @return Value of the parameter as an int |
11 |
13 Sep 07 |
nicklas |
* @exception affymetrix_calvin_exceptions::ParameterMismatchException Parameter is not a int |
11 |
13 Sep 07 |
nicklas |
379 |
*/ |
11 |
13 Sep 07 |
nicklas |
380 |
public int getDefaultValueUInt32() { return (int)valueToInt(defaultValue); } |
11 |
13 Sep 07 |
nicklas |
381 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the default value as a int |
11 |
13 Sep 07 |
nicklas |
* @param v The value |
11 |
13 Sep 07 |
nicklas |
384 |
*/ |
11 |
13 Sep 07 |
nicklas |
385 |
public void setDefaultValueUInt32(int v) { |
11 |
13 Sep 07 |
nicklas |
386 |
hasDefault = true; |
11 |
13 Sep 07 |
nicklas |
387 |
type = MIMEValue.UInt32MIMEType; |
11 |
13 Sep 07 |
nicklas |
388 |
defaultValue = new MIMEValue(); |
11 |
13 Sep 07 |
nicklas |
389 |
intToValue(v, defaultValue); |
11 |
13 Sep 07 |
nicklas |
390 |
} |
11 |
13 Sep 07 |
nicklas |
391 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the default value as a float |
11 |
13 Sep 07 |
nicklas |
* @return Value of the parameter as an float |
11 |
13 Sep 07 |
nicklas |
* @exception affymetrix_calvin_exceptions::ParameterMismatchException Parameter is not a float |
11 |
13 Sep 07 |
nicklas |
395 |
*/ |
11 |
13 Sep 07 |
nicklas |
396 |
public float getDefaultValueFloat() { |
11 |
13 Sep 07 |
nicklas |
397 |
int ival = valueToInt(defaultValue); |
11 |
13 Sep 07 |
nicklas |
398 |
return Float.intBitsToFloat(ival); |
11 |
13 Sep 07 |
nicklas |
399 |
} |
11 |
13 Sep 07 |
nicklas |
400 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the default value as a float |
11 |
13 Sep 07 |
nicklas |
* @param v The value |
11 |
13 Sep 07 |
nicklas |
403 |
*/ |
11 |
13 Sep 07 |
nicklas |
404 |
public void setDefaultValueFloat(float v) { |
11 |
13 Sep 07 |
nicklas |
405 |
|
11 |
13 Sep 07 |
nicklas |
406 |
hasDefault = true; |
11 |
13 Sep 07 |
nicklas |
407 |
type = MIMEValue.FloatMIMEType; |
11 |
13 Sep 07 |
nicklas |
408 |
defaultValue = new MIMEValue(); |
11 |
13 Sep 07 |
nicklas |
409 |
intToValue(Float.floatToRawIntBits(v), defaultValue); |
11 |
13 Sep 07 |
nicklas |
410 |
} |
11 |
13 Sep 07 |
nicklas |
411 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the default value as a wstring |
11 |
13 Sep 07 |
nicklas |
* @return Value of the parameter as an wstring |
11 |
13 Sep 07 |
nicklas |
* @exception affymetrix_calvin_exceptions::ParameterMismatchException Parameter is not a text type |
11 |
13 Sep 07 |
nicklas |
415 |
*/ |
11 |
13 Sep 07 |
nicklas |
416 |
public String getDefaultValueText() { |
11 |
13 Sep 07 |
nicklas |
417 |
byte[] b = defaultValue.getBytes(); |
11 |
13 Sep 07 |
nicklas |
418 |
int len = defaultValue.size()/DataSizes.SHORT_SIZE; |
11 |
13 Sep 07 |
nicklas |
419 |
String str = ""; |
11 |
13 Sep 07 |
nicklas |
420 |
for (int ichar=0, ibyte=0; ichar<len; ichar++, ibyte+=2) |
11 |
13 Sep 07 |
nicklas |
421 |
{ |
11 |
13 Sep 07 |
nicklas |
422 |
if (b[ibyte] == 0 && b[ibyte+1] == 0) |
11 |
13 Sep 07 |
nicklas |
423 |
break; |
11 |
13 Sep 07 |
nicklas |
424 |
|
11 |
13 Sep 07 |
nicklas |
425 |
char c; |
11 |
13 Sep 07 |
nicklas |
426 |
if (b[ibyte] < 0) |
11 |
13 Sep 07 |
nicklas |
427 |
c = (char)((b[ibyte]+256) << 8); |
11 |
13 Sep 07 |
nicklas |
428 |
else |
11 |
13 Sep 07 |
nicklas |
429 |
c = (char)(b[ibyte] << 8); |
11 |
13 Sep 07 |
nicklas |
430 |
|
11 |
13 Sep 07 |
nicklas |
431 |
if (b[ibyte+1] < 0) |
11 |
13 Sep 07 |
nicklas |
432 |
c += (char)(b[ibyte+1] + 256); |
11 |
13 Sep 07 |
nicklas |
433 |
else |
11 |
13 Sep 07 |
nicklas |
434 |
c += (char)b[ibyte+1]; |
11 |
13 Sep 07 |
nicklas |
435 |
|
11 |
13 Sep 07 |
nicklas |
436 |
str += c; |
11 |
13 Sep 07 |
nicklas |
437 |
} |
11 |
13 Sep 07 |
nicklas |
438 |
return str.trim(); |
11 |
13 Sep 07 |
nicklas |
439 |
} |
11 |
13 Sep 07 |
nicklas |
440 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the default value as a text type. |
11 |
13 Sep 07 |
nicklas |
* @param v String representation of the default value. |
11 |
13 Sep 07 |
nicklas |
443 |
*/ |
11 |
13 Sep 07 |
nicklas |
444 |
public void setDefaultValueText(String v) { |
11 |
13 Sep 07 |
nicklas |
445 |
type = MIMEValue.TextMIMEType; |
11 |
13 Sep 07 |
nicklas |
446 |
defaultValue = new MIMEValue(); |
11 |
13 Sep 07 |
nicklas |
447 |
byte[] b = new byte[v.length()*DataSizes.SHORT_SIZE]; |
11 |
13 Sep 07 |
nicklas |
448 |
for (int ichar=0, ibyte=0; ichar<v.length(); ichar++, ibyte+=2) |
11 |
13 Sep 07 |
nicklas |
449 |
{ |
11 |
13 Sep 07 |
nicklas |
450 |
char c = v.charAt(ichar); |
11 |
13 Sep 07 |
nicklas |
451 |
b[ibyte] = (byte) (c >> 8); |
11 |
13 Sep 07 |
nicklas |
452 |
b[ibyte+1] = (byte) c; |
11 |
13 Sep 07 |
nicklas |
453 |
} |
11 |
13 Sep 07 |
nicklas |
454 |
defaultValue.setValue(b, v.length()*DataSizes.SHORT_SIZE); |
11 |
13 Sep 07 |
nicklas |
455 |
} |
11 |
13 Sep 07 |
nicklas |
456 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the default value as a string |
11 |
13 Sep 07 |
nicklas |
* @return Value of the parameter as an string |
11 |
13 Sep 07 |
nicklas |
* @exception affymetrix_calvin_exceptions::ParameterMismatchException Parameter is not a text type |
11 |
13 Sep 07 |
nicklas |
460 |
*/ |
11 |
13 Sep 07 |
nicklas |
461 |
public String getDefaultValueAscii() { |
11 |
13 Sep 07 |
nicklas |
462 |
byte[] b = defaultValue.getBytes(); |
11 |
13 Sep 07 |
nicklas |
463 |
int len = defaultValue.size(); |
11 |
13 Sep 07 |
nicklas |
464 |
String str = ""; |
11 |
13 Sep 07 |
nicklas |
465 |
for (int i = 0; i < len; ++i) |
11 |
13 Sep 07 |
nicklas |
466 |
{ |
11 |
13 Sep 07 |
nicklas |
467 |
if (b[i] == 0) |
11 |
13 Sep 07 |
nicklas |
468 |
break; |
11 |
13 Sep 07 |
nicklas |
469 |
str += (char)b[i]; |
11 |
13 Sep 07 |
nicklas |
470 |
} |
11 |
13 Sep 07 |
nicklas |
471 |
return str; |
11 |
13 Sep 07 |
nicklas |
472 |
} |
11 |
13 Sep 07 |
nicklas |
473 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the default value as a text type. |
11 |
13 Sep 07 |
nicklas |
* @param v String representation of the default value. |
11 |
13 Sep 07 |
nicklas |
476 |
*/ |
11 |
13 Sep 07 |
nicklas |
477 |
public void setDefaultValueAscii(String v) { |
11 |
13 Sep 07 |
nicklas |
478 |
type = MIMEValue.AsciiMIMEType; |
11 |
13 Sep 07 |
nicklas |
479 |
int len = v.length(); |
11 |
13 Sep 07 |
nicklas |
480 |
byte[] buf = new byte[len]; |
11 |
13 Sep 07 |
nicklas |
481 |
for (int i=0; i<len; i++) |
11 |
13 Sep 07 |
nicklas |
482 |
{ |
11 |
13 Sep 07 |
nicklas |
483 |
buf[i] = (byte)v.charAt(i); |
11 |
13 Sep 07 |
nicklas |
484 |
} |
11 |
13 Sep 07 |
nicklas |
485 |
defaultValue = new MIMEValue(); |
11 |
13 Sep 07 |
nicklas |
486 |
defaultValue.setValue(buf, len); |
11 |
13 Sep 07 |
nicklas |
487 |
} |
11 |
13 Sep 07 |
nicklas |
488 |
} |