2 Java class SpdFileContents is used to parse spd xml file.
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
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.
13 package org
.tianocore
.frameworkwizard
.packaging
.ui
;
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
;
23 import org
.apache
.xmlbeans
.XmlObject
;
24 import org
.apache
.xmlbeans
.XmlOptions
;
25 import org
.apache
.xmlbeans
.XmlCursor
;
27 import org
.tianocore
.GuidDeclarationsDocument
;
29 import org
.tianocore
.LibraryClassDeclarationsDocument
;
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
;
44 This class processes spd file contents such as add remove xml elements.
46 @since PackageEditor 1.0
49 public class SpdFileContents
{
51 private File file
= null;
53 private PackageSurfaceAreaDocument psad
= null;
55 private PackageSurfaceAreaDocument
.PackageSurfaceArea psaRoot
= null;
57 private SpdHeaderDocument
.SpdHeader spdHdr
= null;
59 private PackageDefinitionsDocument
.PackageDefinitions spdPkgDefs
= null;
61 private LibraryClassDeclarationsDocument
.LibraryClassDeclarations spdLibClassDeclarations
= null;
63 private MsaFilesDocument
.MsaFiles spdMsaFiles
= null;
65 private PackageHeadersDocument
.PackageHeaders spdModHdrs
= null;
67 private GuidDeclarationsDocument
.GuidDeclarations spdGuidDeclarations
= null;
69 private ProtocolDeclarationsDocument
.ProtocolDeclarations spdProtocolDeclarations
= null;
71 private PpiDeclarationsDocument
.PpiDeclarations spdPpiDeclarations
= null;
73 private PcdDeclarationsDocument
.PcdDeclarations spdPcdDefinitions
= null;
76 Constructor to create a new spd file
78 public SpdFileContents() {
80 psad
= PackageSurfaceAreaDocument
.Factory
.newInstance();
81 psaRoot
= psad
.addNewPackageSurfaceArea();
86 Constructor for existing document object
89 public SpdFileContents(PackageSurfaceAreaDocument
.PackageSurfaceArea psa
) {
91 spdHdr
= psaRoot
.getSpdHeader();
92 spdPkgDefs
= psaRoot
.getPackageDefinitions();
95 Constructor based on an existing spd file
97 @param f Existing spd file
99 public SpdFileContents(File f
) {
101 psad
= PackageSurfaceAreaDocument
.Factory
.parse(f
);
102 psaRoot
= psad
.getPackageSurfaceArea();
104 } catch (Exception e
) {
105 System
.out
.println(e
.toString());
110 Remove existing pcd definitions elements using XmlCursor
112 public void removeSpdPcdDefinition() {
113 XmlObject o
= psaRoot
.getPcdDeclarations();
116 XmlCursor cursor
= o
.newCursor();
118 spdPcdDefinitions
= null;
122 public void removeSpdPcdDefinition(int i
){
123 XmlObject o
= psaRoot
.getPcdDeclarations();
126 XmlCursor cursor
= o
.newCursor();
127 if (cursor
.toFirstChild()) {
128 for (int j
= 0; j
< i
; ++j
) {
129 cursor
.toNextSibling();
132 if (getSpdPcdDefinitionCount() == 0) {
141 Remove existing ppi declarations using XmlCursor
143 public void removeSpdPpiDeclaration() {
144 XmlObject o
= psaRoot
.getPpiDeclarations();
147 XmlCursor cursor
= o
.newCursor();
149 spdPpiDeclarations
= null;
153 public void removeSpdPpiDeclaration(int i
){
154 XmlObject o
= psaRoot
.getPpiDeclarations();
157 XmlCursor cursor
= o
.newCursor();
158 if (cursor
.toFirstChild()) {
159 for (int j
= 0; j
< i
; ++j
) {
160 cursor
.toNextSibling();
163 if (getSpdPpiDeclarationCount() == 0){
171 Remove existing protocols declarations using XmlCursor
173 public void removeSpdProtocolDeclaration() {
174 XmlObject o
= psaRoot
.getProtocolDeclarations();
177 XmlCursor cursor
= o
.newCursor();
179 spdProtocolDeclarations
= null;
183 public void removeSpdProtocolDeclaration(int i
) {
184 XmlObject o
= psaRoot
.getProtocolDeclarations();
187 XmlCursor cursor
= o
.newCursor();
188 if (cursor
.toFirstChild()) {
189 for (int j
= 0; j
< i
; ++j
) {
190 cursor
.toNextSibling();
193 if (getSpdProtocolDeclarationCount() == 0) {
201 Remove existing GUID declarations using XmlCursor
203 public void removeSpdGuidDeclaration() {
204 XmlObject o
= psaRoot
.getGuidDeclarations();
207 XmlCursor cursor
= o
.newCursor();
209 spdGuidDeclarations
= null;
213 public void removeSpdGuidDeclaration(int i
) {
214 XmlObject o
= psaRoot
.getGuidDeclarations();
217 XmlCursor cursor
= o
.newCursor();
218 if (cursor
.toFirstChild()) {
219 for (int j
= 0; j
< i
; ++j
) {
220 cursor
.toNextSibling();
223 if (getSpdGuidDeclarationCount() == 0) {
232 Remove existing spd package include files using XmlCursor
234 public void removeSpdPkgHeader() {
235 XmlObject o
= psaRoot
.getPackageHeaders();
238 XmlCursor cursor
= o
.newCursor();
244 public void removeSpdPkgHeader(int i
){
245 XmlObject o
= psaRoot
.getPackageHeaders();
248 XmlCursor cursor
= o
.newCursor();
249 if (cursor
.toFirstChild()) {
250 for (int j
= 0; j
< i
; ++j
) {
251 cursor
.toNextSibling();
254 if (getSpdPackageHeaderCount() == 0) {
263 Remove existing msa files using XmlCursor
265 public void removeSpdMsaFile() {
266 XmlObject o
= psaRoot
.getMsaFiles();
269 XmlCursor cursor
= o
.newCursor();
275 public void removeSpdMsaFile(int i
){
276 XmlObject o
= psaRoot
.getMsaFiles();
279 XmlCursor cursor
= o
.newCursor();
280 if (cursor
.toFirstChild()) {
281 for (int j
= 0; j
< i
; ++j
) {
282 cursor
.toNextSibling();
285 if (getSpdMsaFileCount() == 0) {
294 Remove existing library class declarations using XmlCursor
296 public void removeSpdLibClass() {
297 XmlObject o
= psaRoot
.getLibraryClassDeclarations();
300 XmlCursor cursor
= o
.newCursor();
302 spdLibClassDeclarations
= null;
306 public void removeSpdLibClass(int i
) {
307 XmlObject o
= psaRoot
.getLibraryClassDeclarations();
310 XmlCursor cursor
= o
.newCursor();
311 if (cursor
.toFirstChild()) {
312 for (int j
= 0; j
< i
; ++j
) {
313 cursor
.toNextSibling();
316 if (getSpdLibClassDeclarationCount() == 0) {
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();
329 XmlCursor cursor
= o
.newCursor();
330 if (cursor
.toFirstChild()) {
331 for (int j
= 0; j
< i
; ++j
) {
332 cursor
.toNextSibling();
334 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass lc
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
)cursor
.getObject();
336 lc
.setIncludeHeader(hdr
);
338 if (clsUsage
!= null) {
339 lc
.setRecommendedInstanceGuid(clsUsage
);
340 if (instanceVer
!= null){
341 lc
.setRecommendedInstanceVersion(instanceVer
);
343 if (lc
.isSetRecommendedInstanceVersion()) {
344 lc
.unsetRecommendedInstanceVersion();
348 if (lc
.isSetRecommendedInstanceGuid()) {
349 lc
.unsetRecommendedInstanceGuid();
351 if (lc
.isSetRecommendedInstanceVersion()) {
352 lc
.unsetRecommendedInstanceVersion();
356 if (stringToList(hdrAttribArch
) != null){
357 lc
.setSupArchList(stringToList(hdrAttribArch
));
359 if (lc
.isSetSupArchList()) {
360 lc
.unsetSupArchList();
363 if (stringToList(hdrAttribModType
) != null){
364 lc
.setSupModuleList(stringToList(hdrAttribModType
));
366 if (lc
.isSetSupModuleList()) {
367 lc
.unsetSupModuleList();
375 public void updateSpdMsaFile(int i
, String msaFile
, String mName
, String v
, String g
){
376 XmlObject o
= psaRoot
.getMsaFiles();
380 XmlCursor cursor
= o
.newCursor();
381 if (cursor
.toFirstChild()) {
382 for (int j
= 0; j
< i
; ++j
) {
383 cursor
.toNextSibling();
385 cursor
.setTextValue(msaFile
);
392 public void updateSpdGuidDecl(int i
, String name
, String cName
, String guid
, String hlp
, String archList
,
393 String modTypeList
, String guidTypeList
){
394 XmlObject o
= psaRoot
.getGuidDeclarations();
399 XmlCursor cursor
= o
.newCursor();
400 if (cursor
.toFirstChild()) {
401 for (int j
= 0; j
< i
; ++j
) {
402 cursor
.toNextSibling();
404 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
)cursor
.getObject();
407 e
.setGuidValue(guid
);
409 if (stringToList(guidTypeList
) != null) {
410 e
.setGuidTypeList(stringToList(guidTypeList
));
413 if (e
.isSetGuidTypeList()) {
414 e
.unsetGuidTypeList();
417 if (stringToList(archList
) != null){
418 e
.setSupArchList(stringToList(archList
));
421 if (e
.isSetSupArchList()) {
422 e
.unsetSupArchList();
425 if (stringToList(modTypeList
) != null) {
426 e
.setSupModuleList(stringToList(modTypeList
));
429 if (e
.isSetSupModuleList()) {
430 e
.unsetSupModuleList();
438 public void updateSpdPpiDecl(int i
, String name
, String cName
, String guid
, String hlp
, String archList
,
439 String modTypeList
, String guidTypeList
){
440 XmlObject o
= psaRoot
.getPpiDeclarations();
445 XmlCursor cursor
= o
.newCursor();
446 if (cursor
.toFirstChild()) {
447 for (int j
= 0; j
< i
; ++j
) {
448 cursor
.toNextSibling();
450 PpiDeclarationsDocument
.PpiDeclarations
.Entry e
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
)cursor
.getObject();
453 e
.setGuidValue(guid
);
455 if (stringToList(guidTypeList
) != null) {
456 e
.setGuidTypeList(stringToList(guidTypeList
));
459 if (e
.isSetGuidTypeList()) {
460 e
.unsetGuidTypeList();
463 if (stringToList(archList
) != null){
464 e
.setSupArchList(stringToList(archList
));
467 if (e
.isSetSupArchList()) {
468 e
.unsetSupArchList();
471 if (stringToList(modTypeList
) != null) {
472 e
.setSupModuleList(stringToList(modTypeList
));
475 if (e
.isSetSupModuleList()) {
476 e
.unsetSupModuleList();
483 public void updateSpdProtocolDecl(int i
, String name
, String cName
, String guid
, String hlp
, String archList
,
484 String modTypeList
, String guidTypeList
){
485 XmlObject o
= psaRoot
.getProtocolDeclarations();
490 XmlCursor cursor
= o
.newCursor();
491 if (cursor
.toFirstChild()) {
492 for (int j
= 0; j
< i
; ++j
) {
493 cursor
.toNextSibling();
495 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry e
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
)cursor
.getObject();
498 e
.setGuidValue(guid
);
500 if (stringToList(guidTypeList
) != null) {
501 e
.setGuidTypeList(stringToList(guidTypeList
));
504 if (e
.isSetGuidTypeList()) {
505 e
.unsetGuidTypeList();
508 if (stringToList(archList
) != null){
509 e
.setSupArchList(stringToList(archList
));
512 if (e
.isSetSupArchList()) {
513 e
.unsetSupArchList();
516 if (stringToList(modTypeList
) != null) {
517 e
.setSupModuleList(stringToList(modTypeList
));
520 if (e
.isSetSupModuleList()) {
521 e
.unsetSupModuleList();
528 public void updateSpdPkgHdr(int i
, String pkgName
, String hdrName
){
529 XmlObject o
= psaRoot
.getPackageHeaders();
534 XmlCursor cursor
= o
.newCursor();
535 if (cursor
.toFirstChild()) {
536 for (int j
= 0; j
< i
; ++j
) {
537 cursor
.toNextSibling();
540 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader iph
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
)cursor
.getObject();
541 iph
.setModuleType(ModuleTypeDef
.Enum
.forString(pkgName
));
542 iph
.setStringValue(hdrName
);
547 public void updateSpdPcdDefinition(int i
, String cName
, String token
, String dataType
, String pcdItemTypes
,
548 String spaceGuid
, String defaultString
, String help
, String archList
, String modTypeList
){
549 XmlObject o
= psaRoot
.getPcdDeclarations();
552 XmlCursor cursor
= o
.newCursor();
553 if (cursor
.toFirstChild()) {
554 for (int j
= 0; j
< i
; ++j
) {
555 cursor
.toNextSibling();
557 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry e
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)cursor
.getObject();
560 e
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
561 if (pcdItemTypes
!= null && pcdItemTypes
.length() > 0) {
562 String usage
[] = pcdItemTypes
.split("( )+");
563 List
<String
> l
= new ArrayList
<String
>();
564 for (int k
= 0; k
< usage
.length
; ++k
) {
570 e
.setTokenSpaceGuidCName(spaceGuid
);
571 e
.setDefaultValue(defaultString
);
573 if (stringToList(archList
) != null){
574 e
.setSupArchList(stringToList(archList
));
577 if (e
.isSetSupArchList()) {
578 e
.unsetSupArchList();
581 if (stringToList(modTypeList
) != null) {
582 e
.setSupModuleList(stringToList(modTypeList
));
585 if (e
.isSetSupModuleList()) {
586 e
.unsetSupModuleList();
594 Get spd file header contents into String array
596 @param s Caller allocated String array
598 public void getSpdHdrDetails(String
[] s
) {
599 if (getSpdHdr() == null) {
600 spdHdr
= psaRoot
.addNewSpdHeader();
602 s
[0] = getSpdHdrPkgName();
603 s
[1] = getSpdHdr().getGuidValue();
604 s
[2] = getSpdHdrVer();
605 // s[3] = getSpdHdr().getAbstract();
606 s
[4] = getSpdHdr().getDescription();
607 s
[5] = getSpdHdr().getCopyright();
608 s
[6] = getSpdHdrLicense();
613 Get the number of library class declarations from the size of List
617 public int getSpdLibClassDeclarationCount() {
618 if (psaRoot
.getLibraryClassDeclarations() == null
619 || psaRoot
.getLibraryClassDeclarations().getLibraryClassList() == null) {
622 return psaRoot
.getLibraryClassDeclarations().getLibraryClassList().size();
626 Get available library class declaration into String array
627 @param libClass Caller allocated two-dimentional String array
629 public void getSpdLibClassDeclarations(String
[][] libClass
) {
630 if (psaRoot
.getLibraryClassDeclarations() == null){
634 List
<LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
> l
= psaRoot
.getLibraryClassDeclarations().getLibraryClassList();
636 ListIterator li
= l
.listIterator();
637 while (li
.hasNext()) {
638 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass lc
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) li
.next();
640 libClass
[i
][0] = lc
.getName();
641 libClass
[i
][1] = lc
.getIncludeHeader();
642 libClass
[i
][2] = lc
.getHelpText();
643 // LAH added logic so you cannot set the version unless the GUID is defined.
645 // if (lc.getRecommendedInstanceGuid() != null) {
646 libClass
[i
][3] = lc
.getRecommendedInstanceGuid();
647 // if (lc.getRecommendedInstanceVersion() != null) {
648 libClass
[i
][4] = lc
.getRecommendedInstanceVersion();
652 if (lc
.getSupArchList() != null) {
653 libClass
[i
][5] = listToString(lc
.getSupArchList());
655 if (lc
.getSupModuleList() != null) {
656 libClass
[i
][6] = listToString(lc
.getSupModuleList());
667 Get the number of Msa files from the size of List
671 public int getSpdMsaFileCount() {
672 if (psaRoot
.getMsaFiles() == null || psaRoot
.getMsaFiles().getFilenameList() == null) {
675 return psaRoot
.getMsaFiles().getFilenameList().size();
679 Get available Msa file into String array
681 @param msaFile Caller allocated two-dimentional String array
683 public void getSpdMsaFiles(String
[][] msaFile
) {
684 if (psaRoot
.getMsaFiles() == null) {
687 List
<String
> l
= psaRoot
.getMsaFiles().getFilenameList();
689 ListIterator li
= l
.listIterator();
690 while (li
.hasNext()) {
691 msaFile
[i
][0] = (String
)li
.next();
698 Get the number of include header files in PackageHeaders from the size of List
702 public int getSpdPackageHeaderCount() {
703 if (psaRoot
.getPackageHeaders() == null || psaRoot
.getPackageHeaders().getIncludePkgHeaderList() == null) {
706 return psaRoot
.getPackageHeaders().getIncludePkgHeaderList().size();
710 Get available package header contents into String array
712 @param pkgHeader Caller allocated two-dimentional String array
714 public void getSpdPackageHeaders(String
[][] pkgHeader
) {
715 if (psaRoot
.getPackageHeaders() == null) {
719 List
<PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
> l
= psaRoot
.getPackageHeaders().getIncludePkgHeaderList();
721 ListIterator li
= l
.listIterator();
722 while (li
.hasNext()) {
723 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader ih
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) li
.next();
724 if (ih
.getModuleType() != null) {
725 pkgHeader
[i
][0] = ih
.getModuleType().toString();
728 pkgHeader
[i
][1] = ih
.getStringValue();
734 Get the number of GUID declarations from the size of List
738 public int getSpdGuidDeclarationCount() {
739 if (psaRoot
.getGuidDeclarations() == null || psaRoot
.getGuidDeclarations().getEntryList() == null) {
742 return psaRoot
.getGuidDeclarations().getEntryList().size();
746 Get available Guid declaration contents into String array
748 @param guid Caller allocated two-dimentional String array
750 public void getSpdGuidDeclarations(String
[][] guid
) {
751 if (psaRoot
.getGuidDeclarations() == null) {
755 List
<GuidDeclarationsDocument
.GuidDeclarations
.Entry
> l
= psaRoot
.getGuidDeclarations().getEntryList();
757 ListIterator li
= l
.listIterator();
758 while (li
.hasNext()) {
759 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) li
761 guid
[i
][0] = e
.getName();
762 guid
[i
][1] = e
.getCName();
763 if (e
.getGuidValue() != null) {
764 guid
[i
][2] = e
.getGuidValue();
766 guid
[i
][3] = e
.getHelpText();
767 guid
[i
][4] = listToString(e
.getSupArchList());
768 guid
[i
][5] = listToString(e
.getSupModuleList());
769 guid
[i
][6] = listToString(e
.getGuidTypeList());
775 Get the number of protocol declarations from the size of List
779 public int getSpdProtocolDeclarationCount() {
780 if (psaRoot
.getProtocolDeclarations() == null || psaRoot
.getProtocolDeclarations().getEntryList() == null) {
783 return psaRoot
.getProtocolDeclarations().getEntryList().size();
787 Get available protocol declaration contents into String array
789 @param protocol Caller allocated two-dimentional String array
791 public void getSpdProtocolDeclarations(String
[][] protocol
) {
792 if (psaRoot
.getProtocolDeclarations() == null) {
796 List
<ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
> l
= psaRoot
.getProtocolDeclarations()
799 ListIterator li
= l
.listIterator();
800 while (li
.hasNext()) {
801 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry e
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) li
803 protocol
[i
][0] = e
.getName();
804 protocol
[i
][1] = e
.getCName();
805 if (e
.getGuidValue() != null) {
806 protocol
[i
][2] = e
.getGuidValue();
808 protocol
[i
][3] = e
.getHelpText();
809 protocol
[i
][4] = listToString(e
.getSupArchList());
810 protocol
[i
][5] = listToString(e
.getSupModuleList());
811 protocol
[i
][6] = listToString(e
.getGuidTypeList());
817 Get the number of Ppi declarations from the size of List
821 public int getSpdPpiDeclarationCount() {
822 if (psaRoot
.getPpiDeclarations() == null || psaRoot
.getPpiDeclarations().getEntryList() == null) {
825 return psaRoot
.getPpiDeclarations().getEntryList().size();
829 Get available Ppi declaration contents into String array
831 @param ppi Caller allocated two-dimentional String array
833 public void getSpdPpiDeclarations(String
[][] ppi
) {
834 if (psaRoot
.getPpiDeclarations() == null) {
838 List
<PpiDeclarationsDocument
.PpiDeclarations
.Entry
> l
= psaRoot
.getPpiDeclarations().getEntryList();
840 ListIterator li
= l
.listIterator();
841 while (li
.hasNext()) {
842 PpiDeclarationsDocument
.PpiDeclarations
.Entry e
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) li
.next();
843 ppi
[i
][0] = e
.getName();
844 ppi
[i
][1] = e
.getCName();
845 if (e
.getGuidValue() != null) {
846 ppi
[i
][2] = e
.getGuidValue();
848 ppi
[i
][3] = e
.getHelpText();
849 ppi
[i
][4] = listToString(e
.getSupArchList());
850 ppi
[i
][5] = listToString(e
.getSupModuleList());
851 ppi
[i
][6] = listToString(e
.getGuidTypeList());
857 Get the number of Pcd definitions from the size of List
861 public int getSpdPcdDefinitionCount() {
862 if (psaRoot
.getPcdDeclarations() == null || psaRoot
.getPcdDeclarations().getPcdEntryList() == null) {
865 return psaRoot
.getPcdDeclarations().getPcdEntryList().size();
869 Get available Pcd definition contents into String array
871 @param pcd Caller allocated two-dimentional String array
873 public void getSpdPcdDefinitions(String
[][] pcd
, String pcdUsage
[][]) {
874 if (psaRoot
.getPcdDeclarations() == null) {
878 List
<PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
> l
= psaRoot
.getPcdDeclarations().getPcdEntryList();
880 while (i
< l
.size()) {
881 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry e
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)l
.get(i
);
882 pcd
[i
][0] = e
.getCName();
883 pcd
[i
][1] = e
.getToken() + "";
884 pcd
[i
][2] = e
.getTokenSpaceGuidCName();
885 if (e
.getDatumType() != null) {
886 pcd
[i
][3] = e
.getDatumType().toString();
888 pcd
[i
][4] = e
.getDefaultValue()+"";
889 pcd
[i
][5] = e
.getHelpText();
890 String archList
= listToString(e
.getSupArchList());
891 if (archList
!= null) {
892 pcd
[i
][6] = archList
;
894 String modTypeList
= listToString(e
.getSupModuleList());
895 if (modTypeList
!= null) {
896 pcd
[i
][7] = modTypeList
;
900 while (j
< e
.getValidUsage().size() && j
< 5) {
901 pcdUsage
[i
][j
] = (String
)e
.getValidUsage().get(j
);
909 Save the processed xml contents to file
911 @param spdFile The file to save xml contents
912 @throws IOException Exceptions during file operation
914 public void saveAs(File spdFile
) throws IOException
{
916 XmlOptions options
= new XmlOptions();
918 options
.setCharacterEncoding("UTF-8");
919 options
.setSavePrettyPrint();
920 options
.setSavePrettyPrintIndent(2);
922 psad
.save(spdFile
, options
);
923 } catch (IOException e
) {
930 Generate SpdHeader contents using parameters passed in.
932 @param pkgName PackageName
934 @param pkgVer Version
935 @param pkgAbs Abstract
936 @param pkgDes Description
937 @param pkgCpRight Copyright
938 @param pkgLicense License
939 @param pkgCreateDate Created
940 @param pkgUpdateDate Updated
942 @param pkgType PackageType
943 @param pkgRdOnly ReadOnly
944 @param pkgRePkg RePackage
945 @param pkgSpec Reserved
946 @param pkgOutDir Reserved
948 public void genSpdHeader(String pkgName
, String pkgGuid
, String pkgVer
, String pkgAbs
, String pkgDes
,
949 String pkgCpRight
, String pkgLicense
, String pkgCreateDate
, String pkgUpdateDate
,
950 String pkgURL
, String pkgType
, String pkgRdOnly
, String pkgRePkg
, String pkgSpec
,
952 if (getSpdHdr() == null) {
953 spdHdr
= psaRoot
.addNewSpdHeader();
956 setSpdHdrPkgName(pkgName
);
957 setSpdHdrGuidValue(pkgGuid
);
958 setSpdHdrVer(pkgVer
);
959 setSpdHdrAbs(pkgAbs
);
960 setSpdHdrDescription(pkgDes
);
961 setSpdHdrCopyright(pkgCpRight
);
962 setSpdHdrLicense(pkgLicense
);
965 setSpdHdrSpec(pkgSpec
);
969 Generate library class declaration element using parameters passed in
971 @param libClassBaseName LibraryClass element value
972 @param libClassUsage Reserved
973 @param incHdrFileName IncludeHeader element value
974 @param incHdrAttribGuid Reserved
975 @param incHdrAttribArch Reserved
976 @param incHdrAttribPath Reserved
977 @param incHdrAttribClass Reserved
978 @param incHdrAttribVer Reserved
979 @param incHdrAttribOverrideID Reserved
980 @param incHdrAttribModuleType Reserved
982 public void genSpdLibClassDeclarations(String libClassBaseName
, String instanceUsage
, String incHdrFileName
,
983 String help
, String incHdrAttribArch
, String incHdrAttribPath
,
984 String incHdrAttribClass
, String incHdrAttribVer
,
985 String incHdrAttribOverrideID
, String incHdrAttribModuleType
) {
986 if (getSpdLibClassDeclarations() == null) {
987 spdLibClassDeclarations
= psaRoot
.addNewLibraryClassDeclarations();
990 // add contents under LibraryClassDeclarations tag
992 setSpdLibClassDeclaration(libClassBaseName
, instanceUsage
, incHdrFileName
, help
, incHdrAttribArch
,
993 incHdrAttribPath
, incHdrAttribClass
, incHdrAttribVer
, incHdrAttribOverrideID
,
994 incHdrAttribModuleType
, spdLibClassDeclarations
);
997 public void getSpdLibClassDeclaration(String
[] sa
, int i
) {
998 if (getSpdLibClassDeclarations() == null) {
1001 XmlCursor cursor
= getSpdLibClassDeclarations().newCursor();
1002 if (cursor
.toFirstChild()) {
1003 for (int j
= 0; j
< i
; ++j
) {
1004 cursor
.toNextSibling();
1006 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass lc
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
)cursor
.getObject();
1007 sa
[0] = lc
.getName();
1008 sa
[1] = lc
.getIncludeHeader();
1009 sa
[2] = lc
.getHelpText();
1010 sa
[3] = lc
.getRecommendedInstanceGuid();
1011 sa
[4] = lc
.getRecommendedInstanceVersion();
1012 sa
[5] = listToString(lc
.getSupArchList());
1013 sa
[6] = listToString(lc
.getSupModuleList());
1019 Set library class declaration contents under parent tag
1021 @param clsName LibraryClass element value
1022 @param clsUsage Reserved
1023 @param hdrFile IncludeHeader element value
1024 @param hdrAttribGuid Reserved
1025 @param hdrAttribArch Reserved
1026 @param hdrAttribPath Reserved
1027 @param hdrAttribClass Reserved
1028 @param hdrAttribVer Reserved
1029 @param hdrAttribOverID Reserved
1030 @param hdrAttribModType Reserved
1031 @param parent The tag under which library class declaration goes to
1033 public void setSpdLibClassDeclaration(String clsName
, String clsUsage
, String hdrFile
, String help
,
1034 String hdrAttribArch
, String hdrAttribPath
, String hdrAttribClass
,
1035 String instanceVer
, String hdrAttribOverID
, String hdrAttribModType
,
1038 setSpdLibraryClass(clsName
, hdrFile
, help
, clsUsage
, instanceVer
, hdrAttribArch
, hdrAttribModType
, parent
);
1043 Set the contents of LibraryClass under parent element
1045 @param clsName LibraryClass element value
1046 @param clsUsage Reserved
1047 @param parent The tag under which library class declaration goes to
1049 public void setSpdLibraryClass(String clsName
, String clsIncludeFile
, String help
, String clsUsage
, String instanceVer
, String hdrAttribArch
, String hdrAttribModType
, XmlObject parent
) {
1050 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass lc
= ((LibraryClassDeclarationsDocument
.LibraryClassDeclarations
) parent
).addNewLibraryClass();
1051 lc
.setName(clsName
);
1052 lc
.setIncludeHeader(clsIncludeFile
);
1053 lc
.setHelpText(help
);
1054 // LAH added logic so you cannot set the version unless the GUID is defined.
1056 if (clsUsage
!= null) {
1057 lc
.setRecommendedInstanceGuid(clsUsage
);
1058 if (instanceVer
!= null) {
1059 lc
.setRecommendedInstanceVersion(instanceVer
);
1063 if (lc
.isSetRecommendedInstanceGuid()) {
1064 lc
.unsetRecommendedInstanceGuid();
1066 if (lc
.isSetRecommendedInstanceVersion()) {
1067 lc
.unsetRecommendedInstanceVersion();
1071 if (hdrAttribArch
!= null) {
1072 lc
.setSupArchList(stringToList(hdrAttribArch
));
1074 if (lc
.isSetSupArchList()) {
1075 lc
.unsetSupArchList();
1079 if (hdrAttribModType
!= null) {
1080 lc
.setSupModuleList(stringToList(hdrAttribModType
));
1082 if (lc
.isSetSupModuleList()) {
1083 lc
.unsetSupModuleList();
1090 Set contents of IncludeHeader under parent element
1092 @param modType Reserved
1093 @param hdrFile IncludeHeader element value
1094 @param hdrAttribGuid Reserved
1095 @param hdrAttribArch Reserved
1096 @param hdrAttribPath Reserved
1097 @param hdrAttribClass Reserved
1098 @param hdrAttribVer Reserved
1099 @param hdrAttribOverID Reserved
1100 @param parent The tag under which library class declaration goes to
1102 public void setSpdIncludeHeader(String modType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
1103 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
1104 String hdrAttribOverID
, XmlObject parent
) {
1106 if (parent
instanceof LibraryClassDeclarationsDocument
.LibraryClassDeclarations
) {
1107 } else if (parent
instanceof PackageHeadersDocument
.PackageHeaders
) {
1108 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader ih
= null;
1109 ih
= ((PackageHeadersDocument
.PackageHeaders
) parent
).addNewIncludePkgHeader();
1110 ih
.setStringValue(hdrFile
);
1111 ih
.setModuleType(ModuleTypeDef
.Enum
.forString(modType
));
1116 if (hdrAttribGuid
!= null) {
1118 if (hdrAttribPath
!= null) {
1120 if (hdrAttribClass
!= null) {
1122 if (hdrAttribVer
!= null) {
1124 if (hdrAttribOverID
!= null) {
1130 Generate MsaFile element.
1132 @param msaFileName MsaFile element value
1133 @param archType Reserved
1135 public void genSpdMsaFiles(String msaFileName
, String moduleName
, String ver
, String guid
) {
1136 if (getSpdMsaFiles() == null) {
1137 spdMsaFiles
= psaRoot
.addNewMsaFiles();
1139 setSpdMsaFile(msaFileName
, moduleName
, ver
, guid
, spdMsaFiles
);
1143 public void getSpdMsaFile (String
[] sa
, int i
) {
1144 if (getSpdMsaFiles() == null) {
1147 XmlCursor cursor
= getSpdMsaFiles().newCursor();
1148 if (cursor
.toFirstChild()) {
1149 for (int j
= 0; j
< i
; ++j
) {
1150 cursor
.toNextSibling();
1152 sa
[0] = cursor
.getTextValue();
1158 Set MsaFile contents under parent element.
1160 @param msaFileName MsaFile element value
1161 @param parent Element under which MsaFile goes to
1163 public void setSpdMsaFile(String msaFileName
, String moduleName
, String ver
, String guid
, XmlObject parent
) {
1164 MsaFilesDocument
.MsaFiles f
= (MsaFilesDocument
.MsaFiles
)parent
;
1165 f
.addNewFilename().setStringValue(msaFileName
);
1166 // f.setFilename(msaFileName);
1167 // f.setModuleName(moduleName);
1168 // f.setModuleVersion(ver);
1169 // f.setModuleGuid(guid);
1173 Generate PackageHeader element using parameters passed in.
1175 @param ModHdrModType ModuleType attribute of IncludeHeader element
1176 @param hdrFile IncludeHeader element value
1177 @param hdrAttribGuid Reserved
1178 @param hdrAttribArch Reserved
1179 @param hdrAttribPath Reserved
1180 @param hdrAttribClass Reserved
1181 @param hdrAttribVer Reserved
1182 @param hdrAttribOverID Reserved
1184 public void genSpdModuleHeaders(String ModHdrModType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
1185 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
1186 String hdrAttribOverID
) {
1187 if (getSpdModHdrs() == null) {
1188 spdModHdrs
= psaRoot
.addNewPackageHeaders();
1192 // add IncludeHeader under PackageHeaders element
1194 setSpdIncludeHeader(ModHdrModType
, hdrFile
, hdrAttribGuid
, hdrAttribArch
, hdrAttribPath
, hdrAttribClass
,
1195 hdrAttribVer
, hdrAttribOverID
, spdModHdrs
);
1198 public void getSpdModuleHeader(String
[] sa
, int i
) {
1199 if (getSpdModHdrs() == null) {
1202 XmlCursor cursor
= getSpdModHdrs().newCursor();
1203 if (cursor
.toFirstChild()) {
1204 for (int j
= 0; j
< i
; ++j
) {
1205 cursor
.toNextSibling();
1207 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader ih
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
)cursor
.getObject();
1208 sa
[0] = ih
.getModuleType()+"";
1209 sa
[1] = ih
.getStringValue();
1215 Generate GUID declaration element using parameters passed in.
1217 @param guidDeclEntryName Name attribute of Entry element
1218 @param guidDeclCName CName element value
1219 @param guidDeclGuid Guid element value
1220 @param guidDeclFeatureFlag Reserved
1222 public void genSpdGuidDeclarations(String guidDeclEntryName
, String guidDeclCName
, String guidDeclGuid
,
1223 String guidDeclHelp
, Vector
<String
> archList
, Vector
<String
> modTypeList
,
1224 Vector
<String
> guidTypeList
) {
1225 if (getSpdGuidDeclarations() == null) {
1226 spdGuidDeclarations
= psaRoot
.addNewGuidDeclarations();
1229 setSpdEntry(guidDeclEntryName
, guidDeclCName
, guidDeclGuid
, guidDeclHelp
, archList
, modTypeList
, guidTypeList
, spdGuidDeclarations
);
1233 Generate protocol declaration element using parameters passed in.
1235 @param protocolDeclEntryName Name attribute of Entry element
1236 @param protocolDeclCName CName element value
1237 @param protocolDeclGuid Guid element value
1238 @param protocolDeclFeatureFlag Reserved
1240 public void genSpdProtocolDeclarations(String protocolDeclEntryName
, String protocolDeclCName
,
1241 String protocolDeclGuid
, String protocolDeclFeatureFlag
,
1242 Vector
<String
> archList
, Vector
<String
> modTypeList
, Vector
<String
> guidTypeList
) {
1243 if (getSpdProtocolDeclarations() == null) {
1244 spdProtocolDeclarations
= psaRoot
.addNewProtocolDeclarations();
1247 setSpdEntry(protocolDeclEntryName
, protocolDeclCName
, protocolDeclGuid
, protocolDeclFeatureFlag
,
1248 archList
, modTypeList
, guidTypeList
, spdProtocolDeclarations
);
1252 Generate PPI declaration element using parameters passed in.
1254 @param ppiDeclEntryName Name attribute of Entry element
1255 @param ppiDeclCName CName element value
1256 @param ppiDeclGuid Guid element value
1257 @param ppiDeclFeatureFlag Reserved
1259 public void genSpdPpiDeclarations(String ppiDeclEntryName
, String ppiDeclCName
, String ppiDeclGuid
,
1260 String ppiDeclFeatureFlag
, Vector
<String
> archList
, Vector
<String
> modTypeList
, Vector
<String
> guidTypeList
) {
1261 if (getSpdPpiDeclarations() == null) {
1262 spdPpiDeclarations
= psaRoot
.addNewPpiDeclarations();
1265 setSpdEntry(ppiDeclEntryName
, ppiDeclCName
, ppiDeclGuid
, ppiDeclFeatureFlag
, archList
, modTypeList
, guidTypeList
, spdPpiDeclarations
);
1268 public void getSpdGuidDeclaration(String
[] sa
, int i
) {
1269 if (getSpdGuidDeclarations() == null) {
1272 getSpdEntry(sa
, i
, getSpdGuidDeclarations());
1275 public void getSpdProtocolDeclaration(String
[] sa
, int i
) {
1276 if (getSpdProtocolDeclarations() == null) {
1279 getSpdEntry(sa
, i
, getSpdProtocolDeclarations());
1282 public void getSpdPpiDeclaration(String
[] sa
, int i
) {
1283 if (getSpdPpiDeclarations() == null) {
1286 getSpdEntry(sa
, i
, getSpdPpiDeclarations());
1289 public void getSpdEntry(String
[] sa
, int i
, XmlObject parent
) {
1290 XmlCursor cursor
= parent
.newCursor();
1291 if (cursor
.toFirstChild()) {
1292 for (int j
= 0; j
< i
; ++j
) {
1293 cursor
.toNextSibling();
1295 if (parent
instanceof GuidDeclarationsDocument
.GuidDeclarations
) {
1296 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
)cursor
.getObject();
1297 sa
[0] = e
.getName();
1298 sa
[1] = e
.getCName();
1299 sa
[2] = e
.getGuidValue();
1300 sa
[3] = e
.getHelpText();
1301 sa
[4] = listToString(e
.getSupArchList());
1302 sa
[5] = listToString(e
.getSupModuleList());
1303 sa
[6] = listToString(e
.getGuidTypeList());
1306 if (parent
instanceof ProtocolDeclarationsDocument
.ProtocolDeclarations
) {
1307 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry e
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
)cursor
.getObject();
1308 sa
[0] = e
.getName();
1309 sa
[1] = e
.getCName();
1310 sa
[2] = e
.getGuidValue();
1311 sa
[3] = e
.getHelpText();
1312 sa
[4] = listToString(e
.getSupArchList());
1313 sa
[5] = listToString(e
.getSupModuleList());
1314 sa
[6] = listToString(e
.getGuidTypeList());
1317 if (parent
instanceof PpiDeclarationsDocument
.PpiDeclarations
) {
1318 PpiDeclarationsDocument
.PpiDeclarations
.Entry e
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
)cursor
.getObject();
1319 sa
[0] = e
.getName();
1320 sa
[1] = e
.getCName();
1321 sa
[2] = e
.getGuidValue();
1322 sa
[3] = e
.getHelpText();
1323 sa
[4] = listToString(e
.getSupArchList());
1324 sa
[5] = listToString(e
.getSupModuleList());
1325 sa
[6] = listToString(e
.getGuidTypeList());
1332 Set Entry contents using parameters passed in
1334 @param entryName Name attribute of Entry element
1335 @param cName CName element value
1336 @param guid Guid element value
1337 @param featureFlag Reserved
1338 @param parent The tag under which Entry element goes to
1340 public void setSpdEntry(String entryName
, String cName
, String guid
, String help
,
1341 Vector
<String
> archList
, Vector
<String
> modTypeList
,
1342 Vector
<String
> guidTypeList
, XmlObject parent
) {
1344 if (parent
instanceof GuidDeclarationsDocument
.GuidDeclarations
) {
1345 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= ((GuidDeclarations
) parent
).addNewEntry();
1346 e
.setName(entryName
);
1348 e
.setGuidValue(guid
);
1349 e
.setHelpText(help
);
1350 if (guidTypeList
!= null) {
1351 e
.setGuidTypeList(guidTypeList
);
1354 if (e
.isSetGuidTypeList()) {
1355 e
.unsetGuidTypeList();
1358 if (archList
!= null) {
1359 e
.setSupArchList(archList
);
1362 if (e
.isSetSupArchList()) {
1363 e
.unsetSupArchList();
1366 if (modTypeList
!= null){
1367 e
.setSupModuleList(modTypeList
);
1370 if (e
.isSetSupModuleList()) {
1371 e
.unsetSupModuleList();
1377 if (parent
instanceof ProtocolDeclarationsDocument
.ProtocolDeclarations
) {
1378 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry pe
= ((ProtocolDeclarationsDocument
.ProtocolDeclarations
) parent
)
1380 pe
.setName(entryName
);
1382 pe
.setGuidValue(guid
);
1383 pe
.setHelpText(help
);
1384 if (guidTypeList
!= null) {
1385 pe
.setGuidTypeList(guidTypeList
);
1388 if (pe
.isSetGuidTypeList()) {
1389 pe
.unsetGuidTypeList();
1392 if (archList
!= null) {
1393 pe
.setSupArchList(archList
);
1396 if (pe
.isSetSupArchList()) {
1397 pe
.unsetSupArchList();
1400 if (modTypeList
!= null){
1401 pe
.setSupModuleList(modTypeList
);
1404 if (pe
.isSetSupModuleList()) {
1405 pe
.unsetSupModuleList();
1411 if (parent
instanceof PpiDeclarationsDocument
.PpiDeclarations
) {
1412 PpiDeclarationsDocument
.PpiDeclarations
.Entry ppe
= ((PpiDeclarationsDocument
.PpiDeclarations
) parent
)
1414 ppe
.setName(entryName
);
1415 ppe
.setCName(cName
);
1416 ppe
.setGuidValue(guid
);
1417 ppe
.setHelpText(help
);
1418 if (guidTypeList
!= null) {
1419 ppe
.setGuidTypeList(guidTypeList
);
1422 if (ppe
.isSetGuidTypeList()) {
1423 ppe
.unsetGuidTypeList();
1426 if (archList
!= null) {
1427 ppe
.setSupArchList(archList
);
1430 if (ppe
.isSetSupArchList()) {
1431 ppe
.unsetSupArchList();
1434 if (modTypeList
!= null){
1435 ppe
.setSupModuleList(modTypeList
);
1438 if (ppe
.isSetSupModuleList()) {
1439 ppe
.unsetSupModuleList();
1451 Generate Pcd definition using parameters passed in
1453 @param pcdItemTypes ItemType attribute of PcdEntry element
1454 @param cName C_Name element value
1455 @param token Token element value
1456 @param dataType DatumType element value
1457 @param skuEnable Reserved
1459 @param maxSku Reserved
1460 @param hiiEnable Reserved
1461 @param varGuid Reserved
1462 @param varName Reserved
1463 @param defaultString DefaultString element value
1465 public void genSpdPcdDefinitions(String cName
, String token
, String dataType
, String pcdItemTypes
,
1466 String spaceGuid
, String defaultString
, String help
, String archList
,
1467 String modTypeList
) {
1468 if (getSpdPcdDefinitions() == null) {
1469 spdPcdDefinitions
= psaRoot
.addNewPcdDeclarations();
1472 setSpdPcdEntry(pcdItemTypes
, cName
, token
, dataType
, spaceGuid
, help
,
1473 defaultString
, archList
, modTypeList
, spdPcdDefinitions
);
1476 public void getSpdPcdDeclaration(String
[] sa
, int i
) {
1477 if (getSpdPcdDefinitions() == null) {
1481 XmlCursor cursor
= getSpdPcdDefinitions().newCursor();
1482 if (cursor
.toFirstChild()) {
1483 for (int j
= 0; j
< i
; ++j
) {
1484 cursor
.toNextSibling();
1486 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry pe
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)cursor
.getObject();
1487 sa
[0] = pe
.getCName();
1488 sa
[1] = pe
.getToken()+"";
1489 sa
[2] = pe
.getTokenSpaceGuidCName();
1490 sa
[3] = pe
.getDatumType()+"";
1491 sa
[4] = pe
.getDefaultValue();
1492 sa
[5] = pe
.getHelpText();
1493 sa
[6] = listToString(pe
.getValidUsage());
1494 sa
[7] = listToString(pe
.getSupArchList());
1495 sa
[8] = listToString(pe
.getSupModuleList());
1501 Set Pcd entry contents under parent tag
1503 @param pcdItemTypes ItemType attribute of PcdEntry element
1504 @param cName C_Name element value
1505 @param token Token element value
1506 @param dataType DatumType element value
1507 @param spaceGuid Reserved
1508 @param help Reserved
1509 @param defaultString DefaultString element value
1510 @param parent Tag under which PcdEntry goes to
1512 public void setSpdPcdEntry(String pcdItemTypes
, String cName
, String token
, String dataType
, String spaceGuid
, String help
,
1513 String defaultString
, String archList
, String modTypeList
, XmlObject parent
) {
1515 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry pe
= ((PcdDeclarationsDocument
.PcdDeclarations
) parent
).addNewPcdEntry();
1517 //ToDo: maybe multiple types in, need parse pcdItemTypes.
1518 String usage
[] = pcdItemTypes
.split("( )+");
1519 List
<String
> l
= new ArrayList
<String
>();
1520 for (int i
= 0; i
< usage
.length
; ++i
) {
1523 pe
.setValidUsage(l
);
1526 pe
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1527 pe
.setDefaultValue(defaultString
);
1528 pe
.setTokenSpaceGuidCName(spaceGuid
);
1529 pe
.setHelpText(help
);
1530 if (archList
!= null){
1531 pe
.setSupArchList(stringToList(archList
));
1533 if (pe
.isSetSupArchList()) {
1534 pe
.unsetSupArchList();
1537 if (modTypeList
!= null){
1538 pe
.setSupModuleList(stringToList(modTypeList
));
1540 if (pe
.isSetSupModuleList()) {
1541 pe
.unsetSupModuleList();
1547 Get PpiDeclarations element
1549 @return PpiDeclarationsDocument.PpiDeclarations
1551 public PpiDeclarationsDocument
.PpiDeclarations
getSpdPpiDeclarations() {
1552 if (spdPpiDeclarations
== null) {
1553 spdPpiDeclarations
= psaRoot
.getPpiDeclarations();
1555 return spdPpiDeclarations
;
1559 Get ProtocolDeclarations element
1561 @return ProtocolDeclarationsDocument.ProtocolDeclarations
1563 public ProtocolDeclarationsDocument
.ProtocolDeclarations
getSpdProtocolDeclarations() {
1564 if (spdProtocolDeclarations
== null) {
1565 spdProtocolDeclarations
= psaRoot
.getProtocolDeclarations();
1567 return spdProtocolDeclarations
;
1571 Get GuidDeclarations element
1573 @return GuidDeclarationsDocument.GuidDeclarations
1575 public GuidDeclarationsDocument
.GuidDeclarations
getSpdGuidDeclarations() {
1576 if (spdGuidDeclarations
== null) {
1577 spdGuidDeclarations
= psaRoot
.getGuidDeclarations();
1579 return spdGuidDeclarations
;
1583 Get PcdDefinitions element
1585 @return PcdDefinitionsDocument.PcdDefinitions
1587 public PcdDeclarationsDocument
.PcdDeclarations
getSpdPcdDefinitions() {
1588 if (spdPcdDefinitions
== null) {
1589 spdPcdDefinitions
= psaRoot
.getPcdDeclarations();
1591 return spdPcdDefinitions
;
1595 Get PackageHeaders element
1597 @return PackageHeadersDocument.PackageHeaders
1599 public PackageHeadersDocument
.PackageHeaders
getSpdModHdrs() {
1600 if (spdModHdrs
== null) {
1601 spdModHdrs
= psaRoot
.getPackageHeaders();
1607 Get MsaFiles element
1609 @return MsaFilesDocument.MsaFiles
1611 public MsaFilesDocument
.MsaFiles
getSpdMsaFiles() {
1612 if (spdMsaFiles
== null) {
1613 spdMsaFiles
= psaRoot
.getMsaFiles();
1619 Get LibraryClassDeclarations element
1621 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
1623 public LibraryClassDeclarationsDocument
.LibraryClassDeclarations
getSpdLibClassDeclarations() {
1624 if (spdLibClassDeclarations
== null) {
1625 spdLibClassDeclarations
= psaRoot
.getLibraryClassDeclarations();
1627 return spdLibClassDeclarations
;
1630 public PackageDefinitionsDocument
.PackageDefinitions
getSpdPkgDefs() {
1631 if (spdPkgDefs
== null) {
1632 spdPkgDefs
= psaRoot
.addNewPackageDefinitions();
1637 Get SpdHeader element
1639 @return SpdHeaderDocument.SpdHeader
1641 public SpdHeaderDocument
.SpdHeader
getSpdHdr() {
1642 if (spdHdr
== null) {
1643 spdHdr
= psaRoot
.addNewSpdHeader();
1649 Set value to Guid element
1651 @param guid The value set to Guid element
1653 public void setSpdHdrGuidValue(String guid
) {
1654 getSpdHdr().setGuidValue(guid
);
1658 Get Version element under SpdHdr
1662 public String
getSpdHdrVer() {
1663 return getSpdHdr().getVersion();
1667 Set value to Version element
1669 @param ver The value set to Version element
1671 public void setSpdHdrVer(String ver
) {
1672 getSpdHdr().setVersion(ver
);
1675 public String
getSpdHdrAbs(){
1676 return getSpdHdr().getAbstract();
1681 Set value to Abstract element
1683 @param abs The value set to Abstract element
1685 public void setSpdHdrAbs(String abs
) {
1687 getSpdHdr().setAbstract(abs
);
1690 public String
getSpdHdrDescription(){
1691 return getSpdHdr().getDescription();
1694 Set value to Description element
1696 @param des The value set to Description element
1698 public void setSpdHdrDescription(String des
) {
1699 getSpdHdr().setDescription(des
);
1702 public String
getSpdHdrCopyright(){
1703 return getSpdHdr().getCopyright();
1706 Set value to Copyright element
1708 @param cpRit The value set to Copyright element
1710 public void setSpdHdrCopyright(String cpRit
) {
1712 getSpdHdr().setCopyright(cpRit
);
1716 Get License element under SpdHdr
1720 public String
getSpdHdrLicense() {
1721 if (getSpdHdr().getLicense() != null) {
1722 return getSpdHdr().getLicense().getStringValue();
1728 Set value to License element
1730 @param license The value set to License element
1732 public void setSpdHdrLicense(String license
) {
1733 if (getSpdHdr().getLicense() == null){
1734 getSpdHdr().addNewLicense().setStringValue(license
);
1737 getSpdHdr().getLicense().setStringValue(license
);
1741 public String
getSpdHdrUrl(){
1742 if (getSpdHdr().getLicense() != null) {
1743 return getSpdHdr().getLicense().getURL();
1748 public void setSpdHdrUrl(String url
){
1749 getSpdHdr().getLicense().setURL(url
);
1753 Get PackageName element under SpdHdr
1757 public String
getSpdHdrPkgName() {
1759 return getSpdHdr().getPackageName();
1763 Set value to PackageName element
1765 @param pkgName The value set to PackageName element
1767 public void setSpdHdrPkgName(String pkgName
) {
1768 getSpdHdr().setPackageName(pkgName
);
1771 public String
getSpdHdrGuidValue(){
1772 return getSpdHdr().getGuidValue();
1778 @return SpecificationDocument.Specification
1780 public String
getSpdHdrSpec() {
1781 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1782 // return getSpdHdr().getSpecification();
1790 public void setSpdHdrSpec(String spec
) {
1791 spec
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1792 getSpdHdr().setSpecification(spec
);
1796 public String
getSpdPkgDefsRdOnly(){
1797 return getSpdPkgDefs().getReadOnly() + "";
1800 Set value to ReadOnly element
1802 @param rdOnly The value set to ReadOnly element
1804 public void setSpdPkgDefsRdOnly(String rdOnly
) {
1806 getSpdPkgDefs().setReadOnly(new Boolean(rdOnly
));
1809 public String
getSpdPkgDefsRePkg(){
1810 return getSpdPkgDefs().getRePackage() + "";
1813 Set value to RePackage element
1815 @param rePkg The value set to RePackage element
1817 public void setSpdPkgDefsRePkg(String rePkg
) {
1819 getSpdPkgDefs().setRePackage(new Boolean(rePkg
));
1823 Set value to URL element
1825 @param url The value set to URL element
1827 // public void setSpdHdrURL(String url) {
1828 // getSpdHdr().setURL(url);
1836 public File
getFile() {
1843 @param file File with xml format
1845 public void setFile(File file
) {
1849 private List
<String
> stringToList(String s
){
1850 if (s
== null || s
.length() == 0) {
1853 Vector
<String
> al
= new Vector
<String
>();
1854 String
[] sArray
= s
.split(" ");
1855 for(int i
= 0; i
< sArray
.length
; ++i
){
1861 private String
listToString(List l
) {
1866 ListIterator li
= l
.listIterator();
1867 while(li
.hasNext()) {