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