]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdFileContents.java
e856cfce4c01f917a8218ed41436ba2863ba9c5e
[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 e.setGuidTypeList(guidTypeList);
1220 e.setSupArchList(archList);
1221 e.setSupModuleList(modTypeList);
1222 // if (guidTypeList != null && guidTypeList.size() > 0) {
1223 // e.setGuidTypeList(new ArrayList<String>(guidTypeList));
1224 // }
1225 // if (archList != null && archList.size() > 0){
1226 // e.setSupArchList(new ArrayList<String>(archList));
1227 // }
1228 // if (modTypeList != null && modTypeList.size() > 0) {
1229 // e.setSupModuleList(new ArrayList<String>(modTypeList));
1230 // }
1231 return;
1232 }
1233 if (parent instanceof ProtocolDeclarationsDocument.ProtocolDeclarations) {
1234 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry pe = ((ProtocolDeclarationsDocument.ProtocolDeclarations) parent)
1235 .addNewEntry();
1236 pe.setName(entryName);
1237 pe.setCName(cName);
1238 pe.setGuidValue(guid);
1239 pe.setHelpText(help);
1240 pe.setSupArchList(archList);
1241 pe.setSupModuleList(modTypeList);
1242 // if (archList != null && archList.size() > 0){
1243 // pe.setSupArchList(new ArrayList<String>(archList));
1244 // }
1245 // if (modTypeList != null && modTypeList.size() > 0) {
1246 // pe.setSupModuleList(new ArrayList<String>(modTypeList));
1247 // }
1248 return;
1249 }
1250 if (parent instanceof PpiDeclarationsDocument.PpiDeclarations) {
1251 PpiDeclarationsDocument.PpiDeclarations.Entry ppe = ((PpiDeclarationsDocument.PpiDeclarations) parent)
1252 .addNewEntry();
1253 ppe.setName(entryName);
1254 ppe.setCName(cName);
1255 ppe.setGuidValue(guid);
1256 ppe.setHelpText(help);
1257 ppe.setSupArchList(archList);
1258 ppe.setSupModuleList(modTypeList);
1259 // if (archList != null && archList.size() > 0){
1260 // ppe.setSupArchList(new ArrayList<String>(archList));
1261 // }
1262 // if (archList != null && modTypeList.size() > 0) {
1263 // ppe.setSupModuleList(new ArrayList<String>(modTypeList));
1264 // }
1265 return;
1266 }
1267
1268 return;
1269
1270 }
1271
1272 /**
1273 Generate Pcd definition using parameters passed in
1274
1275 @param pcdItemTypes ItemType attribute of PcdEntry element
1276 @param cName C_Name element value
1277 @param token Token element value
1278 @param dataType DatumType element value
1279 @param skuEnable Reserved
1280 @param sku Reserved
1281 @param maxSku Reserved
1282 @param hiiEnable Reserved
1283 @param varGuid Reserved
1284 @param varName Reserved
1285 @param defaultString DefaultString element value
1286 **/
1287 public void genSpdPcdDefinitions(String cName, String token, String dataType, String pcdItemTypes,
1288 String spaceGuid, String defaultString, String help, String archList,
1289 String modTypeList) {
1290 if (getSpdPcdDefinitions() == null) {
1291 spdPcdDefinitions = psaRoot.addNewPcdDeclarations();
1292 }
1293
1294 setSpdPcdEntry(pcdItemTypes, cName, token, dataType, spaceGuid, help,
1295 defaultString, archList, modTypeList, spdPcdDefinitions);
1296 }
1297
1298 /**
1299 Set Pcd entry contents under parent tag
1300
1301 @param pcdItemTypes ItemType attribute of PcdEntry element
1302 @param cName C_Name element value
1303 @param token Token element value
1304 @param dataType DatumType element value
1305 @param spaceGuid Reserved
1306 @param help Reserved
1307 @param defaultString DefaultString element value
1308 @param parent Tag under which PcdEntry goes to
1309 **/
1310 public void setSpdPcdEntry(String pcdItemTypes, String cName, String token, String dataType, String spaceGuid, String help,
1311 String defaultString, String archList, String modTypeList, XmlObject parent) {
1312
1313 PcdDeclarationsDocument.PcdDeclarations.PcdEntry pe = ((PcdDeclarationsDocument.PcdDeclarations) parent).addNewPcdEntry();
1314
1315 //ToDo: maybe multiple types in, need parse pcdItemTypes.
1316 String usage[] = pcdItemTypes.split("( )+");
1317 List<String> l = new ArrayList<String>();
1318 for (int i = 0; i < usage.length; ++i) {
1319 l.add(usage[i]);
1320 }
1321 pe.setValidUsage(l);
1322 pe.setCName(cName);
1323 pe.setToken(token);
1324 pe.setDatumType(PcdDataTypes.Enum.forString(dataType));
1325 pe.setDefaultValue(defaultString);
1326 pe.setTokenSpaceGuidCName(spaceGuid);
1327 pe.setHelpText(help);
1328 if (archList != null){
1329 pe.setSupArchList(stringToList(archList));
1330 } else {
1331 if (pe.isSetSupArchList()) {
1332 pe.unsetSupArchList();
1333 }
1334 }
1335 if (modTypeList != null){
1336 pe.setSupModuleList(stringToList(modTypeList));
1337 } else {
1338 if (pe.isSetSupModuleList()) {
1339 pe.unsetSupModuleList();
1340 }
1341 }
1342 }
1343
1344 /**
1345 Get PpiDeclarations element
1346
1347 @return PpiDeclarationsDocument.PpiDeclarations
1348 **/
1349 public PpiDeclarationsDocument.PpiDeclarations getSpdPpiDeclarations() {
1350 if (spdPpiDeclarations == null) {
1351 spdPpiDeclarations = psaRoot.getPpiDeclarations();
1352 }
1353 return spdPpiDeclarations;
1354 }
1355
1356 /**
1357 Get ProtocolDeclarations element
1358
1359 @return ProtocolDeclarationsDocument.ProtocolDeclarations
1360 **/
1361 public ProtocolDeclarationsDocument.ProtocolDeclarations getSpdProtocolDeclarations() {
1362 if (spdProtocolDeclarations == null) {
1363 spdProtocolDeclarations = psaRoot.getProtocolDeclarations();
1364 }
1365 return spdProtocolDeclarations;
1366 }
1367
1368 /**
1369 Get GuidDeclarations element
1370
1371 @return GuidDeclarationsDocument.GuidDeclarations
1372 **/
1373 public GuidDeclarationsDocument.GuidDeclarations getSpdGuidDeclarations() {
1374 if (spdGuidDeclarations == null) {
1375 spdGuidDeclarations = psaRoot.getGuidDeclarations();
1376 }
1377 return spdGuidDeclarations;
1378 }
1379
1380 /**
1381 Get PcdDefinitions element
1382
1383 @return PcdDefinitionsDocument.PcdDefinitions
1384 **/
1385 public PcdDeclarationsDocument.PcdDeclarations getSpdPcdDefinitions() {
1386 if (spdPcdDefinitions == null) {
1387 spdPcdDefinitions = psaRoot.getPcdDeclarations();
1388 }
1389 return spdPcdDefinitions;
1390 }
1391
1392 /**
1393 Get PackageHeaders element
1394
1395 @return PackageHeadersDocument.PackageHeaders
1396 **/
1397 public PackageHeadersDocument.PackageHeaders getSpdModHdrs() {
1398 if (spdModHdrs == null) {
1399 spdModHdrs = psaRoot.getPackageHeaders();
1400 }
1401 return spdModHdrs;
1402 }
1403
1404 /**
1405 Get MsaFiles element
1406
1407 @return MsaFilesDocument.MsaFiles
1408 **/
1409 public MsaFilesDocument.MsaFiles getSpdMsaFiles() {
1410 if (spdMsaFiles == null) {
1411 spdMsaFiles = psaRoot.getMsaFiles();
1412 }
1413 return spdMsaFiles;
1414 }
1415
1416 /**
1417 Get LibraryClassDeclarations element
1418
1419 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
1420 **/
1421 public LibraryClassDeclarationsDocument.LibraryClassDeclarations getSpdLibClassDeclarations() {
1422 if (spdLibClassDeclarations == null) {
1423 spdLibClassDeclarations = psaRoot.getLibraryClassDeclarations();
1424 }
1425 return spdLibClassDeclarations;
1426 }
1427
1428 public PackageDefinitionsDocument.PackageDefinitions getSpdPkgDefs() {
1429 if (spdPkgDefs == null) {
1430 spdPkgDefs = psaRoot.addNewPackageDefinitions();
1431 }
1432 return spdPkgDefs;
1433 }
1434 /**
1435 Get SpdHeader element
1436
1437 @return SpdHeaderDocument.SpdHeader
1438 **/
1439 public SpdHeaderDocument.SpdHeader getSpdHdr() {
1440 if (spdHdr == null) {
1441 spdHdr = psaRoot.addNewSpdHeader();
1442 }
1443 return spdHdr;
1444 }
1445
1446 /**
1447 Set value to Guid element
1448
1449 @param guid The value set to Guid element
1450 **/
1451 public void setSpdHdrGuidValue(String guid) {
1452 getSpdHdr().setGuidValue(guid);
1453 }
1454
1455 /**
1456 Get Version element under SpdHdr
1457
1458 @return String
1459 **/
1460 public String getSpdHdrVer() {
1461 return getSpdHdr().getVersion();
1462 }
1463
1464 /**
1465 Set value to Version element
1466
1467 @param ver The value set to Version element
1468 **/
1469 public void setSpdHdrVer(String ver) {
1470 getSpdHdr().setVersion(ver);
1471 }
1472
1473 public String getSpdHdrAbs(){
1474 return getSpdHdr().getAbstract();
1475
1476 }
1477
1478 /**
1479 Set value to Abstract element
1480
1481 @param abs The value set to Abstract element
1482 **/
1483 public void setSpdHdrAbs(String abs) {
1484
1485 getSpdHdr().setAbstract(abs);
1486 }
1487
1488 public String getSpdHdrDescription(){
1489 return getSpdHdr().getDescription();
1490 }
1491 /**
1492 Set value to Description element
1493
1494 @param des The value set to Description element
1495 **/
1496 public void setSpdHdrDescription(String des) {
1497 getSpdHdr().setDescription(des);
1498 }
1499
1500 public String getSpdHdrCopyright(){
1501 return getSpdHdr().getCopyright();
1502 }
1503 /**
1504 Set value to Copyright element
1505
1506 @param cpRit The value set to Copyright element
1507 **/
1508 public void setSpdHdrCopyright(String cpRit) {
1509
1510 getSpdHdr().setCopyright(cpRit);
1511
1512 }
1513 /**
1514 Get License element under SpdHdr
1515
1516 @return String
1517 **/
1518 public String getSpdHdrLicense() {
1519 if (getSpdHdr().getLicense() != null) {
1520 return getSpdHdr().getLicense().getStringValue();
1521 }
1522 return null;
1523 }
1524
1525 /**
1526 Set value to License element
1527
1528 @param license The value set to License element
1529 **/
1530 public void setSpdHdrLicense(String license) {
1531 if (getSpdHdr().getLicense() == null){
1532 getSpdHdr().addNewLicense().setStringValue(license);
1533 }
1534 else {
1535 getSpdHdr().getLicense().setStringValue(license);
1536 }
1537 }
1538
1539 public String getSpdHdrUrl(){
1540 if (getSpdHdr().getLicense() != null) {
1541 return getSpdHdr().getLicense().getURL();
1542 }
1543 return null;
1544 }
1545
1546 public void setSpdHdrUrl(String url){
1547 getSpdHdr().getLicense().setURL(url);
1548 }
1549
1550 /**
1551 Get PackageName element under SpdHdr
1552
1553 @return String
1554 **/
1555 public String getSpdHdrPkgName() {
1556
1557 return getSpdHdr().getPackageName();
1558 }
1559
1560 /**
1561 Set value to PackageName element
1562
1563 @param pkgName The value set to PackageName element
1564 **/
1565 public void setSpdHdrPkgName(String pkgName) {
1566 getSpdHdr().setPackageName(pkgName);
1567 }
1568
1569 public String getSpdHdrGuidValue(){
1570 return getSpdHdr().getGuidValue();
1571 }
1572
1573 /**
1574 Reserved method
1575
1576 @return SpecificationDocument.Specification
1577 **/
1578 public String getSpdHdrSpec() {
1579 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1580 // return getSpdHdr().getSpecification();
1581 }
1582
1583 /**
1584 Reserved method
1585
1586 @param spec
1587 **/
1588 public void setSpdHdrSpec(String spec) {
1589 spec = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1590 getSpdHdr().setSpecification(spec);
1591
1592 }
1593
1594 public String getSpdPkgDefsRdOnly(){
1595 return getSpdPkgDefs().getReadOnly() + "";
1596 }
1597 /**
1598 Set value to ReadOnly element
1599
1600 @param rdOnly The value set to ReadOnly element
1601 **/
1602 public void setSpdPkgDefsRdOnly(String rdOnly) {
1603
1604 getSpdPkgDefs().setReadOnly(new Boolean(rdOnly));
1605 }
1606
1607 public String getSpdPkgDefsRePkg(){
1608 return getSpdPkgDefs().getRePackage() + "";
1609 }
1610 /**
1611 Set value to RePackage element
1612
1613 @param rePkg The value set to RePackage element
1614 **/
1615 public void setSpdPkgDefsRePkg(String rePkg) {
1616
1617 getSpdPkgDefs().setRePackage(new Boolean(rePkg));
1618 }
1619
1620 /**
1621 Set value to URL element
1622
1623 @param url The value set to URL element
1624 **/
1625 // public void setSpdHdrURL(String url) {
1626 // getSpdHdr().setURL(url);
1627 // }
1628
1629 /**
1630 Get xml file
1631
1632 @return File
1633 **/
1634 public File getFile() {
1635 return file;
1636 }
1637
1638 /**
1639 Set file
1640
1641 @param file File with xml format
1642 **/
1643 public void setFile(File file) {
1644 this.file = file;
1645 }
1646
1647 private List<String> stringToList(String s){
1648 if (s == null || s.length() == 0) {
1649 return null;
1650 }
1651 Vector<String> al = new Vector<String>();
1652 String[] sArray = s.split(" ");
1653 for(int i = 0; i < sArray.length; ++i){
1654 al.add(sArray[i]);
1655 }
1656 return al;
1657 }
1658
1659 private String listToString(List l) {
1660 if (l == null) {
1661 return null;
1662 }
1663 String s = " ";
1664 ListIterator li = l.listIterator();
1665 while(li.hasNext()) {
1666 s += li.next();
1667 s += " ";
1668 }
1669 return s.trim();
1670 }
1671
1672 }