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