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.
14 package org
.tianocore
.build
.toolchain
;
16 import java
.util
.HashMap
;
20 public class ToolChainMap
{
22 private int matchLevel
= ToolChainKey
.keyLength
- 2;
24 private Map
<ToolChainKey
, String
> map
= null;
26 public ToolChainMap() {
27 this.map
= new HashMap
<ToolChainKey
, String
>();
30 public String
put(String key
, String delimiter
, String value
) {
31 ToolChainKey toolChainKey
;
34 toolChainKey
= new ToolChainKey(key
, delimiter
);
35 } catch (Exception e
) {
38 return (String
)map
.put(toolChainKey
, value
);
41 public String
put(String key
, String value
) {
42 ToolChainKey toolChainKey
;
45 toolChainKey
= new ToolChainKey(key
);
46 } catch (Exception e
) {
49 return (String
)map
.put(toolChainKey
, value
);
52 public String
put(String
[] key
, String value
) {
53 ToolChainKey toolChainKey
;
56 toolChainKey
= new ToolChainKey(key
);
57 } catch (Exception e
) {
60 return (String
)map
.put(toolChainKey
, value
);
63 public String
put(ToolChainKey key
, String value
) {
64 return (String
)map
.put(key
, value
);
67 public String
get(String key
) {
68 ToolChainKey toolChainKey
;
71 toolChainKey
= new ToolChainKey(key
);
72 } catch (Exception e
) {
75 return get(toolChainKey
);
78 public String
get(String key
, String delimiter
) {
79 ToolChainKey toolChainKey
;
82 toolChainKey
= new ToolChainKey(key
, delimiter
);
83 } catch (Exception e
) {
86 return get(toolChainKey
);
89 public String
get(String
[] key
) {
90 ToolChainKey toolChainKey
;
93 toolChainKey
= new ToolChainKey(key
);
94 } catch (Exception e
) {
97 return get(toolChainKey
);
100 public String
get(ToolChainKey key
) {
101 String result
= map
.get(key
);
102 if (result
!= null || map
.containsKey(key
)) {
106 String
[] keySet
= key
.getKeySet();
109 tmpKey
= new ToolChainKey(keySet
);
110 } catch (Exception e
) {
114 int level
= matchLevel
;
116 int tmpLevel
= level
;
117 while (tmpLevel
>= level
) {
118 String
[] tmpKeySet
= tmpKey
.getKeySet();
120 if (!tmpKeySet
[tmpLevel
].equals("*")) {
121 tmpKey
.setKey("*", tmpLevel
);
122 tmpLevel
= matchLevel
;
124 tmpKey
.setKey(keySet
[tmpLevel
], tmpLevel
);
128 } catch (Exception e
) {
132 result
= map
.get(tmpKey
);
133 if (result
!= null) {
134 map
.put(key
, result
);
141 map
.put(key
, result
);
149 public Set
<ToolChainKey
> keySet() {
150 return (Set
<ToolChainKey
>)map
.keySet();