]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/id/ModuleIdentification.java
Added copyright&license header.
[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 public class ModuleIdentification extends Identification {
21
22 private PackageIdentification packageId;
23
24 private File msaFile;
25
26 private String moduleType;
27
28 private boolean isLibrary = false;
29
30 public ModuleIdentification(String guid, String version){
31 super(guid, version);
32 }
33
34 public ModuleIdentification(String guid, String version, PackageIdentification packageId){
35 super(guid, version);
36 this.packageId = packageId;
37 }
38
39 public ModuleIdentification(String name, String guid, String version){
40 super(name, guid, version);
41 }
42
43 public ModuleIdentification(String name, String guid, String version, PackageIdentification packageId){
44 super(name, guid, version);
45 this.packageId = packageId;
46 }
47
48 public boolean isLibrary() {
49 return isLibrary;
50 }
51
52 public void setLibrary(boolean isLibrary) {
53 this.isLibrary = isLibrary;
54 }
55
56 public File getMsaFile() {
57 prepareMsaFile();
58 return msaFile;
59 }
60
61 public String getModuleRelativePath() {
62 prepareMsaFile();
63 if (msaFile.getParent().length() == packageId.getPackageDir().length()) {
64 return ".";
65 }
66 return msaFile.getParent().substring(packageId.getPackageDir().length() + 1);
67 }
68
69 private void prepareMsaFile(){
70 if (msaFile == null) {
71 GlobalData.refreshModuleIdentification(this);
72 }
73 }
74
75 public void setMsaFile(File msaFile) {
76 this.msaFile = msaFile;
77 }
78
79 public boolean equals(Object obj) {
80 if (obj instanceof ModuleIdentification) {
81 ModuleIdentification id = (ModuleIdentification)obj;
82 if (guid.equalsIgnoreCase(id.getGuid()) && packageId.equals(id.getPackage())) {
83 if (version == null || id.version == null) {
84 return true;
85 }
86 else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){
87 return true;
88 }
89 else if (version.equalsIgnoreCase(id.version)) {
90 return true;
91 }
92 }
93 return false;
94 }
95 else {
96 return super.equals(obj);
97 }
98 }
99
100 public String toString(){
101 if (name == null) {
102 GlobalData.refreshModuleIdentification(this);
103 }
104 if (version == null || version.trim().equalsIgnoreCase("")) {
105 return "Module [" + name + "] in " + packageId;
106 }
107 else {
108 return "Module [" + name + " " + version + "] in " + packageId;
109 }
110 }
111
112 public void setPackage(PackageIdentification packageId) {
113 this.packageId = packageId;
114 }
115
116 public PackageIdentification getPackage() {
117 return packageId;
118 }
119
120 public String getModuleType() {
121 if (moduleType == null) {
122 GlobalData.refreshModuleIdentification(this);
123 }
124 return moduleType;
125 }
126
127 public void setModuleType(String moduleType) {
128 this.moduleType = moduleType;
129 }
130
131 public String getName() {
132 if (name == null) {
133 GlobalData.refreshModuleIdentification(this);
134 }
135 return name;
136 }
137 }