Fixed grammar in messages.
[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 /**
24 This class is to descript a value type of dynamic PCD.
25 For a dynamic or dynamicEx type PCD data, the value type can be:
26 1) Hii type: the value of dynamic or dynamicEx is stored into a variable.
27 2) Vpd type: the value of dynamic or dynamicEx is stored into somewhere set
28 by OEM.
29 3) Default type: the value of dynamic or dynamicEx is stored into PCD dynamic
30 database.
31 **/
32 public class DynamicTokenValue {
33 ///
34 /// Enumeration macro defintion for value type.
35 ///
36 public static enum VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE}
37
38 ///
39 /// The value type maybe:
40 /// HII_TYPE: the value stored into variable area.
41 /// VPD_TYPE: the value stored into OEM specific area.
42 /// DEFAULT_TYPE: the value stored into PCD runtime database.
43 ///
44 public VALUE_TYPE type;
45
46 ///
47 /// ---------------------------------------------------------------------
48 /// Following member is for HII case. The value of HII case will be put
49 /// into variable area in flash.
50 /// ---------------------------------------------------------------------
51 ///
52
53 ///
54 /// variableName is valid only when this token support Hii functionality. variableName
55 /// indicates the value of token is associated with what variable.
56 /// variableName is defined in FPD.
57 public List variableName;
58
59 ///
60 /// variableGuid is the GUID this token associated with.
61 ///
62 public UUID variableGuid;
63
64 ///
65 /// Variable offset indicate the associated variable's offset in NV storage.
66 ///
67 public String variableOffset;
68
69 ///
70 /// The default value for HII case.
71 ///
72 public String hiiDefaultValue;
73
74 ///
75 /// ---------------------------------------------------------------------
76 /// Following member is for VPD case. The value of VPD case will be put into
77 /// some flash position pointed by OEM.
78 /// ---------------------------------------------------------------------
79 ///
80
81 public String vpdOffset;
82
83 /// ---------------------------------------------------------------------
84 /// Following member is for default case. The value of default type will
85 /// be put into PCD runtime database.
86 /// ---------------------------------------------------------------------
87
88 ///
89 /// The default value of this PCD in default case.
90 ///
91 public String value;
92
93 /**
94 Constructor function for DynamicTokenValue class.
95
96 **/
97 public DynamicTokenValue() {
98 type = VALUE_TYPE.DEFAULT_TYPE;
99 variableName = null;
100 variableGuid = null;
101 variableOffset = null;
102 hiiDefaultValue = null;
103 vpdOffset = null;
104 value = null;
105 }
106
107 /**
108 Set the HII case data.
109
110 @param variableName The variable name
111 @param variableGuid The variable guid
112 @param variableOffset The offset of value in this variable
113 @param hiiDefaultValue Default value for this PCD
114 **/
115 public void setHiiData(List variableName,
116 UUID variableGuid,
117 String variableOffset,
118 String hiiDefaultValue) {
119 this.type = VALUE_TYPE.HII_TYPE;
120
121 this.variableName = variableName;
122 this.variableGuid = variableGuid;
123 this.variableOffset = variableOffset;
124 this.hiiDefaultValue = hiiDefaultValue;
125 }
126
127 /**
128 Get the string like L"xxx" for a variable Name.
129
130 BUGBUG: In fact, it is not correctly, variable name should be
131 treated as unicode UINT16 array.
132
133 @return String
134 **/
135 public String getStringOfVariableName()
136 throws EntityException {
137 String str;
138 int index, num;
139 int size;
140
141 str = "";
142 size = variableName.size();
143 for (index = 0; index < size; index++) {
144 num = Integer.decode(variableName.get(index).toString());
145 if ((num > 127 ) || (num < 0)) {
146 throw new EntityException(String.format("The variable name contains more than 0x80 characters; this is not supported at thist time!"));
147 }
148 str += (char)num;
149 }
150
151 return str;
152 }
153
154 /**
155 Set Vpd case data.
156
157 @param vpdOffset the value offset the start address of OEM specific.
158 **/
159 public void setVpdData(String vpdOffset) {
160 this.type = VALUE_TYPE.VPD_TYPE;
161
162 this.vpdOffset = vpdOffset;
163 }
164
165 /**
166 Set default case data.
167
168 @param value
169 **/
170 public void setValue(String value) {
171 this.type = VALUE_TYPE.DEFAULT_TYPE;
172
173 this.value = value;
174 }
175 }
176
177
178
179
180