]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/id/PackageIdentification.java
Added copyright&license header.
[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 public class PackageIdentification extends Identification{
20
21 //
22 // It is optional
23 //
24 private File spdFile;
25
26 public PackageIdentification(String guid, String version){
27 super(guid, version);
28 }
29
30 public PackageIdentification(String name, String guid, String version){
31 super(name, guid, version);
32 }
33
34 public PackageIdentification(String name, String guid, String version, String spdFilename){
35 super(name, guid, version);
36 this.spdFile = new File(spdFilename);
37 }
38
39 public PackageIdentification(String name, String guid, String version, File spdFile){
40 super(name, guid, version);
41 this.spdFile = spdFile;
42 }
43
44 public void setSpdFile(File spdFile) {
45 this.spdFile = spdFile;
46 }
47
48 public File getSpdFile() {
49 return spdFile;
50 }
51
52 public String toString(){
53 if (name == null) {
54 GlobalData.refreshPackageIdentification(this);
55 }
56 if (version == null || version.trim().equalsIgnoreCase("")) {
57 return "package [" + name + "]";
58 }
59 else {
60 return "package [" + name + " " + version + "]";
61 }
62 }
63
64 public String getPackageDir(){
65 prepareSpdFile();
66 return spdFile.getParent();
67 }
68
69 public String getPackageRelativeDir(){
70 prepareSpdFile();
71 return spdFile.getParent().substring(GlobalData.getWorkspacePath().length() + 1);
72 }
73
74 private void prepareSpdFile(){
75 if (spdFile == null) {
76 GlobalData.refreshPackageIdentification(this);
77 }
78 }
79
80 public String getName() {
81 if (name == null) {
82 GlobalData.refreshPackageIdentification(this);
83 }
84 return name;
85 }
86 }