]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdFileContents.java
Fixed alignment for labels and fields
[mirror_edk2.git] / Tools / Java / 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 public void getSpdGuidDeclWithType (Vector<String> vGuidCName, String type) {
734 if (psaRoot.getGuidDeclarations() == null) {
735 return;
736 }
737 List<GuidDeclarationsDocument.GuidDeclarations.Entry> l = psaRoot.getGuidDeclarations().getEntryList();
738 for (int i = 0; i < l.size(); ++i) {
739 if (l.get(i).getGuidTypeList() == null || l.get(i).getGuidTypeList().contains(type)) {
740 vGuidCName.add(l.get(i).getCName());
741 }
742 }
743 }
744 /**
745 Get the number of GUID declarations from the size of List
746
747 @return int
748 **/
749 public int getSpdGuidDeclarationCount() {
750 if (psaRoot.getGuidDeclarations() == null || psaRoot.getGuidDeclarations().getEntryList() == null) {
751 return 0;
752 }
753 return psaRoot.getGuidDeclarations().getEntryList().size();
754 }
755
756 /**
757 Get available Guid declaration contents into String array
758
759 @param guid Caller allocated two-dimentional String array
760 **/
761 public void getSpdGuidDeclarations(String[][] guid) {
762 if (psaRoot.getGuidDeclarations() == null) {
763 return;
764 }
765
766 List<GuidDeclarationsDocument.GuidDeclarations.Entry> l = psaRoot.getGuidDeclarations().getEntryList();
767 int i = 0;
768 ListIterator li = l.listIterator();
769 while (li.hasNext()) {
770 GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.Entry) li
771 .next();
772 guid[i][0] = e.getName();
773 guid[i][1] = e.getCName();
774 if (e.getGuidValue() != null) {
775 guid[i][2] = e.getGuidValue();
776 }
777 guid[i][3] = e.getHelpText();
778 guid[i][4] = listToString(e.getSupArchList());
779 guid[i][5] = listToString(e.getSupModuleList());
780 guid[i][6] = listToString(e.getGuidTypeList());
781 i++;
782 }
783 }
784
785 /**
786 Get the number of protocol declarations from the size of List
787
788 @return int
789 **/
790 public int getSpdProtocolDeclarationCount() {
791 if (psaRoot.getProtocolDeclarations() == null || psaRoot.getProtocolDeclarations().getEntryList() == null) {
792 return 0;
793 }
794 return psaRoot.getProtocolDeclarations().getEntryList().size();
795 }
796
797 /**
798 Get available protocol declaration contents into String array
799
800 @param protocol Caller allocated two-dimentional String array
801 **/
802 public void getSpdProtocolDeclarations(String[][] protocol) {
803 if (psaRoot.getProtocolDeclarations() == null) {
804 return;
805 }
806
807 List<ProtocolDeclarationsDocument.ProtocolDeclarations.Entry> l = psaRoot.getProtocolDeclarations()
808 .getEntryList();
809 int i = 0;
810 ListIterator li = l.listIterator();
811 while (li.hasNext()) {
812 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) li
813 .next();
814 protocol[i][0] = e.getName();
815 protocol[i][1] = e.getCName();
816 if (e.getGuidValue() != null) {
817 protocol[i][2] = e.getGuidValue();
818 }
819 protocol[i][3] = e.getHelpText();
820 protocol[i][4] = listToString(e.getSupArchList());
821 protocol[i][5] = listToString(e.getSupModuleList());
822 protocol[i][6] = listToString(e.getGuidTypeList());
823 i++;
824 }
825 }
826
827 /**
828 Get the number of Ppi declarations from the size of List
829
830 @return int
831 **/
832 public int getSpdPpiDeclarationCount() {
833 if (psaRoot.getPpiDeclarations() == null || psaRoot.getPpiDeclarations().getEntryList() == null) {
834 return 0;
835 }
836 return psaRoot.getPpiDeclarations().getEntryList().size();
837 }
838
839 /**
840 Get available Ppi declaration contents into String array
841
842 @param ppi Caller allocated two-dimentional String array
843 **/
844 public void getSpdPpiDeclarations(String[][] ppi) {
845 if (psaRoot.getPpiDeclarations() == null) {
846 return;
847 }
848
849 List<PpiDeclarationsDocument.PpiDeclarations.Entry> l = psaRoot.getPpiDeclarations().getEntryList();
850 int i = 0;
851 ListIterator li = l.listIterator();
852 while (li.hasNext()) {
853 PpiDeclarationsDocument.PpiDeclarations.Entry e = (PpiDeclarationsDocument.PpiDeclarations.Entry) li.next();
854 ppi[i][0] = e.getName();
855 ppi[i][1] = e.getCName();
856 if (e.getGuidValue() != null) {
857 ppi[i][2] = e.getGuidValue();
858 }
859 ppi[i][3] = e.getHelpText();
860 ppi[i][4] = listToString(e.getSupArchList());
861 ppi[i][5] = listToString(e.getSupModuleList());
862 ppi[i][6] = listToString(e.getGuidTypeList());
863 i++;
864 }
865 }
866
867 /**
868 Get the number of Pcd definitions from the size of List
869
870 @return int
871 **/
872 public int getSpdPcdDefinitionCount() {
873 if (psaRoot.getPcdDeclarations() == null || psaRoot.getPcdDeclarations().getPcdEntryList() == null) {
874 return 0;
875 }
876 return psaRoot.getPcdDeclarations().getPcdEntryList().size();
877 }
878
879 /**
880 Get available Pcd definition contents into String array
881
882 @param pcd Caller allocated two-dimentional String array
883 **/
884 public void getSpdPcdDefinitions(String[][] pcd, String pcdUsage[][]) {
885 if (psaRoot.getPcdDeclarations() == null) {
886 return;
887 }
888
889 List<PcdDeclarationsDocument.PcdDeclarations.PcdEntry> l = psaRoot.getPcdDeclarations().getPcdEntryList();
890 int i = 0;
891 while (i < l.size()) {
892 PcdDeclarationsDocument.PcdDeclarations.PcdEntry e = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)l.get(i);
893 pcd[i][0] = e.getCName();
894 pcd[i][1] = e.getToken() + "";
895 pcd[i][2] = e.getTokenSpaceGuidCName();
896 if (e.getDatumType() != null) {
897 pcd[i][3] = e.getDatumType().toString();
898 }
899 pcd[i][4] = e.getDefaultValue()+"";
900 pcd[i][5] = e.getHelpText();
901 String archList = listToString(e.getSupArchList());
902 if (archList != null) {
903 pcd[i][6] = archList;
904 }
905 String modTypeList = listToString(e.getSupModuleList());
906 if (modTypeList != null) {
907 pcd[i][7] = modTypeList;
908 }
909
910 int j = 0;
911 while (j < e.getValidUsage().size() && j < 5) {
912 pcdUsage[i][j] = (String)e.getValidUsage().get(j);
913 ++j;
914 }
915 i++;
916 }
917 }
918
919 /**
920 Save the processed xml contents to file
921
922 @param spdFile The file to save xml contents
923 @throws IOException Exceptions during file operation
924 **/
925 public void saveAs(File spdFile) throws IOException {
926
927 XmlOptions options = new XmlOptions();
928
929 options.setCharacterEncoding("UTF-8");
930 options.setSavePrettyPrint();
931 options.setSavePrettyPrintIndent(2);
932 try {
933 psad.save(spdFile, options);
934 } catch (IOException e) {
935 e.printStackTrace();
936 }
937
938 }
939
940 /**
941 Generate SpdHeader contents using parameters passed in.
942
943 @param pkgName PackageName
944 @param pkgGuid Guid
945 @param pkgVer Version
946 @param pkgAbs Abstract
947 @param pkgDes Description
948 @param pkgCpRight Copyright
949 @param pkgLicense License
950 @param pkgCreateDate Created
951 @param pkgUpdateDate Updated
952 @param pkgURL URL
953 @param pkgType PackageType
954 @param pkgRdOnly ReadOnly
955 @param pkgRePkg RePackage
956 @param pkgSpec Reserved
957 @param pkgOutDir Reserved
958 **/
959 public void genSpdHeader(String pkgName, String pkgGuid, String pkgVer, String pkgAbs, String pkgDes,
960 String pkgCpRight, String pkgLicense, String pkgCreateDate, String pkgUpdateDate,
961 String pkgURL, String pkgType, String pkgRdOnly, String pkgRePkg, String pkgSpec,
962 String pkgOutDir) {
963 if (getSpdHdr() == null) {
964 spdHdr = psaRoot.addNewSpdHeader();
965 }
966
967 setSpdHdrPkgName(pkgName);
968 setSpdHdrGuidValue(pkgGuid);
969 setSpdHdrVer(pkgVer);
970 setSpdHdrAbs(pkgAbs);
971 setSpdHdrDescription(pkgDes);
972 setSpdHdrCopyright(pkgCpRight);
973 setSpdHdrLicense(pkgLicense);
974
975
976 setSpdHdrSpec(pkgSpec);
977 }
978
979 /**
980 Generate library class declaration element using parameters passed in
981
982 @param libClassBaseName LibraryClass element value
983 @param libClassUsage Reserved
984 @param incHdrFileName IncludeHeader element value
985 @param incHdrAttribGuid Reserved
986 @param incHdrAttribArch Reserved
987 @param incHdrAttribPath Reserved
988 @param incHdrAttribClass Reserved
989 @param incHdrAttribVer Reserved
990 @param incHdrAttribOverrideID Reserved
991 @param incHdrAttribModuleType Reserved
992 **/
993 public void genSpdLibClassDeclarations(String libClassBaseName, String instanceUsage, String incHdrFileName,
994 String help, String incHdrAttribArch, String incHdrAttribPath,
995 String incHdrAttribClass, String incHdrAttribVer,
996 String incHdrAttribOverrideID, String incHdrAttribModuleType) {
997 if (getSpdLibClassDeclarations() == null) {
998 spdLibClassDeclarations = psaRoot.addNewLibraryClassDeclarations();
999 }
1000 //
1001 // add contents under LibraryClassDeclarations tag
1002 //
1003 setSpdLibClassDeclaration(libClassBaseName, instanceUsage, incHdrFileName, help, incHdrAttribArch,
1004 incHdrAttribPath, incHdrAttribClass, incHdrAttribVer, incHdrAttribOverrideID,
1005 incHdrAttribModuleType, spdLibClassDeclarations);
1006 }
1007
1008 public void getSpdLibClassDeclaration(String[] sa, int i) {
1009 if (getSpdLibClassDeclarations() == null) {
1010 return;
1011 }
1012 XmlCursor cursor = getSpdLibClassDeclarations().newCursor();
1013 if (cursor.toFirstChild()) {
1014 for (int j = 0; j < i; ++j) {
1015 cursor.toNextSibling();
1016 }
1017 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass)cursor.getObject();
1018 sa[0] = lc.getName();
1019 sa[1] = lc.getIncludeHeader();
1020 sa[2] = lc.getHelpText();
1021 sa[3] = lc.getRecommendedInstanceGuid();
1022 sa[4] = lc.getRecommendedInstanceVersion();
1023 sa[5] = listToString(lc.getSupArchList());
1024 sa[6] = listToString(lc.getSupModuleList());
1025 }
1026 cursor.dispose();
1027 }
1028
1029 /**
1030 Set library class declaration contents under parent tag
1031
1032 @param clsName LibraryClass element value
1033 @param clsUsage Reserved
1034 @param hdrFile IncludeHeader element value
1035 @param hdrAttribGuid Reserved
1036 @param hdrAttribArch Reserved
1037 @param hdrAttribPath Reserved
1038 @param hdrAttribClass Reserved
1039 @param hdrAttribVer Reserved
1040 @param hdrAttribOverID Reserved
1041 @param hdrAttribModType Reserved
1042 @param parent The tag under which library class declaration goes to
1043 **/
1044 public void setSpdLibClassDeclaration(String clsName, String clsUsage, String hdrFile, String help,
1045 String hdrAttribArch, String hdrAttribPath, String hdrAttribClass,
1046 String instanceVer, String hdrAttribOverID, String hdrAttribModType,
1047 XmlObject parent) {
1048
1049 setSpdLibraryClass(clsName, hdrFile, help, clsUsage, instanceVer, hdrAttribArch, hdrAttribModType, parent);
1050
1051 }
1052
1053 /**
1054 Set the contents of LibraryClass under parent element
1055
1056 @param clsName LibraryClass element value
1057 @param clsUsage Reserved
1058 @param parent The tag under which library class declaration goes to
1059 **/
1060 public void setSpdLibraryClass(String clsName, String clsIncludeFile, String help, String clsUsage, String instanceVer, String hdrAttribArch, String hdrAttribModType, XmlObject parent) {
1061 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = ((LibraryClassDeclarationsDocument.LibraryClassDeclarations) parent).addNewLibraryClass();
1062 lc.setName(clsName);
1063 lc.setIncludeHeader(clsIncludeFile);
1064 lc.setHelpText(help);
1065 // LAH added logic so you cannot set the version unless the GUID is defined.
1066
1067 if (clsUsage != null) {
1068 lc.setRecommendedInstanceGuid(clsUsage);
1069 if (instanceVer != null) {
1070 lc.setRecommendedInstanceVersion(instanceVer);
1071 }
1072 }
1073 else {
1074 if (lc.isSetRecommendedInstanceGuid()) {
1075 lc.unsetRecommendedInstanceGuid();
1076 }
1077 if (lc.isSetRecommendedInstanceVersion()) {
1078 lc.unsetRecommendedInstanceVersion();
1079 }
1080 }
1081
1082 if (hdrAttribArch != null) {
1083 lc.setSupArchList(stringToList(hdrAttribArch));
1084 } else {
1085 if (lc.isSetSupArchList()) {
1086 lc.unsetSupArchList();
1087 }
1088 }
1089
1090 if (hdrAttribModType != null) {
1091 lc.setSupModuleList(stringToList(hdrAttribModType));
1092 } else {
1093 if (lc.isSetSupModuleList()) {
1094 lc.unsetSupModuleList();
1095 }
1096 }
1097
1098 }
1099
1100 /**
1101 Set contents of IncludeHeader under parent element
1102
1103 @param modType Reserved
1104 @param hdrFile IncludeHeader element value
1105 @param hdrAttribGuid Reserved
1106 @param hdrAttribArch Reserved
1107 @param hdrAttribPath Reserved
1108 @param hdrAttribClass Reserved
1109 @param hdrAttribVer Reserved
1110 @param hdrAttribOverID Reserved
1111 @param parent The tag under which library class declaration goes to
1112 **/
1113 public void setSpdIncludeHeader(String modType, String hdrFile, String hdrAttribGuid, String hdrAttribArch,
1114 String hdrAttribPath, String hdrAttribClass, String hdrAttribVer,
1115 String hdrAttribOverID, XmlObject parent) {
1116
1117 if (parent instanceof LibraryClassDeclarationsDocument.LibraryClassDeclarations) {
1118 } else if (parent instanceof PackageHeadersDocument.PackageHeaders) {
1119 PackageHeadersDocument.PackageHeaders.IncludePkgHeader ih = null;
1120 ih = ((PackageHeadersDocument.PackageHeaders) parent).addNewIncludePkgHeader();
1121 ih.setStringValue(hdrFile);
1122 ih.setModuleType(ModuleTypeDef.Enum.forString(modType));
1123 } else {
1124 return;
1125 }
1126
1127 if (hdrAttribGuid != null) {
1128 }
1129 if (hdrAttribPath != null) {
1130 }
1131 if (hdrAttribClass != null) {
1132 }
1133 if (hdrAttribVer != null) {
1134 }
1135 if (hdrAttribOverID != null) {
1136 }
1137
1138 }
1139
1140 /**
1141 Generate MsaFile element.
1142
1143 @param msaFileName MsaFile element value
1144 @param archType Reserved
1145 **/
1146 public void genSpdMsaFiles(String msaFileName, String moduleName, String ver, String guid) {
1147 if (getSpdMsaFiles() == null) {
1148 spdMsaFiles = psaRoot.addNewMsaFiles();
1149 }
1150 setSpdMsaFile(msaFileName, moduleName, ver, guid, spdMsaFiles);
1151
1152 }
1153
1154 public void getSpdMsaFile (String[] sa, int i) {
1155 if (getSpdMsaFiles() == null) {
1156 return;
1157 }
1158 XmlCursor cursor = getSpdMsaFiles().newCursor();
1159 if (cursor.toFirstChild()) {
1160 for (int j = 0; j < i; ++j) {
1161 cursor.toNextSibling();
1162 }
1163 sa[0] = cursor.getTextValue();
1164 }
1165 cursor.dispose();
1166 }
1167
1168 /**
1169 Set MsaFile contents under parent element.
1170
1171 @param msaFileName MsaFile element value
1172 @param parent Element under which MsaFile goes to
1173 **/
1174 public void setSpdMsaFile(String msaFileName, String moduleName, String ver, String guid, XmlObject parent) {
1175 MsaFilesDocument.MsaFiles f = (MsaFilesDocument.MsaFiles)parent;
1176 f.addNewFilename().setStringValue(msaFileName);
1177 // f.setFilename(msaFileName);
1178 // f.setModuleName(moduleName);
1179 // f.setModuleVersion(ver);
1180 // f.setModuleGuid(guid);
1181 }
1182
1183 /**
1184 Generate PackageHeader element using parameters passed in.
1185
1186 @param ModHdrModType ModuleType attribute of IncludeHeader element
1187 @param hdrFile IncludeHeader element value
1188 @param hdrAttribGuid Reserved
1189 @param hdrAttribArch Reserved
1190 @param hdrAttribPath Reserved
1191 @param hdrAttribClass Reserved
1192 @param hdrAttribVer Reserved
1193 @param hdrAttribOverID Reserved
1194 **/
1195 public void genSpdModuleHeaders(String ModHdrModType, String hdrFile, String hdrAttribGuid, String hdrAttribArch,
1196 String hdrAttribPath, String hdrAttribClass, String hdrAttribVer,
1197 String hdrAttribOverID) {
1198 if (getSpdModHdrs() == null) {
1199 spdModHdrs = psaRoot.addNewPackageHeaders();
1200 }
1201
1202 //
1203 // add IncludeHeader under PackageHeaders element
1204 //
1205 setSpdIncludeHeader(ModHdrModType, hdrFile, hdrAttribGuid, hdrAttribArch, hdrAttribPath, hdrAttribClass,
1206 hdrAttribVer, hdrAttribOverID, spdModHdrs);
1207 }
1208
1209 public void getSpdModuleHeader(String[] sa, int i) {
1210 if (getSpdModHdrs() == null) {
1211 return;
1212 }
1213 XmlCursor cursor = getSpdModHdrs().newCursor();
1214 if (cursor.toFirstChild()) {
1215 for (int j = 0; j < i; ++j) {
1216 cursor.toNextSibling();
1217 }
1218 PackageHeadersDocument.PackageHeaders.IncludePkgHeader ih = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader)cursor.getObject();
1219 sa[0] = ih.getModuleType()+"";
1220 sa[1] = ih.getStringValue();
1221 }
1222 cursor.dispose();
1223 }
1224
1225 /**
1226 Generate GUID declaration element using parameters passed in.
1227
1228 @param guidDeclEntryName Name attribute of Entry element
1229 @param guidDeclCName CName element value
1230 @param guidDeclGuid Guid element value
1231 @param guidDeclFeatureFlag Reserved
1232 **/
1233 public void genSpdGuidDeclarations(String guidDeclEntryName, String guidDeclCName, String guidDeclGuid,
1234 String guidDeclHelp, Vector<String> archList, Vector<String> modTypeList,
1235 Vector<String> guidTypeList) {
1236 if (getSpdGuidDeclarations() == null) {
1237 spdGuidDeclarations = psaRoot.addNewGuidDeclarations();
1238 }
1239
1240 setSpdEntry(guidDeclEntryName, guidDeclCName, guidDeclGuid, guidDeclHelp, archList, modTypeList, guidTypeList, spdGuidDeclarations);
1241 }
1242
1243 /**
1244 Generate protocol declaration element using parameters passed in.
1245
1246 @param protocolDeclEntryName Name attribute of Entry element
1247 @param protocolDeclCName CName element value
1248 @param protocolDeclGuid Guid element value
1249 @param protocolDeclFeatureFlag Reserved
1250 **/
1251 public void genSpdProtocolDeclarations(String protocolDeclEntryName, String protocolDeclCName,
1252 String protocolDeclGuid, String protocolDeclFeatureFlag,
1253 Vector<String> archList, Vector<String> modTypeList, Vector<String> guidTypeList) {
1254 if (getSpdProtocolDeclarations() == null) {
1255 spdProtocolDeclarations = psaRoot.addNewProtocolDeclarations();
1256 }
1257
1258 setSpdEntry(protocolDeclEntryName, protocolDeclCName, protocolDeclGuid, protocolDeclFeatureFlag,
1259 archList, modTypeList, guidTypeList, spdProtocolDeclarations);
1260 }
1261
1262 /**
1263 Generate PPI declaration element using parameters passed in.
1264
1265 @param ppiDeclEntryName Name attribute of Entry element
1266 @param ppiDeclCName CName element value
1267 @param ppiDeclGuid Guid element value
1268 @param ppiDeclFeatureFlag Reserved
1269 **/
1270 public void genSpdPpiDeclarations(String ppiDeclEntryName, String ppiDeclCName, String ppiDeclGuid,
1271 String ppiDeclFeatureFlag, Vector<String> archList, Vector<String> modTypeList, Vector<String> guidTypeList) {
1272 if (getSpdPpiDeclarations() == null) {
1273 spdPpiDeclarations = psaRoot.addNewPpiDeclarations();
1274 }
1275
1276 setSpdEntry(ppiDeclEntryName, ppiDeclCName, ppiDeclGuid, ppiDeclFeatureFlag, archList, modTypeList, guidTypeList, spdPpiDeclarations);
1277 }
1278
1279 public void getSpdGuidDeclaration(String[] sa, int i) {
1280 if (getSpdGuidDeclarations() == null) {
1281 return;
1282 }
1283 getSpdEntry(sa, i, getSpdGuidDeclarations());
1284 }
1285
1286 public void getSpdProtocolDeclaration(String[] sa, int i) {
1287 if (getSpdProtocolDeclarations() == null) {
1288 return;
1289 }
1290 getSpdEntry(sa, i, getSpdProtocolDeclarations());
1291 }
1292
1293 public void getSpdPpiDeclaration(String[] sa, int i) {
1294 if (getSpdPpiDeclarations() == null) {
1295 return;
1296 }
1297 getSpdEntry(sa, i, getSpdPpiDeclarations());
1298 }
1299
1300 public void getSpdEntry(String[] sa, int i, XmlObject parent) {
1301 XmlCursor cursor = parent.newCursor();
1302 if (cursor.toFirstChild()) {
1303 for (int j = 0; j < i; ++j) {
1304 cursor.toNextSibling();
1305 }
1306 if (parent instanceof GuidDeclarationsDocument.GuidDeclarations) {
1307 GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.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 ProtocolDeclarationsDocument.ProtocolDeclarations) {
1318 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.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 if (parent instanceof PpiDeclarationsDocument.PpiDeclarations) {
1329 PpiDeclarationsDocument.PpiDeclarations.Entry e = (PpiDeclarationsDocument.PpiDeclarations.Entry)cursor.getObject();
1330 sa[0] = e.getName();
1331 sa[1] = e.getCName();
1332 sa[2] = e.getGuidValue();
1333 sa[3] = e.getHelpText();
1334 sa[4] = listToString(e.getSupArchList());
1335 sa[5] = listToString(e.getSupModuleList());
1336 sa[6] = listToString(e.getGuidTypeList());
1337 }
1338
1339 }
1340 cursor.dispose();
1341 }
1342 /**
1343 Set Entry contents using parameters passed in
1344
1345 @param entryName Name attribute of Entry element
1346 @param cName CName element value
1347 @param guid Guid element value
1348 @param featureFlag Reserved
1349 @param parent The tag under which Entry element goes to
1350 **/
1351 public void setSpdEntry(String entryName, String cName, String guid, String help,
1352 Vector<String> archList, Vector<String> modTypeList,
1353 Vector<String> guidTypeList, XmlObject parent) {
1354
1355 if (parent instanceof GuidDeclarationsDocument.GuidDeclarations) {
1356 GuidDeclarationsDocument.GuidDeclarations.Entry e = ((GuidDeclarations) parent).addNewEntry();
1357 e.setName(entryName);
1358 e.setCName(cName);
1359 e.setGuidValue(guid);
1360 e.setHelpText(help);
1361 if (guidTypeList != null) {
1362 e.setGuidTypeList(guidTypeList);
1363 }
1364 else{
1365 if (e.isSetGuidTypeList()) {
1366 e.unsetGuidTypeList();
1367 }
1368 }
1369 if (archList != null) {
1370 e.setSupArchList(archList);
1371 }
1372 else {
1373 if (e.isSetSupArchList()) {
1374 e.unsetSupArchList();
1375 }
1376 }
1377 if (modTypeList != null){
1378 e.setSupModuleList(modTypeList);
1379 }
1380 else {
1381 if (e.isSetSupModuleList()) {
1382 e.unsetSupModuleList();
1383 }
1384 }
1385
1386 return;
1387 }
1388 if (parent instanceof ProtocolDeclarationsDocument.ProtocolDeclarations) {
1389 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry pe = ((ProtocolDeclarationsDocument.ProtocolDeclarations) parent)
1390 .addNewEntry();
1391 pe.setName(entryName);
1392 pe.setCName(cName);
1393 pe.setGuidValue(guid);
1394 pe.setHelpText(help);
1395 if (guidTypeList != null) {
1396 pe.setGuidTypeList(guidTypeList);
1397 }
1398 else{
1399 if (pe.isSetGuidTypeList()) {
1400 pe.unsetGuidTypeList();
1401 }
1402 }
1403 if (archList != null) {
1404 pe.setSupArchList(archList);
1405 }
1406 else {
1407 if (pe.isSetSupArchList()) {
1408 pe.unsetSupArchList();
1409 }
1410 }
1411 if (modTypeList != null){
1412 pe.setSupModuleList(modTypeList);
1413 }
1414 else {
1415 if (pe.isSetSupModuleList()) {
1416 pe.unsetSupModuleList();
1417 }
1418 }
1419
1420 return;
1421 }
1422 if (parent instanceof PpiDeclarationsDocument.PpiDeclarations) {
1423 PpiDeclarationsDocument.PpiDeclarations.Entry ppe = ((PpiDeclarationsDocument.PpiDeclarations) parent)
1424 .addNewEntry();
1425 ppe.setName(entryName);
1426 ppe.setCName(cName);
1427 ppe.setGuidValue(guid);
1428 ppe.setHelpText(help);
1429 if (guidTypeList != null) {
1430 ppe.setGuidTypeList(guidTypeList);
1431 }
1432 else{
1433 if (ppe.isSetGuidTypeList()) {
1434 ppe.unsetGuidTypeList();
1435 }
1436 }
1437 if (archList != null) {
1438 ppe.setSupArchList(archList);
1439 }
1440 else {
1441 if (ppe.isSetSupArchList()) {
1442 ppe.unsetSupArchList();
1443 }
1444 }
1445 if (modTypeList != null){
1446 ppe.setSupModuleList(modTypeList);
1447 }
1448 else {
1449 if (ppe.isSetSupModuleList()) {
1450 ppe.unsetSupModuleList();
1451 }
1452 }
1453
1454 return;
1455 }
1456
1457 return;
1458
1459 }
1460
1461 /**
1462 Generate Pcd definition using parameters passed in
1463
1464 @param pcdItemTypes ItemType attribute of PcdEntry element
1465 @param cName C_Name element value
1466 @param token Token element value
1467 @param dataType DatumType element value
1468 @param skuEnable Reserved
1469 @param sku Reserved
1470 @param maxSku Reserved
1471 @param hiiEnable Reserved
1472 @param varGuid Reserved
1473 @param varName Reserved
1474 @param defaultString DefaultString element value
1475 **/
1476 public void genSpdPcdDefinitions(String cName, String token, String dataType, String pcdItemTypes,
1477 String spaceGuid, String defaultString, String help, String archList,
1478 String modTypeList) {
1479 if (getSpdPcdDefinitions() == null) {
1480 spdPcdDefinitions = psaRoot.addNewPcdDeclarations();
1481 }
1482
1483 setSpdPcdEntry(pcdItemTypes, cName, token, dataType, spaceGuid, help,
1484 defaultString, archList, modTypeList, spdPcdDefinitions);
1485 }
1486
1487 public void getSpdPcdDeclaration(String[] sa, int i) {
1488 if (getSpdPcdDefinitions() == null) {
1489 return;
1490 }
1491
1492 XmlCursor cursor = getSpdPcdDefinitions().newCursor();
1493 if (cursor.toFirstChild()) {
1494 for (int j = 0; j < i; ++j) {
1495 cursor.toNextSibling();
1496 }
1497 PcdDeclarationsDocument.PcdDeclarations.PcdEntry pe = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)cursor.getObject();
1498 sa[0] = pe.getCName();
1499 sa[1] = pe.getToken()+"";
1500 sa[2] = pe.getTokenSpaceGuidCName();
1501 sa[3] = pe.getDatumType()+"";
1502 sa[4] = pe.getDefaultValue();
1503 sa[5] = pe.getHelpText();
1504 sa[6] = listToString(pe.getValidUsage());
1505 sa[7] = listToString(pe.getSupArchList());
1506 sa[8] = listToString(pe.getSupModuleList());
1507 }
1508 cursor.dispose();
1509 }
1510
1511 /**
1512 Set Pcd entry contents under parent tag
1513
1514 @param pcdItemTypes ItemType attribute of PcdEntry element
1515 @param cName C_Name element value
1516 @param token Token element value
1517 @param dataType DatumType element value
1518 @param spaceGuid Reserved
1519 @param help Reserved
1520 @param defaultString DefaultString element value
1521 @param parent Tag under which PcdEntry goes to
1522 **/
1523 public void setSpdPcdEntry(String pcdItemTypes, String cName, String token, String dataType, String spaceGuid, String help,
1524 String defaultString, String archList, String modTypeList, XmlObject parent) {
1525
1526 PcdDeclarationsDocument.PcdDeclarations.PcdEntry pe = ((PcdDeclarationsDocument.PcdDeclarations) parent).addNewPcdEntry();
1527
1528 //ToDo: maybe multiple types in, need parse pcdItemTypes.
1529 String usage[] = pcdItemTypes.split("( )+");
1530 List<String> l = new ArrayList<String>();
1531 for (int i = 0; i < usage.length; ++i) {
1532 l.add(usage[i]);
1533 }
1534 pe.setValidUsage(l);
1535 pe.setCName(cName);
1536 pe.setToken(token);
1537 pe.setDatumType(PcdDataTypes.Enum.forString(dataType));
1538 pe.setDefaultValue(defaultString);
1539 pe.setTokenSpaceGuidCName(spaceGuid);
1540 pe.setHelpText(help);
1541 if (archList != null){
1542 pe.setSupArchList(stringToList(archList));
1543 } else {
1544 if (pe.isSetSupArchList()) {
1545 pe.unsetSupArchList();
1546 }
1547 }
1548 if (modTypeList != null){
1549 pe.setSupModuleList(stringToList(modTypeList));
1550 } else {
1551 if (pe.isSetSupModuleList()) {
1552 pe.unsetSupModuleList();
1553 }
1554 }
1555 }
1556
1557 /**
1558 Get PpiDeclarations element
1559
1560 @return PpiDeclarationsDocument.PpiDeclarations
1561 **/
1562 public PpiDeclarationsDocument.PpiDeclarations getSpdPpiDeclarations() {
1563 if (spdPpiDeclarations == null) {
1564 spdPpiDeclarations = psaRoot.getPpiDeclarations();
1565 }
1566 return spdPpiDeclarations;
1567 }
1568
1569 /**
1570 Get ProtocolDeclarations element
1571
1572 @return ProtocolDeclarationsDocument.ProtocolDeclarations
1573 **/
1574 public ProtocolDeclarationsDocument.ProtocolDeclarations getSpdProtocolDeclarations() {
1575 if (spdProtocolDeclarations == null) {
1576 spdProtocolDeclarations = psaRoot.getProtocolDeclarations();
1577 }
1578 return spdProtocolDeclarations;
1579 }
1580
1581 /**
1582 Get GuidDeclarations element
1583
1584 @return GuidDeclarationsDocument.GuidDeclarations
1585 **/
1586 public GuidDeclarationsDocument.GuidDeclarations getSpdGuidDeclarations() {
1587 if (spdGuidDeclarations == null) {
1588 spdGuidDeclarations = psaRoot.getGuidDeclarations();
1589 }
1590 return spdGuidDeclarations;
1591 }
1592
1593 /**
1594 Get PcdDefinitions element
1595
1596 @return PcdDefinitionsDocument.PcdDefinitions
1597 **/
1598 public PcdDeclarationsDocument.PcdDeclarations getSpdPcdDefinitions() {
1599 if (spdPcdDefinitions == null) {
1600 spdPcdDefinitions = psaRoot.getPcdDeclarations();
1601 }
1602 return spdPcdDefinitions;
1603 }
1604
1605 /**
1606 Get PackageHeaders element
1607
1608 @return PackageHeadersDocument.PackageHeaders
1609 **/
1610 public PackageHeadersDocument.PackageHeaders getSpdModHdrs() {
1611 if (spdModHdrs == null) {
1612 spdModHdrs = psaRoot.getPackageHeaders();
1613 }
1614 return spdModHdrs;
1615 }
1616
1617 /**
1618 Get MsaFiles element
1619
1620 @return MsaFilesDocument.MsaFiles
1621 **/
1622 public MsaFilesDocument.MsaFiles getSpdMsaFiles() {
1623 if (spdMsaFiles == null) {
1624 spdMsaFiles = psaRoot.getMsaFiles();
1625 }
1626 return spdMsaFiles;
1627 }
1628
1629 /**
1630 Get LibraryClassDeclarations element
1631
1632 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
1633 **/
1634 public LibraryClassDeclarationsDocument.LibraryClassDeclarations getSpdLibClassDeclarations() {
1635 if (spdLibClassDeclarations == null) {
1636 spdLibClassDeclarations = psaRoot.getLibraryClassDeclarations();
1637 }
1638 return spdLibClassDeclarations;
1639 }
1640
1641 public PackageDefinitionsDocument.PackageDefinitions getSpdPkgDefs() {
1642 if (spdPkgDefs == null) {
1643 spdPkgDefs = psaRoot.addNewPackageDefinitions();
1644 }
1645 return spdPkgDefs;
1646 }
1647 /**
1648 Get SpdHeader element
1649
1650 @return SpdHeaderDocument.SpdHeader
1651 **/
1652 public SpdHeaderDocument.SpdHeader getSpdHdr() {
1653 if (spdHdr == null) {
1654 spdHdr = psaRoot.addNewSpdHeader();
1655 }
1656 return spdHdr;
1657 }
1658
1659 /**
1660 Set value to Guid element
1661
1662 @param guid The value set to Guid element
1663 **/
1664 public void setSpdHdrGuidValue(String guid) {
1665 getSpdHdr().setGuidValue(guid);
1666 }
1667
1668 /**
1669 Get Version element under SpdHdr
1670
1671 @return String
1672 **/
1673 public String getSpdHdrVer() {
1674 return getSpdHdr().getVersion();
1675 }
1676
1677 /**
1678 Set value to Version element
1679
1680 @param ver The value set to Version element
1681 **/
1682 public void setSpdHdrVer(String ver) {
1683 getSpdHdr().setVersion(ver);
1684 }
1685
1686 public String getSpdHdrAbs(){
1687 return getSpdHdr().getAbstract();
1688
1689 }
1690
1691 /**
1692 Set value to Abstract element
1693
1694 @param abs The value set to Abstract element
1695 **/
1696 public void setSpdHdrAbs(String abs) {
1697
1698 getSpdHdr().setAbstract(abs);
1699 }
1700
1701 public String getSpdHdrDescription(){
1702 return getSpdHdr().getDescription();
1703 }
1704 /**
1705 Set value to Description element
1706
1707 @param des The value set to Description element
1708 **/
1709 public void setSpdHdrDescription(String des) {
1710 getSpdHdr().setDescription(des);
1711 }
1712
1713 public String getSpdHdrCopyright(){
1714 return getSpdHdr().getCopyright();
1715 }
1716 /**
1717 Set value to Copyright element
1718
1719 @param cpRit The value set to Copyright element
1720 **/
1721 public void setSpdHdrCopyright(String cpRit) {
1722
1723 getSpdHdr().setCopyright(cpRit);
1724
1725 }
1726 /**
1727 Get License element under SpdHdr
1728
1729 @return String
1730 **/
1731 public String getSpdHdrLicense() {
1732 if (getSpdHdr().getLicense() != null) {
1733 return getSpdHdr().getLicense().getStringValue();
1734 }
1735 return null;
1736 }
1737
1738 /**
1739 Set value to License element
1740
1741 @param license The value set to License element
1742 **/
1743 public void setSpdHdrLicense(String license) {
1744 if (getSpdHdr().getLicense() == null){
1745 getSpdHdr().addNewLicense().setStringValue(license);
1746 }
1747 else {
1748 getSpdHdr().getLicense().setStringValue(license);
1749 }
1750 }
1751
1752 public String getSpdHdrUrl(){
1753 if (getSpdHdr().getLicense() != null) {
1754 return getSpdHdr().getLicense().getURL();
1755 }
1756 return null;
1757 }
1758
1759 public void setSpdHdrUrl(String url){
1760 getSpdHdr().getLicense().setURL(url);
1761 }
1762
1763 /**
1764 Get PackageName element under SpdHdr
1765
1766 @return String
1767 **/
1768 public String getSpdHdrPkgName() {
1769
1770 return getSpdHdr().getPackageName();
1771 }
1772
1773 /**
1774 Set value to PackageName element
1775
1776 @param pkgName The value set to PackageName element
1777 **/
1778 public void setSpdHdrPkgName(String pkgName) {
1779 getSpdHdr().setPackageName(pkgName);
1780 }
1781
1782 public String getSpdHdrGuidValue(){
1783 return getSpdHdr().getGuidValue();
1784 }
1785
1786 /**
1787 Reserved method
1788
1789 @return SpecificationDocument.Specification
1790 **/
1791 public String getSpdHdrSpec() {
1792 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1793 // return getSpdHdr().getSpecification();
1794 }
1795
1796 /**
1797 Reserved method
1798
1799 @param spec
1800 **/
1801 public void setSpdHdrSpec(String spec) {
1802 spec = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1803 getSpdHdr().setSpecification(spec);
1804
1805 }
1806
1807 public String getSpdPkgDefsRdOnly(){
1808 return getSpdPkgDefs().getReadOnly() + "";
1809 }
1810 /**
1811 Set value to ReadOnly element
1812
1813 @param rdOnly The value set to ReadOnly element
1814 **/
1815 public void setSpdPkgDefsRdOnly(String rdOnly) {
1816
1817 getSpdPkgDefs().setReadOnly(new Boolean(rdOnly));
1818 }
1819
1820 public String getSpdPkgDefsRePkg(){
1821 return getSpdPkgDefs().getRePackage() + "";
1822 }
1823 /**
1824 Set value to RePackage element
1825
1826 @param rePkg The value set to RePackage element
1827 **/
1828 public void setSpdPkgDefsRePkg(String rePkg) {
1829
1830 getSpdPkgDefs().setRePackage(new Boolean(rePkg));
1831 }
1832
1833 /**
1834 Set value to URL element
1835
1836 @param url The value set to URL element
1837 **/
1838 // public void setSpdHdrURL(String url) {
1839 // getSpdHdr().setURL(url);
1840 // }
1841
1842 /**
1843 Get xml file
1844
1845 @return File
1846 **/
1847 public File getFile() {
1848 return file;
1849 }
1850
1851 /**
1852 Set file
1853
1854 @param file File with xml format
1855 **/
1856 public void setFile(File file) {
1857 this.file = file;
1858 }
1859
1860 private List<String> stringToList(String s){
1861 if (s == null || s.length() == 0) {
1862 return null;
1863 }
1864 Vector<String> al = new Vector<String>();
1865 String[] sArray = s.split(" ");
1866 for(int i = 0; i < sArray.length; ++i){
1867 al.add(sArray[i]);
1868 }
1869 return al;
1870 }
1871
1872 private String listToString(List l) {
1873 if (l == null) {
1874 return null;
1875 }
1876 String s = " ";
1877 ListIterator li = l.listIterator();
1878 while(li.hasNext()) {
1879 s += li.next();
1880 s += " ";
1881 }
1882 return s.trim();
1883 }
1884
1885 }