]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdFileContents.java
fix the problem that if no data updated in wizard editors, the Save indicator will...
[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
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 public void getSpdLibClassDeclaration(String[] sa, int i) {
998 if (getSpdLibClassDeclarations() == null) {
999 return;
1000 }
1001 XmlCursor cursor = getSpdLibClassDeclarations().newCursor();
1002 if (cursor.toFirstChild()) {
1003 for (int j = 0; j < i; ++j) {
1004 cursor.toNextSibling();
1005 }
1006 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass)cursor.getObject();
1007 sa[0] = lc.getName();
1008 sa[1] = lc.getIncludeHeader();
1009 sa[2] = lc.getHelpText();
1010 sa[3] = lc.getRecommendedInstanceGuid();
1011 sa[4] = lc.getRecommendedInstanceVersion();
1012 sa[5] = listToString(lc.getSupArchList());
1013 sa[6] = listToString(lc.getSupModuleList());
1014 }
1015 cursor.dispose();
1016 }
1017
1018 /**
1019 Set library class declaration contents under parent tag
1020
1021 @param clsName LibraryClass element value
1022 @param clsUsage Reserved
1023 @param hdrFile IncludeHeader element value
1024 @param hdrAttribGuid Reserved
1025 @param hdrAttribArch Reserved
1026 @param hdrAttribPath Reserved
1027 @param hdrAttribClass Reserved
1028 @param hdrAttribVer Reserved
1029 @param hdrAttribOverID Reserved
1030 @param hdrAttribModType Reserved
1031 @param parent The tag under which library class declaration goes to
1032 **/
1033 public void setSpdLibClassDeclaration(String clsName, String clsUsage, String hdrFile, String help,
1034 String hdrAttribArch, String hdrAttribPath, String hdrAttribClass,
1035 String instanceVer, String hdrAttribOverID, String hdrAttribModType,
1036 XmlObject parent) {
1037
1038 setSpdLibraryClass(clsName, hdrFile, help, clsUsage, instanceVer, hdrAttribArch, hdrAttribModType, parent);
1039
1040 }
1041
1042 /**
1043 Set the contents of LibraryClass under parent element
1044
1045 @param clsName LibraryClass element value
1046 @param clsUsage Reserved
1047 @param parent The tag under which library class declaration goes to
1048 **/
1049 public void setSpdLibraryClass(String clsName, String clsIncludeFile, String help, String clsUsage, String instanceVer, String hdrAttribArch, String hdrAttribModType, XmlObject parent) {
1050 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = ((LibraryClassDeclarationsDocument.LibraryClassDeclarations) parent).addNewLibraryClass();
1051 lc.setName(clsName);
1052 lc.setIncludeHeader(clsIncludeFile);
1053 lc.setHelpText(help);
1054 // LAH added logic so you cannot set the version unless the GUID is defined.
1055
1056 if (clsUsage != null) {
1057 lc.setRecommendedInstanceGuid(clsUsage);
1058 if (instanceVer != null) {
1059 lc.setRecommendedInstanceVersion(instanceVer);
1060 }
1061 }
1062 else {
1063 if (lc.isSetRecommendedInstanceGuid()) {
1064 lc.unsetRecommendedInstanceGuid();
1065 }
1066 if (lc.isSetRecommendedInstanceVersion()) {
1067 lc.unsetRecommendedInstanceVersion();
1068 }
1069 }
1070
1071 if (hdrAttribArch != null) {
1072 lc.setSupArchList(stringToList(hdrAttribArch));
1073 } else {
1074 if (lc.isSetSupArchList()) {
1075 lc.unsetSupArchList();
1076 }
1077 }
1078
1079 if (hdrAttribModType != null) {
1080 lc.setSupModuleList(stringToList(hdrAttribModType));
1081 } else {
1082 if (lc.isSetSupModuleList()) {
1083 lc.unsetSupModuleList();
1084 }
1085 }
1086
1087 }
1088
1089 /**
1090 Set contents of IncludeHeader under parent element
1091
1092 @param modType Reserved
1093 @param hdrFile IncludeHeader element value
1094 @param hdrAttribGuid Reserved
1095 @param hdrAttribArch Reserved
1096 @param hdrAttribPath Reserved
1097 @param hdrAttribClass Reserved
1098 @param hdrAttribVer Reserved
1099 @param hdrAttribOverID Reserved
1100 @param parent The tag under which library class declaration goes to
1101 **/
1102 public void setSpdIncludeHeader(String modType, String hdrFile, String hdrAttribGuid, String hdrAttribArch,
1103 String hdrAttribPath, String hdrAttribClass, String hdrAttribVer,
1104 String hdrAttribOverID, XmlObject parent) {
1105
1106 if (parent instanceof LibraryClassDeclarationsDocument.LibraryClassDeclarations) {
1107 } else if (parent instanceof PackageHeadersDocument.PackageHeaders) {
1108 PackageHeadersDocument.PackageHeaders.IncludePkgHeader ih = null;
1109 ih = ((PackageHeadersDocument.PackageHeaders) parent).addNewIncludePkgHeader();
1110 ih.setStringValue(hdrFile);
1111 ih.setModuleType(ModuleTypeDef.Enum.forString(modType));
1112 } else {
1113 return;
1114 }
1115
1116 if (hdrAttribGuid != null) {
1117 }
1118 if (hdrAttribPath != null) {
1119 }
1120 if (hdrAttribClass != null) {
1121 }
1122 if (hdrAttribVer != null) {
1123 }
1124 if (hdrAttribOverID != null) {
1125 }
1126
1127 }
1128
1129 /**
1130 Generate MsaFile element.
1131
1132 @param msaFileName MsaFile element value
1133 @param archType Reserved
1134 **/
1135 public void genSpdMsaFiles(String msaFileName, String moduleName, String ver, String guid) {
1136 if (getSpdMsaFiles() == null) {
1137 spdMsaFiles = psaRoot.addNewMsaFiles();
1138 }
1139 setSpdMsaFile(msaFileName, moduleName, ver, guid, spdMsaFiles);
1140
1141 }
1142
1143 public void getSpdMsaFile (String[] sa, int i) {
1144 if (getSpdMsaFiles() == null) {
1145 return;
1146 }
1147 XmlCursor cursor = getSpdMsaFiles().newCursor();
1148 if (cursor.toFirstChild()) {
1149 for (int j = 0; j < i; ++j) {
1150 cursor.toNextSibling();
1151 }
1152 sa[0] = cursor.getTextValue();
1153 }
1154 cursor.dispose();
1155 }
1156
1157 /**
1158 Set MsaFile contents under parent element.
1159
1160 @param msaFileName MsaFile element value
1161 @param parent Element under which MsaFile goes to
1162 **/
1163 public void setSpdMsaFile(String msaFileName, String moduleName, String ver, String guid, XmlObject parent) {
1164 MsaFilesDocument.MsaFiles f = (MsaFilesDocument.MsaFiles)parent;
1165 f.addNewFilename().setStringValue(msaFileName);
1166 // f.setFilename(msaFileName);
1167 // f.setModuleName(moduleName);
1168 // f.setModuleVersion(ver);
1169 // f.setModuleGuid(guid);
1170 }
1171
1172 /**
1173 Generate PackageHeader element using parameters passed in.
1174
1175 @param ModHdrModType ModuleType attribute of IncludeHeader element
1176 @param hdrFile IncludeHeader element value
1177 @param hdrAttribGuid Reserved
1178 @param hdrAttribArch Reserved
1179 @param hdrAttribPath Reserved
1180 @param hdrAttribClass Reserved
1181 @param hdrAttribVer Reserved
1182 @param hdrAttribOverID Reserved
1183 **/
1184 public void genSpdModuleHeaders(String ModHdrModType, String hdrFile, String hdrAttribGuid, String hdrAttribArch,
1185 String hdrAttribPath, String hdrAttribClass, String hdrAttribVer,
1186 String hdrAttribOverID) {
1187 if (getSpdModHdrs() == null) {
1188 spdModHdrs = psaRoot.addNewPackageHeaders();
1189 }
1190
1191 //
1192 // add IncludeHeader under PackageHeaders element
1193 //
1194 setSpdIncludeHeader(ModHdrModType, hdrFile, hdrAttribGuid, hdrAttribArch, hdrAttribPath, hdrAttribClass,
1195 hdrAttribVer, hdrAttribOverID, spdModHdrs);
1196 }
1197
1198 public void getSpdModuleHeader(String[] sa, int i) {
1199 if (getSpdModHdrs() == null) {
1200 return;
1201 }
1202 XmlCursor cursor = getSpdModHdrs().newCursor();
1203 if (cursor.toFirstChild()) {
1204 for (int j = 0; j < i; ++j) {
1205 cursor.toNextSibling();
1206 }
1207 PackageHeadersDocument.PackageHeaders.IncludePkgHeader ih = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader)cursor.getObject();
1208 sa[0] = ih.getModuleType()+"";
1209 sa[1] = ih.getStringValue();
1210 }
1211 cursor.dispose();
1212 }
1213
1214 /**
1215 Generate GUID declaration element using parameters passed in.
1216
1217 @param guidDeclEntryName Name attribute of Entry element
1218 @param guidDeclCName CName element value
1219 @param guidDeclGuid Guid element value
1220 @param guidDeclFeatureFlag Reserved
1221 **/
1222 public void genSpdGuidDeclarations(String guidDeclEntryName, String guidDeclCName, String guidDeclGuid,
1223 String guidDeclHelp, Vector<String> archList, Vector<String> modTypeList,
1224 Vector<String> guidTypeList) {
1225 if (getSpdGuidDeclarations() == null) {
1226 spdGuidDeclarations = psaRoot.addNewGuidDeclarations();
1227 }
1228
1229 setSpdEntry(guidDeclEntryName, guidDeclCName, guidDeclGuid, guidDeclHelp, archList, modTypeList, guidTypeList, spdGuidDeclarations);
1230 }
1231
1232 /**
1233 Generate protocol declaration element using parameters passed in.
1234
1235 @param protocolDeclEntryName Name attribute of Entry element
1236 @param protocolDeclCName CName element value
1237 @param protocolDeclGuid Guid element value
1238 @param protocolDeclFeatureFlag Reserved
1239 **/
1240 public void genSpdProtocolDeclarations(String protocolDeclEntryName, String protocolDeclCName,
1241 String protocolDeclGuid, String protocolDeclFeatureFlag,
1242 Vector<String> archList, Vector<String> modTypeList, Vector<String> guidTypeList) {
1243 if (getSpdProtocolDeclarations() == null) {
1244 spdProtocolDeclarations = psaRoot.addNewProtocolDeclarations();
1245 }
1246
1247 setSpdEntry(protocolDeclEntryName, protocolDeclCName, protocolDeclGuid, protocolDeclFeatureFlag,
1248 archList, modTypeList, guidTypeList, spdProtocolDeclarations);
1249 }
1250
1251 /**
1252 Generate PPI declaration element using parameters passed in.
1253
1254 @param ppiDeclEntryName Name attribute of Entry element
1255 @param ppiDeclCName CName element value
1256 @param ppiDeclGuid Guid element value
1257 @param ppiDeclFeatureFlag Reserved
1258 **/
1259 public void genSpdPpiDeclarations(String ppiDeclEntryName, String ppiDeclCName, String ppiDeclGuid,
1260 String ppiDeclFeatureFlag, Vector<String> archList, Vector<String> modTypeList, Vector<String> guidTypeList) {
1261 if (getSpdPpiDeclarations() == null) {
1262 spdPpiDeclarations = psaRoot.addNewPpiDeclarations();
1263 }
1264
1265 setSpdEntry(ppiDeclEntryName, ppiDeclCName, ppiDeclGuid, ppiDeclFeatureFlag, archList, modTypeList, guidTypeList, spdPpiDeclarations);
1266 }
1267
1268 public void getSpdGuidDeclaration(String[] sa, int i) {
1269 if (getSpdGuidDeclarations() == null) {
1270 return;
1271 }
1272 getSpdEntry(sa, i, getSpdGuidDeclarations());
1273 }
1274
1275 public void getSpdProtocolDeclaration(String[] sa, int i) {
1276 if (getSpdProtocolDeclarations() == null) {
1277 return;
1278 }
1279 getSpdEntry(sa, i, getSpdProtocolDeclarations());
1280 }
1281
1282 public void getSpdPpiDeclaration(String[] sa, int i) {
1283 if (getSpdPpiDeclarations() == null) {
1284 return;
1285 }
1286 getSpdEntry(sa, i, getSpdPpiDeclarations());
1287 }
1288
1289 public void getSpdEntry(String[] sa, int i, XmlObject parent) {
1290 XmlCursor cursor = parent.newCursor();
1291 if (cursor.toFirstChild()) {
1292 for (int j = 0; j < i; ++j) {
1293 cursor.toNextSibling();
1294 }
1295 if (parent instanceof GuidDeclarationsDocument.GuidDeclarations) {
1296 GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.Entry)cursor.getObject();
1297 sa[0] = e.getName();
1298 sa[1] = e.getCName();
1299 sa[2] = e.getGuidValue();
1300 sa[3] = e.getHelpText();
1301 sa[4] = listToString(e.getSupArchList());
1302 sa[5] = listToString(e.getSupModuleList());
1303 sa[6] = listToString(e.getGuidTypeList());
1304 }
1305
1306 if (parent instanceof ProtocolDeclarationsDocument.ProtocolDeclarations) {
1307 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry)cursor.getObject();
1308 sa[0] = e.getName();
1309 sa[1] = e.getCName();
1310 sa[2] = e.getGuidValue();
1311 sa[3] = e.getHelpText();
1312 sa[4] = listToString(e.getSupArchList());
1313 sa[5] = listToString(e.getSupModuleList());
1314 sa[6] = listToString(e.getGuidTypeList());
1315 }
1316
1317 if (parent instanceof PpiDeclarationsDocument.PpiDeclarations) {
1318 PpiDeclarationsDocument.PpiDeclarations.Entry e = (PpiDeclarationsDocument.PpiDeclarations.Entry)cursor.getObject();
1319 sa[0] = e.getName();
1320 sa[1] = e.getCName();
1321 sa[2] = e.getGuidValue();
1322 sa[3] = e.getHelpText();
1323 sa[4] = listToString(e.getSupArchList());
1324 sa[5] = listToString(e.getSupModuleList());
1325 sa[6] = listToString(e.getGuidTypeList());
1326 }
1327
1328 }
1329 cursor.dispose();
1330 }
1331 /**
1332 Set Entry contents using parameters passed in
1333
1334 @param entryName Name attribute of Entry element
1335 @param cName CName element value
1336 @param guid Guid element value
1337 @param featureFlag Reserved
1338 @param parent The tag under which Entry element goes to
1339 **/
1340 public void setSpdEntry(String entryName, String cName, String guid, String help,
1341 Vector<String> archList, Vector<String> modTypeList,
1342 Vector<String> guidTypeList, XmlObject parent) {
1343
1344 if (parent instanceof GuidDeclarationsDocument.GuidDeclarations) {
1345 GuidDeclarationsDocument.GuidDeclarations.Entry e = ((GuidDeclarations) parent).addNewEntry();
1346 e.setName(entryName);
1347 e.setCName(cName);
1348 e.setGuidValue(guid);
1349 e.setHelpText(help);
1350 if (guidTypeList != null) {
1351 e.setGuidTypeList(guidTypeList);
1352 }
1353 else{
1354 if (e.isSetGuidTypeList()) {
1355 e.unsetGuidTypeList();
1356 }
1357 }
1358 if (archList != null) {
1359 e.setSupArchList(archList);
1360 }
1361 else {
1362 if (e.isSetSupArchList()) {
1363 e.unsetSupArchList();
1364 }
1365 }
1366 if (modTypeList != null){
1367 e.setSupModuleList(modTypeList);
1368 }
1369 else {
1370 if (e.isSetSupModuleList()) {
1371 e.unsetSupModuleList();
1372 }
1373 }
1374
1375 return;
1376 }
1377 if (parent instanceof ProtocolDeclarationsDocument.ProtocolDeclarations) {
1378 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry pe = ((ProtocolDeclarationsDocument.ProtocolDeclarations) parent)
1379 .addNewEntry();
1380 pe.setName(entryName);
1381 pe.setCName(cName);
1382 pe.setGuidValue(guid);
1383 pe.setHelpText(help);
1384 if (guidTypeList != null) {
1385 pe.setGuidTypeList(guidTypeList);
1386 }
1387 else{
1388 if (pe.isSetGuidTypeList()) {
1389 pe.unsetGuidTypeList();
1390 }
1391 }
1392 if (archList != null) {
1393 pe.setSupArchList(archList);
1394 }
1395 else {
1396 if (pe.isSetSupArchList()) {
1397 pe.unsetSupArchList();
1398 }
1399 }
1400 if (modTypeList != null){
1401 pe.setSupModuleList(modTypeList);
1402 }
1403 else {
1404 if (pe.isSetSupModuleList()) {
1405 pe.unsetSupModuleList();
1406 }
1407 }
1408
1409 return;
1410 }
1411 if (parent instanceof PpiDeclarationsDocument.PpiDeclarations) {
1412 PpiDeclarationsDocument.PpiDeclarations.Entry ppe = ((PpiDeclarationsDocument.PpiDeclarations) parent)
1413 .addNewEntry();
1414 ppe.setName(entryName);
1415 ppe.setCName(cName);
1416 ppe.setGuidValue(guid);
1417 ppe.setHelpText(help);
1418 if (guidTypeList != null) {
1419 ppe.setGuidTypeList(guidTypeList);
1420 }
1421 else{
1422 if (ppe.isSetGuidTypeList()) {
1423 ppe.unsetGuidTypeList();
1424 }
1425 }
1426 if (archList != null) {
1427 ppe.setSupArchList(archList);
1428 }
1429 else {
1430 if (ppe.isSetSupArchList()) {
1431 ppe.unsetSupArchList();
1432 }
1433 }
1434 if (modTypeList != null){
1435 ppe.setSupModuleList(modTypeList);
1436 }
1437 else {
1438 if (ppe.isSetSupModuleList()) {
1439 ppe.unsetSupModuleList();
1440 }
1441 }
1442
1443 return;
1444 }
1445
1446 return;
1447
1448 }
1449
1450 /**
1451 Generate Pcd definition using parameters passed in
1452
1453 @param pcdItemTypes ItemType attribute of PcdEntry element
1454 @param cName C_Name element value
1455 @param token Token element value
1456 @param dataType DatumType element value
1457 @param skuEnable Reserved
1458 @param sku Reserved
1459 @param maxSku Reserved
1460 @param hiiEnable Reserved
1461 @param varGuid Reserved
1462 @param varName Reserved
1463 @param defaultString DefaultString element value
1464 **/
1465 public void genSpdPcdDefinitions(String cName, String token, String dataType, String pcdItemTypes,
1466 String spaceGuid, String defaultString, String help, String archList,
1467 String modTypeList) {
1468 if (getSpdPcdDefinitions() == null) {
1469 spdPcdDefinitions = psaRoot.addNewPcdDeclarations();
1470 }
1471
1472 setSpdPcdEntry(pcdItemTypes, cName, token, dataType, spaceGuid, help,
1473 defaultString, archList, modTypeList, spdPcdDefinitions);
1474 }
1475
1476 public void getSpdPcdDeclaration(String[] sa, int i) {
1477 if (getSpdPcdDefinitions() == null) {
1478 return;
1479 }
1480
1481 XmlCursor cursor = getSpdPcdDefinitions().newCursor();
1482 if (cursor.toFirstChild()) {
1483 for (int j = 0; j < i; ++j) {
1484 cursor.toNextSibling();
1485 }
1486 PcdDeclarationsDocument.PcdDeclarations.PcdEntry pe = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)cursor.getObject();
1487 sa[0] = pe.getCName();
1488 sa[1] = pe.getToken()+"";
1489 sa[2] = pe.getTokenSpaceGuidCName();
1490 sa[3] = pe.getDatumType()+"";
1491 sa[4] = pe.getDefaultValue();
1492 sa[5] = pe.getHelpText();
1493 sa[6] = listToString(pe.getValidUsage());
1494 sa[7] = listToString(pe.getSupArchList());
1495 sa[8] = listToString(pe.getSupModuleList());
1496 }
1497 cursor.dispose();
1498 }
1499
1500 /**
1501 Set Pcd entry contents under parent tag
1502
1503 @param pcdItemTypes ItemType attribute of PcdEntry element
1504 @param cName C_Name element value
1505 @param token Token element value
1506 @param dataType DatumType element value
1507 @param spaceGuid Reserved
1508 @param help Reserved
1509 @param defaultString DefaultString element value
1510 @param parent Tag under which PcdEntry goes to
1511 **/
1512 public void setSpdPcdEntry(String pcdItemTypes, String cName, String token, String dataType, String spaceGuid, String help,
1513 String defaultString, String archList, String modTypeList, XmlObject parent) {
1514
1515 PcdDeclarationsDocument.PcdDeclarations.PcdEntry pe = ((PcdDeclarationsDocument.PcdDeclarations) parent).addNewPcdEntry();
1516
1517 //ToDo: maybe multiple types in, need parse pcdItemTypes.
1518 String usage[] = pcdItemTypes.split("( )+");
1519 List<String> l = new ArrayList<String>();
1520 for (int i = 0; i < usage.length; ++i) {
1521 l.add(usage[i]);
1522 }
1523 pe.setValidUsage(l);
1524 pe.setCName(cName);
1525 pe.setToken(token);
1526 pe.setDatumType(PcdDataTypes.Enum.forString(dataType));
1527 pe.setDefaultValue(defaultString);
1528 pe.setTokenSpaceGuidCName(spaceGuid);
1529 pe.setHelpText(help);
1530 if (archList != null){
1531 pe.setSupArchList(stringToList(archList));
1532 } else {
1533 if (pe.isSetSupArchList()) {
1534 pe.unsetSupArchList();
1535 }
1536 }
1537 if (modTypeList != null){
1538 pe.setSupModuleList(stringToList(modTypeList));
1539 } else {
1540 if (pe.isSetSupModuleList()) {
1541 pe.unsetSupModuleList();
1542 }
1543 }
1544 }
1545
1546 /**
1547 Get PpiDeclarations element
1548
1549 @return PpiDeclarationsDocument.PpiDeclarations
1550 **/
1551 public PpiDeclarationsDocument.PpiDeclarations getSpdPpiDeclarations() {
1552 if (spdPpiDeclarations == null) {
1553 spdPpiDeclarations = psaRoot.getPpiDeclarations();
1554 }
1555 return spdPpiDeclarations;
1556 }
1557
1558 /**
1559 Get ProtocolDeclarations element
1560
1561 @return ProtocolDeclarationsDocument.ProtocolDeclarations
1562 **/
1563 public ProtocolDeclarationsDocument.ProtocolDeclarations getSpdProtocolDeclarations() {
1564 if (spdProtocolDeclarations == null) {
1565 spdProtocolDeclarations = psaRoot.getProtocolDeclarations();
1566 }
1567 return spdProtocolDeclarations;
1568 }
1569
1570 /**
1571 Get GuidDeclarations element
1572
1573 @return GuidDeclarationsDocument.GuidDeclarations
1574 **/
1575 public GuidDeclarationsDocument.GuidDeclarations getSpdGuidDeclarations() {
1576 if (spdGuidDeclarations == null) {
1577 spdGuidDeclarations = psaRoot.getGuidDeclarations();
1578 }
1579 return spdGuidDeclarations;
1580 }
1581
1582 /**
1583 Get PcdDefinitions element
1584
1585 @return PcdDefinitionsDocument.PcdDefinitions
1586 **/
1587 public PcdDeclarationsDocument.PcdDeclarations getSpdPcdDefinitions() {
1588 if (spdPcdDefinitions == null) {
1589 spdPcdDefinitions = psaRoot.getPcdDeclarations();
1590 }
1591 return spdPcdDefinitions;
1592 }
1593
1594 /**
1595 Get PackageHeaders element
1596
1597 @return PackageHeadersDocument.PackageHeaders
1598 **/
1599 public PackageHeadersDocument.PackageHeaders getSpdModHdrs() {
1600 if (spdModHdrs == null) {
1601 spdModHdrs = psaRoot.getPackageHeaders();
1602 }
1603 return spdModHdrs;
1604 }
1605
1606 /**
1607 Get MsaFiles element
1608
1609 @return MsaFilesDocument.MsaFiles
1610 **/
1611 public MsaFilesDocument.MsaFiles getSpdMsaFiles() {
1612 if (spdMsaFiles == null) {
1613 spdMsaFiles = psaRoot.getMsaFiles();
1614 }
1615 return spdMsaFiles;
1616 }
1617
1618 /**
1619 Get LibraryClassDeclarations element
1620
1621 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
1622 **/
1623 public LibraryClassDeclarationsDocument.LibraryClassDeclarations getSpdLibClassDeclarations() {
1624 if (spdLibClassDeclarations == null) {
1625 spdLibClassDeclarations = psaRoot.getLibraryClassDeclarations();
1626 }
1627 return spdLibClassDeclarations;
1628 }
1629
1630 public PackageDefinitionsDocument.PackageDefinitions getSpdPkgDefs() {
1631 if (spdPkgDefs == null) {
1632 spdPkgDefs = psaRoot.addNewPackageDefinitions();
1633 }
1634 return spdPkgDefs;
1635 }
1636 /**
1637 Get SpdHeader element
1638
1639 @return SpdHeaderDocument.SpdHeader
1640 **/
1641 public SpdHeaderDocument.SpdHeader getSpdHdr() {
1642 if (spdHdr == null) {
1643 spdHdr = psaRoot.addNewSpdHeader();
1644 }
1645 return spdHdr;
1646 }
1647
1648 /**
1649 Set value to Guid element
1650
1651 @param guid The value set to Guid element
1652 **/
1653 public void setSpdHdrGuidValue(String guid) {
1654 getSpdHdr().setGuidValue(guid);
1655 }
1656
1657 /**
1658 Get Version element under SpdHdr
1659
1660 @return String
1661 **/
1662 public String getSpdHdrVer() {
1663 return getSpdHdr().getVersion();
1664 }
1665
1666 /**
1667 Set value to Version element
1668
1669 @param ver The value set to Version element
1670 **/
1671 public void setSpdHdrVer(String ver) {
1672 getSpdHdr().setVersion(ver);
1673 }
1674
1675 public String getSpdHdrAbs(){
1676 return getSpdHdr().getAbstract();
1677
1678 }
1679
1680 /**
1681 Set value to Abstract element
1682
1683 @param abs The value set to Abstract element
1684 **/
1685 public void setSpdHdrAbs(String abs) {
1686
1687 getSpdHdr().setAbstract(abs);
1688 }
1689
1690 public String getSpdHdrDescription(){
1691 return getSpdHdr().getDescription();
1692 }
1693 /**
1694 Set value to Description element
1695
1696 @param des The value set to Description element
1697 **/
1698 public void setSpdHdrDescription(String des) {
1699 getSpdHdr().setDescription(des);
1700 }
1701
1702 public String getSpdHdrCopyright(){
1703 return getSpdHdr().getCopyright();
1704 }
1705 /**
1706 Set value to Copyright element
1707
1708 @param cpRit The value set to Copyright element
1709 **/
1710 public void setSpdHdrCopyright(String cpRit) {
1711
1712 getSpdHdr().setCopyright(cpRit);
1713
1714 }
1715 /**
1716 Get License element under SpdHdr
1717
1718 @return String
1719 **/
1720 public String getSpdHdrLicense() {
1721 if (getSpdHdr().getLicense() != null) {
1722 return getSpdHdr().getLicense().getStringValue();
1723 }
1724 return null;
1725 }
1726
1727 /**
1728 Set value to License element
1729
1730 @param license The value set to License element
1731 **/
1732 public void setSpdHdrLicense(String license) {
1733 if (getSpdHdr().getLicense() == null){
1734 getSpdHdr().addNewLicense().setStringValue(license);
1735 }
1736 else {
1737 getSpdHdr().getLicense().setStringValue(license);
1738 }
1739 }
1740
1741 public String getSpdHdrUrl(){
1742 if (getSpdHdr().getLicense() != null) {
1743 return getSpdHdr().getLicense().getURL();
1744 }
1745 return null;
1746 }
1747
1748 public void setSpdHdrUrl(String url){
1749 getSpdHdr().getLicense().setURL(url);
1750 }
1751
1752 /**
1753 Get PackageName element under SpdHdr
1754
1755 @return String
1756 **/
1757 public String getSpdHdrPkgName() {
1758
1759 return getSpdHdr().getPackageName();
1760 }
1761
1762 /**
1763 Set value to PackageName element
1764
1765 @param pkgName The value set to PackageName element
1766 **/
1767 public void setSpdHdrPkgName(String pkgName) {
1768 getSpdHdr().setPackageName(pkgName);
1769 }
1770
1771 public String getSpdHdrGuidValue(){
1772 return getSpdHdr().getGuidValue();
1773 }
1774
1775 /**
1776 Reserved method
1777
1778 @return SpecificationDocument.Specification
1779 **/
1780 public String getSpdHdrSpec() {
1781 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1782 // return getSpdHdr().getSpecification();
1783 }
1784
1785 /**
1786 Reserved method
1787
1788 @param spec
1789 **/
1790 public void setSpdHdrSpec(String spec) {
1791 spec = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1792 getSpdHdr().setSpecification(spec);
1793
1794 }
1795
1796 public String getSpdPkgDefsRdOnly(){
1797 return getSpdPkgDefs().getReadOnly() + "";
1798 }
1799 /**
1800 Set value to ReadOnly element
1801
1802 @param rdOnly The value set to ReadOnly element
1803 **/
1804 public void setSpdPkgDefsRdOnly(String rdOnly) {
1805
1806 getSpdPkgDefs().setReadOnly(new Boolean(rdOnly));
1807 }
1808
1809 public String getSpdPkgDefsRePkg(){
1810 return getSpdPkgDefs().getRePackage() + "";
1811 }
1812 /**
1813 Set value to RePackage element
1814
1815 @param rePkg The value set to RePackage element
1816 **/
1817 public void setSpdPkgDefsRePkg(String rePkg) {
1818
1819 getSpdPkgDefs().setRePackage(new Boolean(rePkg));
1820 }
1821
1822 /**
1823 Set value to URL element
1824
1825 @param url The value set to URL element
1826 **/
1827 // public void setSpdHdrURL(String url) {
1828 // getSpdHdr().setURL(url);
1829 // }
1830
1831 /**
1832 Get xml file
1833
1834 @return File
1835 **/
1836 public File getFile() {
1837 return file;
1838 }
1839
1840 /**
1841 Set file
1842
1843 @param file File with xml format
1844 **/
1845 public void setFile(File file) {
1846 this.file = file;
1847 }
1848
1849 private List<String> stringToList(String s){
1850 if (s == null || s.length() == 0) {
1851 return null;
1852 }
1853 Vector<String> al = new Vector<String>();
1854 String[] sArray = s.split(" ");
1855 for(int i = 0; i < sArray.length; ++i){
1856 al.add(sArray[i]);
1857 }
1858 return al;
1859 }
1860
1861 private String listToString(List l) {
1862 if (l == null) {
1863 return null;
1864 }
1865 String s = " ";
1866 ListIterator li = l.listIterator();
1867 while(li.hasNext()) {
1868 s += li.next();
1869 s += " ";
1870 }
1871 return s.trim();
1872 }
1873
1874 }