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