]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PackageIdentification.java
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / id / PackageIdentification.java
1 package org.tianocore.frameworkwizard.platform.ui.id;
2 import java.io.File;
3
4 import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
5
6 public class PackageIdentification extends Identification{
7
8 //
9 // It is optional
10 //
11 private File spdFile;
12
13 public PackageIdentification(String name, String guid, String version){
14 super(name, guid, version);
15 }
16
17 public PackageIdentification(String name, String guid, String version, String spdFilename){
18 super(name, guid, version);
19 this.spdFile = new File(spdFilename);
20 }
21
22 public PackageIdentification(String name, String guid, String version, File spdFile){
23 super(name, guid, version);
24 this.spdFile = spdFile;
25 }
26
27 public void setSpdFile(File spdFile) {
28 this.spdFile = spdFile;
29 }
30
31 public File getSpdFile() {
32 return spdFile;
33 }
34
35 public String toString(){
36 if (version == null || version.trim().equalsIgnoreCase("")) {
37 return "package [" + name + "]";
38 }
39 else {
40 return "package [" + name + " " + version + "]";
41 }
42 }
43
44 public String getPackageDir()throws Exception{
45 prepareSpdFile();
46 return spdFile.getParent();
47 }
48
49 public String getPackageRelativeDir()throws Exception{
50 prepareSpdFile();
51 return spdFile.getParent().substring(GlobalData.getWorkspacePath().length() + 1);
52 }
53
54 private void prepareSpdFile() throws Exception{
55 if (spdFile == null) {
56 spdFile = GlobalData.getPackageFile(this);
57 }
58 }
59 }