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