Change to new XML Schema.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / id / PackageIdentification.java
CommitLineData
a29c47e0 1package org.tianocore.build.id;\r
2import java.io.File;\r
3\r
4import org.tianocore.build.global.GlobalData;\r
5\r
6public class PackageIdentification extends Identification{\r
7 \r
8 //\r
9 // It is optional\r
10 //\r
11 private File spdFile;\r
12 \r
13 public PackageIdentification(String guid, String version){\r
14 super(guid, version);\r
15 }\r
16 \r
17 public PackageIdentification(String name, String guid, String version){\r
18 super(name, guid, version);\r
19 }\r
20 \r
21 public PackageIdentification(String name, String guid, String version, String spdFilename){\r
22 super(name, guid, version);\r
23 this.spdFile = new File(spdFilename);\r
24 }\r
25 \r
26 public PackageIdentification(String name, String guid, String version, File spdFile){\r
27 super(name, guid, version);\r
28 this.spdFile = spdFile;\r
29 }\r
30 \r
31 public void setSpdFile(File spdFile) {\r
32 this.spdFile = spdFile;\r
33 }\r
34\r
35 public File getSpdFile() {\r
36 return spdFile;\r
37 }\r
38\r
39 public String toString(){\r
40 if (name == null) {\r
41 GlobalData.refreshPackageIdentification(this);\r
42 }\r
43 if (version == null || version.trim().equalsIgnoreCase("")) {\r
44 return "package [" + name + "]";\r
45 }\r
46 else {\r
47 return "package [" + name + " " + version + "]";\r
48 }\r
49 }\r
50 \r
51 public String getPackageDir(){\r
52 prepareSpdFile();\r
53 return spdFile.getParent();\r
54 }\r
55 \r
56 public String getPackageRelativeDir(){\r
57 prepareSpdFile();\r
58 return spdFile.getParent().substring(GlobalData.getWorkspacePath().length() + 1);\r
59 }\r
60 \r
61 private void prepareSpdFile(){\r
62 if (spdFile == null) {\r
63 GlobalData.refreshPackageIdentification(this);\r
64 }\r
65 }\r
66 \r
67 public String getName() {\r
68 if (name == null) {\r
69 GlobalData.refreshPackageIdentification(this);\r
70 }\r
71 return name;\r
72 }\r
73}\r