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