Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / id / PlatformIdentification.java
1 /** @file
2 This file is to define PlatformIdentification 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 platform.
21
22 @since GenBuild 1.0
23 **/
24 public class PlatformIdentification extends Identification{
25
26 ///
27 /// FPD file
28 ///
29 private File fpdFile;
30
31 /**
32 @param guid Guid
33 @param version Version
34 **/
35 public PlatformIdentification(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 PlatformIdentification(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 fpdFilename Fpd File Name
53 **/
54 public PlatformIdentification(String name, String guid, String version, String fpdFilename){
55 super(name, guid, version);
56 this.fpdFile = new File(fpdFilename);
57 }
58
59 /**
60 @param name Name
61 @param guid Guid
62 @param version Version
63 @param fpdFile Fpd File
64 **/
65 public PlatformIdentification(String name, String guid, String version, File fpdFile){
66 super(name, guid, version);
67 this.fpdFile = fpdFile;
68 }
69
70 public String toString(){
71 return "Platform " + name + "["+guid+"]";
72 }
73
74 /**
75 Set FPD file.
76 @param fpdFile FPD File
77 **/
78 public void setFpdFile(File fpdFile) {
79 this.fpdFile = fpdFile;
80 }
81
82 /**
83 Get FPD file.
84 @return Fpd File
85 **/
86 public File getFpdFile() {
87 return fpdFile;
88 }
89
90 /**
91 Get FPD relative file to workspace.
92 @return Fpd Relative file.
93 **/
94 public String getRelativeFpdFile (){
95 String relativeDir = fpdFile.getPath().substring(GlobalData.getWorkspacePath().length());
96 if(relativeDir.startsWith("\\") || relativeDir.startsWith("/")) {
97 relativeDir = relativeDir.substring(1);
98 }
99 return relativeDir;
100 }
101
102 /**
103 Get Platform relative directory to workspace.
104 @return Platform relative directory
105 **/
106 public String getPlatformRelativeDir(){
107 String relativeDir = fpdFile.getParent().substring(GlobalData.getWorkspacePath().length());
108 if(relativeDir.startsWith("\\") || relativeDir.startsWith("/")) {
109 relativeDir = relativeDir.substring(1);
110 }
111 return relativeDir;
112 }
113 }