3 The file is used to save basic information of module
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
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.
16 package org
.tianocore
.frameworkwizard
.module
.Identifications
;
19 import java
.io
.IOException
;
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
.Tools
;
28 import org
.tianocore
.frameworkwizard
.common
.Identifications
.Identification
;
29 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
31 public class ModuleIdentification
extends Identification
{
33 private PackageIdentification packageId
;
35 private String moduleType
;
37 private boolean isLibrary
;
39 public ModuleIdentification(String name
, String guid
, String version
, String path
) {
40 super(name
, guid
, version
, path
);
44 public ModuleIdentification(String name
, String guid
, String version
, String path
, boolean library
) {
45 super(name
, guid
, version
, path
);
46 this.isLibrary
= library
;
49 public ModuleIdentification(Identification id
) {
50 super(id
.getName(), id
.getGuid(), id
.getVersion(), id
.getPath());
53 public ModuleIdentification(Identification id
, boolean library
) {
54 super(id
.getName(), id
.getGuid(), id
.getVersion(), id
.getPath());
55 this.isLibrary
= library
;
58 public ModuleIdentification(String name
, String guid
, String version
, String path
, PackageIdentification packageId
){
59 super(name
, guid
, version
, path
);
60 this.packageId
= packageId
;
64 public ModuleIdentification(String name
, String guid
, String version
, String path
, PackageIdentification packageId
, String type
){
65 super(name
, guid
, version
, path
);
66 this.packageId
= packageId
;
67 this.moduleType
= type
;
70 public ModuleIdentification(Identification id
, PackageIdentification packageId
) {
71 super(id
.getName(), id
.getGuid(), id
.getVersion(), id
.getPath());
72 this.packageId
= packageId
;
76 public ModuleIdentification(Identification id
, PackageIdentification packageId
, boolean library
) {
77 super(id
.getName(), id
.getGuid(), id
.getVersion(), id
.getPath());
78 this.packageId
= packageId
;
79 this.isLibrary
= library
;
82 public ModuleIdentification(Identification id
, PackageIdentification packageId
, String type
) {
83 super(id
.getName(), id
.getGuid(), id
.getVersion(), id
.getPath());
84 this.packageId
= packageId
;
85 this.moduleType
= type
;
88 public String
toString(){
89 return "Module " + this.getName() + "[" + this.getGuid() + "] in package " + packageId
;
92 public PackageIdentification
getPackageId() {
96 public void setPackageId(PackageIdentification packageId
) {
97 this.packageId
= packageId
;
100 public String
getModuleType() {
104 public void setModuleType(String moduleType
) {
105 this.moduleType
= moduleType
;
108 private void setModuleType() {
109 ModuleSurfaceArea msa
= null;
111 msa
= OpenFile
.openMsaFile(this.getPath());
112 } catch (IOException e
) {
113 // TODO Auto-generated catch block
115 } catch (XmlException e
) {
116 // TODO Auto-generated catch block
118 } catch (Exception e
) {
119 // TODO Auto-generated catch block
122 setModuleType(DataType
.MODULE_TYPE_MODULE
);
125 LibraryClassDefinitions lib
= msa
.getLibraryClassDefinitions();
127 for (int index
= 0; index
< lib
.getLibraryClassList().size(); index
++) {
128 if (lib
.getLibraryClassList().get(index
).getUsage().equals(LibraryUsage
.ALWAYS_PRODUCED
)) {
129 setModuleType(DataType
.MODULE_TYPE_LIBRARY
);
138 public boolean equals(String moduleGuid
, String moduleVersion
, String packageGuid
, String packageVersion
) {
140 if (this.getGuid().equals(moduleGuid
) && this.getPackageId().getGuid().equals(packageGuid
)) {
145 if (moduleVersion
!= null) {
146 if (!Tools
.isEmpty(moduleVersion
)) {
147 if (!moduleVersion
.equals(this.getVersion())) {
152 if (packageVersion
!= null) {
153 if (!Tools
.isEmpty(packageVersion
)) {
154 if (!packageVersion
.equals(this.getPackageId().getVersion())) {
163 public boolean isLibrary() {
167 public void setLibrary(boolean isLibrary
) {
168 this.isLibrary
= isLibrary
;