Fixed grammar in messages.
[mirror_edk2.git] / Tools / Source / PcdTools / org / tianocore / pcd / entity / DynamicTokenValue.java
CommitLineData
6ff7a41c 1/** @file\r
2 DynamicTokenValue class.\r
3\r
4 This module contains the value type of a dynamic token.\r
bc262841 5\r
6ff7a41c 6Copyright (c) 2006, Intel Corporation\r
7All rights reserved. This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
bc262841 11\r
6ff7a41c 12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
bc262841 15**/\r
d14ebb43 16package org.tianocore.pcd.entity;\r
6ff7a41c 17\r
6ff7a41c 18import java.util.List;\r
6ff7a41c 19import java.util.UUID;\r
20\r
d14ebb43 21import org.tianocore.pcd.exception.EntityException;\r
6ff7a41c 22\r
8b7bd455 23/**\r
f28c0830 24 This class is to descript a value type of dynamic PCD.\r
25 For a dynamic or dynamicEx type PCD data, the value type can be:\r
26 1) Hii type: the value of dynamic or dynamicEx is stored into a variable.\r
27 2) Vpd type: the value of dynamic or dynamicEx is stored into somewhere set\r
28 by OEM.\r
29 3) Default type: the value of dynamic or dynamicEx is stored into PCD dynamic\r
30 database.\r
6ff7a41c 31**/\r
32public class DynamicTokenValue {\r
33 ///\r
34 /// Enumeration macro defintion for value type.\r
f28c0830 35 ///\r
8b7bd455 36 public static enum VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE}\r
6ff7a41c 37\r
f28c0830 38 ///\r
39 /// The value type maybe:\r
40 /// HII_TYPE: the value stored into variable area.\r
41 /// VPD_TYPE: the value stored into OEM specific area.\r
42 /// DEFAULT_TYPE: the value stored into PCD runtime database.\r
8b7bd455 43 ///\r
6ff7a41c 44 public VALUE_TYPE type;\r
45\r
46 ///\r
47 /// ---------------------------------------------------------------------\r
8b7bd455 48 /// Following member is for HII case. The value of HII case will be put\r
f28c0830 49 /// into variable area in flash.\r
6ff7a41c 50 /// ---------------------------------------------------------------------\r
51 ///\r
52\r
53 ///\r
54 /// variableName is valid only when this token support Hii functionality. variableName\r
55 /// indicates the value of token is associated with what variable.\r
56 /// variableName is defined in FPD.\r
57 public List variableName;\r
58\r
59 ///\r
60 /// variableGuid is the GUID this token associated with.\r
61 ///\r
62 public UUID variableGuid;\r
63\r
64 ///\r
65 /// Variable offset indicate the associated variable's offset in NV storage.\r
66 ///\r
67 public String variableOffset;\r
68\r
69 ///\r
70 /// The default value for HII case.\r
bc262841 71 ///\r
6ff7a41c 72 public String hiiDefaultValue;\r
73\r
74 ///\r
bc262841 75 /// ---------------------------------------------------------------------\r
f28c0830 76 /// Following member is for VPD case. The value of VPD case will be put into\r
77 /// some flash position pointed by OEM.\r
bc262841 78 /// ---------------------------------------------------------------------\r
79 ///\r
f28c0830 80\r
6ff7a41c 81 public String vpdOffset;\r
82\r
bc262841 83 /// ---------------------------------------------------------------------\r
f28c0830 84 /// Following member is for default case. The value of default type will\r
85 /// be put into PCD runtime database.\r
bc262841 86 /// ---------------------------------------------------------------------\r
f28c0830 87\r
88 ///\r
89 /// The default value of this PCD in default case.\r
8b7bd455 90 ///\r
6ff7a41c 91 public String value;\r
92\r
bc262841 93 /**\r
94 Constructor function for DynamicTokenValue class.\r
8b7bd455 95\r
bc262841 96 **/\r
6ff7a41c 97 public DynamicTokenValue() {\r
bc262841 98 type = VALUE_TYPE.DEFAULT_TYPE;\r
99 variableName = null;\r
100 variableGuid = null;\r
101 variableOffset = null;\r
102 hiiDefaultValue = null;\r
103 vpdOffset = null;\r
104 value = null;\r
6ff7a41c 105 }\r
106\r
107 /**\r
108 Set the HII case data.\r
bc262841 109\r
8b7bd455 110 @param variableName The variable name\r
bc262841 111 @param variableGuid The variable guid\r
112 @param variableOffset The offset of value in this variable\r
113 @param hiiDefaultValue Default value for this PCD\r
114 **/\r
6ff7a41c 115 public void setHiiData(List variableName,\r
116 UUID variableGuid,\r
117 String variableOffset,\r
118 String hiiDefaultValue) {\r
119 this.type = VALUE_TYPE.HII_TYPE;\r
120\r
121 this.variableName = variableName;\r
122 this.variableGuid = variableGuid;\r
123 this.variableOffset = variableOffset;\r
124 this.hiiDefaultValue = hiiDefaultValue;\r
125 }\r
126\r
127 /**\r
128 Get the string like L"xxx" for a variable Name.\r
bc262841 129\r
6ff7a41c 130 BUGBUG: In fact, it is not correctly, variable name should be\r
131 treated as unicode UINT16 array.\r
bc262841 132\r
8b7bd455 133 @return String\r
f28c0830 134 **/\r
bc262841 135 public String getStringOfVariableName()\r
6ff7a41c 136 throws EntityException {\r
137 String str;\r
138 int index, num;\r
f28c0830 139 int size;\r
6ff7a41c 140\r
f28c0830 141 str = "";\r
142 size = variableName.size();\r
143 for (index = 0; index < size; index++) {\r
6ff7a41c 144 num = Integer.decode(variableName.get(index).toString());\r
145 if ((num > 127 ) || (num < 0)) {\r
d653c17a 146 throw new EntityException(String.format("The variable name contains more than 0x80 characters; this is not supported at thist time!"));\r
6ff7a41c 147 }\r
148 str += (char)num;\r
149 }\r
150\r
151 return str;\r
152 }\r
153\r
6ff7a41c 154 /**\r
155 Set Vpd case data.\r
bc262841 156\r
f28c0830 157 @param vpdOffset the value offset the start address of OEM specific.\r
158 **/\r
6ff7a41c 159 public void setVpdData(String vpdOffset) {\r
160 this.type = VALUE_TYPE.VPD_TYPE;\r
161\r
162 this.vpdOffset = vpdOffset;\r
163 }\r
164\r
165 /**\r
166 Set default case data.\r
bc262841 167\r
6ff7a41c 168 @param value\r
f28c0830 169 **/\r
6ff7a41c 170 public void setValue(String value) {\r
171 this.type = VALUE_TYPE.DEFAULT_TYPE;\r
172\r
173 this.value = value;\r
174 }\r
175}\r
176\r
177\r
178\r
179\r
180\r