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