- Move global declarations from AutoGen.c to AutoGen.h
[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
2c9b03f2 34 private boolean isBinary = false;\r
35\r
bc33b23d 36 private String constructor = "";\r
37\r
38 private String destructor = "";\r
39\r
01413f0c 40 /**\r
41 @param guid Guid\r
42 @param version Version\r
43 **/\r
a29c47e0 44 public ModuleIdentification(String guid, String version){\r
45 super(guid, version);\r
46 }\r
47 \r
01413f0c 48 /**\r
49 @param guid Guid\r
50 @param version Version\r
51 @param packageId Package Identification\r
52 **/\r
a29c47e0 53 public ModuleIdentification(String guid, String version, PackageIdentification packageId){\r
54 super(guid, version);\r
55 this.packageId = packageId;\r
56 }\r
57 \r
01413f0c 58 /**\r
59 @param name Name\r
60 @param guid Guid\r
61 @param version Version\r
62 **/\r
a29c47e0 63 public ModuleIdentification(String name, String guid, String version){\r
64 super(name, guid, version);\r
65 }\r
66 \r
01413f0c 67 /**\r
68 @param name Name\r
69 @param guid Guid\r
70 @param version Version\r
71 @param packageId PackageIdentification\r
72 **/\r
a29c47e0 73 public ModuleIdentification(String name, String guid, String version, PackageIdentification packageId){\r
74 super(name, guid, version);\r
75 this.packageId = packageId;\r
76 }\r
77 \r
01413f0c 78 /**\r
79 @return boolean is this module is library\r
80 **/\r
a29c47e0 81 public boolean isLibrary() {\r
82 return isLibrary;\r
83 }\r
84\r
01413f0c 85 /**\r
86 @param isLibrary \r
87 **/\r
a29c47e0 88 public void setLibrary(boolean isLibrary) {\r
89 this.isLibrary = isLibrary;\r
90 }\r
91\r
2c9b03f2 92 /**\r
93 @return boolean is this module is binary\r
94 **/\r
95 public boolean isBinary() {\r
96 return isBinary;\r
97 }\r
98\r
99 /**\r
100 @param isBinary\r
101 **/\r
102 public void setBinary(boolean isBinary) {\r
103 this.isBinary = isBinary;\r
104 }\r
105\r
01413f0c 106 /**\r
107 @return MSA File\r
108 **/\r
a29c47e0 109 public File getMsaFile() {\r
a29c47e0 110 return msaFile;\r
111 }\r
112 \r
01413f0c 113 /**\r
114 @return Module relative path to package\r
115 **/\r
a29c47e0 116 public String getModuleRelativePath() {\r
a29c47e0 117 if (msaFile.getParent().length() == packageId.getPackageDir().length()) {\r
118 return ".";\r
119 }\r
120 return msaFile.getParent().substring(packageId.getPackageDir().length() + 1);\r
121 }\r
122\r
01413f0c 123 /**\r
124 @param msaFile Set Msa File\r
125 **/\r
a29c47e0 126 public void setMsaFile(File msaFile) {\r
127 this.msaFile = msaFile;\r
128 }\r
129 \r
130 public boolean equals(Object obj) {\r
131 if (obj instanceof ModuleIdentification) {\r
132 ModuleIdentification id = (ModuleIdentification)obj;\r
133 if (guid.equalsIgnoreCase(id.getGuid()) && packageId.equals(id.getPackage())) {\r
134 if (version == null || id.version == null) {\r
135 return true;\r
136 }\r
137 else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){\r
138 return true;\r
139 }\r
140 else if (version.equalsIgnoreCase(id.version)) {\r
141 return true;\r
142 }\r
143 }\r
144 return false;\r
145 }\r
146 else {\r
147 return super.equals(obj);\r
148 }\r
149 }\r
150 \r
892b0e7a 151 public String toString() {\r
89da7eba 152 String nameString;\r
153 String versionString;\r
154 String packageString;\r
155\r
156 if (name != null && name != "") {\r
157 nameString = name;\r
158 } else {\r
159 if (guid != null && guid != "") {\r
160 nameString = guid;\r
161 } else {\r
162 nameString = "UNKNOWN";\r
163 }\r
a29c47e0 164 }\r
89da7eba 165\r
166 if (version != null) {\r
167 versionString = version;\r
168 } else {\r
169 versionString = ""; \r
a29c47e0 170 }\r
89da7eba 171\r
172 if (packageId != null) {\r
173 packageString = packageId.toString();\r
174 } else {\r
175 packageString = "Package [UNKNOWN]";\r
176 }\r
177\r
178 return "Module [" + nameString + versionString + "] in " + packageString; \r
a29c47e0 179 }\r
180\r
01413f0c 181 /**\r
182 @param packageId set package identification\r
183 **/\r
a29c47e0 184 public void setPackage(PackageIdentification packageId) {\r
185 this.packageId = packageId;\r
186 }\r
187\r
01413f0c 188 /**\r
189 @return get package identification\r
190 **/\r
a29c47e0 191 public PackageIdentification getPackage() {\r
192 return packageId;\r
193 }\r
194\r
01413f0c 195 /**\r
196 @return get module type\r
197 **/\r
a29c47e0 198 public String getModuleType() {\r
a29c47e0 199 return moduleType;\r
200 }\r
201\r
01413f0c 202 /**\r
203 @param moduleType set module type\r
204 **/\r
a29c47e0 205 public void setModuleType(String moduleType) {\r
206 this.moduleType = moduleType;\r
207 }\r
23849470 208\r
209 /**\r
210 @return String The module name\r
211 **/\r
a29c47e0 212 public String getName() {\r
a29c47e0 213 return name;\r
214 }\r
bc33b23d 215\r
23849470 216 /**\r
217 @return boolean\r
218 **/\r
bc33b23d 219 public boolean hasConstructor() {\r
220 return constructor != "";\r
221 }\r
222\r
23849470 223 /**\r
224 @return boolean\r
225 */\r
bc33b23d 226 public boolean hasDestructor() {\r
227 return destructor != "";\r
228 }\r
229\r
23849470 230 /**\r
231 Set the constructor function name if this module is a library\r
232\r
233 @param name\r
234 */\r
bc33b23d 235 public void setConstructor(String name) {\r
236 if (name != null) {\r
237 constructor = name;\r
238 }\r
239 }\r
240\r
23849470 241 /**\r
242 Set the destructor function name if this module is a library\r
243\r
244 @param name\r
245 */\r
bc33b23d 246 public void setDestructor(String name) {\r
247 if (name != null) {\r
248 destructor = name;\r
249 }\r
250 }\r
a29c47e0 251}\r