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