4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
.tianocore
.build
.pcd
.action
;
17 import java
.util
.ArrayList
;
18 import java
.util
.Comparator
;
19 import java
.util
.HashMap
;
20 import java
.util
.List
;
22 import java
.util
.UUID
;
23 import org
.tianocore
.build
.global
.GlobalData
;
24 import org
.tianocore
.pcd
.entity
.DynamicTokenValue
;
25 import org
.tianocore
.pcd
.entity
.Token
;
26 import org
.tianocore
.pcd
.exception
.EntityException
;
29 CStructTypeDeclaration
31 This class is used to store the declaration string, such as
32 "UINT32 PcdPlatformFlashBaseAddress", of
33 each memember in the C structure, which is a standard C language
34 feature used to implement a simple and efficient database for
35 dynamic(ex) type PCD entry.
37 class CStructTypeDeclaration
{
43 public CStructTypeDeclaration (String key
, int alignmentSize
, String cCode
, boolean initTable
) {
45 this.alignmentSize
= alignmentSize
;
47 this.initTable
= initTable
;
54 This class is used to store the String in a PCD database.
58 private ArrayList
<String
> al
;
59 private ArrayList
<String
> alComments
;
63 public StringTable (String phase
) {
65 al
= new ArrayList
<String
>();
66 alComments
= new ArrayList
<String
>();
70 public String
getSizeMacro () {
71 return String
.format(PcdDatabase
.StringTableSizeMacro
, phase
, getSize());
74 private int getSize () {
76 // We have at least one Unicode Character in the table.
78 return len
== 0 ?
1 : len
;
81 public String
getExistanceMacro () {
82 return String
.format(PcdDatabase
.StringTableExistenceMacro
, phase
, (al
.size() == 0)?
"TRUE":"FALSE");
85 public void genCode (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
) {
86 final String stringTable
= "StringTable";
87 final String tab
= "\t";
88 final String newLine
= "\r\n";
89 final String commaNewLine
= ",\r\n";
91 CStructTypeDeclaration decl
;
93 String cDeclCode
= "";
94 String cInstCode
= "";
97 // If we have a empty StringTable
100 cDeclCode
+= String
.format("%-20s%s[1]; /* StringTable is empty */", "UINT16", stringTable
) + newLine
;
101 decl
= new CStructTypeDeclaration (
109 cInstCode
= String
.format("/* %s */", stringTable
) + newLine
+ tab
+ "{ 0 }";
110 instTable
.put(stringTable
, cInstCode
);
114 // If there is any String in the StringTable
116 for (int i
= 0; i
< al
.size(); i
++) {
117 String str
= al
.get(i
);
118 String stringTableName
;
122 // StringTable is a well-known name in the PCD DXE driver
124 stringTableName
= stringTable
;
127 stringTableName
= String
.format("%s_%d", stringTable
, i
);
130 cDeclCode
+= String
.format("%-20s%s[%d]; /* %s */", "UINT16",
131 stringTableName
, str
.length() + 1,
136 cInstCode
= "/* StringTable */" + newLine
;
139 cInstCode
+= tab
+ String
.format("L\"%s\" /* %s */", al
.get(i
), alComments
.get(i
));
140 if (i
!= al
.size() - 1) {
141 cInstCode
+= commaNewLine
;
145 decl
= new CStructTypeDeclaration (
153 instTable
.put(stringTable
, cInstCode
);
157 public int add (String inputStr
, Token token
) {
161 String str
= inputStr
;
164 // The input can be two types:
165 // "L\"Bootmode\"" or "Bootmode".
166 // We drop the L\" and \" for the first type.
167 if (str
.startsWith("L\"") && str
.endsWith("\"")) {
168 str
= str
.substring(2, str
.length() - 1);
171 // Check if StringTable has this String already.
172 // If so, return the current pos.
174 for (i
= 0, pos
= 0; i
< al
.size(); i
++) {
175 String s
= al
.get(i
);;
180 pos
= s
.length() + 1;
185 // Include the NULL character at the end of String
187 len
+= str
.length() + 1;
189 alComments
.add(token
.getPrimaryKeyString());
198 This class is used to store the Size information for
199 POINTER TYPE PCD entry in a PCD database.
203 private ArrayList
<ArrayList
<Integer
>> al
;
204 private ArrayList
<String
> alComments
;
206 private String phase
;
208 public SizeTable (String phase
) {
209 al
= new ArrayList
<ArrayList
<Integer
>>();
210 alComments
= new ArrayList
<String
>();
215 public String
getSizeMacro () {
216 return String
.format(PcdDatabase
.SizeTableSizeMacro
, phase
, getSize());
219 private int getSize() {
220 return len
== 0 ?
1 : len
;
223 public void genCode (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) {
224 final String name
= "SizeTable";
226 CStructTypeDeclaration decl
;
229 cCode
= String
.format(PcdDatabase
.SizeTableDeclaration
, phase
);
230 decl
= new CStructTypeDeclaration (
239 cCode
= PcdDatabase
.genInstantiationStr(getInstantiation());
240 instTable
.put(name
, cCode
);
243 private ArrayList
<String
> getInstantiation () {
244 final String comma
= ",";
245 ArrayList
<String
> Output
= new ArrayList
<String
>();
247 Output
.add("/* SizeTable */");
249 if (al
.size() == 0) {
252 for (int index
= 0; index
< al
.size(); index
++) {
253 ArrayList
<Integer
> ial
= al
.get(index
);
257 for (int index2
= 0; index2
< ial
.size(); index2
++) {
258 str
+= " " + ial
.get(index2
).toString();
259 if (index2
!= ial
.size() - 1) {
264 str
+= " /* " + alComments
.get(index
) + " */";
266 if (index
!= (al
.size() - 1)) {
279 public void add (Token token
) {
282 // We only have size information for POINTER type PCD entry.
284 if (token
.datumType
!= Token
.DATUM_TYPE
.POINTER
) {
288 ArrayList
<Integer
> ial
= token
.getPointerTypeSize();
293 alComments
.add(token
.getPrimaryKeyString());
303 This class is used to store the GUIDs in a PCD database.
306 private ArrayList
<UUID
> al
;
307 private ArrayList
<String
> alComments
;
308 private String phase
;
310 private int bodyLineNum
;
312 public GuidTable (String phase
) {
314 al
= new ArrayList
<UUID
>();
315 alComments
= new ArrayList
<String
>();
320 public String
getSizeMacro () {
321 return String
.format(PcdDatabase
.GuidTableSizeMacro
, phase
, getSize());
324 private int getSize () {
325 return (al
.size() == 0)?
1 : al
.size();
328 public String
getExistanceMacro () {
329 return String
.format(PcdDatabase
.GuidTableExistenceMacro
, phase
, (al
.size() == 0)?
"TRUE":"FALSE");
332 public void genCode (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) {
333 final String name
= "GuidTable";
335 CStructTypeDeclaration decl
;
338 cCode
+= String
.format(PcdDatabase
.GuidTableDeclaration
, phase
);
339 decl
= new CStructTypeDeclaration (
348 cCode
= PcdDatabase
.genInstantiationStr(getInstantiation());
349 instTable
.put(name
, cCode
);
352 private String
getUuidCString (UUID uuid
) {
353 String
[] guidStrArray
;
355 guidStrArray
=(uuid
.toString()).split("-");
357 return String
.format("{0x%s, 0x%s, 0x%s, {0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s}}",
361 (guidStrArray
[3].substring(0, 2)),
362 (guidStrArray
[3].substring(2, 4)),
363 (guidStrArray
[4].substring(0, 2)),
364 (guidStrArray
[4].substring(2, 4)),
365 (guidStrArray
[4].substring(4, 6)),
366 (guidStrArray
[4].substring(6, 8)),
367 (guidStrArray
[4].substring(8, 10)),
368 (guidStrArray
[4].substring(10, 12))
372 private ArrayList
<String
> getInstantiation () {
373 ArrayList
<String
> Output
= new ArrayList
<String
>();
375 Output
.add("/* GuidTable */");
378 if (al
.size() == 0) {
379 Output
.add("\t" + getUuidCString(new UUID(0, 0)));
382 for (int i
= 0; i
< al
.size(); i
++) {
383 String str
= "\t" + getUuidCString(al
.get(i
));
385 str
+= "/* " + alComments
.get(i
) + " */";
386 if (i
!= (al
.size() - 1)) {
398 public int add (UUID uuid
, String name
) {
400 // Check if GuidTable has this entry already.
401 // If so, return the GuidTable index.
403 for (int i
= 0; i
< al
.size(); i
++) {
404 if (al
.get(i
).compareTo(uuid
) == 0) {
411 alComments
.add(name
);
414 // Return the previous Table Index
424 This class is used to store the SKU IDs in a PCD database.
428 private ArrayList
<Integer
[]> al
;
429 private ArrayList
<String
> alComment
;
430 private String phase
;
433 public SkuIdTable (String phase
) {
435 al
= new ArrayList
<Integer
[]>();
436 alComment
= new ArrayList
<String
>();
440 public String
getSizeMacro () {
441 return String
.format(PcdDatabase
.SkuIdTableSizeMacro
, phase
, getSize());
444 private int getSize () {
445 return (len
== 0)?
1 : len
;
448 public String
getExistanceMacro () {
449 return String
.format(PcdDatabase
.SkuTableExistenceMacro
, phase
, (al
.size() == 0)?
"TRUE":"FALSE");
452 public void genCode (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) {
453 final String name
= "SkuIdTable";
455 CStructTypeDeclaration decl
;
458 cCode
+= String
.format(PcdDatabase
.SkuIdTableDeclaration
, phase
);
459 decl
= new CStructTypeDeclaration (
468 cCode
= PcdDatabase
.genInstantiationStr(getInstantiation());
469 instTable
.put(name
, cCode
);
472 // SystemSkuId is in PEI phase PCD Database
474 if (phase
.equalsIgnoreCase("PEI")) {
475 decl
= new CStructTypeDeclaration (
478 String
.format("%-20sSystemSkuId;\r\n", "SKU_ID"),
483 instTable
.put("SystemSkuId", "0");
488 private ArrayList
<String
> getInstantiation () {
489 ArrayList
<String
> Output
= new ArrayList
<String
> ();
491 Output
.add("/* SkuIdTable */");
494 if (al
.size() == 0) {
498 for (int index
= 0; index
< al
.size(); index
++) {
501 str
= "/* " + alComment
.get(index
) + "*/ ";
502 str
+= "/* MaxSku */ ";
505 Integer
[] ia
= al
.get(index
);
507 str
+= "\t" + ia
[0].toString() + ", ";
508 for (int index2
= 1; index2
< ia
.length
; index2
++) {
509 str
+= ia
[index2
].toString();
510 if (!((index2
== ia
.length
- 1) && (index
== al
.size() - 1))) {
524 public int add (Token token
) {
530 // Check if this SKU_ID Array is already in the table
534 Integer
[] s
= (Integer
[]) o
;
535 boolean different
= false;
536 if (s
[0] == token
.getSkuIdCount()) {
537 for (index
= 1; index
< s
.length
; index
++) {
538 if (s
[index
] != token
.skuData
.get(index
-1).id
) {
553 Integer
[] skuIds
= new Integer
[token
.skuData
.size() + 1];
554 skuIds
[0] = new Integer(token
.skuData
.size());
555 for (index
= 1; index
< skuIds
.length
; index
++) {
556 skuIds
[index
] = new Integer(token
.skuData
.get(index
- 1).id
);
561 len
+= skuIds
.length
;
563 alComment
.add(token
.getPrimaryKeyString());
570 class LocalTokenNumberTable
{
571 private ArrayList
<String
> al
;
572 private ArrayList
<String
> alComment
;
573 private String phase
;
576 public LocalTokenNumberTable (String phase
) {
578 al
= new ArrayList
<String
>();
579 alComment
= new ArrayList
<String
>();
584 public String
getSizeMacro () {
585 return String
.format(PcdDatabase
.LocalTokenNumberTableSizeMacro
, phase
, getSize())
586 + String
.format(PcdDatabase
.LocalTokenNumberSizeMacro
, phase
, al
.size());
589 public int getSize () {
590 return (al
.size() == 0)?
1 : al
.size();
593 public String
getExistanceMacro () {
594 return String
.format(PcdDatabase
.DatabaseExistenceMacro
, phase
, (al
.size() == 0)?
"TRUE":"FALSE");
597 public void genCode (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) {
598 final String name
= "LocalTokenNumberTable";
600 CStructTypeDeclaration decl
;
603 cCode
+= String
.format(PcdDatabase
.LocalTokenNumberTableDeclaration
, phase
);
604 decl
= new CStructTypeDeclaration (
612 cCode
= PcdDatabase
.genInstantiationStr(getInstantiation());
613 instTable
.put(name
, cCode
);
616 private ArrayList
<String
> getInstantiation () {
617 ArrayList
<String
> output
= new ArrayList
<String
>();
619 output
.add("/* LocalTokenNumberTable */");
622 if (al
.size() == 0) {
626 for (int index
= 0; index
< al
.size(); index
++) {
629 str
= "\t" + (String
)al
.get(index
);
631 str
+= " /* " + alComment
.get(index
) + " */ ";
634 if (index
!= (al
.size() - 1)) {
647 public int add (Token token
) {
653 str
= String
.format(PcdDatabase
.offsetOfStrTemplate
, phase
, token
.hasDefaultValue() ?
"Init" : "Uninit", token
.getPrimaryKeyString());
655 if (token
.isUnicodeStringType()) {
656 str
+= " | PCD_TYPE_STRING";
659 if (token
.isSkuEnable()) {
660 str
+= " | PCD_TYPE_SKU_ENABLED";
663 if (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.HII_TYPE
) {
664 str
+= " | PCD_TYPE_HII";
667 if (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.VPD_TYPE
) {
668 str
+= " | PCD_TYPE_VPD";
671 switch (token
.datumType
) {
674 str
+= " | PCD_DATUM_TYPE_UINT8";
677 str
+= " | PCD_DATUM_TYPE_UINT16";
680 str
+= " | PCD_DATUM_TYPE_UINT32";
683 str
+= " | PCD_DATUM_TYPE_UINT64";
686 str
+= " | PCD_DATUM_TYPE_POINTER";
691 alComment
.add(token
.getPrimaryKeyString());
700 This class is used to store the table of mapping information
701 between DynamicEX ID pair(Guid, TokenNumber) and
702 the local token number assigned by PcdDatabase class.
709 This class is used to store the mapping information
710 between DynamicEX ID pair(Guid, TokenNumber) and
711 the local token number assigned by PcdDatabase class.
714 public Integer guidTableIdx
;
715 public Long exTokenNumber
;
716 public Long localTokenIdx
;
718 public ExTriplet (int guidTableIdx
, long exTokenNumber
, long localTokenIdx
) {
719 this.guidTableIdx
= new Integer(guidTableIdx
);
720 this.exTokenNumber
= new Long(exTokenNumber
);
721 this.localTokenIdx
= new Long(localTokenIdx
);
725 private ArrayList
<ExTriplet
> al
;
726 private Map
<ExTriplet
, String
> alComment
;
727 private String phase
;
729 private int bodyLineNum
;
731 public ExMapTable (String phase
) {
733 al
= new ArrayList
<ExTriplet
>();
734 alComment
= new HashMap
<ExTriplet
, String
>();
739 public String
getSizeMacro () {
740 return String
.format(PcdDatabase
.ExMapTableSizeMacro
, phase
, getTableLen())
741 + String
.format(PcdDatabase
.ExTokenNumber
, phase
, al
.size());
744 public String
getExistanceMacro () {
745 return String
.format(PcdDatabase
.ExMapTableExistenceMacro
, phase
, (al
.size() == 0)?
"TRUE":"FALSE");
748 public void genCode (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) {
749 final String exMapTableName
= "ExMapTable";
753 CStructTypeDeclaration decl
;
756 cCode
+= String
.format(PcdDatabase
.ExMapTableDeclaration
, phase
);
757 decl
= new CStructTypeDeclaration (
766 cCode
= PcdDatabase
.genInstantiationStr(getInstantiation());
767 instTable
.put(exMapTableName
, cCode
);
770 private ArrayList
<String
> getInstantiation () {
771 ArrayList
<String
> Output
= new ArrayList
<String
>();
773 Output
.add("/* ExMapTable */");
775 if (al
.size() == 0) {
776 Output
.add("\t{0, 0, 0}");
780 for (index
= 0; index
< al
.size(); index
++) {
783 ExTriplet e
= (ExTriplet
)al
.get(index
);
785 str
= "\t" + "{ " + String
.format("0x%08X", e
.exTokenNumber
) + ", ";
786 str
+= e
.localTokenIdx
.toString() + ", ";
787 str
+= e
.guidTableIdx
.toString();
789 str
+= "}" + " /* " + alComment
.get(e
) + " */" ;
791 if (index
!= al
.size() - 1) {
805 public int add (int localTokenIdx
, long exTokenNum
, int guidTableIdx
, String name
) {
809 ExTriplet et
= new ExTriplet(guidTableIdx
, exTokenNum
, localTokenIdx
);
812 alComment
.put(et
, name
);
817 private int getTableLen () {
818 return al
.size() == 0 ?
1 : al
.size();
822 // To simplify the algorithm for GetNextToken and GetNextTokenSpace in
823 // PCD PEIM/Driver, we need to sort the ExMapTable according to the
828 class ExTripletComp
implements Comparator
<ExTriplet
> {
829 public int compare (ExTriplet a
, ExTriplet b
) {
830 if (a
.guidTableIdx
== b
.guidTableIdx
) {
832 // exTokenNumber is long, we can't use simple substraction.
834 if (a
.exTokenNumber
> b
.exTokenNumber
) {
836 } else if (a
.exTokenNumber
== b
.exTokenNumber
) {
843 return a
.guidTableIdx
- b
.guidTableIdx
;
847 private void sortTable () {
848 java
.util
.Comparator
<ExTriplet
> comparator
= new ExTripletComp();
849 java
.util
.Collections
.sort(al
, comparator
);
856 This class is used to generate C code for Autogen.h and Autogen.c of
857 a PCD service DXE driver and PCD service PEIM.
859 public class PcdDatabase
{
861 private final static int SkuHeadAlignmentSize
= 4;
862 private final String newLine
= "\r\n";
863 private final String commaNewLine
= ",\r\n";
864 private final String tab
= "\t";
865 public final static String ExMapTableDeclaration
= "DYNAMICEX_MAPPING ExMapTable[%s_EXMAPPING_TABLE_SIZE];\r\n";
866 public final static String GuidTableDeclaration
= "EFI_GUID GuidTable[%s_GUID_TABLE_SIZE];\r\n";
867 public final static String LocalTokenNumberTableDeclaration
= "UINT32 LocalTokenNumberTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";
868 public final static String StringTableDeclaration
= "UINT16 StringTable[%s_STRING_TABLE_SIZE];\r\n";
869 public final static String SizeTableDeclaration
= "SIZE_INFO SizeTable[%s_SIZE_TABLE_SIZE];\r\n";
870 public final static String SkuIdTableDeclaration
= "UINT8 SkuIdTable[%s_SKUID_TABLE_SIZE];\r\n";
873 public final static String ExMapTableSizeMacro
= "#define %s_EXMAPPING_TABLE_SIZE %d\r\n";
874 public final static String ExTokenNumber
= "#define %s_EX_TOKEN_NUMBER %d\r\n";
875 public final static String GuidTableSizeMacro
= "#define %s_GUID_TABLE_SIZE %d\r\n";
876 public final static String LocalTokenNumberTableSizeMacro
= "#define %s_LOCAL_TOKEN_NUMBER_TABLE_SIZE %d\r\n";
877 public final static String LocalTokenNumberSizeMacro
= "#define %s_LOCAL_TOKEN_NUMBER %d\r\n";
878 public final static String SizeTableSizeMacro
= "#define %s_SIZE_TABLE_SIZE %d\r\n";
879 public final static String StringTableSizeMacro
= "#define %s_STRING_TABLE_SIZE %d\r\n";
880 public final static String SkuIdTableSizeMacro
= "#define %s_SKUID_TABLE_SIZE %d\r\n";
883 public final static String ExMapTableExistenceMacro
= "#define %s_EXMAP_TABLE_EMPTY %s\r\n";
884 public final static String GuidTableExistenceMacro
= "#define %s_GUID_TABLE_EMPTY %s\r\n";
885 public final static String DatabaseExistenceMacro
= "#define %s_DATABASE_EMPTY %s\r\n";
886 public final static String StringTableExistenceMacro
= "#define %s_STRING_TABLE_EMPTY %s\r\n";
887 public final static String SkuTableExistenceMacro
= "#define %s_SKUID_TABLE_EMPTY %s\r\n";
889 public final static String offsetOfSkuHeadStrTemplate
= "offsetof(%s_PCD_DATABASE, %s.%s_SkuDataTable)";
890 public final static String offsetOfVariableEnabledDefault
= "offsetof(%s_PCD_DATABASE, %s.%s_VariableDefault_%d)";
891 public final static String offsetOfStrTemplate
= "offsetof(%s_PCD_DATABASE, %s.%s)";
893 private final static String skuDataTableTemplate
= "SkuDataTable";
896 private StringTable stringTable
;
897 private GuidTable guidTable
;
898 private LocalTokenNumberTable localTokenNumberTable
;
899 private SkuIdTable skuIdTable
;
900 private SizeTable sizeTable
;
901 private ExMapTable exMapTable
;
903 private ArrayList
<Token
> alTokens
;
904 private String phase
;
905 private int assignedTokenNumber
;
908 // Use two class global variable to store
911 private String privateGlobalName
;
912 private String privateGlobalCCode
;
914 // After Major changes done to the PCD
915 // database generation class PcdDatabase
916 // Please increment the version and please
917 // also update the version number in PCD
918 // service PEIM and DXE driver accordingly.
920 private final int version
= 2;
922 private String hString
;
923 private String cString
;
926 Constructor for PcdDatabase class.
928 <p>We have two PCD dynamic(ex) database for the Framework implementation. One
929 for PEI phase and the other for DXE phase. </p>
931 @param alTokens A ArrayList of Dynamic(EX) PCD entry.
932 @param exePhase The phase to generate PCD database for: valid input
934 @param startLen The starting Local Token Number for the PCD database. For
935 PEI phase, the starting Local Token Number starts from 0.
936 For DXE phase, the starting Local Token Number starts
937 from the total number of PCD entry of PEI phase.
940 public PcdDatabase (ArrayList
<Token
> alTokens
, String exePhase
, int startLen
) {
943 stringTable
= new StringTable(phase
);
944 guidTable
= new GuidTable(phase
);
945 localTokenNumberTable
= new LocalTokenNumberTable(phase
);
946 skuIdTable
= new SkuIdTable(phase
);
947 sizeTable
= new SizeTable(phase
);
948 exMapTable
= new ExMapTable(phase
);
951 // Local token number 0 is reserved for INVALID_TOKEN_NUMBER.
952 // So we will increment 1 for the startLen passed from the
955 assignedTokenNumber
= startLen
+ 1;
956 this.alTokens
= alTokens
;
959 private void getNonExAndExTokens (ArrayList
<Token
> alTokens
, List
<Token
> nexTokens
, List
<Token
> exTokens
) {
960 for (int i
= 0; i
< alTokens
.size(); i
++) {
961 Token t
= (Token
)alTokens
.get(i
);
962 if (t
.isDynamicEx()) {
972 private int getDataTypeAlignmentSize (Token token
) {
973 switch (token
.datumType
) {
991 private int getHiiPtrTypeAlignmentSize(Token token
) {
992 switch (token
.datumType
) {
1002 if (token
.isHiiEnable()) {
1003 if (token
.isHiiDefaultValueUnicodeStringType()) {
1015 private int getAlignmentSize (Token token
) {
1016 if (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.HII_TYPE
) {
1020 if (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.VPD_TYPE
) {
1024 if (token
.isUnicodeStringType()) {
1028 return getDataTypeAlignmentSize(token
);
1031 public String
getCString () {
1035 public String
getHString () {
1039 private void genCodeWorker(Token t
,
1040 ArrayList
<CStructTypeDeclaration
> declaList
,
1041 HashMap
<String
, String
> instTable
, String phase
)
1042 throws EntityException
{
1044 CStructTypeDeclaration decl
;
1047 // Insert SKU_HEAD if isSkuEnable is true
1049 if (t
.isSkuEnable()) {
1051 tableIdx
= skuIdTable
.add(t
);
1052 decl
= new CStructTypeDeclaration(t
.getPrimaryKeyString(),
1053 SkuHeadAlignmentSize
, getSkuEnabledTypeDeclaration(t
), true);
1054 declaList
.add(decl
);
1055 instTable
.put(t
.getPrimaryKeyString(),
1056 getSkuEnabledTypeInstantiaion(t
, tableIdx
));
1060 // Insert PCD_ENTRY declaration and instantiation
1062 getCDeclarationString(t
);
1064 decl
= new CStructTypeDeclaration(privateGlobalName
,
1065 getAlignmentSize(t
), privateGlobalCCode
, t
.hasDefaultValue());
1066 declaList
.add(decl
);
1068 if (t
.hasDefaultValue()) {
1069 instTable
.put(privateGlobalName
,
1070 getTypeInstantiation(t
, declaList
, instTable
, phase
)
1076 private void ProcessTokens (List
<Token
> tokens
,
1077 ArrayList
<CStructTypeDeclaration
> cStructDeclList
,
1078 HashMap
<String
, String
> cStructInstTable
,
1081 throws EntityException
{
1083 for (int idx
= 0; idx
< tokens
.size(); idx
++) {
1084 Token t
= tokens
.get(idx
);
1086 genCodeWorker (t
, cStructDeclList
, cStructInstTable
, phase
);
1089 localTokenNumberTable
.add(t
);
1090 t
.tokenNumber
= assignedTokenNumber
++;
1093 // Add a mapping if this dynamic PCD entry is a EX type
1095 if (t
.isDynamicEx()) {
1096 exMapTable
.add((int)t
.tokenNumber
,
1097 t
.dynamicExTokenNumber
,
1098 guidTable
.add(translateSchemaStringToUUID(t
.tokenSpaceName
), t
.getPrimaryKeyString()),
1099 t
.getPrimaryKeyString()
1106 public void genCode () throws EntityException
{
1108 ArrayList
<CStructTypeDeclaration
> cStructDeclList
= new ArrayList
<CStructTypeDeclaration
>();
1109 HashMap
<String
, String
> cStructInstTable
= new HashMap
<String
, String
>();
1111 List
<Token
> nexTokens
= new ArrayList
<Token
> ();
1112 List
<Token
> exTokens
= new ArrayList
<Token
> ();
1114 getNonExAndExTokens (alTokens
, nexTokens
, exTokens
);
1117 // We have to process Non-Ex type PCD entry first. The reason is
1118 // that our optimization assumes that the Token Number of Non-Ex
1119 // PCD entry start from 1 (for PEI phase) and grows continously upwards.
1121 // EX type token number starts from the last Non-EX PCD entry and
1122 // grows continously upwards.
1124 ProcessTokens (nexTokens
, cStructDeclList
, cStructInstTable
, phase
);
1125 ProcessTokens (exTokens
, cStructDeclList
, cStructInstTable
, phase
);
1127 stringTable
.genCode(cStructDeclList
, cStructInstTable
);
1128 skuIdTable
.genCode(cStructDeclList
, cStructInstTable
, phase
);
1129 exMapTable
.genCode(cStructDeclList
, cStructInstTable
, phase
);
1130 localTokenNumberTable
.genCode(cStructDeclList
, cStructInstTable
, phase
);
1131 sizeTable
.genCode(cStructDeclList
, cStructInstTable
, phase
);
1132 guidTable
.genCode(cStructDeclList
, cStructInstTable
, phase
);
1134 hString
= genCMacroCode ();
1136 HashMap
<String
, String
> result
;
1138 result
= genCStructCode(cStructDeclList
,
1143 hString
+= result
.get("initDeclStr");
1144 hString
+= result
.get("uninitDeclStr");
1146 hString
+= String
.format("#define PCD_%s_SERVICE_DRIVER_VERSION %d", phase
, version
);
1148 cString
= newLine
+ newLine
+ result
.get("initInstStr");
1152 private String
genCMacroCode () {
1153 String macroStr
= "";
1156 // Generate size info Macro for all Tables
1158 macroStr
+= guidTable
.getSizeMacro();
1159 macroStr
+= stringTable
.getSizeMacro();
1160 macroStr
+= skuIdTable
.getSizeMacro();
1161 macroStr
+= localTokenNumberTable
.getSizeMacro();
1162 macroStr
+= exMapTable
.getSizeMacro();
1163 macroStr
+= sizeTable
.getSizeMacro();
1166 // Generate existance info Macro for all Tables
1168 macroStr
+= guidTable
.getExistanceMacro();
1169 macroStr
+= stringTable
.getExistanceMacro();
1170 macroStr
+= skuIdTable
.getExistanceMacro();
1171 macroStr
+= localTokenNumberTable
.getExistanceMacro();
1172 macroStr
+= exMapTable
.getExistanceMacro();
1174 macroStr
+= newLine
;
1179 private HashMap
<String
, String
> genCStructCode(
1180 ArrayList
<CStructTypeDeclaration
> declaList
,
1181 HashMap
<String
, String
> instTable
,
1186 HashMap
<String
, String
> result
= new HashMap
<String
, String
>();
1187 HashMap
<Integer
, ArrayList
<String
>> alignmentInitDecl
= new HashMap
<Integer
, ArrayList
<String
>>();
1188 HashMap
<Integer
, ArrayList
<String
>> alignmentUninitDecl
= new HashMap
<Integer
, ArrayList
<String
>>();
1189 HashMap
<Integer
, ArrayList
<String
>> alignmentInitInst
= new HashMap
<Integer
, ArrayList
<String
>>();
1192 // Initialize the storage for each alignment
1194 for (i
= 8; i
> 0; i
>>=1) {
1195 alignmentInitDecl
.put(new Integer(i
), new ArrayList
<String
>());
1196 alignmentInitInst
.put(new Integer(i
), new ArrayList
<String
>());
1197 alignmentUninitDecl
.put(new Integer(i
), new ArrayList
<String
>());
1200 String initDeclStr
= "typedef struct {" + newLine
;
1201 String initInstStr
= String
.format("%s_PCD_DATABASE_INIT g%sPcdDbInit = { ", phase
.toUpperCase(), phase
.toUpperCase()) + newLine
;
1202 String uninitDeclStr
= "typedef struct {" + newLine
;
1205 // Sort all C declaration and instantiation base on Alignment Size
1207 for (Object d
: declaList
) {
1208 CStructTypeDeclaration decl
= (CStructTypeDeclaration
) d
;
1210 if (decl
.initTable
) {
1211 alignmentInitDecl
.get(new Integer(decl
.alignmentSize
)).add(decl
.cCode
);
1212 alignmentInitInst
.get(new Integer(decl
.alignmentSize
)).add(instTable
.get(decl
.key
));
1214 alignmentUninitDecl
.get(new Integer(decl
.alignmentSize
)).add(decl
.cCode
);
1219 // Generate code for every alignment size
1221 boolean uinitDatabaseEmpty
= true;
1222 for (int align
= 8; align
> 0; align
>>= 1) {
1223 ArrayList
<String
> declaListBasedOnAlignment
= alignmentInitDecl
.get(new Integer(align
));
1224 ArrayList
<String
> instListBasedOnAlignment
= alignmentInitInst
.get(new Integer(align
));
1225 for (i
= 0; i
< declaListBasedOnAlignment
.size(); i
++) {
1226 initDeclStr
+= tab
+ declaListBasedOnAlignment
.get(i
);
1227 initInstStr
+= tab
+ instListBasedOnAlignment
.get(i
);
1230 // We made a assumption that both PEI_PCD_DATABASE and DXE_PCD_DATABASE
1231 // has a least one data memember with alignment size of 1. So we can
1232 // remove the last "," in the C structure instantiation string. Luckily,
1233 // this is true as both data structure has SKUID_TABLE anyway.
1235 if ((align
== 1) && (i
== declaListBasedOnAlignment
.size() - 1)) {
1236 initInstStr
+= newLine
;
1238 initInstStr
+= commaNewLine
;
1242 declaListBasedOnAlignment
= alignmentUninitDecl
.get(new Integer(align
));
1244 if (declaListBasedOnAlignment
.size() != 0) {
1245 uinitDatabaseEmpty
= false;
1248 for (Object d
: declaListBasedOnAlignment
) {
1249 String s
= (String
)d
;
1250 uninitDeclStr
+= tab
+ s
;
1254 if (uinitDatabaseEmpty
) {
1255 uninitDeclStr
+= tab
+ String
.format("%-20sdummy; /* PCD_DATABASE_UNINIT is emptry */\r\n", "UINT8");
1258 initDeclStr
+= String
.format("} %s_PCD_DATABASE_INIT;", phase
) + newLine
+ newLine
;
1259 initInstStr
+= "};" + newLine
;
1260 uninitDeclStr
+= String
.format("} %s_PCD_DATABASE_UNINIT;", phase
) + newLine
+ newLine
;
1262 result
.put("initDeclStr", initDeclStr
);
1263 result
.put("initInstStr", initInstStr
);
1264 result
.put("uninitDeclStr", uninitDeclStr
);
1269 public static String
genInstantiationStr (ArrayList
<String
> alStr
) {
1271 for (int i
= 0; i
< alStr
.size(); i
++) {
1275 str
+= alStr
.get(i
);
1276 if (i
!= alStr
.size() - 1) {
1284 private String
getSkuEnabledTypeDeclaration (Token token
) {
1285 return String
.format("%-20s%s;\r\n", "SKU_HEAD", token
.getPrimaryKeyString());
1288 private String
getSkuEnabledTypeInstantiaion (Token token
, int SkuTableIdx
) {
1290 String offsetof
= String
.format(PcdDatabase
.offsetOfSkuHeadStrTemplate
, phase
, token
.hasDefaultValue()?
"Init" : "Uninit", token
.getPrimaryKeyString());
1291 return String
.format("{ %s, %d } /* SKU_ENABLED: %s */", offsetof
, SkuTableIdx
, token
.getPrimaryKeyString());
1294 private String
getDataTypeInstantiationForVariableDefault (Token token
, String cName
, int skuId
) {
1295 return String
.format("%s /* %s */", token
.skuData
.get(skuId
).value
.hiiDefaultValue
, cName
);
1298 private String
getCType (Token t
)
1299 throws EntityException
{
1301 if (t
.isHiiEnable()) {
1302 return "VARIABLE_HEAD";
1305 if (t
.isVpdEnable()) {
1309 if (t
.isUnicodeStringType()) {
1310 return "STRING_HEAD";
1313 switch (t
.datumType
) {
1327 throw new EntityException("Unknown DatumType in getDataTypeCDeclaration");
1332 // privateGlobalName and privateGlobalCCode is used to pass output to caller of getCDeclarationString
1334 private void getCDeclarationString(Token t
)
1335 throws EntityException
{
1337 if (t
.isSkuEnable()) {
1338 privateGlobalName
= String
.format("%s_%s", t
.getPrimaryKeyString(), skuDataTableTemplate
);
1340 privateGlobalName
= t
.getPrimaryKeyString();
1343 String type
= getCType(t
);
1344 if ((t
.datumType
== Token
.DATUM_TYPE
.POINTER
) && (!t
.isHiiEnable()) && (!t
.isUnicodeStringType())) {
1346 if (t
.isASCIIStringType()) {
1348 // Build tool will add a NULL string at the end of the ASCII string
1350 bufferSize
= t
.datumSize
+ 1;
1352 bufferSize
= t
.datumSize
;
1354 privateGlobalCCode
= String
.format("%-20s%s[%d][%d];\r\n", type
, privateGlobalName
, t
.getSkuIdCount(), bufferSize
);
1356 privateGlobalCCode
= String
.format("%-20s%s[%d];\r\n", type
, privateGlobalName
, t
.getSkuIdCount());
1360 private String
getDataTypeDeclarationForVariableDefault (Token token
, String cName
, int skuId
)
1361 throws EntityException
{
1365 if (token
.datumType
== Token
.DATUM_TYPE
.UINT8
) {
1367 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT16
) {
1369 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT32
) {
1371 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT64
) {
1373 } else if (token
.datumType
== Token
.DATUM_TYPE
.BOOLEAN
) {
1374 typeStr
= "BOOLEAN";
1375 } else if (token
.datumType
== Token
.DATUM_TYPE
.POINTER
) {
1377 if (token
.isHiiDefaultValueUnicodeStringType()) {
1380 // Include the NULL charactor
1382 size
= token
.datumSize
/ 2 + 1;
1385 if (token
.isHiiDefaultValueASCIIStringType()) {
1387 // Include the NULL charactor
1389 size
= token
.datumSize
+ 1;
1391 size
= token
.datumSize
;
1394 return String
.format("%-20s%s[%d];\r\n", typeStr
, cName
, size
);
1396 throw new EntityException("Unknown DATUM_TYPE type in when generating code for VARIABLE_ENABLED PCD entry");
1399 return String
.format("%-20s%s;\r\n", typeStr
, cName
);
1402 private String
getTypeInstantiation (Token t
, ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) throws EntityException
{
1407 s
= String
.format("/* %s */", t
.getPrimaryKeyString()) + newLine
;
1408 s
+= tab
+ "{" + newLine
;
1410 for (i
= 0; i
< t
.skuData
.size(); i
++) {
1411 if (t
.isUnicodeStringType()) {
1412 s
+= tab
+ tab
+ String
.format("{ %d }", stringTable
.add(t
.skuData
.get(i
).value
.value
, t
));
1413 } else if (t
.isHiiEnable()) {
1414 /* VPD_HEAD definition
1416 UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
1417 UINT16 StringIndex; // Offset in String Table in units of UINT16.
1418 UINT16 Offset; // Offset in Variable
1419 UINT16 DefaultValueOffset; // Offset of the Default Value
1422 String variableDefaultName
= String
.format("%s_VariableDefault_%d", t
.getPrimaryKeyString(), i
);
1424 s
+= tab
+ tab
+ String
.format("{ %d, %d, %s, %s }", guidTable
.add(t
.skuData
.get(i
).value
.variableGuid
, t
.getPrimaryKeyString()),
1425 stringTable
.add(t
.skuData
.get(i
).value
.getStringOfVariableName(), t
),
1426 t
.skuData
.get(i
).value
.variableOffset
,
1427 String
.format("offsetof(%s_PCD_DATABASE, Init.%s)", phase
, variableDefaultName
)
1430 // We need to support the default value, so we add the declaration and
1431 // the instantiation for the default value.
1433 CStructTypeDeclaration decl
= new CStructTypeDeclaration (variableDefaultName
,
1434 getHiiPtrTypeAlignmentSize(t
),
1435 getDataTypeDeclarationForVariableDefault(t
, variableDefaultName
, i
),
1438 declaList
.add(decl
);
1439 instTable
.put(variableDefaultName
, getDataTypeInstantiationForVariableDefault (t
, variableDefaultName
, i
));
1440 } else if (t
.isVpdEnable()) {
1445 s
+= tab
+ tab
+ String
.format("{ %s }", t
.skuData
.get(i
).value
.vpdOffset
);
1447 if (t
.isByteStreamType()) {
1449 // Byte stream type input has their own "{" "}", so we won't help to insert.
1451 s
+= tab
+ tab
+ String
.format(" %s ", t
.skuData
.get(i
).value
.value
);
1453 s
+= tab
+ tab
+ String
.format("{ %s }", t
.skuData
.get(i
).value
.value
);
1457 if (i
!= t
.skuData
.size() - 1) {
1470 public static String
getPcdDatabaseCommonDefinitions () {
1475 retStr
+= "// The following definition will be generated by build tool\r\n";
1479 retStr
+= "// Common definitions\r\n";
1481 retStr
+= "typedef UINT8 SKU_ID;\r\n";
1483 retStr
+= "#define PCD_TYPE_SHIFT 28\r\n";
1485 retStr
+= "#define PCD_TYPE_DATA (0x0 << PCD_TYPE_SHIFT)\r\n";
1486 retStr
+= "#define PCD_TYPE_HII (0x8 << PCD_TYPE_SHIFT)\r\n";
1487 retStr
+= "#define PCD_TYPE_VPD (0x4 << PCD_TYPE_SHIFT)\r\n";
1488 retStr
+= "#define PCD_TYPE_SKU_ENABLED (0x2 << PCD_TYPE_SHIFT)\r\n";
1489 retStr
+= "#define PCD_TYPE_STRING (0x1 << PCD_TYPE_SHIFT)\r\n";
1491 retStr
+= "#define PCD_TYPE_ALL_SET (PCD_TYPE_DATA | PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING)\r\n";
1493 retStr
+= "#define PCD_DATUM_TYPE_SHIFT 24\r\n";
1495 retStr
+= "#define PCD_DATUM_TYPE_POINTER (0x0 << PCD_DATUM_TYPE_SHIFT)\r\n";
1496 retStr
+= "#define PCD_DATUM_TYPE_UINT8 (0x1 << PCD_DATUM_TYPE_SHIFT)\r\n";
1497 retStr
+= "#define PCD_DATUM_TYPE_UINT16 (0x2 << PCD_DATUM_TYPE_SHIFT)\r\n";
1498 retStr
+= "#define PCD_DATUM_TYPE_UINT32 (0x4 << PCD_DATUM_TYPE_SHIFT)\r\n";
1499 retStr
+= "#define PCD_DATUM_TYPE_UINT64 (0x8 << PCD_DATUM_TYPE_SHIFT)\r\n";
1501 retStr
+= "#define PCD_DATUM_TYPE_ALL_SET (PCD_DATUM_TYPE_POINTER | \\\r\n";
1502 retStr
+= " PCD_DATUM_TYPE_UINT8 | \\\r\n";
1503 retStr
+= " PCD_DATUM_TYPE_UINT16 | \\\r\n";
1504 retStr
+= " PCD_DATUM_TYPE_UINT32 | \\\r\n";
1505 retStr
+= " PCD_DATUM_TYPE_UINT64)\r\n";
1508 retStr
+= "#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET | PCD_DATUM_TYPE_ALL_SET))\r\n";
1510 retStr
+= "typedef struct {\r\n";
1511 retStr
+= " UINT32 ExTokenNumber;\r\n";
1512 retStr
+= " UINT16 LocalTokenNumber; // PCD Number of this particular platform build\r\n";
1513 retStr
+= " UINT16 ExGuidIndex; // Index of GuidTable\r\n";
1514 retStr
+= "} DYNAMICEX_MAPPING;\r\n";
1517 retStr
+= "typedef struct {\r\n";
1518 retStr
+= " UINT32 SkuDataStartOffset; //We have to use offsetof MACRO as we don't know padding done by compiler\r\n";
1519 retStr
+= " UINT32 SkuIdTableOffset; //Offset from the PCD_DB\r\n";
1520 retStr
+= "} SKU_HEAD;\r\n";
1523 retStr
+= "typedef struct {\r\n";
1524 retStr
+= " UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.\r\n";
1525 retStr
+= " UINT16 StringIndex; // Offset in String Table in units of UINT16.\r\n";
1526 retStr
+= " UINT16 Offset; // Offset in Variable\r\n";
1527 retStr
+= " UINT16 DefaultValueOffset; // Offset of the Default Value\r\n";
1528 retStr
+= "} VARIABLE_HEAD ;\r\n";
1531 retStr
+= "typedef struct {\r\n";
1532 retStr
+= " UINT32 Offset;\r\n";
1533 retStr
+= "} VPD_HEAD;\r\n";
1535 retStr
+= "typedef UINT16 STRING_HEAD;\r\n";
1537 retStr
+= "typedef UINT16 SIZE_INFO;\r\n";
1539 retStr
+= "#define offsetof(s,m) (UINT32) (UINTN) &(((s *)0)->m)\r\n";
1547 public static String
getPcdDxeDatabaseDefinitions ()
1548 throws EntityException
{
1553 retStr
+= "typedef struct {\r\n";
1554 retStr
+= " DXE_PCD_DATABASE_INIT Init;\r\n";
1555 retStr
+= " DXE_PCD_DATABASE_UNINIT Uninit;\r\n";
1556 retStr
+= "} DXE_PCD_DATABASE;\r\n";
1559 retStr
+= "typedef struct {\r\n";
1560 retStr
+= " PEI_PCD_DATABASE PeiDb;\r\n";
1561 retStr
+= " DXE_PCD_DATABASE DxeDb;\r\n";
1562 retStr
+= "} PCD_DATABASE;\r\n";
1564 retStr
+= "#define DXE_NEX_TOKEN_NUMBER (DXE_LOCAL_TOKEN_NUMBER - DXE_EX_TOKEN_NUMBER)\r\n";
1566 retStr
+= "#define PCD_TOTAL_TOKEN_NUMBER (PEI_LOCAL_TOKEN_NUMBER + DXE_LOCAL_TOKEN_NUMBER)\r\n";
1573 public static String
getPcdPeiDatabaseDefinitions ()
1574 throws EntityException
{
1579 retStr
+= "typedef struct {\r\n";
1580 retStr
+= " PEI_PCD_DATABASE_INIT Init;\r\n";
1581 retStr
+= " PEI_PCD_DATABASE_UNINIT Uninit;\r\n";
1582 retStr
+= "} PEI_PCD_DATABASE;\r\n";
1584 retStr
+= "#define PEI_NEX_TOKEN_NUMBER (PEI_LOCAL_TOKEN_NUMBER - PEI_EX_TOKEN_NUMBER)\r\n";
1591 Translate the schema string to UUID instance.
1593 In schema, the string of UUID is defined as following two types string:
1594 1) GuidArrayType: pattern = 0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},(
1595 )*0x[a-fA-F0-9]{1,4}(,( )*\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\})?
1597 2) GuidNamingConvention: pattern =
1598 [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}
1600 This function will convert string and create uuid instance.
1602 @param uuidString UUID string in XML file
1604 @return UUID UUID instance
1606 private UUID
translateSchemaStringToUUID(String uuidString
)
1607 throws EntityException
{
1609 String
[] splitStringArray
;
1614 if (uuidString
== null) {
1618 if (uuidString
.length() == 0) {
1622 if (uuidString
.equals("0") ||
1623 uuidString
.equalsIgnoreCase("0x0")) {
1624 return new UUID(0, 0);
1627 uuidString
= uuidString
.replaceAll("\\{", "");
1628 uuidString
= uuidString
.replaceAll("\\}", "");
1631 // If the UUID schema string is GuidArrayType type then need translate
1632 // to GuidNamingConvention type at first.
1634 if ((uuidString
.charAt(0) == '0') && ((uuidString
.charAt(1) == 'x') || (uuidString
.charAt(1) == 'X'))) {
1635 splitStringArray
= uuidString
.split("," );
1636 if (splitStringArray
.length
!= 11) {
1637 throw new EntityException ("[FPD file error] Wrong format for GUID string: " + uuidString
);
1641 // Remove blank space from these string and remove header string "0x"
1643 for (index
= 0; index
< 11; index
++) {
1644 splitStringArray
[index
] = splitStringArray
[index
].trim();
1645 splitStringArray
[index
] = splitStringArray
[index
].substring(2, splitStringArray
[index
].length());
1649 // Add heading '0' to normalize the string length
1651 for (index
= 3; index
< 11; index
++) {
1652 chLen
= splitStringArray
[index
].length();
1653 for (chIndex
= 0; chIndex
< 2 - chLen
; chIndex
++) {
1654 splitStringArray
[index
] = "0" + splitStringArray
[index
];
1659 // construct the final GuidNamingConvention string
1661 temp
= String
.format("%s-%s-%s-%s%s-%s%s%s%s%s%s",
1662 splitStringArray
[0],
1663 splitStringArray
[1],
1664 splitStringArray
[2],
1665 splitStringArray
[3],
1666 splitStringArray
[4],
1667 splitStringArray
[5],
1668 splitStringArray
[6],
1669 splitStringArray
[7],
1670 splitStringArray
[8],
1671 splitStringArray
[9],
1672 splitStringArray
[10]);
1676 return UUID
.fromString(uuidString
);