]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/id/ModuleIdentification.java
Remove some unused code and adjust some code format. Modules build with FPD sequence...
[mirror_edk2.git] / Tools / 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 import org.tianocore.build.global.GlobalData;
19 /**
20 This class is used to identify a module with Module Guid, Module Version,
21 Package Guid, Package Version.
22
23 @since GenBuild 1.0
24 **/
25 public class ModuleIdentification extends Identification {
26
27 private PackageIdentification packageId;
28
29 private File msaFile;
30
31 private String moduleType;
32
33 private boolean isLibrary = false;
34
35 /**
36 @param guid Guid
37 @param version Version
38 **/
39 public ModuleIdentification(String guid, String version){
40 super(guid, version);
41 }
42
43 /**
44 @param guid Guid
45 @param version Version
46 @param packageId Package Identification
47 **/
48 public ModuleIdentification(String guid, String version, PackageIdentification packageId){
49 super(guid, version);
50 this.packageId = packageId;
51 }
52
53 /**
54 @param name Name
55 @param guid Guid
56 @param version Version
57 **/
58 public ModuleIdentification(String name, String guid, String version){
59 super(name, guid, version);
60 }
61
62 /**
63 @param name Name
64 @param guid Guid
65 @param version Version
66 @param packageId PackageIdentification
67 **/
68 public ModuleIdentification(String name, String guid, String version, PackageIdentification packageId){
69 super(name, guid, version);
70 this.packageId = packageId;
71 }
72
73 /**
74 @return boolean is this module is library
75 **/
76 public boolean isLibrary() {
77 return isLibrary;
78 }
79
80 /**
81 @param isLibrary
82 **/
83 public void setLibrary(boolean isLibrary) {
84 this.isLibrary = isLibrary;
85 }
86
87 /**
88 @return MSA File
89 **/
90 public File getMsaFile() {
91 prepareMsaFile();
92 return msaFile;
93 }
94
95 /**
96 @return Module relative path to package
97 **/
98 public String getModuleRelativePath() {
99 prepareMsaFile();
100 if (msaFile.getParent().length() == packageId.getPackageDir().length()) {
101 return ".";
102 }
103 return msaFile.getParent().substring(packageId.getPackageDir().length() + 1);
104 }
105
106 private void prepareMsaFile(){
107 if (msaFile == null) {
108 GlobalData.refreshModuleIdentification(this);
109 }
110 }
111
112 /**
113 @param msaFile Set Msa File
114 **/
115 public void setMsaFile(File msaFile) {
116 this.msaFile = msaFile;
117 }
118
119 public boolean equals(Object obj) {
120 if (obj instanceof ModuleIdentification) {
121 ModuleIdentification id = (ModuleIdentification)obj;
122 if (guid.equalsIgnoreCase(id.getGuid()) && packageId.equals(id.getPackage())) {
123 if (version == null || id.version == null) {
124 return true;
125 }
126 else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){
127 return true;
128 }
129 else if (version.equalsIgnoreCase(id.version)) {
130 return true;
131 }
132 }
133 return false;
134 }
135 else {
136 return super.equals(obj);
137 }
138 }
139
140 public String toString(){
141 if (name == null) {
142 GlobalData.refreshModuleIdentification(this);
143 }
144 if (version == null || version.trim().equalsIgnoreCase("")) {
145 return "Module [" + name + "] in " + packageId;
146 }
147 else {
148 return "Module [" + name + " " + version + "] in " + packageId;
149 }
150 }
151
152 /**
153 @param packageId set package identification
154 **/
155 public void setPackage(PackageIdentification packageId) {
156 this.packageId = packageId;
157 }
158
159 /**
160 @return get package identification
161 **/
162 public PackageIdentification getPackage() {
163 return packageId;
164 }
165
166 /**
167 @return get module type
168 **/
169 public String getModuleType() {
170 if (moduleType == null) {
171 GlobalData.refreshModuleIdentification(this);
172 }
173 return moduleType;
174 }
175
176 /**
177 @param moduleType set module type
178 **/
179 public void setModuleType(String moduleType) {
180 this.moduleType = moduleType;
181 }
182
183 public String getName() {
184 if (name == null) {
185 GlobalData.refreshModuleIdentification(this);
186 }
187 return name;
188 }
189 }