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