summaryrefslogtreecommitdiff
path: root/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/OpenFile.java
blob: 32eec68258ded37651be4e10a5ae5e4e6c2f54d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/** @file
 
 The file provides interface to open xml file.
 
 Copyright (c) 2006, Intel Corporation
 All rights reserved. This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php
 
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
package org.tianocore.frameworkwizard.common;

import java.io.File;
import java.io.IOException;

import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.tianocore.FrameworkDatabaseDocument;
import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.FrameworkDatabaseDocument.FrameworkDatabase;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;

public class OpenFile {
    /**
     
     @param args
     
     **/
    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }

    /**
     Open specificed Msa file and read its content
     
     @param strMsaFilePath The input data of Msa File Path
     
     **/
    public static ModuleSurfaceArea openMsaFile(String strMsaFilePath) throws IOException, XmlException, Exception {
        Log.log("Open Msa", strMsaFilePath);
        File msaFile = new File(strMsaFilePath);
        ModuleSurfaceAreaDocument xmlMsaDoc = (ModuleSurfaceAreaDocument) XmlObject.Factory.parse(msaFile);
        return xmlMsaDoc.getModuleSurfaceArea();
    }

    /**
     Open specificed Spd file and read its content
     
     @param strSpdFilePath The input data of Spd File Path
     
     **/
    public static PackageSurfaceArea openSpdFile(String strSpdFilePath) throws IOException, XmlException, Exception {
        Log.log("Open Spd", strSpdFilePath);
        File spdFile = new File(strSpdFilePath);
        PackageSurfaceAreaDocument xmlSpdDoc = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(spdFile);
        return xmlSpdDoc.getPackageSurfaceArea();
    }

    /**
     Open specificed Fpd file and read its content
     
     @param strFpdFilePath The input data of Fpd File Path
     
     **/
    public static PlatformSurfaceArea openFpdFile(String strFpdFilePath) throws IOException, XmlException,
                                                                                 Exception {
        Log.log("Open Fpd", strFpdFilePath);
        File fpdFile = new File(strFpdFilePath);
        PlatformSurfaceAreaDocument xmlFpdDoc = null;
        xmlFpdDoc = (PlatformSurfaceAreaDocument) XmlObject.Factory.parse(fpdFile);
        return xmlFpdDoc.getPlatformSurfaceArea();
    }

    /**
     
     Open specificed Framework Database file and read its content
     
     */
    public static FrameworkDatabase openFrameworkDb(String strDbFilePath) throws IOException, XmlException, Exception {
        Log.log("Open Framework Database", strDbFilePath);
        File db = new File(strDbFilePath);
        FrameworkDatabaseDocument xmlDb = null;
        xmlDb = (FrameworkDatabaseDocument) XmlObject.Factory.parse(db);
        return xmlDb.getFrameworkDatabase();
    }
}