+++ /dev/null
-/** @file\r
- \r
- The file is used to save basic information of module\r
- \r
- Copyright (c) 2006, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
- \r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
- \r
- **/\r
-\r
-package org.tianocore.frameworkwizard.module.Identifications;\r
-\r
-import java.io.IOException;\r
-\r
-import org.apache.xmlbeans.XmlException;\r
-import org.tianocore.LibraryUsage;\r
-import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;\r
-import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
-import org.tianocore.frameworkwizard.common.DataType;\r
-import org.tianocore.frameworkwizard.common.OpenFile;\r
-import org.tianocore.frameworkwizard.common.Tools;\r
-import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
-import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
-\r
-public class ModuleIdentification extends Identification {\r
-\r
- private PackageIdentification packageId;\r
-\r
- private String moduleType;\r
-\r
- private boolean isLibrary;\r
-\r
- public ModuleIdentification(String name, String guid, String version, String path) {\r
- super(name, guid, version, path);\r
- setModuleType();\r
- }\r
-\r
- public ModuleIdentification(String name, String guid, String version, String path, boolean library) {\r
- super(name, guid, version, path);\r
- this.isLibrary = library;\r
- }\r
-\r
- public ModuleIdentification(Identification id) {\r
- super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
- }\r
-\r
- public ModuleIdentification(Identification id, boolean library) {\r
- super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
- this.isLibrary = library;\r
- }\r
-\r
- public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId) {\r
- super(name, guid, version, path);\r
- this.packageId = packageId;\r
- setModuleType();\r
- }\r
-\r
- public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId,\r
- String type) {\r
- super(name, guid, version, path);\r
- this.packageId = packageId;\r
- this.moduleType = type;\r
- }\r
-\r
- public ModuleIdentification(Identification id, PackageIdentification packageId) {\r
- super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
- this.packageId = packageId;\r
- setModuleType();\r
- }\r
-\r
- public ModuleIdentification(Identification id, PackageIdentification packageId, boolean library) {\r
- super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
- this.packageId = packageId;\r
- this.isLibrary = library;\r
- }\r
-\r
- public ModuleIdentification(Identification id, PackageIdentification packageId, String type) {\r
- super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
- this.packageId = packageId;\r
- this.moduleType = type;\r
- }\r
-\r
- public String toString() {\r
- return "Module " + this.getName() + "[" + this.getGuid() + "] in package " + packageId;\r
- }\r
-\r
- public PackageIdentification getPackageId() {\r
- return packageId;\r
- }\r
-\r
- public void setPackageId(PackageIdentification packageId) {\r
- this.packageId = packageId;\r
- }\r
-\r
- public String getModuleType() {\r
- return moduleType;\r
- }\r
-\r
- public void setModuleType(String moduleType) {\r
- this.moduleType = moduleType;\r
- }\r
-\r
- private void setModuleType() {\r
- ModuleSurfaceArea msa = null;\r
- try {\r
- msa = OpenFile.openMsaFile(this.getPath());\r
- } catch (IOException e) {\r
- // TODO Auto-generated catch block\r
-\r
- } catch (XmlException e) {\r
- // TODO Auto-generated catch block\r
-\r
- } catch (Exception e) {\r
- // TODO Auto-generated catch block\r
-\r
- }\r
- setModuleType(DataType.MODULE_TYPE_MODULE);\r
- setLibrary(false);\r
- if (msa != null) {\r
- LibraryClassDefinitions lib = msa.getLibraryClassDefinitions();\r
- if (lib != null) {\r
- for (int index = 0; index < lib.getLibraryClassList().size(); index++) {\r
- if (lib.getLibraryClassList().get(index).getUsage().equals(LibraryUsage.ALWAYS_PRODUCED)) {\r
- setModuleType(DataType.MODULE_TYPE_LIBRARY);\r
- setLibrary(true);\r
- break;\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- public boolean equals(String moduleGuid, String moduleVersion, String packageGuid, String packageVersion) {\r
- boolean b = false;\r
- if (this.getGuid().equals(moduleGuid) && this.getPackageId().getGuid().equals(packageGuid)) {\r
- b = true;\r
- //\r
- // Check Version\r
- //\r
- if (moduleVersion != null) {\r
- if (!Tools.isEmpty(moduleVersion)) {\r
- if (!moduleVersion.equals(this.getVersion())) {\r
- b = false;\r
- }\r
- }\r
- }\r
- if (packageVersion != null) {\r
- if (!Tools.isEmpty(packageVersion)) {\r
- if (!packageVersion.equals(this.getPackageId().getVersion())) {\r
- b = false;\r
- }\r
- }\r
- }\r
- }\r
- return b;\r
- }\r
-\r
- public boolean isLibrary() {\r
- return isLibrary;\r
- }\r
-\r
- public void setLibrary(boolean isLibrary) {\r
- this.isLibrary = isLibrary;\r
- }\r
-}\r