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