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 String 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();
128 spdPcdDefinitions
= null;
132 Remove existing ppi declarations using XmlCursor
134 public void removeSpdPpiDeclaration() {
135 XmlObject o
= psaRoot
.getPpiDeclarations();
138 XmlCursor cursor
= o
.newCursor();
140 spdPpiDeclarations
= null;
144 Remove existing protocols declarations using XmlCursor
146 public void removeSpdProtocolDeclaration() {
147 XmlObject o
= psaRoot
.getProtocolDeclarations();
150 XmlCursor cursor
= o
.newCursor();
152 spdProtocolDeclarations
= null;
156 Remove existing GUID declarations using XmlCursor
158 public void removeSpdGuidDeclaration() {
159 XmlObject o
= psaRoot
.getGuidDeclarations();
162 XmlCursor cursor
= o
.newCursor();
164 spdGuidDeclarations
= null;
168 Remove existing spd package include files using XmlCursor
170 public void removeSpdPkgHeader() {
171 XmlObject o
= psaRoot
.getPackageHeaders();
174 XmlCursor cursor
= o
.newCursor();
180 Remove existing msa files using XmlCursor
182 public void removeSpdMsaFile() {
183 XmlObject o
= psaRoot
.getMsaFiles();
186 XmlCursor cursor
= o
.newCursor();
192 Remove existing library class declarations using XmlCursor
194 public void removeSpdLibClass() {
195 XmlObject o
= psaRoot
.getLibraryClassDeclarations();
198 XmlCursor cursor
= o
.newCursor();
200 spdLibClassDeclarations
= null;
204 Get spd file header contents into String array
206 @param s Caller allocated String array
208 public void getSpdHdrDetails(String
[] s
) {
209 if (getSpdHdr() == null) {
210 spdHdr
= psaRoot
.addNewSpdHeader();
212 s
[0] = getSpdHdrPkgName();
213 s
[1] = getSpdHdrGuid().getStringValue();
214 s
[2] = getSpdHdrVer();
215 s
[3] = getSpdHdrAbs().getStringValue();
216 s
[4] = getSpdHdr().getDescription();
217 s
[5] = getSpdHdr().getCopyright();
218 s
[6] = getSpdHdrLicense().getStringValue();
219 s
[7] = getSpdHdr().getCreated();
220 s
[8] = getSpdHdr().getURL();
221 if (getSpdHdr().getPackageType() != null) {
222 s
[9] = getSpdHdr().getPackageType().toString();
225 // convert boolean to String by adding empty String ""
227 s
[10] = getSpdHdr().getReadOnly() + "";
228 s
[11] = getSpdHdr().getReadOnly() + "";
232 Get the number of library class declarations from the size of List
236 public int getSpdLibClassDeclarationCount() {
237 if (psaRoot
.getLibraryClassDeclarations() == null
238 || psaRoot
.getLibraryClassDeclarations().getLibraryClassDeclarationList() == null) {
241 return psaRoot
.getLibraryClassDeclarations().getLibraryClassDeclarationList().size();
245 Get available library class declaration into String array
246 @param libClass Caller allocated two-dimentional String array
248 public void getSpdLibClassDeclarations(String
[][] libClass
) {
249 if (psaRoot
.getLibraryClassDeclarations() == null){
252 List
<LibraryClassDeclarationDocument
.LibraryClassDeclaration
> l
= psaRoot
.getLibraryClassDeclarations()
253 .getLibraryClassDeclarationList();
255 ListIterator li
= l
.listIterator();
256 while (li
.hasNext()) {
257 LibraryClassDeclarationDocument
.LibraryClassDeclaration lcd
= (LibraryClassDeclarationDocument
.LibraryClassDeclaration
) li
259 if (lcd
.getLibraryClass() != null) {
260 libClass
[i
][0] = lcd
.getLibraryClass().getStringValue();
262 if (lcd
.getIncludeHeader() != null) {
263 libClass
[i
][1] = lcd
.getIncludeHeader().getStringValue();
272 Get the number of Msa files from the size of List
276 public int getSpdMsaFileCount() {
277 if (psaRoot
.getMsaFiles() == null || psaRoot
.getMsaFiles().getMsaFileList() == null) {
280 return psaRoot
.getMsaFiles().getMsaFileList().size();
284 Get available Msa file into String array
286 @param msaFile Caller allocated two-dimentional String array
288 public void getSpdMsaFiles(String
[][] msaFile
) {
289 if (psaRoot
.getMsaFiles() == null) {
292 List
<MsaFilesDocument
.MsaFiles
.MsaFile
> l
= psaRoot
.getMsaFiles().getMsaFileList();
294 ListIterator li
= l
.listIterator();
295 while (li
.hasNext()) {
296 MsaFilesDocument
.MsaFiles
.MsaFile m
= (MsaFilesDocument
.MsaFiles
.MsaFile
) li
.next();
297 if (m
.getFilename() != null) {
298 msaFile
[i
][0] = m
.getFilename().getStringValue();
306 Get the number of include header files in PackageHeaders from the size of List
310 public int getSpdPackageHeaderCount() {
311 if (psaRoot
.getPackageHeaders() == null || psaRoot
.getPackageHeaders().getIncludeHeaderList() == null) {
314 return psaRoot
.getPackageHeaders().getIncludeHeaderList().size();
318 Get available package header contents into String array
320 @param pkgHeader Caller allocated two-dimentional String array
322 public void getSpdPackageHeaders(String
[][] pkgHeader
) {
323 if (psaRoot
.getPackageHeaders() == null) {
327 List
<IncludeHeaderDocument
.IncludeHeader
> l
= psaRoot
.getPackageHeaders().getIncludeHeaderList();
329 ListIterator li
= l
.listIterator();
330 while (li
.hasNext()) {
331 IncludeHeaderDocument
.IncludeHeader ih
= (IncludeHeaderDocument
.IncludeHeader
) li
.next();
332 if (ih
.getModuleType() != null) {
333 pkgHeader
[i
][0] = ih
.getModuleType().toString();
336 pkgHeader
[i
][1] = ih
.getStringValue();
342 Get the number of GUID declarations from the size of List
346 public int getSpdGuidDeclarationCount() {
347 if (psaRoot
.getGuidDeclarations() == null || psaRoot
.getGuidDeclarations().getEntryList() == null) {
350 return psaRoot
.getGuidDeclarations().getEntryList().size();
354 Get available Guid declaration contents into String array
356 @param guid Caller allocated two-dimentional String array
358 public void getSpdGuidDeclarations(String
[][] guid
) {
359 if (psaRoot
.getGuidDeclarations() == null) {
363 List
<GuidDeclarationsDocument
.GuidDeclarations
.Entry
> l
= psaRoot
.getGuidDeclarations().getEntryList();
365 ListIterator li
= l
.listIterator();
366 while (li
.hasNext()) {
367 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) li
369 guid
[i
][0] = e
.getName();
370 guid
[i
][1] = e
.getCName();
371 if (e
.getGuid() != null) {
372 guid
[i
][2] = e
.getGuid().getStringValue();
379 Get the number of protocol declarations from the size of List
383 public int getSpdProtocolDeclarationCount() {
384 if (psaRoot
.getProtocolDeclarations() == null || psaRoot
.getProtocolDeclarations().getEntryList() == null) {
387 return psaRoot
.getProtocolDeclarations().getEntryList().size();
391 Get available protocol declaration contents into String array
393 @param protocol Caller allocated two-dimentional String array
395 public void getSpdProtocolDeclarations(String
[][] protocol
) {
396 if (psaRoot
.getProtocolDeclarations() == null) {
400 List
<ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
> l
= psaRoot
.getProtocolDeclarations()
403 ListIterator li
= l
.listIterator();
404 while (li
.hasNext()) {
405 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry e
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) li
407 protocol
[i
][0] = e
.getName();
408 protocol
[i
][1] = e
.getCName();
409 if (e
.getGuid() != null) {
410 protocol
[i
][2] = e
.getGuid().getStringValue();
417 Get the number of Ppi declarations from the size of List
421 public int getSpdPpiDeclarationCount() {
422 if (psaRoot
.getPpiDeclarations() == null || psaRoot
.getPpiDeclarations().getEntryList() == null) {
425 return psaRoot
.getPpiDeclarations().getEntryList().size();
429 Get available Ppi declaration contents into String array
431 @param ppi Caller allocated two-dimentional String array
433 public void getSpdPpiDeclarations(String
[][] ppi
) {
434 if (psaRoot
.getPpiDeclarations() == null) {
438 List
<PpiDeclarationsDocument
.PpiDeclarations
.Entry
> l
= psaRoot
.getPpiDeclarations().getEntryList();
440 ListIterator li
= l
.listIterator();
441 while (li
.hasNext()) {
442 PpiDeclarationsDocument
.PpiDeclarations
.Entry e
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) li
.next();
443 ppi
[i
][0] = e
.getName();
444 ppi
[i
][1] = e
.getCName();
445 if (e
.getGuid() != null) {
446 ppi
[i
][2] = e
.getGuid().getStringValue();
454 Get the number of Pcd definitions from the size of List
458 public int getSpdPcdDefinitionCount() {
459 if (psaRoot
.getPcdDefinitions() == null || psaRoot
.getPcdDefinitions().getPcdEntryList() == null) {
462 return psaRoot
.getPcdDefinitions().getPcdEntryList().size();
466 Get available Pcd definition contents into String array
468 @param pcd Caller allocated two-dimentional String array
470 public void getSpdPcdDefinitions(String
[][] pcd
) {
471 if (psaRoot
.getPcdDefinitions() == null) {
475 List
<PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry
> l
= psaRoot
.getPcdDefinitions().getPcdEntryList();
477 ListIterator li
= l
.listIterator();
478 while (li
.hasNext()) {
479 PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry e
= (PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry
) li
481 if (e
.getItemType() != null) {
482 pcd
[i
][0] = e
.getItemType().toString();
485 pcd
[i
][1] = e
.getCName();
486 pcd
[i
][2] = e
.getToken();
487 if (e
.getDatumType() != null) {
488 pcd
[i
][3] = e
.getDatumType().toString();
491 if (e
.getDefaultValue() != null) {
492 pcd
[i
][4] = e
.getDefaultValue().toString();
500 Save the processed xml contents to file
502 @param spdFile The file to save xml contents
503 @throws IOException Exceptions during file operation
505 public void saveAs(File spdFile
) throws IOException
{
507 XmlOptions options
= new XmlOptions();
509 options
.setCharacterEncoding("UTF-8");
510 options
.setSavePrettyPrint();
511 options
.setSavePrettyPrintIndent(2);
513 psad
.save(spdFile
, options
);
514 } catch (IOException e
) {
521 Generate SpdHeader contents using parameters passed in.
523 @param pkgName PackageName
525 @param pkgVer Version
526 @param pkgAbs Abstract
527 @param pkgDes Description
528 @param pkgCpRight Copyright
529 @param pkgLicense License
530 @param pkgCreateDate Created
531 @param pkgUpdateDate Updated
533 @param pkgType PackageType
534 @param pkgRdOnly ReadOnly
535 @param pkgRePkg RePackage
536 @param pkgSpec Reserved
537 @param pkgOutDir Reserved
539 public void genSpdHeader(String pkgName
, String pkgGuid
, String pkgVer
, String pkgAbs
, String pkgDes
,
540 String pkgCpRight
, String pkgLicense
, String pkgCreateDate
, String pkgUpdateDate
,
541 String pkgURL
, String pkgType
, String pkgRdOnly
, String pkgRePkg
, String pkgSpec
,
543 if (getSpdHdr() == null) {
544 spdHdr
= psaRoot
.addNewSpdHeader();
547 setSpdHdrPkgName(pkgName
);
548 setSpdHdrGuid(pkgGuid
);
549 setSpdHdrVer(pkgVer
);
550 setSpdHdrAbs(pkgAbs
);
551 setSpdHdrDes(pkgDes
);
552 setSpdHdrCpRit(pkgCpRight
);
553 setSpdHdrLicense(pkgLicense
);
554 setSpdHdrCreateDate(pkgCreateDate
);
555 setSpdHdrUpdateDate(pkgUpdateDate
);
556 setSpdHdrURL(pkgURL
);
557 setSpdHdrPkgType(pkgType
);
558 setSpdHdrRdOnly(pkgRdOnly
);
559 setSpdHdrRePkg(pkgRePkg
);
560 setSpdHdrSpec(pkgSpec
);
561 setSpdHdrOutDir(pkgOutDir
);
565 Generate library class declaration element using parameters passed in
567 @param libClassBaseName LibraryClass element value
568 @param libClassUsage Reserved
569 @param incHdrFileName IncludeHeader element value
570 @param incHdrAttribGuid Reserved
571 @param incHdrAttribArch Reserved
572 @param incHdrAttribPath Reserved
573 @param incHdrAttribClass Reserved
574 @param incHdrAttribVer Reserved
575 @param incHdrAttribOverrideID Reserved
576 @param incHdrAttribModuleType Reserved
578 public void genSpdLibClassDeclarations(String libClassBaseName
, String libClassUsage
, String incHdrFileName
,
579 String incHdrAttribGuid
, String incHdrAttribArch
, String incHdrAttribPath
,
580 String incHdrAttribClass
, String incHdrAttribVer
,
581 String incHdrAttribOverrideID
, String incHdrAttribModuleType
) {
582 if (getSpdLibClassDeclarations() == null) {
583 spdLibClassDeclarations
= psaRoot
.addNewLibraryClassDeclarations();
586 // add contents under LibraryClassDeclarations tag
588 setSpdLibClassDeclaration(libClassBaseName
, libClassUsage
, incHdrFileName
, incHdrAttribGuid
, incHdrAttribArch
,
589 incHdrAttribPath
, incHdrAttribClass
, incHdrAttribVer
, incHdrAttribOverrideID
,
590 incHdrAttribModuleType
, spdLibClassDeclarations
);
594 Set library class declaration contents under parent tag
596 @param clsName LibraryClass element value
597 @param clsUsage Reserved
598 @param hdrFile IncludeHeader element value
599 @param hdrAttribGuid Reserved
600 @param hdrAttribArch Reserved
601 @param hdrAttribPath Reserved
602 @param hdrAttribClass Reserved
603 @param hdrAttribVer Reserved
604 @param hdrAttribOverID Reserved
605 @param hdrAttribModType Reserved
606 @param parent The tag under which library class declaration goes to
608 public void setSpdLibClassDeclaration(String clsName
, String clsUsage
, String hdrFile
, String hdrAttribGuid
,
609 String hdrAttribArch
, String hdrAttribPath
, String hdrAttribClass
,
610 String hdrAttribVer
, String hdrAttribOverID
, String hdrAttribModType
,
613 LibraryClassDeclarationDocument
.LibraryClassDeclaration lcd
= ((LibraryClassDeclarationsDocument
.LibraryClassDeclarations
) parent
)
614 .addNewLibraryClassDeclaration();
616 setSpdLibraryClass(clsName
, clsUsage
, lcd
);
618 setSpdIncludeHeader(null, hdrFile
, hdrAttribGuid
, hdrAttribArch
, hdrAttribPath
, hdrAttribClass
, hdrAttribVer
,
619 hdrAttribOverID
, lcd
);
623 Set the contents of LibraryClass under parent element
625 @param clsName LibraryClass element value
626 @param clsUsage Reserved
627 @param parent The tag under which library class declaration goes to
629 public void setSpdLibraryClass(String clsName
, String clsUsage
, XmlObject parent
) {
630 LibraryClassDeclarationDocument
.LibraryClassDeclaration
.LibraryClass lc
= ((LibraryClassDeclarationDocument
.LibraryClassDeclaration
) parent
).addNewLibraryClass();
631 lc
.setStringValue(clsName
);
635 Set contents of IncludeHeader under parent element
637 @param modType Reserved
638 @param hdrFile IncludeHeader element value
639 @param hdrAttribGuid Reserved
640 @param hdrAttribArch Reserved
641 @param hdrAttribPath Reserved
642 @param hdrAttribClass Reserved
643 @param hdrAttribVer Reserved
644 @param hdrAttribOverID Reserved
645 @param parent The tag under which library class declaration goes to
647 public void setSpdIncludeHeader(String modType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
648 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
649 String hdrAttribOverID
, XmlObject parent
) {
650 IncludeHeaderDocument
.IncludeHeader ih
= null;
651 if (parent
instanceof LibraryClassDeclarationDocument
.LibraryClassDeclaration
) {
652 ih
= ((LibraryClassDeclarationDocument
.LibraryClassDeclaration
) parent
).addNewIncludeHeader();
653 } else if (parent
instanceof PackageHeadersDocument
.PackageHeaders
) {
654 ih
= ((PackageHeadersDocument
.PackageHeaders
) parent
).addNewIncludeHeader();
659 ih
.setStringValue(hdrFile
);
660 if (hdrAttribGuid
!= null) {
661 ih
.setGuid(hdrAttribGuid
);
663 if (hdrAttribPath
!= null) {
664 ih
.setPath(hdrAttribPath
);
666 if (hdrAttribClass
!= null) {
667 ih
.setClass1(hdrAttribClass
);
669 if (hdrAttribVer
!= null) {
670 ih
.setVersion(hdrAttribVer
);
672 if (hdrAttribOverID
!= null) {
673 ih
.setOverrideID(Integer
.parseInt(hdrAttribOverID
));
675 if (modType
!= null) {
676 ih
.setModuleType(ModuleTypeDef
.Enum
.forString(modType
));
686 @param pkgDepPkgAttribGuid
687 @param pkgDepPkgAttribVer
688 @param pkgDepPkgAttribType
689 @param pkgDepPkgAttribUsage
690 @param pkgDepPkgAttribInstallDate
691 @param pkgDepPkgAttribUpdateDate
692 @param pkgDepPkgAttribPath
694 public void genSpdPackageDependencies(String pkgDepPkgName
, String pkgDepPkgAttribGuid
, String pkgDepPkgAttribVer
,
695 String pkgDepPkgAttribType
, String pkgDepPkgAttribUsage
,
696 String pkgDepPkgAttribInstallDate
, String pkgDepPkgAttribUpdateDate
,
697 String pkgDepPkgAttribPath
) {
698 if (spdPkgDeps
== null) {
699 spdPkgDeps
= psaRoot
.addNewPackageDependencies();
702 setSpdPackageName(pkgDepPkgName
, pkgDepPkgAttribGuid
, pkgDepPkgAttribVer
, pkgDepPkgAttribType
,
703 pkgDepPkgAttribUsage
, pkgDepPkgAttribInstallDate
, pkgDepPkgAttribUpdateDate
,
704 pkgDepPkgAttribPath
, spdPkgDeps
);
714 @param pkgAttribUsage
715 @param pkgAttribInstallDate
716 @param pkgAttribUpdateDate
720 public void setSpdPackageName(String pkgName
, String pkgAttribGuid
, String pkgAttribVer
, String pkgAttribType
,
721 String pkgAttribUsage
, String pkgAttribInstallDate
, String pkgAttribUpdateDate
,
722 String pkgAttribPath
, XmlObject parent
) {
724 PackageNameDocument
.PackageName pn
= ((PackageDependenciesDocument
.PackageDependencies
) parent
)
725 .addNewPackageName();
726 pn
.setStringValue(pkgName
);
727 pn
.setPackageType(PackageType
.Enum
.forString(pkgAttribType
));
728 pn
.setUsage(PackageUsage
.Enum
.forString(pkgAttribUsage
));
729 pn
.setUpdatedDate(pkgAttribUpdateDate
);
733 Generate MsaFile element.
735 @param msaFileName MsaFile element value
736 @param archType Reserved
738 public void genSpdMsaFiles(String msaFileName
, String archType
) {
739 if (getSpdMsaFiles() == null) {
740 spdMsaFiles
= psaRoot
.addNewMsaFiles();
742 setSpdMsaFile(msaFileName
, spdMsaFiles
);
747 Set MsaFile contents under parent element.
749 @param msaFileName MsaFile element value
750 @param parent Element under which MsaFile goes to
752 public void setSpdMsaFile(String msaFileName
, XmlObject parent
) {
754 ((MsaFilesDocument
.MsaFiles
) parent
).addNewMsaFile().addNewFilename().setStringValue(msaFileName
);
758 Generate PackageHeader element using parameters passed in.
760 @param ModHdrModType ModuleType attribute of IncludeHeader element
761 @param hdrFile IncludeHeader element value
762 @param hdrAttribGuid Reserved
763 @param hdrAttribArch Reserved
764 @param hdrAttribPath Reserved
765 @param hdrAttribClass Reserved
766 @param hdrAttribVer Reserved
767 @param hdrAttribOverID Reserved
769 public void genSpdModuleHeaders(String ModHdrModType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
770 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
771 String hdrAttribOverID
) {
772 if (getSpdModHdrs() == null) {
773 spdModHdrs
= psaRoot
.addNewPackageHeaders();
777 // add IncludeHeader under PackageHeaders element
779 setSpdIncludeHeader(ModHdrModType
, hdrFile
, hdrAttribGuid
, hdrAttribArch
, hdrAttribPath
, hdrAttribClass
,
780 hdrAttribVer
, hdrAttribOverID
, spdModHdrs
);
784 Generate GUID declaration element using parameters passed in.
786 @param guidDeclEntryName Name attribute of Entry element
787 @param guidDeclCName CName element value
788 @param guidDeclGuid Guid element value
789 @param guidDeclFeatureFlag Reserved
791 public void genSpdGuidDeclarations(String guidDeclEntryName
, String guidDeclCName
, String guidDeclGuid
,
792 String guidDeclFeatureFlag
) {
793 if (getSpdGuidDeclarations() == null) {
794 spdGuidDeclarations
= psaRoot
.addNewGuidDeclarations();
797 setSpdEntry(guidDeclEntryName
, guidDeclCName
, guidDeclGuid
, guidDeclFeatureFlag
, spdGuidDeclarations
);
801 Generate protocol declaration element using parameters passed in.
803 @param protocolDeclEntryName Name attribute of Entry element
804 @param protocolDeclCName CName element value
805 @param protocolDeclGuid Guid element value
806 @param protocolDeclFeatureFlag Reserved
808 public void genSpdProtocolDeclarations(String protocolDeclEntryName
, String protocolDeclCName
,
809 String protocolDeclGuid
, String protocolDeclFeatureFlag
) {
810 if (getSpdProtocolDeclarations() == null) {
811 spdProtocolDeclarations
= psaRoot
.addNewProtocolDeclarations();
814 setSpdEntry(protocolDeclEntryName
, protocolDeclCName
, protocolDeclGuid
, protocolDeclFeatureFlag
,
815 spdProtocolDeclarations
);
819 Generate PPI declaration element using parameters passed in.
821 @param ppiDeclEntryName Name attribute of Entry element
822 @param ppiDeclCName CName element value
823 @param ppiDeclGuid Guid element value
824 @param ppiDeclFeatureFlag Reserved
826 public void genSpdPpiDeclarations(String ppiDeclEntryName
, String ppiDeclCName
, String ppiDeclGuid
,
827 String ppiDeclFeatureFlag
) {
828 if (getSpdPpiDeclarations() == null) {
829 spdPpiDeclarations
= psaRoot
.addNewPpiDeclarations();
832 setSpdEntry(ppiDeclEntryName
, ppiDeclCName
, ppiDeclGuid
, ppiDeclFeatureFlag
, spdPpiDeclarations
);
836 Set Entry contents using parameters passed in
838 @param entryName Name attribute of Entry element
839 @param cName CName element value
840 @param guid Guid element value
841 @param featureFlag Reserved
842 @param parent The tag under which Entry element goes to
844 public void setSpdEntry(String entryName
, String cName
, String guid
, String featureFlag
, XmlObject parent
) {
846 if (parent
instanceof GuidDeclarationsDocument
.GuidDeclarations
) {
847 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= ((GuidDeclarations
) parent
).addNewEntry();
848 e
.setName(entryName
);
850 e
.addNewGuid().setStringValue(guid
);
854 if (parent
instanceof ProtocolDeclarationsDocument
.ProtocolDeclarations
) {
855 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry pe
= ((ProtocolDeclarationsDocument
.ProtocolDeclarations
) parent
)
857 pe
.setName(entryName
);
859 pe
.addNewGuid().setStringValue(guid
);
862 if (parent
instanceof PpiDeclarationsDocument
.PpiDeclarations
) {
863 PpiDeclarationsDocument
.PpiDeclarations
.Entry ppe
= ((PpiDeclarationsDocument
.PpiDeclarations
) parent
)
865 ppe
.setName(entryName
);
867 ppe
.addNewGuid().setStringValue(guid
);
877 Generate Pcd definition using parameters passed in
879 @param pcdItemTypes ItemType attribute of PcdEntry element
880 @param cName C_Name element value
881 @param token Token element value
882 @param dataType DatumType element value
883 @param skuEnable Reserved
885 @param maxSku Reserved
886 @param hiiEnable Reserved
887 @param varGuid Reserved
888 @param varName Reserved
889 @param defaultString DefaultString element value
891 public void genSpdPcdDefinitions(String pcdItemTypes
, String cName
, String token
, String dataType
,
892 String skuEnable
, String sku
, String maxSku
, String hiiEnable
, String varGuid
,
893 String varName
, String defaultString
) {
894 if (getSpdPcdDefinitions() == null) {
895 spdPcdDefinitions
= psaRoot
.addNewPcdDefinitions();
898 setSpdPcdEntry(pcdItemTypes
, cName
, token
, dataType
, skuEnable
, sku
, maxSku
, hiiEnable
, varGuid
, varName
,
899 defaultString
, spdPcdDefinitions
);
903 Set Pcd entry contents under parent tag
905 @param pcdItemTypes ItemType attribute of PcdEntry element
906 @param cName C_Name element value
907 @param token Token element value
908 @param dataType DatumType element value
909 @param skuEnable Reserved
911 @param maxSku Reserved
912 @param hiiEnable Reserved
913 @param varGuid Reserved
914 @param varName Reserved
915 @param defaultString DefaultString element value
916 @param parent Tag under which PcdEntry goes to
918 public void setSpdPcdEntry(String pcdItemTypes
, String cName
, String token
, String dataType
, String skuEnable
,
919 String sku
, String maxSku
, String hiiEnable
, String varGuid
, String varName
,
920 String defaultString
, XmlObject parent
) {
922 PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry pe
= ((PcdDefinitionsDocument
.PcdDefinitions
) parent
)
924 pe
.setItemType(PcdItemTypes
.Enum
.forString(pcdItemTypes
));
927 pe
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
928 pe
.setDefaultValue(defaultString
);
933 Get PpiDeclarations element
935 @return PpiDeclarationsDocument.PpiDeclarations
937 public PpiDeclarationsDocument
.PpiDeclarations
getSpdPpiDeclarations() {
938 if (spdPpiDeclarations
== null) {
939 spdPpiDeclarations
= psaRoot
.getPpiDeclarations();
941 return spdPpiDeclarations
;
945 Get ProtocolDeclarations element
947 @return ProtocolDeclarationsDocument.ProtocolDeclarations
949 public ProtocolDeclarationsDocument
.ProtocolDeclarations
getSpdProtocolDeclarations() {
950 if (spdProtocolDeclarations
== null) {
951 spdProtocolDeclarations
= psaRoot
.getProtocolDeclarations();
953 return spdProtocolDeclarations
;
957 Get GuidDeclarations element
959 @return GuidDeclarationsDocument.GuidDeclarations
961 public GuidDeclarationsDocument
.GuidDeclarations
getSpdGuidDeclarations() {
962 if (spdGuidDeclarations
== null) {
963 spdGuidDeclarations
= psaRoot
.getGuidDeclarations();
965 return spdGuidDeclarations
;
969 Get PcdDefinitions element
971 @return PcdDefinitionsDocument.PcdDefinitions
973 public PcdDefinitionsDocument
.PcdDefinitions
getSpdPcdDefinitions() {
974 if (spdPcdDefinitions
== null) {
975 spdPcdDefinitions
= psaRoot
.getPcdDefinitions();
977 return spdPcdDefinitions
;
981 Get PackageHeaders element
983 @return PackageHeadersDocument.PackageHeaders
985 public PackageHeadersDocument
.PackageHeaders
getSpdModHdrs() {
986 if (spdModHdrs
== null) {
987 spdModHdrs
= psaRoot
.getPackageHeaders();
995 @return MsaFilesDocument.MsaFiles
997 public MsaFilesDocument
.MsaFiles
getSpdMsaFiles() {
998 if (spdMsaFiles
== null) {
999 spdMsaFiles
= psaRoot
.getMsaFiles();
1005 Get LibraryClassDeclarations element
1007 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
1009 public LibraryClassDeclarationsDocument
.LibraryClassDeclarations
getSpdLibClassDeclarations() {
1010 if (spdLibClassDeclarations
== null) {
1011 spdLibClassDeclarations
= psaRoot
.getLibraryClassDeclarations();
1013 return spdLibClassDeclarations
;
1017 Get SpdHeader element
1019 @return SpdHeaderDocument.SpdHeader
1021 public SpdHeaderDocument
.SpdHeader
getSpdHdr() {
1022 if (spdHdr
== null) {
1023 spdHdr
= psaRoot
.getSpdHeader();
1029 Get Abstract element under tag SpdHeader
1031 @return AbstractDocument.Abstract
1033 public AbstractDocument
.Abstract
getSpdHdrAbs() {
1034 if (spdHdrAbs
== null) {
1035 spdHdrAbs
= getSpdHdr().getAbstract();
1041 Set value to Abstract element
1043 @param abs The value set to Abstract element
1045 public void setSpdHdrAbs(String abs
) {
1047 if (getSpdHdrAbs() != null) {
1048 getSpdHdrAbs().setStringValue(abs
);
1050 spdHdrAbs
= getSpdHdr().addNewAbstract();
1051 spdHdrAbs
.setStringValue(abs
);
1056 Set value to Copyright element
1058 @param cpRit The value set to Copyright element
1060 public void setSpdHdrCpRit(String cpRit
) {
1062 getSpdHdr().setCopyright(cpRit
);
1067 Set value to Created element
1069 @param createDate The value set to Created element
1071 public void setSpdHdrCreateDate(String createDate
) {
1073 getSpdHdr().setCreated(createDate
);
1078 Set value to Description element
1080 @param des The value set to Description element
1082 public void setSpdHdrDes(String des
) {
1083 getSpdHdr().setDescription(des
);
1087 Get Guid element under SpdHdr
1089 @return GuidDocument.Guid
1091 public GuidDocument
.Guid
getSpdHdrGuid() {
1092 if (spdHdrGuid
== null) {
1093 spdHdrGuid
= getSpdHdr().getGuid();
1099 Set value to Guid element
1101 @param guid The value set to Guid element
1103 public void setSpdHdrGuid(String guid
) {
1104 if (getSpdHdrGuid() != null) {
1105 getSpdHdrGuid().setStringValue(guid
);
1107 spdHdrGuid
= getSpdHdr().addNewGuid();
1108 spdHdrGuid
.setStringValue(guid
);
1113 Get Version element under SpdHdr
1117 public String
getSpdHdrVer() {
1119 return spdHdr
.getVersion() + "";
1125 Set value to Version element
1127 @param ver The value set to Version element
1129 public void setSpdHdrVer(String ver
) {
1130 if (spdHdr
!= null) {
1131 spdHdr
.setVersion(new BigDecimal(ver
.toCharArray()));
1137 Get License element under SpdHdr
1139 @return LicenseDocument.License
1141 public LicenseDocument
.License
getSpdHdrLicense() {
1142 if (spdHdrLicense
== null) {
1143 spdHdrLicense
= getSpdHdr().getLicense();
1145 return spdHdrLicense
;
1149 Set value to License element
1151 @param license The value set to License element
1153 public void setSpdHdrLicense(String license
) {
1154 if (getSpdHdrLicense() != null) {
1155 getSpdHdrLicense().setStringValue(license
);
1157 spdHdrLicense
= getSpdHdr().addNewLicense();
1158 spdHdrLicense
.setStringValue(license
);
1167 public OutputDirectoryDocument
.OutputDirectory
getSpdHdrOutDir() {
1168 return spdHdrOutDir
;
1176 public void setSpdHdrOutDir(String outdir
) {
1177 if (outdir
== null) {
1180 if (getSpdHdrOutDir() != null) {
1181 getSpdHdrOutDir().setStringValue(outdir
);
1183 spdHdrOutDir
= getSpdHdr().addNewOutputDirectory();
1184 spdHdrOutDir
.setStringValue(outdir
);
1189 Get PackageName element under SpdHdr
1191 @return PackageNameDocument.PackageName
1193 public String
getSpdHdrPkgName() {
1194 if (spdHdrPkgName
== null) {
1195 spdHdrPkgName
= getSpdHdr().getPackageName();
1197 return spdHdrPkgName
;
1201 Set value to PackageName element
1203 @param pkgName The value set to PackageName element
1205 public void setSpdHdrPkgName(String pkgName
) {
1207 if (getSpdHdrPkgName() != null) {
1208 getSpdHdr().setPackageName(pkgName
);
1210 getSpdHdr().setPackageName(pkgName
);
1217 @return SpecificationDocument.Specification
1219 public SpecificationDocument
.Specification
getSpdHdrSpec() {
1228 public void setSpdHdrSpec(String spec
) {
1232 if (getSpdHdrSpec() != null) {
1233 getSpdHdrSpec().setStringValue(spec
);
1235 spdHdrSpec
= getSpdHdr().addNewSpecification();
1236 spdHdrSpec
.setStringValue(spec
);
1241 Set value to PackageType element
1243 @param pkgType The value set to PackageType element
1245 public void setSpdHdrPkgType(String pkgType
) {
1246 getSpdHdr().setPackageType(PackageType
.Enum
.forString(pkgType
));
1250 Set value to ReadOnly element
1252 @param rdOnly The value set to ReadOnly element
1254 public void setSpdHdrRdOnly(String rdOnly
) {
1256 getSpdHdr().setReadOnly(new Boolean(rdOnly
));
1260 Set value to RePackage element
1262 @param rePkg The value set to RePackage element
1264 public void setSpdHdrRePkg(String rePkg
) {
1266 getSpdHdr().setRePackage(new Boolean(rePkg
));
1270 Set value to Updated element
1272 @param updateDate The value set to Updated element
1274 public void setSpdHdrUpdateDate(String updateDate
) {
1275 getSpdHdr().setUpdated(updateDate
);
1279 Set value to URL element
1281 @param url The value set to URL element
1283 public void setSpdHdrURL(String url
) {
1284 getSpdHdr().setURL(url
);
1292 public File
getFile() {
1299 @param file File with xml format
1301 public void setFile(File file
) {