4 This class is to generate a global table for the content of spd file.
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 package org
.tianocore
.frameworkwizard
.platform
.ui
.global
;
19 import java
.util
.HashMap
;
23 import org
.apache
.xmlbeans
.XmlObject
;
24 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.ModuleIdentification
;
25 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.PackageIdentification
;
29 This class is to generate a global table for the content of spd file.
36 Map
<ModuleIdentification
, File
> msaInfo
= new HashMap
<ModuleIdentification
, File
>();
39 // Xml Doc of Spd file, Msa file
41 public Map
<String
, XmlObject
> spdDocMap
= new HashMap
<String
, XmlObject
>();
42 public Map
<ModuleIdentification
, XmlObject
> msaDocMap
= new HashMap
<ModuleIdentification
, XmlObject
>();
46 PackageIdentification packageId
;
51 This function mainly initialize some member variables.
53 Spd(File packageFile
) throws Exception
{
55 XmlObject spdDoc
= XmlObject
.Factory
.parse(packageFile
);
57 // Verify SPD file, if is invalid, throw Exception
59 // if (! spdDoc.validate()) {
60 // throw new Exception("Package Surface Area file [" + packageFile.getPath() + "] is invalid. ");
62 // We can change Map to XmlObject
64 spdDocMap
.put("PackageSurfaceArea", spdDoc
);
65 SurfaceAreaQuery
.setDoc(spdDocMap
);
69 packageId
= SurfaceAreaQuery
.getSpdHeader();
70 packageId
.setSpdFile(packageFile
);
73 // initialize Msa Files
74 // MSA file is absolute file path
76 String
[] msaFilenames
= SurfaceAreaQuery
.getSpdMsaFile();
77 for (int i
= 0; i
< msaFilenames
.length
; i
++){
78 File msaFile
= new File(packageId
.getPackageDir() + File
.separatorChar
+ msaFilenames
[i
]);
79 if (!msaFile
.exists()) {
82 Map
<String
, XmlObject
> msaDoc
= WorkspaceProfile
.getNativeMsa( msaFile
);
83 SurfaceAreaQuery
.push(msaDoc
);
84 ModuleIdentification moduleId
= SurfaceAreaQuery
.getMsaHeader();
85 SurfaceAreaQuery
.pop();
86 moduleId
.setPackage(packageId
);
87 msaInfo
.put(moduleId
, msaFile
);
88 msaDocMap
.put(moduleId
, msaDoc
.get("ModuleSurfaceArea"));
94 throw new Exception("Parse package description file [" + packageId
.getSpdFile() + "] Error.\n"
99 public PackageIdentification
getPackageId() {
103 public File
getModuleFile(ModuleIdentification moduleId
) {
104 return msaInfo
.get(moduleId
);
107 public Set
<ModuleIdentification
> getModules(){
108 return msaInfo
.keySet();