]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/id/ModuleIdentification.java
Update GlobalData, SPD, SurfaceAreaQuery to using EdkException.
[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 /**
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 if (version == null || version.trim().equalsIgnoreCase("")) {
133 return "Module [" + name + "] in " + packageId;
134 }
135 else {
136 return "Module [" + name + " " + version + "] in " + packageId;
137 }
138 }
139
140 /**
141 @param packageId set package identification
142 **/
143 public void setPackage(PackageIdentification packageId) {
144 this.packageId = packageId;
145 }
146
147 /**
148 @return get package identification
149 **/
150 public PackageIdentification getPackage() {
151 return packageId;
152 }
153
154 /**
155 @return get module type
156 **/
157 public String getModuleType() {
158 return moduleType;
159 }
160
161 /**
162 @param moduleType set module type
163 **/
164 public void setModuleType(String moduleType) {
165 this.moduleType = moduleType;
166 }
167
168 public String getName() {
169 return name;
170 }
171 }