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