]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | \r | |
3 | The file is used to provides all kinds of Data Validation interface \r | |
4 | \r | |
5 | Copyright (c) 2006, Intel Corporation\r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | package org.tianocore.common;\r | |
17 | \r | |
18 | import java.util.regex.Matcher;\r | |
19 | import java.util.regex.Pattern;\r | |
20 | \r | |
21 | /**\r | |
22 | The class is used to provides all kinds of data validation interface\r | |
23 | \r | |
24 | <p>All provided interfaces are in static mode</p>\r | |
25 | \r | |
26 | @since ModuleEditor 1.0\r | |
27 | \r | |
28 | **/\r | |
29 | public class DataValidation {\r | |
30 | \r | |
31 | /**\r | |
32 | Reserved for test\r | |
33 | \r | |
34 | @param args\r | |
35 | \r | |
36 | **/\r | |
37 | public static void main(String[] args) {\r | |
38 | // TODO Auto-generated method stub\r | |
39 | \r | |
40 | }\r | |
41 | \r | |
42 | //\r | |
43 | // The below is used to check common data types\r | |
44 | //\r | |
45 | \r | |
46 | /**\r | |
47 | Check if the imput data is int\r | |
48 | \r | |
49 | @param strInt The input string which needs validation\r | |
50 | \r | |
51 | @retval true - The input is Int\r | |
52 | @retval false - The input is not Int\r | |
53 | \r | |
54 | **/\r | |
55 | public static boolean isInt(String strInt) {\r | |
56 | return isMatch("^-?[0-9]\\d*$", strInt);\r | |
57 | }\r | |
58 | \r | |
59 | /**\r | |
60 | Check if the input data is int and it is in the valid scope\r | |
61 | The scope is provided by String\r | |
62 | \r | |
63 | @param strNumber The input string which needs validation\r | |
64 | @param BeginNumber The left boundary of the scope\r | |
65 | @param EndNumber The right boundary of the scope\r | |
66 | \r | |
67 | @retval true - The input is Int and in the scope;\r | |
68 | @retval false - The input is not Int or not in the scope\r | |
69 | \r | |
70 | **/\r | |
71 | public static boolean isInt(String strNumber, int BeginNumber, int EndNumber) {\r | |
72 | //\r | |
73 | //Check if the input data is int first\r | |
74 | //\r | |
75 | if (!isInt(strNumber)) {\r | |
76 | return false;\r | |
77 | }\r | |
78 | //\r | |
79 | //And then check if the data is between the scope\r | |
80 | //\r | |
81 | Integer intTemp = new Integer(strNumber);\r | |
82 | if ((intTemp.intValue() < BeginNumber) || (intTemp.intValue() > EndNumber)) {\r | |
83 | return false;\r | |
84 | }\r | |
85 | return true;\r | |
86 | }\r | |
87 | \r | |
88 | /**\r | |
89 | Check if the input data is int and it is in the valid scope\r | |
90 | The scope is provided by String\r | |
91 | \r | |
92 | @param strNumber The input string which needs validation\r | |
93 | @param strBeginNumber The left boundary of the scope\r | |
94 | @param strEndNumber The right boundary of the scope\r | |
95 | \r | |
96 | @retval true - The input is Int and in the scope;\r | |
97 | @retval false - The input is not Int or not in the scope\r | |
98 | \r | |
99 | **/\r | |
100 | public static boolean isInt(String strNumber, String strBeginNumber, String strEndNumber) {\r | |
101 | //\r | |
102 | //Check if all input data are int\r | |
103 | //\r | |
104 | if (!isInt(strNumber)) {\r | |
105 | return false;\r | |
106 | }\r | |
107 | if (!isInt(strBeginNumber)) {\r | |
108 | return false;\r | |
109 | }\r | |
110 | if (!isInt(strEndNumber)) {\r | |
111 | return false;\r | |
112 | }\r | |
113 | //\r | |
114 | //And then check if the data is between the scope\r | |
115 | //\r | |
116 | Integer intI = new Integer(strNumber);\r | |
117 | Integer intJ = new Integer(strBeginNumber);\r | |
118 | Integer intK = new Integer(strEndNumber);\r | |
119 | if ((intI.intValue() < intJ.intValue()) || (intI.intValue() > intK.intValue())) {\r | |
120 | return false;\r | |
121 | }\r | |
122 | return true;\r | |
123 | }\r | |
124 | \r | |
125 | /**\r | |
126 | Use regex to check if the input data is in valid format\r | |
127 | \r | |
128 | @param strPattern The input regex\r | |
129 | @param strMatcher The input data need be checked\r | |
130 | \r | |
131 | @retval true - The data matches the regex\r | |
132 | @retval false - The data doesn't match the regex\r | |
133 | \r | |
134 | **/\r | |
135 | public static boolean isMatch(String strPattern, String strMatcher) {\r | |
136 | Pattern pattern = Pattern.compile(strPattern);\r | |
137 | Matcher matcher = pattern.matcher(strMatcher);\r | |
138 | \r | |
139 | return matcher.find();\r | |
140 | }\r | |
141 | \r | |
142 | //\r | |
143 | // The below is used to check common customized data types\r | |
144 | //\r | |
145 | \r | |
146 | /**\r | |
147 | Check if the input data is BaseNameConvention\r | |
148 | \r | |
149 | @param strBaseNameConvention The input string need be checked\r | |
150 | \r | |
151 | @retval true - The input is BaseNameConvention\r | |
152 | @retval false - The input is not BaseNameConvention\r | |
153 | \r | |
154 | **/\r | |
155 | public static boolean isBaseNameConvention(String strBaseNameConvention) {\r | |
156 | return isMatch("[A-Z]([a-zA-Z0-9])*(_)?([a-zA-Z0-9])*", strBaseNameConvention);\r | |
157 | }\r | |
158 | \r | |
159 | /**\r | |
160 | Check if the input data is GuidArrayType\r | |
161 | \r | |
162 | @param strGuidArrayType The input string need be checked\r | |
163 | \r | |
164 | @retval true - The input is GuidArrayType\r | |
165 | @retval false - The input is not GuidArrayType\r | |
166 | \r | |
167 | **/\r | |
168 | public static boolean isGuidArrayType(String strGuidArrayType) {\r | |
169 | return isMatch(\r | |
170 | "0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},( )*0x[a-fA-F0-9]{1,4}(,( )*\\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\\})?",\r | |
171 | strGuidArrayType);\r | |
172 | }\r | |
173 | \r | |
174 | /**\r | |
175 | Check if the input data is GuidNamingConvention\r | |
176 | \r | |
177 | @param strGuidNamingConvention The input string need be checked\r | |
178 | \r | |
179 | @retval true - The input is GuidNamingConvention\r | |
180 | @retval false - The input is not GuidNamingConvention\r | |
181 | \r | |
182 | **/\r | |
183 | public static boolean isGuidNamingConvention(String strGuidNamingConvention) {\r | |
184 | return isMatch("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}",\r | |
185 | strGuidNamingConvention);\r | |
186 | }\r | |
187 | \r | |
188 | /**\r | |
189 | Check if the input data is GuidType \r | |
190 | \r | |
191 | @param strGuidType The input string need be checked\r | |
192 | \r | |
193 | @retval true - The input is GuidType\r | |
194 | @reture false is not GuidType\r | |
195 | \r | |
196 | **/\r | |
197 | public static boolean isGuidType(String strGuidType) {\r | |
198 | return (isGuidArrayType(strGuidType) || isGuidNamingConvention(strGuidType));\r | |
199 | }\r | |
200 | \r | |
201 | /**\r | |
202 | Check if the input data is Guid \r | |
203 | \r | |
204 | @param strGuid The input string need be checked\r | |
205 | \r | |
206 | @retval true - The input is Guid\r | |
207 | @retval false - The input is not Guid\r | |
208 | \r | |
209 | **/\r | |
210 | public static boolean isGuid(String strGuid) {\r | |
211 | return isGuidType(strGuid);\r | |
212 | }\r | |
213 | \r | |
214 | /**\r | |
215 | Check if the input data is Sentence\r | |
216 | \r | |
217 | @param strSentence The input string need be checked\r | |
218 | \r | |
219 | @retval true - The input is Sentence\r | |
220 | @retval false - The input is not Sentence\r | |
221 | \r | |
222 | **/\r | |
223 | public static boolean isSentence(String strSentence) {\r | |
224 | return isMatch("(\\w+\\W*)+( )+(\\W*\\w*\\W*\\s*)*", strSentence);\r | |
225 | }\r | |
226 | \r | |
227 | /**\r | |
228 | Check if the input data is DateType\r | |
229 | \r | |
230 | @param strDateType The input string need be checked\r | |
231 | \r | |
232 | @retval true - The input is DateType\r | |
233 | @retval false - The input is not DateType\r | |
234 | \r | |
235 | **/\r | |
236 | public static boolean isDateType(String strDateType) {\r | |
237 | return isMatch("[1-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]", strDateType);\r | |
238 | }\r | |
239 | \r | |
240 | /**\r | |
241 | Check if the input data is DosPath\r | |
242 | \r | |
243 | @param strDosPath The input string need be checked\r | |
244 | \r | |
245 | @retval true - The input is DosPath\r | |
246 | @retval false - The input is not DosPath\r | |
247 | \r | |
248 | **/\r | |
249 | public static boolean isDosPath(String strDosPath) {\r | |
250 | return isMatch("([a-zA-Z]:\\\\)?(((\\\\?_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\\\)?)*", strDosPath);\r | |
251 | }\r | |
252 | \r | |
253 | /**\r | |
254 | Check if the input data is UnixPath\r | |
255 | \r | |
256 | @param strUnixPath The input string need be checked\r | |
257 | \r | |
258 | @retval true - The input is UnixPath\r | |
259 | @retval false - The input is not UnixPath\r | |
260 | \r | |
261 | **/\r | |
262 | public static boolean isUnixPath(String strUnixPath) {\r | |
263 | return isMatch("(\\/)?(((_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\/)?)*", strUnixPath);\r | |
264 | }\r | |
265 | \r | |
266 | /**\r | |
267 | Check if the input data is DirectoryNamingConvention\r | |
268 | \r | |
269 | @param strDirectoryNamingConvention The input string need be checked\r | |
270 | \r | |
271 | @retval true - The input is DirectoryNamingConvention\r | |
272 | @retval false - The input is not DirectoryNamingConvention\r | |
273 | \r | |
274 | **/\r | |
275 | public static boolean isDirectoryNamingConvention(String strDirectoryNamingConvention) {\r | |
276 | return (isDosPath(strDirectoryNamingConvention) || isUnixPath(strDirectoryNamingConvention));\r | |
277 | }\r | |
278 | \r | |
279 | /**\r | |
280 | Check if the input data is HexDoubleWordDataType\r | |
281 | \r | |
282 | @param strHexDoubleWordDataType The input string need be checked\r | |
283 | \r | |
284 | @retval true - The input is HexDoubleWordDataType\r | |
285 | @retval false - The input is not HexDoubleWordDataType\r | |
286 | \r | |
287 | **/\r | |
288 | public static boolean isHexDoubleWordDataType(String strHexDoubleWordDataType) {\r | |
289 | return isMatch("0x[a-fA-F0-9]{1,8}", strHexDoubleWordDataType);\r | |
290 | }\r | |
291 | \r | |
292 | /**\r | |
293 | Check if the input data is V1\r | |
294 | \r | |
295 | @param strV1 The input string need be checked\r | |
296 | \r | |
297 | @retval true - The input is V1\r | |
298 | @retval false - The input is not V1\r | |
299 | \r | |
300 | **/\r | |
301 | public static boolean isV1(String strV1) {\r | |
302 | return isMatch("((%[A-Z](_*[A-Z0-9]*)*%)+((((\\\\)?_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\\\)?)*)", strV1);\r | |
303 | }\r | |
304 | \r | |
305 | /**\r | |
306 | Check if the input data is V2\r | |
307 | \r | |
308 | @param strV2 The input string need be checked\r | |
309 | \r | |
310 | @retval true - The input is V2\r | |
311 | @retval false - The input is not V2\r | |
312 | \r | |
313 | **/\r | |
314 | public static boolean isV2(String strV2) {\r | |
315 | return isMatch(\r | |
316 | "(($[A-Z](_*[A-Z0-9]*)*)+||($\\([A-Z](_*[A-Z0-9]*)*\\))+||($\\{[A-Z](_*[A-Z0-9]*)*\\})+)+(\\/)?(((((_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\/)?)*)*)",\r | |
317 | strV2);\r | |
318 | }\r | |
319 | \r | |
320 | /**\r | |
321 | Check if the input data is VariableConvention\r | |
322 | \r | |
323 | @param strVariableConvention The input string need be checked\r | |
324 | \r | |
325 | @retval true - The input is VariableConvention\r | |
326 | @retval false - The input is not VariableConvention\r | |
327 | \r | |
328 | **/\r | |
329 | public static boolean isVariableConvention(String strVariableConvention) {\r | |
330 | return (isV1(strVariableConvention) || isV2(strVariableConvention));\r | |
331 | }\r | |
332 | \r | |
333 | /**\r | |
334 | Check if the input data is UCName\r | |
335 | \r | |
336 | @param strUCName The input string need be checked\r | |
337 | \r | |
338 | @retval true - The input is UCName\r | |
339 | @retval false - The input is not UCName\r | |
340 | \r | |
341 | **/\r | |
342 | public static boolean isUCName(String strUCName) {\r | |
343 | return isMatch("[A-Z]+(_*[A-Z0-9]*( )*)*", strUCName);\r | |
344 | }\r | |
345 | \r | |
346 | /**\r | |
347 | Check if the input data is HexByteDataType\r | |
348 | \r | |
349 | @param strHex64BitDataType The input string need be checked \r | |
350 | \r | |
351 | @retval true - The input is HexByteDataType\r | |
352 | @retval false - The input is not HexByteDataType\r | |
353 | \r | |
354 | **/\r | |
355 | public static boolean isHexByteDataType(String strHex64BitDataType) {\r | |
356 | return isMatch("(0x)?[a-fA-F0-9]{1,2}", strHex64BitDataType);\r | |
357 | }\r | |
358 | \r | |
359 | /**\r | |
360 | Check if the input data is Hex64BitDataType\r | |
361 | \r | |
362 | @param strHex64BitDataType The input string need be checked\r | |
363 | \r | |
364 | @retval true - The input is Hex64BitDataType\r | |
365 | @retval false - The input is not Hex64BitDataType\r | |
366 | \r | |
367 | **/\r | |
368 | public static boolean isHex64BitDataType(String strHex64BitDataType) {\r | |
369 | return isMatch("(0x)?[a-fA-F0-9]{1,16}", strHex64BitDataType);\r | |
370 | }\r | |
371 | \r | |
372 | /**\r | |
373 | Check if the input data is HexWordDataType\r | |
374 | \r | |
375 | @param strHexWordDataType The input string need be checked\r | |
376 | \r | |
377 | @retval true - The input is HexWordDataType\r | |
378 | @retval false - The input is not HexWordDataType\r | |
379 | \r | |
380 | **/\r | |
381 | public static boolean isHexWordDataType(String strHexWordDataType) {\r | |
382 | return isMatch("0x[a-fA-F0-9]{1,4}", strHexWordDataType);\r | |
383 | }\r | |
384 | \r | |
385 | /**\r | |
386 | Check if the input data is CName\r | |
387 | \r | |
388 | @param strCName The input string need be checked\r | |
389 | \r | |
390 | @retval true - The input is CName\r | |
391 | @retval false - The input is not CName\r | |
392 | \r | |
393 | **/\r | |
394 | public static boolean isCName(String strCName) {\r | |
395 | return isMatch("((_)*([a-zA-Z])+((_)*[a-zA-Z0-9]*))*", strCName);\r | |
396 | }\r | |
397 | \r | |
398 | /**\r | |
399 | Check if the input data is OverrideID\r | |
400 | \r | |
401 | @param strOverrideID The input string need be checked\r | |
402 | \r | |
403 | @retval true - The input is OverrideID\r | |
404 | @retval false - The input is not OverrideID\r | |
405 | \r | |
406 | **/\r | |
407 | public static boolean isOverrideID(String strOverrideID) {\r | |
408 | return isInt(strOverrideID);\r | |
409 | }\r | |
410 | \r | |
411 | //\r | |
412 | //The below is used to check msaheader data type\r | |
413 | //\r | |
414 | \r | |
415 | /**\r | |
416 | Check if the input data is BaseName\r | |
417 | \r | |
418 | @param strBaseName The input string need be checked\r | |
419 | \r | |
420 | @retval true - The input is BaseName\r | |
421 | @retval false - The input is not BaseName\r | |
422 | \r | |
423 | **/\r | |
424 | public static boolean isBaseName(String strBaseName) {\r | |
425 | return isBaseNameConvention(strBaseName);\r | |
426 | }\r | |
427 | \r | |
428 | /**\r | |
429 | Check if the input data is Abstract\r | |
430 | \r | |
431 | @param strAbstract The input string need be checked\r | |
432 | \r | |
433 | @retval true - The input is Abstract\r | |
434 | @retval false - The input is not Abstract\r | |
435 | \r | |
436 | **/\r | |
437 | public static boolean isAbstract(String strAbstract) {\r | |
438 | return isSentence(strAbstract);\r | |
439 | }\r | |
440 | \r | |
441 | /**\r | |
442 | Check if the input data is Copyright\r | |
443 | \r | |
444 | @param strCopyright The input string need be checked\r | |
445 | \r | |
446 | @retval true - The input is Copyright\r | |
447 | @retval false - The input is not Copyright\r | |
448 | \r | |
449 | **/\r | |
450 | public static boolean isCopyright(String strCopyright) {\r | |
451 | return isSentence(strCopyright);\r | |
452 | }\r | |
453 | \r | |
454 | /**\r | |
455 | Check if the input data is Created\r | |
456 | \r | |
457 | @param strCreated The input string need be checked\r | |
458 | \r | |
459 | @retval true - The input is Created\r | |
460 | @retval false - The input is not Created\r | |
461 | \r | |
462 | **/\r | |
463 | public static boolean isCreated(String strCreated) {\r | |
464 | return isDateType(strCreated);\r | |
465 | }\r | |
466 | \r | |
467 | /**\r | |
468 | Check if the input data is Updated\r | |
469 | \r | |
470 | @param strUpdated The input string need be checked\r | |
471 | \r | |
472 | @retval true - The input is Updated\r | |
473 | @retval false - The input is not Updated\r | |
474 | \r | |
475 | **/\r | |
476 | public static boolean isUpdated(String strUpdated) {\r | |
477 | return isDateType(strUpdated);\r | |
478 | }\r | |
479 | \r | |
480 | //\r | |
481 | // The below is used to check LibraryClass data types\r | |
482 | //\r | |
483 | \r | |
484 | /**\r | |
485 | Check if the input data is LibraryClass\r | |
486 | \r | |
487 | @param strLibraryClass The input string need be checked\r | |
488 | \r | |
489 | @retval true - The input is LibraryClass\r | |
490 | @retval false - The input is not LibraryClass\r | |
491 | \r | |
492 | **/\r | |
493 | public static boolean isLibraryClass(String strLibraryClass) {\r | |
494 | return isBaseNameConvention(strLibraryClass);\r | |
495 | }\r | |
496 | \r | |
497 | //\r | |
498 | // The below is used to check sourcefiles data types\r | |
499 | //\r | |
500 | \r | |
501 | /**\r | |
502 | Check if the input data is Path\r | |
503 | \r | |
504 | @param strPath The input string need be checked\r | |
505 | \r | |
506 | @retval true - The input is Path\r | |
507 | @retval false - The input is not Path\r | |
508 | \r | |
509 | **/\r | |
510 | public static boolean isPath(String strPath) {\r | |
511 | return isDirectoryNamingConvention(strPath);\r | |
512 | }\r | |
513 | \r | |
514 | /**\r | |
515 | Check if the input data is FileName\r | |
516 | \r | |
517 | @param strFileName The input string need be checked\r | |
518 | \r | |
519 | @retval true - The input is FileName\r | |
520 | @retval false - The input is not FileName\r | |
521 | \r | |
522 | **/\r | |
523 | public static boolean isFileName(String strFileName) {\r | |
524 | return isVariableConvention(strFileName);\r | |
525 | }\r | |
526 | \r | |
527 | //\r | |
528 | // The below is used to check includes data types\r | |
529 | //\r | |
530 | \r | |
531 | /**\r | |
532 | Check if the input data is UpdatedDate\r | |
533 | \r | |
534 | @param strUpdatedDate The input string need be checked\r | |
535 | \r | |
536 | @retval true - The input is UpdatedDate\r | |
537 | @retval false - The input is not UpdatedDate\r | |
538 | \r | |
539 | **/\r | |
540 | public static boolean isUpdatedDate(String strUpdatedDate) {\r | |
541 | return isDateType(strUpdatedDate);\r | |
542 | }\r | |
543 | \r | |
544 | /**\r | |
545 | Check if the input data is PackageName\r | |
546 | \r | |
547 | @param strPackageName The input string need be checked\r | |
548 | \r | |
549 | @retval true - The input is PackageName\r | |
550 | @retval false - The input is not PackageName\r | |
551 | \r | |
552 | **/\r | |
553 | public static boolean isPackageName(String strPackageName) {\r | |
554 | return isBaseNameConvention(strPackageName);\r | |
555 | }\r | |
556 | \r | |
557 | //\r | |
558 | // The below is used to check protocols data types\r | |
559 | //\r | |
560 | \r | |
561 | /**\r | |
562 | Check if the input data is ProtocolName\r | |
563 | \r | |
564 | @param strProtocolName The input string need be checked\r | |
565 | \r | |
566 | @retval true - The input is ProtocolName\r | |
567 | @retval false - The input is not ProtocolName\r | |
568 | \r | |
569 | **/\r | |
570 | public static boolean isProtocolName(String strProtocolName) {\r | |
571 | return isCName(strProtocolName);\r | |
572 | }\r | |
573 | \r | |
574 | /**\r | |
575 | Check if the input data is ProtocolNotifyName\r | |
576 | \r | |
577 | @param strProtocolNotifyName The input string need be checked\r | |
578 | \r | |
579 | @retval true - The input is ProtocolNotifyName\r | |
580 | @retval false - The input is not ProtocolNotifyName\r | |
581 | \r | |
582 | **/\r | |
583 | public static boolean isProtocolNotifyName(String strProtocolNotifyName) {\r | |
584 | return isCName(strProtocolNotifyName);\r | |
585 | }\r | |
586 | \r | |
587 | //\r | |
588 | // The below is used to check ppis data types\r | |
589 | //\r | |
590 | \r | |
591 | /**\r | |
592 | Check if the input data is PpiName\r | |
593 | \r | |
594 | @param strPpiName The input string need be checked\r | |
595 | \r | |
596 | @retval true - The input is PpiName\r | |
597 | @retval false - The input is not PpiName\r | |
598 | \r | |
599 | **/\r | |
600 | public static boolean isPpiName(String strPpiName) {\r | |
601 | return isCName(strPpiName);\r | |
602 | }\r | |
603 | \r | |
604 | /**\r | |
605 | Check if the input data is PpiNotifyName\r | |
606 | \r | |
607 | @param strPpiNotifyName The input string need be checked\r | |
608 | \r | |
609 | @retval true - The input is PpiNotifyName\r | |
610 | @retval false - The input is not PpiNotifyName\r | |
611 | \r | |
612 | **/\r | |
613 | public static boolean isPpiNotifyName(String strPpiNotifyName) {\r | |
614 | return isCName(strPpiNotifyName);\r | |
615 | }\r | |
616 | \r | |
617 | /**\r | |
618 | Check if the input data is FeatureFlag\r | |
619 | \r | |
620 | @param strFeatureFlag The input string need be checked\r | |
621 | \r | |
622 | @retval true - The input is FeatureFlag\r | |
623 | @retval false - The input is not FeatureFlag\r | |
624 | \r | |
625 | **/\r | |
626 | public static boolean isFeatureFlag(String strFeatureFlag) {\r | |
627 | return isCName(strFeatureFlag);\r | |
628 | }\r | |
629 | \r | |
630 | //\r | |
631 | // The below is used to check variable data types\r | |
632 | //\r | |
633 | \r | |
634 | /**\r | |
635 | Check if the input data is ByteOffset\r | |
636 | \r | |
637 | @param strByteOffset The input string need be checked\r | |
638 | \r | |
639 | @retval true - The input is ByteOffset\r | |
640 | @retval false - The input is not ByteOffset\r | |
641 | \r | |
642 | **/\r | |
643 | public static boolean isByteOffset(String strByteOffset) {\r | |
644 | return isByteOffset(strByteOffset);\r | |
645 | }\r | |
646 | \r | |
647 | /**\r | |
648 | Check if the input data is BitOffset\r | |
649 | \r | |
650 | @param strBitOffset The input string need be checked\r | |
651 | \r | |
652 | @retval true - The input is BitOffset\r | |
653 | @retval false - The input is not BitOffset\r | |
654 | \r | |
655 | **/\r | |
656 | public static boolean isBitOffset(String strBitOffset) {\r | |
657 | return isInt(strBitOffset, 0, 8);\r | |
658 | }\r | |
659 | \r | |
660 | /**\r | |
661 | Check if the input data is OffsetBitSize\r | |
662 | \r | |
663 | @param strOffsetBitSize The input string need be checked\r | |
664 | \r | |
665 | @retval true - The input is OffsetBitSize\r | |
666 | @retval false - The input is not OffsetBitSize\r | |
667 | \r | |
668 | **/\r | |
669 | public static boolean isOffsetBitSize(String strOffsetBitSize) {\r | |
670 | return isInt(strOffsetBitSize, 0, 7);\r | |
671 | }\r | |
672 | \r | |
673 | //\r | |
674 | // The below is used to check formsets data types\r | |
675 | //\r | |
676 | \r | |
677 | /**\r | |
678 | Check if the input data is Formsets\r | |
679 | \r | |
680 | @param strFormsets The input string need be checked\r | |
681 | \r | |
682 | @retval true - The input is Formsets\r | |
683 | @retval false - The input is not Formsets\r | |
684 | \r | |
685 | **/\r | |
686 | public static boolean isFormsets(String strFormsets) {\r | |
687 | return isCName(strFormsets);\r | |
688 | }\r | |
689 | \r | |
690 | //\r | |
691 | // The below is used to check externs data types\r | |
692 | //\r | |
693 | \r | |
694 | /**\r | |
695 | Check if the input data is Constructor\r | |
696 | \r | |
697 | @param strConstructor The input string need be checked\r | |
698 | \r | |
699 | @retval true - The input is Constructor\r | |
700 | @retval false - The input is not Constructor\r | |
701 | \r | |
702 | **/\r | |
703 | public static boolean isConstructor(String strConstructor) {\r | |
704 | return isCName(strConstructor);\r | |
705 | }\r | |
706 | \r | |
707 | /**\r | |
708 | Check if the input data is Destructor\r | |
709 | \r | |
710 | @param strDestructor The input string need be checked\r | |
711 | \r | |
712 | @retval true - The input is Destructor\r | |
713 | @retval false - The input is not Destructor\r | |
714 | \r | |
715 | **/\r | |
716 | public static boolean isDestructor(String strDestructor) {\r | |
717 | return isCName(strDestructor);\r | |
718 | }\r | |
719 | \r | |
720 | /**\r | |
721 | Check if the input data is DriverBinding\r | |
722 | \r | |
723 | @param strDriverBinding The input string need be checked\r | |
724 | \r | |
725 | @retval true - The input is DriverBinding\r | |
726 | @retval false - The input is not DriverBinding\r | |
727 | \r | |
728 | **/\r | |
729 | public static boolean isDriverBinding(String strDriverBinding) {\r | |
730 | return isCName(strDriverBinding);\r | |
731 | }\r | |
732 | \r | |
733 | /**\r | |
734 | Check if the input data is ComponentName\r | |
735 | \r | |
736 | @param strComponentName The input string need be checked\r | |
737 | \r | |
738 | @retval true - The input is ComponentName\r | |
739 | @retval false - The input is not ComponentName\r | |
740 | \r | |
741 | **/\r | |
742 | public static boolean isComponentName(String strComponentName) {\r | |
743 | return isCName(strComponentName);\r | |
744 | }\r | |
745 | \r | |
746 | /**\r | |
747 | Check if the input data is DriverConfig\r | |
748 | \r | |
749 | @param strDriverConfig The input string need be checked\r | |
750 | \r | |
751 | @retval true - The input is DriverConfig\r | |
752 | @retval false - The input is not DriverConfig\r | |
753 | \r | |
754 | **/\r | |
755 | public static boolean isDriverConfig(String strDriverConfig) {\r | |
756 | return isCName(strDriverConfig);\r | |
757 | }\r | |
758 | \r | |
759 | /**\r | |
760 | Check if the input data is DriverDiag\r | |
761 | \r | |
762 | @param strDriverDiag The input string need be checked\r | |
763 | \r | |
764 | @retval true - The input is DriverDiag\r | |
765 | @retval false - The input is not DriverDiag\r | |
766 | \r | |
767 | **/\r | |
768 | public static boolean isDriverDiag(String strDriverDiag) {\r | |
769 | return isCName(strDriverDiag);\r | |
770 | }\r | |
771 | \r | |
772 | /**\r | |
773 | Check if the input data is SetVirtualAddressMapCallBack\r | |
774 | \r | |
775 | @param strSetVirtualAddressMapCallBack The input string need be checked\r | |
776 | \r | |
777 | @retval true - The input is SetVirtualAddressMapCallBack\r | |
778 | @retval false - The input is not SetVirtualAddressMapCallBack\r | |
779 | \r | |
780 | **/\r | |
781 | public static boolean isSetVirtualAddressMapCallBack(String strSetVirtualAddressMapCallBack) {\r | |
782 | return isCName(strSetVirtualAddressMapCallBack);\r | |
783 | }\r | |
784 | \r | |
785 | /**\r | |
786 | Check if the input data is ExitBootServicesCallBack\r | |
787 | \r | |
788 | @param strExitBootServicesCallBack The input string need be checked\r | |
789 | \r | |
790 | @retval true - The input is ExitBootServicesCallBack\r | |
791 | @retval false - The input is not ExitBootServicesCallBack\r | |
792 | \r | |
793 | **/\r | |
794 | public static boolean isExitBootServicesCallBack(String strExitBootServicesCallBack) {\r | |
795 | return isCName(strExitBootServicesCallBack);\r | |
796 | }\r | |
797 | \r | |
798 | /**\r | |
799 | Check if the input data is UserDefined\r | |
800 | \r | |
801 | @param strUserDefined The input string need be checked\r | |
802 | \r | |
803 | @retval true - The input is UserDefined\r | |
804 | @retval false - The input is not UserDefined\r | |
805 | \r | |
806 | **/\r | |
807 | public static boolean isUserDefined(String strUserDefined) {\r | |
808 | return isCName(strUserDefined);\r | |
809 | }\r | |
810 | \r | |
811 | //\r | |
812 | // The below is used to check PCDs data types\r | |
813 | //\r | |
814 | \r | |
815 | /**\r | |
816 | Check if the input data is Token\r | |
817 | \r | |
818 | @param strToken The input string need be checked\r | |
819 | \r | |
820 | @retval true - The input is Token\r | |
821 | @retval false - The input is not Token\r | |
822 | \r | |
823 | **/\r | |
824 | public static boolean isToken(String strToken) {\r | |
825 | return isHexDoubleWordDataType(strToken);\r | |
826 | }\r | |
827 | \r | |
828 | /**\r | |
829 | Check if the input data is MaxSku\r | |
830 | \r | |
831 | @param strMaxSku The input string need be checked\r | |
832 | \r | |
833 | @retval true - The input is MaxSku\r | |
834 | @retval false - The input is not MaxSku\r | |
835 | \r | |
836 | **/\r | |
837 | public static boolean isMaxSku(String strMaxSku) {\r | |
838 | return isHexByteDataType(strMaxSku);\r | |
839 | }\r | |
840 | \r | |
841 | /**\r | |
842 | Check if the input data is SkuId\r | |
843 | \r | |
844 | @param strSkuId The input string need be checked\r | |
845 | \r | |
846 | @retval true - The input is SkuId\r | |
847 | @retval false - The input is not SkuId\r | |
848 | \r | |
849 | **/\r | |
850 | public static boolean isSkuId(String strSkuId) {\r | |
851 | return isHexByteDataType(strSkuId);\r | |
852 | }\r | |
853 | \r | |
854 | /**\r | |
855 | Check if the input data is DatumSize\r | |
856 | \r | |
857 | @param strDatumSize The input string need be checked\r | |
858 | \r | |
859 | @retval true - The input is DatumSize\r | |
860 | @retval false - The input is not DatumSize\r | |
861 | \r | |
862 | **/\r | |
863 | public static boolean isDatumSize(String strDatumSize) {\r | |
864 | return isInt(strDatumSize, 1, 16777215);\r | |
865 | }\r | |
866 | \r | |
867 | /**\r | |
868 | Check if the input data is VariableGuid\r | |
869 | \r | |
870 | @param strVariableGuid The input string need be checked\r | |
871 | \r | |
872 | @retval true - The input is VariableGuid\r | |
873 | @retval false - The input is not VariableGuid\r | |
874 | \r | |
875 | **/\r | |
876 | public static boolean isVariableGuid(String strVariableGuid) {\r | |
877 | return (isGuid(strVariableGuid) || strVariableGuid.equals("0"));\r | |
878 | }\r | |
879 | \r | |
880 | /**\r | |
881 | Check if the input data is DataOffset\r | |
882 | \r | |
883 | @param strDataOffset The input string need be checked\r | |
884 | \r | |
885 | @retval true - The input is DataOffset\r | |
886 | @retval false - The input is not DataOffset\r | |
887 | \r | |
888 | **/\r | |
889 | public static boolean isDataOffset(String strDataOffset) {\r | |
890 | return isHex64BitDataType(strDataOffset);\r | |
891 | }\r | |
892 | \r | |
893 | /**\r | |
894 | Check if the input data is GuidOffset\r | |
895 | \r | |
896 | @param strGuidOffset The input string need be checked\r | |
897 | \r | |
898 | @retval true - The input is GuidOffset\r | |
899 | @retval false - The input is not GuidOffset\r | |
900 | \r | |
901 | **/\r | |
902 | public static boolean isGuidOffset(String strGuidOffset) {\r | |
903 | return isHex64BitDataType(strGuidOffset);\r | |
904 | }\r | |
905 | }\r |