1. Update to just keep several line JAVA related msg; 2. Remove file PropertyManager...
[mirror_edk2.git] / Tools / Java / 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 (version == null || version.trim().equalsIgnoreCase("")) {
88 return "package [" + name + "]";
89 }
90 else {
91 return "package [" + name + " " + version + "]";
92 }
93 }
94
95 /**
96 get package directory
97 @return Package Directory
98 **/
99 public String getPackageDir(){
100 return spdFile.getParent();
101 }
102
103 /**
104 get package relative directory.
105 @return package relative directory
106 **/
107 public String getPackageRelativeDir(){
108 String relativeDir =spdFile.getParent().substring(GlobalData.getWorkspacePath().length());
109 if(relativeDir.startsWith("\\") || relativeDir.startsWith("/")) {
110 relativeDir = relativeDir.substring(1);
111 }
112 return relativeDir;
113 }
114
115 public String getName() {
116 return name;
117 }
118 }