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