]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java
1, Fix EDKT141
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / entity / Token.java
1 /** @file
2 Token class.
3
4 This module contains all classes releted to PCD token.
5
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16 package org.tianocore.build.pcd.entity;
17
18 import java.math.BigInteger;
19 import java.util.ArrayList;
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23 import java.util.UUID;
24
25 import org.tianocore.build.id.ModuleIdentification;
26 import org.tianocore.build.pcd.exception.EntityException;
27
28 /** This class is to descript a PCD token object. The information of a token mainly
29 comes from MSA, SPD and setting produced by platform developer.
30 **/
31 public class Token {
32 ///
33 /// Enumeration macro defintion for PCD type.
34 /// BUGBUG: Not use upcase charater is to facility for reading. It may be changed
35 /// in coding review.
36 public enum PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC,
37 DYNAMIC_EX, UNKNOWN}
38
39 ///
40 /// Enumeration macro definition for datum type. All type mainly comes from ProcessBind.h.
41 /// Wizard maybe expand this type as "int, unsigned int, short, unsigned short etc" in
42 /// prompt dialog.
43 ///
44 public enum DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN}
45
46 ///
47 /// Enumeration macor defintion for usage of PCD
48 ///
49 public enum PCD_USAGE {ALWAYS_PRODUCED, ALWAYS_CONSUMED, SOMETIMES_PRODUCED,
50 SOMETIMES_CONSUMED, UNKNOWN}
51
52 ///
53 /// cName is to identify a PCD entry and will be used for generating autogen.h/autogen.c.
54 /// cName will be defined in MSA, SPD and FPD, can be regarded as primary key with token space guid.
55 ///
56 public String cName;
57
58 ///
59 /// Token space name is the guid defined by token itself in package or module level. This
60 /// name mainly for DynamicEx type. For other PCD type token, his token space name is the
61 /// assignedtokenSpaceName as follows.
62 /// tokenSpaceName is defined in MSA, SPD, FPD, can be regarded as primary key with cName.
63 ///
64 public String tokenSpaceName;
65
66 ///
67 /// tokenNumber is allocated by platform. tokenNumber indicate an index for this token in
68 /// platform token space. For Dynamic, dynamicEx type, this number will be re-adjust by
69 /// PCD run-time database autogen tools.
70 ///
71 public long tokenNumber;
72
73 ///
74 /// This token number is retrieved from FPD file for DynamicEx type.
75 ///
76 public long dynamicExTokenNumber;
77
78 ///
79 /// All supported PCD type, this value can be retrieved from SPD
80 /// Currently, only record all PCD type for this token in FPD file.
81 ///
82 public List<PCD_TYPE> supportedPcdType;
83
84 ///
85 /// If the token's item type is Dynamic or DynamicEx type, isDynamicPCD
86 /// is true.
87 ///
88 public boolean isDynamicPCD;
89
90 ///
91 /// datumSize is to descript the fix size or max size for this token.
92 /// datumSize is defined in SPD.
93 ///
94 public int datumSize;
95
96 ///
97 /// datum type is to descript what type can be expressed by a PCD token.
98 /// For same PCD used in different module, the datum type should be unique.
99 /// So it belong memeber to Token class.
100 ///
101 public DATUM_TYPE datumType;
102
103 ///
104 /// skuData contains all value for SkuNumber of token.
105 /// This field is for Dynamic or DynamicEx type PCD,
106 ///
107 public List<SkuInstance> skuData;
108
109 ///
110 /// consumers array record all module private information who consume this PCD token.
111 ///
112 public Map<String, UsageInstance> consumers;
113
114 /**
115 Constructure function for Token class
116
117 @param cName The name of token
118 @param tokenSpaceName The name of token space, it is a guid string
119 **/
120 public Token(String cName, String tokenSpaceName) {
121 UUID nullUUID = new UUID(0, 0);
122
123 this.cName = cName;
124 this.tokenSpaceName = tokenSpaceName;
125 this.tokenNumber = 0;
126 this.datumType = DATUM_TYPE.UNKNOWN;
127 this.datumSize = -1;
128 this.skuData = new ArrayList<SkuInstance>();
129
130 this.consumers = new HashMap<String, UsageInstance>();
131 this.supportedPcdType = new ArrayList<PCD_TYPE>();
132 }
133
134 /**
135 updateSupportPcdType
136
137 SupportPcdType should be gotten from SPD file actually, but now it just
138 record all PCD type for this token in FPD file.
139
140 @param pcdType new PCD type found in FPD file for this token.
141 **/
142 public void updateSupportPcdType(PCD_TYPE pcdType) {
143 for (int index = 0; index < this.supportedPcdType.size(); index ++) {
144 if (supportedPcdType.get(index) == pcdType) {
145 return;
146 }
147 }
148
149 //
150 // If not found, add the pcd type to member variable supportedPcdType
151 //
152 supportedPcdType.add(pcdType);
153 }
154
155 /**
156 Judge whether pcdType is belong to dynamic type. Dynamic type includes
157 DYNAMIC and DYNAMIC_EX.
158
159 @param pcdType the judged pcd type
160
161 @return boolean
162 */
163 public static boolean isDynamic(PCD_TYPE pcdType) {
164 if ((pcdType == PCD_TYPE.DYNAMIC ) ||
165 (pcdType == PCD_TYPE.DYNAMIC_EX)) {
166 return true;
167 }
168
169 return false;
170 }
171
172 public boolean isDynamicEx() {
173 for (int i = 0; i < supportedPcdType.size(); i++) {
174 if (supportedPcdType.get(i) == PCD_TYPE.DYNAMIC_EX) {
175 return true;
176 }
177 }
178
179 return false;
180 }
181
182 /**
183 Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database
184
185 @param cName Token name.
186 @param tokenSpaceName The token space guid string defined in MSA or SPD
187
188 @retval primary key for this token in token database.
189 **/
190 public static String getPrimaryKeyString(String cName, String tokenSpaceName) {
191 if (tokenSpaceName == null) {
192 return cName + "_nullTokenSpaceGuid";
193 } else {
194 return cName + "_" + tokenSpaceName.toString().replace('-', '_');
195 }
196 }
197
198 /**
199 If skudata list contains more than one data, then Sku mechanism is enable.
200
201 @retval boolean if the number of sku data exceed to 1
202 */
203 public boolean isSkuEnable() {
204 if (this.skuData.size() > 1) {
205 return true;
206 }
207 return false;
208 }
209
210 /**
211 If Hii type for value of token
212
213 @return boolean
214 **/
215 public boolean isHiiEnable() {
216 if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {
217 return true;
218 }
219 return false;
220 }
221
222 /**
223 If Vpd type for value of token
224
225 @return boolean
226 **/
227 public boolean isVpdEnable() {
228 if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {
229 return true;
230 }
231 return false;
232 }
233
234 /**
235 Get the token primary key in token database.
236
237 @return String
238 */
239 public String getPrimaryKeyString () {
240 return Token.getPrimaryKeyString(cName, tokenSpaceName);
241 }
242
243 /**
244 Judge datumType is valid
245
246 @param type The datumType want to be judged.
247
248 @retval TRUE - The type is valid.
249 @retval FALSE - The type is invalid.
250 **/
251 public static boolean isValiddatumType(DATUM_TYPE type) {
252 if ((type.ordinal() < DATUM_TYPE.UINT8.ordinal() ) ||
253 (type.ordinal() > DATUM_TYPE.POINTER.ordinal())) {
254 return false;
255 }
256 return true;
257 }
258
259 /**
260 Judge pcdType is valid
261
262 @param type The PCdType want to be judged.
263
264 @retval TRUE - The type is valid.
265 @retval FALSE - The type is invalid.
266 **/
267 public static boolean isValidpcdType(PCD_TYPE type) {
268 if ((type.ordinal() < PCD_TYPE.FEATURE_FLAG.ordinal() ) ||
269 (type.ordinal() > PCD_TYPE.DYNAMIC_EX.ordinal())) {
270 return false;
271 }
272 return true;
273 }
274
275 /**
276 Add an usage instance for token
277
278 @param usageInstance The usage instance
279
280 @retval TRUE - Success to add usage instance.
281 @retval FALSE - Fail to add usage instance
282 **/
283 public boolean addUsageInstance(UsageInstance usageInstance) throws EntityException {
284 String exceptionStr;
285
286 if (isUsageInstanceExist(usageInstance.moduleId, usageInstance.arch)) {
287 exceptionStr = String.format("[PCD Collection Tool Exception] PCD %s for module %s has already exist in database, Please check all PCD build entries "+
288 "in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!",
289 usageInstance.parentToken.cName,
290 usageInstance.moduleId.getName(),
291 usageInstance.moduleId.getName());
292 throw new EntityException(exceptionStr);
293 }
294
295 //
296 // Put usage instance into usage instance database of this PCD token.
297 //
298 consumers.put(usageInstance.getPrimaryKey(), usageInstance);
299
300 return true;
301 }
302
303 /**
304 Judge whether exist an usage instance for this token
305
306 @param moduleId The module identification for usage instance
307 @param arch the architecture string
308
309 @return boolean whether exist an usage instance for this token.
310 */
311 public boolean isUsageInstanceExist(ModuleIdentification moduleId,
312 String arch) {
313 String keyStr = UsageInstance.getPrimaryKey(moduleId, arch);
314
315 return (consumers.get(keyStr) != null);
316 }
317
318 /**
319 Get the PCD_TYPE according to the string of PCD_TYPE
320
321 @param pcdTypeStr The string of PCD_TYPE
322
323 @return PCD_TYPE
324 **/
325 public static PCD_TYPE getpcdTypeFromString(String pcdTypeStr) {
326 if (pcdTypeStr == null) {
327 return PCD_TYPE.UNKNOWN;
328 }
329
330 if (pcdTypeStr.equalsIgnoreCase("FEATURE_FLAG")) {
331 return PCD_TYPE.FEATURE_FLAG;
332 } else if (pcdTypeStr.equalsIgnoreCase("FIXED_AT_BUILD")) {
333 return PCD_TYPE.FIXED_AT_BUILD;
334 } else if (pcdTypeStr.equalsIgnoreCase("PATCHABLE_IN_MODULE")) {
335 return PCD_TYPE.PATCHABLE_IN_MODULE;
336 } else if (pcdTypeStr.equalsIgnoreCase("DYNAMIC")) {
337 return PCD_TYPE.DYNAMIC;
338 } else if (pcdTypeStr.equalsIgnoreCase("DYNAMIC_EX")) {
339 return PCD_TYPE.DYNAMIC_EX;
340 } else {
341 return PCD_TYPE.UNKNOWN;
342 }
343 }
344
345 /**
346 Get the string of given datumType. This string will be used for generating autogen files
347
348 @param datumType Given datumType
349
350 @return The string of datum type.
351 **/
352 public static String getStringOfdatumType(DATUM_TYPE datumType) {
353 switch (datumType) {
354 case UINT8:
355 return "UINT8";
356 case UINT16:
357 return "UINT16";
358 case UINT32:
359 return "UINT32";
360 case UINT64:
361 return "UINT64";
362 case POINTER:
363 return "POINTER";
364 case BOOLEAN:
365 return "BOOLEAN";
366 }
367 return "UNKNOWN";
368 }
369
370 /**
371 Get the datumType according to a string.
372
373 @param datumTypeStr The string of datumType
374
375 @return DATUM_TYPE
376 **/
377 public static DATUM_TYPE getdatumTypeFromString(String datumTypeStr) {
378 if (datumTypeStr.equalsIgnoreCase("UINT8")) {
379 return DATUM_TYPE.UINT8;
380 } else if (datumTypeStr.equalsIgnoreCase("UINT16")) {
381 return DATUM_TYPE.UINT16;
382 } else if (datumTypeStr.equalsIgnoreCase("UINT32")) {
383 return DATUM_TYPE.UINT32;
384 } else if (datumTypeStr.equalsIgnoreCase("UINT64")) {
385 return DATUM_TYPE.UINT64;
386 } else if (datumTypeStr.equalsIgnoreCase("VOID*")) {
387 return DATUM_TYPE.POINTER;
388 } else if (datumTypeStr.equalsIgnoreCase("BOOLEAN")) {
389 return DATUM_TYPE.BOOLEAN;
390 }
391 return DATUM_TYPE.UNKNOWN;
392 }
393
394 /**
395 Get string of given pcdType
396
397 @param pcdType The given PcdType
398
399 @return The string of PCD_TYPE.
400 **/
401 public static String getStringOfpcdType(PCD_TYPE pcdType) {
402 switch (pcdType) {
403 case FEATURE_FLAG:
404 return "FEATURE_FLAG";
405 case FIXED_AT_BUILD:
406 return "FIXED_AT_BUILD";
407 case PATCHABLE_IN_MODULE:
408 return "PATCHABLE_IN_MODULE";
409 case DYNAMIC:
410 return "DYNAMIC";
411 case DYNAMIC_EX:
412 return "DYNAMIC_EX";
413 }
414 return "UNKNOWN";
415 }
416
417 /**
418 Get the PCD_USAGE according to a string
419
420 @param usageStr The string of PCD_USAGE
421
422 @return The PCD_USAGE
423 **/
424 public static PCD_USAGE getUsageFromString(String usageStr) {
425 if (usageStr == null) {
426 return PCD_USAGE.UNKNOWN;
427 }
428
429 if (usageStr.equalsIgnoreCase("ALWAYS_PRODUCED")) {
430 return PCD_USAGE.ALWAYS_PRODUCED;
431 } else if (usageStr.equalsIgnoreCase("SOMETIMES_PRODUCED")) {
432 return PCD_USAGE.SOMETIMES_PRODUCED;
433 } else if (usageStr.equalsIgnoreCase("ALWAYS_CONSUMED")) {
434 return PCD_USAGE.ALWAYS_CONSUMED;
435 } else if (usageStr.equalsIgnoreCase("SOMETIMES_CONSUMED")) {
436 return PCD_USAGE.SOMETIMES_CONSUMED;
437 }
438
439 return PCD_USAGE.UNKNOWN;
440 }
441
442 /**
443 Get the string of given PCD_USAGE
444
445 @param usage The given PCD_USAGE
446
447 @return The string of PDC_USAGE.
448 **/
449 public static String getStringOfUsage(PCD_USAGE usage) {
450 switch (usage) {
451 case ALWAYS_PRODUCED:
452 return "ALWAYS_PRODUCED";
453 case ALWAYS_CONSUMED:
454 return "ALWAYS_CONSUMED";
455 case SOMETIMES_PRODUCED:
456 return "SOMETIMES_PRODUCED";
457 case SOMETIMES_CONSUMED:
458 return "SOMETIMES_CONSUMED";
459 }
460 return "UNKNOWN";
461 }
462
463 /**
464 Get the Defined datumType string for autogen. The string is for generating some MACROs in Autogen.h
465
466 @param datumType The given datumType
467
468 @return string of datum type for autogen.
469 **/
470 public static String GetAutogenDefinedatumTypeString(DATUM_TYPE datumType) {
471 switch (datumType) {
472
473 case UINT8:
474 return "8";
475 case UINT16:
476 return "16";
477 case BOOLEAN:
478 return "BOOL";
479 case POINTER:
480 return "PTR";
481 case UINT32:
482 return "32";
483 case UINT64:
484 return "64";
485 default:
486 return null;
487 }
488 }
489
490 /**
491 Get the datumType String for Autogen. This string will be used for generating defintions of PCD token in autogen
492
493 @param datumType The given datumType
494
495 @return string of datum type.
496 **/
497
498 public static String getAutogendatumTypeString(DATUM_TYPE datumType) {
499 switch (datumType) {
500 case UINT8:
501 return "UINT8";
502 case UINT16:
503 return "UINT16";
504 case UINT32:
505 return "UINT32";
506 case UINT64:
507 return "UINT64";
508 case POINTER:
509 return "VOID*";
510 case BOOLEAN:
511 return "BOOLEAN";
512 }
513 return null;
514 }
515
516 /**
517 Get the datumType string for generating some MACROs in autogen file of Library
518
519 @param datumType The given datumType
520
521 @return String of datum for genrating bit charater.
522 **/
523 public static String getAutogenLibrarydatumTypeString(DATUM_TYPE datumType) {
524 switch (datumType) {
525 case UINT8:
526 return "8";
527 case UINT16:
528 return "16";
529 case BOOLEAN:
530 return "Bool";
531 case POINTER:
532 return "Ptr";
533 case UINT32:
534 return "32";
535 case UINT64:
536 return "64";
537 default:
538 return null;
539 }
540 }
541
542 /**
543 Get the sku data who id is 0.
544
545 @retval DynamicTokenValue the value of this dyanmic token.
546 **/
547 public DynamicTokenValue getDefaultSku() {
548 DynamicTokenValue dynamicData;
549 int index;
550
551 for (index = 0; index < this.skuData.size(); index ++) {
552 if (skuData.get(index).id == 0) {
553 return skuData.get(index).value;
554 }
555 }
556
557 return null;
558 }
559
560 /**
561 Get the number of Sku data for this token
562
563 @retval int the number of sku data
564 **/
565 public int getSkuIdCount () {
566 return this.skuData.size();
567 }
568
569 /**
570 Get the size of PCD value, this PCD is POINTER type.
571
572 @param str the string of the value
573 @param al
574 **/
575 private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {
576 if (isValidNullValue(str)) {
577 al.add(new Integer(0));
578 } else {
579 //
580 // isValidNullValue has already make sure that str here
581 // always contain a valid default value of the following 3
582 // cases:
583 // 1) "Hello world" //Assci string
584 // 2) L"Hello" //Unicode string
585 // 3) {0x01, 0x02, 0x03} //Byte stream
586 //
587 if (str.startsWith("\"")) {
588 al.add(new Integer(str.length() - 2));
589 } else if (str.startsWith("L\"")){
590 //
591 // Unicode is 2 bytes each.
592 //
593 al.add(new Integer((str.length() - 3) * 2));
594 } else if (str.startsWith("{")) {
595 //
596 // We count the number of "," in the string.
597 // The number of byte is one plus the number of
598 // comma.
599 //
600 String str2 = str;
601
602 int cnt = 0;
603 int pos = 0;
604 pos = str2.indexOf(",", 0);
605 while (pos != -1) {
606 cnt++;
607 pos++;
608 pos = str2.indexOf(",", pos);
609 }
610 cnt++;
611 al.add(new Integer(cnt));
612 }
613 }
614 }
615
616 /**
617 This method can be used to get the MAX and current size
618 for pointer type dynamic(ex) PCD entry
619 **/
620 public ArrayList<Integer> getPointerTypeSize () {
621 ArrayList<Integer> al = new ArrayList<Integer>();
622
623 //
624 // For VPD_enabled and HII_enabled, we can only return the MAX size.
625 // For the default DATA type dynamic PCD entry, we will return
626 // the MAX size and current size for each SKU_ID.
627 //
628 al.add(new Integer(this.datumSize));
629
630 if (!this.isVpdEnable()) {
631 int idx;
632 if (this.isHiiEnable()){
633 for (idx = 0; idx < this.skuData.size(); idx++) {
634 String str = this.skuData.get(idx).value.hiiDefaultValue;
635 getCurrentSizeFromDefaultValue(str, al);
636 }
637 } else {
638 for (idx = 0; idx < this.skuData.size(); idx++) {
639 String str = this.skuData.get(idx).value.value;
640 getCurrentSizeFromDefaultValue(str, al);
641 }
642 }
643 }
644
645 return al;
646 }
647
648 /**
649 Get default value for a token, For HII type, HiiDefaultValue of default
650 SKU 0 will be returned; For Default type, the defaultvalue of default SKU
651 0 will be returned.
652
653 @return String
654 */
655 public String getDynamicDefaultValue() {
656 DynamicTokenValue dynamicData = getDefaultSku();
657 if (hasDefaultValue()) {
658 switch (dynamicData.type) {
659 case DEFAULT_TYPE:
660 return dynamicData.value;
661 }
662 }
663
664 return null;
665 }
666
667 //
668 // BugBug: We need change this algorithm accordingly when schema is updated
669 // to support no default value.
670 //
671 public boolean hasDefaultValue () {
672 int value = 0;
673 boolean isInteger = true;
674 DynamicTokenValue dynamicValue = null;
675
676 if (isSkuEnable()) {
677 return true;
678 }
679
680 if (this.isDynamicPCD) {
681 dynamicValue = getDefaultSku();
682 switch (dynamicValue.type) {
683 case HII_TYPE:
684 return true;
685 case VPD_TYPE:
686 return true;
687 case DEFAULT_TYPE:
688 return !isValidNullValue(dynamicValue.value);
689 }
690 }
691
692 return false;
693 }
694
695 /**
696 Judge the value is NULL value. NULL value means the value is uninitialized value
697
698 @param judgedValue
699
700 @return boolean
701 */
702 public boolean isValidNullValue(String judgedValue) {
703 String subStr;
704 BigInteger bigIntValue;
705
706 switch (datumType) {
707 case UINT8:
708 case UINT16:
709 case UINT32:
710 if (judgedValue.length() > 2) {
711 if ((judgedValue.charAt(0) == '0') &&
712 ((judgedValue.charAt(1) == 'x') || (judgedValue.charAt(1) == 'X'))){
713 subStr = judgedValue.substring(2, judgedValue.length());
714 bigIntValue = new BigInteger(subStr, 16);
715 } else {
716 bigIntValue = new BigInteger(judgedValue);
717 }
718 } else {
719 bigIntValue = new BigInteger(judgedValue);
720 }
721 if (bigIntValue.bitCount() == 0) {
722 return true;
723 }
724 break;
725 case UINT64:
726 if (judgedValue.length() > 2){
727 if ((judgedValue.charAt(0) == '0') &&
728 ((judgedValue.charAt(1) == 'x') ||
729 (judgedValue.charAt(1) == 'X'))) {
730 bigIntValue = new BigInteger(judgedValue.substring(2, judgedValue.length()), 16);
731 if (bigIntValue.bitCount() == 0) {
732 return true;
733 }
734 } else {
735 bigIntValue = new BigInteger(judgedValue);
736 if (bigIntValue.bitCount() == 0) {
737 return true;
738 }
739 }
740 } else {
741 bigIntValue = new BigInteger(judgedValue);
742 if (bigIntValue.bitCount() == 0) {
743 return true;
744 }
745 }
746 break;
747 case BOOLEAN:
748 if (judgedValue.equalsIgnoreCase("false")) {
749 return true;
750 }
751 break;
752 case POINTER:
753 if (judgedValue.equalsIgnoreCase("") ||
754 judgedValue.equalsIgnoreCase("\"\"") ||
755 judgedValue.equalsIgnoreCase("L\"\"") ||
756 (judgedValue.length() == 0) ||
757 judgedValue.equalsIgnoreCase("{0}")) {
758 return true;
759 }
760 }
761 return false;
762 }
763
764 /**
765 Is the string value in Unicode
766
767 @return boolean
768 **/
769 public boolean isHiiDefaultValueUnicodeStringType() {
770 DynamicTokenValue dynamicData = getDefaultSku();
771
772 if (dynamicData == null)
773 return false;
774
775 return dynamicData.hiiDefaultValue.startsWith("L\"")
776 && dynamicData.hiiDefaultValue.endsWith("\"");
777 }
778
779 /**
780 Is the string value in ANSCI
781
782 @return boolean
783 **/
784 public boolean isHiiDefaultValueASCIIStringType() {
785 DynamicTokenValue dynamicData = getDefaultSku();
786
787 if (dynamicData == null)
788 return false;
789
790 return dynamicData.hiiDefaultValue.startsWith("\"")
791 && dynamicData.hiiDefaultValue.endsWith("\"");
792 }
793
794 /**
795 Judege whether current value is UNICODE string type.
796 @return boolean
797 */
798 public boolean isUnicodeStringType () {
799 String str = getDynamicDefaultValue();
800
801 if (str == null) {
802 return false;
803 }
804
805 if (datumType == Token.DATUM_TYPE.POINTER &&
806 str.startsWith("L\"") &&
807 str.endsWith("\"")) {
808 return true;
809 }
810
811 return false;
812 }
813
814 public boolean isASCIIStringType () {
815 String str = getDynamicDefaultValue();
816
817 if (str == null) {
818 return false;
819 }
820
821 if (datumType == Token.DATUM_TYPE.POINTER &&
822 str.startsWith("\"") &&
823 str.endsWith("\"")) {
824 return true;
825 }
826
827 return false;
828 }
829
830 public boolean isByteStreamType () {
831 String str = getDynamicDefaultValue();
832
833 if (str == null) {
834 return false;
835 }
836
837 if (datumType == Token.DATUM_TYPE.POINTER &&
838 str.startsWith("{") &&
839 str.endsWith("}")) {
840 return true;
841 }
842
843 return false;
844
845 }
846
847 public String getStringTypeString () {
848 return getDefaultSku().value.substring(2, getDefaultSku().value.length() - 1);
849 }
850 }
851
852
853
854