]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java
Changed the code to read the correct configuration name in target.txt file;
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / toolchain / ToolChainMap.java
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13 ToolChainMap.java
14
15 Abstract:
16
17 --*/
18
19 package org.tianocore.build.toolchain;
20
21 import java.util.HashMap;
22 import java.util.Map;
23 import java.util.Set;
24
25 import org.tianocore.exception.EdkException;
26
27 public class ToolChainMap {
28
29 private int matchLevel = ToolChainKey.keyLength - 2;
30
31 private Map<ToolChainKey, String> map = null;
32
33 public ToolChainMap() {
34 this.map = new HashMap<ToolChainKey, String>();
35 }
36
37 public String put(String key, String delimiter, String value) {
38 ToolChainKey toolChainKey;
39
40 try {
41 toolChainKey = new ToolChainKey(key, delimiter);
42 } catch (Exception e) {
43 return null;
44 }
45 return (String)map.put(toolChainKey, value);
46 }
47
48 public String put(String key, String value) {
49 ToolChainKey toolChainKey;
50
51 try {
52 toolChainKey = new ToolChainKey(key);
53 } catch (Exception e) {
54 return null;
55 }
56 return (String)map.put(toolChainKey, value);
57 }
58
59 public String put(String[] key, String value) {
60 ToolChainKey toolChainKey;
61
62 try {
63 toolChainKey = new ToolChainKey(key);
64 } catch (Exception e) {
65 return null;
66 }
67 return (String)map.put(toolChainKey, value);
68 }
69
70 public String put(ToolChainKey key, String value) {
71 return (String)map.put(key, value);
72 }
73
74 public String get(String key) {
75 ToolChainKey toolChainKey;
76
77 try {
78 toolChainKey = new ToolChainKey(key);
79 } catch (Exception e) {
80 return null;
81 }
82 return get(toolChainKey);
83 }
84
85 public String get(String key, String delimiter) {
86 ToolChainKey toolChainKey;
87
88 try {
89 toolChainKey = new ToolChainKey(key, delimiter);
90 } catch (Exception e) {
91 return null;
92 }
93 return get(toolChainKey);
94 }
95
96 public String get(String[] key) {
97 ToolChainKey toolChainKey;
98
99 try {
100 toolChainKey = new ToolChainKey(key);
101 } catch (Exception e) {
102 return null;
103 }
104 return get(toolChainKey);
105 }
106
107 public String get(ToolChainKey key) {
108 String result = map.get(key);
109 if (result != null || map.containsKey(key)) {
110 return result;
111 }
112
113 String[] keySet = key.getKeySet();
114 ToolChainKey tmpKey;
115 try {
116 tmpKey = new ToolChainKey(keySet);
117 } catch (Exception e) {
118 return null;
119 }
120
121 int level = matchLevel;
122 while (level >= 0) {
123 int tmpLevel = level;
124 while (tmpLevel >= level) {
125 String[] tmpKeySet = tmpKey.getKeySet();
126 try {
127 if (!tmpKeySet[tmpLevel].equals("*")) {
128 tmpKey.setKey("*", tmpLevel);
129 tmpLevel = matchLevel;
130 } else {
131 tmpKey.setKey(keySet[tmpLevel], tmpLevel);
132 --tmpLevel;
133 continue;
134 }
135 } catch (Exception e) {
136 return null;
137 }
138
139 result = map.get(tmpKey);
140 if (result != null) {
141 map.put(key, result);
142 return result;
143 }
144 }
145 --level;
146 }
147
148 map.put(key, result);
149 return result;
150 }
151
152 public int size() {
153 return map.size();
154 }
155
156 public Set<ToolChainKey> keySet() {
157 return (Set<ToolChainKey>)map.keySet();
158 }
159 }
160