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