]>
Commit | Line | Data |
---|---|---|
a13899c5 | 1 | /** @file\r |
2 | \r | |
3 | The file is used to save basic information of module\r | |
4 | \r | |
5 | Copyright (c) 2006, Intel Corporation\r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
79cb6fdb | 16 | package org.tianocore.frameworkwizard.module.Identifications;\r |
a13899c5 | 17 | \r |
18 | \r | |
92e29378 | 19 | import java.io.IOException;\r |
20 | \r | |
21 | import org.apache.xmlbeans.XmlException;\r | |
22 | import org.tianocore.LibraryUsage;\r | |
23 | import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;\r | |
24 | import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r | |
25 | import org.tianocore.frameworkwizard.common.DataType;\r | |
f9d0ab92 | 26 | import org.tianocore.frameworkwizard.common.OpenFile;\r |
419558bb | 27 | import org.tianocore.frameworkwizard.common.Tools;\r |
79cb6fdb | 28 | import org.tianocore.frameworkwizard.common.Identifications.Identification;\r |
a13899c5 | 29 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r |
30 | \r | |
31 | public class ModuleIdentification extends Identification {\r | |
32 | \r | |
33 | private PackageIdentification packageId;\r | |
34 | \r | |
92e29378 | 35 | private String moduleType;\r |
36 | \r | |
37 | private boolean isLibrary;\r | |
38 | \r | |
a13899c5 | 39 | public ModuleIdentification(String name, String guid, String version, String path) {\r |
40 | super(name, guid, version, path);\r | |
92e29378 | 41 | setModuleType();\r |
a13899c5 | 42 | }\r |
43 | \r | |
92e29378 | 44 | public ModuleIdentification(String name, String guid, String version, String path, boolean library) {\r |
45 | super(name, guid, version, path);\r | |
46 | this.isLibrary = library;\r | |
47 | }\r | |
48 | \r | |
739c6b04 | 49 | public ModuleIdentification(Identification id) {\r |
50 | super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r | |
51 | }\r | |
52 | \r | |
92e29378 | 53 | public ModuleIdentification(Identification id, boolean library) {\r |
a13899c5 | 54 | super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r |
92e29378 | 55 | this.isLibrary = library;\r |
a13899c5 | 56 | }\r |
57 | \r | |
58 | public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId){\r | |
59 | super(name, guid, version, path);\r | |
60 | this.packageId = packageId;\r | |
92e29378 | 61 | setModuleType();\r |
62 | }\r | |
63 | \r | |
64 | public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId, String type){\r | |
65 | super(name, guid, version, path);\r | |
66 | this.packageId = packageId;\r | |
67 | this.moduleType = type;\r | |
a13899c5 | 68 | }\r |
69 | \r | |
70 | public ModuleIdentification(Identification id, PackageIdentification packageId) {\r | |
71 | super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r | |
72 | this.packageId = packageId;\r | |
92e29378 | 73 | setModuleType();\r |
a13899c5 | 74 | }\r |
75 | \r | |
92e29378 | 76 | public ModuleIdentification(Identification id, PackageIdentification packageId, boolean library) {\r |
77 | super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r | |
78 | this.packageId = packageId;\r | |
79 | this.isLibrary = library;\r | |
80 | }\r | |
81 | \r | |
82 | public ModuleIdentification(Identification id, PackageIdentification packageId, String type) {\r | |
83 | super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r | |
84 | this.packageId = packageId;\r | |
85 | this.moduleType = type;\r | |
86 | }\r | |
a13899c5 | 87 | \r |
88 | public String toString(){\r | |
89 | return "Module " + this.getName() + "[" + this.getGuid() + "] in package " + packageId;\r | |
90 | }\r | |
91 | \r | |
92 | public PackageIdentification getPackageId() {\r | |
93 | return packageId;\r | |
94 | }\r | |
95 | \r | |
96 | public void setPackageId(PackageIdentification packageId) {\r | |
97 | this.packageId = packageId;\r | |
98 | }\r | |
92e29378 | 99 | \r |
100 | public String getModuleType() {\r | |
101 | return moduleType;\r | |
102 | }\r | |
103 | \r | |
104 | public void setModuleType(String moduleType) {\r | |
105 | this.moduleType = moduleType;\r | |
106 | }\r | |
107 | \r | |
108 | private void setModuleType() {\r | |
109 | ModuleSurfaceArea msa = null;\r | |
110 | try {\r | |
111 | msa = OpenFile.openMsaFile(this.getPath());\r | |
112 | } catch (IOException e) {\r | |
113 | // TODO Auto-generated catch block\r | |
114 | \r | |
115 | } catch (XmlException e) {\r | |
116 | // TODO Auto-generated catch block\r | |
117 | \r | |
118 | } catch (Exception e) {\r | |
119 | // TODO Auto-generated catch block\r | |
120 | \r | |
121 | }\r | |
122 | setModuleType(DataType.MODULE_TYPE_MODULE);\r | |
123 | setLibrary(false);\r | |
124 | if (msa != null) {\r | |
125 | LibraryClassDefinitions lib = msa.getLibraryClassDefinitions();\r | |
126 | if (lib != null) {\r | |
127 | for (int index = 0; index < lib.getLibraryClassList().size(); index++) {\r | |
128 | if (lib.getLibraryClassList().get(index).getUsage().equals(LibraryUsage.ALWAYS_PRODUCED)) {\r | |
129 | setModuleType(DataType.MODULE_TYPE_LIBRARY);\r | |
130 | setLibrary(true);\r | |
131 | break;\r | |
132 | }\r | |
133 | }\r | |
134 | }\r | |
135 | }\r | |
136 | }\r | |
419558bb | 137 | \r |
138 | public boolean equals(String moduleGuid, String moduleVersion, String packageGuid, String packageVersion) {\r | |
139 | boolean b = false;\r | |
140 | if (this.getGuid().equals(moduleGuid) && this.getPackageId().getGuid().equals(packageGuid)) {\r | |
141 | b = true;\r | |
142 | //\r | |
143 | // Check Version\r | |
144 | //\r | |
145 | if (moduleVersion != null) {\r | |
146 | if (!Tools.isEmpty(moduleVersion)) {\r | |
147 | if (!moduleVersion.equals(this.getVersion())) {\r | |
148 | b = false;\r | |
149 | }\r | |
150 | }\r | |
151 | }\r | |
152 | if (packageVersion != null) {\r | |
153 | if (!Tools.isEmpty(packageVersion)) {\r | |
154 | if (!packageVersion.equals(this.getPackageId().getVersion())) {\r | |
155 | b = false;\r | |
156 | }\r | |
157 | }\r | |
158 | }\r | |
159 | }\r | |
160 | return b;\r | |
161 | }\r | |
92e29378 | 162 | \r |
163 | public boolean isLibrary() {\r | |
164 | return isLibrary;\r | |
165 | }\r | |
166 | \r | |
167 | public void setLibrary(boolean isLibrary) {\r | |
168 | this.isLibrary = isLibrary;\r | |
169 | }\r | |
a13899c5 | 170 | }\r |