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