]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java
Because Pcd entity, exception and some action package are shared by Building tools...
[mirror_edk2.git] / Tools / Source / PcdTools / org / tianocore / pcd / entity / DynamicTokenValue.java
diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java b/Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java
new file mode 100644 (file)
index 0000000..e8fb8e8
--- /dev/null
@@ -0,0 +1,162 @@
+/** @file\r
+  DynamicTokenValue class.\r
+\r
+  This module contains the value type of a dynamic token.\r
\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/  \r
+package org.tianocore.pcd.entity;\r
+\r
+import java.util.List;\r
+import java.util.UUID;\r
+\r
+import org.tianocore.pcd.exception.EntityException;\r
+\r
+/** This class is to descript a value type of dynamic PCD.\r
+    For a dynamic or dynamicEx type PCD data, the value type can be:\r
+        1) Hii type: the value of dynamic or dynamicEx is stored into a variable.\r
+        2) Vpd type: the value of dynamic or dynamicEx is stored into somewhere set\r
+                     by OEM.\r
+        3) Default type: the value of dynamic or dynamicEx is stored into PCD dynamic\r
+                         database.\r
+**/\r
+public class DynamicTokenValue {\r
+    ///\r
+    /// Enumeration macro defintion for value type.\r
+    /// BUGBUG: Not use upcase charater is to facility for reading. It may be changed\r
+    ///         in coding review.\r
+    public enum        VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE}\r
+\r
+    public VALUE_TYPE  type;\r
+\r
+    ///\r
+    /// ---------------------------------------------------------------------\r
+    /// Following member is for HII case.\r
+    /// ---------------------------------------------------------------------\r
+    ///\r
+\r
+    ///\r
+    /// variableName is valid only when this token support Hii functionality. variableName\r
+    /// indicates the value of token is associated with what variable.\r
+    /// variableName is defined in FPD.\r
+    public List        variableName;\r
+\r
+    ///\r
+    /// variableGuid is the GUID this token associated with.\r
+    ///\r
+    public UUID        variableGuid;\r
+\r
+    ///\r
+    /// Variable offset indicate the associated variable's offset in NV storage.\r
+    ///\r
+    public String      variableOffset;\r
+\r
+    ///\r
+    /// The default value for HII case.\r
+    /// \r
+    public String      hiiDefaultValue;\r
+\r
+    ///\r
+    /// Following member is for VPD case.\r
+    /// BUGBUG: Consider 64 bit integer by using java.math.BigInteger.\r
+    /// \r
+    public String      vpdOffset;\r
+\r
+    ///\r
+    /// Following member is for default case.\r
+    /// \r
+    public String      value;\r
+\r
+    public DynamicTokenValue() {\r
+        this.type               = VALUE_TYPE.DEFAULT_TYPE;\r
+        this.variableName       = null;\r
+        this.variableGuid       = null;\r
+        this.variableOffset     = null;\r
+        this.hiiDefaultValue    = null;\r
+\r
+        this.vpdOffset          = null;\r
+\r
+        this.value              = null;\r
+    }\r
+\r
+    /**\r
+       Set the HII case data.\r
+       \r
+       @param variableName\r
+       @param variableGuid\r
+       @param variableOffset\r
+       @param hiiDefaultValue\r
+     */\r
+    public void setHiiData(List        variableName,\r
+                           UUID        variableGuid,\r
+                           String      variableOffset,\r
+                           String      hiiDefaultValue) {\r
+        this.type = VALUE_TYPE.HII_TYPE;\r
+\r
+        this.variableName    = variableName;\r
+        this.variableGuid    = variableGuid;\r
+        this.variableOffset  = variableOffset;\r
+        this.hiiDefaultValue = hiiDefaultValue;\r
+    }\r
+\r
+    /**\r
+       Get the string like L"xxx" for a variable Name.\r
+       \r
+       BUGBUG: In fact, it is not correctly, variable name should be\r
+               treated as unicode UINT16 array.\r
+       \r
+       @return String\r
+     */\r
+    public String getStringOfVariableName() \r
+        throws EntityException {\r
+        String str;\r
+        int    index, num;\r
+        char   ch;\r
+\r
+        str = "";\r
+        for (index = 0; index < variableName.size(); index ++) {\r
+            num = Integer.decode(variableName.get(index).toString());\r
+            if ((num > 127 ) || (num < 0)) {\r
+                throw new EntityException(String.format("variable name contains >0x80 character, now is not support!"));\r
+            }\r
+            str += (char)num;\r
+        }\r
+\r
+        return str;\r
+    }\r
+\r
+    /**\r
+       Set Vpd case data.\r
+       \r
+       @param vpdOffset\r
+     */\r
+    public void setVpdData(String vpdOffset) {\r
+        this.type = VALUE_TYPE.VPD_TYPE;\r
+\r
+        this.vpdOffset = vpdOffset;\r
+    }\r
+\r
+    /**\r
+       Set default case data.\r
+       \r
+       @param value\r
+     */\r
+    public void setValue(String value) {\r
+        this.type = VALUE_TYPE.DEFAULT_TYPE;\r
+\r
+        this.value = value;\r
+    }\r
+}\r
+\r
+\r
+\r
+\r
+\r