]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/OpenFile.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / OpenFile.java
1 /** @file
2
3 The file provides interface to open xml file.
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15 package org.tianocore.frameworkwizard.common;
16
17 import java.io.File;
18 import java.io.IOException;
19
20 import org.apache.xmlbeans.XmlException;
21 import org.apache.xmlbeans.XmlObject;
22 import org.tianocore.FrameworkDatabaseDocument;
23 import org.tianocore.ModuleSurfaceAreaDocument;
24 import org.tianocore.PackageSurfaceAreaDocument;
25 import org.tianocore.PlatformSurfaceAreaDocument;
26 import org.tianocore.FrameworkDatabaseDocument.FrameworkDatabase;
27 import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
28 import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
29 import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
30
31 public class OpenFile {
32 /**
33
34 @param args
35
36 **/
37 public static void main(String[] args) {
38 // TODO Auto-generated method stub
39
40 }
41
42 /**
43 Open specificed Msa file and read its content
44
45 @param strMsaFilePath The input data of Msa File Path
46
47 **/
48 public static ModuleSurfaceArea openMsaFile(String strMsaFilePath) throws IOException, XmlException, Exception {
49 Log.log("Open Msa", strMsaFilePath);
50 File msaFile = new File(strMsaFilePath);
51 ModuleSurfaceAreaDocument xmlMsaDoc = (ModuleSurfaceAreaDocument) XmlObject.Factory.parse(msaFile);
52 return xmlMsaDoc.getModuleSurfaceArea();
53 }
54
55 /**
56 Open specificed Spd file and read its content
57
58 @param strSpdFilePath The input data of Spd File Path
59
60 **/
61 public static PackageSurfaceArea openSpdFile(String strSpdFilePath) throws IOException, XmlException, Exception {
62 Log.log("Open Spd", strSpdFilePath);
63 File spdFile = new File(strSpdFilePath);
64 PackageSurfaceAreaDocument xmlSpdDoc = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(spdFile);
65 return xmlSpdDoc.getPackageSurfaceArea();
66 }
67
68 /**
69 Open specificed Fpd file and read its content
70
71 @param strFpdFilePath The input data of Fpd File Path
72
73 **/
74 public static PlatformSurfaceArea openFpdFile(String strFpdFilePath) throws IOException, XmlException,
75 Exception {
76 Log.log("Open Fpd", strFpdFilePath);
77 File fpdFile = new File(strFpdFilePath);
78 PlatformSurfaceAreaDocument xmlFpdDoc = null;
79 xmlFpdDoc = (PlatformSurfaceAreaDocument) XmlObject.Factory.parse(fpdFile);
80 return xmlFpdDoc.getPlatformSurfaceArea();
81 }
82
83 /**
84
85 Open specificed Framework Database file and read its content
86
87 */
88 public static FrameworkDatabase openFrameworkDb(String strDbFilePath) throws IOException, XmlException, Exception {
89 Log.log("Open Framework Database", strDbFilePath);
90 File db = new File(strDbFilePath);
91 FrameworkDatabaseDocument xmlDb = null;
92 xmlDb = (FrameworkDatabaseDocument) XmlObject.Factory.parse(db);
93 return xmlDb.getFrameworkDatabase();
94 }
95 }