alTokens;
private String phase;
private int assignedTokenNumber;
//
// Use two class global variable to store
// temperary
//
private String privateGlobalName;
private String privateGlobalCCode;
//
// After Major changes done to the PCD
// database generation class PcdDatabase
// Please increment the version and please
// also update the version number in PCD
// service PEIM and DXE driver accordingly.
//
private final int version = 2;
private String hString;
private String cString;
/**
Constructor for PcdDatabase class.
We have two PCD dynamic(ex) database for the Framework implementation. One
for PEI phase and the other for DXE phase.
@param alTokens A ArrayList of Dynamic(EX) PCD entry.
@param exePhase The phase to generate PCD database for: valid input
is "PEI" or "DXE".
@param startLen The starting Local Token Number for the PCD database. For
PEI phase, the starting Local Token Number starts from 0.
For DXE phase, the starting Local Token Number starts
from the total number of PCD entry of PEI phase.
@return void
**/
public PcdDatabase (ArrayList alTokens, String exePhase, int startLen) {
phase = exePhase;
stringTable = new StringTable(phase);
guidTable = new GuidTable(phase);
localTokenNumberTable = new LocalTokenNumberTable(phase);
skuIdTable = new SkuIdTable(phase);
sizeTable = new SizeTable(phase);
exMapTable = new ExMapTable(phase);
//
// Local token number 0 is reserved for INVALID_TOKEN_NUMBER.
// So we will increment 1 for the startLen passed from the
// constructor.
//
assignedTokenNumber = startLen + 1;
this.alTokens = alTokens;
}
private void getNonExAndExTokens (ArrayList alTokens, List nexTokens, List exTokens) {
for (int i = 0; i < alTokens.size(); i++) {
Token t = (Token)alTokens.get(i);
if (t.isDynamicEx()) {
exTokens.add(t);
} else {
nexTokens.add(t);
}
}
return;
}
private int getDataTypeAlignmentSize (Token token) {
switch (token.datumType) {
case UINT8:
return 1;
case UINT16:
return 2;
case UINT32:
return 4;
case UINT64:
return 8;
case POINTER:
return 1;
case BOOLEAN:
return 1;
default:
return 1;
}
}
private int getHiiPtrTypeAlignmentSize(Token token) {
switch (token.datumType) {
case UINT8:
return 1;
case UINT16:
return 2;
case UINT32:
return 4;
case UINT64:
return 8;
case POINTER:
if (token.isHiiEnable()) {
if (token.isHiiDefaultValueUnicodeStringType()) {
return 2;
}
}
return 1;
case BOOLEAN:
return 1;
default:
return 1;
}
}
private int getAlignmentSize (Token token) {
if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {
return 2;
}
if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {
return 4;
}
if (token.isUnicodeStringType()) {
return 2;
}
return getDataTypeAlignmentSize(token);
}
public String getCString () {
return cString;
}
public String getHString () {
return hString;
}
private void genCodeWorker(Token t,
ArrayList declaList,
HashMap instTable, String phase)
throws EntityException {
CStructTypeDeclaration decl;
//
// Insert SKU_HEAD if isSkuEnable is true
//
if (t.isSkuEnable()) {
int tableIdx;
tableIdx = skuIdTable.add(t);
decl = new CStructTypeDeclaration(t.getPrimaryKeyString(),
SkuHeadAlignmentSize, getSkuEnabledTypeDeclaration(t), true);
declaList.add(decl);
instTable.put(t.getPrimaryKeyString(),
getSkuEnabledTypeInstantiaion(t, tableIdx));
}
//
// Insert PCD_ENTRY declaration and instantiation
//
getCDeclarationString(t);
decl = new CStructTypeDeclaration(privateGlobalName,
getAlignmentSize(t), privateGlobalCCode, t.hasDefaultValue());
declaList.add(decl);
if (t.hasDefaultValue()) {
instTable.put(privateGlobalName,
getTypeInstantiation(t, declaList, instTable, phase)
);
}
}
private void ProcessTokens (List tokens,
ArrayList cStructDeclList,
HashMap cStructInstTable,
String phase
)
throws EntityException {
for (int idx = 0; idx < tokens.size(); idx++) {
Token t = tokens.get(idx);
genCodeWorker (t, cStructDeclList, cStructInstTable, phase);
sizeTable.add(t);
localTokenNumberTable.add(t);
t.tokenNumber = assignedTokenNumber++;
//
// Add a mapping if this dynamic PCD entry is a EX type
//
if (t.isDynamicEx()) {
exMapTable.add((int)t.tokenNumber,
t.dynamicExTokenNumber,
guidTable.add(translateSchemaStringToUUID(t.tokenSpaceName), t.getPrimaryKeyString()),
t.getPrimaryKeyString()
);
}
}
}
public void genCode () throws EntityException {
ArrayList cStructDeclList = new ArrayList();
HashMap cStructInstTable = new HashMap();
List nexTokens = new ArrayList ();
List exTokens = new ArrayList ();
getNonExAndExTokens (alTokens, nexTokens, exTokens);
//
// We have to process Non-Ex type PCD entry first. The reason is
// that our optimization assumes that the Token Number of Non-Ex
// PCD entry start from 1 (for PEI phase) and grows continously upwards.
//
// EX type token number starts from the last Non-EX PCD entry and
// grows continously upwards.
//
ProcessTokens (nexTokens, cStructDeclList, cStructInstTable, phase);
ProcessTokens (exTokens, cStructDeclList, cStructInstTable, phase);
stringTable.genCode(cStructDeclList, cStructInstTable);
skuIdTable.genCode(cStructDeclList, cStructInstTable, phase);
exMapTable.genCode(cStructDeclList, cStructInstTable, phase);
localTokenNumberTable.genCode(cStructDeclList, cStructInstTable, phase);
sizeTable.genCode(cStructDeclList, cStructInstTable, phase);
guidTable.genCode(cStructDeclList, cStructInstTable, phase);
hString = genCMacroCode ();
HashMap result;
result = genCStructCode(cStructDeclList,
cStructInstTable,
phase
);
hString += result.get("initDeclStr");
hString += result.get("uninitDeclStr");
hString += String.format("#define PCD_%s_SERVICE_DRIVER_AUTOGEN_VERSION %d", phase, version);
cString = newLine + newLine + result.get("initInstStr");
}
private String genCMacroCode () {
String macroStr = "";
//
// Generate size info Macro for all Tables
//
macroStr += guidTable.getSizeMacro();
macroStr += stringTable.getSizeMacro();
macroStr += skuIdTable.getSizeMacro();
macroStr += localTokenNumberTable.getSizeMacro();
macroStr += exMapTable.getSizeMacro();
macroStr += sizeTable.getSizeMacro();
//
// Generate existance info Macro for all Tables
//
macroStr += guidTable.getExistanceMacro();
macroStr += stringTable.getExistanceMacro();
macroStr += skuIdTable.getExistanceMacro();
macroStr += localTokenNumberTable.getExistanceMacro();
macroStr += exMapTable.getExistanceMacro();
macroStr += newLine;
return macroStr;
}
private HashMap genCStructCode(
ArrayList declaList,
HashMap instTable,
String phase
) {
int i;
HashMap result = new HashMap();
HashMap > alignmentInitDecl = new HashMap>();
HashMap > alignmentUninitDecl = new HashMap>();
HashMap > alignmentInitInst = new HashMap>();
//
// Initialize the storage for each alignment
//
for (i = 8; i > 0; i>>=1) {
alignmentInitDecl.put(new Integer(i), new ArrayList());
alignmentInitInst.put(new Integer(i), new ArrayList());
alignmentUninitDecl.put(new Integer(i), new ArrayList());
}
String initDeclStr = "typedef struct {" + newLine;
String initInstStr = String.format("%s_PCD_DATABASE_INIT g%sPcdDbInit = { ", phase.toUpperCase(), phase.toUpperCase()) + newLine;
String uninitDeclStr = "typedef struct {" + newLine;
//
// Sort all C declaration and instantiation base on Alignment Size
//
for (Object d : declaList) {
CStructTypeDeclaration decl = (CStructTypeDeclaration) d;
if (decl.initTable) {
alignmentInitDecl.get(new Integer(decl.alignmentSize)).add(decl.cCode);
alignmentInitInst.get(new Integer(decl.alignmentSize)).add(instTable.get(decl.key));
} else {
alignmentUninitDecl.get(new Integer(decl.alignmentSize)).add(decl.cCode);
}
}
//
// Generate code for every alignment size
//
boolean uinitDatabaseEmpty = true;
for (int align = 8; align > 0; align >>= 1) {
ArrayList declaListBasedOnAlignment = alignmentInitDecl.get(new Integer(align));
ArrayList instListBasedOnAlignment = alignmentInitInst.get(new Integer(align));
for (i = 0; i < declaListBasedOnAlignment.size(); i++) {
initDeclStr += tab + declaListBasedOnAlignment.get(i);
initInstStr += tab + instListBasedOnAlignment.get(i);
//
// We made a assumption that both PEI_PCD_DATABASE and DXE_PCD_DATABASE
// has a least one data memember with alignment size of 1. So we can
// remove the last "," in the C structure instantiation string. Luckily,
// this is true as both data structure has SKUID_TABLE anyway.
//
if ((align == 1) && (i == declaListBasedOnAlignment.size() - 1)) {
initInstStr += newLine;
} else {
initInstStr += commaNewLine;
}
}
declaListBasedOnAlignment = alignmentUninitDecl.get(new Integer(align));
if (declaListBasedOnAlignment.size() != 0) {
uinitDatabaseEmpty = false;
}
for (Object d : declaListBasedOnAlignment) {
String s = (String)d;
uninitDeclStr += tab + s;
}
}
if (uinitDatabaseEmpty) {
uninitDeclStr += tab + String.format("%-20sdummy; /* PCD_DATABASE_UNINIT is emptry */\r\n", "UINT8");
}
initDeclStr += String.format("} %s_PCD_DATABASE_INIT;", phase) + newLine + newLine;
initInstStr += "};" + newLine;
uninitDeclStr += String.format("} %s_PCD_DATABASE_UNINIT;", phase) + newLine + newLine;
result.put("initDeclStr", initDeclStr);
result.put("initInstStr", initInstStr);
result.put("uninitDeclStr", uninitDeclStr);
return result;
}
public static String genInstantiationStr (ArrayList alStr) {
String str = "";
for (int i = 0; i< alStr.size(); i++) {
if (i != 0) {
str += "\t";
}
str += alStr.get(i);
if (i != alStr.size() - 1) {
str += "\r\n";
}
}
return str;
}
private String getSkuEnabledTypeDeclaration (Token token) {
return String.format("%-20s%s;\r\n", "SKU_HEAD", token.getPrimaryKeyString());
}
private String getSkuEnabledTypeInstantiaion (Token token, int SkuTableIdx) {
String offsetof = String.format(PcdDatabase.offsetOfSkuHeadStrTemplate, phase, token.hasDefaultValue()? "Init" : "Uninit", token.getPrimaryKeyString());
return String.format("{ %s, %d } /* SKU_ENABLED: %s */", offsetof, SkuTableIdx, token.getPrimaryKeyString());
}
private String getDataTypeInstantiationForVariableDefault (Token token, String cName, int skuId) {
return String.format("%s /* %s */", token.skuData.get(skuId).value.hiiDefaultValue, cName);
}
private String getCType (Token t)
throws EntityException {
if (t.isHiiEnable()) {
return "VARIABLE_HEAD";
}
if (t.isVpdEnable()) {
return "VPD_HEAD";
}
if (t.isUnicodeStringType()) {
return "STRING_HEAD";
}
switch (t.datumType) {
case UINT64:
return "UINT64";
case UINT32:
return "UINT32";
case UINT16:
return "UINT16";
case UINT8:
return "UINT8";
case BOOLEAN:
return "BOOLEAN";
case POINTER:
return "UINT8";
default:
throw new EntityException("Unknown DatumType in getDataTypeCDeclaration");
}
}
//
// privateGlobalName and privateGlobalCCode is used to pass output to caller of getCDeclarationString
//
private void getCDeclarationString(Token t)
throws EntityException {
if (t.isSkuEnable()) {
privateGlobalName = String.format("%s_%s", t.getPrimaryKeyString(), skuDataTableTemplate);
} else {
privateGlobalName = t.getPrimaryKeyString();
}
String type = getCType(t);
if ((t.datumType == Token.DATUM_TYPE.POINTER) && (!t.isHiiEnable()) && (!t.isUnicodeStringType())) {
int bufferSize;
if (t.isASCIIStringType()) {
//
// Build tool will add a NULL string at the end of the ASCII string
//
bufferSize = t.datumSize + 1;
} else {
bufferSize = t.datumSize;
}
privateGlobalCCode = String.format("%-20s%s[%d][%d];\r\n", type, privateGlobalName, t.getSkuIdCount(), bufferSize);
} else {
privateGlobalCCode = String.format("%-20s%s[%d];\r\n", type, privateGlobalName, t.getSkuIdCount());
}
}
private String getDataTypeDeclarationForVariableDefault (Token token, String cName, int skuId)
throws EntityException {
String typeStr;
if (token.datumType == Token.DATUM_TYPE.UINT8) {
typeStr = "UINT8";
} else if (token.datumType == Token.DATUM_TYPE.UINT16) {
typeStr = "UINT16";
} else if (token.datumType == Token.DATUM_TYPE.UINT32) {
typeStr = "UINT32";
} else if (token.datumType == Token.DATUM_TYPE.UINT64) {
typeStr = "UINT64";
} else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) {
typeStr = "BOOLEAN";
} else if (token.datumType == Token.DATUM_TYPE.POINTER) {
int size;
if (token.isHiiDefaultValueUnicodeStringType()) {
typeStr = "UINT16";
//
// Include the NULL charactor
//
size = token.datumSize / 2 + 1;
} else {
typeStr = "UINT8";
if (token.isHiiDefaultValueASCIIStringType()) {
//
// Include the NULL charactor
//
size = token.datumSize + 1;
} else {
size = token.datumSize;
}
}
return String.format("%-20s%s[%d];\r\n", typeStr, cName, size);
} else {
throw new EntityException("Unknown DATUM_TYPE type in when generating code for VARIABLE_ENABLED PCD entry");
}
return String.format("%-20s%s;\r\n", typeStr, cName);
}
private String getTypeInstantiation (Token t, ArrayList declaList, HashMap instTable, String phase) throws EntityException {
int i;
String s;
s = String.format("/* %s */", t.getPrimaryKeyString()) + newLine;
s += tab + "{" + newLine;
for (i = 0; i < t.skuData.size(); i++) {
if (t.isUnicodeStringType()) {
s += tab + tab + String.format(" %d ", stringTable.add(t.skuData.get(i).value.value, t));
} else if (t.isHiiEnable()) {
/* VPD_HEAD definition
typedef struct {
UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
UINT16 StringIndex; // Offset in String Table in units of UINT16.
UINT16 Offset; // Offset in Variable
UINT16 DefaultValueOffset; // Offset of the Default Value
} VARIABLE_HEAD ;
*/
String variableDefaultName = String.format("%s_VariableDefault_%d", t.getPrimaryKeyString(), i);
s += tab + tab + String.format("{ %d, %d, %s, %s }", guidTable.add(t.skuData.get(i).value.variableGuid, t.getPrimaryKeyString()),
stringTable.add(t.skuData.get(i).value.getStringOfVariableName(), t),
t.skuData.get(i).value.variableOffset,
String.format("offsetof(%s_PCD_DATABASE, Init.%s)", phase, variableDefaultName)
);
//
// We need to support the default value, so we add the declaration and
// the instantiation for the default value.
//
CStructTypeDeclaration decl = new CStructTypeDeclaration (variableDefaultName,
getHiiPtrTypeAlignmentSize(t),
getDataTypeDeclarationForVariableDefault(t, variableDefaultName, i),
true
);
declaList.add(decl);
instTable.put(variableDefaultName, getDataTypeInstantiationForVariableDefault (t, variableDefaultName, i));
} else if (t.isVpdEnable()) {
/* typedef struct {
UINT32 Offset;
} VPD_HEAD;
*/
s += tab + tab + String.format("{ %s }", t.skuData.get(i).value.vpdOffset);
} else {
if (t.isByteStreamType()) {
//
// Byte stream type input has their own "{" "}", so we won't help to insert.
//
s += tab + tab + String.format(" %s ", t.skuData.get(i).value.value);
} else {
s += tab + tab + String.format("{ %s }", t.skuData.get(i).value.value);
}
}
if (i != t.skuData.size() - 1) {
s += commaNewLine;
} else {
s += newLine;
}
}
s += tab + "}";
return s;
}
public static String getPcdDatabaseCommonDefinitions () {
String retStr;
retStr = "//\r\n";
retStr += "// The following definition will be generated by build tool\r\n";
retStr += "//\r\n";
retStr += "\r\n";
retStr += "//\r\n";
retStr += "// Common definitions\r\n";
retStr += "//\r\n";
retStr += "typedef UINT8 SKU_ID;\r\n";
retStr += "\r\n";
retStr += "#define PCD_TYPE_SHIFT 28\r\n";
retStr += "\r\n";
retStr += "#define PCD_TYPE_DATA (0x0 << PCD_TYPE_SHIFT)\r\n";
retStr += "#define PCD_TYPE_HII (0x8 << PCD_TYPE_SHIFT)\r\n";
retStr += "#define PCD_TYPE_VPD (0x4 << PCD_TYPE_SHIFT)\r\n";
retStr += "#define PCD_TYPE_SKU_ENABLED (0x2 << PCD_TYPE_SHIFT)\r\n";
retStr += "#define PCD_TYPE_STRING (0x1 << PCD_TYPE_SHIFT)\r\n";
retStr += "\r\n";
retStr += "#define PCD_TYPE_ALL_SET (PCD_TYPE_DATA | PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING)\r\n";
retStr += "\r\n";
retStr += "#define PCD_DATUM_TYPE_SHIFT 24\r\n";
retStr += "\r\n";
retStr += "#define PCD_DATUM_TYPE_POINTER (0x0 << PCD_DATUM_TYPE_SHIFT)\r\n";
retStr += "#define PCD_DATUM_TYPE_UINT8 (0x1 << PCD_DATUM_TYPE_SHIFT)\r\n";
retStr += "#define PCD_DATUM_TYPE_UINT16 (0x2 << PCD_DATUM_TYPE_SHIFT)\r\n";
retStr += "#define PCD_DATUM_TYPE_UINT32 (0x4 << PCD_DATUM_TYPE_SHIFT)\r\n";
retStr += "#define PCD_DATUM_TYPE_UINT64 (0x8 << PCD_DATUM_TYPE_SHIFT)\r\n";
retStr += "\r\n";
retStr += "#define PCD_DATUM_TYPE_ALL_SET (PCD_DATUM_TYPE_POINTER | \\\r\n";
retStr += " PCD_DATUM_TYPE_UINT8 | \\\r\n";
retStr += " PCD_DATUM_TYPE_UINT16 | \\\r\n";
retStr += " PCD_DATUM_TYPE_UINT32 | \\\r\n";
retStr += " PCD_DATUM_TYPE_UINT64)\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET | PCD_DATUM_TYPE_ALL_SET))\r\n";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " UINT32 ExTokenNumber;\r\n";
retStr += " UINT16 LocalTokenNumber; // PCD Number of this particular platform build\r\n";
retStr += " UINT16 ExGuidIndex; // Index of GuidTable\r\n";
retStr += "} DYNAMICEX_MAPPING;\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " UINT32 SkuDataStartOffset; //We have to use offsetof MACRO as we don't know padding done by compiler\r\n";
retStr += " UINT32 SkuIdTableOffset; //Offset from the PCD_DB\r\n";
retStr += "} SKU_HEAD;\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.\r\n";
retStr += " UINT16 StringIndex; // Offset in String Table in units of UINT16.\r\n";
retStr += " UINT16 Offset; // Offset in Variable\r\n";
retStr += " UINT16 DefaultValueOffset; // Offset of the Default Value\r\n";
retStr += "} VARIABLE_HEAD ;\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " UINT32 Offset;\r\n";
retStr += "} VPD_HEAD;\r\n";
retStr += "\r\n";
retStr += "typedef UINT16 STRING_HEAD;\r\n";
retStr += "\r\n";
retStr += "typedef UINT16 SIZE_INFO;\r\n";
retStr += "\r\n";
retStr += "#define offsetof(s,m) (UINT32) (UINTN) &(((s *)0)->m)\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "\r\n";
return retStr;
}
public static String getPcdDxeDatabaseDefinitions ()
throws EntityException {
String retStr = "";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " DXE_PCD_DATABASE_INIT Init;\r\n";
retStr += " DXE_PCD_DATABASE_UNINIT Uninit;\r\n";
retStr += "} DXE_PCD_DATABASE;\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " PEI_PCD_DATABASE PeiDb;\r\n";
retStr += " DXE_PCD_DATABASE DxeDb;\r\n";
retStr += "} PCD_DATABASE;\r\n";
retStr += "\r\n";
retStr += "#define DXE_NEX_TOKEN_NUMBER (DXE_LOCAL_TOKEN_NUMBER - DXE_EX_TOKEN_NUMBER)\r\n";
retStr += "\r\n";
retStr += "#define PCD_TOTAL_TOKEN_NUMBER (PEI_LOCAL_TOKEN_NUMBER + DXE_LOCAL_TOKEN_NUMBER)\r\n";
retStr += "\r\n";
retStr += "\r\n";
return retStr;
}
public static String getPcdPeiDatabaseDefinitions ()
throws EntityException {
String retStr = "";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " PEI_PCD_DATABASE_INIT Init;\r\n";
retStr += " PEI_PCD_DATABASE_UNINIT Uninit;\r\n";
retStr += "} PEI_PCD_DATABASE;\r\n";
retStr += "\r\n";
retStr += "#define PEI_NEX_TOKEN_NUMBER (PEI_LOCAL_TOKEN_NUMBER - PEI_EX_TOKEN_NUMBER)\r\n";
retStr += "\r\n";
return retStr;
}
/**
Translate the schema string to UUID instance.
In schema, the string of UUID is defined as following two types string:
1) GuidArrayType: pattern = 0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},(
)*0x[a-fA-F0-9]{1,4}(,( )*\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\})?
2) GuidNamingConvention: pattern =
[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}
This function will convert string and create uuid instance.
@param uuidString UUID string in XML file
@return UUID UUID instance
**/
private UUID translateSchemaStringToUUID(String uuidString)
throws EntityException {
String temp;
String[] splitStringArray;
int index;
int chIndex;
int chLen;
if (uuidString == null) {
return null;
}
if (uuidString.length() == 0) {
return null;
}
if (uuidString.equals("0") ||
uuidString.equalsIgnoreCase("0x0")) {
return new UUID(0, 0);
}
uuidString = uuidString.replaceAll("\\{", "");
uuidString = uuidString.replaceAll("\\}", "");
//
// If the UUID schema string is GuidArrayType type then need translate
// to GuidNamingConvention type at first.
//
if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) {
splitStringArray = uuidString.split("," );
if (splitStringArray.length != 11) {
throw new EntityException ("[FPD file error] Wrong format for GUID string: " + uuidString);
}
//
// Remove blank space from these string and remove header string "0x"
//
for (index = 0; index < 11; index ++) {
splitStringArray[index] = splitStringArray[index].trim();
splitStringArray[index] = splitStringArray[index].substring(2, splitStringArray[index].length());
}
//
// Add heading '0' to normalize the string length
//
for (index = 3; index < 11; index ++) {
chLen = splitStringArray[index].length();
for (chIndex = 0; chIndex < 2 - chLen; chIndex ++) {
splitStringArray[index] = "0" + splitStringArray[index];
}
}
//
// construct the final GuidNamingConvention string
//
temp = String.format("%s-%s-%s-%s%s-%s%s%s%s%s%s",
splitStringArray[0],
splitStringArray[1],
splitStringArray[2],
splitStringArray[3],
splitStringArray[4],
splitStringArray[5],
splitStringArray[6],
splitStringArray[7],
splitStringArray[8],
splitStringArray[9],
splitStringArray[10]);
uuidString = temp;
}
return UUID.fromString(uuidString);
}
}