]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/GenBuild/org/tianocore/build/pcd/entity/DynamicTokenValue.java
Modify PCD tool according to final PCD schema modification.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / 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
5 \r
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
11 \r
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
15**/ \r
16package org.tianocore.build.pcd.entity;\r
17\r
18import java.util.ArrayList;\r
19import java.util.HashMap;\r
20import java.util.List;\r
21import java.util.Map;\r
22import java.util.UUID;\r
23\r
24import org.tianocore.build.pcd.exception.EntityException;\r
25\r
26/** This class is to descript a value type of dynamic PCD.\r
27 For a dynamic or dynamicEx type PCD data, the value type can be:\r
28 1) Hii type: the value of dynamic or dynamicEx is stored into a variable.\r
29 2) Vpd type: the value of dynamic or dynamicEx is stored into somewhere set\r
30 by OEM.\r
31 3) Default type: the value of dynamic or dynamicEx is stored into PCD dynamic\r
32 database.\r
33**/\r
34public class DynamicTokenValue {\r
35 ///\r
36 /// Enumeration macro defintion for value type.\r
37 /// BUGBUG: Not use upcase charater is to facility for reading. It may be changed\r
38 /// in coding review.\r
39 public enum VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE}\r
40\r
41 public VALUE_TYPE type;\r
42\r
43 ///\r
44 /// ---------------------------------------------------------------------\r
45 /// Following member is for HII case.\r
46 /// ---------------------------------------------------------------------\r
47 ///\r
48\r
49 ///\r
50 /// variableName is valid only when this token support Hii functionality. variableName\r
51 /// indicates the value of token is associated with what variable.\r
52 /// variableName is defined in FPD.\r
53 public List variableName;\r
54\r
55 ///\r
56 /// variableGuid is the GUID this token associated with.\r
57 ///\r
58 public UUID variableGuid;\r
59\r
60 ///\r
61 /// Variable offset indicate the associated variable's offset in NV storage.\r
62 ///\r
63 public String variableOffset;\r
64\r
65 ///\r
66 /// The default value for HII case.\r
67 /// \r
68 public String hiiDefaultValue;\r
69\r
70 ///\r
71 /// Following member is for VPD case.\r
72 /// BUGBUG: Consider 64 bit integer by using java.math.BigInteger.\r
73 /// \r
74 public String vpdOffset;\r
75\r
76 ///\r
77 /// Following member is for default case.\r
78 /// \r
79 public String value;\r
80\r
81 public DynamicTokenValue() {\r
82 this.type = VALUE_TYPE.DEFAULT_TYPE;\r
83 this.variableName = null;\r
84 this.variableGuid = null;\r
85 this.variableOffset = null;\r
86 this.hiiDefaultValue = null;\r
87\r
88 this.vpdOffset = null;\r
89\r
90 this.value = null;\r
91 }\r
92\r
93 /**\r
94 Set the HII case data.\r
95 \r
96 @param variableName\r
97 @param variableGuid\r
98 @param variableOffset\r
99 @param hiiDefaultValue\r
100 */\r
101 public void setHiiData(List variableName,\r
102 UUID variableGuid,\r
103 String variableOffset,\r
104 String hiiDefaultValue) {\r
105 this.type = VALUE_TYPE.HII_TYPE;\r
106\r
107 this.variableName = variableName;\r
108 this.variableGuid = variableGuid;\r
109 this.variableOffset = variableOffset;\r
110 this.hiiDefaultValue = hiiDefaultValue;\r
111 }\r
112\r
113 /**\r
114 Get the string like L"xxx" for a variable Name.\r
115 \r
116 BUGBUG: In fact, it is not correctly, variable name should be\r
117 treated as unicode UINT16 array.\r
118 \r
119 @return String\r
120 */\r
121 public String getStringOfVariableName() \r
122 throws EntityException {\r
123 String str;\r
124 int index, num;\r
125 char ch;\r
126\r
127 str = "";\r
128 for (index = 0; index < variableName.size(); index ++) {\r
129 num = Integer.decode(variableName.get(index).toString());\r
130 if ((num > 127 ) || (num < 0)) {\r
131 throw new EntityException(String.format("variable name contains >0x80 character, now is not support!"));\r
132 }\r
133 str += (char)num;\r
134 }\r
135\r
136 return str;\r
137 }\r
138\r
139 /**\r
140 Get UINT16 array which use string to express a number.\r
141 \r
142 @return String\r
143 */\r
144 public String getStringArrayOfVariableName() {\r
145 String strArray;\r
146 int index;\r
147\r
148 strArray = "{";\r
149 for (index = 0; index < variableName.size(); index ++) {\r
150 strArray += variableName.get(index).toString();\r
151 if (index != (variableName.size() - 1)) {\r
152 strArray += ",";\r
153 }\r
154 }\r
155 strArray += "}";\r
156 return strArray;\r
157 }\r
158\r
159 /**\r
160 Set Vpd case data.\r
161 \r
162 @param vpdOffset\r
163 */\r
164 public void setVpdData(String vpdOffset) {\r
165 this.type = VALUE_TYPE.VPD_TYPE;\r
166\r
167 this.vpdOffset = vpdOffset;\r
168 }\r
169\r
170 /**\r
171 Set default case data.\r
172 \r
173 @param value\r
174 */\r
175 public void setValue(String value) {\r
176 this.type = VALUE_TYPE.DEFAULT_TYPE;\r
177\r
178 this.value = value;\r
179 }\r
180}\r
181\r
182\r
183\r
184\r
185\r