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