]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/Spd.java
Fixes:
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / global / Spd.java
CommitLineData
a13899c5 1/** @file\r
2 Spd class.\r
3\r
4 This class is to generate a global table for the content of spd file.\r
5 \r
6 Copyright (c) 2006, Intel Corporation\r
7 All rights reserved. This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11 \r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15 **/\r
16package org.tianocore.frameworkwizard.platform.ui.global;\r
17\r
18import java.io.File;\r
19import java.util.HashMap;\r
a13899c5 20import java.util.Map;\r
21import java.util.Set;\r
22\r
23import org.apache.xmlbeans.XmlObject;\r
24import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;\r
25import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;\r
26\r
27/**\r
28 \r
29 This class is to generate a global table for the content of spd file.\r
30 \r
31 **/\r
32public class Spd {\r
33 ///\r
34 ///\r
35 ///\r
36 Map<ModuleIdentification, File> msaInfo = new HashMap<ModuleIdentification, File>();\r
12e17a0a 37 \r
a13899c5 38 //\r
39 // Xml Doc of Spd file, Msa file\r
40 //\r
41 public Map<String, XmlObject> spdDocMap = new HashMap<String, XmlObject>();\r
42 public Map<ModuleIdentification, XmlObject> msaDocMap = new HashMap<ModuleIdentification, XmlObject>();\r
43 ///\r
44 /// Package path.\r
45 ///\r
46 PackageIdentification packageId;\r
47\r
48 /**\r
49 Constructor function\r
50 \r
51 This function mainly initialize some member variables. \r
52 **/\r
53 Spd(File packageFile) throws Exception {\r
54 try {\r
55 XmlObject spdDoc = XmlObject.Factory.parse(packageFile);\r
56 //\r
57 // Verify SPD file, if is invalid, throw Exception\r
58 //\r
59// if (! spdDoc.validate()) {\r
60// throw new Exception("Package Surface Area file [" + packageFile.getPath() + "] is invalid. ");\r
61// }\r
62 // We can change Map to XmlObject\r
63 \r
64 spdDocMap.put("PackageSurfaceArea", spdDoc);\r
65 SurfaceAreaQuery.setDoc(spdDocMap);\r
66 //\r
67 //\r
68 //\r
69 packageId = SurfaceAreaQuery.getSpdHeader();\r
70 packageId.setSpdFile(packageFile);\r
71 \r
72 //\r
73 // initialize Msa Files\r
74 // MSA file is absolute file path\r
75 //\r
76 String[] msaFilenames = SurfaceAreaQuery.getSpdMsaFile();\r
77 for (int i = 0; i < msaFilenames.length; i++){\r
78 File msaFile = new File(packageId.getPackageDir() + File.separatorChar + msaFilenames[i]);\r
12e17a0a 79 if (!msaFile.exists()) {\r
80 continue;\r
81 }\r
a13899c5 82 Map<String, XmlObject> msaDoc = GlobalData.getNativeMsa( msaFile );\r
83 SurfaceAreaQuery.push(msaDoc);\r
84 ModuleIdentification moduleId = SurfaceAreaQuery.getMsaHeader();\r
85 SurfaceAreaQuery.pop();\r
86 moduleId.setPackage(packageId);\r
87 msaInfo.put(moduleId, msaFile);\r
88 msaDocMap.put(moduleId, msaDoc.get("ModuleSurfaceArea"));\r
89 }\r
12e17a0a 90 \r
a13899c5 91 }\r
92 catch (Exception e) {\r
12e17a0a 93 \r
a13899c5 94 throw new Exception("Parse package description file [" + packageId.getSpdFile() + "] Error.\n"\r
95 + e.getMessage());\r
96 }\r
97 }\r
98\r
99 public PackageIdentification getPackageId() {\r
100 return packageId;\r
101 }\r
102\r
103 public File getModuleFile(ModuleIdentification moduleId) {\r
104 return msaInfo.get(moduleId);\r
105 }\r
106 \r
107 public Set<ModuleIdentification> getModules(){\r
108 return msaInfo.keySet();\r
109 }\r
a13899c5 110 \r
a13899c5 111}\r