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
.packaging
;
16 import java
.io
.IOException
;
17 import java
.util
.List
;
18 import java
.util
.ListIterator
;
20 import org
.apache
.xmlbeans
.XmlObject
;
21 import org
.apache
.xmlbeans
.XmlOptions
;
22 import org
.apache
.xmlbeans
.XmlCursor
;
24 import org
.tianocore
.AbstractDocument
;
25 import org
.tianocore
.GuidDeclarationsDocument
;
26 import org
.tianocore
.GuidDocument
;
27 import org
.tianocore
.IncludeHeaderDocument
;
28 import org
.tianocore
.LibraryClassDeclarationDocument
;
29 import org
.tianocore
.LibraryClassDeclarationsDocument
;
30 import org
.tianocore
.LibraryClassDocument
;
31 import org
.tianocore
.LibraryUsage
;
32 import org
.tianocore
.LicenseDocument
;
33 import org
.tianocore
.ModuleTypeDef
;
34 import org
.tianocore
.MsaFilesDocument
;
35 import org
.tianocore
.OutputDirectoryDocument
;
36 import org
.tianocore
.PackageDependenciesDocument
;
37 import org
.tianocore
.PackageHeadersDocument
;
38 import org
.tianocore
.PackageNameDocument
;
39 import org
.tianocore
.PackageSurfaceAreaDocument
;
40 import org
.tianocore
.PackageType
;
41 import org
.tianocore
.PackageUsage
;
42 import org
.tianocore
.PcdDataTypes
;
43 import org
.tianocore
.PcdDefinitionsDocument
;
44 import org
.tianocore
.PcdItemTypes
;
45 import org
.tianocore
.PpiDeclarationsDocument
;
46 import org
.tianocore
.ProtocolDeclarationsDocument
;
47 import org
.tianocore
.SpdHeaderDocument
;
48 import org
.tianocore
.SpecificationDocument
;
49 import org
.tianocore
.GuidDeclarationsDocument
.GuidDeclarations
;
52 This class processes spd file contents such as add remove xml elements.
54 @since PackageEditor 1.0
56 public class SpdFileContents
{
58 private File file
= null;
60 private PackageSurfaceAreaDocument psad
= null;
62 private PackageSurfaceAreaDocument
.PackageSurfaceArea psaRoot
= null;
64 private SpdHeaderDocument
.SpdHeader spdHdr
= null;
66 private PackageNameDocument
.PackageName spdHdrPkgName
= null;
68 private GuidDocument
.Guid spdHdrGuid
= null;
70 private AbstractDocument
.Abstract spdHdrAbs
= null;
72 private LicenseDocument
.License spdHdrLicense
= null;
74 private SpecificationDocument
.Specification spdHdrSpec
= null;
76 private OutputDirectoryDocument
.OutputDirectory spdHdrOutDir
= null;
78 private LibraryClassDeclarationsDocument
.LibraryClassDeclarations spdLibClassDeclarations
= null;
80 private PackageDependenciesDocument
.PackageDependencies spdPkgDeps
= null;
82 private MsaFilesDocument
.MsaFiles spdMsaFiles
= null;
84 private PackageHeadersDocument
.PackageHeaders spdModHdrs
= null;
86 private GuidDeclarationsDocument
.GuidDeclarations spdGuidDeclarations
= null;
88 private ProtocolDeclarationsDocument
.ProtocolDeclarations spdProtocolDeclarations
= null;
90 private PpiDeclarationsDocument
.PpiDeclarations spdPpiDeclarations
= null;
92 private PcdDefinitionsDocument
.PcdDefinitions spdPcdDefinitions
= null;
95 Constructor to create a new spd file
97 public SpdFileContents() {
99 psad
= PackageSurfaceAreaDocument
.Factory
.newInstance();
100 psaRoot
= psad
.addNewPackageSurfaceArea();
105 Constructor based on an existing spd file
107 @param f Existing spd file
109 public SpdFileContents(File f
) {
111 psad
= PackageSurfaceAreaDocument
.Factory
.parse(f
);
112 psaRoot
= psad
.getPackageSurfaceArea();
114 } catch (Exception e
) {
115 System
.out
.println(e
.toString());
120 Remove existing pcd definitions elements using XmlCursor
122 public void removeSpdPcdDefinition() {
123 XmlObject o
= psaRoot
.getPcdDefinitions();
126 XmlCursor cursor
= o
.newCursor();
131 Remove existing ppi declarations using XmlCursor
133 public void removeSpdPpiDeclaration() {
134 XmlObject o
= psaRoot
.getPpiDeclarations();
137 XmlCursor cursor
= o
.newCursor();
142 Remove existing protocols declarations using XmlCursor
144 public void removeSpdProtocolDeclaration() {
145 XmlObject o
= psaRoot
.getProtocolDeclarations();
148 XmlCursor cursor
= o
.newCursor();
153 Remove existing GUID declarations using XmlCursor
155 public void removeSpdGuidDeclaration() {
156 XmlObject o
= psaRoot
.getGuidDeclarations();
159 XmlCursor cursor
= o
.newCursor();
164 Remove existing spd package header using XmlCursor
166 public void removeSpdPkgHeader() {
167 XmlObject o
= psaRoot
.getPackageHeaders();
170 XmlCursor cursor
= o
.newCursor();
175 Remove existing msa files using XmlCursor
177 public void removeSpdMsaFile() {
178 XmlObject o
= psaRoot
.getMsaFiles();
181 XmlCursor cursor
= o
.newCursor();
186 Remove existing library class declarations using XmlCursor
188 public void removeSpdLibClass() {
189 XmlObject o
= psaRoot
.getLibraryClassDeclarations();
192 XmlCursor cursor
= o
.newCursor();
198 Get spd file header contents into String array
200 @param s Caller allocated String array
202 public void getSpdHdrDetails(String
[] s
) {
203 if (getSpdHdr() == null) {
204 spdHdr
= psaRoot
.addNewSpdHeader();
206 s
[0] = getSpdHdrPkgName().getStringValue();
207 s
[1] = getSpdHdrGuid().getStringValue();
208 s
[2] = getSpdHdrVer();
209 s
[3] = getSpdHdrAbs().getStringValue();
210 s
[4] = getSpdHdr().getDescription();
211 s
[5] = getSpdHdr().getCopyright();
212 s
[6] = getSpdHdrLicense().getStringValue();
213 s
[7] = getSpdHdr().getCreated();
214 s
[8] = getSpdHdr().getURL();
215 if (getSpdHdr().getPackageType() != null) {
216 s
[9] = getSpdHdr().getPackageType().toString();
219 // convert boolean to String by adding empty String ""
221 s
[10] = getSpdHdr().getReadOnly() + "";
222 s
[11] = getSpdHdr().getReadOnly() + "";
226 Get the number of library class declarations from the size of List
230 public int getSpdLibClassDeclarationCount() {
231 if (psaRoot
.getLibraryClassDeclarations() == null
232 || psaRoot
.getLibraryClassDeclarations().getLibraryClassDeclarationList() == null) {
235 return psaRoot
.getLibraryClassDeclarations().getLibraryClassDeclarationList().size();
239 Get available library class declaration into String array
240 @param libClass Caller allocated two-dimentional String array
242 public void getSpdLibClassDeclarations(String
[][] libClass
) {
243 List
<LibraryClassDeclarationDocument
.LibraryClassDeclaration
> l
= psaRoot
.getLibraryClassDeclarations()
244 .getLibraryClassDeclarationList();
246 ListIterator li
= l
.listIterator();
247 while (li
.hasNext()) {
248 LibraryClassDeclarationDocument
.LibraryClassDeclaration lcd
= (LibraryClassDeclarationDocument
.LibraryClassDeclaration
) li
250 if (lcd
.getLibraryClass() != null) {
251 libClass
[i
][0] = lcd
.getLibraryClass().getStringValue();
253 if (lcd
.getIncludeHeader() != null) {
254 libClass
[i
][1] = lcd
.getIncludeHeader().getStringValue();
263 Get the number of Msa files from the size of List
267 public int getSpdMsaFileCount() {
268 if (psaRoot
.getMsaFiles() == null || psaRoot
.getMsaFiles().getMsaFileList() == null) {
271 return psaRoot
.getMsaFiles().getMsaFileList().size();
275 Get available Msa file into String array
277 @param msaFile Caller allocated two-dimentional String array
279 public void getSpdMsaFiles(String
[][] msaFile
) {
280 List
<MsaFilesDocument
.MsaFiles
.MsaFile
> l
= psaRoot
.getMsaFiles().getMsaFileList();
282 ListIterator li
= l
.listIterator();
283 while (li
.hasNext()) {
284 MsaFilesDocument
.MsaFiles
.MsaFile m
= (MsaFilesDocument
.MsaFiles
.MsaFile
) li
.next();
285 if (m
.getFilename() != null) {
286 msaFile
[i
][0] = m
.getFilename().getStringValue();
294 Get the number of include header files in PackageHeaders from the size of List
298 public int getSpdPackageHeaderCount() {
299 if (psaRoot
.getPackageHeaders() == null || psaRoot
.getPackageHeaders().getIncludeHeaderList() == null) {
302 return psaRoot
.getPackageHeaders().getIncludeHeaderList().size();
306 Get available package header contents into String array
308 @param pkgHeader Caller allocated two-dimentional String array
310 public void getSpdPackageHeaders(String
[][] pkgHeader
) {
311 List
<IncludeHeaderDocument
.IncludeHeader
> l
= psaRoot
.getPackageHeaders().getIncludeHeaderList();
313 ListIterator li
= l
.listIterator();
314 while (li
.hasNext()) {
315 IncludeHeaderDocument
.IncludeHeader ih
= (IncludeHeaderDocument
.IncludeHeader
) li
.next();
316 if (ih
.getModuleType() != null) {
317 pkgHeader
[i
][0] = ih
.getModuleType().toString();
320 pkgHeader
[i
][1] = ih
.getStringValue();
326 Get the number of GUID declarations from the size of List
330 public int getSpdGuidDeclarationCount() {
331 if (psaRoot
.getGuidDeclarations() == null || psaRoot
.getGuidDeclarations().getEntryList() == null) {
334 return psaRoot
.getGuidDeclarations().getEntryList().size();
338 Get available Guid declaration contents into String array
340 @param guid Caller allocated two-dimentional String array
342 public void getSpdGuidDeclarations(String
[][] guid
) {
343 List
<GuidDeclarationsDocument
.GuidDeclarations
.Entry
> l
= psaRoot
.getGuidDeclarations().getEntryList();
345 ListIterator li
= l
.listIterator();
346 while (li
.hasNext()) {
347 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) li
349 guid
[i
][0] = e
.getName();
350 guid
[i
][1] = e
.getCName();
351 if (e
.getGuid() != null) {
352 guid
[i
][2] = e
.getGuid().getStringValue();
359 Get the number of protocol declarations from the size of List
363 public int getSpdProtocolDeclarationCount() {
364 if (psaRoot
.getProtocolDeclarations() == null || psaRoot
.getProtocolDeclarations().getEntryList() == null) {
367 return psaRoot
.getProtocolDeclarations().getEntryList().size();
371 Get available protocol declaration contents into String array
373 @param protocol Caller allocated two-dimentional String array
375 public void getSpdProtocolDeclarations(String
[][] protocol
) {
376 List
<ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
> l
= psaRoot
.getProtocolDeclarations()
379 ListIterator li
= l
.listIterator();
380 while (li
.hasNext()) {
381 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry e
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) li
383 protocol
[i
][0] = e
.getName();
384 protocol
[i
][1] = e
.getCName();
385 if (e
.getGuid() != null) {
386 protocol
[i
][2] = e
.getGuid().getStringValue();
393 Get the number of Ppi declarations from the size of List
397 public int getSpdPpiDeclarationCount() {
398 if (psaRoot
.getPpiDeclarations() == null || psaRoot
.getPpiDeclarations().getEntryList() == null) {
401 return psaRoot
.getPpiDeclarations().getEntryList().size();
405 Get available Ppi declaration contents into String array
407 @param ppi Caller allocated two-dimentional String array
409 public void getSpdPpiDeclarations(String
[][] ppi
) {
410 List
<PpiDeclarationsDocument
.PpiDeclarations
.Entry
> l
= psaRoot
.getPpiDeclarations().getEntryList();
412 ListIterator li
= l
.listIterator();
413 while (li
.hasNext()) {
414 PpiDeclarationsDocument
.PpiDeclarations
.Entry e
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) li
.next();
415 ppi
[i
][0] = e
.getName();
416 ppi
[i
][1] = e
.getCName();
417 if (e
.getGuid() != null) {
418 ppi
[i
][2] = e
.getGuid().getStringValue();
426 Get the number of Pcd definitions from the size of List
430 public int getSpdPcdDefinitionCount() {
431 if (psaRoot
.getPcdDefinitions() == null || psaRoot
.getPcdDefinitions().getPcdEntryList() == null) {
434 return psaRoot
.getPcdDefinitions().getPcdEntryList().size();
438 Get available Pcd definition contents into String array
440 @param pcd Caller allocated two-dimentional String array
442 public void getSpdPcdDefinitions(String
[][] pcd
) {
443 List
<PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry
> l
= psaRoot
.getPcdDefinitions().getPcdEntryList();
445 ListIterator li
= l
.listIterator();
446 while (li
.hasNext()) {
447 PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry e
= (PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry
) li
449 if (e
.getItemType() != null) {
450 pcd
[i
][0] = e
.getItemType().toString();
453 pcd
[i
][1] = e
.getCName();
454 pcd
[i
][2] = e
.getToken();
455 if (e
.getDatumType() != null) {
456 pcd
[i
][3] = e
.getDatumType().toString();
459 if (e
.getDefaultValue() != null) {
460 pcd
[i
][4] = e
.getDefaultValue().toString();
468 Save the processed xml contents to file
470 @param spdFile The file to save xml contents
471 @throws IOException Exceptions during file operation
473 public void saveAs(File spdFile
) throws IOException
{
475 XmlOptions options
= new XmlOptions();
477 options
.setCharacterEncoding("UTF-8");
478 options
.setSavePrettyPrint();
479 options
.setSavePrettyPrintIndent(2);
481 psad
.save(spdFile
, options
);
482 } catch (IOException e
) {
489 Generate SpdHeader contents using parameters passed in.
491 @param pkgName PackageName
493 @param pkgVer Version
494 @param pkgAbs Abstract
495 @param pkgDes Description
496 @param pkgCpRight Copyright
497 @param pkgLicense License
498 @param pkgCreateDate Created
499 @param pkgUpdateDate Updated
501 @param pkgType PackageType
502 @param pkgRdOnly ReadOnly
503 @param pkgRePkg RePackage
504 @param pkgSpec Reserved
505 @param pkgOutDir Reserved
507 public void genSpdHeader(String pkgName
, String pkgGuid
, String pkgVer
, String pkgAbs
, String pkgDes
,
508 String pkgCpRight
, String pkgLicense
, String pkgCreateDate
, String pkgUpdateDate
,
509 String pkgURL
, String pkgType
, String pkgRdOnly
, String pkgRePkg
, String pkgSpec
,
511 if (getSpdHdr() == null) {
512 spdHdr
= psaRoot
.addNewSpdHeader();
515 setSpdHdrPkgName(pkgName
);
516 setSpdHdrGuid(pkgGuid
);
517 setSpdHdrVer(pkgVer
);
518 setSpdHdrAbs(pkgAbs
);
519 setSpdHdrDes(pkgDes
);
520 setSpdHdrCpRit(pkgCpRight
);
521 setSpdHdrLicense(pkgLicense
);
522 setSpdHdrCreateDate(pkgCreateDate
);
523 setSpdHdrUpdateDate(pkgUpdateDate
);
524 setSpdHdrURL(pkgURL
);
525 setSpdHdrPkgType(pkgType
);
526 setSpdHdrRdOnly(pkgRdOnly
);
527 setSpdHdrRePkg(pkgRePkg
);
528 setSpdHdrSpec(pkgSpec
);
529 setSpdHdrOutDir(pkgOutDir
);
533 Generate library class declaration element using parameters passed in
535 @param libClassBaseName LibraryClass element value
536 @param libClassUsage Reserved
537 @param incHdrFileName IncludeHeader element value
538 @param incHdrAttribGuid Reserved
539 @param incHdrAttribArch Reserved
540 @param incHdrAttribPath Reserved
541 @param incHdrAttribClass Reserved
542 @param incHdrAttribVer Reserved
543 @param incHdrAttribOverrideID Reserved
544 @param incHdrAttribModuleType Reserved
546 public void genSpdLibClassDeclarations(String libClassBaseName
, String libClassUsage
, String incHdrFileName
,
547 String incHdrAttribGuid
, String incHdrAttribArch
, String incHdrAttribPath
,
548 String incHdrAttribClass
, String incHdrAttribVer
,
549 String incHdrAttribOverrideID
, String incHdrAttribModuleType
) {
550 if (getSpdLibClassDeclarations() == null) {
551 spdLibClassDeclarations
= psaRoot
.addNewLibraryClassDeclarations();
554 // add contents under LibraryClassDeclarations tag
556 setSpdLibClassDeclaration(libClassBaseName
, libClassUsage
, incHdrFileName
, incHdrAttribGuid
, incHdrAttribArch
,
557 incHdrAttribPath
, incHdrAttribClass
, incHdrAttribVer
, incHdrAttribOverrideID
,
558 incHdrAttribModuleType
, spdLibClassDeclarations
);
562 Set library class declaration contents under parent tag
564 @param clsName LibraryClass element value
565 @param clsUsage Reserved
566 @param hdrFile IncludeHeader element value
567 @param hdrAttribGuid Reserved
568 @param hdrAttribArch Reserved
569 @param hdrAttribPath Reserved
570 @param hdrAttribClass Reserved
571 @param hdrAttribVer Reserved
572 @param hdrAttribOverID Reserved
573 @param hdrAttribModType Reserved
574 @param parent The tag under which library class declaration goes to
576 public void setSpdLibClassDeclaration(String clsName
, String clsUsage
, String hdrFile
, String hdrAttribGuid
,
577 String hdrAttribArch
, String hdrAttribPath
, String hdrAttribClass
,
578 String hdrAttribVer
, String hdrAttribOverID
, String hdrAttribModType
,
581 LibraryClassDeclarationDocument
.LibraryClassDeclaration lcd
= ((LibraryClassDeclarationsDocument
.LibraryClassDeclarations
) parent
)
582 .addNewLibraryClassDeclaration();
584 setSpdLibraryClass(clsName
, clsUsage
, lcd
);
586 setSpdIncludeHeader(null, hdrFile
, hdrAttribGuid
, hdrAttribArch
, hdrAttribPath
, hdrAttribClass
, hdrAttribVer
,
587 hdrAttribOverID
, lcd
);
591 Set the contents of LibraryClass under parent element
593 @param clsName LibraryClass element value
594 @param clsUsage Reserved
595 @param parent The tag under which library class declaration goes to
597 public void setSpdLibraryClass(String clsName
, String clsUsage
, XmlObject parent
) {
598 LibraryClassDocument
.LibraryClass lc
= ((LibraryClassDeclarationDocument
.LibraryClassDeclaration
) parent
)
599 .addNewLibraryClass();
600 lc
.setStringValue(clsName
);
604 Set contents of IncludeHeader under parent element
606 @param modType Reserved
607 @param hdrFile IncludeHeader element value
608 @param hdrAttribGuid Reserved
609 @param hdrAttribArch Reserved
610 @param hdrAttribPath Reserved
611 @param hdrAttribClass Reserved
612 @param hdrAttribVer Reserved
613 @param hdrAttribOverID Reserved
614 @param parent The tag under which library class declaration goes to
616 public void setSpdIncludeHeader(String modType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
617 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
618 String hdrAttribOverID
, XmlObject parent
) {
619 IncludeHeaderDocument
.IncludeHeader ih
= null;
620 if (parent
instanceof LibraryClassDeclarationDocument
.LibraryClassDeclaration
) {
621 ih
= ((LibraryClassDeclarationDocument
.LibraryClassDeclaration
) parent
).addNewIncludeHeader();
622 } else if (parent
instanceof PackageHeadersDocument
.PackageHeaders
) {
623 ih
= ((PackageHeadersDocument
.PackageHeaders
) parent
).addNewIncludeHeader();
628 ih
.setStringValue(hdrFile
);
629 if (hdrAttribGuid
!= null) {
630 ih
.setGuid(hdrAttribGuid
);
632 if (hdrAttribPath
!= null) {
633 ih
.setPath(hdrAttribPath
);
635 if (hdrAttribClass
!= null) {
636 ih
.setClass1(hdrAttribClass
);
638 if (hdrAttribVer
!= null) {
639 ih
.setVersion(hdrAttribVer
);
641 if (hdrAttribOverID
!= null) {
642 ih
.setOverrideID(Integer
.parseInt(hdrAttribOverID
));
644 if (modType
!= null) {
645 ih
.setModuleType(ModuleTypeDef
.Enum
.forString(modType
));
655 @param pkgDepPkgAttribGuid
656 @param pkgDepPkgAttribVer
657 @param pkgDepPkgAttribType
658 @param pkgDepPkgAttribUsage
659 @param pkgDepPkgAttribInstallDate
660 @param pkgDepPkgAttribUpdateDate
661 @param pkgDepPkgAttribPath
663 public void genSpdPackageDependencies(String pkgDepPkgName
, String pkgDepPkgAttribGuid
, String pkgDepPkgAttribVer
,
664 String pkgDepPkgAttribType
, String pkgDepPkgAttribUsage
,
665 String pkgDepPkgAttribInstallDate
, String pkgDepPkgAttribUpdateDate
,
666 String pkgDepPkgAttribPath
) {
667 if (spdPkgDeps
== null) {
668 spdPkgDeps
= psaRoot
.addNewPackageDependencies();
671 setSpdPackageName(pkgDepPkgName
, pkgDepPkgAttribGuid
, pkgDepPkgAttribVer
, pkgDepPkgAttribType
,
672 pkgDepPkgAttribUsage
, pkgDepPkgAttribInstallDate
, pkgDepPkgAttribUpdateDate
,
673 pkgDepPkgAttribPath
, spdPkgDeps
);
683 @param pkgAttribUsage
684 @param pkgAttribInstallDate
685 @param pkgAttribUpdateDate
689 public void setSpdPackageName(String pkgName
, String pkgAttribGuid
, String pkgAttribVer
, String pkgAttribType
,
690 String pkgAttribUsage
, String pkgAttribInstallDate
, String pkgAttribUpdateDate
,
691 String pkgAttribPath
, XmlObject parent
) {
693 PackageNameDocument
.PackageName pn
= ((PackageDependenciesDocument
.PackageDependencies
) parent
)
694 .addNewPackageName();
695 pn
.setStringValue(pkgName
);
696 pn
.setPackageType(PackageType
.Enum
.forString(pkgAttribType
));
697 pn
.setUsage(PackageUsage
.Enum
.forString(pkgAttribUsage
));
698 pn
.setUpdatedDate(pkgAttribUpdateDate
);
702 Generate MsaFile element.
704 @param msaFileName MsaFile element value
705 @param archType Reserved
707 public void genSpdMsaFiles(String msaFileName
, String archType
) {
708 if (getSpdMsaFiles() == null) {
709 spdMsaFiles
= psaRoot
.addNewMsaFiles();
711 setSpdMsaFile(msaFileName
, spdMsaFiles
);
716 Set MsaFile contents under parent element.
718 @param msaFileName MsaFile element value
719 @param parent Element under which MsaFile goes to
721 public void setSpdMsaFile(String msaFileName
, XmlObject parent
) {
723 ((MsaFilesDocument
.MsaFiles
) parent
).addNewMsaFile().addNewFilename().setStringValue(msaFileName
);
727 Generate PackageHeader element using parameters passed in.
729 @param ModHdrModType ModuleType attribute of IncludeHeader element
730 @param hdrFile IncludeHeader element value
731 @param hdrAttribGuid Reserved
732 @param hdrAttribArch Reserved
733 @param hdrAttribPath Reserved
734 @param hdrAttribClass Reserved
735 @param hdrAttribVer Reserved
736 @param hdrAttribOverID Reserved
738 public void genSpdModuleHeaders(String ModHdrModType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
739 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
740 String hdrAttribOverID
) {
741 if (getSpdModHdrs() == null) {
742 spdModHdrs
= psaRoot
.addNewPackageHeaders();
746 // add IncludeHeader under PackageHeaders element
748 setSpdIncludeHeader(ModHdrModType
, hdrFile
, hdrAttribGuid
, hdrAttribArch
, hdrAttribPath
, hdrAttribClass
,
749 hdrAttribVer
, hdrAttribOverID
, spdModHdrs
);
753 Generate GUID declaration element using parameters passed in.
755 @param guidDeclEntryName Name attribute of Entry element
756 @param guidDeclCName CName element value
757 @param guidDeclGuid Guid element value
758 @param guidDeclFeatureFlag Reserved
760 public void genSpdGuidDeclarations(String guidDeclEntryName
, String guidDeclCName
, String guidDeclGuid
,
761 String guidDeclFeatureFlag
) {
762 if (getSpdGuidDeclarations() == null) {
763 spdGuidDeclarations
= psaRoot
.addNewGuidDeclarations();
766 setSpdEntry(guidDeclEntryName
, guidDeclCName
, guidDeclGuid
, guidDeclFeatureFlag
, spdGuidDeclarations
);
770 Generate protocol declaration element using parameters passed in.
772 @param protocolDeclEntryName Name attribute of Entry element
773 @param protocolDeclCName CName element value
774 @param protocolDeclGuid Guid element value
775 @param protocolDeclFeatureFlag Reserved
777 public void genSpdProtocolDeclarations(String protocolDeclEntryName
, String protocolDeclCName
,
778 String protocolDeclGuid
, String protocolDeclFeatureFlag
) {
779 if (getSpdProtocolDeclarations() == null) {
780 spdProtocolDeclarations
= psaRoot
.addNewProtocolDeclarations();
783 setSpdEntry(protocolDeclEntryName
, protocolDeclCName
, protocolDeclGuid
, protocolDeclFeatureFlag
,
784 spdProtocolDeclarations
);
788 Generate PPI declaration element using parameters passed in.
790 @param ppiDeclEntryName Name attribute of Entry element
791 @param ppiDeclCName CName element value
792 @param ppiDeclGuid Guid element value
793 @param ppiDeclFeatureFlag Reserved
795 public void genSpdPpiDeclarations(String ppiDeclEntryName
, String ppiDeclCName
, String ppiDeclGuid
,
796 String ppiDeclFeatureFlag
) {
797 if (getSpdPpiDeclarations() == null) {
798 spdPpiDeclarations
= psaRoot
.addNewPpiDeclarations();
801 setSpdEntry(ppiDeclEntryName
, ppiDeclCName
, ppiDeclGuid
, ppiDeclFeatureFlag
, spdPpiDeclarations
);
805 Set Entry contents using parameters passed in
807 @param entryName Name attribute of Entry element
808 @param cName CName element value
809 @param guid Guid element value
810 @param featureFlag Reserved
811 @param parent The tag under which Entry element goes to
813 public void setSpdEntry(String entryName
, String cName
, String guid
, String featureFlag
, XmlObject parent
) {
815 if (parent
instanceof GuidDeclarationsDocument
.GuidDeclarations
) {
816 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= ((GuidDeclarations
) parent
).addNewEntry();
817 e
.setName(entryName
);
819 e
.addNewGuid().setStringValue(guid
);
820 if (featureFlag
!= null) {
821 e
.addNewFeatureFlag().setStringValue(featureFlag
);
825 if (parent
instanceof ProtocolDeclarationsDocument
.ProtocolDeclarations
) {
826 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry pe
= ((ProtocolDeclarationsDocument
.ProtocolDeclarations
) parent
)
828 pe
.setName(entryName
);
830 pe
.addNewGuid().setStringValue(guid
);
831 if (featureFlag
!= null) {
832 pe
.addNewFeatureFlag().setStringValue(featureFlag
);
836 if (parent
instanceof PpiDeclarationsDocument
.PpiDeclarations
) {
837 PpiDeclarationsDocument
.PpiDeclarations
.Entry ppe
= ((PpiDeclarationsDocument
.PpiDeclarations
) parent
)
839 ppe
.setName(entryName
);
841 ppe
.addNewGuid().setStringValue(guid
);
842 if (featureFlag
!= null) {
843 ppe
.addNewFeatureFlag().setStringValue(featureFlag
);
853 Generate Pcd definition using parameters passed in
855 @param pcdItemTypes ItemType attribute of PcdEntry element
856 @param cName C_Name element value
857 @param token Token element value
858 @param dataType DatumType element value
859 @param skuEnable Reserved
861 @param maxSku Reserved
862 @param hiiEnable Reserved
863 @param varGuid Reserved
864 @param varName Reserved
865 @param defaultString DefaultString element value
867 public void genSpdPcdDefinitions(String pcdItemTypes
, String cName
, String token
, String dataType
,
868 String skuEnable
, String sku
, String maxSku
, String hiiEnable
, String varGuid
,
869 String varName
, String defaultString
) {
870 if (getSpdPcdDefinitions() == null) {
871 spdPcdDefinitions
= psaRoot
.addNewPcdDefinitions();
874 setSpdPcdEntry(pcdItemTypes
, cName
, token
, dataType
, skuEnable
, sku
, maxSku
, hiiEnable
, varGuid
, varName
,
875 defaultString
, spdPcdDefinitions
);
879 Set Pcd entry contents under parent tag
881 @param pcdItemTypes ItemType attribute of PcdEntry element
882 @param cName C_Name element value
883 @param token Token element value
884 @param dataType DatumType element value
885 @param skuEnable Reserved
887 @param maxSku Reserved
888 @param hiiEnable Reserved
889 @param varGuid Reserved
890 @param varName Reserved
891 @param defaultString DefaultString element value
892 @param parent Tag under which PcdEntry goes to
894 public void setSpdPcdEntry(String pcdItemTypes
, String cName
, String token
, String dataType
, String skuEnable
,
895 String sku
, String maxSku
, String hiiEnable
, String varGuid
, String varName
,
896 String defaultString
, XmlObject parent
) {
898 PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry pe
= ((PcdDefinitionsDocument
.PcdDefinitions
) parent
)
900 pe
.setItemType(PcdItemTypes
.Enum
.forString(pcdItemTypes
));
903 pe
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
904 pe
.setDefaultValue(defaultString
);
909 Get PpiDeclarations element
911 @return PpiDeclarationsDocument.PpiDeclarations
913 public PpiDeclarationsDocument
.PpiDeclarations
getSpdPpiDeclarations() {
914 if (spdPpiDeclarations
== null) {
915 spdPpiDeclarations
= psaRoot
.getPpiDeclarations();
917 return spdPpiDeclarations
;
921 Get ProtocolDeclarations element
923 @return ProtocolDeclarationsDocument.ProtocolDeclarations
925 public ProtocolDeclarationsDocument
.ProtocolDeclarations
getSpdProtocolDeclarations() {
926 if (spdProtocolDeclarations
== null) {
927 spdProtocolDeclarations
= psaRoot
.getProtocolDeclarations();
929 return spdProtocolDeclarations
;
933 Get GuidDeclarations element
935 @return GuidDeclarationsDocument.GuidDeclarations
937 public GuidDeclarationsDocument
.GuidDeclarations
getSpdGuidDeclarations() {
938 if (spdGuidDeclarations
== null) {
939 spdGuidDeclarations
= psaRoot
.getGuidDeclarations();
941 return spdGuidDeclarations
;
945 Get PcdDefinitions element
947 @return PcdDefinitionsDocument.PcdDefinitions
949 public PcdDefinitionsDocument
.PcdDefinitions
getSpdPcdDefinitions() {
950 if (spdPcdDefinitions
== null) {
951 spdPcdDefinitions
= psaRoot
.getPcdDefinitions();
953 return spdPcdDefinitions
;
957 Get PackageHeaders element
959 @return PackageHeadersDocument.PackageHeaders
961 public PackageHeadersDocument
.PackageHeaders
getSpdModHdrs() {
962 if (spdModHdrs
== null) {
963 spdModHdrs
= psaRoot
.getPackageHeaders();
971 @return MsaFilesDocument.MsaFiles
973 public MsaFilesDocument
.MsaFiles
getSpdMsaFiles() {
974 if (spdMsaFiles
== null) {
975 spdMsaFiles
= psaRoot
.getMsaFiles();
981 Get LibraryClassDeclarations element
983 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
985 public LibraryClassDeclarationsDocument
.LibraryClassDeclarations
getSpdLibClassDeclarations() {
986 if (spdLibClassDeclarations
== null) {
987 spdLibClassDeclarations
= psaRoot
.getLibraryClassDeclarations();
989 return spdLibClassDeclarations
;
993 Get SpdHeader element
995 @return SpdHeaderDocument.SpdHeader
997 public SpdHeaderDocument
.SpdHeader
getSpdHdr() {
998 if (spdHdr
== null) {
999 spdHdr
= psaRoot
.getSpdHeader();
1005 Get Abstract element under tag SpdHeader
1007 @return AbstractDocument.Abstract
1009 public AbstractDocument
.Abstract
getSpdHdrAbs() {
1010 if (spdHdrAbs
== null) {
1011 spdHdrAbs
= getSpdHdr().getAbstract();
1017 Set value to Abstract element
1019 @param abs The value set to Abstract element
1021 public void setSpdHdrAbs(String abs
) {
1023 if (getSpdHdrAbs() != null) {
1024 getSpdHdrAbs().setStringValue(abs
);
1026 spdHdrAbs
= getSpdHdr().addNewAbstract();
1027 spdHdrAbs
.setStringValue(abs
);
1032 Set value to Copyright element
1034 @param cpRit The value set to Copyright element
1036 public void setSpdHdrCpRit(String cpRit
) {
1038 getSpdHdr().setCopyright(cpRit
);
1043 Set value to Created element
1045 @param createDate The value set to Created element
1047 public void setSpdHdrCreateDate(String createDate
) {
1049 getSpdHdr().setCreated(createDate
);
1054 Set value to Description element
1056 @param des The value set to Description element
1058 public void setSpdHdrDes(String des
) {
1059 getSpdHdr().setDescription(des
);
1063 Get Guid element under SpdHdr
1065 @return GuidDocument.Guid
1067 public GuidDocument
.Guid
getSpdHdrGuid() {
1068 if (spdHdrGuid
== null) {
1069 spdHdrGuid
= getSpdHdr().getGuid();
1075 Set value to Guid element
1077 @param guid The value set to Guid element
1079 public void setSpdHdrGuid(String guid
) {
1080 if (getSpdHdrGuid() != null) {
1081 getSpdHdrGuid().setStringValue(guid
);
1083 spdHdrGuid
= getSpdHdr().addNewGuid();
1084 spdHdrGuid
.setStringValue(guid
);
1089 Get Version element under SpdHdr
1093 public String
getSpdHdrVer() {
1095 return spdHdr
.getVersion();
1101 Set value to Version element
1103 @param ver The value set to Version element
1105 public void setSpdHdrVer(String ver
) {
1106 if (spdHdr
!= null) {
1107 spdHdr
.setVersion(ver
);
1113 Get License element under SpdHdr
1115 @return LicenseDocument.License
1117 public LicenseDocument
.License
getSpdHdrLicense() {
1118 if (spdHdrLicense
== null) {
1119 spdHdrLicense
= getSpdHdr().getLicense();
1121 return spdHdrLicense
;
1125 Set value to License element
1127 @param license The value set to License element
1129 public void setSpdHdrLicense(String license
) {
1130 if (getSpdHdrLicense() != null) {
1131 getSpdHdrLicense().setStringValue(license
);
1133 spdHdrLicense
= getSpdHdr().addNewLicense();
1134 spdHdrLicense
.setStringValue(license
);
1143 public OutputDirectoryDocument
.OutputDirectory
getSpdHdrOutDir() {
1144 return spdHdrOutDir
;
1152 public void setSpdHdrOutDir(String outdir
) {
1153 if (outdir
== null) {
1156 if (getSpdHdrOutDir() != null) {
1157 getSpdHdrOutDir().setStringValue(outdir
);
1159 spdHdrOutDir
= getSpdHdr().addNewOutputDirectory();
1160 spdHdrOutDir
.setStringValue(outdir
);
1165 Get PackageName element under SpdHdr
1167 @return PackageNameDocument.PackageName
1169 public PackageNameDocument
.PackageName
getSpdHdrPkgName() {
1170 if (spdHdrPkgName
== null) {
1171 spdHdrPkgName
= getSpdHdr().getPackageName();
1173 return spdHdrPkgName
;
1177 Set value to PackageName element
1179 @param pkgName The value set to PackageName element
1181 public void setSpdHdrPkgName(String pkgName
) {
1183 if (getSpdHdrPkgName() != null) {
1184 getSpdHdrPkgName().setStringValue(pkgName
);
1186 spdHdrPkgName
= getSpdHdr().addNewPackageName();
1187 spdHdrPkgName
.setStringValue(pkgName
);
1194 @return SpecificationDocument.Specification
1196 public SpecificationDocument
.Specification
getSpdHdrSpec() {
1205 public void setSpdHdrSpec(String spec
) {
1209 if (getSpdHdrSpec() != null) {
1210 getSpdHdrSpec().setStringValue(spec
);
1212 spdHdrSpec
= getSpdHdr().addNewSpecification();
1213 spdHdrSpec
.setStringValue(spec
);
1218 Set value to PackageType element
1220 @param pkgType The value set to PackageType element
1222 public void setSpdHdrPkgType(String pkgType
) {
1223 getSpdHdr().setPackageType(PackageType
.Enum
.forString(pkgType
));
1227 Set value to ReadOnly element
1229 @param rdOnly The value set to ReadOnly element
1231 public void setSpdHdrRdOnly(String rdOnly
) {
1233 getSpdHdr().setReadOnly(new Boolean(rdOnly
));
1237 Set value to RePackage element
1239 @param rePkg The value set to RePackage element
1241 public void setSpdHdrRePkg(String rePkg
) {
1243 getSpdHdr().setRePackage(new Boolean(rePkg
));
1247 Set value to Updated element
1249 @param updateDate The value set to Updated element
1251 public void setSpdHdrUpdateDate(String updateDate
) {
1252 getSpdHdr().setUpdated(updateDate
);
1256 Set value to URL element
1258 @param url The value set to URL element
1260 public void setSpdHdrURL(String url
) {
1261 getSpdHdr().setURL(url
);
1269 public File
getFile() {
1276 @param file File with xml format
1278 public void setFile(File file
) {