]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/id/PackageIdentification.java
Remove some unused code and adjust some code format. Modules build with FPD sequence...
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / id / PackageIdentification.java
1 /** @file
2 This file is to define PackageIdentification class.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 **/
13
14 package org.tianocore.build.id;
15 import java.io.File;
16
17 import org.tianocore.build.global.GlobalData;
18
19 /**
20 This class is used to identify a package.
21
22 @since GenBuild 1.0
23 **/
24 public class PackageIdentification extends Identification{
25
26 //
27 // SPD file
28 //
29 private File spdFile;
30
31 /**
32 @param guid Guid
33 @param version Version
34 **/
35 public PackageIdentification(String guid, String version){
36 super(guid, version);
37 }
38
39 /**
40 @param name Name
41 @param guid Guid
42 @param version Version
43 **/
44 public PackageIdentification(String name, String guid, String version){
45 super(name, guid, version);
46 }
47
48 /**
49 @param name Name
50 @param guid Guid
51 @param version Version
52 @param spdFilename SPD file name
53 **/
54 public PackageIdentification(String name, String guid, String version, String spdFilename){
55 super(name, guid, version);
56 this.spdFile = new File(spdFilename);
57 }
58
59 /**
60 @param name Name
61 @param guid Guid
62 @param version Version
63 @param spdFile SPD file
64 **/
65 public PackageIdentification(String name, String guid, String version, File spdFile){
66 super(name, guid, version);
67 this.spdFile = spdFile;
68 }
69
70 /**
71 set SPD file.
72 @param spdFile SPD file
73 **/
74 public void setSpdFile(File spdFile) {
75 this.spdFile = spdFile;
76 }
77
78 /**
79 get SPD file
80 @return SPD file
81 **/
82 public File getSpdFile() {
83 return spdFile;
84 }
85
86 public String toString(){
87 if (name == null) {
88 GlobalData.refreshPackageIdentification(this);
89 }
90 if (version == null || version.trim().equalsIgnoreCase("")) {
91 return "package [" + name + "]";
92 }
93 else {
94 return "package [" + name + " " + version + "]";
95 }
96 }
97
98 /**
99 get package directory
100 @return Package Directory
101 **/
102 public String getPackageDir(){
103 prepareSpdFile();
104 return spdFile.getParent();
105 }
106
107 /**
108 get package relative directory.
109 @return package relative directory
110 **/
111 public String getPackageRelativeDir(){
112 prepareSpdFile();
113 String relativeDir =spdFile.getParent().substring(GlobalData.getWorkspacePath().length());
114 if(relativeDir.startsWith("\\") || relativeDir.startsWith("/")) {
115 relativeDir = relativeDir.substring(1);
116 }
117 return relativeDir;
118 }
119
120 private void prepareSpdFile(){
121 if (spdFile == null) {
122 GlobalData.refreshPackageIdentification(this);
123 }
124 }
125
126 public String getName() {
127 if (name == null) {
128 GlobalData.refreshPackageIdentification(this);
129 }
130 return name;
131 }
132 }