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