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