3 The file is used to init workspace and get basic information of workspace
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.
16 package org
.tianocore
.packaging
.workspace
.common
;
20 import org
.apache
.xmlbeans
.XmlException
;
21 import org
.apache
.xmlbeans
.XmlObject
;
22 import org
.tianocore
.FrameworkDatabaseDocument
;
23 import org
.tianocore
.common
.Log
;
26 The file is used to init workspace and get basic information of workspace
28 @since ModuleEditor 1.0
31 public class Workspace
{
34 // Define class members
36 private String currentWorkspace
= null;
38 private FrameworkDatabaseDocument xmlFrameworkDbDoc
= null;
40 private String strWorkspaceDatabaseFile
= System
.getProperty("file.separator") + "Tools"
41 + System
.getProperty("file.separator") + "Conf"
42 + System
.getProperty("file.separator") + "FrameworkDatabase.db";
44 public static void main(String
[] args
) {
49 This is the default constructor
50 Get current WORKSPACE from system environment variable
54 this.currentWorkspace
= System
.getenv("WORKSPACE");
58 Check if current workspace exists of not
60 @retval true - The current WORKSPACE exists
61 @retval false - The current WORKSPACE doesn't exist
64 public boolean checkCurrentWorkspace() {
65 return checkCurrentWorkspace(getCurrentWorkspace());
69 Check if current workspace exists or not via input workspace path
71 @param strWorkspace The input data of WORKSPACE path
72 @retval true - The current WORKSPACE exists
73 @retval false - The current WORKSPACE doesn't exist
76 public boolean checkCurrentWorkspace(String strWorkspace
) {
77 if (strWorkspace
== null || strWorkspace
== "") {
80 File f
= new File(strWorkspace
);
81 if (!f
.isDirectory()) {
93 @return currentWorkspace
96 public String
getCurrentWorkspace() {
97 return currentWorkspace
;
101 Set Current Workspace
103 @param currentWorkspace The input data of currentWorkspace
106 public void setCurrentWorkspace(String currentWorkspace
) {
107 this.currentWorkspace
= currentWorkspace
;
111 Open Framework Database file
114 private void openFrameworkDb() {
115 String strFrameworkDbFilePath
= this.getCurrentWorkspace() + strWorkspaceDatabaseFile
;
117 xmlFrameworkDbDoc
= (FrameworkDatabaseDocument
) XmlObject
.Factory
.parse(strFrameworkDbFilePath
);
118 } catch (XmlException e
) {
119 Log
.err("Open Framework Database " + strFrameworkDbFilePath
, e
.getMessage());
121 } catch (Exception e
) {
122 Log
.err("Open Framework Database " + strFrameworkDbFilePath
, "Invalid file type");
128 Get FrameworkDatabaseDocument
130 @return FrameworkDatabaseDocument
133 public FrameworkDatabaseDocument
getXmlFrameworkDbDoc() {
135 return xmlFrameworkDbDoc
;
139 Set FrameworkDatabaseDocument
141 @param xmlFrameworkDbDoc The input data of FrameworkDatabaseDocument
144 public void setXmlFrameworkDbDoc(FrameworkDatabaseDocument xmlFrameworkDbDoc
) {
145 this.xmlFrameworkDbDoc
= xmlFrameworkDbDoc
;