]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdFileContents.java
Added some checks to see if the attributes were set - clears up some warning messages...
[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 }
352
353 if (stringToList(hdrAttribArch) != null){
354 lc.setSupArchList(stringToList(hdrAttribArch));
355 } else {
356 if (lc.isSetSupArchList()) {
357 lc.unsetSupArchList();
358 }
359 }
360 if (stringToList(hdrAttribModType) != null){
361 lc.setSupModuleList(stringToList(hdrAttribModType));
362 } else {
363 if (lc.isSetSupModuleList()) {
364 lc.unsetSupModuleList();
365 }
366 }
367 }
368
369 cursor.dispose();
370 }
371
372 public void updateSpdMsaFile(int i, String msaFile, String mName, String v, String g){
373 XmlObject o = psaRoot.getMsaFiles();
374 if (o == null)
375 return;
376
377 XmlCursor cursor = o.newCursor();
378 if (cursor.toFirstChild()) {
379 for (int j = 0; j < i; ++j) {
380 cursor.toNextSibling();
381 }
382 cursor.setTextValue(msaFile);
383
384 }
385
386 cursor.dispose();
387 }
388
389 public void updateSpdGuidDecl(int i, String name, String cName, String guid, String hlp, String archList,
390 String modTypeList, String guidTypeList){
391 XmlObject o = psaRoot.getGuidDeclarations();
392 if (o == null){
393 return;
394 }
395
396 XmlCursor cursor = o.newCursor();
397 if (cursor.toFirstChild()) {
398 for (int j = 0; j < i; ++j) {
399 cursor.toNextSibling();
400 }
401 GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.Entry)cursor.getObject();
402 e.setName(name);
403 e.setCName(cName);
404 e.setGuidValue(guid);
405 e.setHelpText(hlp);
406 if (stringToList(guidTypeList) != null) {
407 e.setGuidTypeList(stringToList(guidTypeList));
408 }
409 else{
410 if (e.isSetGuidTypeList()) {
411 e.unsetGuidTypeList();
412 }
413 }
414 if (stringToList(archList) != null){
415 e.setSupArchList(stringToList(archList));
416 }
417 else{
418 if (e.isSetSupArchList()) {
419 e.unsetSupArchList();
420 }
421 }
422 if (stringToList(modTypeList) != null) {
423 e.setSupModuleList(stringToList(modTypeList));
424 }
425 else{
426 if (e.isSetSupModuleList()) {
427 e.unsetSupModuleList();
428 }
429 }
430
431 }
432 cursor.dispose();
433 }
434
435 public void updateSpdPpiDecl(int i, String name, String cName, String guid, String hlp, String archList,
436 String modTypeList){
437 XmlObject o = psaRoot.getPpiDeclarations();
438 if (o == null){
439 return;
440 }
441
442 XmlCursor cursor = o.newCursor();
443 if (cursor.toFirstChild()) {
444 for (int j = 0; j < i; ++j) {
445 cursor.toNextSibling();
446 }
447 PpiDeclarationsDocument.PpiDeclarations.Entry e = (PpiDeclarationsDocument.PpiDeclarations.Entry)cursor.getObject();
448 e.setName(name);
449 e.setCName(cName);
450 e.setGuidValue(guid);
451 e.setHelpText(hlp);
452 if (stringToList(archList) != null){
453 e.setSupArchList(stringToList(archList));
454 }
455 else{
456 if (e.isSetSupArchList()) {
457 e.unsetSupArchList();
458 }
459 }
460 if (stringToList(modTypeList) != null) {
461 e.setSupModuleList(stringToList(modTypeList));
462 }
463 else{
464 if (e.isSetSupModuleList()) {
465 e.unsetSupModuleList();
466 }
467 }
468 }
469 cursor.dispose();
470 }
471
472 public void updateSpdProtocolDecl(int i, String name, String cName, String guid, String hlp, String archList,
473 String modTypeList){
474 XmlObject o = psaRoot.getProtocolDeclarations();
475 if (o == null){
476 return;
477 }
478
479 XmlCursor cursor = o.newCursor();
480 if (cursor.toFirstChild()) {
481 for (int j = 0; j < i; ++j) {
482 cursor.toNextSibling();
483 }
484 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry)cursor.getObject();
485 e.setName(name);
486 e.setCName(cName);
487 e.setGuidValue(guid);
488 e.setHelpText(hlp);
489 if (stringToList(archList) != null){
490 e.setSupArchList(stringToList(archList));
491 }
492 else{
493 if (e.isSetSupArchList()) {
494 e.unsetSupArchList();
495 }
496 }
497 if (stringToList(modTypeList) != null) {
498 e.setSupModuleList(stringToList(modTypeList));
499 }
500 else{
501 if (e.isSetSupModuleList()) {
502 e.unsetSupModuleList();
503 }
504 }
505 }
506 cursor.dispose();
507 }
508
509 public void updateSpdPkgHdr(int i, String pkgName, String hdrName){
510 XmlObject o = psaRoot.getPackageHeaders();
511 if (o == null){
512 return;
513 }
514
515 XmlCursor cursor = o.newCursor();
516 if (cursor.toFirstChild()) {
517 for (int j = 0; j < i; ++j) {
518 cursor.toNextSibling();
519 }
520
521 PackageHeadersDocument.PackageHeaders.IncludePkgHeader iph = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader)cursor.getObject();
522 iph.setModuleType(ModuleTypeDef.Enum.forString(pkgName));
523 iph.setStringValue(hdrName);
524 }
525 cursor.dispose();
526 }
527
528 public void updateSpdPcdDefinition(int i, String cName, String token, String dataType, String pcdItemTypes,
529 String spaceGuid, String defaultString, String help, String archList, String modTypeList){
530 XmlObject o = psaRoot.getPcdDeclarations();
531 if (o == null)
532 return;
533 XmlCursor cursor = o.newCursor();
534 if (cursor.toFirstChild()) {
535 for (int j = 0; j < i; ++j) {
536 cursor.toNextSibling();
537 }
538 PcdDeclarationsDocument.PcdDeclarations.PcdEntry e = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)cursor.getObject();
539 e.setCName(cName);
540 e.setToken(token);
541 e.setDatumType(PcdDataTypes.Enum.forString(dataType));
542 if (pcdItemTypes != null && pcdItemTypes.length() > 0) {
543 String usage[] = pcdItemTypes.split("( )+");
544 List<String> l = new ArrayList<String>();
545 for (int k = 0; k < usage.length; ++k) {
546 l.add(usage[k]);
547 }
548 e.setValidUsage(l);
549 }
550
551 e.setTokenSpaceGuidCName(spaceGuid);
552 e.setDefaultValue(defaultString);
553 e.setHelpText(help);
554 if (archList != null && archList.length() > 0){
555 e.setSupArchList(stringToList(archList));
556 }
557 if (modTypeList != null && modTypeList.length() > 0){
558 e.setSupModuleList(stringToList(modTypeList));
559 }
560 }
561 cursor.dispose();
562 }
563 /**
564 Get spd file header contents into String array
565
566 @param s Caller allocated String array
567 **/
568 public void getSpdHdrDetails(String[] s) {
569 if (getSpdHdr() == null) {
570 spdHdr = psaRoot.addNewSpdHeader();
571 }
572 s[0] = getSpdHdrPkgName();
573 s[1] = getSpdHdr().getGuidValue();
574 s[2] = getSpdHdrVer();
575 // s[3] = getSpdHdr().getAbstract();
576 s[4] = getSpdHdr().getDescription();
577 s[5] = getSpdHdr().getCopyright();
578 s[6] = getSpdHdrLicense();
579
580 }
581
582 /**
583 Get the number of library class declarations from the size of List
584
585 @return int
586 **/
587 public int getSpdLibClassDeclarationCount() {
588 if (psaRoot.getLibraryClassDeclarations() == null
589 || psaRoot.getLibraryClassDeclarations().getLibraryClassList() == null) {
590 return 0;
591 }
592 return psaRoot.getLibraryClassDeclarations().getLibraryClassList().size();
593 }
594
595 /**
596 Get available library class declaration into String array
597 @param libClass Caller allocated two-dimentional String array
598 **/
599 public void getSpdLibClassDeclarations(String[][] libClass) {
600 if (psaRoot.getLibraryClassDeclarations() == null){
601 return;
602 }
603
604 List<LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass> l = psaRoot.getLibraryClassDeclarations().getLibraryClassList();
605 int i = 0;
606 ListIterator li = l.listIterator();
607 while (li.hasNext()) {
608 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass) li.next();
609 if (lc != null) {
610 libClass[i][0] = lc.getName();
611 libClass[i][1] = lc.getIncludeHeader();
612 libClass[i][2] = lc.getHelpText();
613 // LAH added logic so you cannot set the version unless the GUID is defined.
614 /* LAH do not set now
615 if (lc.getRecommendedInstanceGuid() != null) {
616 libClass[i][3] = lc.getRecommendedInstanceGuid();
617 if (lc.getRecommendedInstanceVersion() != null) {
618 libClass[i][4] = lc.getRecommendedInstanceVersion();
619 }
620 }
621 */
622 if (lc.getSupArchList() != null) {
623 libClass[i][5] = listToString(lc.getSupArchList());
624 }
625 if (lc.getSupModuleList() != null) {
626 libClass[i][6] = listToString(lc.getSupModuleList());
627 }
628
629 }
630
631 i++;
632 }
633
634 }
635
636 /**
637 Get the number of Msa files from the size of List
638
639 @return int
640 **/
641 public int getSpdMsaFileCount() {
642 if (psaRoot.getMsaFiles() == null || psaRoot.getMsaFiles().getFilenameList() == null) {
643 return 0;
644 }
645 return psaRoot.getMsaFiles().getFilenameList().size();
646 }
647
648 /**
649 Get available Msa file into String array
650
651 @param msaFile Caller allocated two-dimentional String array
652 **/
653 public void getSpdMsaFiles(String[][] msaFile) {
654 if (psaRoot.getMsaFiles() == null) {
655 return;
656 }
657 List<String> l = psaRoot.getMsaFiles().getFilenameList();
658 int i = 0;
659 ListIterator li = l.listIterator();
660 while (li.hasNext()) {
661 msaFile[i][0] = (String)li.next();
662
663 i++;
664 }
665 }
666
667 /**
668 Get the number of include header files in PackageHeaders from the size of List
669
670 @return int
671 **/
672 public int getSpdPackageHeaderCount() {
673 if (psaRoot.getPackageHeaders() == null || psaRoot.getPackageHeaders().getIncludePkgHeaderList() == null) {
674 return 0;
675 }
676 return psaRoot.getPackageHeaders().getIncludePkgHeaderList().size();
677 }
678
679 /**
680 Get available package header contents into String array
681
682 @param pkgHeader Caller allocated two-dimentional String array
683 **/
684 public void getSpdPackageHeaders(String[][] pkgHeader) {
685 if (psaRoot.getPackageHeaders() == null) {
686 return;
687 }
688
689 List<PackageHeadersDocument.PackageHeaders.IncludePkgHeader> l = psaRoot.getPackageHeaders().getIncludePkgHeaderList();
690 int i = 0;
691 ListIterator li = l.listIterator();
692 while (li.hasNext()) {
693 PackageHeadersDocument.PackageHeaders.IncludePkgHeader ih = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) li.next();
694 if (ih.getModuleType() != null) {
695 pkgHeader[i][0] = ih.getModuleType().toString();
696 }
697
698 pkgHeader[i][1] = ih.getStringValue();
699 i++;
700 }
701 }
702
703 /**
704 Get the number of GUID declarations from the size of List
705
706 @return int
707 **/
708 public int getSpdGuidDeclarationCount() {
709 if (psaRoot.getGuidDeclarations() == null || psaRoot.getGuidDeclarations().getEntryList() == null) {
710 return 0;
711 }
712 return psaRoot.getGuidDeclarations().getEntryList().size();
713 }
714
715 /**
716 Get available Guid declaration contents into String array
717
718 @param guid Caller allocated two-dimentional String array
719 **/
720 public void getSpdGuidDeclarations(String[][] guid) {
721 if (psaRoot.getGuidDeclarations() == null) {
722 return;
723 }
724
725 List<GuidDeclarationsDocument.GuidDeclarations.Entry> l = psaRoot.getGuidDeclarations().getEntryList();
726 int i = 0;
727 ListIterator li = l.listIterator();
728 while (li.hasNext()) {
729 GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.Entry) li
730 .next();
731 guid[i][0] = e.getName();
732 guid[i][1] = e.getCName();
733 if (e.getGuidValue() != null) {
734 guid[i][2] = e.getGuidValue();
735 }
736 guid[i][3] = e.getHelpText();
737 guid[i][4] = listToString(e.getSupArchList());
738 guid[i][5] = listToString(e.getSupModuleList());
739 guid[i][6] = listToString(e.getGuidTypeList());
740 i++;
741 }
742 }
743
744 /**
745 Get the number of protocol declarations from the size of List
746
747 @return int
748 **/
749 public int getSpdProtocolDeclarationCount() {
750 if (psaRoot.getProtocolDeclarations() == null || psaRoot.getProtocolDeclarations().getEntryList() == null) {
751 return 0;
752 }
753 return psaRoot.getProtocolDeclarations().getEntryList().size();
754 }
755
756 /**
757 Get available protocol declaration contents into String array
758
759 @param protocol Caller allocated two-dimentional String array
760 **/
761 public void getSpdProtocolDeclarations(String[][] protocol) {
762 if (psaRoot.getProtocolDeclarations() == null) {
763 return;
764 }
765
766 List<ProtocolDeclarationsDocument.ProtocolDeclarations.Entry> l = psaRoot.getProtocolDeclarations()
767 .getEntryList();
768 int i = 0;
769 ListIterator li = l.listIterator();
770 while (li.hasNext()) {
771 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) li
772 .next();
773 protocol[i][0] = e.getName();
774 protocol[i][1] = e.getCName();
775 if (e.getGuidValue() != null) {
776 protocol[i][2] = e.getGuidValue();
777 }
778 protocol[i][3] = e.getHelpText();
779 protocol[i][4] = listToString(e.getSupArchList());
780 protocol[i][5] = listToString(e.getSupModuleList());
781 i++;
782 }
783 }
784
785 /**
786 Get the number of Ppi declarations from the size of List
787
788 @return int
789 **/
790 public int getSpdPpiDeclarationCount() {
791 if (psaRoot.getPpiDeclarations() == null || psaRoot.getPpiDeclarations().getEntryList() == null) {
792 return 0;
793 }
794 return psaRoot.getPpiDeclarations().getEntryList().size();
795 }
796
797 /**
798 Get available Ppi declaration contents into String array
799
800 @param ppi Caller allocated two-dimentional String array
801 **/
802 public void getSpdPpiDeclarations(String[][] ppi) {
803 if (psaRoot.getPpiDeclarations() == null) {
804 return;
805 }
806
807 List<PpiDeclarationsDocument.PpiDeclarations.Entry> l = psaRoot.getPpiDeclarations().getEntryList();
808 int i = 0;
809 ListIterator li = l.listIterator();
810 while (li.hasNext()) {
811 PpiDeclarationsDocument.PpiDeclarations.Entry e = (PpiDeclarationsDocument.PpiDeclarations.Entry) li.next();
812 ppi[i][0] = e.getName();
813 ppi[i][1] = e.getCName();
814 if (e.getGuidValue() != null) {
815 ppi[i][2] = e.getGuidValue();
816 }
817 ppi[i][3] = e.getHelpText();
818 ppi[i][4] = listToString(e.getSupArchList());
819 ppi[i][5] = listToString(e.getSupModuleList());
820
821 i++;
822 }
823 }
824
825 /**
826 Get the number of Pcd definitions from the size of List
827
828 @return int
829 **/
830 public int getSpdPcdDefinitionCount() {
831 if (psaRoot.getPcdDeclarations() == null || psaRoot.getPcdDeclarations().getPcdEntryList() == null) {
832 return 0;
833 }
834 return psaRoot.getPcdDeclarations().getPcdEntryList().size();
835 }
836
837 /**
838 Get available Pcd definition contents into String array
839
840 @param pcd Caller allocated two-dimentional String array
841 **/
842 public void getSpdPcdDefinitions(String[][] pcd, String pcdUsage[][]) {
843 if (psaRoot.getPcdDeclarations() == null) {
844 return;
845 }
846
847 List<PcdDeclarationsDocument.PcdDeclarations.PcdEntry> l = psaRoot.getPcdDeclarations().getPcdEntryList();
848 int i = 0;
849 while (i < l.size()) {
850 PcdDeclarationsDocument.PcdDeclarations.PcdEntry e = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)l.get(i);
851 pcd[i][0] = e.getCName();
852 pcd[i][1] = e.getToken() + "";
853 pcd[i][2] = e.getTokenSpaceGuidCName();
854 if (e.getDatumType() != null) {
855 pcd[i][3] = e.getDatumType().toString();
856 }
857 pcd[i][4] = e.getDefaultValue()+"";
858 pcd[i][5] = e.getHelpText();
859 String archList = listToString(e.getSupArchList());
860 if (archList != null) {
861 pcd[i][6] = archList;
862 }
863 String modTypeList = listToString(e.getSupModuleList());
864 if (modTypeList != null) {
865 pcd[i][7] = modTypeList;
866 }
867
868 int j = 0;
869 while (j < e.getValidUsage().size() && j < 5) {
870 pcdUsage[i][j] = (String)e.getValidUsage().get(j);
871 ++j;
872 }
873 i++;
874 }
875 }
876
877 /**
878 Save the processed xml contents to file
879
880 @param spdFile The file to save xml contents
881 @throws IOException Exceptions during file operation
882 **/
883 public void saveAs(File spdFile) throws IOException {
884
885 XmlOptions options = new XmlOptions();
886
887 options.setCharacterEncoding("UTF-8");
888 options.setSavePrettyPrint();
889 options.setSavePrettyPrintIndent(2);
890 try {
891 psad.save(spdFile, options);
892 } catch (IOException e) {
893 e.printStackTrace();
894 }
895
896 }
897
898 /**
899 Generate SpdHeader contents using parameters passed in.
900
901 @param pkgName PackageName
902 @param pkgGuid Guid
903 @param pkgVer Version
904 @param pkgAbs Abstract
905 @param pkgDes Description
906 @param pkgCpRight Copyright
907 @param pkgLicense License
908 @param pkgCreateDate Created
909 @param pkgUpdateDate Updated
910 @param pkgURL URL
911 @param pkgType PackageType
912 @param pkgRdOnly ReadOnly
913 @param pkgRePkg RePackage
914 @param pkgSpec Reserved
915 @param pkgOutDir Reserved
916 **/
917 public void genSpdHeader(String pkgName, String pkgGuid, String pkgVer, String pkgAbs, String pkgDes,
918 String pkgCpRight, String pkgLicense, String pkgCreateDate, String pkgUpdateDate,
919 String pkgURL, String pkgType, String pkgRdOnly, String pkgRePkg, String pkgSpec,
920 String pkgOutDir) {
921 if (getSpdHdr() == null) {
922 spdHdr = psaRoot.addNewSpdHeader();
923 }
924
925 setSpdHdrPkgName(pkgName);
926 setSpdHdrGuidValue(pkgGuid);
927 setSpdHdrVer(pkgVer);
928 setSpdHdrAbs(pkgAbs);
929 setSpdHdrDescription(pkgDes);
930 setSpdHdrCopyright(pkgCpRight);
931 setSpdHdrLicense(pkgLicense);
932
933
934 setSpdHdrSpec(pkgSpec);
935 }
936
937 /**
938 Generate library class declaration element using parameters passed in
939
940 @param libClassBaseName LibraryClass element value
941 @param libClassUsage Reserved
942 @param incHdrFileName IncludeHeader element value
943 @param incHdrAttribGuid Reserved
944 @param incHdrAttribArch Reserved
945 @param incHdrAttribPath Reserved
946 @param incHdrAttribClass Reserved
947 @param incHdrAttribVer Reserved
948 @param incHdrAttribOverrideID Reserved
949 @param incHdrAttribModuleType Reserved
950 **/
951 public void genSpdLibClassDeclarations(String libClassBaseName, String instanceUsage, String incHdrFileName,
952 String help, String incHdrAttribArch, String incHdrAttribPath,
953 String incHdrAttribClass, String incHdrAttribVer,
954 String incHdrAttribOverrideID, String incHdrAttribModuleType) {
955 if (getSpdLibClassDeclarations() == null) {
956 spdLibClassDeclarations = psaRoot.addNewLibraryClassDeclarations();
957 }
958 //
959 // add contents under LibraryClassDeclarations tag
960 //
961 setSpdLibClassDeclaration(libClassBaseName, instanceUsage, incHdrFileName, help, incHdrAttribArch,
962 incHdrAttribPath, incHdrAttribClass, incHdrAttribVer, incHdrAttribOverrideID,
963 incHdrAttribModuleType, spdLibClassDeclarations);
964 }
965
966 /**
967 Set library class declaration contents under parent tag
968
969 @param clsName LibraryClass element value
970 @param clsUsage Reserved
971 @param hdrFile IncludeHeader element value
972 @param hdrAttribGuid Reserved
973 @param hdrAttribArch Reserved
974 @param hdrAttribPath Reserved
975 @param hdrAttribClass Reserved
976 @param hdrAttribVer Reserved
977 @param hdrAttribOverID Reserved
978 @param hdrAttribModType Reserved
979 @param parent The tag under which library class declaration goes to
980 **/
981 public void setSpdLibClassDeclaration(String clsName, String clsUsage, String hdrFile, String help,
982 String hdrAttribArch, String hdrAttribPath, String hdrAttribClass,
983 String instanceVer, String hdrAttribOverID, String hdrAttribModType,
984 XmlObject parent) {
985
986 setSpdLibraryClass(clsName, hdrFile, help, clsUsage, instanceVer, hdrAttribArch, hdrAttribModType, parent);
987
988 }
989
990 /**
991 Set the contents of LibraryClass under parent element
992
993 @param clsName LibraryClass element value
994 @param clsUsage Reserved
995 @param parent The tag under which library class declaration goes to
996 **/
997 public void setSpdLibraryClass(String clsName, String clsIncludeFile, String help, String clsUsage, String instanceVer, String hdrAttribArch, String hdrAttribModType, XmlObject parent) {
998 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = ((LibraryClassDeclarationsDocument.LibraryClassDeclarations) parent).addNewLibraryClass();
999 lc.setName(clsName);
1000 lc.setIncludeHeader(clsIncludeFile);
1001 lc.setHelpText(help);
1002 // LAH added logic so you cannot set the version unless the GUID is defined.
1003 /* LAH
1004 if (clsUsage != null) {
1005 lc.setRecommendedInstanceGuid(clsUsage);
1006 if (instanceVer != null) {
1007 lc.setRecommendedInstanceVersion(instanceVer);
1008 }
1009 }
1010 */
1011 if (hdrAttribArch != null) {
1012 lc.setSupArchList(stringToList(hdrAttribArch));
1013 } else {
1014 if (lc.isSetSupArchList()) {
1015 lc.unsetSupArchList();
1016 }
1017 }
1018
1019 if (hdrAttribModType != null) {
1020 lc.setSupModuleList(stringToList(hdrAttribModType));
1021 } else {
1022 if (lc.isSetSupModuleList()) {
1023 lc.unsetSupModuleList();
1024 }
1025 }
1026
1027 }
1028
1029 /**
1030 Set contents of IncludeHeader under parent element
1031
1032 @param modType Reserved
1033 @param hdrFile IncludeHeader element value
1034 @param hdrAttribGuid Reserved
1035 @param hdrAttribArch Reserved
1036 @param hdrAttribPath Reserved
1037 @param hdrAttribClass Reserved
1038 @param hdrAttribVer Reserved
1039 @param hdrAttribOverID Reserved
1040 @param parent The tag under which library class declaration goes to
1041 **/
1042 public void setSpdIncludeHeader(String modType, String hdrFile, String hdrAttribGuid, String hdrAttribArch,
1043 String hdrAttribPath, String hdrAttribClass, String hdrAttribVer,
1044 String hdrAttribOverID, XmlObject parent) {
1045
1046 if (parent instanceof LibraryClassDeclarationsDocument.LibraryClassDeclarations) {
1047 } else if (parent instanceof PackageHeadersDocument.PackageHeaders) {
1048 PackageHeadersDocument.PackageHeaders.IncludePkgHeader ih = null;
1049 ih = ((PackageHeadersDocument.PackageHeaders) parent).addNewIncludePkgHeader();
1050 ih.setStringValue(hdrFile);
1051 ih.setModuleType(ModuleTypeDef.Enum.forString(modType));
1052 } else {
1053 return;
1054 }
1055
1056 if (hdrAttribGuid != null) {
1057 }
1058 if (hdrAttribPath != null) {
1059 }
1060 if (hdrAttribClass != null) {
1061 }
1062 if (hdrAttribVer != null) {
1063 }
1064 if (hdrAttribOverID != null) {
1065 }
1066
1067 }
1068
1069 /**
1070 Generate MsaFile element.
1071
1072 @param msaFileName MsaFile element value
1073 @param archType Reserved
1074 **/
1075 public void genSpdMsaFiles(String msaFileName, String moduleName, String ver, String guid) {
1076 if (getSpdMsaFiles() == null) {
1077 spdMsaFiles = psaRoot.addNewMsaFiles();
1078 }
1079 setSpdMsaFile(msaFileName, moduleName, ver, guid, spdMsaFiles);
1080
1081 }
1082
1083 /**
1084 Set MsaFile contents under parent element.
1085
1086 @param msaFileName MsaFile element value
1087 @param parent Element under which MsaFile goes to
1088 **/
1089 public void setSpdMsaFile(String msaFileName, String moduleName, String ver, String guid, XmlObject parent) {
1090 MsaFilesDocument.MsaFiles f = (MsaFilesDocument.MsaFiles)parent;
1091 f.addNewFilename().setStringValue(msaFileName);
1092 // f.setFilename(msaFileName);
1093 // f.setModuleName(moduleName);
1094 // f.setModuleVersion(ver);
1095 // f.setModuleGuid(guid);
1096 }
1097
1098 /**
1099 Generate PackageHeader element using parameters passed in.
1100
1101 @param ModHdrModType ModuleType attribute of IncludeHeader element
1102 @param hdrFile IncludeHeader element value
1103 @param hdrAttribGuid Reserved
1104 @param hdrAttribArch Reserved
1105 @param hdrAttribPath Reserved
1106 @param hdrAttribClass Reserved
1107 @param hdrAttribVer Reserved
1108 @param hdrAttribOverID Reserved
1109 **/
1110 public void genSpdModuleHeaders(String ModHdrModType, String hdrFile, String hdrAttribGuid, String hdrAttribArch,
1111 String hdrAttribPath, String hdrAttribClass, String hdrAttribVer,
1112 String hdrAttribOverID) {
1113 if (getSpdModHdrs() == null) {
1114 spdModHdrs = psaRoot.addNewPackageHeaders();
1115 }
1116
1117 //
1118 // add IncludeHeader under PackageHeaders element
1119 //
1120 setSpdIncludeHeader(ModHdrModType, hdrFile, hdrAttribGuid, hdrAttribArch, hdrAttribPath, hdrAttribClass,
1121 hdrAttribVer, hdrAttribOverID, spdModHdrs);
1122 }
1123
1124 /**
1125 Generate GUID declaration element using parameters passed in.
1126
1127 @param guidDeclEntryName Name attribute of Entry element
1128 @param guidDeclCName CName element value
1129 @param guidDeclGuid Guid element value
1130 @param guidDeclFeatureFlag Reserved
1131 **/
1132 public void genSpdGuidDeclarations(String guidDeclEntryName, String guidDeclCName, String guidDeclGuid,
1133 String guidDeclHelp, Vector<String> archList, Vector<String> modTypeList,
1134 Vector<String> guidTypeList) {
1135 if (getSpdGuidDeclarations() == null) {
1136 spdGuidDeclarations = psaRoot.addNewGuidDeclarations();
1137 }
1138
1139 setSpdEntry(guidDeclEntryName, guidDeclCName, guidDeclGuid, guidDeclHelp, archList, modTypeList, guidTypeList, spdGuidDeclarations);
1140 }
1141
1142 /**
1143 Generate protocol declaration element using parameters passed in.
1144
1145 @param protocolDeclEntryName Name attribute of Entry element
1146 @param protocolDeclCName CName element value
1147 @param protocolDeclGuid Guid element value
1148 @param protocolDeclFeatureFlag Reserved
1149 **/
1150 public void genSpdProtocolDeclarations(String protocolDeclEntryName, String protocolDeclCName,
1151 String protocolDeclGuid, String protocolDeclFeatureFlag,
1152 Vector<String> archList, Vector<String> modTypeList) {
1153 if (getSpdProtocolDeclarations() == null) {
1154 spdProtocolDeclarations = psaRoot.addNewProtocolDeclarations();
1155 }
1156
1157 setSpdEntry(protocolDeclEntryName, protocolDeclCName, protocolDeclGuid, protocolDeclFeatureFlag,
1158 archList, modTypeList, null, spdProtocolDeclarations);
1159 }
1160
1161 /**
1162 Generate PPI declaration element using parameters passed in.
1163
1164 @param ppiDeclEntryName Name attribute of Entry element
1165 @param ppiDeclCName CName element value
1166 @param ppiDeclGuid Guid element value
1167 @param ppiDeclFeatureFlag Reserved
1168 **/
1169 public void genSpdPpiDeclarations(String ppiDeclEntryName, String ppiDeclCName, String ppiDeclGuid,
1170 String ppiDeclFeatureFlag, Vector<String> archList, Vector<String> modTypeList) {
1171 if (getSpdPpiDeclarations() == null) {
1172 spdPpiDeclarations = psaRoot.addNewPpiDeclarations();
1173 }
1174
1175 setSpdEntry(ppiDeclEntryName, ppiDeclCName, ppiDeclGuid, ppiDeclFeatureFlag, archList, modTypeList, null, spdPpiDeclarations);
1176 }
1177
1178 /**
1179 Set Entry contents using parameters passed in
1180
1181 @param entryName Name attribute of Entry element
1182 @param cName CName element value
1183 @param guid Guid element value
1184 @param featureFlag Reserved
1185 @param parent The tag under which Entry element goes to
1186 **/
1187 public void setSpdEntry(String entryName, String cName, String guid, String help,
1188 Vector<String> archList, Vector<String> modTypeList,
1189 Vector<String> guidTypeList, XmlObject parent) {
1190
1191 if (parent instanceof GuidDeclarationsDocument.GuidDeclarations) {
1192 GuidDeclarationsDocument.GuidDeclarations.Entry e = ((GuidDeclarations) parent).addNewEntry();
1193 e.setName(entryName);
1194 e.setCName(cName);
1195 e.setGuidValue(guid);
1196 e.setHelpText(help);
1197 e.setGuidTypeList(guidTypeList);
1198 e.setSupArchList(archList);
1199 e.setSupModuleList(modTypeList);
1200 // if (guidTypeList != null && guidTypeList.size() > 0) {
1201 // e.setGuidTypeList(new ArrayList<String>(guidTypeList));
1202 // }
1203 // if (archList != null && archList.size() > 0){
1204 // e.setSupArchList(new ArrayList<String>(archList));
1205 // }
1206 // if (modTypeList != null && modTypeList.size() > 0) {
1207 // e.setSupModuleList(new ArrayList<String>(modTypeList));
1208 // }
1209 return;
1210 }
1211 if (parent instanceof ProtocolDeclarationsDocument.ProtocolDeclarations) {
1212 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry pe = ((ProtocolDeclarationsDocument.ProtocolDeclarations) parent)
1213 .addNewEntry();
1214 pe.setName(entryName);
1215 pe.setCName(cName);
1216 pe.setGuidValue(guid);
1217 pe.setHelpText(help);
1218 pe.setSupArchList(archList);
1219 pe.setSupModuleList(modTypeList);
1220 // if (archList != null && archList.size() > 0){
1221 // pe.setSupArchList(new ArrayList<String>(archList));
1222 // }
1223 // if (modTypeList != null && modTypeList.size() > 0) {
1224 // pe.setSupModuleList(new ArrayList<String>(modTypeList));
1225 // }
1226 return;
1227 }
1228 if (parent instanceof PpiDeclarationsDocument.PpiDeclarations) {
1229 PpiDeclarationsDocument.PpiDeclarations.Entry ppe = ((PpiDeclarationsDocument.PpiDeclarations) parent)
1230 .addNewEntry();
1231 ppe.setName(entryName);
1232 ppe.setCName(cName);
1233 ppe.setGuidValue(guid);
1234 ppe.setHelpText(help);
1235 ppe.setSupArchList(archList);
1236 ppe.setSupModuleList(modTypeList);
1237 // if (archList != null && archList.size() > 0){
1238 // ppe.setSupArchList(new ArrayList<String>(archList));
1239 // }
1240 // if (archList != null && modTypeList.size() > 0) {
1241 // ppe.setSupModuleList(new ArrayList<String>(modTypeList));
1242 // }
1243 return;
1244 }
1245
1246 return;
1247
1248 }
1249
1250 /**
1251 Generate Pcd definition using parameters passed in
1252
1253 @param pcdItemTypes ItemType attribute of PcdEntry element
1254 @param cName C_Name element value
1255 @param token Token element value
1256 @param dataType DatumType element value
1257 @param skuEnable Reserved
1258 @param sku Reserved
1259 @param maxSku Reserved
1260 @param hiiEnable Reserved
1261 @param varGuid Reserved
1262 @param varName Reserved
1263 @param defaultString DefaultString element value
1264 **/
1265 public void genSpdPcdDefinitions(String cName, String token, String dataType, String pcdItemTypes,
1266 String spaceGuid, String defaultString, String help, String archList,
1267 String modTypeList) {
1268 if (getSpdPcdDefinitions() == null) {
1269 spdPcdDefinitions = psaRoot.addNewPcdDeclarations();
1270 }
1271
1272 setSpdPcdEntry(pcdItemTypes, cName, token, dataType, spaceGuid, help,
1273 defaultString, archList, modTypeList, spdPcdDefinitions);
1274 }
1275
1276 /**
1277 Set Pcd entry contents under parent tag
1278
1279 @param pcdItemTypes ItemType attribute of PcdEntry element
1280 @param cName C_Name element value
1281 @param token Token element value
1282 @param dataType DatumType element value
1283 @param spaceGuid Reserved
1284 @param help Reserved
1285 @param defaultString DefaultString element value
1286 @param parent Tag under which PcdEntry goes to
1287 **/
1288 public void setSpdPcdEntry(String pcdItemTypes, String cName, String token, String dataType, String spaceGuid, String help,
1289 String defaultString, String archList, String modTypeList, XmlObject parent) {
1290
1291 PcdDeclarationsDocument.PcdDeclarations.PcdEntry pe = ((PcdDeclarationsDocument.PcdDeclarations) parent).addNewPcdEntry();
1292
1293 //ToDo: maybe multiple types in, need parse pcdItemTypes.
1294 String usage[] = pcdItemTypes.split("( )+");
1295 List<String> l = new ArrayList<String>();
1296 for (int i = 0; i < usage.length; ++i) {
1297 l.add(usage[i]);
1298 }
1299 pe.setValidUsage(l);
1300 pe.setCName(cName);
1301 pe.setToken(token);
1302 pe.setDatumType(PcdDataTypes.Enum.forString(dataType));
1303 pe.setDefaultValue(defaultString);
1304 pe.setTokenSpaceGuidCName(spaceGuid);
1305 pe.setHelpText(help);
1306 if (archList != null){
1307 pe.setSupArchList(stringToList(archList));
1308 } else {
1309 if (pe.isSetSupArchList()) {
1310 pe.unsetSupArchList();
1311 }
1312 }
1313 if (modTypeList != null){
1314 pe.setSupModuleList(stringToList(modTypeList));
1315 } else {
1316 if (pe.isSetSupModuleList()) {
1317 pe.unsetSupModuleList();
1318 }
1319 }
1320 }
1321
1322 /**
1323 Get PpiDeclarations element
1324
1325 @return PpiDeclarationsDocument.PpiDeclarations
1326 **/
1327 public PpiDeclarationsDocument.PpiDeclarations getSpdPpiDeclarations() {
1328 if (spdPpiDeclarations == null) {
1329 spdPpiDeclarations = psaRoot.getPpiDeclarations();
1330 }
1331 return spdPpiDeclarations;
1332 }
1333
1334 /**
1335 Get ProtocolDeclarations element
1336
1337 @return ProtocolDeclarationsDocument.ProtocolDeclarations
1338 **/
1339 public ProtocolDeclarationsDocument.ProtocolDeclarations getSpdProtocolDeclarations() {
1340 if (spdProtocolDeclarations == null) {
1341 spdProtocolDeclarations = psaRoot.getProtocolDeclarations();
1342 }
1343 return spdProtocolDeclarations;
1344 }
1345
1346 /**
1347 Get GuidDeclarations element
1348
1349 @return GuidDeclarationsDocument.GuidDeclarations
1350 **/
1351 public GuidDeclarationsDocument.GuidDeclarations getSpdGuidDeclarations() {
1352 if (spdGuidDeclarations == null) {
1353 spdGuidDeclarations = psaRoot.getGuidDeclarations();
1354 }
1355 return spdGuidDeclarations;
1356 }
1357
1358 /**
1359 Get PcdDefinitions element
1360
1361 @return PcdDefinitionsDocument.PcdDefinitions
1362 **/
1363 public PcdDeclarationsDocument.PcdDeclarations getSpdPcdDefinitions() {
1364 if (spdPcdDefinitions == null) {
1365 spdPcdDefinitions = psaRoot.getPcdDeclarations();
1366 }
1367 return spdPcdDefinitions;
1368 }
1369
1370 /**
1371 Get PackageHeaders element
1372
1373 @return PackageHeadersDocument.PackageHeaders
1374 **/
1375 public PackageHeadersDocument.PackageHeaders getSpdModHdrs() {
1376 if (spdModHdrs == null) {
1377 spdModHdrs = psaRoot.getPackageHeaders();
1378 }
1379 return spdModHdrs;
1380 }
1381
1382 /**
1383 Get MsaFiles element
1384
1385 @return MsaFilesDocument.MsaFiles
1386 **/
1387 public MsaFilesDocument.MsaFiles getSpdMsaFiles() {
1388 if (spdMsaFiles == null) {
1389 spdMsaFiles = psaRoot.getMsaFiles();
1390 }
1391 return spdMsaFiles;
1392 }
1393
1394 /**
1395 Get LibraryClassDeclarations element
1396
1397 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
1398 **/
1399 public LibraryClassDeclarationsDocument.LibraryClassDeclarations getSpdLibClassDeclarations() {
1400 if (spdLibClassDeclarations == null) {
1401 spdLibClassDeclarations = psaRoot.getLibraryClassDeclarations();
1402 }
1403 return spdLibClassDeclarations;
1404 }
1405
1406 public PackageDefinitionsDocument.PackageDefinitions getSpdPkgDefs() {
1407 if (spdPkgDefs == null) {
1408 spdPkgDefs = psaRoot.addNewPackageDefinitions();
1409 }
1410 return spdPkgDefs;
1411 }
1412 /**
1413 Get SpdHeader element
1414
1415 @return SpdHeaderDocument.SpdHeader
1416 **/
1417 public SpdHeaderDocument.SpdHeader getSpdHdr() {
1418 if (spdHdr == null) {
1419 spdHdr = psaRoot.addNewSpdHeader();
1420 }
1421 return spdHdr;
1422 }
1423
1424 /**
1425 Set value to Guid element
1426
1427 @param guid The value set to Guid element
1428 **/
1429 public void setSpdHdrGuidValue(String guid) {
1430 getSpdHdr().setGuidValue(guid);
1431 }
1432
1433 /**
1434 Get Version element under SpdHdr
1435
1436 @return String
1437 **/
1438 public String getSpdHdrVer() {
1439 return getSpdHdr().getVersion();
1440 }
1441
1442 /**
1443 Set value to Version element
1444
1445 @param ver The value set to Version element
1446 **/
1447 public void setSpdHdrVer(String ver) {
1448 getSpdHdr().setVersion(ver);
1449 }
1450
1451 public String getSpdHdrAbs(){
1452 return getSpdHdr().getAbstract();
1453
1454 }
1455
1456 /**
1457 Set value to Abstract element
1458
1459 @param abs The value set to Abstract element
1460 **/
1461 public void setSpdHdrAbs(String abs) {
1462
1463 getSpdHdr().setAbstract(abs);
1464 }
1465
1466 public String getSpdHdrDescription(){
1467 return getSpdHdr().getDescription();
1468 }
1469 /**
1470 Set value to Description element
1471
1472 @param des The value set to Description element
1473 **/
1474 public void setSpdHdrDescription(String des) {
1475 getSpdHdr().setDescription(des);
1476 }
1477
1478 public String getSpdHdrCopyright(){
1479 return getSpdHdr().getCopyright();
1480 }
1481 /**
1482 Set value to Copyright element
1483
1484 @param cpRit The value set to Copyright element
1485 **/
1486 public void setSpdHdrCopyright(String cpRit) {
1487
1488 getSpdHdr().setCopyright(cpRit);
1489
1490 }
1491 /**
1492 Get License element under SpdHdr
1493
1494 @return String
1495 **/
1496 public String getSpdHdrLicense() {
1497 if (getSpdHdr().getLicense() != null) {
1498 return getSpdHdr().getLicense().getStringValue();
1499 }
1500 return null;
1501 }
1502
1503 /**
1504 Set value to License element
1505
1506 @param license The value set to License element
1507 **/
1508 public void setSpdHdrLicense(String license) {
1509 if (getSpdHdr().getLicense() == null){
1510 getSpdHdr().addNewLicense().setStringValue(license);
1511 }
1512 else {
1513 getSpdHdr().getLicense().setStringValue(license);
1514 }
1515 }
1516
1517 public String getSpdHdrUrl(){
1518 if (getSpdHdr().getLicense() != null) {
1519 return getSpdHdr().getLicense().getURL();
1520 }
1521 return null;
1522 }
1523
1524 public void setSpdHdrUrl(String url){
1525 getSpdHdr().getLicense().setURL(url);
1526 }
1527
1528 /**
1529 Get PackageName element under SpdHdr
1530
1531 @return String
1532 **/
1533 public String getSpdHdrPkgName() {
1534
1535 return getSpdHdr().getPackageName();
1536 }
1537
1538 /**
1539 Set value to PackageName element
1540
1541 @param pkgName The value set to PackageName element
1542 **/
1543 public void setSpdHdrPkgName(String pkgName) {
1544 getSpdHdr().setPackageName(pkgName);
1545 }
1546
1547 public String getSpdHdrGuidValue(){
1548 return getSpdHdr().getGuidValue();
1549 }
1550
1551 /**
1552 Reserved method
1553
1554 @return SpecificationDocument.Specification
1555 **/
1556 public String getSpdHdrSpec() {
1557 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1558 // return getSpdHdr().getSpecification();
1559 }
1560
1561 /**
1562 Reserved method
1563
1564 @param spec
1565 **/
1566 public void setSpdHdrSpec(String spec) {
1567 spec = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1568 getSpdHdr().setSpecification(spec);
1569
1570 }
1571
1572 public String getSpdPkgDefsRdOnly(){
1573 return getSpdPkgDefs().getReadOnly() + "";
1574 }
1575 /**
1576 Set value to ReadOnly element
1577
1578 @param rdOnly The value set to ReadOnly element
1579 **/
1580 public void setSpdPkgDefsRdOnly(String rdOnly) {
1581
1582 getSpdPkgDefs().setReadOnly(new Boolean(rdOnly));
1583 }
1584
1585 public String getSpdPkgDefsRePkg(){
1586 return getSpdPkgDefs().getRePackage() + "";
1587 }
1588 /**
1589 Set value to RePackage element
1590
1591 @param rePkg The value set to RePackage element
1592 **/
1593 public void setSpdPkgDefsRePkg(String rePkg) {
1594
1595 getSpdPkgDefs().setRePackage(new Boolean(rePkg));
1596 }
1597
1598 /**
1599 Set value to URL element
1600
1601 @param url The value set to URL element
1602 **/
1603 // public void setSpdHdrURL(String url) {
1604 // getSpdHdr().setURL(url);
1605 // }
1606
1607 /**
1608 Get xml file
1609
1610 @return File
1611 **/
1612 public File getFile() {
1613 return file;
1614 }
1615
1616 /**
1617 Set file
1618
1619 @param file File with xml format
1620 **/
1621 public void setFile(File file) {
1622 this.file = file;
1623 }
1624
1625 private List<String> stringToList(String s){
1626 if (s == null || s.length() == 0) {
1627 return null;
1628 }
1629 Vector<String> al = new Vector<String>();
1630 String[] sArray = s.split(" ");
1631 for(int i = 0; i < sArray.length; ++i){
1632 al.add(sArray[i]);
1633 }
1634 return al;
1635 }
1636
1637 private String listToString(List l) {
1638 if (l == null) {
1639 return null;
1640 }
1641 String s = " ";
1642 ListIterator li = l.listIterator();
1643 while(li.hasNext()) {
1644 s += li.next();
1645 s += " ";
1646 }
1647 return s.trim();
1648 }
1649
1650 }