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