]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/pcd/entity/DynamicTokenValue.java
54c89573026f841c1cd3bcd8560f3e132d92fd86
2 DynamicTokenValue class.
4 This module contains the value type of a dynamic token.
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
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.
16 package org
.tianocore
.build
.pcd
.entity
;
18 import java
.util
.ArrayList
;
19 import java
.util
.HashMap
;
20 import java
.util
.List
;
22 import java
.util
.UUID
;
24 import org
.tianocore
.build
.pcd
.exception
.EntityException
;
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
31 3) Default type: the value of dynamic or dynamicEx is stored into PCD dynamic
34 public class DynamicTokenValue
{
36 /// Enumeration macro defintion for value type.
37 /// BUGBUG: Not use upcase charater is to facility for reading. It may be changed
39 public enum VALUE_TYPE
{HII_TYPE
, VPD_TYPE
, DEFAULT_TYPE
}
41 public VALUE_TYPE type
;
44 /// ---------------------------------------------------------------------
45 /// Following member is for HII case.
46 /// ---------------------------------------------------------------------
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
;
56 /// variableGuid is the GUID this token associated with.
58 public UUID variableGuid
;
61 /// Variable offset indicate the associated variable's offset in NV storage.
63 public String variableOffset
;
66 /// The default value for HII case.
68 public String hiiDefaultValue
;
71 /// Following member is for VPD case.
72 /// BUGBUG: Consider 64 bit integer by using java.math.BigInteger.
74 public String vpdOffset
;
77 /// Following member is for default case.
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;
88 this.vpdOffset
= null;
94 Set the HII case data.
99 @param hiiDefaultValue
101 public void setHiiData(List variableName
,
103 String variableOffset
,
104 String hiiDefaultValue
) {
105 this.type
= VALUE_TYPE
.HII_TYPE
;
107 this.variableName
= variableName
;
108 this.variableGuid
= variableGuid
;
109 this.variableOffset
= variableOffset
;
110 this.hiiDefaultValue
= hiiDefaultValue
;
114 Get the string like L"xxx" for a variable Name.
116 BUGBUG: In fact, it is not correctly, variable name should be
117 treated as unicode UINT16 array.
121 public String
getStringOfVariableName()
122 throws EntityException
{
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!"));
140 Get UINT16 array which use string to express a number.
144 public String
getStringArrayOfVariableName() {
149 for (index
= 0; index
< variableName
.size(); index
++) {
150 strArray
+= variableName
.get(index
).toString();
151 if (index
!= (variableName
.size() - 1)) {
164 public void setVpdData(String vpdOffset
) {
165 this.type
= VALUE_TYPE
.VPD_TYPE
;
167 this.vpdOffset
= vpdOffset
;
171 Set default case data.
175 public void setValue(String value
) {
176 this.type
= VALUE_TYPE
.DEFAULT_TYPE
;