]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/global/PropertyManager.java
1 package org
.tianocore
.build
.global
;
3 import java
.util
.HashMap
;
4 import java
.util
.Hashtable
;
5 import java
.util
.Iterator
;
7 import java
.util
.Stack
;
9 import org
.apache
.tools
.ant
.Project
;
10 import org
.apache
.tools
.ant
.PropertyHelper
;
12 public class PropertyManager
{
13 private static Stack
<HashMap
<String
, String
>> propertyTableStack
= new Stack
<HashMap
<String
, String
>>();
14 private static HashMap
<String
, String
> orgPropertyTable
= null;
15 private static HashMap
<String
, String
> oldPropertyTable
= null;
16 private static HashMap
<String
, String
> bakPropertyTable
= null;
17 private static Project prj
= null;
19 public static void save() {
20 if (orgPropertyTable
== null) {
21 Hashtable prjProperties
= prj
.getProperties();
22 orgPropertyTable
= new HashMap
<String
, String
>();
24 Set keys
= prjProperties
.keySet();
25 Iterator iter
= keys
.iterator();
26 while (iter
.hasNext()) {
27 String item
= (String
)iter
.next();
28 orgPropertyTable
.put(item
, (String
)prjProperties
.get(item
));
32 if (bakPropertyTable
!= null) {
33 propertyTableStack
.push(bakPropertyTable
);
34 oldPropertyTable
= bakPropertyTable
;
36 oldPropertyTable
= orgPropertyTable
;
38 bakPropertyTable
= new HashMap
<String
, String
>();
41 public static void restore() {
42 if (bakPropertyTable
== null) {
45 Set keys
= bakPropertyTable
.keySet();
47 Iterator iter
= keys
.iterator();
48 while (iter
.hasNext()) {
49 String name
= (String
)iter
.next();
50 String value
= (String
)bakPropertyTable
.get(name
);
51 setProperty(prj
, name
, value
);
54 if (propertyTableStack
.size() > 0) {
55 bakPropertyTable
= (HashMap
<String
, String
>)propertyTableStack
.pop();
57 bakPropertyTable
= null;
60 if (propertyTableStack
.size() == 0) {
61 oldPropertyTable
= orgPropertyTable
;
63 oldPropertyTable
= (HashMap
<String
, String
>)propertyTableStack
.peek();
67 public static void setProject(Project prj
) {
68 PropertyManager
.prj
= prj
;
71 public static void setProperty(String name
, String value
) {
76 setProperty(prj
, name
, value
);
78 if (oldPropertyTable
== null || bakPropertyTable
== null) {
82 String oldValue
= oldPropertyTable
.get(name
);
83 if (oldValue
== null) {
86 bakPropertyTable
.put(name
, oldValue
);
89 public static void setProperty(Project project
, String name
, String value
) {
90 if (project
== null) {
97 PropertyHelper
.getPropertyHelper(project
).setProperty(null, name
, value
, false);