]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdFileContents.java
Fix the bug of leaving empty GuidTypeList, SupArchList attributes in xml file.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdFileContents.java
1 /** @file
2 Java class SpdFileContents is used to parse spd xml file.
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 package org.tianocore.frameworkwizard.packaging.ui;
14
15 import java.io.File;
16 import java.io.IOException;
17 import java.util.ArrayList;
18 import java.util.List;
19 import java.util.ListIterator;
20 import java.util.Vector;
21
22
23 import org.apache.xmlbeans.XmlObject;
24 import org.apache.xmlbeans.XmlOptions;
25 import org.apache.xmlbeans.XmlCursor;
26
27 import org.tianocore.GuidDeclarationsDocument;
28
29 import org.tianocore.LibraryClassDeclarationsDocument;
30
31 import org.tianocore.ModuleTypeDef;
32 import org.tianocore.MsaFilesDocument;
33 import org.tianocore.PackageDefinitionsDocument;
34 import org.tianocore.PackageHeadersDocument;
35 import org.tianocore.PackageSurfaceAreaDocument;
36 import org.tianocore.PcdDataTypes;
37 import org.tianocore.PcdDeclarationsDocument;
38 import org.tianocore.PpiDeclarationsDocument;
39 import org.tianocore.ProtocolDeclarationsDocument;
40 import org.tianocore.SpdHeaderDocument;
41 import org.tianocore.GuidDeclarationsDocument.GuidDeclarations;
42
43 /**
44 This class processes spd file contents such as add remove xml elements.
45
46 @since PackageEditor 1.0
47 **/
48
49 public class SpdFileContents {
50
51 private File file = null;
52
53 private PackageSurfaceAreaDocument psad = null;
54
55 private PackageSurfaceAreaDocument.PackageSurfaceArea psaRoot = null;
56
57 private SpdHeaderDocument.SpdHeader spdHdr = null;
58
59 private PackageDefinitionsDocument.PackageDefinitions spdPkgDefs = null;
60
61 private LibraryClassDeclarationsDocument.LibraryClassDeclarations spdLibClassDeclarations = null;
62
63 private MsaFilesDocument.MsaFiles spdMsaFiles = null;
64
65 private PackageHeadersDocument.PackageHeaders spdModHdrs = null;
66
67 private GuidDeclarationsDocument.GuidDeclarations spdGuidDeclarations = null;
68
69 private ProtocolDeclarationsDocument.ProtocolDeclarations spdProtocolDeclarations = null;
70
71 private PpiDeclarationsDocument.PpiDeclarations spdPpiDeclarations = null;
72
73 private PcdDeclarationsDocument.PcdDeclarations spdPcdDefinitions = null;
74
75 /**
76 Constructor to create a new spd file
77 **/
78 public SpdFileContents() {
79
80 psad = PackageSurfaceAreaDocument.Factory.newInstance();
81 psaRoot = psad.addNewPackageSurfaceArea();
82
83 }
84
85 /**
86 Constructor for existing document object
87 @param psa
88 **/
89 public SpdFileContents(PackageSurfaceAreaDocument.PackageSurfaceArea psa) {
90 psaRoot = psa;
91 spdHdr = psaRoot.getSpdHeader();
92 spdPkgDefs = psaRoot.getPackageDefinitions();
93 }
94 /**
95 Constructor based on an existing spd file
96
97 @param f Existing spd file
98 **/
99 public SpdFileContents(File f) {
100 try {
101 psad = PackageSurfaceAreaDocument.Factory.parse(f);
102 psaRoot = psad.getPackageSurfaceArea();
103 file = f;
104 } catch (Exception e) {
105 System.out.println(e.toString());
106 }
107 }
108
109 /**
110 Remove existing pcd definitions elements using XmlCursor
111 **/
112 public void removeSpdPcdDefinition() {
113 XmlObject o = psaRoot.getPcdDeclarations();
114 if (o == null)
115 return;
116 XmlCursor cursor = o.newCursor();
117 cursor.removeXml();
118 spdPcdDefinitions = null;
119 cursor.dispose();
120 }
121
122 public void removeSpdPcdDefinition(int i){
123 XmlObject o = psaRoot.getPcdDeclarations();
124 if (o == null)
125 return;
126 XmlCursor cursor = o.newCursor();
127 if (cursor.toFirstChild()) {
128 for (int j = 0; j < i; ++j) {
129 cursor.toNextSibling();
130 }
131 cursor.removeXml();
132 if (getSpdPcdDefinitionCount() == 0) {
133 cursor.toParent();
134 cursor.removeXml();
135 }
136 }
137 cursor.dispose();
138 }
139
140 /**
141 Remove existing ppi declarations using XmlCursor
142 **/
143 public void removeSpdPpiDeclaration() {
144 XmlObject o = psaRoot.getPpiDeclarations();
145 if (o == null)
146 return;
147 XmlCursor cursor = o.newCursor();
148 cursor.removeXml();
149 spdPpiDeclarations = null;
150 cursor.dispose();
151 }
152
153 public void removeSpdPpiDeclaration(int i){
154 XmlObject o = psaRoot.getPpiDeclarations();
155 if (o == null)
156 return;
157 XmlCursor cursor = o.newCursor();
158 if (cursor.toFirstChild()) {
159 for (int j = 0; j < i; ++j) {
160 cursor.toNextSibling();
161 }
162 cursor.removeXml();
163 if (getSpdPpiDeclarationCount() == 0){
164 cursor.toParent();
165 cursor.removeXml();
166 }
167 }
168 cursor.dispose();
169 }
170 /**
171 Remove existing protocols declarations using XmlCursor
172 **/
173 public void removeSpdProtocolDeclaration() {
174 XmlObject o = psaRoot.getProtocolDeclarations();
175 if (o == null)
176 return;
177 XmlCursor cursor = o.newCursor();
178 cursor.removeXml();
179 spdProtocolDeclarations = null;
180 cursor.dispose();
181 }
182
183 public void removeSpdProtocolDeclaration(int i) {
184 XmlObject o = psaRoot.getProtocolDeclarations();
185 if (o == null)
186 return;
187 XmlCursor cursor = o.newCursor();
188 if (cursor.toFirstChild()) {
189 for (int j = 0; j < i; ++j) {
190 cursor.toNextSibling();
191 }
192 cursor.removeXml();
193 if (getSpdProtocolDeclarationCount() == 0) {
194 cursor.toParent();
195 cursor.removeXml();
196 }
197 }
198 cursor.dispose();
199 }
200 /**
201 Remove existing GUID declarations using XmlCursor
202 **/
203 public void removeSpdGuidDeclaration() {
204 XmlObject o = psaRoot.getGuidDeclarations();
205 if (o == null)
206 return;
207 XmlCursor cursor = o.newCursor();
208 cursor.removeXml();
209 spdGuidDeclarations = null;
210 cursor.dispose();
211 }
212
213 public void removeSpdGuidDeclaration(int i) {
214 XmlObject o = psaRoot.getGuidDeclarations();
215 if (o == null)
216 return;
217 XmlCursor cursor = o.newCursor();
218 if (cursor.toFirstChild()) {
219 for (int j = 0; j < i; ++j) {
220 cursor.toNextSibling();
221 }
222 cursor.removeXml();
223 if (getSpdGuidDeclarationCount() == 0) {
224 cursor.toParent();
225 cursor.removeXml();
226 }
227 }
228 cursor.dispose();
229 }
230
231 /**
232 Remove existing spd package include files using XmlCursor
233 **/
234 public void removeSpdPkgHeader() {
235 XmlObject o = psaRoot.getPackageHeaders();
236 if (o == null)
237 return;
238 XmlCursor cursor = o.newCursor();
239 cursor.removeXml();
240 spdModHdrs = null;
241 cursor.dispose();
242 }
243
244 public void removeSpdPkgHeader(int i){
245 XmlObject o = psaRoot.getPackageHeaders();
246 if (o == null)
247 return;
248 XmlCursor cursor = o.newCursor();
249 if (cursor.toFirstChild()) {
250 for (int j = 0; j < i; ++j) {
251 cursor.toNextSibling();
252 }
253 cursor.removeXml();
254 if (getSpdPackageHeaderCount() == 0) {
255 cursor.toParent();
256 cursor.removeXml();
257 }
258 }
259 cursor.dispose();
260 }
261
262 /**
263 Remove existing msa files using XmlCursor
264 **/
265 public void removeSpdMsaFile() {
266 XmlObject o = psaRoot.getMsaFiles();
267 if (o == null)
268 return;
269 XmlCursor cursor = o.newCursor();
270 cursor.removeXml();
271 spdMsaFiles = null;
272 cursor.dispose();
273 }
274
275 public void removeSpdMsaFile(int i){
276 XmlObject o = psaRoot.getMsaFiles();
277 if (o == null)
278 return;
279 XmlCursor cursor = o.newCursor();
280 if (cursor.toFirstChild()) {
281 for (int j = 0; j < i; ++j) {
282 cursor.toNextSibling();
283 }
284 cursor.removeXml();
285 if (getSpdMsaFileCount() == 0) {
286 cursor.toParent();
287 cursor.removeXml();
288 }
289 }
290 cursor.dispose();
291 }
292
293 /**
294 Remove existing library class declarations using XmlCursor
295 **/
296 public void removeSpdLibClass() {
297 XmlObject o = psaRoot.getLibraryClassDeclarations();
298 if (o == null)
299 return;
300 XmlCursor cursor = o.newCursor();
301 cursor.removeXml();
302 spdLibClassDeclarations = null;
303 cursor.dispose();
304 }
305
306 public void removeSpdLibClass(int i) {
307 XmlObject o = psaRoot.getLibraryClassDeclarations();
308 if (o == null)
309 return;
310 XmlCursor cursor = o.newCursor();
311 if (cursor.toFirstChild()) {
312 for (int j = 0; j < i; ++j) {
313 cursor.toNextSibling();
314 }
315 cursor.removeXml();
316 if (getSpdLibClassDeclarationCount() == 0) {
317 cursor.toParent();
318 cursor.removeXml();
319 }
320 }
321 cursor.dispose();
322 }
323
324 public void updateSpdLibClass(int i, String lib, String hdr, String hlp, String clsUsage, String instanceVer, String hdrAttribArch, String hdrAttribModType) {
325 XmlObject o = psaRoot.getLibraryClassDeclarations();
326 if (o == null)
327 return;
328
329 XmlCursor cursor = o.newCursor();
330 if (cursor.toFirstChild()) {
331 for (int j = 0; j < i; ++j) {
332 cursor.toNextSibling();
333 }
334 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass)cursor.getObject();
335 lc.setName(lib);
336 lc.setIncludeHeader(hdr);
337 lc.setHelpText(hlp);
338 if (clsUsage != null) {
339 lc.setRecommendedInstanceGuid(clsUsage);
340 if (instanceVer != null){
341 lc.setRecommendedInstanceVersion(instanceVer);
342 } else {
343 if (lc.isSetRecommendedInstanceVersion()) {
344 lc.unsetRecommendedInstanceVersion();
345 }
346 }
347 } else {
348 if (lc.isSetRecommendedInstanceGuid()) {
349 lc.unsetRecommendedInstanceGuid();
350 }
351 if (lc.isSetRecommendedInstanceVersion()) {
352 lc.unsetRecommendedInstanceVersion();
353 }
354 }
355
356 if (stringToList(hdrAttribArch) != null){
357 lc.setSupArchList(stringToList(hdrAttribArch));
358 } else {
359 if (lc.isSetSupArchList()) {
360 lc.unsetSupArchList();
361 }
362 }
363 if (stringToList(hdrAttribModType) != null){
364 lc.setSupModuleList(stringToList(hdrAttribModType));
365 } else {
366 if (lc.isSetSupModuleList()) {
367 lc.unsetSupModuleList();
368 }
369 }
370 }
371
372 cursor.dispose();
373 }
374
375 public void updateSpdMsaFile(int i, String msaFile, String mName, String v, String g){
376 XmlObject o = psaRoot.getMsaFiles();
377 if (o == null)
378 return;
379
380 XmlCursor cursor = o.newCursor();
381 if (cursor.toFirstChild()) {
382 for (int j = 0; j < i; ++j) {
383 cursor.toNextSibling();
384 }
385 cursor.setTextValue(msaFile);
386
387 }
388
389 cursor.dispose();
390 }
391
392 public void updateSpdGuidDecl(int i, String name, String cName, String guid, String hlp, String archList,
393 String modTypeList, String guidTypeList){
394 XmlObject o = psaRoot.getGuidDeclarations();
395 if (o == null){
396 return;
397 }
398
399 XmlCursor cursor = o.newCursor();
400 if (cursor.toFirstChild()) {
401 for (int j = 0; j < i; ++j) {
402 cursor.toNextSibling();
403 }
404 GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.Entry)cursor.getObject();
405 e.setName(name);
406 e.setCName(cName);
407 e.setGuidValue(guid);
408 e.setHelpText(hlp);
409 if (stringToList(guidTypeList) != null) {
410 e.setGuidTypeList(stringToList(guidTypeList));
411 }
412 else{
413 if (e.isSetGuidTypeList()) {
414 e.unsetGuidTypeList();
415 }
416 }
417 if (stringToList(archList) != null){
418 e.setSupArchList(stringToList(archList));
419 }
420 else{
421 if (e.isSetSupArchList()) {
422 e.unsetSupArchList();
423 }
424 }
425 if (stringToList(modTypeList) != null) {
426 e.setSupModuleList(stringToList(modTypeList));
427 }
428 else{
429 if (e.isSetSupModuleList()) {
430 e.unsetSupModuleList();
431 }
432 }
433
434 }
435 cursor.dispose();
436 }
437
438 public void updateSpdPpiDecl(int i, String name, String cName, String guid, String hlp, String archList,
439 String modTypeList){
440 XmlObject o = psaRoot.getPpiDeclarations();
441 if (o == null){
442 return;
443 }
444
445 XmlCursor cursor = o.newCursor();
446 if (cursor.toFirstChild()) {
447 for (int j = 0; j < i; ++j) {
448 cursor.toNextSibling();
449 }
450 PpiDeclarationsDocument.PpiDeclarations.Entry e = (PpiDeclarationsDocument.PpiDeclarations.Entry)cursor.getObject();
451 e.setName(name);
452 e.setCName(cName);
453 e.setGuidValue(guid);
454 e.setHelpText(hlp);
455 if (stringToList(archList) != null){
456 e.setSupArchList(stringToList(archList));
457 }
458 else{
459 if (e.isSetSupArchList()) {
460 e.unsetSupArchList();
461 }
462 }
463 if (stringToList(modTypeList) != null) {
464 e.setSupModuleList(stringToList(modTypeList));
465 }
466 else{
467 if (e.isSetSupModuleList()) {
468 e.unsetSupModuleList();
469 }
470 }
471 }
472 cursor.dispose();
473 }
474
475 public void updateSpdProtocolDecl(int i, String name, String cName, String guid, String hlp, String archList,
476 String modTypeList){
477 XmlObject o = psaRoot.getProtocolDeclarations();
478 if (o == null){
479 return;
480 }
481
482 XmlCursor cursor = o.newCursor();
483 if (cursor.toFirstChild()) {
484 for (int j = 0; j < i; ++j) {
485 cursor.toNextSibling();
486 }
487 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry)cursor.getObject();
488 e.setName(name);
489 e.setCName(cName);
490 e.setGuidValue(guid);
491 e.setHelpText(hlp);
492 if (stringToList(archList) != null){
493 e.setSupArchList(stringToList(archList));
494 }
495 else{
496 if (e.isSetSupArchList()) {
497 e.unsetSupArchList();
498 }
499 }
500 if (stringToList(modTypeList) != null) {
501 e.setSupModuleList(stringToList(modTypeList));
502 }
503 else{
504 if (e.isSetSupModuleList()) {
505 e.unsetSupModuleList();
506 }
507 }
508 }
509 cursor.dispose();
510 }
511
512 public void updateSpdPkgHdr(int i, String pkgName, String hdrName){
513 XmlObject o = psaRoot.getPackageHeaders();
514 if (o == null){
515 return;
516 }
517
518 XmlCursor cursor = o.newCursor();
519 if (cursor.toFirstChild()) {
520 for (int j = 0; j < i; ++j) {
521 cursor.toNextSibling();
522 }
523
524 PackageHeadersDocument.PackageHeaders.IncludePkgHeader iph = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader)cursor.getObject();
525 iph.setModuleType(ModuleTypeDef.Enum.forString(pkgName));
526 iph.setStringValue(hdrName);
527 }
528 cursor.dispose();
529 }
530
531 public void updateSpdPcdDefinition(int i, String cName, String token, String dataType, String pcdItemTypes,
532 String spaceGuid, String defaultString, String help, String archList, String modTypeList){
533 XmlObject o = psaRoot.getPcdDeclarations();
534 if (o == null)
535 return;
536 XmlCursor cursor = o.newCursor();
537 if (cursor.toFirstChild()) {
538 for (int j = 0; j < i; ++j) {
539 cursor.toNextSibling();
540 }
541 PcdDeclarationsDocument.PcdDeclarations.PcdEntry e = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)cursor.getObject();
542 e.setCName(cName);
543 e.setToken(token);
544 e.setDatumType(PcdDataTypes.Enum.forString(dataType));
545 if (pcdItemTypes != null && pcdItemTypes.length() > 0) {
546 String usage[] = pcdItemTypes.split("( )+");
547 List<String> l = new ArrayList<String>();
548 for (int k = 0; k < usage.length; ++k) {
549 l.add(usage[k]);
550 }
551 e.setValidUsage(l);
552 }
553
554 e.setTokenSpaceGuidCName(spaceGuid);
555 e.setDefaultValue(defaultString);
556 e.setHelpText(help);
557 if (stringToList(archList) != null){
558 e.setSupArchList(stringToList(archList));
559 }
560 else{
561 if (e.isSetSupArchList()) {
562 e.unsetSupArchList();
563 }
564 }
565 if (stringToList(modTypeList) != null) {
566 e.setSupModuleList(stringToList(modTypeList));
567 }
568 else{
569 if (e.isSetSupModuleList()) {
570 e.unsetSupModuleList();
571 }
572 }
573
574 }
575 cursor.dispose();
576 }
577 /**
578 Get spd file header contents into String array
579
580 @param s Caller allocated String array
581 **/
582 public void getSpdHdrDetails(String[] s) {
583 if (getSpdHdr() == null) {
584 spdHdr = psaRoot.addNewSpdHeader();
585 }
586 s[0] = getSpdHdrPkgName();
587 s[1] = getSpdHdr().getGuidValue();
588 s[2] = getSpdHdrVer();
589 // s[3] = getSpdHdr().getAbstract();
590 s[4] = getSpdHdr().getDescription();
591 s[5] = getSpdHdr().getCopyright();
592 s[6] = getSpdHdrLicense();
593
594 }
595
596 /**
597 Get the number of library class declarations from the size of List
598
599 @return int
600 **/
601 public int getSpdLibClassDeclarationCount() {
602 if (psaRoot.getLibraryClassDeclarations() == null
603 || psaRoot.getLibraryClassDeclarations().getLibraryClassList() == null) {
604 return 0;
605 }
606 return psaRoot.getLibraryClassDeclarations().getLibraryClassList().size();
607 }
608
609 /**
610 Get available library class declaration into String array
611 @param libClass Caller allocated two-dimentional String array
612 **/
613 public void getSpdLibClassDeclarations(String[][] libClass) {
614 if (psaRoot.getLibraryClassDeclarations() == null){
615 return;
616 }
617
618 List<LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass> l = psaRoot.getLibraryClassDeclarations().getLibraryClassList();
619 int i = 0;
620 ListIterator li = l.listIterator();
621 while (li.hasNext()) {
622 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass) li.next();
623 if (lc != null) {
624 libClass[i][0] = lc.getName();
625 libClass[i][1] = lc.getIncludeHeader();
626 libClass[i][2] = lc.getHelpText();
627 // LAH added logic so you cannot set the version unless the GUID is defined.
628 /* LAH do not set now
629 if (lc.getRecommendedInstanceGuid() != null) {
630 libClass[i][3] = lc.getRecommendedInstanceGuid();
631 if (lc.getRecommendedInstanceVersion() != null) {
632 libClass[i][4] = lc.getRecommendedInstanceVersion();
633 }
634 }
635 */
636 if (lc.getSupArchList() != null) {
637 libClass[i][5] = listToString(lc.getSupArchList());
638 }
639 if (lc.getSupModuleList() != null) {
640 libClass[i][6] = listToString(lc.getSupModuleList());
641 }
642
643 }
644
645 i++;
646 }
647
648 }
649
650 /**
651 Get the number of Msa files from the size of List
652
653 @return int
654 **/
655 public int getSpdMsaFileCount() {
656 if (psaRoot.getMsaFiles() == null || psaRoot.getMsaFiles().getFilenameList() == null) {
657 return 0;
658 }
659 return psaRoot.getMsaFiles().getFilenameList().size();
660 }
661
662 /**
663 Get available Msa file into String array
664
665 @param msaFile Caller allocated two-dimentional String array
666 **/
667 public void getSpdMsaFiles(String[][] msaFile) {
668 if (psaRoot.getMsaFiles() == null) {
669 return;
670 }
671 List<String> l = psaRoot.getMsaFiles().getFilenameList();
672 int i = 0;
673 ListIterator li = l.listIterator();
674 while (li.hasNext()) {
675 msaFile[i][0] = (String)li.next();
676
677 i++;
678 }
679 }
680
681 /**
682 Get the number of include header files in PackageHeaders from the size of List
683
684 @return int
685 **/
686 public int getSpdPackageHeaderCount() {
687 if (psaRoot.getPackageHeaders() == null || psaRoot.getPackageHeaders().getIncludePkgHeaderList() == null) {
688 return 0;
689 }
690 return psaRoot.getPackageHeaders().getIncludePkgHeaderList().size();
691 }
692
693 /**
694 Get available package header contents into String array
695
696 @param pkgHeader Caller allocated two-dimentional String array
697 **/
698 public void getSpdPackageHeaders(String[][] pkgHeader) {
699 if (psaRoot.getPackageHeaders() == null) {
700 return;
701 }
702
703 List<PackageHeadersDocument.PackageHeaders.IncludePkgHeader> l = psaRoot.getPackageHeaders().getIncludePkgHeaderList();
704 int i = 0;
705 ListIterator li = l.listIterator();
706 while (li.hasNext()) {
707 PackageHeadersDocument.PackageHeaders.IncludePkgHeader ih = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) li.next();
708 if (ih.getModuleType() != null) {
709 pkgHeader[i][0] = ih.getModuleType().toString();
710 }
711
712 pkgHeader[i][1] = ih.getStringValue();
713 i++;
714 }
715 }
716
717 /**
718 Get the number of GUID declarations from the size of List
719
720 @return int
721 **/
722 public int getSpdGuidDeclarationCount() {
723 if (psaRoot.getGuidDeclarations() == null || psaRoot.getGuidDeclarations().getEntryList() == null) {
724 return 0;
725 }
726 return psaRoot.getGuidDeclarations().getEntryList().size();
727 }
728
729 /**
730 Get available Guid declaration contents into String array
731
732 @param guid Caller allocated two-dimentional String array
733 **/
734 public void getSpdGuidDeclarations(String[][] guid) {
735 if (psaRoot.getGuidDeclarations() == null) {
736 return;
737 }
738
739 List<GuidDeclarationsDocument.GuidDeclarations.Entry> l = psaRoot.getGuidDeclarations().getEntryList();
740 int i = 0;
741 ListIterator li = l.listIterator();
742 while (li.hasNext()) {
743 GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.Entry) li
744 .next();
745 guid[i][0] = e.getName();
746 guid[i][1] = e.getCName();
747 if (e.getGuidValue() != null) {
748 guid[i][2] = e.getGuidValue();
749 }
750 guid[i][3] = e.getHelpText();
751 guid[i][4] = listToString(e.getSupArchList());
752 guid[i][5] = listToString(e.getSupModuleList());
753 guid[i][6] = listToString(e.getGuidTypeList());
754 i++;
755 }
756 }
757
758 /**
759 Get the number of protocol declarations from the size of List
760
761 @return int
762 **/
763 public int getSpdProtocolDeclarationCount() {
764 if (psaRoot.getProtocolDeclarations() == null || psaRoot.getProtocolDeclarations().getEntryList() == null) {
765 return 0;
766 }
767 return psaRoot.getProtocolDeclarations().getEntryList().size();
768 }
769
770 /**
771 Get available protocol declaration contents into String array
772
773 @param protocol Caller allocated two-dimentional String array
774 **/
775 public void getSpdProtocolDeclarations(String[][] protocol) {
776 if (psaRoot.getProtocolDeclarations() == null) {
777 return;
778 }
779
780 List<ProtocolDeclarationsDocument.ProtocolDeclarations.Entry> l = psaRoot.getProtocolDeclarations()
781 .getEntryList();
782 int i = 0;
783 ListIterator li = l.listIterator();
784 while (li.hasNext()) {
785 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) li
786 .next();
787 protocol[i][0] = e.getName();
788 protocol[i][1] = e.getCName();
789 if (e.getGuidValue() != null) {
790 protocol[i][2] = e.getGuidValue();
791 }
792 protocol[i][3] = e.getHelpText();
793 protocol[i][4] = listToString(e.getSupArchList());
794 protocol[i][5] = listToString(e.getSupModuleList());
795 i++;
796 }
797 }
798
799 /**
800 Get the number of Ppi declarations from the size of List
801
802 @return int
803 **/
804 public int getSpdPpiDeclarationCount() {
805 if (psaRoot.getPpiDeclarations() == null || psaRoot.getPpiDeclarations().getEntryList() == null) {
806 return 0;
807 }
808 return psaRoot.getPpiDeclarations().getEntryList().size();
809 }
810
811 /**
812 Get available Ppi declaration contents into String array
813
814 @param ppi Caller allocated two-dimentional String array
815 **/
816 public void getSpdPpiDeclarations(String[][] ppi) {
817 if (psaRoot.getPpiDeclarations() == null) {
818 return;
819 }
820
821 List<PpiDeclarationsDocument.PpiDeclarations.Entry> l = psaRoot.getPpiDeclarations().getEntryList();
822 int i = 0;
823 ListIterator li = l.listIterator();
824 while (li.hasNext()) {
825 PpiDeclarationsDocument.PpiDeclarations.Entry e = (PpiDeclarationsDocument.PpiDeclarations.Entry) li.next();
826 ppi[i][0] = e.getName();
827 ppi[i][1] = e.getCName();
828 if (e.getGuidValue() != null) {
829 ppi[i][2] = e.getGuidValue();
830 }
831 ppi[i][3] = e.getHelpText();
832 ppi[i][4] = listToString(e.getSupArchList());
833 ppi[i][5] = listToString(e.getSupModuleList());
834
835 i++;
836 }
837 }
838
839 /**
840 Get the number of Pcd definitions from the size of List
841
842 @return int
843 **/
844 public int getSpdPcdDefinitionCount() {
845 if (psaRoot.getPcdDeclarations() == null || psaRoot.getPcdDeclarations().getPcdEntryList() == null) {
846 return 0;
847 }
848 return psaRoot.getPcdDeclarations().getPcdEntryList().size();
849 }
850
851 /**
852 Get available Pcd definition contents into String array
853
854 @param pcd Caller allocated two-dimentional String array
855 **/
856 public void getSpdPcdDefinitions(String[][] pcd, String pcdUsage[][]) {
857 if (psaRoot.getPcdDeclarations() == null) {
858 return;
859 }
860
861 List<PcdDeclarationsDocument.PcdDeclarations.PcdEntry> l = psaRoot.getPcdDeclarations().getPcdEntryList();
862 int i = 0;
863 while (i < l.size()) {
864 PcdDeclarationsDocument.PcdDeclarations.PcdEntry e = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)l.get(i);
865 pcd[i][0] = e.getCName();
866 pcd[i][1] = e.getToken() + "";
867 pcd[i][2] = e.getTokenSpaceGuidCName();
868 if (e.getDatumType() != null) {
869 pcd[i][3] = e.getDatumType().toString();
870 }
871 pcd[i][4] = e.getDefaultValue()+"";
872 pcd[i][5] = e.getHelpText();
873 String archList = listToString(e.getSupArchList());
874 if (archList != null) {
875 pcd[i][6] = archList;
876 }
877 String modTypeList = listToString(e.getSupModuleList());
878 if (modTypeList != null) {
879 pcd[i][7] = modTypeList;
880 }
881
882 int j = 0;
883 while (j < e.getValidUsage().size() && j < 5) {
884 pcdUsage[i][j] = (String)e.getValidUsage().get(j);
885 ++j;
886 }
887 i++;
888 }
889 }
890
891 /**
892 Save the processed xml contents to file
893
894 @param spdFile The file to save xml contents
895 @throws IOException Exceptions during file operation
896 **/
897 public void saveAs(File spdFile) throws IOException {
898
899 XmlOptions options = new XmlOptions();
900
901 options.setCharacterEncoding("UTF-8");
902 options.setSavePrettyPrint();
903 options.setSavePrettyPrintIndent(2);
904 try {
905 psad.save(spdFile, options);
906 } catch (IOException e) {
907 e.printStackTrace();
908 }
909
910 }
911
912 /**
913 Generate SpdHeader contents using parameters passed in.
914
915 @param pkgName PackageName
916 @param pkgGuid Guid
917 @param pkgVer Version
918 @param pkgAbs Abstract
919 @param pkgDes Description
920 @param pkgCpRight Copyright
921 @param pkgLicense License
922 @param pkgCreateDate Created
923 @param pkgUpdateDate Updated
924 @param pkgURL URL
925 @param pkgType PackageType
926 @param pkgRdOnly ReadOnly
927 @param pkgRePkg RePackage
928 @param pkgSpec Reserved
929 @param pkgOutDir Reserved
930 **/
931 public void genSpdHeader(String pkgName, String pkgGuid, String pkgVer, String pkgAbs, String pkgDes,
932 String pkgCpRight, String pkgLicense, String pkgCreateDate, String pkgUpdateDate,
933 String pkgURL, String pkgType, String pkgRdOnly, String pkgRePkg, String pkgSpec,
934 String pkgOutDir) {
935 if (getSpdHdr() == null) {
936 spdHdr = psaRoot.addNewSpdHeader();
937 }
938
939 setSpdHdrPkgName(pkgName);
940 setSpdHdrGuidValue(pkgGuid);
941 setSpdHdrVer(pkgVer);
942 setSpdHdrAbs(pkgAbs);
943 setSpdHdrDescription(pkgDes);
944 setSpdHdrCopyright(pkgCpRight);
945 setSpdHdrLicense(pkgLicense);
946
947
948 setSpdHdrSpec(pkgSpec);
949 }
950
951 /**
952 Generate library class declaration element using parameters passed in
953
954 @param libClassBaseName LibraryClass element value
955 @param libClassUsage Reserved
956 @param incHdrFileName IncludeHeader element value
957 @param incHdrAttribGuid Reserved
958 @param incHdrAttribArch Reserved
959 @param incHdrAttribPath Reserved
960 @param incHdrAttribClass Reserved
961 @param incHdrAttribVer Reserved
962 @param incHdrAttribOverrideID Reserved
963 @param incHdrAttribModuleType Reserved
964 **/
965 public void genSpdLibClassDeclarations(String libClassBaseName, String instanceUsage, String incHdrFileName,
966 String help, String incHdrAttribArch, String incHdrAttribPath,
967 String incHdrAttribClass, String incHdrAttribVer,
968 String incHdrAttribOverrideID, String incHdrAttribModuleType) {
969 if (getSpdLibClassDeclarations() == null) {
970 spdLibClassDeclarations = psaRoot.addNewLibraryClassDeclarations();
971 }
972 //
973 // add contents under LibraryClassDeclarations tag
974 //
975 setSpdLibClassDeclaration(libClassBaseName, instanceUsage, incHdrFileName, help, incHdrAttribArch,
976 incHdrAttribPath, incHdrAttribClass, incHdrAttribVer, incHdrAttribOverrideID,
977 incHdrAttribModuleType, spdLibClassDeclarations);
978 }
979
980 /**
981 Set library class declaration contents under parent tag
982
983 @param clsName LibraryClass element value
984 @param clsUsage Reserved
985 @param hdrFile IncludeHeader element value
986 @param hdrAttribGuid Reserved
987 @param hdrAttribArch Reserved
988 @param hdrAttribPath Reserved
989 @param hdrAttribClass Reserved
990 @param hdrAttribVer Reserved
991 @param hdrAttribOverID Reserved
992 @param hdrAttribModType Reserved
993 @param parent The tag under which library class declaration goes to
994 **/
995 public void setSpdLibClassDeclaration(String clsName, String clsUsage, String hdrFile, String help,
996 String hdrAttribArch, String hdrAttribPath, String hdrAttribClass,
997 String instanceVer, String hdrAttribOverID, String hdrAttribModType,
998 XmlObject parent) {
999
1000 setSpdLibraryClass(clsName, hdrFile, help, clsUsage, instanceVer, hdrAttribArch, hdrAttribModType, parent);
1001
1002 }
1003
1004 /**
1005 Set the contents of LibraryClass under parent element
1006
1007 @param clsName LibraryClass element value
1008 @param clsUsage Reserved
1009 @param parent The tag under which library class declaration goes to
1010 **/
1011 public void setSpdLibraryClass(String clsName, String clsIncludeFile, String help, String clsUsage, String instanceVer, String hdrAttribArch, String hdrAttribModType, XmlObject parent) {
1012 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = ((LibraryClassDeclarationsDocument.LibraryClassDeclarations) parent).addNewLibraryClass();
1013 lc.setName(clsName);
1014 lc.setIncludeHeader(clsIncludeFile);
1015 lc.setHelpText(help);
1016 // LAH added logic so you cannot set the version unless the GUID is defined.
1017
1018 if (clsUsage != null) {
1019 lc.setRecommendedInstanceGuid(clsUsage);
1020 if (instanceVer != null) {
1021 lc.setRecommendedInstanceVersion(instanceVer);
1022 }
1023 }
1024 else {
1025 if (lc.isSetRecommendedInstanceGuid()) {
1026 lc.unsetRecommendedInstanceGuid();
1027 }
1028 if (lc.isSetRecommendedInstanceVersion()) {
1029 lc.unsetRecommendedInstanceVersion();
1030 }
1031 }
1032
1033 if (hdrAttribArch != null) {
1034 lc.setSupArchList(stringToList(hdrAttribArch));
1035 } else {
1036 if (lc.isSetSupArchList()) {
1037 lc.unsetSupArchList();
1038 }
1039 }
1040
1041 if (hdrAttribModType != null) {
1042 lc.setSupModuleList(stringToList(hdrAttribModType));
1043 } else {
1044 if (lc.isSetSupModuleList()) {
1045 lc.unsetSupModuleList();
1046 }
1047 }
1048
1049 }
1050
1051 /**
1052 Set contents of IncludeHeader under parent element
1053
1054 @param modType Reserved
1055 @param hdrFile IncludeHeader element value
1056 @param hdrAttribGuid Reserved
1057 @param hdrAttribArch Reserved
1058 @param hdrAttribPath Reserved
1059 @param hdrAttribClass Reserved
1060 @param hdrAttribVer Reserved
1061 @param hdrAttribOverID Reserved
1062 @param parent The tag under which library class declaration goes to
1063 **/
1064 public void setSpdIncludeHeader(String modType, String hdrFile, String hdrAttribGuid, String hdrAttribArch,
1065 String hdrAttribPath, String hdrAttribClass, String hdrAttribVer,
1066 String hdrAttribOverID, XmlObject parent) {
1067
1068 if (parent instanceof LibraryClassDeclarationsDocument.LibraryClassDeclarations) {
1069 } else if (parent instanceof PackageHeadersDocument.PackageHeaders) {
1070 PackageHeadersDocument.PackageHeaders.IncludePkgHeader ih = null;
1071 ih = ((PackageHeadersDocument.PackageHeaders) parent).addNewIncludePkgHeader();
1072 ih.setStringValue(hdrFile);
1073 ih.setModuleType(ModuleTypeDef.Enum.forString(modType));
1074 } else {
1075 return;
1076 }
1077
1078 if (hdrAttribGuid != null) {
1079 }
1080 if (hdrAttribPath != null) {
1081 }
1082 if (hdrAttribClass != null) {
1083 }
1084 if (hdrAttribVer != null) {
1085 }
1086 if (hdrAttribOverID != null) {
1087 }
1088
1089 }
1090
1091 /**
1092 Generate MsaFile element.
1093
1094 @param msaFileName MsaFile element value
1095 @param archType Reserved
1096 **/
1097 public void genSpdMsaFiles(String msaFileName, String moduleName, String ver, String guid) {
1098 if (getSpdMsaFiles() == null) {
1099 spdMsaFiles = psaRoot.addNewMsaFiles();
1100 }
1101 setSpdMsaFile(msaFileName, moduleName, ver, guid, spdMsaFiles);
1102
1103 }
1104
1105 /**
1106 Set MsaFile contents under parent element.
1107
1108 @param msaFileName MsaFile element value
1109 @param parent Element under which MsaFile goes to
1110 **/
1111 public void setSpdMsaFile(String msaFileName, String moduleName, String ver, String guid, XmlObject parent) {
1112 MsaFilesDocument.MsaFiles f = (MsaFilesDocument.MsaFiles)parent;
1113 f.addNewFilename().setStringValue(msaFileName);
1114 // f.setFilename(msaFileName);
1115 // f.setModuleName(moduleName);
1116 // f.setModuleVersion(ver);
1117 // f.setModuleGuid(guid);
1118 }
1119
1120 /**
1121 Generate PackageHeader element using parameters passed in.
1122
1123 @param ModHdrModType ModuleType attribute of IncludeHeader element
1124 @param hdrFile IncludeHeader element value
1125 @param hdrAttribGuid Reserved
1126 @param hdrAttribArch Reserved
1127 @param hdrAttribPath Reserved
1128 @param hdrAttribClass Reserved
1129 @param hdrAttribVer Reserved
1130 @param hdrAttribOverID Reserved
1131 **/
1132 public void genSpdModuleHeaders(String ModHdrModType, String hdrFile, String hdrAttribGuid, String hdrAttribArch,
1133 String hdrAttribPath, String hdrAttribClass, String hdrAttribVer,
1134 String hdrAttribOverID) {
1135 if (getSpdModHdrs() == null) {
1136 spdModHdrs = psaRoot.addNewPackageHeaders();
1137 }
1138
1139 //
1140 // add IncludeHeader under PackageHeaders element
1141 //
1142 setSpdIncludeHeader(ModHdrModType, hdrFile, hdrAttribGuid, hdrAttribArch, hdrAttribPath, hdrAttribClass,
1143 hdrAttribVer, hdrAttribOverID, spdModHdrs);
1144 }
1145
1146 /**
1147 Generate GUID declaration element using parameters passed in.
1148
1149 @param guidDeclEntryName Name attribute of Entry element
1150 @param guidDeclCName CName element value
1151 @param guidDeclGuid Guid element value
1152 @param guidDeclFeatureFlag Reserved
1153 **/
1154 public void genSpdGuidDeclarations(String guidDeclEntryName, String guidDeclCName, String guidDeclGuid,
1155 String guidDeclHelp, Vector<String> archList, Vector<String> modTypeList,
1156 Vector<String> guidTypeList) {
1157 if (getSpdGuidDeclarations() == null) {
1158 spdGuidDeclarations = psaRoot.addNewGuidDeclarations();
1159 }
1160
1161 setSpdEntry(guidDeclEntryName, guidDeclCName, guidDeclGuid, guidDeclHelp, archList, modTypeList, guidTypeList, spdGuidDeclarations);
1162 }
1163
1164 /**
1165 Generate protocol declaration element using parameters passed in.
1166
1167 @param protocolDeclEntryName Name attribute of Entry element
1168 @param protocolDeclCName CName element value
1169 @param protocolDeclGuid Guid element value
1170 @param protocolDeclFeatureFlag Reserved
1171 **/
1172 public void genSpdProtocolDeclarations(String protocolDeclEntryName, String protocolDeclCName,
1173 String protocolDeclGuid, String protocolDeclFeatureFlag,
1174 Vector<String> archList, Vector<String> modTypeList) {
1175 if (getSpdProtocolDeclarations() == null) {
1176 spdProtocolDeclarations = psaRoot.addNewProtocolDeclarations();
1177 }
1178
1179 setSpdEntry(protocolDeclEntryName, protocolDeclCName, protocolDeclGuid, protocolDeclFeatureFlag,
1180 archList, modTypeList, null, spdProtocolDeclarations);
1181 }
1182
1183 /**
1184 Generate PPI declaration element using parameters passed in.
1185
1186 @param ppiDeclEntryName Name attribute of Entry element
1187 @param ppiDeclCName CName element value
1188 @param ppiDeclGuid Guid element value
1189 @param ppiDeclFeatureFlag Reserved
1190 **/
1191 public void genSpdPpiDeclarations(String ppiDeclEntryName, String ppiDeclCName, String ppiDeclGuid,
1192 String ppiDeclFeatureFlag, Vector<String> archList, Vector<String> modTypeList) {
1193 if (getSpdPpiDeclarations() == null) {
1194 spdPpiDeclarations = psaRoot.addNewPpiDeclarations();
1195 }
1196
1197 setSpdEntry(ppiDeclEntryName, ppiDeclCName, ppiDeclGuid, ppiDeclFeatureFlag, archList, modTypeList, null, spdPpiDeclarations);
1198 }
1199
1200 /**
1201 Set Entry contents using parameters passed in
1202
1203 @param entryName Name attribute of Entry element
1204 @param cName CName element value
1205 @param guid Guid element value
1206 @param featureFlag Reserved
1207 @param parent The tag under which Entry element goes to
1208 **/
1209 public void setSpdEntry(String entryName, String cName, String guid, String help,
1210 Vector<String> archList, Vector<String> modTypeList,
1211 Vector<String> guidTypeList, XmlObject parent) {
1212
1213 if (parent instanceof GuidDeclarationsDocument.GuidDeclarations) {
1214 GuidDeclarationsDocument.GuidDeclarations.Entry e = ((GuidDeclarations) parent).addNewEntry();
1215 e.setName(entryName);
1216 e.setCName(cName);
1217 e.setGuidValue(guid);
1218 e.setHelpText(help);
1219 if (guidTypeList != null) {
1220 e.setGuidTypeList(guidTypeList);
1221 }
1222 else{
1223 if (e.isSetGuidTypeList()) {
1224 e.unsetGuidTypeList();
1225 }
1226 }
1227 if (archList != null) {
1228 e.setSupArchList(archList);
1229 }
1230 else {
1231 if (e.isSetSupArchList()) {
1232 e.unsetSupArchList();
1233 }
1234 }
1235 if (modTypeList != null){
1236 e.setSupModuleList(modTypeList);
1237 }
1238 else {
1239 if (e.isSetSupModuleList()) {
1240 e.unsetSupModuleList();
1241 }
1242 }
1243
1244 return;
1245 }
1246 if (parent instanceof ProtocolDeclarationsDocument.ProtocolDeclarations) {
1247 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry pe = ((ProtocolDeclarationsDocument.ProtocolDeclarations) parent)
1248 .addNewEntry();
1249 pe.setName(entryName);
1250 pe.setCName(cName);
1251 pe.setGuidValue(guid);
1252 pe.setHelpText(help);
1253 if (archList != null) {
1254 pe.setSupArchList(archList);
1255 }
1256 else {
1257 if (pe.isSetSupArchList()) {
1258 pe.unsetSupArchList();
1259 }
1260 }
1261 if (modTypeList != null){
1262 pe.setSupModuleList(modTypeList);
1263 }
1264 else {
1265 if (pe.isSetSupModuleList()) {
1266 pe.unsetSupModuleList();
1267 }
1268 }
1269
1270 return;
1271 }
1272 if (parent instanceof PpiDeclarationsDocument.PpiDeclarations) {
1273 PpiDeclarationsDocument.PpiDeclarations.Entry ppe = ((PpiDeclarationsDocument.PpiDeclarations) parent)
1274 .addNewEntry();
1275 ppe.setName(entryName);
1276 ppe.setCName(cName);
1277 ppe.setGuidValue(guid);
1278 ppe.setHelpText(help);
1279 if (archList != null) {
1280 ppe.setSupArchList(archList);
1281 }
1282 else {
1283 if (ppe.isSetSupArchList()) {
1284 ppe.unsetSupArchList();
1285 }
1286 }
1287 if (modTypeList != null){
1288 ppe.setSupModuleList(modTypeList);
1289 }
1290 else {
1291 if (ppe.isSetSupModuleList()) {
1292 ppe.unsetSupModuleList();
1293 }
1294 }
1295
1296 return;
1297 }
1298
1299 return;
1300
1301 }
1302
1303 /**
1304 Generate Pcd definition using parameters passed in
1305
1306 @param pcdItemTypes ItemType attribute of PcdEntry element
1307 @param cName C_Name element value
1308 @param token Token element value
1309 @param dataType DatumType element value
1310 @param skuEnable Reserved
1311 @param sku Reserved
1312 @param maxSku Reserved
1313 @param hiiEnable Reserved
1314 @param varGuid Reserved
1315 @param varName Reserved
1316 @param defaultString DefaultString element value
1317 **/
1318 public void genSpdPcdDefinitions(String cName, String token, String dataType, String pcdItemTypes,
1319 String spaceGuid, String defaultString, String help, String archList,
1320 String modTypeList) {
1321 if (getSpdPcdDefinitions() == null) {
1322 spdPcdDefinitions = psaRoot.addNewPcdDeclarations();
1323 }
1324
1325 setSpdPcdEntry(pcdItemTypes, cName, token, dataType, spaceGuid, help,
1326 defaultString, archList, modTypeList, spdPcdDefinitions);
1327 }
1328
1329 /**
1330 Set Pcd entry contents under parent tag
1331
1332 @param pcdItemTypes ItemType attribute of PcdEntry element
1333 @param cName C_Name element value
1334 @param token Token element value
1335 @param dataType DatumType element value
1336 @param spaceGuid Reserved
1337 @param help Reserved
1338 @param defaultString DefaultString element value
1339 @param parent Tag under which PcdEntry goes to
1340 **/
1341 public void setSpdPcdEntry(String pcdItemTypes, String cName, String token, String dataType, String spaceGuid, String help,
1342 String defaultString, String archList, String modTypeList, XmlObject parent) {
1343
1344 PcdDeclarationsDocument.PcdDeclarations.PcdEntry pe = ((PcdDeclarationsDocument.PcdDeclarations) parent).addNewPcdEntry();
1345
1346 //ToDo: maybe multiple types in, need parse pcdItemTypes.
1347 String usage[] = pcdItemTypes.split("( )+");
1348 List<String> l = new ArrayList<String>();
1349 for (int i = 0; i < usage.length; ++i) {
1350 l.add(usage[i]);
1351 }
1352 pe.setValidUsage(l);
1353 pe.setCName(cName);
1354 pe.setToken(token);
1355 pe.setDatumType(PcdDataTypes.Enum.forString(dataType));
1356 pe.setDefaultValue(defaultString);
1357 pe.setTokenSpaceGuidCName(spaceGuid);
1358 pe.setHelpText(help);
1359 if (archList != null){
1360 pe.setSupArchList(stringToList(archList));
1361 } else {
1362 if (pe.isSetSupArchList()) {
1363 pe.unsetSupArchList();
1364 }
1365 }
1366 if (modTypeList != null){
1367 pe.setSupModuleList(stringToList(modTypeList));
1368 } else {
1369 if (pe.isSetSupModuleList()) {
1370 pe.unsetSupModuleList();
1371 }
1372 }
1373 }
1374
1375 /**
1376 Get PpiDeclarations element
1377
1378 @return PpiDeclarationsDocument.PpiDeclarations
1379 **/
1380 public PpiDeclarationsDocument.PpiDeclarations getSpdPpiDeclarations() {
1381 if (spdPpiDeclarations == null) {
1382 spdPpiDeclarations = psaRoot.getPpiDeclarations();
1383 }
1384 return spdPpiDeclarations;
1385 }
1386
1387 /**
1388 Get ProtocolDeclarations element
1389
1390 @return ProtocolDeclarationsDocument.ProtocolDeclarations
1391 **/
1392 public ProtocolDeclarationsDocument.ProtocolDeclarations getSpdProtocolDeclarations() {
1393 if (spdProtocolDeclarations == null) {
1394 spdProtocolDeclarations = psaRoot.getProtocolDeclarations();
1395 }
1396 return spdProtocolDeclarations;
1397 }
1398
1399 /**
1400 Get GuidDeclarations element
1401
1402 @return GuidDeclarationsDocument.GuidDeclarations
1403 **/
1404 public GuidDeclarationsDocument.GuidDeclarations getSpdGuidDeclarations() {
1405 if (spdGuidDeclarations == null) {
1406 spdGuidDeclarations = psaRoot.getGuidDeclarations();
1407 }
1408 return spdGuidDeclarations;
1409 }
1410
1411 /**
1412 Get PcdDefinitions element
1413
1414 @return PcdDefinitionsDocument.PcdDefinitions
1415 **/
1416 public PcdDeclarationsDocument.PcdDeclarations getSpdPcdDefinitions() {
1417 if (spdPcdDefinitions == null) {
1418 spdPcdDefinitions = psaRoot.getPcdDeclarations();
1419 }
1420 return spdPcdDefinitions;
1421 }
1422
1423 /**
1424 Get PackageHeaders element
1425
1426 @return PackageHeadersDocument.PackageHeaders
1427 **/
1428 public PackageHeadersDocument.PackageHeaders getSpdModHdrs() {
1429 if (spdModHdrs == null) {
1430 spdModHdrs = psaRoot.getPackageHeaders();
1431 }
1432 return spdModHdrs;
1433 }
1434
1435 /**
1436 Get MsaFiles element
1437
1438 @return MsaFilesDocument.MsaFiles
1439 **/
1440 public MsaFilesDocument.MsaFiles getSpdMsaFiles() {
1441 if (spdMsaFiles == null) {
1442 spdMsaFiles = psaRoot.getMsaFiles();
1443 }
1444 return spdMsaFiles;
1445 }
1446
1447 /**
1448 Get LibraryClassDeclarations element
1449
1450 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
1451 **/
1452 public LibraryClassDeclarationsDocument.LibraryClassDeclarations getSpdLibClassDeclarations() {
1453 if (spdLibClassDeclarations == null) {
1454 spdLibClassDeclarations = psaRoot.getLibraryClassDeclarations();
1455 }
1456 return spdLibClassDeclarations;
1457 }
1458
1459 public PackageDefinitionsDocument.PackageDefinitions getSpdPkgDefs() {
1460 if (spdPkgDefs == null) {
1461 spdPkgDefs = psaRoot.addNewPackageDefinitions();
1462 }
1463 return spdPkgDefs;
1464 }
1465 /**
1466 Get SpdHeader element
1467
1468 @return SpdHeaderDocument.SpdHeader
1469 **/
1470 public SpdHeaderDocument.SpdHeader getSpdHdr() {
1471 if (spdHdr == null) {
1472 spdHdr = psaRoot.addNewSpdHeader();
1473 }
1474 return spdHdr;
1475 }
1476
1477 /**
1478 Set value to Guid element
1479
1480 @param guid The value set to Guid element
1481 **/
1482 public void setSpdHdrGuidValue(String guid) {
1483 getSpdHdr().setGuidValue(guid);
1484 }
1485
1486 /**
1487 Get Version element under SpdHdr
1488
1489 @return String
1490 **/
1491 public String getSpdHdrVer() {
1492 return getSpdHdr().getVersion();
1493 }
1494
1495 /**
1496 Set value to Version element
1497
1498 @param ver The value set to Version element
1499 **/
1500 public void setSpdHdrVer(String ver) {
1501 getSpdHdr().setVersion(ver);
1502 }
1503
1504 public String getSpdHdrAbs(){
1505 return getSpdHdr().getAbstract();
1506
1507 }
1508
1509 /**
1510 Set value to Abstract element
1511
1512 @param abs The value set to Abstract element
1513 **/
1514 public void setSpdHdrAbs(String abs) {
1515
1516 getSpdHdr().setAbstract(abs);
1517 }
1518
1519 public String getSpdHdrDescription(){
1520 return getSpdHdr().getDescription();
1521 }
1522 /**
1523 Set value to Description element
1524
1525 @param des The value set to Description element
1526 **/
1527 public void setSpdHdrDescription(String des) {
1528 getSpdHdr().setDescription(des);
1529 }
1530
1531 public String getSpdHdrCopyright(){
1532 return getSpdHdr().getCopyright();
1533 }
1534 /**
1535 Set value to Copyright element
1536
1537 @param cpRit The value set to Copyright element
1538 **/
1539 public void setSpdHdrCopyright(String cpRit) {
1540
1541 getSpdHdr().setCopyright(cpRit);
1542
1543 }
1544 /**
1545 Get License element under SpdHdr
1546
1547 @return String
1548 **/
1549 public String getSpdHdrLicense() {
1550 if (getSpdHdr().getLicense() != null) {
1551 return getSpdHdr().getLicense().getStringValue();
1552 }
1553 return null;
1554 }
1555
1556 /**
1557 Set value to License element
1558
1559 @param license The value set to License element
1560 **/
1561 public void setSpdHdrLicense(String license) {
1562 if (getSpdHdr().getLicense() == null){
1563 getSpdHdr().addNewLicense().setStringValue(license);
1564 }
1565 else {
1566 getSpdHdr().getLicense().setStringValue(license);
1567 }
1568 }
1569
1570 public String getSpdHdrUrl(){
1571 if (getSpdHdr().getLicense() != null) {
1572 return getSpdHdr().getLicense().getURL();
1573 }
1574 return null;
1575 }
1576
1577 public void setSpdHdrUrl(String url){
1578 getSpdHdr().getLicense().setURL(url);
1579 }
1580
1581 /**
1582 Get PackageName element under SpdHdr
1583
1584 @return String
1585 **/
1586 public String getSpdHdrPkgName() {
1587
1588 return getSpdHdr().getPackageName();
1589 }
1590
1591 /**
1592 Set value to PackageName element
1593
1594 @param pkgName The value set to PackageName element
1595 **/
1596 public void setSpdHdrPkgName(String pkgName) {
1597 getSpdHdr().setPackageName(pkgName);
1598 }
1599
1600 public String getSpdHdrGuidValue(){
1601 return getSpdHdr().getGuidValue();
1602 }
1603
1604 /**
1605 Reserved method
1606
1607 @return SpecificationDocument.Specification
1608 **/
1609 public String getSpdHdrSpec() {
1610 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1611 // return getSpdHdr().getSpecification();
1612 }
1613
1614 /**
1615 Reserved method
1616
1617 @param spec
1618 **/
1619 public void setSpdHdrSpec(String spec) {
1620 spec = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1621 getSpdHdr().setSpecification(spec);
1622
1623 }
1624
1625 public String getSpdPkgDefsRdOnly(){
1626 return getSpdPkgDefs().getReadOnly() + "";
1627 }
1628 /**
1629 Set value to ReadOnly element
1630
1631 @param rdOnly The value set to ReadOnly element
1632 **/
1633 public void setSpdPkgDefsRdOnly(String rdOnly) {
1634
1635 getSpdPkgDefs().setReadOnly(new Boolean(rdOnly));
1636 }
1637
1638 public String getSpdPkgDefsRePkg(){
1639 return getSpdPkgDefs().getRePackage() + "";
1640 }
1641 /**
1642 Set value to RePackage element
1643
1644 @param rePkg The value set to RePackage element
1645 **/
1646 public void setSpdPkgDefsRePkg(String rePkg) {
1647
1648 getSpdPkgDefs().setRePackage(new Boolean(rePkg));
1649 }
1650
1651 /**
1652 Set value to URL element
1653
1654 @param url The value set to URL element
1655 **/
1656 // public void setSpdHdrURL(String url) {
1657 // getSpdHdr().setURL(url);
1658 // }
1659
1660 /**
1661 Get xml file
1662
1663 @return File
1664 **/
1665 public File getFile() {
1666 return file;
1667 }
1668
1669 /**
1670 Set file
1671
1672 @param file File with xml format
1673 **/
1674 public void setFile(File file) {
1675 this.file = file;
1676 }
1677
1678 private List<String> stringToList(String s){
1679 if (s == null || s.length() == 0) {
1680 return null;
1681 }
1682 Vector<String> al = new Vector<String>();
1683 String[] sArray = s.split(" ");
1684 for(int i = 0; i < sArray.length; ++i){
1685 al.add(sArray[i]);
1686 }
1687 return al;
1688 }
1689
1690 private String listToString(List l) {
1691 if (l == null) {
1692 return null;
1693 }
1694 String s = " ";
1695 ListIterator li = l.listIterator();
1696 while(li.hasNext()) {
1697 s += li.next();
1698 s += " ";
1699 }
1700 return s.trim();
1701 }
1702
1703 }