]>
Commit | Line | Data |
---|---|---|
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 | 6 | Copyright (c) 2006, Intel Corporation\r |
7 | All rights reserved. This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
bc262841 | 11 | \r |
6ff7a41c | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
bc262841 | 15 | **/\r |
d14ebb43 | 16 | package org.tianocore.pcd.entity;\r |
6ff7a41c | 17 | \r |
6ff7a41c | 18 | import java.util.List;\r |
6ff7a41c | 19 | import java.util.UUID;\r |
20 | \r | |
d14ebb43 | 21 | import org.tianocore.pcd.exception.EntityException;\r |
6ff7a41c | 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 | |
31 | public 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 | |
bc262841 | 64 | ///\r |
6ff7a41c | 65 | public String hiiDefaultValue;\r |
66 | \r | |
67 | ///\r | |
bc262841 | 68 | /// ---------------------------------------------------------------------\r |
6ff7a41c | 69 | /// Following member is for VPD case.\r |
bc262841 | 70 | /// ---------------------------------------------------------------------\r |
71 | ///\r | |
6ff7a41c | 72 | public String vpdOffset;\r |
73 | \r | |
bc262841 | 74 | /// ---------------------------------------------------------------------\r |
6ff7a41c | 75 | /// Following member is for default case.\r |
bc262841 | 76 | /// ---------------------------------------------------------------------\r |
6ff7a41c | 77 | public String value;\r |
78 | \r | |
bc262841 | 79 | /**\r |
80 | Constructor function for DynamicTokenValue class.\r | |
81 | \r | |
82 | **/\r | |
6ff7a41c | 83 | public DynamicTokenValue() {\r |
bc262841 | 84 | type = VALUE_TYPE.DEFAULT_TYPE;\r |
85 | variableName = null;\r | |
86 | variableGuid = null;\r | |
87 | variableOffset = null;\r | |
88 | hiiDefaultValue = null;\r | |
89 | vpdOffset = null;\r | |
90 | value = null;\r | |
6ff7a41c | 91 | }\r |
92 | \r | |
93 | /**\r | |
94 | Set the HII case data.\r | |
bc262841 | 95 | \r |
96 | @param variableName The variable name \r | |
97 | @param variableGuid The variable guid\r | |
98 | @param variableOffset The offset of value in this variable\r | |
99 | @param hiiDefaultValue Default value for this PCD\r | |
100 | **/\r | |
6ff7a41c | 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 | |
bc262841 | 115 | \r |
6ff7a41c | 116 | BUGBUG: In fact, it is not correctly, variable name should be\r |
117 | treated as unicode UINT16 array.\r | |
bc262841 | 118 | \r |
6ff7a41c | 119 | @return String\r |
120 | */\r | |
bc262841 | 121 | public String getStringOfVariableName()\r |
6ff7a41c | 122 | throws EntityException {\r |
123 | String str;\r | |
124 | int index, num;\r | |
6ff7a41c | 125 | \r |
126 | str = "";\r | |
127 | for (index = 0; index < variableName.size(); index ++) {\r | |
128 | num = Integer.decode(variableName.get(index).toString());\r | |
129 | if ((num > 127 ) || (num < 0)) {\r | |
130 | throw new EntityException(String.format("variable name contains >0x80 character, now is not support!"));\r | |
131 | }\r | |
132 | str += (char)num;\r | |
133 | }\r | |
134 | \r | |
135 | return str;\r | |
136 | }\r | |
137 | \r | |
6ff7a41c | 138 | /**\r |
139 | Set Vpd case data.\r | |
bc262841 | 140 | \r |
6ff7a41c | 141 | @param vpdOffset\r |
142 | */\r | |
143 | public void setVpdData(String vpdOffset) {\r | |
144 | this.type = VALUE_TYPE.VPD_TYPE;\r | |
145 | \r | |
146 | this.vpdOffset = vpdOffset;\r | |
147 | }\r | |
148 | \r | |
149 | /**\r | |
150 | Set default case data.\r | |
bc262841 | 151 | \r |
6ff7a41c | 152 | @param value\r |
153 | */\r | |
154 | public void setValue(String value) {\r | |
155 | this.type = VALUE_TYPE.DEFAULT_TYPE;\r | |
156 | \r | |
157 | this.value = value;\r | |
158 | }\r | |
159 | }\r | |
160 | \r | |
161 | \r | |
162 | \r | |
163 | \r | |
164 | \r |