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
;
22 import javax
.xml
.namespace
.QName
;
24 import org
.apache
.xmlbeans
.XmlObject
;
25 import org
.apache
.xmlbeans
.XmlOptions
;
26 import org
.apache
.xmlbeans
.XmlCursor
;
28 import org
.tianocore
.GuidDeclarationsDocument
;
30 import org
.tianocore
.LibraryClassDeclarationsDocument
;
32 import org
.tianocore
.ModuleTypeDef
;
33 import org
.tianocore
.MsaFilesDocument
;
34 import org
.tianocore
.PackageDefinitionsDocument
;
35 import org
.tianocore
.PackageHeadersDocument
;
36 import org
.tianocore
.PackageSurfaceAreaDocument
;
37 import org
.tianocore
.PcdDataTypes
;
38 import org
.tianocore
.PcdDeclarationsDocument
;
39 import org
.tianocore
.PpiDeclarationsDocument
;
40 import org
.tianocore
.ProtocolDeclarationsDocument
;
41 import org
.tianocore
.SpdHeaderDocument
;
42 import org
.tianocore
.GuidDeclarationsDocument
.GuidDeclarations
;
45 This class processes spd file contents such as add remove xml elements.
47 @since PackageEditor 1.0
50 public class SpdFileContents
{
52 private File file
= null;
54 private PackageSurfaceAreaDocument psad
= null;
56 private PackageSurfaceAreaDocument
.PackageSurfaceArea psaRoot
= null;
58 private SpdHeaderDocument
.SpdHeader spdHdr
= null;
60 private PackageDefinitionsDocument
.PackageDefinitions spdPkgDefs
= null;
62 private LibraryClassDeclarationsDocument
.LibraryClassDeclarations spdLibClassDeclarations
= null;
64 private MsaFilesDocument
.MsaFiles spdMsaFiles
= null;
66 private PackageHeadersDocument
.PackageHeaders spdModHdrs
= null;
68 private GuidDeclarationsDocument
.GuidDeclarations spdGuidDeclarations
= null;
70 private ProtocolDeclarationsDocument
.ProtocolDeclarations spdProtocolDeclarations
= null;
72 private PpiDeclarationsDocument
.PpiDeclarations spdPpiDeclarations
= null;
74 private PcdDeclarationsDocument
.PcdDeclarations spdPcdDefinitions
= null;
77 Constructor to create a new spd file
79 public SpdFileContents() {
81 psad
= PackageSurfaceAreaDocument
.Factory
.newInstance();
82 psaRoot
= psad
.addNewPackageSurfaceArea();
87 Constructor for existing document object
90 public SpdFileContents(PackageSurfaceAreaDocument
.PackageSurfaceArea psa
) {
92 spdHdr
= psaRoot
.getSpdHeader();
93 spdPkgDefs
= psaRoot
.getPackageDefinitions();
96 Constructor based on an existing spd file
98 @param f Existing spd file
100 public SpdFileContents(File f
) {
102 psad
= PackageSurfaceAreaDocument
.Factory
.parse(f
);
103 psaRoot
= psad
.getPackageSurfaceArea();
105 } catch (Exception e
) {
106 System
.out
.println(e
.toString());
111 Remove existing pcd definitions elements using XmlCursor
113 public void removeSpdPcdDefinition() {
114 XmlObject o
= psaRoot
.getPcdDeclarations();
117 XmlCursor cursor
= o
.newCursor();
119 spdPcdDefinitions
= null;
123 public void removeSpdPcdDefinition(int i
){
124 XmlObject o
= psaRoot
.getPcdDeclarations();
127 XmlCursor cursor
= o
.newCursor();
128 if (cursor
.toFirstChild()) {
129 for (int j
= 0; j
< i
; ++j
) {
130 cursor
.toNextSibling();
138 Remove existing ppi declarations using XmlCursor
140 public void removeSpdPpiDeclaration() {
141 XmlObject o
= psaRoot
.getPpiDeclarations();
144 XmlCursor cursor
= o
.newCursor();
146 spdPpiDeclarations
= null;
150 public void removeSpdPpiDeclaration(int i
){
151 XmlObject o
= psaRoot
.getPpiDeclarations();
154 XmlCursor cursor
= o
.newCursor();
155 if (cursor
.toFirstChild()) {
156 for (int j
= 0; j
< i
; ++j
) {
157 cursor
.toNextSibling();
164 Remove existing protocols declarations using XmlCursor
166 public void removeSpdProtocolDeclaration() {
167 XmlObject o
= psaRoot
.getProtocolDeclarations();
170 XmlCursor cursor
= o
.newCursor();
172 spdProtocolDeclarations
= null;
176 public void removeSpdProtocolDeclaration(int i
) {
177 XmlObject o
= psaRoot
.getProtocolDeclarations();
180 XmlCursor cursor
= o
.newCursor();
181 if (cursor
.toFirstChild()) {
182 for (int j
= 0; j
< i
; ++j
) {
183 cursor
.toNextSibling();
190 Remove existing GUID declarations using XmlCursor
192 public void removeSpdGuidDeclaration() {
193 XmlObject o
= psaRoot
.getGuidDeclarations();
196 XmlCursor cursor
= o
.newCursor();
198 spdGuidDeclarations
= null;
202 public void removeSpdGuidDeclaration(int i
) {
203 XmlObject o
= psaRoot
.getGuidDeclarations();
206 XmlCursor cursor
= o
.newCursor();
207 if (cursor
.toFirstChild()) {
208 for (int j
= 0; j
< i
; ++j
) {
209 cursor
.toNextSibling();
218 Remove existing spd package include files using XmlCursor
220 public void removeSpdPkgHeader() {
221 XmlObject o
= psaRoot
.getPackageHeaders();
224 XmlCursor cursor
= o
.newCursor();
230 public void removeSpdPkgHeader(int i
){
231 XmlObject o
= psaRoot
.getPackageHeaders();
234 XmlCursor cursor
= o
.newCursor();
235 if (cursor
.toFirstChild()) {
236 for (int j
= 0; j
< i
; ++j
) {
237 cursor
.toNextSibling();
245 Remove existing msa files using XmlCursor
247 public void removeSpdMsaFile() {
248 XmlObject o
= psaRoot
.getMsaFiles();
251 XmlCursor cursor
= o
.newCursor();
257 public void removeSpdMsaFile(int i
){
258 XmlObject o
= psaRoot
.getMsaFiles();
261 XmlCursor cursor
= o
.newCursor();
262 if (cursor
.toFirstChild()) {
263 for (int j
= 0; j
< i
; ++j
) {
264 cursor
.toNextSibling();
272 Remove existing library class declarations using XmlCursor
274 public void removeSpdLibClass() {
275 XmlObject o
= psaRoot
.getLibraryClassDeclarations();
278 XmlCursor cursor
= o
.newCursor();
280 spdLibClassDeclarations
= null;
284 public void removeSpdLibClass(int i
) {
285 XmlObject o
= psaRoot
.getLibraryClassDeclarations();
288 XmlCursor cursor
= o
.newCursor();
289 if (cursor
.toFirstChild()) {
290 for (int j
= 0; j
< i
; ++j
) {
291 cursor
.toNextSibling();
298 public void updateSpdLibClass(int i
, String lib
, String hdr
, String hlp
, String clsUsage
, String instanceVer
, String hdrAttribArch
, String hdrAttribModType
) {
299 XmlObject o
= psaRoot
.getLibraryClassDeclarations();
303 XmlCursor cursor
= o
.newCursor();
304 if (cursor
.toFirstChild()) {
305 for (int j
= 0; j
< i
; ++j
) {
306 cursor
.toNextSibling();
308 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass lc
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
)cursor
.getObject();
310 lc
.setIncludeHeader(hdr
);
312 if (clsUsage
!= null) {
313 lc
.setRecommendedInstanceGuid(clsUsage
);
315 if (instanceVer
!= null){
316 lc
.setRecommendedInstanceVersion(instanceVer
);
318 if (stringToList(hdrAttribArch
) != null){
319 lc
.setSupArchList(stringToList(hdrAttribArch
));
321 if (stringToList(hdrAttribModType
) != null){
322 lc
.setSupModuleList(stringToList(hdrAttribModType
));
329 public void updateSpdMsaFile(int i
, String msaFile
, String mName
, String v
, String g
){
330 XmlObject o
= psaRoot
.getMsaFiles();
334 XmlCursor cursor
= o
.newCursor();
335 if (cursor
.toFirstChild()) {
336 for (int j
= 0; j
< i
; ++j
) {
337 cursor
.toNextSibling();
339 cursor
.setTextValue(msaFile
);
346 public void updateSpdGuidDecl(int i
, String name
, String cName
, String guid
, String hlp
, String archList
,
347 String modTypeList
, String guidTypeList
){
348 XmlObject o
= psaRoot
.getGuidDeclarations();
353 XmlCursor cursor
= o
.newCursor();
354 if (cursor
.toFirstChild()) {
355 for (int j
= 0; j
< i
; ++j
) {
356 cursor
.toNextSibling();
358 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
)cursor
.getObject();
361 e
.setGuidValue(guid
);
363 if (stringToList(guidTypeList
) != null && !guidTypeList
.equals("")) {
364 e
.setGuidTypeList(stringToList(guidTypeList
));
366 if (stringToList(archList
) != null){
367 e
.setSupArchList(stringToList(archList
));
369 if (stringToList(modTypeList
) != null) {
370 e
.setSupModuleList(stringToList(modTypeList
));
377 public void updateSpdPpiDecl(int i
, String name
, String cName
, String guid
, String hlp
, String archList
,
379 XmlObject o
= psaRoot
.getPpiDeclarations();
384 XmlCursor cursor
= o
.newCursor();
385 if (cursor
.toFirstChild()) {
386 for (int j
= 0; j
< i
; ++j
) {
387 cursor
.toNextSibling();
389 PpiDeclarationsDocument
.PpiDeclarations
.Entry e
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
)cursor
.getObject();
392 e
.setGuidValue(guid
);
394 if (stringToList(archList
) != null){
395 e
.setSupArchList(stringToList(archList
));
397 if (stringToList(modTypeList
) != null) {
398 e
.setSupModuleList(stringToList(modTypeList
));
404 public void updateSpdProtocolDecl(int i
, String name
, String cName
, String guid
, String hlp
, String archList
,
406 XmlObject o
= psaRoot
.getProtocolDeclarations();
411 XmlCursor cursor
= o
.newCursor();
412 if (cursor
.toFirstChild()) {
413 for (int j
= 0; j
< i
; ++j
) {
414 cursor
.toNextSibling();
416 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry e
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
)cursor
.getObject();
419 e
.setGuidValue(guid
);
421 if (stringToList(archList
) != null){
422 e
.setSupArchList(stringToList(archList
));
424 if (stringToList(modTypeList
) != null) {
425 e
.setSupModuleList(stringToList(modTypeList
));
431 public void updateSpdPkgHdr(int i
, String pkgName
, String hdrName
){
432 XmlObject o
= psaRoot
.getPackageHeaders();
437 XmlCursor cursor
= o
.newCursor();
438 if (cursor
.toFirstChild()) {
439 for (int j
= 0; j
< i
; ++j
) {
440 cursor
.toNextSibling();
443 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader iph
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
)cursor
.getObject();
444 iph
.setModuleType(ModuleTypeDef
.Enum
.forString(pkgName
));
445 iph
.setStringValue(hdrName
);
450 public void updateSpdPcdDefinition(int i
, String cName
, String token
, String dataType
, String pcdItemTypes
,
451 String spaceGuid
, String defaultString
, String help
, String archList
, String modTypeList
){
452 XmlObject o
= psaRoot
.getPcdDeclarations();
455 XmlCursor cursor
= o
.newCursor();
456 if (cursor
.toFirstChild()) {
457 for (int j
= 0; j
< i
; ++j
) {
458 cursor
.toNextSibling();
460 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry e
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)cursor
.getObject();
463 e
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
464 if (pcdItemTypes
!= null && pcdItemTypes
.length() > 0) {
465 String usage
[] = pcdItemTypes
.split("( )+");
466 List
<String
> l
= new ArrayList
<String
>();
467 for (int k
= 0; k
< usage
.length
; ++k
) {
473 e
.setTokenSpaceGuidCName(spaceGuid
);
474 e
.setDefaultValue(defaultString
);
476 if (archList
!= null && archList
.length() > 0){
477 e
.setSupArchList(stringToList(archList
));
479 if (modTypeList
!= null && modTypeList
.length() > 0){
480 e
.setSupModuleList(stringToList(modTypeList
));
486 Get spd file header contents into String array
488 @param s Caller allocated String array
490 public void getSpdHdrDetails(String
[] s
) {
491 if (getSpdHdr() == null) {
492 spdHdr
= psaRoot
.addNewSpdHeader();
494 s
[0] = getSpdHdrPkgName();
495 s
[1] = getSpdHdr().getGuidValue();
496 s
[2] = getSpdHdrVer();
497 // s[3] = getSpdHdr().getAbstract();
498 s
[4] = getSpdHdr().getDescription();
499 s
[5] = getSpdHdr().getCopyright();
500 s
[6] = getSpdHdrLicense();
505 Get the number of library class declarations from the size of List
509 public int getSpdLibClassDeclarationCount() {
510 if (psaRoot
.getLibraryClassDeclarations() == null
511 || psaRoot
.getLibraryClassDeclarations().getLibraryClassList() == null) {
514 return psaRoot
.getLibraryClassDeclarations().getLibraryClassList().size();
518 Get available library class declaration into String array
519 @param libClass Caller allocated two-dimentional String array
521 public void getSpdLibClassDeclarations(String
[][] libClass
) {
522 if (psaRoot
.getLibraryClassDeclarations() == null){
526 List
<LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
> l
= psaRoot
.getLibraryClassDeclarations().getLibraryClassList();
528 ListIterator li
= l
.listIterator();
529 while (li
.hasNext()) {
530 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass lc
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) li
.next();
532 libClass
[i
][0] = lc
.getName();
533 libClass
[i
][1] = lc
.getIncludeHeader();
534 libClass
[i
][2] = lc
.getHelpText();
535 libClass
[i
][3] = lc
.getRecommendedInstanceGuid();
536 libClass
[i
][4] = lc
.getRecommendedInstanceVersion();
537 if (lc
.getSupArchList() != null) {
538 libClass
[i
][5] = listToString(lc
.getSupArchList());
540 if (lc
.getSupModuleList() != null) {
541 libClass
[i
][6] = listToString(lc
.getSupModuleList());
552 Get the number of Msa files from the size of List
556 public int getSpdMsaFileCount() {
557 if (psaRoot
.getMsaFiles() == null || psaRoot
.getMsaFiles().getFilenameList() == null) {
560 return psaRoot
.getMsaFiles().getFilenameList().size();
564 Get available Msa file into String array
566 @param msaFile Caller allocated two-dimentional String array
568 public void getSpdMsaFiles(String
[][] msaFile
) {
569 if (psaRoot
.getMsaFiles() == null) {
572 List
<String
> l
= psaRoot
.getMsaFiles().getFilenameList();
574 ListIterator li
= l
.listIterator();
575 while (li
.hasNext()) {
576 msaFile
[i
][0] = (String
)li
.next();
583 Get the number of include header files in PackageHeaders from the size of List
587 public int getSpdPackageHeaderCount() {
588 if (psaRoot
.getPackageHeaders() == null || psaRoot
.getPackageHeaders().getIncludePkgHeaderList() == null) {
591 return psaRoot
.getPackageHeaders().getIncludePkgHeaderList().size();
595 Get available package header contents into String array
597 @param pkgHeader Caller allocated two-dimentional String array
599 public void getSpdPackageHeaders(String
[][] pkgHeader
) {
600 if (psaRoot
.getPackageHeaders() == null) {
604 List
<PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
> l
= psaRoot
.getPackageHeaders().getIncludePkgHeaderList();
606 ListIterator li
= l
.listIterator();
607 while (li
.hasNext()) {
608 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader ih
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) li
.next();
609 if (ih
.getModuleType() != null) {
610 pkgHeader
[i
][0] = ih
.getModuleType().toString();
613 pkgHeader
[i
][1] = ih
.getStringValue();
619 Get the number of GUID declarations from the size of List
623 public int getSpdGuidDeclarationCount() {
624 if (psaRoot
.getGuidDeclarations() == null || psaRoot
.getGuidDeclarations().getEntryList() == null) {
627 return psaRoot
.getGuidDeclarations().getEntryList().size();
631 Get available Guid declaration contents into String array
633 @param guid Caller allocated two-dimentional String array
635 public void getSpdGuidDeclarations(String
[][] guid
) {
636 if (psaRoot
.getGuidDeclarations() == null) {
640 List
<GuidDeclarationsDocument
.GuidDeclarations
.Entry
> l
= psaRoot
.getGuidDeclarations().getEntryList();
642 ListIterator li
= l
.listIterator();
643 while (li
.hasNext()) {
644 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) li
646 guid
[i
][0] = e
.getName();
647 guid
[i
][1] = e
.getCName();
648 if (e
.getGuidValue() != null) {
649 guid
[i
][2] = e
.getGuidValue();
651 guid
[i
][3] = e
.getHelpText();
652 guid
[i
][4] = listToString(e
.getSupArchList());
653 guid
[i
][5] = listToString(e
.getSupModuleList());
654 guid
[i
][6] = listToString(e
.getGuidTypeList());
660 Get the number of protocol declarations from the size of List
664 public int getSpdProtocolDeclarationCount() {
665 if (psaRoot
.getProtocolDeclarations() == null || psaRoot
.getProtocolDeclarations().getEntryList() == null) {
668 return psaRoot
.getProtocolDeclarations().getEntryList().size();
672 Get available protocol declaration contents into String array
674 @param protocol Caller allocated two-dimentional String array
676 public void getSpdProtocolDeclarations(String
[][] protocol
) {
677 if (psaRoot
.getProtocolDeclarations() == null) {
681 List
<ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
> l
= psaRoot
.getProtocolDeclarations()
684 ListIterator li
= l
.listIterator();
685 while (li
.hasNext()) {
686 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry e
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) li
688 protocol
[i
][0] = e
.getName();
689 protocol
[i
][1] = e
.getCName();
690 if (e
.getGuidValue() != null) {
691 protocol
[i
][2] = e
.getGuidValue();
693 protocol
[i
][3] = e
.getHelpText();
694 protocol
[i
][4] = listToString(e
.getSupArchList());
695 protocol
[i
][5] = listToString(e
.getSupModuleList());
701 Get the number of Ppi declarations from the size of List
705 public int getSpdPpiDeclarationCount() {
706 if (psaRoot
.getPpiDeclarations() == null || psaRoot
.getPpiDeclarations().getEntryList() == null) {
709 return psaRoot
.getPpiDeclarations().getEntryList().size();
713 Get available Ppi declaration contents into String array
715 @param ppi Caller allocated two-dimentional String array
717 public void getSpdPpiDeclarations(String
[][] ppi
) {
718 if (psaRoot
.getPpiDeclarations() == null) {
722 List
<PpiDeclarationsDocument
.PpiDeclarations
.Entry
> l
= psaRoot
.getPpiDeclarations().getEntryList();
724 ListIterator li
= l
.listIterator();
725 while (li
.hasNext()) {
726 PpiDeclarationsDocument
.PpiDeclarations
.Entry e
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) li
.next();
727 ppi
[i
][0] = e
.getName();
728 ppi
[i
][1] = e
.getCName();
729 if (e
.getGuidValue() != null) {
730 ppi
[i
][2] = e
.getGuidValue();
732 ppi
[i
][3] = e
.getHelpText();
733 ppi
[i
][4] = listToString(e
.getSupArchList());
734 ppi
[i
][5] = listToString(e
.getSupModuleList());
741 Get the number of Pcd definitions from the size of List
745 public int getSpdPcdDefinitionCount() {
746 if (psaRoot
.getPcdDeclarations() == null || psaRoot
.getPcdDeclarations().getPcdEntryList() == null) {
749 return psaRoot
.getPcdDeclarations().getPcdEntryList().size();
753 Get available Pcd definition contents into String array
755 @param pcd Caller allocated two-dimentional String array
757 public void getSpdPcdDefinitions(String
[][] pcd
, String pcdUsage
[][]) {
758 if (psaRoot
.getPcdDeclarations() == null) {
762 List
<PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
> l
= psaRoot
.getPcdDeclarations().getPcdEntryList();
764 while (i
< l
.size()) {
765 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry e
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)l
.get(i
);
766 pcd
[i
][0] = e
.getCName();
767 pcd
[i
][1] = e
.getToken() + "";
768 pcd
[i
][2] = e
.getTokenSpaceGuidCName();
769 if (e
.getDatumType() != null) {
770 pcd
[i
][3] = e
.getDatumType().toString();
772 pcd
[i
][4] = e
.getDefaultValue()+"";
773 pcd
[i
][5] = e
.getHelpText();
774 String archList
= listToString(e
.getSupArchList());
775 if (archList
!= null) {
776 pcd
[i
][6] = archList
;
778 String modTypeList
= listToString(e
.getSupModuleList());
779 if (modTypeList
!= null) {
780 pcd
[i
][7] = modTypeList
;
784 while (j
< e
.getValidUsage().size() && j
< 5) {
785 pcdUsage
[i
][j
] = (String
)e
.getValidUsage().get(j
);
793 Save the processed xml contents to file
795 @param spdFile The file to save xml contents
796 @throws IOException Exceptions during file operation
798 public void saveAs(File spdFile
) throws IOException
{
800 XmlOptions options
= new XmlOptions();
802 options
.setCharacterEncoding("UTF-8");
803 options
.setSavePrettyPrint();
804 options
.setSavePrettyPrintIndent(2);
806 psad
.save(spdFile
, options
);
807 } catch (IOException e
) {
814 Generate SpdHeader contents using parameters passed in.
816 @param pkgName PackageName
818 @param pkgVer Version
819 @param pkgAbs Abstract
820 @param pkgDes Description
821 @param pkgCpRight Copyright
822 @param pkgLicense License
823 @param pkgCreateDate Created
824 @param pkgUpdateDate Updated
826 @param pkgType PackageType
827 @param pkgRdOnly ReadOnly
828 @param pkgRePkg RePackage
829 @param pkgSpec Reserved
830 @param pkgOutDir Reserved
832 public void genSpdHeader(String pkgName
, String pkgGuid
, String pkgVer
, String pkgAbs
, String pkgDes
,
833 String pkgCpRight
, String pkgLicense
, String pkgCreateDate
, String pkgUpdateDate
,
834 String pkgURL
, String pkgType
, String pkgRdOnly
, String pkgRePkg
, String pkgSpec
,
836 if (getSpdHdr() == null) {
837 spdHdr
= psaRoot
.addNewSpdHeader();
840 setSpdHdrPkgName(pkgName
);
841 setSpdHdrGuidValue(pkgGuid
);
842 setSpdHdrVer(pkgVer
);
843 setSpdHdrAbs(pkgAbs
);
844 setSpdHdrDescription(pkgDes
);
845 setSpdHdrCopyright(pkgCpRight
);
846 setSpdHdrLicense(pkgLicense
);
849 setSpdHdrSpec(pkgSpec
);
853 Generate library class declaration element using parameters passed in
855 @param libClassBaseName LibraryClass element value
856 @param libClassUsage Reserved
857 @param incHdrFileName IncludeHeader element value
858 @param incHdrAttribGuid Reserved
859 @param incHdrAttribArch Reserved
860 @param incHdrAttribPath Reserved
861 @param incHdrAttribClass Reserved
862 @param incHdrAttribVer Reserved
863 @param incHdrAttribOverrideID Reserved
864 @param incHdrAttribModuleType Reserved
866 public void genSpdLibClassDeclarations(String libClassBaseName
, String instanceUsage
, String incHdrFileName
,
867 String help
, String incHdrAttribArch
, String incHdrAttribPath
,
868 String incHdrAttribClass
, String incHdrAttribVer
,
869 String incHdrAttribOverrideID
, String incHdrAttribModuleType
) {
870 if (getSpdLibClassDeclarations() == null) {
871 spdLibClassDeclarations
= psaRoot
.addNewLibraryClassDeclarations();
874 // add contents under LibraryClassDeclarations tag
876 setSpdLibClassDeclaration(libClassBaseName
, instanceUsage
, incHdrFileName
, help
, incHdrAttribArch
,
877 incHdrAttribPath
, incHdrAttribClass
, incHdrAttribVer
, incHdrAttribOverrideID
,
878 incHdrAttribModuleType
, spdLibClassDeclarations
);
882 Set library class declaration contents under parent tag
884 @param clsName LibraryClass element value
885 @param clsUsage Reserved
886 @param hdrFile IncludeHeader element value
887 @param hdrAttribGuid Reserved
888 @param hdrAttribArch Reserved
889 @param hdrAttribPath Reserved
890 @param hdrAttribClass Reserved
891 @param hdrAttribVer Reserved
892 @param hdrAttribOverID Reserved
893 @param hdrAttribModType Reserved
894 @param parent The tag under which library class declaration goes to
896 public void setSpdLibClassDeclaration(String clsName
, String clsUsage
, String hdrFile
, String help
,
897 String hdrAttribArch
, String hdrAttribPath
, String hdrAttribClass
,
898 String instanceVer
, String hdrAttribOverID
, String hdrAttribModType
,
901 setSpdLibraryClass(clsName
, hdrFile
, help
, clsUsage
, instanceVer
, hdrAttribArch
, hdrAttribModType
, parent
);
906 Set the contents of LibraryClass under parent element
908 @param clsName LibraryClass element value
909 @param clsUsage Reserved
910 @param parent The tag under which library class declaration goes to
912 public void setSpdLibraryClass(String clsName
, String clsIncludeFile
, String help
, String clsUsage
, String instanceVer
, String hdrAttribArch
, String hdrAttribModType
, XmlObject parent
) {
913 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass lc
= ((LibraryClassDeclarationsDocument
.LibraryClassDeclarations
) parent
).addNewLibraryClass();
915 lc
.setIncludeHeader(clsIncludeFile
);
916 lc
.setHelpText(help
);
917 lc
.setRecommendedInstanceGuid(clsUsage
);
918 lc
.setRecommendedInstanceVersion(instanceVer
);
919 if (hdrAttribArch
!= null) {
920 lc
.setSupArchList(stringToList(hdrAttribArch
));
922 if (hdrAttribModType
!= null) {
923 lc
.setSupModuleList(stringToList(hdrAttribModType
));
929 Set contents of IncludeHeader under parent element
931 @param modType Reserved
932 @param hdrFile IncludeHeader element value
933 @param hdrAttribGuid Reserved
934 @param hdrAttribArch Reserved
935 @param hdrAttribPath Reserved
936 @param hdrAttribClass Reserved
937 @param hdrAttribVer Reserved
938 @param hdrAttribOverID Reserved
939 @param parent The tag under which library class declaration goes to
941 public void setSpdIncludeHeader(String modType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
942 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
943 String hdrAttribOverID
, XmlObject parent
) {
945 if (parent
instanceof LibraryClassDeclarationsDocument
.LibraryClassDeclarations
) {
946 } else if (parent
instanceof PackageHeadersDocument
.PackageHeaders
) {
947 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader ih
= null;
948 ih
= ((PackageHeadersDocument
.PackageHeaders
) parent
).addNewIncludePkgHeader();
949 ih
.setStringValue(hdrFile
);
950 ih
.setModuleType(ModuleTypeDef
.Enum
.forString(modType
));
955 if (hdrAttribGuid
!= null) {
957 if (hdrAttribPath
!= null) {
959 if (hdrAttribClass
!= null) {
961 if (hdrAttribVer
!= null) {
963 if (hdrAttribOverID
!= null) {
969 Generate MsaFile element.
971 @param msaFileName MsaFile element value
972 @param archType Reserved
974 public void genSpdMsaFiles(String msaFileName
, String moduleName
, String ver
, String guid
) {
975 if (getSpdMsaFiles() == null) {
976 spdMsaFiles
= psaRoot
.addNewMsaFiles();
978 setSpdMsaFile(msaFileName
, moduleName
, ver
, guid
, spdMsaFiles
);
983 Set MsaFile contents under parent element.
985 @param msaFileName MsaFile element value
986 @param parent Element under which MsaFile goes to
988 public void setSpdMsaFile(String msaFileName
, String moduleName
, String ver
, String guid
, XmlObject parent
) {
989 MsaFilesDocument
.MsaFiles f
= (MsaFilesDocument
.MsaFiles
)parent
;
990 f
.addNewFilename().setStringValue(msaFileName
);
991 // f.setFilename(msaFileName);
992 // f.setModuleName(moduleName);
993 // f.setModuleVersion(ver);
994 // f.setModuleGuid(guid);
998 Generate PackageHeader element using parameters passed in.
1000 @param ModHdrModType ModuleType attribute of IncludeHeader element
1001 @param hdrFile IncludeHeader element value
1002 @param hdrAttribGuid Reserved
1003 @param hdrAttribArch Reserved
1004 @param hdrAttribPath Reserved
1005 @param hdrAttribClass Reserved
1006 @param hdrAttribVer Reserved
1007 @param hdrAttribOverID Reserved
1009 public void genSpdModuleHeaders(String ModHdrModType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
1010 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
1011 String hdrAttribOverID
) {
1012 if (getSpdModHdrs() == null) {
1013 spdModHdrs
= psaRoot
.addNewPackageHeaders();
1017 // add IncludeHeader under PackageHeaders element
1019 setSpdIncludeHeader(ModHdrModType
, hdrFile
, hdrAttribGuid
, hdrAttribArch
, hdrAttribPath
, hdrAttribClass
,
1020 hdrAttribVer
, hdrAttribOverID
, spdModHdrs
);
1024 Generate GUID declaration element using parameters passed in.
1026 @param guidDeclEntryName Name attribute of Entry element
1027 @param guidDeclCName CName element value
1028 @param guidDeclGuid Guid element value
1029 @param guidDeclFeatureFlag Reserved
1031 public void genSpdGuidDeclarations(String guidDeclEntryName
, String guidDeclCName
, String guidDeclGuid
,
1032 String guidDeclHelp
, Vector
<String
> archList
, Vector
<String
> modTypeList
,
1033 Vector
<String
> guidTypeList
) {
1034 if (getSpdGuidDeclarations() == null) {
1035 spdGuidDeclarations
= psaRoot
.addNewGuidDeclarations();
1038 setSpdEntry(guidDeclEntryName
, guidDeclCName
, guidDeclGuid
, guidDeclHelp
, archList
, modTypeList
, guidTypeList
, spdGuidDeclarations
);
1042 Generate protocol declaration element using parameters passed in.
1044 @param protocolDeclEntryName Name attribute of Entry element
1045 @param protocolDeclCName CName element value
1046 @param protocolDeclGuid Guid element value
1047 @param protocolDeclFeatureFlag Reserved
1049 public void genSpdProtocolDeclarations(String protocolDeclEntryName
, String protocolDeclCName
,
1050 String protocolDeclGuid
, String protocolDeclFeatureFlag
,
1051 Vector
<String
> archList
, Vector
<String
> modTypeList
) {
1052 if (getSpdProtocolDeclarations() == null) {
1053 spdProtocolDeclarations
= psaRoot
.addNewProtocolDeclarations();
1056 setSpdEntry(protocolDeclEntryName
, protocolDeclCName
, protocolDeclGuid
, protocolDeclFeatureFlag
,
1057 archList
, modTypeList
, null, spdProtocolDeclarations
);
1061 Generate PPI declaration element using parameters passed in.
1063 @param ppiDeclEntryName Name attribute of Entry element
1064 @param ppiDeclCName CName element value
1065 @param ppiDeclGuid Guid element value
1066 @param ppiDeclFeatureFlag Reserved
1068 public void genSpdPpiDeclarations(String ppiDeclEntryName
, String ppiDeclCName
, String ppiDeclGuid
,
1069 String ppiDeclFeatureFlag
, Vector
<String
> archList
, Vector
<String
> modTypeList
) {
1070 if (getSpdPpiDeclarations() == null) {
1071 spdPpiDeclarations
= psaRoot
.addNewPpiDeclarations();
1074 setSpdEntry(ppiDeclEntryName
, ppiDeclCName
, ppiDeclGuid
, ppiDeclFeatureFlag
, archList
, modTypeList
, null, spdPpiDeclarations
);
1078 Set Entry contents using parameters passed in
1080 @param entryName Name attribute of Entry element
1081 @param cName CName element value
1082 @param guid Guid element value
1083 @param featureFlag Reserved
1084 @param parent The tag under which Entry element goes to
1086 public void setSpdEntry(String entryName
, String cName
, String guid
, String help
,
1087 Vector
<String
> archList
, Vector
<String
> modTypeList
,
1088 Vector
<String
> guidTypeList
, XmlObject parent
) {
1090 if (parent
instanceof GuidDeclarationsDocument
.GuidDeclarations
) {
1091 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= ((GuidDeclarations
) parent
).addNewEntry();
1092 e
.setName(entryName
);
1094 e
.setGuidValue(guid
);
1095 e
.setHelpText(help
);
1096 if (guidTypeList
!= null && guidTypeList
.size() > 0) {
1097 e
.setGuidTypeList(new ArrayList
<String
>(guidTypeList
));
1099 if (archList
!= null && archList
.size() > 0){
1100 e
.setSupArchList(new ArrayList
<String
>(archList
));
1102 if (modTypeList
!= null && modTypeList
.size() > 0) {
1103 e
.setSupModuleList(new ArrayList
<String
>(modTypeList
));
1107 if (parent
instanceof ProtocolDeclarationsDocument
.ProtocolDeclarations
) {
1108 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry pe
= ((ProtocolDeclarationsDocument
.ProtocolDeclarations
) parent
)
1110 pe
.setName(entryName
);
1112 pe
.setGuidValue(guid
);
1113 pe
.setHelpText(help
);
1114 if (archList
!= null && archList
.size() > 0){
1115 pe
.setSupArchList(new ArrayList
<String
>(archList
));
1117 if (modTypeList
!= null && modTypeList
.size() > 0) {
1118 pe
.setSupModuleList(new ArrayList
<String
>(modTypeList
));
1122 if (parent
instanceof PpiDeclarationsDocument
.PpiDeclarations
) {
1123 PpiDeclarationsDocument
.PpiDeclarations
.Entry ppe
= ((PpiDeclarationsDocument
.PpiDeclarations
) parent
)
1125 ppe
.setName(entryName
);
1126 ppe
.setCName(cName
);
1127 ppe
.setGuidValue(guid
);
1128 ppe
.setHelpText(help
);
1129 if (archList
!= null && archList
.size() > 0){
1130 ppe
.setSupArchList(new ArrayList
<String
>(archList
));
1132 if (archList
!= null && modTypeList
.size() > 0) {
1133 ppe
.setSupModuleList(new ArrayList
<String
>(modTypeList
));
1143 Generate Pcd definition using parameters passed in
1145 @param pcdItemTypes ItemType attribute of PcdEntry element
1146 @param cName C_Name element value
1147 @param token Token element value
1148 @param dataType DatumType element value
1149 @param skuEnable Reserved
1151 @param maxSku Reserved
1152 @param hiiEnable Reserved
1153 @param varGuid Reserved
1154 @param varName Reserved
1155 @param defaultString DefaultString element value
1157 public void genSpdPcdDefinitions(String cName
, String token
, String dataType
, String pcdItemTypes
,
1158 String spaceGuid
, String defaultString
, String help
, String archList
,
1159 String modTypeList
) {
1160 if (getSpdPcdDefinitions() == null) {
1161 spdPcdDefinitions
= psaRoot
.addNewPcdDeclarations();
1164 setSpdPcdEntry(pcdItemTypes
, cName
, token
, dataType
, spaceGuid
, help
,
1165 defaultString
, archList
, modTypeList
, spdPcdDefinitions
);
1169 Set Pcd entry contents under parent tag
1171 @param pcdItemTypes ItemType attribute of PcdEntry element
1172 @param cName C_Name element value
1173 @param token Token element value
1174 @param dataType DatumType element value
1175 @param spaceGuid Reserved
1176 @param help Reserved
1177 @param defaultString DefaultString element value
1178 @param parent Tag under which PcdEntry goes to
1180 public void setSpdPcdEntry(String pcdItemTypes
, String cName
, String token
, String dataType
, String spaceGuid
, String help
,
1181 String defaultString
, String archList
, String modTypeList
, XmlObject parent
) {
1183 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry pe
= ((PcdDeclarationsDocument
.PcdDeclarations
) parent
).addNewPcdEntry();
1185 //ToDo: maybe multiple types in, need parse pcdItemTypes.
1186 String usage
[] = pcdItemTypes
.split("( )+");
1187 List
<String
> l
= new ArrayList
<String
>();
1188 for (int i
= 0; i
< usage
.length
; ++i
) {
1191 pe
.setValidUsage(l
);
1194 pe
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1195 pe
.setDefaultValue(defaultString
);
1196 pe
.setTokenSpaceGuidCName(spaceGuid
);
1197 pe
.setHelpText(help
);
1198 if (archList
!= null){
1199 pe
.setSupArchList(stringToList(archList
));
1201 if (modTypeList
!= null){
1202 pe
.setSupModuleList(stringToList(modTypeList
));
1207 Get PpiDeclarations element
1209 @return PpiDeclarationsDocument.PpiDeclarations
1211 public PpiDeclarationsDocument
.PpiDeclarations
getSpdPpiDeclarations() {
1212 if (spdPpiDeclarations
== null) {
1213 spdPpiDeclarations
= psaRoot
.getPpiDeclarations();
1215 return spdPpiDeclarations
;
1219 Get ProtocolDeclarations element
1221 @return ProtocolDeclarationsDocument.ProtocolDeclarations
1223 public ProtocolDeclarationsDocument
.ProtocolDeclarations
getSpdProtocolDeclarations() {
1224 if (spdProtocolDeclarations
== null) {
1225 spdProtocolDeclarations
= psaRoot
.getProtocolDeclarations();
1227 return spdProtocolDeclarations
;
1231 Get GuidDeclarations element
1233 @return GuidDeclarationsDocument.GuidDeclarations
1235 public GuidDeclarationsDocument
.GuidDeclarations
getSpdGuidDeclarations() {
1236 if (spdGuidDeclarations
== null) {
1237 spdGuidDeclarations
= psaRoot
.getGuidDeclarations();
1239 return spdGuidDeclarations
;
1243 Get PcdDefinitions element
1245 @return PcdDefinitionsDocument.PcdDefinitions
1247 public PcdDeclarationsDocument
.PcdDeclarations
getSpdPcdDefinitions() {
1248 if (spdPcdDefinitions
== null) {
1249 spdPcdDefinitions
= psaRoot
.getPcdDeclarations();
1251 return spdPcdDefinitions
;
1255 Get PackageHeaders element
1257 @return PackageHeadersDocument.PackageHeaders
1259 public PackageHeadersDocument
.PackageHeaders
getSpdModHdrs() {
1260 if (spdModHdrs
== null) {
1261 spdModHdrs
= psaRoot
.getPackageHeaders();
1267 Get MsaFiles element
1269 @return MsaFilesDocument.MsaFiles
1271 public MsaFilesDocument
.MsaFiles
getSpdMsaFiles() {
1272 if (spdMsaFiles
== null) {
1273 spdMsaFiles
= psaRoot
.getMsaFiles();
1279 Get LibraryClassDeclarations element
1281 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
1283 public LibraryClassDeclarationsDocument
.LibraryClassDeclarations
getSpdLibClassDeclarations() {
1284 if (spdLibClassDeclarations
== null) {
1285 spdLibClassDeclarations
= psaRoot
.getLibraryClassDeclarations();
1287 return spdLibClassDeclarations
;
1290 public PackageDefinitionsDocument
.PackageDefinitions
getSpdPkgDefs() {
1291 if (spdPkgDefs
== null) {
1292 spdPkgDefs
= psaRoot
.addNewPackageDefinitions();
1297 Get SpdHeader element
1299 @return SpdHeaderDocument.SpdHeader
1301 public SpdHeaderDocument
.SpdHeader
getSpdHdr() {
1302 if (spdHdr
== null) {
1303 spdHdr
= psaRoot
.addNewSpdHeader();
1309 Set value to Guid element
1311 @param guid The value set to Guid element
1313 public void setSpdHdrGuidValue(String guid
) {
1314 getSpdHdr().setGuidValue(guid
);
1318 Get Version element under SpdHdr
1322 public String
getSpdHdrVer() {
1323 return getSpdHdr().getVersion();
1327 Set value to Version element
1329 @param ver The value set to Version element
1331 public void setSpdHdrVer(String ver
) {
1332 getSpdHdr().setVersion(ver
);
1335 public String
getSpdHdrAbs(){
1336 return getSpdHdr().getAbstract();
1341 Set value to Abstract element
1343 @param abs The value set to Abstract element
1345 public void setSpdHdrAbs(String abs
) {
1347 getSpdHdr().setAbstract(abs
);
1350 public String
getSpdHdrDescription(){
1351 return getSpdHdr().getDescription();
1354 Set value to Description element
1356 @param des The value set to Description element
1358 public void setSpdHdrDescription(String des
) {
1359 getSpdHdr().setDescription(des
);
1362 public String
getSpdHdrCopyright(){
1363 return getSpdHdr().getCopyright();
1366 Set value to Copyright element
1368 @param cpRit The value set to Copyright element
1370 public void setSpdHdrCopyright(String cpRit
) {
1372 getSpdHdr().setCopyright(cpRit
);
1376 Get License element under SpdHdr
1380 public String
getSpdHdrLicense() {
1381 if (getSpdHdr().getLicense() != null) {
1382 return getSpdHdr().getLicense().getStringValue();
1388 Set value to License element
1390 @param license The value set to License element
1392 public void setSpdHdrLicense(String license
) {
1393 if (getSpdHdr().getLicense() == null){
1394 getSpdHdr().addNewLicense().setStringValue(license
);
1397 getSpdHdr().getLicense().setStringValue(license
);
1401 public String
getSpdHdrUrl(){
1402 if (getSpdHdr().getLicense() != null) {
1403 return getSpdHdr().getLicense().getURL();
1408 public void setSpdHdrUrl(String url
){
1409 getSpdHdr().getLicense().setURL(url
);
1413 Get PackageName element under SpdHdr
1417 public String
getSpdHdrPkgName() {
1419 return getSpdHdr().getPackageName();
1423 Set value to PackageName element
1425 @param pkgName The value set to PackageName element
1427 public void setSpdHdrPkgName(String pkgName
) {
1428 getSpdHdr().setPackageName(pkgName
);
1431 public String
getSpdHdrGuidValue(){
1432 return getSpdHdr().getGuidValue();
1438 @return SpecificationDocument.Specification
1440 public String
getSpdHdrSpec() {
1441 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1442 // return getSpdHdr().getSpecification();
1450 public void setSpdHdrSpec(String spec
) {
1451 spec
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1452 getSpdHdr().setSpecification(spec
);
1456 public String
getSpdPkgDefsRdOnly(){
1457 return getSpdPkgDefs().getReadOnly() + "";
1460 Set value to ReadOnly element
1462 @param rdOnly The value set to ReadOnly element
1464 public void setSpdPkgDefsRdOnly(String rdOnly
) {
1466 getSpdPkgDefs().setReadOnly(new Boolean(rdOnly
));
1469 public String
getSpdPkgDefsRePkg(){
1470 return getSpdPkgDefs().getRePackage() + "";
1473 Set value to RePackage element
1475 @param rePkg The value set to RePackage element
1477 public void setSpdPkgDefsRePkg(String rePkg
) {
1479 getSpdPkgDefs().setRePackage(new Boolean(rePkg
));
1483 Set value to URL element
1485 @param url The value set to URL element
1487 // public void setSpdHdrURL(String url) {
1488 // getSpdHdr().setURL(url);
1496 public File
getFile() {
1503 @param file File with xml format
1505 public void setFile(File file
) {
1509 private List
<String
> stringToList(String s
){
1513 ArrayList
<String
> al
= new ArrayList
<String
>();
1514 String
[] sArray
= s
.split(" ");
1515 for(int i
= 0; i
< sArray
.length
; ++i
){
1521 private String
listToString(List
<String
> l
) {
1526 ListIterator li
= l
.listIterator();
1527 while(li
.hasNext()) {