]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/MigrationTools/org/tianocore/migration/Database.java
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.
13 package org
.tianocore
.migration
;
18 public final class Database
{
19 Database(String path
) throws Exception
{
22 importDBLib("Library.csv");
23 importDBGuid("Guid.csv", "Guid");
24 importDBGuid("Ppi.csv", "Ppi");
25 importDBGuid("Protocol.csv", "Protocol");
26 importDBMacro("Macro.csv");
29 public static String defaultpath
= "C:" + File
.separator
+ "tianocore" + File
.separator
+ "edk2" + File
.separator
+ "Tools" + File
.separator
+ "Conf" + File
.separator
+ "Migration";
31 public String DatabasePath
;
32 public Set
<String
> error
= new HashSet
<String
>();
34 private Map
<String
,Guid
> hashguid
= new HashMap
<String
,Guid
>();
35 private Map
<String
,Func
> hashfunc
= new HashMap
<String
,Func
>();
36 private Map
<String
,Macro
> hashmacro
= new HashMap
<String
,Macro
>();
38 private void importDBLib(String filename
) throws Exception
{
39 BufferedReader rd
= new BufferedReader(new FileReader(DatabasePath
+ File
.separator
+ filename
));
45 System
.out
.println("Found " + filename
+ ", Importing Library Database.");
46 while ((line
= rd
.readLine()) != null) {
47 if (line
.length() != 0) {
48 linecontext
= line
.split(",");
49 lf
= new Func(linecontext
);
50 hashfunc
.put(lf
.r8funcname
,lf
);
56 private void importDBGuid(String filename
, String type
) throws Exception
{
57 BufferedReader rd
= new BufferedReader(new FileReader(DatabasePath
+ File
.separator
+ filename
));
63 System
.out
.println("Found " + filename
+ ", Importing " + type
+ " Database.");
64 while ((line
= rd
.readLine()) != null) {
65 if (line
.length() != 0) {
66 linecontext
= line
.split(",");
67 gu
= new Guid(linecontext
, type
);
68 hashguid
.put(gu
.r8name
,gu
);
74 private void importDBMacro(String filename
) throws Exception
{
75 BufferedReader rd
= new BufferedReader(new FileReader(DatabasePath
+ File
.separator
+ filename
));
81 System
.out
.println("Found " + filename
+ ", Importing Macro Database.");
82 while ((line
= rd
.readLine()) != null) {
83 if (line
.length() != 0) {
84 linecontext
= line
.split(",");
85 mc
= new Macro(linecontext
);
86 hashmacro
.put(mc
.r8name
,mc
);
92 public String
getR9Lib(String r8funcname
) {
94 if (hashfunc
.containsKey(r8funcname
)) {
95 temp
= hashfunc
.get(r8funcname
).r9libname
;
100 public String
getR9Func(String r8funcname
) {
102 if (hashfunc
.containsKey(r8funcname
)) {
103 temp
= hashfunc
.get(r8funcname
).r9funcname
;
108 public boolean hasFunc(String r8lib
) {
109 return hashfunc
.containsKey(r8lib
);
112 public boolean hasGuid(String r8guid
) {
113 return hashguid
.containsKey(r8guid
);
116 public boolean hasMacro(String r8macro
) {
117 return hashmacro
.containsKey(r8macro
);
120 public String
getR9Macro(String r8macro
) {
121 return hashmacro
.get(r8macro
).r9name
; // the verification job of if the macro exists in the database is done when registering it
124 public String
getR9Guidname(String r8Guid
) {
127 temp
= hashguid
.get(r8Guid
).r9name
;
128 } catch (NullPointerException e
) {
129 error
.add("getR9Guidname :" + r8Guid
);
134 public String
getGuidType(String r8Guid
) {
137 temp
= hashguid
.get(r8Guid
).type
;
138 } catch (NullPointerException e
) {
139 error
.add("getR9Guidname :" + r8Guid
);
144 public static Database
init() throws Exception
{
145 if (System
.getenv("WORKSPACE") == null) {
146 return new Database("C:" + File
.separator
+ "tianocore" + File
.separator
+ "edk2" + File
.separator
+ "Tools" + File
.separator
+ "Conf" + File
.separator
+ "Migration");
148 return new Database(System
.getenv("WORKSPACE") + File
.separator
+ "Tools" + File
.separator
+ "Conf" + File
.separator
+ "Migration");