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