]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpenFile.java
1. Restructure some folders and files
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / Identifications / 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.Identifications;
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 import org.tianocore.frameworkwizard.common.Log;
31
32 public class OpenFile {
33 /**
34
35 @param args
36
37 **/
38 public static void main(String[] args) {
39 // TODO Auto-generated method stub
40
41 }
42
43 /**
44 Open specificed Msa file and read its content
45
46 @param strMsaFilePath The input data of Msa File Path
47
48 **/
49 public static ModuleSurfaceArea openMsaFile(String strMsaFilePath) throws IOException, XmlException, Exception {
50 Log.log("Open Msa", strMsaFilePath);
51 File msaFile = new File(strMsaFilePath);
52 ModuleSurfaceAreaDocument xmlMsaDoc = (ModuleSurfaceAreaDocument) XmlObject.Factory.parse(msaFile);
53 return xmlMsaDoc.getModuleSurfaceArea();
54 }
55
56 /**
57 Open specificed Spd file and read its content
58
59 @param strSpdFilePath The input data of Spd File Path
60
61 **/
62 public static PackageSurfaceArea openSpdFile(String strSpdFilePath) throws IOException, XmlException, Exception {
63 Log.log("Open Spd", strSpdFilePath);
64 File spdFile = new File(strSpdFilePath);
65 PackageSurfaceAreaDocument xmlSpdDoc = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(spdFile);
66 return xmlSpdDoc.getPackageSurfaceArea();
67 }
68
69 /**
70 Open specificed Fpd file and read its content
71
72 @param strFpdFilePath The input data of Fpd File Path
73
74 **/
75 public static PlatformSurfaceArea openFpdFile(String strFpdFilePath) throws IOException, XmlException,
76 Exception {
77 Log.log("Open Fpd", strFpdFilePath);
78 File fpdFile = new File(strFpdFilePath);
79 PlatformSurfaceAreaDocument xmlFpdDoc = null;
80 xmlFpdDoc = (PlatformSurfaceAreaDocument) XmlObject.Factory.parse(fpdFile);
81 return xmlFpdDoc.getPlatformSurfaceArea();
82 }
83
84 /**
85
86 Open specificed Framework Database file and read its content
87
88 */
89 public static FrameworkDatabase openFrameworkDb(String strDbFilePath) throws IOException, XmlException, Exception {
90 Log.log("Open Framework Database", strDbFilePath);
91 File db = new File(strDbFilePath);
92 FrameworkDatabaseDocument xmlDb = null;
93 xmlDb = (FrameworkDatabaseDocument) XmlObject.Factory.parse(db);
94 return xmlDb.getFrameworkDatabase();
95 }
96 }