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();
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().getStringValue();
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 List
<LibraryClassDeclarationDocument
.LibraryClassDeclaration
> l
= psaRoot
.getLibraryClassDeclarations()
250 .getLibraryClassDeclarationList();
252 ListIterator li
= l
.listIterator();
253 while (li
.hasNext()) {
254 LibraryClassDeclarationDocument
.LibraryClassDeclaration lcd
= (LibraryClassDeclarationDocument
.LibraryClassDeclaration
) li
256 if (lcd
.getLibraryClass() != null) {
257 libClass
[i
][0] = lcd
.getLibraryClass().getStringValue();
259 if (lcd
.getIncludeHeader() != null) {
260 libClass
[i
][1] = lcd
.getIncludeHeader().getStringValue();
269 Get the number of Msa files from the size of List
273 public int getSpdMsaFileCount() {
274 if (psaRoot
.getMsaFiles() == null || psaRoot
.getMsaFiles().getMsaFileList() == null) {
277 return psaRoot
.getMsaFiles().getMsaFileList().size();
281 Get available Msa file into String array
283 @param msaFile Caller allocated two-dimentional String array
285 public void getSpdMsaFiles(String
[][] msaFile
) {
286 List
<MsaFilesDocument
.MsaFiles
.MsaFile
> l
= psaRoot
.getMsaFiles().getMsaFileList();
288 ListIterator li
= l
.listIterator();
289 while (li
.hasNext()) {
290 MsaFilesDocument
.MsaFiles
.MsaFile m
= (MsaFilesDocument
.MsaFiles
.MsaFile
) li
.next();
291 if (m
.getFilename() != null) {
292 msaFile
[i
][0] = m
.getFilename().getStringValue();
300 Get the number of include header files in PackageHeaders from the size of List
304 public int getSpdPackageHeaderCount() {
305 if (psaRoot
.getPackageHeaders() == null || psaRoot
.getPackageHeaders().getIncludeHeaderList() == null) {
308 return psaRoot
.getPackageHeaders().getIncludeHeaderList().size();
312 Get available package header contents into String array
314 @param pkgHeader Caller allocated two-dimentional String array
316 public void getSpdPackageHeaders(String
[][] pkgHeader
) {
317 List
<IncludeHeaderDocument
.IncludeHeader
> l
= psaRoot
.getPackageHeaders().getIncludeHeaderList();
319 ListIterator li
= l
.listIterator();
320 while (li
.hasNext()) {
321 IncludeHeaderDocument
.IncludeHeader ih
= (IncludeHeaderDocument
.IncludeHeader
) li
.next();
322 if (ih
.getModuleType() != null) {
323 pkgHeader
[i
][0] = ih
.getModuleType().toString();
326 pkgHeader
[i
][1] = ih
.getStringValue();
332 Get the number of GUID declarations from the size of List
336 public int getSpdGuidDeclarationCount() {
337 if (psaRoot
.getGuidDeclarations() == null || psaRoot
.getGuidDeclarations().getEntryList() == null) {
340 return psaRoot
.getGuidDeclarations().getEntryList().size();
344 Get available Guid declaration contents into String array
346 @param guid Caller allocated two-dimentional String array
348 public void getSpdGuidDeclarations(String
[][] guid
) {
349 List
<GuidDeclarationsDocument
.GuidDeclarations
.Entry
> l
= psaRoot
.getGuidDeclarations().getEntryList();
351 ListIterator li
= l
.listIterator();
352 while (li
.hasNext()) {
353 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) li
355 guid
[i
][0] = e
.getName();
356 guid
[i
][1] = e
.getCName();
357 if (e
.getGuid() != null) {
358 guid
[i
][2] = e
.getGuid().getStringValue();
365 Get the number of protocol declarations from the size of List
369 public int getSpdProtocolDeclarationCount() {
370 if (psaRoot
.getProtocolDeclarations() == null || psaRoot
.getProtocolDeclarations().getEntryList() == null) {
373 return psaRoot
.getProtocolDeclarations().getEntryList().size();
377 Get available protocol declaration contents into String array
379 @param protocol Caller allocated two-dimentional String array
381 public void getSpdProtocolDeclarations(String
[][] protocol
) {
382 List
<ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
> l
= psaRoot
.getProtocolDeclarations()
385 ListIterator li
= l
.listIterator();
386 while (li
.hasNext()) {
387 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry e
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) li
389 protocol
[i
][0] = e
.getName();
390 protocol
[i
][1] = e
.getCName();
391 if (e
.getGuid() != null) {
392 protocol
[i
][2] = e
.getGuid().getStringValue();
399 Get the number of Ppi declarations from the size of List
403 public int getSpdPpiDeclarationCount() {
404 if (psaRoot
.getPpiDeclarations() == null || psaRoot
.getPpiDeclarations().getEntryList() == null) {
407 return psaRoot
.getPpiDeclarations().getEntryList().size();
411 Get available Ppi declaration contents into String array
413 @param ppi Caller allocated two-dimentional String array
415 public void getSpdPpiDeclarations(String
[][] ppi
) {
416 List
<PpiDeclarationsDocument
.PpiDeclarations
.Entry
> l
= psaRoot
.getPpiDeclarations().getEntryList();
418 ListIterator li
= l
.listIterator();
419 while (li
.hasNext()) {
420 PpiDeclarationsDocument
.PpiDeclarations
.Entry e
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) li
.next();
421 ppi
[i
][0] = e
.getName();
422 ppi
[i
][1] = e
.getCName();
423 if (e
.getGuid() != null) {
424 ppi
[i
][2] = e
.getGuid().getStringValue();
432 Get the number of Pcd definitions from the size of List
436 public int getSpdPcdDefinitionCount() {
437 if (psaRoot
.getPcdDefinitions() == null || psaRoot
.getPcdDefinitions().getPcdEntryList() == null) {
440 return psaRoot
.getPcdDefinitions().getPcdEntryList().size();
444 Get available Pcd definition contents into String array
446 @param pcd Caller allocated two-dimentional String array
448 public void getSpdPcdDefinitions(String
[][] pcd
) {
449 List
<PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry
> l
= psaRoot
.getPcdDefinitions().getPcdEntryList();
451 ListIterator li
= l
.listIterator();
452 while (li
.hasNext()) {
453 PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry e
= (PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry
) li
455 if (e
.getItemType() != null) {
456 pcd
[i
][0] = e
.getItemType().toString();
459 pcd
[i
][1] = e
.getCName();
460 pcd
[i
][2] = e
.getToken();
461 if (e
.getDatumType() != null) {
462 pcd
[i
][3] = e
.getDatumType().toString();
465 if (e
.getDefaultValue() != null) {
466 pcd
[i
][4] = e
.getDefaultValue().toString();
474 Save the processed xml contents to file
476 @param spdFile The file to save xml contents
477 @throws IOException Exceptions during file operation
479 public void saveAs(File spdFile
) throws IOException
{
481 XmlOptions options
= new XmlOptions();
483 options
.setCharacterEncoding("UTF-8");
484 options
.setSavePrettyPrint();
485 options
.setSavePrettyPrintIndent(2);
487 psad
.save(spdFile
, options
);
488 } catch (IOException e
) {
495 Generate SpdHeader contents using parameters passed in.
497 @param pkgName PackageName
499 @param pkgVer Version
500 @param pkgAbs Abstract
501 @param pkgDes Description
502 @param pkgCpRight Copyright
503 @param pkgLicense License
504 @param pkgCreateDate Created
505 @param pkgUpdateDate Updated
507 @param pkgType PackageType
508 @param pkgRdOnly ReadOnly
509 @param pkgRePkg RePackage
510 @param pkgSpec Reserved
511 @param pkgOutDir Reserved
513 public void genSpdHeader(String pkgName
, String pkgGuid
, String pkgVer
, String pkgAbs
, String pkgDes
,
514 String pkgCpRight
, String pkgLicense
, String pkgCreateDate
, String pkgUpdateDate
,
515 String pkgURL
, String pkgType
, String pkgRdOnly
, String pkgRePkg
, String pkgSpec
,
517 if (getSpdHdr() == null) {
518 spdHdr
= psaRoot
.addNewSpdHeader();
521 setSpdHdrPkgName(pkgName
);
522 setSpdHdrGuid(pkgGuid
);
523 setSpdHdrVer(pkgVer
);
524 setSpdHdrAbs(pkgAbs
);
525 setSpdHdrDes(pkgDes
);
526 setSpdHdrCpRit(pkgCpRight
);
527 setSpdHdrLicense(pkgLicense
);
528 setSpdHdrCreateDate(pkgCreateDate
);
529 setSpdHdrUpdateDate(pkgUpdateDate
);
530 setSpdHdrURL(pkgURL
);
531 setSpdHdrPkgType(pkgType
);
532 setSpdHdrRdOnly(pkgRdOnly
);
533 setSpdHdrRePkg(pkgRePkg
);
534 setSpdHdrSpec(pkgSpec
);
535 setSpdHdrOutDir(pkgOutDir
);
539 Generate library class declaration element using parameters passed in
541 @param libClassBaseName LibraryClass element value
542 @param libClassUsage Reserved
543 @param incHdrFileName IncludeHeader element value
544 @param incHdrAttribGuid Reserved
545 @param incHdrAttribArch Reserved
546 @param incHdrAttribPath Reserved
547 @param incHdrAttribClass Reserved
548 @param incHdrAttribVer Reserved
549 @param incHdrAttribOverrideID Reserved
550 @param incHdrAttribModuleType Reserved
552 public void genSpdLibClassDeclarations(String libClassBaseName
, String libClassUsage
, String incHdrFileName
,
553 String incHdrAttribGuid
, String incHdrAttribArch
, String incHdrAttribPath
,
554 String incHdrAttribClass
, String incHdrAttribVer
,
555 String incHdrAttribOverrideID
, String incHdrAttribModuleType
) {
556 if (getSpdLibClassDeclarations() == null) {
557 spdLibClassDeclarations
= psaRoot
.addNewLibraryClassDeclarations();
560 // add contents under LibraryClassDeclarations tag
562 setSpdLibClassDeclaration(libClassBaseName
, libClassUsage
, incHdrFileName
, incHdrAttribGuid
, incHdrAttribArch
,
563 incHdrAttribPath
, incHdrAttribClass
, incHdrAttribVer
, incHdrAttribOverrideID
,
564 incHdrAttribModuleType
, spdLibClassDeclarations
);
568 Set library class declaration contents under parent tag
570 @param clsName LibraryClass element value
571 @param clsUsage Reserved
572 @param hdrFile IncludeHeader element value
573 @param hdrAttribGuid Reserved
574 @param hdrAttribArch Reserved
575 @param hdrAttribPath Reserved
576 @param hdrAttribClass Reserved
577 @param hdrAttribVer Reserved
578 @param hdrAttribOverID Reserved
579 @param hdrAttribModType Reserved
580 @param parent The tag under which library class declaration goes to
582 public void setSpdLibClassDeclaration(String clsName
, String clsUsage
, String hdrFile
, String hdrAttribGuid
,
583 String hdrAttribArch
, String hdrAttribPath
, String hdrAttribClass
,
584 String hdrAttribVer
, String hdrAttribOverID
, String hdrAttribModType
,
587 LibraryClassDeclarationDocument
.LibraryClassDeclaration lcd
= ((LibraryClassDeclarationsDocument
.LibraryClassDeclarations
) parent
)
588 .addNewLibraryClassDeclaration();
590 setSpdLibraryClass(clsName
, clsUsage
, lcd
);
592 setSpdIncludeHeader(null, hdrFile
, hdrAttribGuid
, hdrAttribArch
, hdrAttribPath
, hdrAttribClass
, hdrAttribVer
,
593 hdrAttribOverID
, lcd
);
597 Set the contents of LibraryClass under parent element
599 @param clsName LibraryClass element value
600 @param clsUsage Reserved
601 @param parent The tag under which library class declaration goes to
603 public void setSpdLibraryClass(String clsName
, String clsUsage
, XmlObject parent
) {
604 LibraryClassDocument
.LibraryClass lc
= ((LibraryClassDeclarationDocument
.LibraryClassDeclaration
) parent
)
605 .addNewLibraryClass();
606 lc
.setStringValue(clsName
);
610 Set contents of IncludeHeader under parent element
612 @param modType Reserved
613 @param hdrFile IncludeHeader element value
614 @param hdrAttribGuid Reserved
615 @param hdrAttribArch Reserved
616 @param hdrAttribPath Reserved
617 @param hdrAttribClass Reserved
618 @param hdrAttribVer Reserved
619 @param hdrAttribOverID Reserved
620 @param parent The tag under which library class declaration goes to
622 public void setSpdIncludeHeader(String modType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
623 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
624 String hdrAttribOverID
, XmlObject parent
) {
625 IncludeHeaderDocument
.IncludeHeader ih
= null;
626 if (parent
instanceof LibraryClassDeclarationDocument
.LibraryClassDeclaration
) {
627 ih
= ((LibraryClassDeclarationDocument
.LibraryClassDeclaration
) parent
).addNewIncludeHeader();
628 } else if (parent
instanceof PackageHeadersDocument
.PackageHeaders
) {
629 ih
= ((PackageHeadersDocument
.PackageHeaders
) parent
).addNewIncludeHeader();
634 ih
.setStringValue(hdrFile
);
635 if (hdrAttribGuid
!= null) {
636 ih
.setGuid(hdrAttribGuid
);
638 if (hdrAttribPath
!= null) {
639 ih
.setPath(hdrAttribPath
);
641 if (hdrAttribClass
!= null) {
642 ih
.setClass1(hdrAttribClass
);
644 if (hdrAttribVer
!= null) {
645 ih
.setVersion(hdrAttribVer
);
647 if (hdrAttribOverID
!= null) {
648 ih
.setOverrideID(Integer
.parseInt(hdrAttribOverID
));
650 if (modType
!= null) {
651 ih
.setModuleType(ModuleTypeDef
.Enum
.forString(modType
));
661 @param pkgDepPkgAttribGuid
662 @param pkgDepPkgAttribVer
663 @param pkgDepPkgAttribType
664 @param pkgDepPkgAttribUsage
665 @param pkgDepPkgAttribInstallDate
666 @param pkgDepPkgAttribUpdateDate
667 @param pkgDepPkgAttribPath
669 public void genSpdPackageDependencies(String pkgDepPkgName
, String pkgDepPkgAttribGuid
, String pkgDepPkgAttribVer
,
670 String pkgDepPkgAttribType
, String pkgDepPkgAttribUsage
,
671 String pkgDepPkgAttribInstallDate
, String pkgDepPkgAttribUpdateDate
,
672 String pkgDepPkgAttribPath
) {
673 if (spdPkgDeps
== null) {
674 spdPkgDeps
= psaRoot
.addNewPackageDependencies();
677 setSpdPackageName(pkgDepPkgName
, pkgDepPkgAttribGuid
, pkgDepPkgAttribVer
, pkgDepPkgAttribType
,
678 pkgDepPkgAttribUsage
, pkgDepPkgAttribInstallDate
, pkgDepPkgAttribUpdateDate
,
679 pkgDepPkgAttribPath
, spdPkgDeps
);
689 @param pkgAttribUsage
690 @param pkgAttribInstallDate
691 @param pkgAttribUpdateDate
695 public void setSpdPackageName(String pkgName
, String pkgAttribGuid
, String pkgAttribVer
, String pkgAttribType
,
696 String pkgAttribUsage
, String pkgAttribInstallDate
, String pkgAttribUpdateDate
,
697 String pkgAttribPath
, XmlObject parent
) {
699 PackageNameDocument
.PackageName pn
= ((PackageDependenciesDocument
.PackageDependencies
) parent
)
700 .addNewPackageName();
701 pn
.setStringValue(pkgName
);
702 pn
.setPackageType(PackageType
.Enum
.forString(pkgAttribType
));
703 pn
.setUsage(PackageUsage
.Enum
.forString(pkgAttribUsage
));
704 pn
.setUpdatedDate(pkgAttribUpdateDate
);
708 Generate MsaFile element.
710 @param msaFileName MsaFile element value
711 @param archType Reserved
713 public void genSpdMsaFiles(String msaFileName
, String archType
) {
714 if (getSpdMsaFiles() == null) {
715 spdMsaFiles
= psaRoot
.addNewMsaFiles();
717 setSpdMsaFile(msaFileName
, spdMsaFiles
);
722 Set MsaFile contents under parent element.
724 @param msaFileName MsaFile element value
725 @param parent Element under which MsaFile goes to
727 public void setSpdMsaFile(String msaFileName
, XmlObject parent
) {
729 ((MsaFilesDocument
.MsaFiles
) parent
).addNewMsaFile().addNewFilename().setStringValue(msaFileName
);
733 Generate PackageHeader element using parameters passed in.
735 @param ModHdrModType ModuleType attribute of IncludeHeader element
736 @param hdrFile IncludeHeader element value
737 @param hdrAttribGuid Reserved
738 @param hdrAttribArch Reserved
739 @param hdrAttribPath Reserved
740 @param hdrAttribClass Reserved
741 @param hdrAttribVer Reserved
742 @param hdrAttribOverID Reserved
744 public void genSpdModuleHeaders(String ModHdrModType
, String hdrFile
, String hdrAttribGuid
, String hdrAttribArch
,
745 String hdrAttribPath
, String hdrAttribClass
, String hdrAttribVer
,
746 String hdrAttribOverID
) {
747 if (getSpdModHdrs() == null) {
748 spdModHdrs
= psaRoot
.addNewPackageHeaders();
752 // add IncludeHeader under PackageHeaders element
754 setSpdIncludeHeader(ModHdrModType
, hdrFile
, hdrAttribGuid
, hdrAttribArch
, hdrAttribPath
, hdrAttribClass
,
755 hdrAttribVer
, hdrAttribOverID
, spdModHdrs
);
759 Generate GUID declaration element using parameters passed in.
761 @param guidDeclEntryName Name attribute of Entry element
762 @param guidDeclCName CName element value
763 @param guidDeclGuid Guid element value
764 @param guidDeclFeatureFlag Reserved
766 public void genSpdGuidDeclarations(String guidDeclEntryName
, String guidDeclCName
, String guidDeclGuid
,
767 String guidDeclFeatureFlag
) {
768 if (getSpdGuidDeclarations() == null) {
769 spdGuidDeclarations
= psaRoot
.addNewGuidDeclarations();
772 setSpdEntry(guidDeclEntryName
, guidDeclCName
, guidDeclGuid
, guidDeclFeatureFlag
, spdGuidDeclarations
);
776 Generate protocol declaration element using parameters passed in.
778 @param protocolDeclEntryName Name attribute of Entry element
779 @param protocolDeclCName CName element value
780 @param protocolDeclGuid Guid element value
781 @param protocolDeclFeatureFlag Reserved
783 public void genSpdProtocolDeclarations(String protocolDeclEntryName
, String protocolDeclCName
,
784 String protocolDeclGuid
, String protocolDeclFeatureFlag
) {
785 if (getSpdProtocolDeclarations() == null) {
786 spdProtocolDeclarations
= psaRoot
.addNewProtocolDeclarations();
789 setSpdEntry(protocolDeclEntryName
, protocolDeclCName
, protocolDeclGuid
, protocolDeclFeatureFlag
,
790 spdProtocolDeclarations
);
794 Generate PPI declaration element using parameters passed in.
796 @param ppiDeclEntryName Name attribute of Entry element
797 @param ppiDeclCName CName element value
798 @param ppiDeclGuid Guid element value
799 @param ppiDeclFeatureFlag Reserved
801 public void genSpdPpiDeclarations(String ppiDeclEntryName
, String ppiDeclCName
, String ppiDeclGuid
,
802 String ppiDeclFeatureFlag
) {
803 if (getSpdPpiDeclarations() == null) {
804 spdPpiDeclarations
= psaRoot
.addNewPpiDeclarations();
807 setSpdEntry(ppiDeclEntryName
, ppiDeclCName
, ppiDeclGuid
, ppiDeclFeatureFlag
, spdPpiDeclarations
);
811 Set Entry contents using parameters passed in
813 @param entryName Name attribute of Entry element
814 @param cName CName element value
815 @param guid Guid element value
816 @param featureFlag Reserved
817 @param parent The tag under which Entry element goes to
819 public void setSpdEntry(String entryName
, String cName
, String guid
, String featureFlag
, XmlObject parent
) {
821 if (parent
instanceof GuidDeclarationsDocument
.GuidDeclarations
) {
822 GuidDeclarationsDocument
.GuidDeclarations
.Entry e
= ((GuidDeclarations
) parent
).addNewEntry();
823 e
.setName(entryName
);
825 e
.addNewGuid().setStringValue(guid
);
826 if (featureFlag
!= null) {
827 e
.addNewFeatureFlag().setStringValue(featureFlag
);
831 if (parent
instanceof ProtocolDeclarationsDocument
.ProtocolDeclarations
) {
832 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry pe
= ((ProtocolDeclarationsDocument
.ProtocolDeclarations
) parent
)
834 pe
.setName(entryName
);
836 pe
.addNewGuid().setStringValue(guid
);
837 if (featureFlag
!= null) {
838 pe
.addNewFeatureFlag().setStringValue(featureFlag
);
842 if (parent
instanceof PpiDeclarationsDocument
.PpiDeclarations
) {
843 PpiDeclarationsDocument
.PpiDeclarations
.Entry ppe
= ((PpiDeclarationsDocument
.PpiDeclarations
) parent
)
845 ppe
.setName(entryName
);
847 ppe
.addNewGuid().setStringValue(guid
);
848 if (featureFlag
!= null) {
849 ppe
.addNewFeatureFlag().setStringValue(featureFlag
);
859 Generate Pcd definition using parameters passed in
861 @param pcdItemTypes ItemType attribute of PcdEntry element
862 @param cName C_Name element value
863 @param token Token element value
864 @param dataType DatumType element value
865 @param skuEnable Reserved
867 @param maxSku Reserved
868 @param hiiEnable Reserved
869 @param varGuid Reserved
870 @param varName Reserved
871 @param defaultString DefaultString element value
873 public void genSpdPcdDefinitions(String pcdItemTypes
, String cName
, String token
, String dataType
,
874 String skuEnable
, String sku
, String maxSku
, String hiiEnable
, String varGuid
,
875 String varName
, String defaultString
) {
876 if (getSpdPcdDefinitions() == null) {
877 spdPcdDefinitions
= psaRoot
.addNewPcdDefinitions();
880 setSpdPcdEntry(pcdItemTypes
, cName
, token
, dataType
, skuEnable
, sku
, maxSku
, hiiEnable
, varGuid
, varName
,
881 defaultString
, spdPcdDefinitions
);
885 Set Pcd entry contents under parent tag
887 @param pcdItemTypes ItemType attribute of PcdEntry element
888 @param cName C_Name element value
889 @param token Token element value
890 @param dataType DatumType element value
891 @param skuEnable Reserved
893 @param maxSku Reserved
894 @param hiiEnable Reserved
895 @param varGuid Reserved
896 @param varName Reserved
897 @param defaultString DefaultString element value
898 @param parent Tag under which PcdEntry goes to
900 public void setSpdPcdEntry(String pcdItemTypes
, String cName
, String token
, String dataType
, String skuEnable
,
901 String sku
, String maxSku
, String hiiEnable
, String varGuid
, String varName
,
902 String defaultString
, XmlObject parent
) {
904 PcdDefinitionsDocument
.PcdDefinitions
.PcdEntry pe
= ((PcdDefinitionsDocument
.PcdDefinitions
) parent
)
906 pe
.setItemType(PcdItemTypes
.Enum
.forString(pcdItemTypes
));
909 pe
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
910 pe
.setDefaultValue(defaultString
);
915 Get PpiDeclarations element
917 @return PpiDeclarationsDocument.PpiDeclarations
919 public PpiDeclarationsDocument
.PpiDeclarations
getSpdPpiDeclarations() {
920 if (spdPpiDeclarations
== null) {
921 spdPpiDeclarations
= psaRoot
.getPpiDeclarations();
923 return spdPpiDeclarations
;
927 Get ProtocolDeclarations element
929 @return ProtocolDeclarationsDocument.ProtocolDeclarations
931 public ProtocolDeclarationsDocument
.ProtocolDeclarations
getSpdProtocolDeclarations() {
932 if (spdProtocolDeclarations
== null) {
933 spdProtocolDeclarations
= psaRoot
.getProtocolDeclarations();
935 return spdProtocolDeclarations
;
939 Get GuidDeclarations element
941 @return GuidDeclarationsDocument.GuidDeclarations
943 public GuidDeclarationsDocument
.GuidDeclarations
getSpdGuidDeclarations() {
944 if (spdGuidDeclarations
== null) {
945 spdGuidDeclarations
= psaRoot
.getGuidDeclarations();
947 return spdGuidDeclarations
;
951 Get PcdDefinitions element
953 @return PcdDefinitionsDocument.PcdDefinitions
955 public PcdDefinitionsDocument
.PcdDefinitions
getSpdPcdDefinitions() {
956 if (spdPcdDefinitions
== null) {
957 spdPcdDefinitions
= psaRoot
.getPcdDefinitions();
959 return spdPcdDefinitions
;
963 Get PackageHeaders element
965 @return PackageHeadersDocument.PackageHeaders
967 public PackageHeadersDocument
.PackageHeaders
getSpdModHdrs() {
968 if (spdModHdrs
== null) {
969 spdModHdrs
= psaRoot
.getPackageHeaders();
977 @return MsaFilesDocument.MsaFiles
979 public MsaFilesDocument
.MsaFiles
getSpdMsaFiles() {
980 if (spdMsaFiles
== null) {
981 spdMsaFiles
= psaRoot
.getMsaFiles();
987 Get LibraryClassDeclarations element
989 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
991 public LibraryClassDeclarationsDocument
.LibraryClassDeclarations
getSpdLibClassDeclarations() {
992 if (spdLibClassDeclarations
== null) {
993 spdLibClassDeclarations
= psaRoot
.getLibraryClassDeclarations();
995 return spdLibClassDeclarations
;
999 Get SpdHeader element
1001 @return SpdHeaderDocument.SpdHeader
1003 public SpdHeaderDocument
.SpdHeader
getSpdHdr() {
1004 if (spdHdr
== null) {
1005 spdHdr
= psaRoot
.getSpdHeader();
1011 Get Abstract element under tag SpdHeader
1013 @return AbstractDocument.Abstract
1015 public AbstractDocument
.Abstract
getSpdHdrAbs() {
1016 if (spdHdrAbs
== null) {
1017 spdHdrAbs
= getSpdHdr().getAbstract();
1023 Set value to Abstract element
1025 @param abs The value set to Abstract element
1027 public void setSpdHdrAbs(String abs
) {
1029 if (getSpdHdrAbs() != null) {
1030 getSpdHdrAbs().setStringValue(abs
);
1032 spdHdrAbs
= getSpdHdr().addNewAbstract();
1033 spdHdrAbs
.setStringValue(abs
);
1038 Set value to Copyright element
1040 @param cpRit The value set to Copyright element
1042 public void setSpdHdrCpRit(String cpRit
) {
1044 getSpdHdr().setCopyright(cpRit
);
1049 Set value to Created element
1051 @param createDate The value set to Created element
1053 public void setSpdHdrCreateDate(String createDate
) {
1055 getSpdHdr().setCreated(createDate
);
1060 Set value to Description element
1062 @param des The value set to Description element
1064 public void setSpdHdrDes(String des
) {
1065 getSpdHdr().setDescription(des
);
1069 Get Guid element under SpdHdr
1071 @return GuidDocument.Guid
1073 public GuidDocument
.Guid
getSpdHdrGuid() {
1074 if (spdHdrGuid
== null) {
1075 spdHdrGuid
= getSpdHdr().getGuid();
1081 Set value to Guid element
1083 @param guid The value set to Guid element
1085 public void setSpdHdrGuid(String guid
) {
1086 if (getSpdHdrGuid() != null) {
1087 getSpdHdrGuid().setStringValue(guid
);
1089 spdHdrGuid
= getSpdHdr().addNewGuid();
1090 spdHdrGuid
.setStringValue(guid
);
1095 Get Version element under SpdHdr
1099 public String
getSpdHdrVer() {
1101 return spdHdr
.getVersion();
1107 Set value to Version element
1109 @param ver The value set to Version element
1111 public void setSpdHdrVer(String ver
) {
1112 if (spdHdr
!= null) {
1113 spdHdr
.setVersion(ver
);
1119 Get License element under SpdHdr
1121 @return LicenseDocument.License
1123 public LicenseDocument
.License
getSpdHdrLicense() {
1124 if (spdHdrLicense
== null) {
1125 spdHdrLicense
= getSpdHdr().getLicense();
1127 return spdHdrLicense
;
1131 Set value to License element
1133 @param license The value set to License element
1135 public void setSpdHdrLicense(String license
) {
1136 if (getSpdHdrLicense() != null) {
1137 getSpdHdrLicense().setStringValue(license
);
1139 spdHdrLicense
= getSpdHdr().addNewLicense();
1140 spdHdrLicense
.setStringValue(license
);
1149 public OutputDirectoryDocument
.OutputDirectory
getSpdHdrOutDir() {
1150 return spdHdrOutDir
;
1158 public void setSpdHdrOutDir(String outdir
) {
1159 if (outdir
== null) {
1162 if (getSpdHdrOutDir() != null) {
1163 getSpdHdrOutDir().setStringValue(outdir
);
1165 spdHdrOutDir
= getSpdHdr().addNewOutputDirectory();
1166 spdHdrOutDir
.setStringValue(outdir
);
1171 Get PackageName element under SpdHdr
1173 @return PackageNameDocument.PackageName
1175 public PackageNameDocument
.PackageName
getSpdHdrPkgName() {
1176 if (spdHdrPkgName
== null) {
1177 spdHdrPkgName
= getSpdHdr().getPackageName();
1179 return spdHdrPkgName
;
1183 Set value to PackageName element
1185 @param pkgName The value set to PackageName element
1187 public void setSpdHdrPkgName(String pkgName
) {
1189 if (getSpdHdrPkgName() != null) {
1190 getSpdHdrPkgName().setStringValue(pkgName
);
1192 spdHdrPkgName
= getSpdHdr().addNewPackageName();
1193 spdHdrPkgName
.setStringValue(pkgName
);
1200 @return SpecificationDocument.Specification
1202 public SpecificationDocument
.Specification
getSpdHdrSpec() {
1211 public void setSpdHdrSpec(String spec
) {
1215 if (getSpdHdrSpec() != null) {
1216 getSpdHdrSpec().setStringValue(spec
);
1218 spdHdrSpec
= getSpdHdr().addNewSpecification();
1219 spdHdrSpec
.setStringValue(spec
);
1224 Set value to PackageType element
1226 @param pkgType The value set to PackageType element
1228 public void setSpdHdrPkgType(String pkgType
) {
1229 getSpdHdr().setPackageType(PackageType
.Enum
.forString(pkgType
));
1233 Set value to ReadOnly element
1235 @param rdOnly The value set to ReadOnly element
1237 public void setSpdHdrRdOnly(String rdOnly
) {
1239 getSpdHdr().setReadOnly(new Boolean(rdOnly
));
1243 Set value to RePackage element
1245 @param rePkg The value set to RePackage element
1247 public void setSpdHdrRePkg(String rePkg
) {
1249 getSpdHdr().setRePackage(new Boolean(rePkg
));
1253 Set value to Updated element
1255 @param updateDate The value set to Updated element
1257 public void setSpdHdrUpdateDate(String updateDate
) {
1258 getSpdHdr().setUpdated(updateDate
);
1262 Set value to URL element
1264 @param url The value set to URL element
1266 public void setSpdHdrURL(String url
) {
1267 getSpdHdr().setURL(url
);
1275 public File
getFile() {
1282 @param file File with xml format
1284 public void setFile(File file
) {