3 The file provides interface to save xml file.
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
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.
15 package org
.tianocore
.frameworkwizard
.common
;
19 import org
.apache
.xmlbeans
.XmlCursor
;
20 import org
.apache
.xmlbeans
.XmlOptions
;
21 import org
.tianocore
.FrameworkDatabaseDocument
;
22 import org
.tianocore
.ModuleSurfaceAreaDocument
;
23 import org
.tianocore
.PackageSurfaceAreaDocument
;
24 import org
.tianocore
.PlatformSurfaceAreaDocument
;
25 import org
.tianocore
.FrameworkDatabaseDocument
.FrameworkDatabase
;
26 import org
.tianocore
.ModuleSurfaceAreaDocument
.ModuleSurfaceArea
;
27 import org
.tianocore
.PackageSurfaceAreaDocument
.PackageSurfaceArea
;
28 import org
.tianocore
.PlatformSurfaceAreaDocument
.PlatformSurfaceArea
;
30 public class SaveFile
{
37 public static void main(String
[] args
) {
38 // TODO Auto-generated method stub
46 public static void saveMsaFile(String path
, ModuleSurfaceArea msa
) throws Exception
{
47 ModuleSurfaceAreaDocument msaDoc
= ModuleSurfaceAreaDocument
.Factory
.newInstance();
48 File f
= new File(path
);
53 XmlCursor cursor
= XmlConfig
.setupXmlCursor(msa
.newCursor());
58 XmlOptions options
= XmlConfig
.setupXmlOptions();
63 msaDoc
.addNewModuleSurfaceArea();
64 msaDoc
.setModuleSurfaceArea((ModuleSurfaceArea
) cursor
.getObject());
68 msaDoc
.save(f
, options
);
75 public static void saveSpdFile(String path
, PackageSurfaceArea spd
) throws Exception
{
76 PackageSurfaceAreaDocument spdDoc
= PackageSurfaceAreaDocument
.Factory
.newInstance();
77 File f
= new File(path
);
82 XmlCursor cursor
= XmlConfig
.setupXmlCursor(spd
.newCursor());
87 XmlOptions options
= XmlConfig
.setupXmlOptions();
92 spdDoc
.addNewPackageSurfaceArea();
93 spdDoc
.setPackageSurfaceArea((PackageSurfaceArea
) cursor
.getObject());
97 spdDoc
.save(f
, options
);
104 public static void saveFpdFile(String path
, PlatformSurfaceArea fpd
) throws Exception
{
105 PlatformSurfaceAreaDocument fpdDoc
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
106 File f
= new File(path
);
111 XmlCursor cursor
= XmlConfig
.setupXmlCursor(fpd
.newCursor());
116 XmlOptions options
= XmlConfig
.setupXmlOptions();
121 fpdDoc
.addNewPlatformSurfaceArea();
122 fpdDoc
.setPlatformSurfaceArea((PlatformSurfaceArea
) cursor
.getObject());
126 fpdDoc
.save(f
, options
);
130 Save file as framework db
133 public static void saveDbFile(String path
, FrameworkDatabase db
) throws Exception
{
134 FrameworkDatabaseDocument dbDoc
= FrameworkDatabaseDocument
.Factory
.newInstance();
135 File f
= new File(path
);
140 XmlCursor cursor
= XmlConfig
.setupXmlCursor(db
.newCursor());
145 XmlOptions options
= XmlConfig
.setupXmlOptions();
150 dbDoc
.addNewFrameworkDatabase();
151 dbDoc
.setFrameworkDatabase((FrameworkDatabase
) cursor
.getObject());
156 dbDoc
.save(f
, options
);