]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/ModuleIdentification.java
1. Merge ModuleDefinitions to MsaHeader
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / module / Identifications / ModuleIdentification.java
CommitLineData
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 16package org.tianocore.frameworkwizard.module.Identifications;\r
a13899c5 17\r
18\r
92e29378 19import java.io.IOException;\r
20\r
21import org.apache.xmlbeans.XmlException;\r
22import org.tianocore.LibraryUsage;\r
23import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;\r
24import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
25import org.tianocore.frameworkwizard.common.DataType;\r
f9d0ab92 26import org.tianocore.frameworkwizard.common.OpenFile;\r
79cb6fdb 27import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
a13899c5 28import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
29\r
30public class ModuleIdentification extends Identification {\r
31 \r
32 private PackageIdentification packageId;\r
33 \r
92e29378 34 private String moduleType;\r
35 \r
36 private boolean isLibrary;\r
37 \r
a13899c5 38 public ModuleIdentification(String name, String guid, String version, String path) {\r
39 super(name, guid, version, path);\r
92e29378 40 setModuleType();\r
a13899c5 41 }\r
42 \r
92e29378 43 public ModuleIdentification(String name, String guid, String version, String path, boolean library) {\r
44 super(name, guid, version, path);\r
45 this.isLibrary = library;\r
46 }\r
47 \r
739c6b04 48 public ModuleIdentification(Identification id) {\r
49 super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
50 }\r
51 \r
92e29378 52 public ModuleIdentification(Identification id, boolean library) {\r
a13899c5 53 super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
92e29378 54 this.isLibrary = library;\r
a13899c5 55 }\r
56 \r
57 public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId){\r
58 super(name, guid, version, path);\r
59 this.packageId = packageId;\r
92e29378 60 setModuleType();\r
61 }\r
62 \r
63 public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId, String type){\r
64 super(name, guid, version, path);\r
65 this.packageId = packageId;\r
66 this.moduleType = type;\r
a13899c5 67 }\r
68 \r
69 public ModuleIdentification(Identification id, PackageIdentification packageId) {\r
70 super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
71 this.packageId = packageId;\r
92e29378 72 setModuleType();\r
a13899c5 73 }\r
74 \r
92e29378 75 public ModuleIdentification(Identification id, PackageIdentification packageId, boolean library) {\r
76 super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
77 this.packageId = packageId;\r
78 this.isLibrary = library;\r
79 }\r
80 \r
81 public ModuleIdentification(Identification id, PackageIdentification packageId, String type) {\r
82 super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
83 this.packageId = packageId;\r
84 this.moduleType = type;\r
85 }\r
a13899c5 86 \r
87 public String toString(){\r
88 return "Module " + this.getName() + "[" + this.getGuid() + "] in package " + packageId;\r
89 }\r
90\r
91 public PackageIdentification getPackageId() {\r
92 return packageId;\r
93 }\r
94\r
95 public void setPackageId(PackageIdentification packageId) {\r
96 this.packageId = packageId;\r
97 }\r
92e29378 98\r
99 public String getModuleType() {\r
100 return moduleType;\r
101 }\r
102\r
103 public void setModuleType(String moduleType) {\r
104 this.moduleType = moduleType;\r
105 }\r
106 \r
107 private void setModuleType() {\r
108 ModuleSurfaceArea msa = null;\r
109 try {\r
110 msa = OpenFile.openMsaFile(this.getPath());\r
111 } catch (IOException e) {\r
112 // TODO Auto-generated catch block\r
113 \r
114 } catch (XmlException e) {\r
115 // TODO Auto-generated catch block\r
116 \r
117 } catch (Exception e) {\r
118 // TODO Auto-generated catch block\r
119 \r
120 }\r
121 setModuleType(DataType.MODULE_TYPE_MODULE);\r
122 setLibrary(false);\r
123 if (msa != null) {\r
124 LibraryClassDefinitions lib = msa.getLibraryClassDefinitions();\r
125 if (lib != null) {\r
126 for (int index = 0; index < lib.getLibraryClassList().size(); index++) {\r
127 if (lib.getLibraryClassList().get(index).getUsage().equals(LibraryUsage.ALWAYS_PRODUCED)) {\r
128 setModuleType(DataType.MODULE_TYPE_LIBRARY);\r
129 setLibrary(true);\r
130 break;\r
131 }\r
132 }\r
133 }\r
134 }\r
135 }\r
136\r
137 public boolean isLibrary() {\r
138 return isLibrary;\r
139 }\r
140\r
141 public void setLibrary(boolean isLibrary) {\r
142 this.isLibrary = isLibrary;\r
143 }\r
a13899c5 144}\r