]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/LibraryClassDescriptor.java
remove unnecessary check for NULL pointer.
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / global / LibraryClassDescriptor.java
1 /** @file
2 This file is for surface area information retrieval.
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.frameworkwizard.platform.ui.global;
15
16 import java.util.Vector;
17
18 public class LibraryClassDescriptor {
19 public String className = "";
20 public String supArchs = "";
21 public String supModTypes = "";
22
23 public LibraryClassDescriptor (String s1, String s2, String s3) {
24 className = s1;
25 if (s2 != null) {
26 supArchs = s2;
27 }
28 if (s3 != null) {
29 supModTypes = s3;
30 }
31
32 }
33
34 public boolean equals(Object obj) {
35 if (obj instanceof LibraryClassDescriptor) {
36 LibraryClassDescriptor id = (LibraryClassDescriptor)obj;
37 if (className.equals(id.className) && sameArchs (supArchs, id.supArchs) && sameModTypes(supModTypes, id.supModTypes)) {
38 return true;
39 }
40 return false;
41 }
42 else {
43 return super.equals(obj);
44 }
45 }
46
47 public int hashCode(){
48 return (className + supArchs + supModTypes).toLowerCase().hashCode();
49 }
50
51 public String toString() {
52 return "Library Class "+ className + " [SupArchs: " + supArchs + " SupModTypes: " + supModTypes + "]";
53 }
54
55 public boolean isSubSetByArchs (LibraryClassDescriptor lcd) {
56 if (className.equals(lcd.className)) {
57 Vector<String> vArchs1 = getVectorFromString(supArchs);
58 Vector<String> vArchs2 = getVectorFromString(lcd.supArchs);
59
60 if (isSubSet(vArchs1, vArchs2)) {
61 return true;
62 }
63 }
64 return false;
65 }
66
67 public boolean isSubSetByModTypes (LibraryClassDescriptor lcd) {
68 if (className.equals(lcd.className)) {
69 Vector<String> vModTypes1 = getVectorFromString(supModTypes);
70 Vector<String> vModTypes2 = getVectorFromString(lcd.supModTypes);
71
72 if (isSubSet(vModTypes1, vModTypes2)) {
73 return true;
74 }
75 }
76 return false;
77 }
78
79 public boolean hasInterSectionWith (LibraryClassDescriptor lcd) {
80 if (className.equals(lcd.className)) {
81 Vector<String> vArchs1 = getVectorFromString(supArchs);
82 Vector<String> vArchs2 = getVectorFromString(lcd.supArchs);
83 if (vArchs1.size() == 0 || (vArchs1.size() == 1 && vArchs1.get(0).equalsIgnoreCase(""))) {
84 return true;
85 }
86 if (vArchs2.size() == 0 || (vArchs2.size() == 1 && vArchs2.get(0).equalsIgnoreCase(""))) {
87 return true;
88 }
89 vArchs1.retainAll(vArchs2);
90 if (vArchs1.size() > 0) {
91 return true;
92 }
93 }
94 return false;
95 }
96
97 private boolean isSubSet (Vector<String> v1, Vector<String> v2) {
98 if (v2.size() == 0 || (v2.size() == 1 && v2.get(0).equalsIgnoreCase(""))) {
99 return true;
100 }
101 if (v2.containsAll(v1)) {
102 return true;
103 }
104 return false;
105 }
106
107 public Vector<String> getVectorFromString (String s) {
108 if (s == null || s.equals("null")) {
109 s = "";
110 }
111 String[] sa1 = s.split(" ");
112 Vector<String> v = new Vector<String>();
113 for (int i = 0; i < sa1.length; ++i) {
114 v.add(sa1[i]);
115 }
116 return v;
117 }
118
119 private boolean sameArchs (String archs1, String archs2) {
120 Vector<String> vArchs1 = getVectorFromString(archs1);
121 Vector<String> vArchs2 = getVectorFromString(archs2);
122
123 if (vArchs1.containsAll(vArchs2) && vArchs2.containsAll(vArchs1)) {
124 return true;
125 }
126 return false;
127 }
128
129 private boolean sameModTypes (String modTypes1, String modTypes2) {
130 return sameArchs(modTypes1, modTypes2);
131 }
132 }