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