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();
733 public void getSpdGuidDeclWithType (Vector
<String
> vGuidCName
, String type
) {
734 if (psaRoot
.getGuidDeclarations() == null) {
737 List
<GuidDeclarationsDocument
.GuidDeclarations
.Entry
> l
= psaRoot
.getGuidDeclarations().getEntryList();
738 for (int i
= 0; i
< l
.size(); ++i
) {
739 if (l
.get(i
).getGuidTypeList() == null || l
.get(i
).getGuidTypeList().contains(type
)) {
740 vGuidCName
.add(l
.get(i
).getCName());
745 Get the number of GUID declarations from the size of List
749 public int getSpdGuidDeclarationCount() {
750 if (psaRoot
.getGuidDeclarations() == null || psaRoot
.getGuidDeclarations().getEntryList() == null) {
753 return psaRoot
.getGuidDeclarations().getEntryList().size();
757 Get available Guid declaration contents into String array
759 @param guid Caller allocated two-dimentional String array
761 public void getSpdGuidDeclarations(String
[][] guid
) {
762 if (psaRoot
.getGuidDeclarations() == null) {
766 List
<GuidDeclarationsDocument
.GuidDeclarations
.Entry
> l
= psaRoot
.getGuidDeclarations().getEntryList();
768 ListIterator li
= l
.listIterator();
769 while (li
.hasNext()) {
770 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) li
772 guid
[i
][0] = e
.getName();
773 guid
[i
][1] = e
.getCName();
774 if (e
.getGuidValue() != null) {
775 guid
[i
][2] = e
.getGuidValue();
777 guid
[i
][3] = e
.getHelpText();
778 guid
[i
][4] = listToString(e
.getSupArchList());
779 guid
[i
][5] = listToString(e
.getSupModuleList());
780 guid
[i
][6] = listToString(e
.getGuidTypeList());
786 Get the number of protocol declarations from the size of List
790 public int getSpdProtocolDeclarationCount() {
791 if (psaRoot
.getProtocolDeclarations() == null || psaRoot
.getProtocolDeclarations().getEntryList() == null) {
794 return psaRoot
.getProtocolDeclarations().getEntryList().size();
798 Get available protocol declaration contents into String array
800 @param protocol Caller allocated two-dimentional String array
802 public void getSpdProtocolDeclarations(String
[][] protocol
) {
803 if (psaRoot
.getProtocolDeclarations() == null) {
807 List
<ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
> l
= psaRoot
.getProtocolDeclarations()
810 ListIterator li
= l
.listIterator();
811 while (li
.hasNext()) {
812 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry e
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) li
814 protocol
[i
][0] = e
.getName();
815 protocol
[i
][1] = e
.getCName();
816 if (e
.getGuidValue() != null) {
817 protocol
[i
][2] = e
.getGuidValue();
819 protocol
[i
][3] = e
.getHelpText();
820 protocol
[i
][4] = listToString(e
.getSupArchList());
821 protocol
[i
][5] = listToString(e
.getSupModuleList());
822 protocol
[i
][6] = listToString(e
.getGuidTypeList());
828 Get the number of Ppi declarations from the size of List
832 public int getSpdPpiDeclarationCount() {
833 if (psaRoot
.getPpiDeclarations() == null || psaRoot
.getPpiDeclarations().getEntryList() == null) {
836 return psaRoot
.getPpiDeclarations().getEntryList().size();
840 Get available Ppi declaration contents into String array
842 @param ppi Caller allocated two-dimentional String array
844 public void getSpdPpiDeclarations(String
[][] ppi
) {
845 if (psaRoot
.getPpiDeclarations() == null) {
849 List
<PpiDeclarationsDocument
.PpiDeclarations
.Entry
> l
= psaRoot
.getPpiDeclarations().getEntryList();
851 ListIterator li
= l
.listIterator();
852 while (li
.hasNext()) {
853 PpiDeclarationsDocument
.PpiDeclarations
.Entry e
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) li
.next();
854 ppi
[i
][0] = e
.getName();
855 ppi
[i
][1] = e
.getCName();
856 if (e
.getGuidValue() != null) {
857 ppi
[i
][2] = e
.getGuidValue();
859 ppi
[i
][3] = e
.getHelpText();
860 ppi
[i
][4] = listToString(e
.getSupArchList());
861 ppi
[i
][5] = listToString(e
.getSupModuleList());
862 ppi
[i
][6] = listToString(e
.getGuidTypeList());
868 Get the number of Pcd definitions from the size of List
872 public int getSpdPcdDefinitionCount() {
873 if (psaRoot
.getPcdDeclarations() == null || psaRoot
.getPcdDeclarations().getPcdEntryList() == null) {
876 return psaRoot
.getPcdDeclarations().getPcdEntryList().size();
880 Get available Pcd definition contents into String array
882 @param pcd Caller allocated two-dimentional String array
884 public void getSpdPcdDefinitions(String
[][] pcd
, String pcdUsage
[][]) {
885 if (psaRoot
.getPcdDeclarations() == null) {
889 List
<PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
> l
= psaRoot
.getPcdDeclarations().getPcdEntryList();
891 while (i
< l
.size()) {
892 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry e
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)l
.get(i
);
893 pcd
[i
][0] = e
.getCName();
894 pcd
[i
][1] = e
.getToken() + "";
895 pcd
[i
][2] = e
.getTokenSpaceGuidCName();
896 if (e
.getDatumType() != null) {
897 pcd
[i
][3] = e
.getDatumType().toString();
899 pcd
[i
][4] = e
.getDefaultValue()+"";
900 pcd
[i
][5] = e
.getHelpText();
901 String archList
= listToString(e
.getSupArchList());
902 if (archList
!= null) {
903 pcd
[i
][6] = archList
;
905 String modTypeList
= listToString(e
.getSupModuleList());
906 if (modTypeList
!= null) {
907 pcd
[i
][7] = modTypeList
;
911 while (j
< e
.getValidUsage().size() && j
< 5) {
912 pcdUsage
[i
][j
] = (String
)e
.getValidUsage().get(j
);
920 Save the processed xml contents to file
922 @param spdFile The file to save xml contents
923 @throws IOException Exceptions during file operation
925 public void saveAs(File spdFile
) throws IOException
{
927 XmlOptions options
= new XmlOptions();
929 options
.setCharacterEncoding("UTF-8");
930 options
.setSavePrettyPrint();
931 options
.setSavePrettyPrintIndent(2);
933 psad
.save(spdFile
, options
);
934 } catch (IOException e
) {
941 Generate SpdHeader contents using parameters passed in.
943 @param pkgName PackageName
945 @param pkgVer Version
946 @param pkgAbs Abstract
947 @param pkgDes Description
948 @param pkgCpRight Copyright
949 @param pkgLicense License
950 @param pkgCreateDate Created
951 @param pkgUpdateDate Updated
953 @param pkgType PackageType
954 @param pkgRdOnly ReadOnly
955 @param pkgRePkg RePackage
956 @param pkgSpec Reserved
957 @param pkgOutDir Reserved
959 public void genSpdHeader(String pkgName
, String pkgGuid
, String pkgVer
, String pkgAbs
, String pkgDes
,
960 String pkgCpRight
, String pkgLicense
, String pkgCreateDate
, String pkgUpdateDate
,
961 String pkgURL
, String pkgType
, String pkgRdOnly
, String pkgRePkg
, String pkgSpec
,
963 if (getSpdHdr() == null) {
964 spdHdr
= psaRoot
.addNewSpdHeader();
967 setSpdHdrPkgName(pkgName
);
968 setSpdHdrGuidValue(pkgGuid
);
969 setSpdHdrVer(pkgVer
);
970 setSpdHdrAbs(pkgAbs
);
971 setSpdHdrDescription(pkgDes
);
972 setSpdHdrCopyright(pkgCpRight
);
973 setSpdHdrLicense(pkgLicense
);
976 setSpdHdrSpec(pkgSpec
);
980 Generate library class declaration element using parameters passed in
982 @param libClassBaseName LibraryClass element value
983 @param libClassUsage Reserved
984 @param incHdrFileName IncludeHeader element value
985 @param incHdrAttribGuid Reserved
986 @param incHdrAttribArch Reserved
987 @param incHdrAttribPath Reserved
988 @param incHdrAttribClass Reserved
989 @param incHdrAttribVer Reserved
990 @param incHdrAttribOverrideID Reserved
991 @param incHdrAttribModuleType Reserved
993 public void genSpdLibClassDeclarations(String libClassBaseName
, String instanceUsage
, String incHdrFileName
,
994 String help
, String incHdrAttribArch
, String incHdrAttribPath
,
995 String incHdrAttribClass
, String incHdrAttribVer
,
996 String incHdrAttribOverrideID
, String incHdrAttribModuleType
) {
997 if (getSpdLibClassDeclarations() == null) {
998 spdLibClassDeclarations
= psaRoot
.addNewLibraryClassDeclarations();
1001 // add contents under LibraryClassDeclarations tag
1003 setSpdLibClassDeclaration(libClassBaseName
, instanceUsage
, incHdrFileName
, help
, incHdrAttribArch
,
1004 incHdrAttribPath
, incHdrAttribClass
, incHdrAttribVer
, incHdrAttribOverrideID
,
1005 incHdrAttribModuleType
, spdLibClassDeclarations
);
1008 public void getSpdLibClassDeclaration(String
[] sa
, int i
) {
1009 if (getSpdLibClassDeclarations() == null) {
1012 XmlCursor cursor
= getSpdLibClassDeclarations().newCursor();
1013 if (cursor
.toFirstChild()) {
1014 for (int j
= 0; j
< i
; ++j
) {
1015 cursor
.toNextSibling();
1017 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass lc
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
)cursor
.getObject();
1018 sa
[0] = lc
.getName();
1019 sa
[1] = lc
.getIncludeHeader();
1020 sa
[2] = lc
.getHelpText();
1021 sa
[3] = lc
.getRecommendedInstanceGuid();
1022 sa
[4] = lc
.getRecommendedInstanceVersion();
1023 sa
[5] = listToString(lc
.getSupArchList());
1024 sa
[6] = listToString(lc
.getSupModuleList());
1030 Set library class declaration contents under parent tag
1032 @param clsName LibraryClass element value
1033 @param clsUsage Reserved
1034 @param hdrFile IncludeHeader element value
1035 @param hdrAttribGuid Reserved
1036 @param hdrAttribArch Reserved
1037 @param hdrAttribPath Reserved
1038 @param hdrAttribClass Reserved
1039 @param hdrAttribVer Reserved
1040 @param hdrAttribOverID Reserved
1041 @param hdrAttribModType Reserved
1042 @param parent The tag under which library class declaration goes to
1044 public void setSpdLibClassDeclaration(String clsName
, String clsUsage
, String hdrFile
, String help
,
1045 String hdrAttribArch
, String hdrAttribPath
, String hdrAttribClass
,
1046 String instanceVer
, String hdrAttribOverID
, String hdrAttribModType
,
1049 setSpdLibraryClass(clsName
, hdrFile
, help
, clsUsage
, instanceVer
, hdrAttribArch
, hdrAttribModType
, parent
);
1054 Set the contents of LibraryClass under parent element
1056 @param clsName LibraryClass element value
1057 @param clsUsage Reserved
1058 @param parent The tag under which library class declaration goes to
1060 public void setSpdLibraryClass(String clsName
, String clsIncludeFile
, String help
, String clsUsage
, String instanceVer
, String hdrAttribArch
, String hdrAttribModType
, XmlObject parent
) {
1061 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass lc
= ((LibraryClassDeclarationsDocument
.LibraryClassDeclarations
) parent
).addNewLibraryClass();
1062 lc
.setName(clsName
);
1063 lc
.setIncludeHeader(clsIncludeFile
);
1064 lc
.setHelpText(help
);
1065 // LAH added logic so you cannot set the version unless the GUID is defined.
1067 if (clsUsage
!= null) {
1068 lc
.setRecommendedInstanceGuid(clsUsage
);
1069 if (instanceVer
!= null) {
1070 lc
.setRecommendedInstanceVersion(instanceVer
);
1074 if (lc
.isSetRecommendedInstanceGuid()) {
1075 lc
.unsetRecommendedInstanceGuid();
1077 if (lc
.isSetRecommendedInstanceVersion()) {
1078 lc
.unsetRecommendedInstanceVersion();
1082 if (hdrAttribArch
!= null) {
1083 lc
.setSupArchList(stringToList(hdrAttribArch
));
1085 if (lc
.isSetSupArchList()) {
1086 lc
.unsetSupArchList();
1090 if (hdrAttribModType
!= null) {
1091 lc
.setSupModuleList(stringToList(hdrAttribModType
));
1093 if (lc
.isSetSupModuleList()) {
1094 lc
.unsetSupModuleList();
1101 Set contents of IncludeHeader under parent element
1103 @param modType Reserved
1104 @param hdrFile IncludeHeader element value
1105 @param hdrAttribGuid Reserved
1106 @param hdrAttribArch Reserved
1107 @param hdrAttribPath Reserved
1108 @param hdrAttribClass Reserved
1109 @param hdrAttribVer Reserved
1110 @param hdrAttribOverID Reserved
1111 @param parent The tag under which library class declaration goes to
1113 public void setSpdIncludeHeader(String modType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
1114 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
1115 String hdrAttribOverID
, XmlObject parent
) {
1117 if (parent
instanceof LibraryClassDeclarationsDocument
.LibraryClassDeclarations
) {
1118 } else if (parent
instanceof PackageHeadersDocument
.PackageHeaders
) {
1119 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader ih
= null;
1120 ih
= ((PackageHeadersDocument
.PackageHeaders
) parent
).addNewIncludePkgHeader();
1121 ih
.setStringValue(hdrFile
);
1122 ih
.setModuleType(ModuleTypeDef
.Enum
.forString(modType
));
1127 if (hdrAttribGuid
!= null) {
1129 if (hdrAttribPath
!= null) {
1131 if (hdrAttribClass
!= null) {
1133 if (hdrAttribVer
!= null) {
1135 if (hdrAttribOverID
!= null) {
1141 Generate MsaFile element.
1143 @param msaFileName MsaFile element value
1144 @param archType Reserved
1146 public void genSpdMsaFiles(String msaFileName
, String moduleName
, String ver
, String guid
) {
1147 if (getSpdMsaFiles() == null) {
1148 spdMsaFiles
= psaRoot
.addNewMsaFiles();
1150 setSpdMsaFile(msaFileName
, moduleName
, ver
, guid
, spdMsaFiles
);
1154 public void getSpdMsaFile (String
[] sa
, int i
) {
1155 if (getSpdMsaFiles() == null) {
1158 XmlCursor cursor
= getSpdMsaFiles().newCursor();
1159 if (cursor
.toFirstChild()) {
1160 for (int j
= 0; j
< i
; ++j
) {
1161 cursor
.toNextSibling();
1163 sa
[0] = cursor
.getTextValue();
1169 Set MsaFile contents under parent element.
1171 @param msaFileName MsaFile element value
1172 @param parent Element under which MsaFile goes to
1174 public void setSpdMsaFile(String msaFileName
, String moduleName
, String ver
, String guid
, XmlObject parent
) {
1175 MsaFilesDocument
.MsaFiles f
= (MsaFilesDocument
.MsaFiles
)parent
;
1176 f
.addNewFilename().setStringValue(msaFileName
);
1177 // f.setFilename(msaFileName);
1178 // f.setModuleName(moduleName);
1179 // f.setModuleVersion(ver);
1180 // f.setModuleGuid(guid);
1184 Generate PackageHeader element using parameters passed in.
1186 @param ModHdrModType ModuleType attribute of IncludeHeader element
1187 @param hdrFile IncludeHeader element value
1188 @param hdrAttribGuid Reserved
1189 @param hdrAttribArch Reserved
1190 @param hdrAttribPath Reserved
1191 @param hdrAttribClass Reserved
1192 @param hdrAttribVer Reserved
1193 @param hdrAttribOverID Reserved
1195 public void genSpdModuleHeaders(String ModHdrModType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
1196 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
1197 String hdrAttribOverID
) {
1198 if (getSpdModHdrs() == null) {
1199 spdModHdrs
= psaRoot
.addNewPackageHeaders();
1203 // add IncludeHeader under PackageHeaders element
1205 setSpdIncludeHeader(ModHdrModType
, hdrFile
, hdrAttribGuid
, hdrAttribArch
, hdrAttribPath
, hdrAttribClass
,
1206 hdrAttribVer
, hdrAttribOverID
, spdModHdrs
);
1209 public void getSpdModuleHeader(String
[] sa
, int i
) {
1210 if (getSpdModHdrs() == null) {
1213 XmlCursor cursor
= getSpdModHdrs().newCursor();
1214 if (cursor
.toFirstChild()) {
1215 for (int j
= 0; j
< i
; ++j
) {
1216 cursor
.toNextSibling();
1218 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader ih
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
)cursor
.getObject();
1219 sa
[0] = ih
.getModuleType()+"";
1220 sa
[1] = ih
.getStringValue();
1226 Generate GUID declaration element using parameters passed in.
1228 @param guidDeclEntryName Name attribute of Entry element
1229 @param guidDeclCName CName element value
1230 @param guidDeclGuid Guid element value
1231 @param guidDeclFeatureFlag Reserved
1233 public void genSpdGuidDeclarations(String guidDeclEntryName
, String guidDeclCName
, String guidDeclGuid
,
1234 String guidDeclHelp
, Vector
<String
> archList
, Vector
<String
> modTypeList
,
1235 Vector
<String
> guidTypeList
) {
1236 if (getSpdGuidDeclarations() == null) {
1237 spdGuidDeclarations
= psaRoot
.addNewGuidDeclarations();
1240 setSpdEntry(guidDeclEntryName
, guidDeclCName
, guidDeclGuid
, guidDeclHelp
, archList
, modTypeList
, guidTypeList
, spdGuidDeclarations
);
1244 Generate protocol declaration element using parameters passed in.
1246 @param protocolDeclEntryName Name attribute of Entry element
1247 @param protocolDeclCName CName element value
1248 @param protocolDeclGuid Guid element value
1249 @param protocolDeclFeatureFlag Reserved
1251 public void genSpdProtocolDeclarations(String protocolDeclEntryName
, String protocolDeclCName
,
1252 String protocolDeclGuid
, String protocolDeclFeatureFlag
,
1253 Vector
<String
> archList
, Vector
<String
> modTypeList
, Vector
<String
> guidTypeList
) {
1254 if (getSpdProtocolDeclarations() == null) {
1255 spdProtocolDeclarations
= psaRoot
.addNewProtocolDeclarations();
1258 setSpdEntry(protocolDeclEntryName
, protocolDeclCName
, protocolDeclGuid
, protocolDeclFeatureFlag
,
1259 archList
, modTypeList
, guidTypeList
, spdProtocolDeclarations
);
1263 Generate PPI declaration element using parameters passed in.
1265 @param ppiDeclEntryName Name attribute of Entry element
1266 @param ppiDeclCName CName element value
1267 @param ppiDeclGuid Guid element value
1268 @param ppiDeclFeatureFlag Reserved
1270 public void genSpdPpiDeclarations(String ppiDeclEntryName
, String ppiDeclCName
, String ppiDeclGuid
,
1271 String ppiDeclFeatureFlag
, Vector
<String
> archList
, Vector
<String
> modTypeList
, Vector
<String
> guidTypeList
) {
1272 if (getSpdPpiDeclarations() == null) {
1273 spdPpiDeclarations
= psaRoot
.addNewPpiDeclarations();
1276 setSpdEntry(ppiDeclEntryName
, ppiDeclCName
, ppiDeclGuid
, ppiDeclFeatureFlag
, archList
, modTypeList
, guidTypeList
, spdPpiDeclarations
);
1279 public void getSpdGuidDeclaration(String
[] sa
, int i
) {
1280 if (getSpdGuidDeclarations() == null) {
1283 getSpdEntry(sa
, i
, getSpdGuidDeclarations());
1286 public void getSpdProtocolDeclaration(String
[] sa
, int i
) {
1287 if (getSpdProtocolDeclarations() == null) {
1290 getSpdEntry(sa
, i
, getSpdProtocolDeclarations());
1293 public void getSpdPpiDeclaration(String
[] sa
, int i
) {
1294 if (getSpdPpiDeclarations() == null) {
1297 getSpdEntry(sa
, i
, getSpdPpiDeclarations());
1300 public void getSpdEntry(String
[] sa
, int i
, XmlObject parent
) {
1301 XmlCursor cursor
= parent
.newCursor();
1302 if (cursor
.toFirstChild()) {
1303 for (int j
= 0; j
< i
; ++j
) {
1304 cursor
.toNextSibling();
1306 if (parent
instanceof GuidDeclarationsDocument
.GuidDeclarations
) {
1307 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= (GuidDeclarationsDocument
.GuidDeclarations
.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 ProtocolDeclarationsDocument
.ProtocolDeclarations
) {
1318 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry e
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.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());
1328 if (parent
instanceof PpiDeclarationsDocument
.PpiDeclarations
) {
1329 PpiDeclarationsDocument
.PpiDeclarations
.Entry e
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
)cursor
.getObject();
1330 sa
[0] = e
.getName();
1331 sa
[1] = e
.getCName();
1332 sa
[2] = e
.getGuidValue();
1333 sa
[3] = e
.getHelpText();
1334 sa
[4] = listToString(e
.getSupArchList());
1335 sa
[5] = listToString(e
.getSupModuleList());
1336 sa
[6] = listToString(e
.getGuidTypeList());
1343 Set Entry contents using parameters passed in
1345 @param entryName Name attribute of Entry element
1346 @param cName CName element value
1347 @param guid Guid element value
1348 @param featureFlag Reserved
1349 @param parent The tag under which Entry element goes to
1351 public void setSpdEntry(String entryName
, String cName
, String guid
, String help
,
1352 Vector
<String
> archList
, Vector
<String
> modTypeList
,
1353 Vector
<String
> guidTypeList
, XmlObject parent
) {
1355 if (parent
instanceof GuidDeclarationsDocument
.GuidDeclarations
) {
1356 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= ((GuidDeclarations
) parent
).addNewEntry();
1357 e
.setName(entryName
);
1359 e
.setGuidValue(guid
);
1360 e
.setHelpText(help
);
1361 if (guidTypeList
!= null) {
1362 e
.setGuidTypeList(guidTypeList
);
1365 if (e
.isSetGuidTypeList()) {
1366 e
.unsetGuidTypeList();
1369 if (archList
!= null) {
1370 e
.setSupArchList(archList
);
1373 if (e
.isSetSupArchList()) {
1374 e
.unsetSupArchList();
1377 if (modTypeList
!= null){
1378 e
.setSupModuleList(modTypeList
);
1381 if (e
.isSetSupModuleList()) {
1382 e
.unsetSupModuleList();
1388 if (parent
instanceof ProtocolDeclarationsDocument
.ProtocolDeclarations
) {
1389 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry pe
= ((ProtocolDeclarationsDocument
.ProtocolDeclarations
) parent
)
1391 pe
.setName(entryName
);
1393 pe
.setGuidValue(guid
);
1394 pe
.setHelpText(help
);
1395 if (guidTypeList
!= null) {
1396 pe
.setGuidTypeList(guidTypeList
);
1399 if (pe
.isSetGuidTypeList()) {
1400 pe
.unsetGuidTypeList();
1403 if (archList
!= null) {
1404 pe
.setSupArchList(archList
);
1407 if (pe
.isSetSupArchList()) {
1408 pe
.unsetSupArchList();
1411 if (modTypeList
!= null){
1412 pe
.setSupModuleList(modTypeList
);
1415 if (pe
.isSetSupModuleList()) {
1416 pe
.unsetSupModuleList();
1422 if (parent
instanceof PpiDeclarationsDocument
.PpiDeclarations
) {
1423 PpiDeclarationsDocument
.PpiDeclarations
.Entry ppe
= ((PpiDeclarationsDocument
.PpiDeclarations
) parent
)
1425 ppe
.setName(entryName
);
1426 ppe
.setCName(cName
);
1427 ppe
.setGuidValue(guid
);
1428 ppe
.setHelpText(help
);
1429 if (guidTypeList
!= null) {
1430 ppe
.setGuidTypeList(guidTypeList
);
1433 if (ppe
.isSetGuidTypeList()) {
1434 ppe
.unsetGuidTypeList();
1437 if (archList
!= null) {
1438 ppe
.setSupArchList(archList
);
1441 if (ppe
.isSetSupArchList()) {
1442 ppe
.unsetSupArchList();
1445 if (modTypeList
!= null){
1446 ppe
.setSupModuleList(modTypeList
);
1449 if (ppe
.isSetSupModuleList()) {
1450 ppe
.unsetSupModuleList();
1462 Generate Pcd definition using parameters passed in
1464 @param pcdItemTypes ItemType attribute of PcdEntry element
1465 @param cName C_Name element value
1466 @param token Token element value
1467 @param dataType DatumType element value
1468 @param skuEnable Reserved
1470 @param maxSku Reserved
1471 @param hiiEnable Reserved
1472 @param varGuid Reserved
1473 @param varName Reserved
1474 @param defaultString DefaultString element value
1476 public void genSpdPcdDefinitions(String cName
, String token
, String dataType
, String pcdItemTypes
,
1477 String spaceGuid
, String defaultString
, String help
, String archList
,
1478 String modTypeList
) {
1479 if (getSpdPcdDefinitions() == null) {
1480 spdPcdDefinitions
= psaRoot
.addNewPcdDeclarations();
1483 setSpdPcdEntry(pcdItemTypes
, cName
, token
, dataType
, spaceGuid
, help
,
1484 defaultString
, archList
, modTypeList
, spdPcdDefinitions
);
1487 public void getSpdPcdDeclaration(String
[] sa
, int i
) {
1488 if (getSpdPcdDefinitions() == null) {
1492 XmlCursor cursor
= getSpdPcdDefinitions().newCursor();
1493 if (cursor
.toFirstChild()) {
1494 for (int j
= 0; j
< i
; ++j
) {
1495 cursor
.toNextSibling();
1497 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry pe
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)cursor
.getObject();
1498 sa
[0] = pe
.getCName();
1499 sa
[1] = pe
.getToken()+"";
1500 sa
[2] = pe
.getTokenSpaceGuidCName();
1501 sa
[3] = pe
.getDatumType()+"";
1502 sa
[4] = pe
.getDefaultValue();
1503 sa
[5] = pe
.getHelpText();
1504 sa
[6] = listToString(pe
.getValidUsage());
1505 sa
[7] = listToString(pe
.getSupArchList());
1506 sa
[8] = listToString(pe
.getSupModuleList());
1512 Set Pcd entry contents under parent tag
1514 @param pcdItemTypes ItemType attribute of PcdEntry element
1515 @param cName C_Name element value
1516 @param token Token element value
1517 @param dataType DatumType element value
1518 @param spaceGuid Reserved
1519 @param help Reserved
1520 @param defaultString DefaultString element value
1521 @param parent Tag under which PcdEntry goes to
1523 public void setSpdPcdEntry(String pcdItemTypes
, String cName
, String token
, String dataType
, String spaceGuid
, String help
,
1524 String defaultString
, String archList
, String modTypeList
, XmlObject parent
) {
1526 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry pe
= ((PcdDeclarationsDocument
.PcdDeclarations
) parent
).addNewPcdEntry();
1528 //ToDo: maybe multiple types in, need parse pcdItemTypes.
1529 String usage
[] = pcdItemTypes
.split("( )+");
1530 List
<String
> l
= new ArrayList
<String
>();
1531 for (int i
= 0; i
< usage
.length
; ++i
) {
1534 pe
.setValidUsage(l
);
1537 pe
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1538 pe
.setDefaultValue(defaultString
);
1539 pe
.setTokenSpaceGuidCName(spaceGuid
);
1540 pe
.setHelpText(help
);
1541 if (archList
!= null){
1542 pe
.setSupArchList(stringToList(archList
));
1544 if (pe
.isSetSupArchList()) {
1545 pe
.unsetSupArchList();
1548 if (modTypeList
!= null){
1549 pe
.setSupModuleList(stringToList(modTypeList
));
1551 if (pe
.isSetSupModuleList()) {
1552 pe
.unsetSupModuleList();
1558 Get PpiDeclarations element
1560 @return PpiDeclarationsDocument.PpiDeclarations
1562 public PpiDeclarationsDocument
.PpiDeclarations
getSpdPpiDeclarations() {
1563 if (spdPpiDeclarations
== null) {
1564 spdPpiDeclarations
= psaRoot
.getPpiDeclarations();
1566 return spdPpiDeclarations
;
1570 Get ProtocolDeclarations element
1572 @return ProtocolDeclarationsDocument.ProtocolDeclarations
1574 public ProtocolDeclarationsDocument
.ProtocolDeclarations
getSpdProtocolDeclarations() {
1575 if (spdProtocolDeclarations
== null) {
1576 spdProtocolDeclarations
= psaRoot
.getProtocolDeclarations();
1578 return spdProtocolDeclarations
;
1582 Get GuidDeclarations element
1584 @return GuidDeclarationsDocument.GuidDeclarations
1586 public GuidDeclarationsDocument
.GuidDeclarations
getSpdGuidDeclarations() {
1587 if (spdGuidDeclarations
== null) {
1588 spdGuidDeclarations
= psaRoot
.getGuidDeclarations();
1590 return spdGuidDeclarations
;
1594 Get PcdDefinitions element
1596 @return PcdDefinitionsDocument.PcdDefinitions
1598 public PcdDeclarationsDocument
.PcdDeclarations
getSpdPcdDefinitions() {
1599 if (spdPcdDefinitions
== null) {
1600 spdPcdDefinitions
= psaRoot
.getPcdDeclarations();
1602 return spdPcdDefinitions
;
1606 Get PackageHeaders element
1608 @return PackageHeadersDocument.PackageHeaders
1610 public PackageHeadersDocument
.PackageHeaders
getSpdModHdrs() {
1611 if (spdModHdrs
== null) {
1612 spdModHdrs
= psaRoot
.getPackageHeaders();
1618 Get MsaFiles element
1620 @return MsaFilesDocument.MsaFiles
1622 public MsaFilesDocument
.MsaFiles
getSpdMsaFiles() {
1623 if (spdMsaFiles
== null) {
1624 spdMsaFiles
= psaRoot
.getMsaFiles();
1630 Get LibraryClassDeclarations element
1632 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
1634 public LibraryClassDeclarationsDocument
.LibraryClassDeclarations
getSpdLibClassDeclarations() {
1635 if (spdLibClassDeclarations
== null) {
1636 spdLibClassDeclarations
= psaRoot
.getLibraryClassDeclarations();
1638 return spdLibClassDeclarations
;
1641 public PackageDefinitionsDocument
.PackageDefinitions
getSpdPkgDefs() {
1642 if (spdPkgDefs
== null) {
1643 spdPkgDefs
= psaRoot
.addNewPackageDefinitions();
1648 Get SpdHeader element
1650 @return SpdHeaderDocument.SpdHeader
1652 public SpdHeaderDocument
.SpdHeader
getSpdHdr() {
1653 if (spdHdr
== null) {
1654 spdHdr
= psaRoot
.addNewSpdHeader();
1660 Set value to Guid element
1662 @param guid The value set to Guid element
1664 public void setSpdHdrGuidValue(String guid
) {
1665 getSpdHdr().setGuidValue(guid
);
1669 Get Version element under SpdHdr
1673 public String
getSpdHdrVer() {
1674 return getSpdHdr().getVersion();
1678 Set value to Version element
1680 @param ver The value set to Version element
1682 public void setSpdHdrVer(String ver
) {
1683 getSpdHdr().setVersion(ver
);
1686 public String
getSpdHdrAbs(){
1687 return getSpdHdr().getAbstract();
1692 Set value to Abstract element
1694 @param abs The value set to Abstract element
1696 public void setSpdHdrAbs(String abs
) {
1698 getSpdHdr().setAbstract(abs
);
1701 public String
getSpdHdrDescription(){
1702 return getSpdHdr().getDescription();
1705 Set value to Description element
1707 @param des The value set to Description element
1709 public void setSpdHdrDescription(String des
) {
1710 getSpdHdr().setDescription(des
);
1713 public String
getSpdHdrCopyright(){
1714 return getSpdHdr().getCopyright();
1717 Set value to Copyright element
1719 @param cpRit The value set to Copyright element
1721 public void setSpdHdrCopyright(String cpRit
) {
1723 getSpdHdr().setCopyright(cpRit
);
1727 Get License element under SpdHdr
1731 public String
getSpdHdrLicense() {
1732 if (getSpdHdr().getLicense() != null) {
1733 return getSpdHdr().getLicense().getStringValue();
1739 Set value to License element
1741 @param license The value set to License element
1743 public void setSpdHdrLicense(String license
) {
1744 if (getSpdHdr().getLicense() == null){
1745 getSpdHdr().addNewLicense().setStringValue(license
);
1748 getSpdHdr().getLicense().setStringValue(license
);
1752 public String
getSpdHdrUrl(){
1753 if (getSpdHdr().getLicense() != null) {
1754 return getSpdHdr().getLicense().getURL();
1759 public void setSpdHdrUrl(String url
){
1760 getSpdHdr().getLicense().setURL(url
);
1764 Get PackageName element under SpdHdr
1768 public String
getSpdHdrPkgName() {
1770 return getSpdHdr().getPackageName();
1774 Set value to PackageName element
1776 @param pkgName The value set to PackageName element
1778 public void setSpdHdrPkgName(String pkgName
) {
1779 getSpdHdr().setPackageName(pkgName
);
1782 public String
getSpdHdrGuidValue(){
1783 return getSpdHdr().getGuidValue();
1789 @return SpecificationDocument.Specification
1791 public String
getSpdHdrSpec() {
1792 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1793 // return getSpdHdr().getSpecification();
1801 public void setSpdHdrSpec(String spec
) {
1802 spec
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1803 getSpdHdr().setSpecification(spec
);
1807 public String
getSpdPkgDefsRdOnly(){
1808 return getSpdPkgDefs().getReadOnly() + "";
1811 Set value to ReadOnly element
1813 @param rdOnly The value set to ReadOnly element
1815 public void setSpdPkgDefsRdOnly(String rdOnly
) {
1817 getSpdPkgDefs().setReadOnly(new Boolean(rdOnly
));
1820 public String
getSpdPkgDefsRePkg(){
1821 return getSpdPkgDefs().getRePackage() + "";
1824 Set value to RePackage element
1826 @param rePkg The value set to RePackage element
1828 public void setSpdPkgDefsRePkg(String rePkg
) {
1830 getSpdPkgDefs().setRePackage(new Boolean(rePkg
));
1834 Set value to URL element
1836 @param url The value set to URL element
1838 // public void setSpdHdrURL(String url) {
1839 // getSpdHdr().setURL(url);
1847 public File
getFile() {
1854 @param file File with xml format
1856 public void setFile(File file
) {
1860 private List
<String
> stringToList(String s
){
1861 if (s
== null || s
.length() == 0) {
1864 Vector
<String
> al
= new Vector
<String
>();
1865 String
[] sArray
= s
.split(" ");
1866 for(int i
= 0; i
< sArray
.length
; ++i
){
1872 private String
listToString(List l
) {
1877 ListIterator li
= l
.listIterator();
1878 while(li
.hasNext()) {