]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/find/Find.java
c735b5e6b4da4dc85d9039dc7e5ae7d57c885816
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / find / Find.java
1 /** @file
2
3 The file is used to provide Find funtions in workspace
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15 package org.tianocore.frameworkwizard.common.find;
16
17 import java.util.Vector;
18
19 import org.tianocore.LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass;
20 import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;
21 import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
22 import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
23 import org.tianocore.PcdDeclarationsDocument.PcdDeclarations.PcdEntry;
24 import org.tianocore.frameworkwizard.common.DataType;
25 import org.tianocore.frameworkwizard.common.GlobalData;
26 import org.tianocore.frameworkwizard.common.Sort;
27 import org.tianocore.frameworkwizard.common.Tools;
28 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
29 import org.tianocore.frameworkwizard.module.Identifications.Guids.GuidsIdentification;
30 import org.tianocore.frameworkwizard.module.Identifications.Guids.GuidsVector;
31 import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassIdentification;
32 import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassVector;
33 import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdCodedIdentification;
34 import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdCodedVector;
35 import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisIdentification;
36 import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisVector;
37 import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsIdentification;
38 import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsVector;
39 import org.tianocore.frameworkwizard.packaging.PackageIdentification;
40
41 public class Find {
42
43 private final static String SEPERATOR = ".";
44
45 /**
46 Get all ppi entries from workspace
47
48 @return
49
50 **/
51 public static PpisVector getAllPpisVector() {
52 PpisVector pv = new PpisVector();
53 ModuleSurfaceArea msa = null;
54 ModuleIdentification mid = null;
55 PpisIdentification pid = null;
56
57 //
58 // Go through each module one by one
59 //
60 if (GlobalData.openingModuleList.size() > 0) {
61 for (int indexOfModule = 0; indexOfModule < GlobalData.openingModuleList.size(); indexOfModule++) {
62 msa = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getXmlMsa();
63 mid = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getId();
64
65 if (msa.getPPIs() != null) {
66 if (msa.getPPIs().getPpiList().size() > 0) {
67 for (int index = 0; index < msa.getPPIs().getPpiList().size(); index++) {
68 String arg0 = msa.getPPIs().getPpiList().get(index).getPpiCName();
69 String arg1 = DataType.PPI_TYPE_PPI;
70 String arg2 = null;
71 if (msa.getPPIs().getPpiList().get(index).getUsage() != null) {
72 arg2 = msa.getPPIs().getPpiList().get(index).getUsage().toString();
73 }
74
75 String arg3 = msa.getPPIs().getPpiList().get(index).getFeatureFlag();
76 Vector<String> arg4 = Tools.convertListToVector(msa.getPPIs().getPpiList().get(index)
77 .getSupArchList());
78 String arg5 = msa.getPPIs().getPpiList().get(index).getHelpText();
79
80 pid = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
81 pid.setBelongModule(mid);
82
83 //
84 // Find which package declares it
85 //
86 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {
87 PackageSurfaceArea spd = GlobalData.openingPackageList
88 .getOpeningPackageByIndex(
89 indexOfPackage)
90 .getXmlSpd();
91 PackageIdentification packageId = GlobalData.openingPackageList
92 .getOpeningPackageByIndex(
93 indexOfPackage)
94 .getId();
95 if (spd.getPpiDeclarations() != null) {
96 for (int indexOfPpis = 0; indexOfPpis < spd.getPpiDeclarations().getEntryList()
97 .size(); indexOfPpis++) {
98 if (spd.getPpiDeclarations().getEntryList().get(indexOfPpis).getCName()
99 .equals(arg0)) {
100 pid.setDeclaredBy(packageId);
101 break;
102 }
103 }
104 }
105 }
106 if (pid.getDeclaredBy() == null) {
107 pid.setDeclaredBy(new PackageIdentification("", "", "", ""));
108 }
109
110 pv.addPpis(pid);
111 }
112 }
113 if (msa.getPPIs().getPpiNotifyList().size() > 0) {
114 for (int index = 0; index < msa.getPPIs().getPpiNotifyList().size(); index++) {
115 String arg0 = msa.getPPIs().getPpiNotifyList().get(index).getPpiNotifyCName();
116 String arg1 = DataType.PPI_TYPE_PPI_NOTIFY;
117 String arg2 = null;
118 if (msa.getPPIs().getPpiNotifyList().get(index).getUsage() != null) {
119 arg2 = msa.getPPIs().getPpiNotifyList().get(index).getUsage().toString();
120 }
121
122 String arg3 = msa.getPPIs().getPpiNotifyList().get(index).getFeatureFlag();
123 Vector<String> arg4 = Tools.convertListToVector(msa.getPPIs().getPpiNotifyList().get(index)
124 .getSupArchList());
125 String arg5 = msa.getPPIs().getPpiNotifyList().get(index).getHelpText();
126
127 pid = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
128 pid.setBelongModule(mid);
129
130 //
131 // Find which package declares it
132 //
133 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {
134 PackageSurfaceArea spd = GlobalData.openingPackageList
135 .getOpeningPackageByIndex(
136 indexOfPackage)
137 .getXmlSpd();
138 PackageIdentification packageId = GlobalData.openingPackageList
139 .getOpeningPackageByIndex(
140 indexOfPackage)
141 .getId();
142 if (spd.getPpiDeclarations() != null) {
143 for (int indexOfPpis = 0; indexOfPpis < spd.getPpiDeclarations().getEntryList()
144 .size(); indexOfPpis++) {
145 if (spd.getPpiDeclarations().getEntryList().get(indexOfPpis).getCName()
146 .equals(arg0)) {
147 pid.setDeclaredBy(packageId);
148 break;
149 }
150 }
151 }
152 }
153 if (pid.getDeclaredBy() == null) {
154 pid.setDeclaredBy(new PackageIdentification("", "", "", ""));
155 }
156
157 pv.addPpis(pid);
158 }
159 }
160 }
161 }
162 }
163 Sort.sortPpis(pv, DataType.SORT_TYPE_ASCENDING);
164 return pv;
165 }
166
167 /**
168 Re-org all ppi entries for find table
169
170 @return
171
172 **/
173 public static Vector<PpiId> getAllPpisForFind() {
174 Vector<PpiId> ppi = new Vector<PpiId>();
175 PpisVector pv = Find.getAllPpisVector();
176 boolean isAdded = false;
177 boolean isProduced = false;
178
179 //
180 // Go through pv to add item as new format to ppi one by one
181 //
182 for (int indexOfPv = 0; indexOfPv < pv.size(); indexOfPv++) {
183 isAdded = false;
184 PpisIdentification pvId = pv.getPpis(indexOfPv);
185
186 //
187 // First check if produced or not
188 //
189 if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)
190 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {
191 isProduced = true;
192 } else if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)
193 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {
194 isProduced = false;
195 }
196
197 //
198 // Get the sting "PackageName.ModuleName"
199 //
200 String tmp = pvId.getBelongModule().getPackageId().getName() + SEPERATOR + pvId.getBelongModule().getName();
201
202 //
203 // Check if the item has been added in
204 // If added, append package name and new module name
205 // If not added, add a new one first
206 //
207 for (int indexOfPpi = 0; indexOfPpi < ppi.size(); indexOfPpi++) {
208 PpiId ppiId = ppi.get(indexOfPpi);
209
210 if (pvId.getName().equals(ppiId.getName())) {
211 if (isProduced) {
212 ppi.get(indexOfPpi).setProducedModules(ppiId.getProducedModules() + "<br>" + tmp);
213 } else if (!isProduced) {
214 ppi.get(indexOfPpi).setConsumedModules(ppiId.getConsumedModules() + "<br>" + tmp);
215 }
216 isAdded = true;
217 continue;
218 }
219 }
220
221 //
222 // Add a new one
223 //
224 if (!isAdded) {
225 if (isProduced) {
226 ppi
227 .addElement(new PpiId(pvId.getName(), pvId.getType(), tmp, null, pvId.getDeclaredBy().getName()));
228 } else if (!isProduced) {
229 ppi
230 .addElement(new PpiId(pvId.getName(), pvId.getType(), null, tmp, pvId.getDeclaredBy().getName()));
231 }
232 }
233 }
234
235 return ppi;
236 }
237
238 /**
239 Get all protocol entries from workspace
240
241 @return
242
243 **/
244 public static ProtocolsVector getAllProtocolsVector() {
245 ProtocolsVector pv = new ProtocolsVector();
246 ModuleSurfaceArea msa = null;
247 ModuleIdentification mid = null;
248 ProtocolsIdentification pid = null;
249
250 //
251 // Go through each module one by one
252 //
253 if (GlobalData.openingModuleList.size() > 0) {
254 for (int indexOfModule = 0; indexOfModule < GlobalData.openingModuleList.size(); indexOfModule++) {
255 msa = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getXmlMsa();
256 mid = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getId();
257
258 if (msa.getProtocols() != null) {
259 if (msa.getProtocols().getProtocolList().size() > 0) {
260 for (int index = 0; index < msa.getProtocols().getProtocolList().size(); index++) {
261 String arg0 = msa.getProtocols().getProtocolList().get(index).getProtocolCName();
262 String arg1 = DataType.PROTOCOL_TYPE_PROTOCOL;
263 String arg2 = null;
264 if (msa.getProtocols().getProtocolList().get(index).getUsage() != null) {
265 arg2 = msa.getProtocols().getProtocolList().get(index).getUsage().toString();
266 }
267
268 String arg3 = msa.getProtocols().getProtocolList().get(index).getFeatureFlag();
269 Vector<String> arg4 = Tools.convertListToVector(msa.getProtocols().getProtocolList()
270 .get(index).getSupArchList());
271 String arg5 = msa.getProtocols().getProtocolList().get(index).getHelpText();
272
273 pid = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
274 pid.setBelongModule(mid);
275
276 //
277 // Find which package declares it
278 //
279 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {
280 PackageSurfaceArea spd = GlobalData.openingPackageList
281 .getOpeningPackageByIndex(
282 indexOfPackage)
283 .getXmlSpd();
284 PackageIdentification packageId = GlobalData.openingPackageList
285 .getOpeningPackageByIndex(
286 indexOfPackage)
287 .getId();
288 if (spd.getProtocolDeclarations() != null) {
289 for (int indexOfProtocols = 0; indexOfProtocols < spd.getProtocolDeclarations()
290 .getEntryList().size(); indexOfProtocols++) {
291 if (spd.getProtocolDeclarations().getEntryList().get(indexOfProtocols)
292 .getCName().equals(arg0)) {
293 pid.setDeclaredBy(packageId);
294 break;
295 }
296 }
297 }
298 }
299 if (pid.getDeclaredBy() == null) {
300 pid.setDeclaredBy(new PackageIdentification("", "", "", ""));
301 }
302 pv.addProtocols(pid);
303 }
304 }
305 if (msa.getProtocols().getProtocolNotifyList().size() > 0) {
306 for (int index = 0; index < msa.getProtocols().getProtocolNotifyList().size(); index++) {
307 String arg0 = msa.getProtocols().getProtocolNotifyList().get(index)
308 .getProtocolNotifyCName();
309 String arg1 = DataType.PPI_TYPE_PPI_NOTIFY;
310 String arg2 = null;
311 if (msa.getProtocols().getProtocolNotifyList().get(index).getUsage() != null) {
312 arg2 = msa.getProtocols().getProtocolNotifyList().get(index).getUsage().toString();
313 }
314
315 String arg3 = msa.getProtocols().getProtocolNotifyList().get(index).getFeatureFlag();
316 Vector<String> arg4 = Tools.convertListToVector(msa.getProtocols().getProtocolNotifyList()
317 .get(index).getSupArchList());
318 String arg5 = msa.getProtocols().getProtocolNotifyList().get(index).getHelpText();
319
320 pid = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
321 pid.setBelongModule(mid);
322
323 //
324 // Find which package declares it
325 //
326 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {
327 PackageSurfaceArea spd = GlobalData.openingPackageList
328 .getOpeningPackageByIndex(
329 indexOfPackage)
330 .getXmlSpd();
331 PackageIdentification packageId = GlobalData.openingPackageList
332 .getOpeningPackageByIndex(
333 indexOfPackage)
334 .getId();
335 if (spd.getProtocolDeclarations() != null) {
336 for (int indexOfProtocols = 0; indexOfProtocols < spd.getProtocolDeclarations()
337 .getEntryList().size(); indexOfProtocols++) {
338 if (spd.getProtocolDeclarations().getEntryList().get(indexOfProtocols)
339 .getCName().equals(arg0)) {
340 pid.setDeclaredBy(packageId);
341 break;
342 }
343 }
344 }
345 }
346 if (pid.getDeclaredBy() == null) {
347 pid.setDeclaredBy(new PackageIdentification("", "", "", ""));
348 }
349
350 pv.addProtocols(pid);
351 }
352 }
353 }
354 }
355 }
356 Sort.sortProtocols(pv, DataType.SORT_TYPE_ASCENDING);
357 return pv;
358 }
359
360 /**
361 Re-org all protocol entries for find table
362
363 @return
364
365 **/
366 public static Vector<ProtocolId> getAllProtocolsForFind() {
367 Vector<ProtocolId> protocol = new Vector<ProtocolId>();
368 ProtocolsVector pv = Find.getAllProtocolsVector();
369 boolean isAdded = false;
370 boolean isProduced = false;
371
372 //
373 // Go through pv to add item as new format to ppi one by one
374 //
375 for (int indexOfPv = 0; indexOfPv < pv.size(); indexOfPv++) {
376 isAdded = false;
377 ProtocolsIdentification pvId = pv.getProtocols(indexOfPv);
378
379 //
380 // First check if produced or not
381 //
382 if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)
383 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {
384 isProduced = true;
385 } else if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)
386 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {
387 isProduced = false;
388 }
389
390 //
391 // Get the sting "PackageName.ModuleName"
392 //
393 String tmp = pvId.getBelongModule().getPackageId().getName() + SEPERATOR + pvId.getBelongModule().getName();
394
395 //
396 // Check if the item has been added in
397 // If added, append package name and new module name
398 // If not added, add a new one first
399 //
400 for (int indexOfProtocol = 0; indexOfProtocol < protocol.size(); indexOfProtocol++) {
401 ProtocolId protocolId = protocol.get(indexOfProtocol);
402
403 if (pvId.getName().equals(protocolId.getName())) {
404 if (isProduced) {
405 protocol.get(indexOfProtocol)
406 .setProducedModules(protocolId.getProducedModules() + "<br>" + tmp);
407 } else if (!isProduced) {
408 protocol.get(indexOfProtocol)
409 .setConsumedModules(protocolId.getConsumedModules() + "<br>" + tmp);
410 }
411 isAdded = true;
412 continue;
413 }
414 }
415
416 //
417 // Add a new one
418 //
419 if (!isAdded) {
420 if (isProduced) {
421 protocol.addElement(new ProtocolId(pvId.getName(), pvId.getType(), tmp, null, pvId.getDeclaredBy()
422 .getName()));
423 } else if (!isProduced) {
424 protocol.addElement(new ProtocolId(pvId.getName(), pvId.getType(), null, tmp, pvId.getDeclaredBy()
425 .getName()));
426 }
427 }
428 }
429
430 return protocol;
431 }
432
433 /**
434 Get all protocol entries from workspace
435
436 @return
437
438 **/
439 public static GuidsVector getAllGuidsVector() {
440 GuidsVector gv = new GuidsVector();
441 ModuleSurfaceArea msa = null;
442 ModuleIdentification mid = null;
443 GuidsIdentification gid = null;
444
445 //
446 // Go through each module one by one
447 //
448 if (GlobalData.openingModuleList.size() > 0) {
449 for (int indexOfModule = 0; indexOfModule < GlobalData.openingModuleList.size(); indexOfModule++) {
450 msa = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getXmlMsa();
451 mid = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getId();
452
453 if (msa.getGuids() != null) {
454 if (msa.getGuids().getGuidCNamesList().size() > 0) {
455 for (int index = 0; index < msa.getGuids().getGuidCNamesList().size(); index++) {
456 String arg0 = msa.getGuids().getGuidCNamesList().get(index).getGuidCName();
457 String arg1 = null;
458 if (msa.getGuids().getGuidCNamesList().get(index).getUsage() != null) {
459 arg1 = msa.getGuids().getGuidCNamesList().get(index).getUsage().toString();
460 }
461
462 String arg2 = msa.getGuids().getGuidCNamesList().get(index).getFeatureFlag();
463 Vector<String> arg3 = Tools.convertListToVector(msa.getGuids().getGuidCNamesList()
464 .get(index).getSupArchList());
465 String arg4 = msa.getGuids().getGuidCNamesList().get(index).getHelpText();
466
467 gid = new GuidsIdentification(arg0, arg1, arg2, arg3, arg4);
468 gid.setBelongModule(mid);
469
470 //
471 // Find which package declares it
472 //
473 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {
474 PackageSurfaceArea spd = GlobalData.openingPackageList
475 .getOpeningPackageByIndex(
476 indexOfPackage)
477 .getXmlSpd();
478 PackageIdentification packageId = GlobalData.openingPackageList
479 .getOpeningPackageByIndex(
480 indexOfPackage)
481 .getId();
482 if (spd.getGuidDeclarations() != null) {
483 for (int indexOfGuids = 0; indexOfGuids < spd.getGuidDeclarations().getEntryList()
484 .size(); indexOfGuids++) {
485 if (spd.getGuidDeclarations().getEntryList().get(indexOfGuids).getCName()
486 .equals(arg0)) {
487 gid.setDeclaredBy(packageId);
488 break;
489 }
490 }
491 }
492 }
493 if (gid.getDeclaredBy() == null) {
494 gid.setDeclaredBy(new PackageIdentification("", "", "", ""));
495 }
496
497 gv.addGuids(gid);
498 }
499 }
500 }
501 }
502 }
503 Sort.sortGuids(gv, DataType.SORT_TYPE_ASCENDING);
504 return gv;
505 }
506
507 /**
508 Re-org all guid entries for find table
509
510 @return
511
512 **/
513 public static Vector<GuidId> getAllGuidsForFind() {
514 Vector<GuidId> guid = new Vector<GuidId>();
515 GuidsVector gv = Find.getAllGuidsVector();
516 boolean isAdded = false;
517 boolean isProduced = false;
518
519 //
520 // Go through pv to add item as new format to ppi one by one
521 //
522 for (int indexOfGv = 0; indexOfGv < gv.size(); indexOfGv++) {
523 isAdded = false;
524 GuidsIdentification gvId = gv.getGuids(indexOfGv);
525
526 //
527 // First check if produced or not
528 //
529 if (gvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)
530 || gvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {
531 isProduced = true;
532 } else if (gvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)
533 || gvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {
534 isProduced = false;
535 }
536
537 //
538 // Get the sting "PackageName.ModuleName"
539 //
540 String tmp = gvId.getBelongModule().getPackageId().getName() + SEPERATOR + gvId.getBelongModule().getName();
541
542 //
543 // Check if the item has been added in
544 // If added, append package name and new module name
545 // If not added, add a new one first
546 //
547 for (int indexOfGuid = 0; indexOfGuid < guid.size(); indexOfGuid++) {
548 GuidId guidId = guid.get(indexOfGuid);
549
550 if (gvId.getName().equals(guidId.getName())) {
551 if (isProduced) {
552 guid.get(indexOfGuid).setProducedModules(guidId.getProducedModules() + "<br>" + tmp);
553 } else if (!isProduced) {
554 guid.get(indexOfGuid).setConsumedModules(guidId.getConsumedModules() + "<br>" + tmp);
555 }
556 isAdded = true;
557 continue;
558 }
559 }
560
561 //
562 // Add a new one
563 //
564 if (!isAdded) {
565 if (isProduced) {
566 guid.addElement(new GuidId(gvId.getName(), "GUID", tmp, null, gvId.getDeclaredBy().getName()));
567 } else if (!isProduced) {
568 guid.addElement(new GuidId(gvId.getName(), "GUID", null, tmp, gvId.getDeclaredBy().getName()));
569 }
570 }
571 }
572
573 return guid;
574 }
575
576 /**
577 Get all pcd coded entries from workspace
578
579 @return
580
581 **/
582 public static PcdCodedVector getAllPcdCodedVector() {
583 PcdCodedVector pv = new PcdCodedVector();
584 ModuleSurfaceArea msa = null;
585 ModuleIdentification mid = null;
586 PcdCodedIdentification pid = null;
587
588 //
589 // Go through each module one by one
590 //
591 if (GlobalData.openingModuleList.size() > 0) {
592 for (int indexOfModule = 0; indexOfModule < GlobalData.openingModuleList.size(); indexOfModule++) {
593 msa = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getXmlMsa();
594 mid = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getId();
595
596 if (msa.getPcdCoded() != null) {
597 if (msa.getPcdCoded().getPcdEntryList().size() > 0) {
598 for (int index = 0; index < msa.getPcdCoded().getPcdEntryList().size(); index++) {
599
600 String arg0 = msa.getPcdCoded().getPcdEntryList().get(index).getCName();
601 String arg1 = msa.getPcdCoded().getPcdEntryList().get(index).getTokenSpaceGuidCName();
602
603 String arg2 = msa.getPcdCoded().getPcdEntryList().get(index).getFeatureFlag();
604 Vector<String> arg3 = Tools.convertListToVector(msa.getPcdCoded().getPcdEntryList()
605 .get(index).getSupArchList());
606
607 String arg4 = msa.getPcdCoded().getPcdEntryList().get(index).getDefaultValue();
608 String arg5 = msa.getPcdCoded().getPcdEntryList().get(index).getHelpText();
609 String arg6 = null;
610 if (msa.getPcdCoded().getPcdEntryList().get(index).getPcdItemType() != null) {
611 arg6 = msa.getPcdCoded().getPcdEntryList().get(index).getPcdItemType().toString();
612 }
613 String arg7 = null;
614 if (msa.getPcdCoded().getPcdEntryList().get(index).getUsage() != null) {
615 arg7 = msa.getPcdCoded().getPcdEntryList().get(index).getUsage().toString();
616 }
617 pid = new PcdCodedIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
618 pid.setBelongModule(mid);
619
620 //
621 // Find which package declares it
622 //
623 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {
624 PackageSurfaceArea spd = GlobalData.openingPackageList
625 .getOpeningPackageByIndex(
626 indexOfPackage)
627 .getXmlSpd();
628 PackageIdentification packageId = GlobalData.openingPackageList
629 .getOpeningPackageByIndex(
630 indexOfPackage)
631 .getId();
632 if (spd.getPcdDeclarations() != null) {
633 for (int indexOfPcds = 0; indexOfPcds < spd.getPcdDeclarations().getPcdEntryList()
634 .size(); indexOfPcds++) {
635 PcdEntry pcdEntry = spd.getPcdDeclarations().getPcdEntryList().get(indexOfPcds);
636 if (pcdEntry.getCName().equals(arg0)) {
637 pid.setTokenSpaceGuidCName(pcdEntry.getTokenSpaceGuidCName());
638 pid.setToken(pcdEntry.getToken().toString());
639 pid.setDatumType(pcdEntry.getDatumType().toString());
640 pid.setValue(pcdEntry.getDefaultValue());
641 pid.setUsage(Tools.convertListToString(pcdEntry.getValidUsage()));
642 pid.setHelp(pcdEntry.getHelpText());
643 pid.setDeclaredBy(packageId);
644 break;
645 }
646 }
647 }
648 }
649 if (pid.getDeclaredBy() == null) {
650 pid.setDeclaredBy(new PackageIdentification("", "", "", ""));
651 }
652
653 pv.addPcdCoded(pid);
654 }
655 }
656 }
657 }
658 }
659 Sort.sortPcdCodeds(pv, DataType.SORT_TYPE_ASCENDING);
660 return pv;
661 }
662
663 /**
664 Re-org all guid entries for find table
665
666 @return
667
668 **/
669 /**
670
671 @return
672
673 **/
674 /**
675
676 @return
677
678 **/
679 /**
680
681 @return
682
683 **/
684 public static Vector<PcdFindResultId> getAllPcdCodedForFind(PcdCodedVector pv) {
685 Vector<PcdFindResultId> pcd = new Vector<PcdFindResultId>();
686 boolean isAdded = false;
687 boolean isProduced = false;
688
689 //
690 // Go through pv to add item as new format to ppi one by one
691 //
692 for (int indexOfPv = 0; indexOfPv < pv.size(); indexOfPv++) {
693 isAdded = false;
694 PcdCodedIdentification pvId = pv.getPcdCoded(indexOfPv);
695
696 //
697 // First check if produced or not
698 //
699 if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)
700 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {
701 isProduced = true;
702 } else if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)
703 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {
704 isProduced = false;
705 }
706
707 //
708 // Check if the item has been added in
709 // If added, append package name and new module name
710 // If not added, add a new one first
711 //
712 for (int indexOfGuid = 0; indexOfGuid < pcd.size(); indexOfGuid++) {
713 PcdFindResultId pcdId = pcd.get(indexOfGuid);
714
715 if (pvId.getName().equals(pcdId.getName())) {
716 if (isProduced) {
717 pcd.get(indexOfGuid).addProducedModules(pvId.getBelongModule());
718 } else if (!isProduced) {
719 pcd.get(indexOfGuid).addConsumedModules(pvId.getBelongModule());
720 }
721 isAdded = true;
722 continue;
723 }
724 }
725
726 //
727 // Add a new one
728 //
729 if (!isAdded) {
730 PcdFindResultId pcdId = new PcdFindResultId(pvId.getName(), "PCD", pvId.getSupArchList(),
731 pvId.getHelp(), null, pvId.getDeclaredBy());
732 pcdId.setTokenSpaceGuidCName(pvId.getTokenSpaceGuidCName());
733 pcdId.setToken(pvId.getToken());
734 pcdId.setDatumType(pvId.getDatumType());
735 pcdId.setValue(pvId.getValue());
736 pcdId.setUsage(pvId.getUsage());
737
738 pcd.addElement(pcdId);
739 }
740 }
741
742 return pcd;
743 }
744 /**
745 Get all library class entries from workspace
746
747 @return
748
749 **/
750 public static LibraryClassVector getAllLibraryClassVector() {
751 LibraryClassVector lcv = new LibraryClassVector();
752 ModuleSurfaceArea msa = null;
753 ModuleIdentification mid = null;
754 LibraryClassIdentification lcid = null;
755
756 //
757 // Go through each module one by one
758 //
759 if (GlobalData.openingModuleList.size() > 0) {
760 for (int indexOfModule = 0; indexOfModule < GlobalData.openingModuleList.size(); indexOfModule++) {
761 msa = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getXmlMsa();
762 mid = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getId();
763
764 if (msa.getLibraryClassDefinitions() != null) {
765 LibraryClassDefinitions lcd = msa.getLibraryClassDefinitions();
766 if (lcd.getLibraryClassList().size() > 0) {
767 for (int index = 0; index < lcd.getLibraryClassList().size(); index++) {
768 String name = lcd.getLibraryClassList().get(index).getKeyword();
769 String usage = null;
770 if (lcd.getLibraryClassList().get(index).getUsage() != null) {
771 usage = lcd.getLibraryClassList().get(index).getUsage().toString();
772 }
773 String version = lcd.getLibraryClassList().get(index).getRecommendedInstanceVersion();
774 String guid = lcd.getLibraryClassList().get(index).getRecommendedInstanceGuid();
775 String featureFlag = lcd.getLibraryClassList().get(index).getFeatureFlag();
776 Vector<String> arch = Tools.convertListToVector(lcd.getLibraryClassList().get(index)
777 .getSupArchList());
778 Vector<String> module = Tools.convertListToVector(lcd.getLibraryClassList().get(index)
779 .getSupModuleList());
780 String help = lcd.getLibraryClassList().get(index).getHelpText();
781 lcid = new LibraryClassIdentification(name, usage, version, guid, arch, featureFlag,
782 module, help);
783 lcid.setBelongModule(mid);
784
785 //
786 // Find which package declares it
787 //
788 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {
789 PackageSurfaceArea spd = GlobalData.openingPackageList
790 .getOpeningPackageByIndex(
791 indexOfPackage)
792 .getXmlSpd();
793 PackageIdentification packageId = GlobalData.openingPackageList
794 .getOpeningPackageByIndex(
795 indexOfPackage)
796 .getId();
797 if (spd.getLibraryClassDeclarations() != null) {
798 for (int indexOfLibraryClass = 0; indexOfLibraryClass < spd
799 .getLibraryClassDeclarations()
800 .getLibraryClassList()
801 .size(); indexOfLibraryClass++) {
802 LibraryClass lc = spd.getLibraryClassDeclarations().getLibraryClassList()
803 .get(indexOfLibraryClass);
804 if (lc.getName().equals(name)) {
805 lcid.setSupArchList(Tools.convertListToVector(lc.getSupArchList()));
806 lcid.setSupModuleList(Tools.convertListToVector(lc.getSupModuleList()));
807 lcid.setHelp(lc.getHelpText());
808 lcid.setDeclaredBy(packageId);
809 break;
810 }
811 }
812 }
813 }
814 if (lcid.getDeclaredBy() == null) {
815 lcid.setDeclaredBy(new PackageIdentification("", "", "", ""));
816 }
817
818 lcv.addLibraryClass(lcid);
819 }
820 }
821 }
822 }
823 }
824 Sort.sortLibraryClass(lcv, DataType.SORT_TYPE_ASCENDING);
825 return lcv;
826 }
827
828 /**
829 Re-org all guid entries for find table
830
831 @return
832
833 **/
834 public static Vector<FindResultId> getAllLibraryClassForFind(LibraryClassVector lcv) {
835 Vector<FindResultId> libraryClass = new Vector<FindResultId>();
836 boolean isAdded = false;
837 boolean isProduced = false;
838
839 //
840 // Go through pv to add item as new format to ppi one by one
841 //
842 for (int indexOfLcv = 0; indexOfLcv < lcv.size(); indexOfLcv++) {
843 isAdded = false;
844 LibraryClassIdentification lcvId = lcv.getLibraryClass(indexOfLcv);
845
846 //
847 // First check if produced or not
848 //
849 if (lcvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)
850 || lcvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {
851 isProduced = true;
852 } else if (lcvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)
853 || lcvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {
854 isProduced = false;
855 }
856
857 //
858 // Check if the item has been added in
859 // If added, append package name and new module name
860 // If not added, add a new one first
861 //
862 for (int indexOfGuid = 0; indexOfGuid < libraryClass.size(); indexOfGuid++) {
863 FindResultId frId = libraryClass.get(indexOfGuid);
864
865 if (lcvId.getLibraryClassName().equals(frId.getName())) {
866 if (isProduced) {
867 libraryClass.get(indexOfGuid).addProducedModules(lcvId.getBelongModule());
868 } else if (!isProduced) {
869 libraryClass.get(indexOfGuid).addConsumedModules(lcvId.getBelongModule());
870 }
871 isAdded = true;
872 continue;
873 }
874 }
875
876 //
877 // Add a new one
878 //
879 if (!isAdded) {
880 libraryClass.addElement(new FindResultId(lcvId.getLibraryClassName(), "Library Class",
881 lcvId.getSupArchList(), lcvId.getHelp(),
882 lcvId.getSupModuleList(), lcvId.getDeclaredBy()));
883 }
884 }
885
886 return libraryClass;
887 }
888 }