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