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 public class ToolChainMap
{
27 private int matchLevel
= ToolChainKey
.keyLength
- 2;
29 private Map
<ToolChainKey
, String
> map
= null;
31 public ToolChainMap() {
32 this.map
= new HashMap
<ToolChainKey
, String
>();
35 public String
put(String key
, String delimiter
, String value
) {
36 ToolChainKey toolChainKey
;
39 toolChainKey
= new ToolChainKey(key
, delimiter
);
40 } catch (Exception e
) {
43 return (String
)map
.put(toolChainKey
, value
);
46 public String
put(String key
, String value
) {
47 ToolChainKey toolChainKey
;
50 toolChainKey
= new ToolChainKey(key
);
51 } catch (Exception e
) {
54 return (String
)map
.put(toolChainKey
, value
);
57 public String
put(String
[] key
, String value
) {
58 ToolChainKey toolChainKey
;
61 toolChainKey
= new ToolChainKey(key
);
62 } catch (Exception e
) {
65 return (String
)map
.put(toolChainKey
, value
);
68 public String
put(ToolChainKey key
, String value
) {
69 return (String
)map
.put(key
, value
);
72 public String
get(String key
) {
73 ToolChainKey toolChainKey
;
76 toolChainKey
= new ToolChainKey(key
);
77 } catch (Exception e
) {
80 return get(toolChainKey
);
83 public String
get(String key
, String delimiter
) {
84 ToolChainKey toolChainKey
;
87 toolChainKey
= new ToolChainKey(key
, delimiter
);
88 } catch (Exception e
) {
91 return get(toolChainKey
);
94 public String
get(String
[] key
) {
95 ToolChainKey toolChainKey
;
98 toolChainKey
= new ToolChainKey(key
);
99 } catch (Exception e
) {
102 return get(toolChainKey
);
105 public String
get(ToolChainKey key
) {
106 String result
= map
.get(key
);
107 if (result
!= null || map
.containsKey(key
)) {
111 String
[] keySet
= key
.getKeySet();
114 tmpKey
= new ToolChainKey(keySet
);
115 } catch (Exception e
) {
119 int level
= matchLevel
;
121 int tmpLevel
= level
;
122 while (tmpLevel
>= level
) {
123 String
[] tmpKeySet
= tmpKey
.getKeySet();
125 if (!tmpKeySet
[tmpLevel
].equals("*")) {
126 tmpKey
.setKey("*", tmpLevel
);
127 tmpLevel
= matchLevel
;
129 tmpKey
.setKey(keySet
[tmpLevel
], tmpLevel
);
133 } catch (Exception e
) {
137 result
= map
.get(tmpKey
);
138 if (result
!= null) {
139 map
.put(key
, result
);
146 map
.put(key
, result
);
154 public Set
<ToolChainKey
> keySet() {
155 return (Set
<ToolChainKey
>)map
.keySet();