]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java
Abstract the logic of Platform pcd preprocess according to FPD file to a class. And...
[mirror_edk2.git] / Tools / Source / PcdTools / org / tianocore / 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.pcd.entity;
17
18 import java.util.List;
19 import java.util.UUID;
20
21 import org.tianocore.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 /// ---------------------------------------------------------------------
69 /// Following member is for VPD case.
70 /// ---------------------------------------------------------------------
71 ///
72 public String vpdOffset;
73
74 /// ---------------------------------------------------------------------
75 /// Following member is for default case.
76 /// ---------------------------------------------------------------------
77 public String value;
78
79 /**
80 Constructor function for DynamicTokenValue class.
81
82 **/
83 public DynamicTokenValue() {
84 type = VALUE_TYPE.DEFAULT_TYPE;
85 variableName = null;
86 variableGuid = null;
87 variableOffset = null;
88 hiiDefaultValue = null;
89 vpdOffset = null;
90 value = null;
91 }
92
93 /**
94 Set the HII case data.
95
96 @param variableName The variable name
97 @param variableGuid The variable guid
98 @param variableOffset The offset of value in this variable
99 @param hiiDefaultValue Default value for this PCD
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
126 str = "";
127 for (index = 0; index < variableName.size(); index ++) {
128 num = Integer.decode(variableName.get(index).toString());
129 if ((num > 127 ) || (num < 0)) {
130 throw new EntityException(String.format("variable name contains >0x80 character, now is not support!"));
131 }
132 str += (char)num;
133 }
134
135 return str;
136 }
137
138 /**
139 Set Vpd case data.
140
141 @param vpdOffset
142 */
143 public void setVpdData(String vpdOffset) {
144 this.type = VALUE_TYPE.VPD_TYPE;
145
146 this.vpdOffset = vpdOffset;
147 }
148
149 /**
150 Set default case data.
151
152 @param value
153 */
154 public void setValue(String value) {
155 this.type = VALUE_TYPE.DEFAULT_TYPE;
156
157 this.value = value;
158 }
159 }
160
161
162
163
164