]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/id/ModuleIdentification.java
Change to new XML Schema.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / id / ModuleIdentification.java
1 package org.tianocore.build.id;
2
3 import java.io.File;
4
5 import org.tianocore.build.global.GlobalData;
6
7 public class ModuleIdentification extends Identification {
8
9 private PackageIdentification packageId;
10
11 private File msaFile;
12
13 private String moduleType;
14
15 private boolean isLibrary = false;
16
17 public ModuleIdentification(String guid, String version){
18 super(guid, version);
19 }
20
21 public ModuleIdentification(String guid, String version, PackageIdentification packageId){
22 super(guid, version);
23 this.packageId = packageId;
24 }
25
26 public ModuleIdentification(String name, String guid, String version){
27 super(name, guid, version);
28 }
29
30 public ModuleIdentification(String name, String guid, String version, PackageIdentification packageId){
31 super(name, guid, version);
32 this.packageId = packageId;
33 }
34
35 public boolean isLibrary() {
36 return isLibrary;
37 }
38
39 public void setLibrary(boolean isLibrary) {
40 this.isLibrary = isLibrary;
41 }
42
43 public File getMsaFile() {
44 prepareMsaFile();
45 return msaFile;
46 }
47
48 public String getModuleRelativePath() {
49 prepareMsaFile();
50 if (msaFile.getParent().length() == packageId.getPackageDir().length()) {
51 return ".";
52 }
53 return msaFile.getParent().substring(packageId.getPackageDir().length() + 1);
54 }
55
56 private void prepareMsaFile(){
57 if (msaFile == null) {
58 GlobalData.refreshModuleIdentification(this);
59 }
60 }
61
62 public void setMsaFile(File msaFile) {
63 this.msaFile = msaFile;
64 }
65
66 public boolean equals(Object obj) {
67 if (obj instanceof ModuleIdentification) {
68 ModuleIdentification id = (ModuleIdentification)obj;
69 if (guid.equalsIgnoreCase(id.getGuid()) && packageId.equals(id.getPackage())) {
70 if (version == null || id.version == null) {
71 return true;
72 }
73 else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){
74 return true;
75 }
76 else if (version.equalsIgnoreCase(id.version)) {
77 return true;
78 }
79 }
80 return false;
81 }
82 else {
83 return super.equals(obj);
84 }
85 }
86
87 public String toString(){
88 if (name == null) {
89 GlobalData.refreshModuleIdentification(this);
90 }
91 if (version == null || version.trim().equalsIgnoreCase("")) {
92 return "Module [" + name + "] in " + packageId;
93 }
94 else {
95 return "Module [" + name + " " + version + "] in " + packageId;
96 }
97 }
98
99 public void setPackage(PackageIdentification packageId) {
100 this.packageId = packageId;
101 }
102
103 public PackageIdentification getPackage() {
104 return packageId;
105 }
106
107 public String getModuleType() {
108 if (moduleType == null) {
109 GlobalData.refreshModuleIdentification(this);
110 }
111 return moduleType;
112 }
113
114 public void setModuleType(String moduleType) {
115 this.moduleType = moduleType;
116 }
117
118 public String getName() {
119 if (name == null) {
120 GlobalData.refreshModuleIdentification(this);
121 }
122 return name;
123 }
124 }