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