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