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