Rewrote the error message output when module cannnot be found in any packages.
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / id / ModuleIdentification.java
CommitLineData
5f42a4ba 1/** @file\r
2This file is to define ModuleIdentification class.\r
3\r
4Copyright (c) 2006, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12**/\r
13\r
a29c47e0 14package org.tianocore.build.id;\r
15\r
16import java.io.File;\r
17\r
01413f0c 18/**\r
19 This class is used to identify a module with Module Guid, Module Version, \r
20 Package Guid, Package Version. \r
a29c47e0 21\r
01413f0c 22 @since GenBuild 1.0\r
23**/\r
a29c47e0 24public class ModuleIdentification extends Identification {\r
25 \r
26 private PackageIdentification packageId;\r
27 \r
28 private File msaFile;\r
29 \r
30 private String moduleType;\r
31 \r
32 private boolean isLibrary = false;\r
33\r
01413f0c 34 /**\r
35 @param guid Guid\r
36 @param version Version\r
37 **/\r
a29c47e0 38 public ModuleIdentification(String guid, String version){\r
39 super(guid, version);\r
40 }\r
41 \r
01413f0c 42 /**\r
43 @param guid Guid\r
44 @param version Version\r
45 @param packageId Package Identification\r
46 **/\r
a29c47e0 47 public ModuleIdentification(String guid, String version, PackageIdentification packageId){\r
48 super(guid, version);\r
49 this.packageId = packageId;\r
50 }\r
51 \r
01413f0c 52 /**\r
53 @param name Name\r
54 @param guid Guid\r
55 @param version Version\r
56 **/\r
a29c47e0 57 public ModuleIdentification(String name, String guid, String version){\r
58 super(name, guid, version);\r
59 }\r
60 \r
01413f0c 61 /**\r
62 @param name Name\r
63 @param guid Guid\r
64 @param version Version\r
65 @param packageId PackageIdentification\r
66 **/\r
a29c47e0 67 public ModuleIdentification(String name, String guid, String version, PackageIdentification packageId){\r
68 super(name, guid, version);\r
69 this.packageId = packageId;\r
70 }\r
71 \r
01413f0c 72 /**\r
73 @return boolean is this module is library\r
74 **/\r
a29c47e0 75 public boolean isLibrary() {\r
76 return isLibrary;\r
77 }\r
78\r
01413f0c 79 /**\r
80 @param isLibrary \r
81 **/\r
a29c47e0 82 public void setLibrary(boolean isLibrary) {\r
83 this.isLibrary = isLibrary;\r
84 }\r
85\r
01413f0c 86 /**\r
87 @return MSA File\r
88 **/\r
a29c47e0 89 public File getMsaFile() {\r
a29c47e0 90 return msaFile;\r
91 }\r
92 \r
01413f0c 93 /**\r
94 @return Module relative path to package\r
95 **/\r
a29c47e0 96 public String getModuleRelativePath() {\r
a29c47e0 97 if (msaFile.getParent().length() == packageId.getPackageDir().length()) {\r
98 return ".";\r
99 }\r
100 return msaFile.getParent().substring(packageId.getPackageDir().length() + 1);\r
101 }\r
102\r
01413f0c 103 /**\r
104 @param msaFile Set Msa File\r
105 **/\r
a29c47e0 106 public void setMsaFile(File msaFile) {\r
107 this.msaFile = msaFile;\r
108 }\r
109 \r
110 public boolean equals(Object obj) {\r
111 if (obj instanceof ModuleIdentification) {\r
112 ModuleIdentification id = (ModuleIdentification)obj;\r
113 if (guid.equalsIgnoreCase(id.getGuid()) && packageId.equals(id.getPackage())) {\r
114 if (version == null || id.version == null) {\r
115 return true;\r
116 }\r
117 else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){\r
118 return true;\r
119 }\r
120 else if (version.equalsIgnoreCase(id.version)) {\r
121 return true;\r
122 }\r
123 }\r
124 return false;\r
125 }\r
126 else {\r
127 return super.equals(obj);\r
128 }\r
129 }\r
130 \r
892b0e7a 131 public String toString() {\r
89da7eba 132 String nameString;\r
133 String versionString;\r
134 String packageString;\r
135\r
136 if (name != null && name != "") {\r
137 nameString = name;\r
138 } else {\r
139 if (guid != null && guid != "") {\r
140 nameString = guid;\r
141 } else {\r
142 nameString = "UNKNOWN";\r
143 }\r
a29c47e0 144 }\r
89da7eba 145\r
146 if (version != null) {\r
147 versionString = version;\r
148 } else {\r
149 versionString = ""; \r
a29c47e0 150 }\r
89da7eba 151\r
152 if (packageId != null) {\r
153 packageString = packageId.toString();\r
154 } else {\r
155 packageString = "Package [UNKNOWN]";\r
156 }\r
157\r
158 return "Module [" + nameString + versionString + "] in " + packageString; \r
a29c47e0 159 }\r
160\r
01413f0c 161 /**\r
162 @param packageId set package identification\r
163 **/\r
a29c47e0 164 public void setPackage(PackageIdentification packageId) {\r
165 this.packageId = packageId;\r
166 }\r
167\r
01413f0c 168 /**\r
169 @return get package identification\r
170 **/\r
a29c47e0 171 public PackageIdentification getPackage() {\r
172 return packageId;\r
173 }\r
174\r
01413f0c 175 /**\r
176 @return get module type\r
177 **/\r
a29c47e0 178 public String getModuleType() {\r
a29c47e0 179 return moduleType;\r
180 }\r
181\r
01413f0c 182 /**\r
183 @param moduleType set module type\r
184 **/\r
a29c47e0 185 public void setModuleType(String moduleType) {\r
186 this.moduleType = moduleType;\r
187 }\r
188 \r
189 public String getName() {\r
a29c47e0 190 return name;\r
191 }\r
192}\r