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
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.
19 package org
.tianocore
.build
.toolchain
;
21 import java
.util
.HashMap
;
25 import org
.tianocore
.exception
.EdkException
;
27 public class ToolChainMap
{
29 private int matchLevel
= ToolChainKey
.keyLength
- 2;
31 private Map
<ToolChainKey
, String
> map
= null;
33 public ToolChainMap() {
34 this.map
= new HashMap
<ToolChainKey
, String
>();
37 public String
put(String key
, String delimiter
, String value
) {
38 ToolChainKey toolChainKey
;
41 toolChainKey
= new ToolChainKey(key
, delimiter
);
42 } catch (Exception e
) {
45 return (String
)map
.put(toolChainKey
, value
);
48 public String
put(String key
, String value
) {
49 ToolChainKey toolChainKey
;
52 toolChainKey
= new ToolChainKey(key
);
53 } catch (Exception e
) {
56 return (String
)map
.put(toolChainKey
, value
);
59 public String
put(String
[] key
, String value
) {
60 ToolChainKey toolChainKey
;
63 toolChainKey
= new ToolChainKey(key
);
64 } catch (Exception e
) {
67 return (String
)map
.put(toolChainKey
, value
);
70 public String
put(ToolChainKey key
, String value
) {
71 return (String
)map
.put(key
, value
);
74 public String
get(String key
) {
75 ToolChainKey toolChainKey
;
78 toolChainKey
= new ToolChainKey(key
);
79 } catch (Exception e
) {
82 return get(toolChainKey
);
85 public String
get(String key
, String delimiter
) {
86 ToolChainKey toolChainKey
;
89 toolChainKey
= new ToolChainKey(key
, delimiter
);
90 } catch (Exception e
) {
93 return get(toolChainKey
);
96 public String
get(String
[] key
) {
97 ToolChainKey toolChainKey
;
100 toolChainKey
= new ToolChainKey(key
);
101 } catch (Exception e
) {
104 return get(toolChainKey
);
107 public String
get(ToolChainKey key
) {
108 String result
= map
.get(key
);
109 if (result
!= null || map
.containsKey(key
)) {
113 String
[] keySet
= key
.getKeySet();
116 tmpKey
= new ToolChainKey(keySet
);
117 } catch (Exception e
) {
121 int level
= matchLevel
;
123 int tmpLevel
= level
;
124 while (tmpLevel
>= level
) {
125 String
[] tmpKeySet
= tmpKey
.getKeySet();
127 if (!tmpKeySet
[tmpLevel
].equals("*")) {
128 tmpKey
.setKey("*", tmpLevel
);
129 tmpLevel
= matchLevel
;
131 tmpKey
.setKey(keySet
[tmpLevel
], tmpLevel
);
135 } catch (Exception e
) {
139 result
= map
.get(tmpKey
);
140 if (result
!= null) {
141 map
.put(key
, result
);
148 map
.put(key
, result
);
156 public Set
<ToolChainKey
> keySet() {
157 return (Set
<ToolChainKey
>)map
.keySet();