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