import java.util.Map;\r
import java.util.UUID;\r
\r
+import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.pcd.exception.EntityException;\r
\r
/** This class is to descript a PCD token object. The information of a token mainly \r
/// assignedtokenSpaceName as follows.\r
/// tokenSpaceName is defined in MSA, SPD, FPD, can be regarded as primary key with cName.\r
///\r
- public UUID tokenSpaceName;\r
+ public String tokenSpaceName;\r
\r
///\r
/// tokenNumber is allocated by platform. tokenNumber indicate an index for this token in\r
/// platform token space. For Dynamic, dynamicEx type, this number will be re-adjust by\r
/// PCD run-time database autogen tools.\r
///\r
- public long tokenNumber;\r
+ public long tokenNumber;\r
\r
///\r
/// This token number is retrieved from FPD file for DynamicEx type. \r
/// \r
- public long dynamicExTokenNumber;\r
+ public long dynamicExTokenNumber;\r
\r
///\r
/// All supported PCD type, this value can be retrieved from SPD\r
///\r
public Map<String, UsageInstance> consumers;\r
\r
- public Token(String cName, UUID tokenSpaceName) {\r
+ /**\r
+ Constructure function for Token class\r
+ \r
+ @param cName The name of token\r
+ @param tokenSpaceName The name of token space, it is a guid string\r
+ **/\r
+ public Token(String cName, String tokenSpaceName) {\r
UUID nullUUID = new UUID(0, 0);\r
\r
this.cName = cName;\r
- this.tokenSpaceName = (tokenSpaceName == null) ? nullUUID : tokenSpaceName;\r
+ this.tokenSpaceName = tokenSpaceName;\r
this.tokenNumber = 0;\r
this.datumType = DATUM_TYPE.UNKNOWN;\r
this.datumSize = -1;\r
@param pcdType new PCD type found in FPD file for this token.\r
**/\r
public void updateSupportPcdType(PCD_TYPE pcdType) {\r
- int index = 0;\r
- boolean found = false;\r
- for (index = 0; index < this.supportedPcdType.size(); index ++) {\r
- if (this.supportedPcdType.get(index) == pcdType) {\r
- found = true;\r
- break;\r
+ for (int index = 0; index < this.supportedPcdType.size(); index ++) {\r
+ if (supportedPcdType.get(index) == pcdType) {\r
+ return;\r
}\r
}\r
- if (!found) {\r
- this.supportedPcdType.add(pcdType);\r
- }\r
+\r
+ //\r
+ // If not found, add the pcd type to member variable supportedPcdType\r
+ // \r
+ supportedPcdType.add(pcdType);\r
}\r
\r
/**\r
Judge whether pcdType is belong to dynamic type. Dynamic type includes\r
DYNAMIC and DYNAMIC_EX.\r
\r
- @param pcdType\r
+ @param pcdType the judged pcd type\r
\r
@return boolean\r
*/\r
}\r
\r
public boolean isDynamicEx() {\r
- \r
for (int i = 0; i < supportedPcdType.size(); i++) {\r
if (supportedPcdType.get(i) == PCD_TYPE.DYNAMIC_EX) {\r
return true;\r
Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database\r
\r
@param cName Token name.\r
- @param tokenSpaceName The token space guid defined in MSA or SPD\r
- @param platformtokenSpaceName The token space guid for current platform token space,\r
+ @param tokenSpaceName The token space guid string defined in MSA or SPD\r
\r
- @return primary key for this token in token database.\r
+ @retval primary key for this token in token database.\r
**/\r
- public static String getPrimaryKeyString(String cName, UUID tokenSpaceName) {\r
- UUID nullUUID = new UUID(0, 0);\r
-\r
+ public static String getPrimaryKeyString(String cName, String tokenSpaceName) {\r
if (tokenSpaceName == null) {\r
- return cName + "_" + nullUUID.toString().replace('-', '_');\r
+ return cName + "_nullTokenSpaceGuid";\r
} else {\r
return cName + "_" + tokenSpaceName.toString().replace('-', '_');\r
}\r
/**\r
If skudata list contains more than one data, then Sku mechanism is enable.\r
\r
- @return boolean\r
+ @retval boolean if the number of sku data exceed to 1\r
*/\r
public boolean isSkuEnable() {\r
if (this.skuData.size() > 1) {\r
}\r
return false;\r
}\r
- \r
+\r
+ /**\r
+ If Hii type for value of token\r
+ \r
+ @return boolean\r
+ **/\r
public boolean isHiiEnable() {\r
if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {\r
return true;\r
return false;\r
}\r
\r
+ /**\r
+ If Vpd type for value of token\r
+ \r
+ @return boolean\r
+ **/\r
public boolean isVpdEnable() {\r
if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {\r
return true;\r
@retval TRUE - Success to add usage instance.\r
@retval FALSE - Fail to add usage instance\r
**/\r
- public boolean addUsageInstance(UsageInstance usageInstance) \r
- throws EntityException {\r
+ public boolean addUsageInstance(UsageInstance usageInstance) throws EntityException {\r
String exceptionStr;\r
\r
- if (isUsageInstanceExist(usageInstance.moduleName,\r
- usageInstance.moduleGUID,\r
- usageInstance.packageName,\r
- usageInstance.packageGUID,\r
- usageInstance.arch,\r
- usageInstance.version)) {\r
- exceptionStr = String.format("PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
- "in modules %s in <ModuleSA> to make sure no duplicated definitions!",\r
+ if (isUsageInstanceExist(usageInstance.moduleId, usageInstance.arch)) {\r
+ exceptionStr = String.format("[PCD Collection Tool Exception] PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
+ "in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!",\r
usageInstance.parentToken.cName,\r
- usageInstance.moduleName,\r
- usageInstance.moduleName);\r
+ usageInstance.moduleId.getName(),\r
+ usageInstance.moduleId.getName());\r
throw new EntityException(exceptionStr);\r
}\r
\r
+ //\r
+ // Put usage instance into usage instance database of this PCD token.\r
+ // \r
consumers.put(usageInstance.getPrimaryKey(), usageInstance);\r
+\r
return true;\r
}\r
\r
/**\r
Judge whether exist an usage instance for this token\r
\r
- @param moduleName the name of module\r
- @param moduleGuid the GUID name of modules\r
- @param packageName the name of package contains this module\r
- @param packageGuid the GUID name of package contains this module\r
+ @param moduleId The module identification for usage instance\r
@param arch the architecture string\r
- @param version the version string\r
\r
@return boolean whether exist an usage instance for this token.\r
*/\r
- public boolean isUsageInstanceExist(String moduleName,\r
- UUID moduleGuid,\r
- String packageName,\r
- UUID packageGuid,\r
- String arch,\r
- String version) {\r
- String keyStr = UsageInstance.getPrimaryKey(moduleName, \r
- moduleGuid, \r
- packageName, \r
- packageGuid, \r
- arch, \r
- version);\r
+ public boolean isUsageInstanceExist(ModuleIdentification moduleId,\r
+ String arch) {\r
+ String keyStr = UsageInstance.getPrimaryKey(moduleId, arch);\r
+\r
return (consumers.get(keyStr) != null);\r
}\r
\r
}\r
\r
/**\r
- UUID defined in Schems is object, this function is to tranlate this object \r
- to UUID data.\r
- \r
- @param uuidObj The object comes from schema.\r
- \r
- @return The traslated UUID instance.\r
+ Get the sku data who id is 0.\r
+ \r
+ @retval DynamicTokenValue the value of this dyanmic token.\r
**/\r
- public static UUID getGUIDFromSchemaObject(Object uuidObj) {\r
- UUID uuid;\r
- if (uuidObj.toString().equalsIgnoreCase("0")) {\r
- uuid = new UUID(0,0);\r
- } else {\r
- uuid = UUID.fromString(uuidObj.toString());\r
- }\r
-\r
- return uuid;\r
- }\r
-\r
public DynamicTokenValue getDefaultSku() {\r
DynamicTokenValue dynamicData;\r
int index;\r
+\r
for (index = 0; index < this.skuData.size(); index ++) {\r
if (skuData.get(index).id == 0) {\r
return skuData.get(index).value;\r
\r
return null;\r
}\r
- \r
+\r
+ /**\r
+ Get the number of Sku data for this token\r
+ \r
+ @retval int the number of sku data\r
+ **/\r
public int getSkuIdCount () {\r
return this.skuData.size();\r
}\r
\r
+ /**\r
+ Get the size of PCD value, this PCD is POINTER type.\r
+ \r
+ @param str the string of the value\r
+ @param al \r
+ **/\r
private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {\r
if (isValidNullValue(str)) {\r
al.add(new Integer(0));\r
}\r
}\r
}\r
- //\r
- // This method can be used to get the MAX and current size\r
- // for pointer type dynamic(ex) PCD entry\r
- //\r
+\r
+ /**\r
+ This method can be used to get the MAX and current size\r
+ for pointer type dynamic(ex) PCD entry\r
+ **/ \r
public ArrayList<Integer> getPointerTypeSize () {\r
ArrayList<Integer> al = new ArrayList<Integer>();\r
\r
return false;\r
}\r
\r
+ /**\r
+ Judge the value is NULL value. NULL value means the value is uninitialized value\r
+ \r
+ @param judgedValue\r
+ \r
+ @return boolean\r
+ */\r
public boolean isValidNullValue(String judgedValue) {\r
String subStr;\r
BigInteger bigIntValue;\r
}\r
return false;\r
}\r
- \r
+\r
+ /**\r
+ Is the string value in Unicode\r
+ \r
+ @return boolean\r
+ **/\r
public boolean isHiiDefaultValueUnicodeStringType() {\r
DynamicTokenValue dynamicData = getDefaultSku();\r
\r
return dynamicData.hiiDefaultValue.startsWith("L\"")\r
&& dynamicData.hiiDefaultValue.endsWith("\"");\r
}\r
- \r
+\r
+ /**\r
+ Is the string value in ANSCI\r
+ \r
+ @return boolean\r
+ **/\r
public boolean isHiiDefaultValueASCIIStringType() {\r
DynamicTokenValue dynamicData = getDefaultSku();\r
\r