]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PackageEditor/src/org/tianocore/packaging/SpdFileContents.java
17a5a0cdb73269d0781215247e0c8299e96b73c4
[mirror_edk2.git] / Tools / Source / PackageEditor / src / org / tianocore / packaging / SpdFileContents.java
1 /** @file
2 Java class SpdFileContents is used to parse spd xml file.
3
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
9
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.
12 **/
13 package org.tianocore.packaging;
14
15 import java.io.File;
16 import java.io.IOException;
17 import java.util.List;
18 import java.util.ListIterator;
19
20 import org.apache.xmlbeans.XmlObject;
21 import org.apache.xmlbeans.XmlOptions;
22 import org.apache.xmlbeans.XmlCursor;
23
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;
50
51 /**
52 This class processes spd file contents such as add remove xml elements.
53
54 @since PackageEditor 1.0
55 **/
56 public class SpdFileContents {
57
58 private File file = null;
59
60 private PackageSurfaceAreaDocument psad = null;
61
62 private PackageSurfaceAreaDocument.PackageSurfaceArea psaRoot = null;
63
64 private SpdHeaderDocument.SpdHeader spdHdr = null;
65
66 private PackageNameDocument.PackageName spdHdrPkgName = null;
67
68 private GuidDocument.Guid spdHdrGuid = null;
69
70 private AbstractDocument.Abstract spdHdrAbs = null;
71
72 private LicenseDocument.License spdHdrLicense = null;
73
74 private SpecificationDocument.Specification spdHdrSpec = null;
75
76 private OutputDirectoryDocument.OutputDirectory spdHdrOutDir = null;
77
78 private LibraryClassDeclarationsDocument.LibraryClassDeclarations spdLibClassDeclarations = null;
79
80 private PackageDependenciesDocument.PackageDependencies spdPkgDeps = null;
81
82 private MsaFilesDocument.MsaFiles spdMsaFiles = null;
83
84 private PackageHeadersDocument.PackageHeaders spdModHdrs = null;
85
86 private GuidDeclarationsDocument.GuidDeclarations spdGuidDeclarations = null;
87
88 private ProtocolDeclarationsDocument.ProtocolDeclarations spdProtocolDeclarations = null;
89
90 private PpiDeclarationsDocument.PpiDeclarations spdPpiDeclarations = null;
91
92 private PcdDefinitionsDocument.PcdDefinitions spdPcdDefinitions = null;
93
94 /**
95 Constructor to create a new spd file
96 **/
97 public SpdFileContents() {
98
99 psad = PackageSurfaceAreaDocument.Factory.newInstance();
100 psaRoot = psad.addNewPackageSurfaceArea();
101
102 }
103
104 /**
105 Constructor based on an existing spd file
106
107 @param f Existing spd file
108 **/
109 public SpdFileContents(File f) {
110 try {
111 psad = PackageSurfaceAreaDocument.Factory.parse(f);
112 psaRoot = psad.getPackageSurfaceArea();
113 file = f;
114 } catch (Exception e) {
115 System.out.println(e.toString());
116 }
117 }
118
119 /**
120 Remove existing pcd definitions elements using XmlCursor
121 **/
122 public void removeSpdPcdDefinition() {
123 XmlObject o = psaRoot.getPcdDefinitions();
124 if (o == null)
125 return;
126 XmlCursor cursor = o.newCursor();
127 cursor.removeXml();
128 spdPcdDefinitions = null;
129 }
130
131 /**
132 Remove existing ppi declarations using XmlCursor
133 **/
134 public void removeSpdPpiDeclaration() {
135 XmlObject o = psaRoot.getPpiDeclarations();
136 if (o == null)
137 return;
138 XmlCursor cursor = o.newCursor();
139 cursor.removeXml();
140 spdPpiDeclarations = null;
141 }
142
143 /**
144 Remove existing protocols declarations using XmlCursor
145 **/
146 public void removeSpdProtocolDeclaration() {
147 XmlObject o = psaRoot.getProtocolDeclarations();
148 if (o == null)
149 return;
150 XmlCursor cursor = o.newCursor();
151 cursor.removeXml();
152 spdProtocolDeclarations = null;
153 }
154
155 /**
156 Remove existing GUID declarations using XmlCursor
157 **/
158 public void removeSpdGuidDeclaration() {
159 XmlObject o = psaRoot.getGuidDeclarations();
160 if (o == null)
161 return;
162 XmlCursor cursor = o.newCursor();
163 cursor.removeXml();
164 spdGuidDeclarations = null;
165 }
166
167 /**
168 Remove existing spd package include files using XmlCursor
169 **/
170 public void removeSpdPkgHeader() {
171 XmlObject o = psaRoot.getPackageHeaders();
172 if (o == null)
173 return;
174 XmlCursor cursor = o.newCursor();
175 cursor.removeXml();
176 spdModHdrs = null;
177 }
178
179 /**
180 Remove existing msa files using XmlCursor
181 **/
182 public void removeSpdMsaFile() {
183 XmlObject o = psaRoot.getMsaFiles();
184 if (o == null)
185 return;
186 XmlCursor cursor = o.newCursor();
187 cursor.removeXml();
188 spdMsaFiles = null;
189 }
190
191 /**
192 Remove existing library class declarations using XmlCursor
193 **/
194 public void removeSpdLibClass() {
195 XmlObject o = psaRoot.getLibraryClassDeclarations();
196 if (o == null)
197 return;
198 XmlCursor cursor = o.newCursor();
199 cursor.removeXml();
200 spdLibClassDeclarations = null;
201 }
202
203 /**
204 Get spd file header contents into String array
205
206 @param s Caller allocated String array
207 **/
208 public void getSpdHdrDetails(String[] s) {
209 if (getSpdHdr() == null) {
210 spdHdr = psaRoot.addNewSpdHeader();
211 }
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();
223 }
224 //
225 // convert boolean to String by adding empty String ""
226 //
227 s[10] = getSpdHdr().getReadOnly() + "";
228 s[11] = getSpdHdr().getReadOnly() + "";
229 }
230
231 /**
232 Get the number of library class declarations from the size of List
233
234 @return int
235 **/
236 public int getSpdLibClassDeclarationCount() {
237 if (psaRoot.getLibraryClassDeclarations() == null
238 || psaRoot.getLibraryClassDeclarations().getLibraryClassDeclarationList() == null) {
239 return 0;
240 }
241 return psaRoot.getLibraryClassDeclarations().getLibraryClassDeclarationList().size();
242 }
243
244 /**
245 Get available library class declaration into String array
246 @param libClass Caller allocated two-dimentional String array
247 **/
248 public void getSpdLibClassDeclarations(String[][] libClass) {
249 List<LibraryClassDeclarationDocument.LibraryClassDeclaration> l = psaRoot.getLibraryClassDeclarations()
250 .getLibraryClassDeclarationList();
251 int i = 0;
252 ListIterator li = l.listIterator();
253 while (li.hasNext()) {
254 LibraryClassDeclarationDocument.LibraryClassDeclaration lcd = (LibraryClassDeclarationDocument.LibraryClassDeclaration) li
255 .next();
256 if (lcd.getLibraryClass() != null) {
257 libClass[i][0] = lcd.getLibraryClass().getStringValue();
258 }
259 if (lcd.getIncludeHeader() != null) {
260 libClass[i][1] = lcd.getIncludeHeader().getStringValue();
261 }
262
263 i++;
264 }
265
266 }
267
268 /**
269 Get the number of Msa files from the size of List
270
271 @return int
272 **/
273 public int getSpdMsaFileCount() {
274 if (psaRoot.getMsaFiles() == null || psaRoot.getMsaFiles().getMsaFileList() == null) {
275 return 0;
276 }
277 return psaRoot.getMsaFiles().getMsaFileList().size();
278 }
279
280 /**
281 Get available Msa file into String array
282
283 @param msaFile Caller allocated two-dimentional String array
284 **/
285 public void getSpdMsaFiles(String[][] msaFile) {
286 List<MsaFilesDocument.MsaFiles.MsaFile> l = psaRoot.getMsaFiles().getMsaFileList();
287 int i = 0;
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();
293 }
294
295 i++;
296 }
297 }
298
299 /**
300 Get the number of include header files in PackageHeaders from the size of List
301
302 @return int
303 **/
304 public int getSpdPackageHeaderCount() {
305 if (psaRoot.getPackageHeaders() == null || psaRoot.getPackageHeaders().getIncludeHeaderList() == null) {
306 return 0;
307 }
308 return psaRoot.getPackageHeaders().getIncludeHeaderList().size();
309 }
310
311 /**
312 Get available package header contents into String array
313
314 @param pkgHeader Caller allocated two-dimentional String array
315 **/
316 public void getSpdPackageHeaders(String[][] pkgHeader) {
317 List<IncludeHeaderDocument.IncludeHeader> l = psaRoot.getPackageHeaders().getIncludeHeaderList();
318 int i = 0;
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();
324 }
325
326 pkgHeader[i][1] = ih.getStringValue();
327 i++;
328 }
329 }
330
331 /**
332 Get the number of GUID declarations from the size of List
333
334 @return int
335 **/
336 public int getSpdGuidDeclarationCount() {
337 if (psaRoot.getGuidDeclarations() == null || psaRoot.getGuidDeclarations().getEntryList() == null) {
338 return 0;
339 }
340 return psaRoot.getGuidDeclarations().getEntryList().size();
341 }
342
343 /**
344 Get available Guid declaration contents into String array
345
346 @param guid Caller allocated two-dimentional String array
347 **/
348 public void getSpdGuidDeclarations(String[][] guid) {
349 List<GuidDeclarationsDocument.GuidDeclarations.Entry> l = psaRoot.getGuidDeclarations().getEntryList();
350 int i = 0;
351 ListIterator li = l.listIterator();
352 while (li.hasNext()) {
353 GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.Entry) li
354 .next();
355 guid[i][0] = e.getName();
356 guid[i][1] = e.getCName();
357 if (e.getGuid() != null) {
358 guid[i][2] = e.getGuid().getStringValue();
359 }
360 i++;
361 }
362 }
363
364 /**
365 Get the number of protocol declarations from the size of List
366
367 @return int
368 **/
369 public int getSpdProtocolDeclarationCount() {
370 if (psaRoot.getProtocolDeclarations() == null || psaRoot.getProtocolDeclarations().getEntryList() == null) {
371 return 0;
372 }
373 return psaRoot.getProtocolDeclarations().getEntryList().size();
374 }
375
376 /**
377 Get available protocol declaration contents into String array
378
379 @param protocol Caller allocated two-dimentional String array
380 **/
381 public void getSpdProtocolDeclarations(String[][] protocol) {
382 List<ProtocolDeclarationsDocument.ProtocolDeclarations.Entry> l = psaRoot.getProtocolDeclarations()
383 .getEntryList();
384 int i = 0;
385 ListIterator li = l.listIterator();
386 while (li.hasNext()) {
387 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) li
388 .next();
389 protocol[i][0] = e.getName();
390 protocol[i][1] = e.getCName();
391 if (e.getGuid() != null) {
392 protocol[i][2] = e.getGuid().getStringValue();
393 }
394 i++;
395 }
396 }
397
398 /**
399 Get the number of Ppi declarations from the size of List
400
401 @return int
402 **/
403 public int getSpdPpiDeclarationCount() {
404 if (psaRoot.getPpiDeclarations() == null || psaRoot.getPpiDeclarations().getEntryList() == null) {
405 return 0;
406 }
407 return psaRoot.getPpiDeclarations().getEntryList().size();
408 }
409
410 /**
411 Get available Ppi declaration contents into String array
412
413 @param ppi Caller allocated two-dimentional String array
414 **/
415 public void getSpdPpiDeclarations(String[][] ppi) {
416 List<PpiDeclarationsDocument.PpiDeclarations.Entry> l = psaRoot.getPpiDeclarations().getEntryList();
417 int i = 0;
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();
425 }
426
427 i++;
428 }
429 }
430
431 /**
432 Get the number of Pcd definitions from the size of List
433
434 @return int
435 **/
436 public int getSpdPcdDefinitionCount() {
437 if (psaRoot.getPcdDefinitions() == null || psaRoot.getPcdDefinitions().getPcdEntryList() == null) {
438 return 0;
439 }
440 return psaRoot.getPcdDefinitions().getPcdEntryList().size();
441 }
442
443 /**
444 Get available Pcd definition contents into String array
445
446 @param pcd Caller allocated two-dimentional String array
447 **/
448 public void getSpdPcdDefinitions(String[][] pcd) {
449 List<PcdDefinitionsDocument.PcdDefinitions.PcdEntry> l = psaRoot.getPcdDefinitions().getPcdEntryList();
450 int i = 0;
451 ListIterator li = l.listIterator();
452 while (li.hasNext()) {
453 PcdDefinitionsDocument.PcdDefinitions.PcdEntry e = (PcdDefinitionsDocument.PcdDefinitions.PcdEntry) li
454 .next();
455 if (e.getItemType() != null) {
456 pcd[i][0] = e.getItemType().toString();
457 }
458
459 pcd[i][1] = e.getCName();
460 pcd[i][2] = e.getToken();
461 if (e.getDatumType() != null) {
462 pcd[i][3] = e.getDatumType().toString();
463 }
464
465 if (e.getDefaultValue() != null) {
466 pcd[i][4] = e.getDefaultValue().toString();
467 }
468
469 i++;
470 }
471 }
472
473 /**
474 Save the processed xml contents to file
475
476 @param spdFile The file to save xml contents
477 @throws IOException Exceptions during file operation
478 **/
479 public void saveAs(File spdFile) throws IOException {
480
481 XmlOptions options = new XmlOptions();
482
483 options.setCharacterEncoding("UTF-8");
484 options.setSavePrettyPrint();
485 options.setSavePrettyPrintIndent(2);
486 try {
487 psad.save(spdFile, options);
488 } catch (IOException e) {
489 e.printStackTrace();
490 }
491
492 }
493
494 /**
495 Generate SpdHeader contents using parameters passed in.
496
497 @param pkgName PackageName
498 @param pkgGuid Guid
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
506 @param pkgURL URL
507 @param pkgType PackageType
508 @param pkgRdOnly ReadOnly
509 @param pkgRePkg RePackage
510 @param pkgSpec Reserved
511 @param pkgOutDir Reserved
512 **/
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,
516 String pkgOutDir) {
517 if (getSpdHdr() == null) {
518 spdHdr = psaRoot.addNewSpdHeader();
519 }
520
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);
536 }
537
538 /**
539 Generate library class declaration element using parameters passed in
540
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
551 **/
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();
558 }
559 //
560 // add contents under LibraryClassDeclarations tag
561 //
562 setSpdLibClassDeclaration(libClassBaseName, libClassUsage, incHdrFileName, incHdrAttribGuid, incHdrAttribArch,
563 incHdrAttribPath, incHdrAttribClass, incHdrAttribVer, incHdrAttribOverrideID,
564 incHdrAttribModuleType, spdLibClassDeclarations);
565 }
566
567 /**
568 Set library class declaration contents under parent tag
569
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
581 **/
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,
585 XmlObject parent) {
586
587 LibraryClassDeclarationDocument.LibraryClassDeclaration lcd = ((LibraryClassDeclarationsDocument.LibraryClassDeclarations) parent)
588 .addNewLibraryClassDeclaration();
589
590 setSpdLibraryClass(clsName, clsUsage, lcd);
591
592 setSpdIncludeHeader(null, hdrFile, hdrAttribGuid, hdrAttribArch, hdrAttribPath, hdrAttribClass, hdrAttribVer,
593 hdrAttribOverID, lcd);
594 }
595
596 /**
597 Set the contents of LibraryClass under parent element
598
599 @param clsName LibraryClass element value
600 @param clsUsage Reserved
601 @param parent The tag under which library class declaration goes to
602 **/
603 public void setSpdLibraryClass(String clsName, String clsUsage, XmlObject parent) {
604 LibraryClassDeclarationDocument.LibraryClassDeclaration.LibraryClass lc = ((LibraryClassDeclarationDocument.LibraryClassDeclaration) parent).addNewLibraryClass();
605 lc.setStringValue(clsName);
606 }
607
608 /**
609 Set contents of IncludeHeader under parent element
610
611 @param modType Reserved
612 @param hdrFile IncludeHeader element value
613 @param hdrAttribGuid Reserved
614 @param hdrAttribArch Reserved
615 @param hdrAttribPath Reserved
616 @param hdrAttribClass Reserved
617 @param hdrAttribVer Reserved
618 @param hdrAttribOverID Reserved
619 @param parent The tag under which library class declaration goes to
620 **/
621 public void setSpdIncludeHeader(String modType, String hdrFile, String hdrAttribGuid, String hdrAttribArch,
622 String hdrAttribPath, String hdrAttribClass, String hdrAttribVer,
623 String hdrAttribOverID, XmlObject parent) {
624 IncludeHeaderDocument.IncludeHeader ih = null;
625 if (parent instanceof LibraryClassDeclarationDocument.LibraryClassDeclaration) {
626 ih = ((LibraryClassDeclarationDocument.LibraryClassDeclaration) parent).addNewIncludeHeader();
627 } else if (parent instanceof PackageHeadersDocument.PackageHeaders) {
628 ih = ((PackageHeadersDocument.PackageHeaders) parent).addNewIncludeHeader();
629 } else {
630 return;
631 }
632
633 ih.setStringValue(hdrFile);
634 if (hdrAttribGuid != null) {
635 ih.setGuid(hdrAttribGuid);
636 }
637 if (hdrAttribPath != null) {
638 ih.setPath(hdrAttribPath);
639 }
640 if (hdrAttribClass != null) {
641 ih.setClass1(hdrAttribClass);
642 }
643 if (hdrAttribVer != null) {
644 ih.setVersion(hdrAttribVer);
645 }
646 if (hdrAttribOverID != null) {
647 ih.setOverrideID(Integer.parseInt(hdrAttribOverID));
648 }
649 if (modType != null) {
650 ih.setModuleType(ModuleTypeDef.Enum.forString(modType));
651
652 }
653
654 }
655
656 /**
657 Reserved method
658
659 @param pkgDepPkgName
660 @param pkgDepPkgAttribGuid
661 @param pkgDepPkgAttribVer
662 @param pkgDepPkgAttribType
663 @param pkgDepPkgAttribUsage
664 @param pkgDepPkgAttribInstallDate
665 @param pkgDepPkgAttribUpdateDate
666 @param pkgDepPkgAttribPath
667 **/
668 public void genSpdPackageDependencies(String pkgDepPkgName, String pkgDepPkgAttribGuid, String pkgDepPkgAttribVer,
669 String pkgDepPkgAttribType, String pkgDepPkgAttribUsage,
670 String pkgDepPkgAttribInstallDate, String pkgDepPkgAttribUpdateDate,
671 String pkgDepPkgAttribPath) {
672 if (spdPkgDeps == null) {
673 spdPkgDeps = psaRoot.addNewPackageDependencies();
674 }
675
676 setSpdPackageName(pkgDepPkgName, pkgDepPkgAttribGuid, pkgDepPkgAttribVer, pkgDepPkgAttribType,
677 pkgDepPkgAttribUsage, pkgDepPkgAttribInstallDate, pkgDepPkgAttribUpdateDate,
678 pkgDepPkgAttribPath, spdPkgDeps);
679 }
680
681 /**
682 Reserved method
683
684 @param pkgName
685 @param pkgAttribGuid
686 @param pkgAttribVer
687 @param pkgAttribType
688 @param pkgAttribUsage
689 @param pkgAttribInstallDate
690 @param pkgAttribUpdateDate
691 @param pkgAttribPath
692 @param parent
693 **/
694 public void setSpdPackageName(String pkgName, String pkgAttribGuid, String pkgAttribVer, String pkgAttribType,
695 String pkgAttribUsage, String pkgAttribInstallDate, String pkgAttribUpdateDate,
696 String pkgAttribPath, XmlObject parent) {
697
698 PackageNameDocument.PackageName pn = ((PackageDependenciesDocument.PackageDependencies) parent)
699 .addNewPackageName();
700 pn.setStringValue(pkgName);
701 pn.setPackageType(PackageType.Enum.forString(pkgAttribType));
702 pn.setUsage(PackageUsage.Enum.forString(pkgAttribUsage));
703 pn.setUpdatedDate(pkgAttribUpdateDate);
704 }
705
706 /**
707 Generate MsaFile element.
708
709 @param msaFileName MsaFile element value
710 @param archType Reserved
711 **/
712 public void genSpdMsaFiles(String msaFileName, String archType) {
713 if (getSpdMsaFiles() == null) {
714 spdMsaFiles = psaRoot.addNewMsaFiles();
715 }
716 setSpdMsaFile(msaFileName, spdMsaFiles);
717
718 }
719
720 /**
721 Set MsaFile contents under parent element.
722
723 @param msaFileName MsaFile element value
724 @param parent Element under which MsaFile goes to
725 **/
726 public void setSpdMsaFile(String msaFileName, XmlObject parent) {
727
728 ((MsaFilesDocument.MsaFiles) parent).addNewMsaFile().addNewFilename().setStringValue(msaFileName);
729 }
730
731 /**
732 Generate PackageHeader element using parameters passed in.
733
734 @param ModHdrModType ModuleType attribute of IncludeHeader element
735 @param hdrFile IncludeHeader element value
736 @param hdrAttribGuid Reserved
737 @param hdrAttribArch Reserved
738 @param hdrAttribPath Reserved
739 @param hdrAttribClass Reserved
740 @param hdrAttribVer Reserved
741 @param hdrAttribOverID Reserved
742 **/
743 public void genSpdModuleHeaders(String ModHdrModType, String hdrFile, String hdrAttribGuid, String hdrAttribArch,
744 String hdrAttribPath, String hdrAttribClass, String hdrAttribVer,
745 String hdrAttribOverID) {
746 if (getSpdModHdrs() == null) {
747 spdModHdrs = psaRoot.addNewPackageHeaders();
748 }
749
750 //
751 // add IncludeHeader under PackageHeaders element
752 //
753 setSpdIncludeHeader(ModHdrModType, hdrFile, hdrAttribGuid, hdrAttribArch, hdrAttribPath, hdrAttribClass,
754 hdrAttribVer, hdrAttribOverID, spdModHdrs);
755 }
756
757 /**
758 Generate GUID declaration element using parameters passed in.
759
760 @param guidDeclEntryName Name attribute of Entry element
761 @param guidDeclCName CName element value
762 @param guidDeclGuid Guid element value
763 @param guidDeclFeatureFlag Reserved
764 **/
765 public void genSpdGuidDeclarations(String guidDeclEntryName, String guidDeclCName, String guidDeclGuid,
766 String guidDeclFeatureFlag) {
767 if (getSpdGuidDeclarations() == null) {
768 spdGuidDeclarations = psaRoot.addNewGuidDeclarations();
769 }
770
771 setSpdEntry(guidDeclEntryName, guidDeclCName, guidDeclGuid, guidDeclFeatureFlag, spdGuidDeclarations);
772 }
773
774 /**
775 Generate protocol declaration element using parameters passed in.
776
777 @param protocolDeclEntryName Name attribute of Entry element
778 @param protocolDeclCName CName element value
779 @param protocolDeclGuid Guid element value
780 @param protocolDeclFeatureFlag Reserved
781 **/
782 public void genSpdProtocolDeclarations(String protocolDeclEntryName, String protocolDeclCName,
783 String protocolDeclGuid, String protocolDeclFeatureFlag) {
784 if (getSpdProtocolDeclarations() == null) {
785 spdProtocolDeclarations = psaRoot.addNewProtocolDeclarations();
786 }
787
788 setSpdEntry(protocolDeclEntryName, protocolDeclCName, protocolDeclGuid, protocolDeclFeatureFlag,
789 spdProtocolDeclarations);
790 }
791
792 /**
793 Generate PPI declaration element using parameters passed in.
794
795 @param ppiDeclEntryName Name attribute of Entry element
796 @param ppiDeclCName CName element value
797 @param ppiDeclGuid Guid element value
798 @param ppiDeclFeatureFlag Reserved
799 **/
800 public void genSpdPpiDeclarations(String ppiDeclEntryName, String ppiDeclCName, String ppiDeclGuid,
801 String ppiDeclFeatureFlag) {
802 if (getSpdPpiDeclarations() == null) {
803 spdPpiDeclarations = psaRoot.addNewPpiDeclarations();
804 }
805
806 setSpdEntry(ppiDeclEntryName, ppiDeclCName, ppiDeclGuid, ppiDeclFeatureFlag, spdPpiDeclarations);
807 }
808
809 /**
810 Set Entry contents using parameters passed in
811
812 @param entryName Name attribute of Entry element
813 @param cName CName element value
814 @param guid Guid element value
815 @param featureFlag Reserved
816 @param parent The tag under which Entry element goes to
817 **/
818 public void setSpdEntry(String entryName, String cName, String guid, String featureFlag, XmlObject parent) {
819
820 if (parent instanceof GuidDeclarationsDocument.GuidDeclarations) {
821 GuidDeclarationsDocument.GuidDeclarations.Entry e = ((GuidDeclarations) parent).addNewEntry();
822 e.setName(entryName);
823 e.setCName(cName);
824 e.addNewGuid().setStringValue(guid);
825 if (featureFlag != null) {
826 e.addNewFeatureFlag().setStringValue(featureFlag);
827 }
828 return;
829 }
830 if (parent instanceof ProtocolDeclarationsDocument.ProtocolDeclarations) {
831 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry pe = ((ProtocolDeclarationsDocument.ProtocolDeclarations) parent)
832 .addNewEntry();
833 pe.setName(entryName);
834 pe.setCName(cName);
835 pe.addNewGuid().setStringValue(guid);
836 if (featureFlag != null) {
837 pe.addNewFeatureFlag().setStringValue(featureFlag);
838 }
839 return;
840 }
841 if (parent instanceof PpiDeclarationsDocument.PpiDeclarations) {
842 PpiDeclarationsDocument.PpiDeclarations.Entry ppe = ((PpiDeclarationsDocument.PpiDeclarations) parent)
843 .addNewEntry();
844 ppe.setName(entryName);
845 ppe.setCName(cName);
846 ppe.addNewGuid().setStringValue(guid);
847 if (featureFlag != null) {
848 ppe.addNewFeatureFlag().setStringValue(featureFlag);
849 }
850 return;
851 }
852
853 return;
854
855 }
856
857 /**
858 Generate Pcd definition using parameters passed in
859
860 @param pcdItemTypes ItemType attribute of PcdEntry element
861 @param cName C_Name element value
862 @param token Token element value
863 @param dataType DatumType element value
864 @param skuEnable Reserved
865 @param sku Reserved
866 @param maxSku Reserved
867 @param hiiEnable Reserved
868 @param varGuid Reserved
869 @param varName Reserved
870 @param defaultString DefaultString element value
871 **/
872 public void genSpdPcdDefinitions(String pcdItemTypes, String cName, String token, String dataType,
873 String skuEnable, String sku, String maxSku, String hiiEnable, String varGuid,
874 String varName, String defaultString) {
875 if (getSpdPcdDefinitions() == null) {
876 spdPcdDefinitions = psaRoot.addNewPcdDefinitions();
877 }
878
879 setSpdPcdEntry(pcdItemTypes, cName, token, dataType, skuEnable, sku, maxSku, hiiEnable, varGuid, varName,
880 defaultString, spdPcdDefinitions);
881 }
882
883 /**
884 Set Pcd entry contents under parent tag
885
886 @param pcdItemTypes ItemType attribute of PcdEntry element
887 @param cName C_Name element value
888 @param token Token element value
889 @param dataType DatumType element value
890 @param skuEnable Reserved
891 @param sku Reserved
892 @param maxSku Reserved
893 @param hiiEnable Reserved
894 @param varGuid Reserved
895 @param varName Reserved
896 @param defaultString DefaultString element value
897 @param parent Tag under which PcdEntry goes to
898 **/
899 public void setSpdPcdEntry(String pcdItemTypes, String cName, String token, String dataType, String skuEnable,
900 String sku, String maxSku, String hiiEnable, String varGuid, String varName,
901 String defaultString, XmlObject parent) {
902
903 PcdDefinitionsDocument.PcdDefinitions.PcdEntry pe = ((PcdDefinitionsDocument.PcdDefinitions) parent)
904 .addNewPcdEntry();
905 pe.setItemType(PcdItemTypes.Enum.forString(pcdItemTypes));
906 pe.setCName(cName);
907 pe.setToken(token);
908 pe.setDatumType(PcdDataTypes.Enum.forString(dataType));
909 pe.setDefaultValue(defaultString);
910
911 }
912
913 /**
914 Get PpiDeclarations element
915
916 @return PpiDeclarationsDocument.PpiDeclarations
917 **/
918 public PpiDeclarationsDocument.PpiDeclarations getSpdPpiDeclarations() {
919 if (spdPpiDeclarations == null) {
920 spdPpiDeclarations = psaRoot.getPpiDeclarations();
921 }
922 return spdPpiDeclarations;
923 }
924
925 /**
926 Get ProtocolDeclarations element
927
928 @return ProtocolDeclarationsDocument.ProtocolDeclarations
929 **/
930 public ProtocolDeclarationsDocument.ProtocolDeclarations getSpdProtocolDeclarations() {
931 if (spdProtocolDeclarations == null) {
932 spdProtocolDeclarations = psaRoot.getProtocolDeclarations();
933 }
934 return spdProtocolDeclarations;
935 }
936
937 /**
938 Get GuidDeclarations element
939
940 @return GuidDeclarationsDocument.GuidDeclarations
941 **/
942 public GuidDeclarationsDocument.GuidDeclarations getSpdGuidDeclarations() {
943 if (spdGuidDeclarations == null) {
944 spdGuidDeclarations = psaRoot.getGuidDeclarations();
945 }
946 return spdGuidDeclarations;
947 }
948
949 /**
950 Get PcdDefinitions element
951
952 @return PcdDefinitionsDocument.PcdDefinitions
953 **/
954 public PcdDefinitionsDocument.PcdDefinitions getSpdPcdDefinitions() {
955 if (spdPcdDefinitions == null) {
956 spdPcdDefinitions = psaRoot.getPcdDefinitions();
957 }
958 return spdPcdDefinitions;
959 }
960
961 /**
962 Get PackageHeaders element
963
964 @return PackageHeadersDocument.PackageHeaders
965 **/
966 public PackageHeadersDocument.PackageHeaders getSpdModHdrs() {
967 if (spdModHdrs == null) {
968 spdModHdrs = psaRoot.getPackageHeaders();
969 }
970 return spdModHdrs;
971 }
972
973 /**
974 Get MsaFiles element
975
976 @return MsaFilesDocument.MsaFiles
977 **/
978 public MsaFilesDocument.MsaFiles getSpdMsaFiles() {
979 if (spdMsaFiles == null) {
980 spdMsaFiles = psaRoot.getMsaFiles();
981 }
982 return spdMsaFiles;
983 }
984
985 /**
986 Get LibraryClassDeclarations element
987
988 @return LibraryClassDeclarationsDocument.LibraryClassDeclarations
989 **/
990 public LibraryClassDeclarationsDocument.LibraryClassDeclarations getSpdLibClassDeclarations() {
991 if (spdLibClassDeclarations == null) {
992 spdLibClassDeclarations = psaRoot.getLibraryClassDeclarations();
993 }
994 return spdLibClassDeclarations;
995 }
996
997 /**
998 Get SpdHeader element
999
1000 @return SpdHeaderDocument.SpdHeader
1001 **/
1002 public SpdHeaderDocument.SpdHeader getSpdHdr() {
1003 if (spdHdr == null) {
1004 spdHdr = psaRoot.getSpdHeader();
1005 }
1006 return spdHdr;
1007 }
1008
1009 /**
1010 Get Abstract element under tag SpdHeader
1011
1012 @return AbstractDocument.Abstract
1013 **/
1014 public AbstractDocument.Abstract getSpdHdrAbs() {
1015 if (spdHdrAbs == null) {
1016 spdHdrAbs = getSpdHdr().getAbstract();
1017 }
1018 return spdHdrAbs;
1019 }
1020
1021 /**
1022 Set value to Abstract element
1023
1024 @param abs The value set to Abstract element
1025 **/
1026 public void setSpdHdrAbs(String abs) {
1027
1028 if (getSpdHdrAbs() != null) {
1029 getSpdHdrAbs().setStringValue(abs);
1030 } else {
1031 spdHdrAbs = getSpdHdr().addNewAbstract();
1032 spdHdrAbs.setStringValue(abs);
1033 }
1034 }
1035
1036 /**
1037 Set value to Copyright element
1038
1039 @param cpRit The value set to Copyright element
1040 **/
1041 public void setSpdHdrCpRit(String cpRit) {
1042
1043 getSpdHdr().setCopyright(cpRit);
1044
1045 }
1046
1047 /**
1048 Set value to Created element
1049
1050 @param createDate The value set to Created element
1051 **/
1052 public void setSpdHdrCreateDate(String createDate) {
1053
1054 getSpdHdr().setCreated(createDate);
1055
1056 }
1057
1058 /**
1059 Set value to Description element
1060
1061 @param des The value set to Description element
1062 **/
1063 public void setSpdHdrDes(String des) {
1064 getSpdHdr().setDescription(des);
1065 }
1066
1067 /**
1068 Get Guid element under SpdHdr
1069
1070 @return GuidDocument.Guid
1071 **/
1072 public GuidDocument.Guid getSpdHdrGuid() {
1073 if (spdHdrGuid == null) {
1074 spdHdrGuid = getSpdHdr().getGuid();
1075 }
1076 return spdHdrGuid;
1077 }
1078
1079 /**
1080 Set value to Guid element
1081
1082 @param guid The value set to Guid element
1083 **/
1084 public void setSpdHdrGuid(String guid) {
1085 if (getSpdHdrGuid() != null) {
1086 getSpdHdrGuid().setStringValue(guid);
1087 } else {
1088 spdHdrGuid = getSpdHdr().addNewGuid();
1089 spdHdrGuid.setStringValue(guid);
1090 }
1091 }
1092
1093 /**
1094 Get Version element under SpdHdr
1095
1096 @return String
1097 **/
1098 public String getSpdHdrVer() {
1099 if (spdHdr != null)
1100 return spdHdr.getVersion();
1101 else
1102 return null;
1103 }
1104
1105 /**
1106 Set value to Version element
1107
1108 @param ver The value set to Version element
1109 **/
1110 public void setSpdHdrVer(String ver) {
1111 if (spdHdr != null) {
1112 spdHdr.setVersion(ver);
1113 }
1114
1115 }
1116
1117 /**
1118 Get License element under SpdHdr
1119
1120 @return LicenseDocument.License
1121 **/
1122 public LicenseDocument.License getSpdHdrLicense() {
1123 if (spdHdrLicense == null) {
1124 spdHdrLicense = getSpdHdr().getLicense();
1125 }
1126 return spdHdrLicense;
1127 }
1128
1129 /**
1130 Set value to License element
1131
1132 @param license The value set to License element
1133 **/
1134 public void setSpdHdrLicense(String license) {
1135 if (getSpdHdrLicense() != null) {
1136 getSpdHdrLicense().setStringValue(license);
1137 } else {
1138 spdHdrLicense = getSpdHdr().addNewLicense();
1139 spdHdrLicense.setStringValue(license);
1140 }
1141 }
1142
1143 /**
1144 Reserved method
1145
1146 @return
1147 **/
1148 public OutputDirectoryDocument.OutputDirectory getSpdHdrOutDir() {
1149 return spdHdrOutDir;
1150 }
1151
1152 /**
1153 Reserved method
1154
1155 @param outdir
1156 **/
1157 public void setSpdHdrOutDir(String outdir) {
1158 if (outdir == null) {
1159 return;
1160 }
1161 if (getSpdHdrOutDir() != null) {
1162 getSpdHdrOutDir().setStringValue(outdir);
1163 } else {
1164 spdHdrOutDir = getSpdHdr().addNewOutputDirectory();
1165 spdHdrOutDir.setStringValue(outdir);
1166 }
1167 }
1168
1169 /**
1170 Get PackageName element under SpdHdr
1171
1172 @return PackageNameDocument.PackageName
1173 **/
1174 public PackageNameDocument.PackageName getSpdHdrPkgName() {
1175 if (spdHdrPkgName == null) {
1176 spdHdrPkgName = getSpdHdr().getPackageName();
1177 }
1178 return spdHdrPkgName;
1179 }
1180
1181 /**
1182 Set value to PackageName element
1183
1184 @param pkgName The value set to PackageName element
1185 **/
1186 public void setSpdHdrPkgName(String pkgName) {
1187
1188 if (getSpdHdrPkgName() != null) {
1189 getSpdHdrPkgName().setStringValue(pkgName);
1190 } else {
1191 spdHdrPkgName = getSpdHdr().addNewPackageName();
1192 spdHdrPkgName.setStringValue(pkgName);
1193 }
1194 }
1195
1196 /**
1197 Reserved method
1198
1199 @return SpecificationDocument.Specification
1200 **/
1201 public SpecificationDocument.Specification getSpdHdrSpec() {
1202 return spdHdrSpec;
1203 }
1204
1205 /**
1206 Reserved method
1207
1208 @param spec
1209 **/
1210 public void setSpdHdrSpec(String spec) {
1211 if (spec == null) {
1212 return;
1213 }
1214 if (getSpdHdrSpec() != null) {
1215 getSpdHdrSpec().setStringValue(spec);
1216 } else {
1217 spdHdrSpec = getSpdHdr().addNewSpecification();
1218 spdHdrSpec.setStringValue(spec);
1219 }
1220 }
1221
1222 /**
1223 Set value to PackageType element
1224
1225 @param pkgType The value set to PackageType element
1226 **/
1227 public void setSpdHdrPkgType(String pkgType) {
1228 getSpdHdr().setPackageType(PackageType.Enum.forString(pkgType));
1229 }
1230
1231 /**
1232 Set value to ReadOnly element
1233
1234 @param rdOnly The value set to ReadOnly element
1235 **/
1236 public void setSpdHdrRdOnly(String rdOnly) {
1237
1238 getSpdHdr().setReadOnly(new Boolean(rdOnly));
1239 }
1240
1241 /**
1242 Set value to RePackage element
1243
1244 @param rePkg The value set to RePackage element
1245 **/
1246 public void setSpdHdrRePkg(String rePkg) {
1247
1248 getSpdHdr().setRePackage(new Boolean(rePkg));
1249 }
1250
1251 /**
1252 Set value to Updated element
1253
1254 @param updateDate The value set to Updated element
1255 **/
1256 public void setSpdHdrUpdateDate(String updateDate) {
1257 getSpdHdr().setUpdated(updateDate);
1258 }
1259
1260 /**
1261 Set value to URL element
1262
1263 @param url The value set to URL element
1264 **/
1265 public void setSpdHdrURL(String url) {
1266 getSpdHdr().setURL(url);
1267 }
1268
1269 /**
1270 Get xml file
1271
1272 @return File
1273 **/
1274 public File getFile() {
1275 return file;
1276 }
1277
1278 /**
1279 Set file
1280
1281 @param file File with xml format
1282 **/
1283 public void setFile(File file) {
1284 this.file = file;
1285 }
1286
1287 }