]>
Commit | Line | Data |
---|---|---|
a13899c5 | 1 | /** @file\r |
2 | Java class FpdFileContents is used to parse fpd xml file.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | **/\r | |
13 | package org.tianocore.frameworkwizard.platform.ui;\r | |
14 | \r | |
15 | import java.io.File;\r | |
16 | import java.io.IOException;\r | |
17 | import java.math.BigInteger;\r | |
18 | import java.util.ArrayList;\r | |
19 | import java.util.HashMap;\r | |
20 | import java.util.Iterator;\r | |
21 | import java.util.LinkedHashMap;\r | |
22 | import java.util.List;\r | |
23 | import java.util.ListIterator;\r | |
24 | import java.util.Map;\r | |
25 | import java.util.Set;\r | |
6a09eb19 | 26 | import java.util.Vector;\r |
a13899c5 | 27 | \r |
28 | import javax.xml.namespace.QName;\r | |
29 | \r | |
30 | import org.apache.xmlbeans.XmlCursor;\r | |
31 | import org.apache.xmlbeans.XmlObject;\r | |
32 | import org.apache.xmlbeans.XmlOptions;\r | |
33 | import org.tianocore.AntTaskDocument;\r | |
34 | import org.tianocore.BuildOptionsDocument;\r | |
35 | import org.tianocore.DynamicPcdBuildDefinitionsDocument;\r | |
6cba26e8 | 36 | import org.tianocore.EfiSectionType;\r |
a13899c5 | 37 | import org.tianocore.FlashDefinitionFileDocument;\r |
a13899c5 | 38 | import org.tianocore.FlashDocument;\r |
39 | import org.tianocore.FrameworkModulesDocument;\r | |
6a09eb19 | 40 | import org.tianocore.IntermediateOutputType;\r |
a13899c5 | 41 | import org.tianocore.LibrariesDocument;\r |
42 | import org.tianocore.ModuleSADocument;\r | |
43 | import org.tianocore.ModuleSurfaceAreaDocument;\r | |
44 | import org.tianocore.OptionDocument;\r | |
45 | import org.tianocore.OptionsDocument;\r | |
46 | import org.tianocore.PcdBuildDefinitionDocument;\r | |
47 | import org.tianocore.PcdCodedDocument;\r | |
48 | import org.tianocore.PcdDataTypes;\r | |
49 | import org.tianocore.PcdDeclarationsDocument;\r | |
50 | import org.tianocore.PcdItemTypes;\r | |
51 | import org.tianocore.PlatformDefinitionsDocument;\r | |
52 | import org.tianocore.PlatformSurfaceAreaDocument;\r | |
53 | import org.tianocore.FvImageTypes;\r | |
54 | import org.tianocore.FvImagesDocument;\r | |
55 | import org.tianocore.LicenseDocument;\r | |
56 | import org.tianocore.PlatformHeaderDocument;\r | |
57 | import org.tianocore.SkuInfoDocument;\r | |
58 | import org.tianocore.UserDefinedAntTasksDocument;\r | |
59 | import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;\r | |
60 | import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r | |
61 | import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;\r | |
62 | import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;\r | |
63 | \r | |
64 | /**\r | |
65 | This class processes fpd file contents such as add remove xml elements. \r | |
66 | @since PackageEditor 1.0\r | |
67 | **/\r | |
68 | public class FpdFileContents {\r | |
69 | \r | |
70 | static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0";\r | |
71 | \r | |
72 | private PlatformSurfaceAreaDocument fpdd = null;\r | |
73 | \r | |
74 | private PlatformSurfaceAreaDocument.PlatformSurfaceArea fpdRoot = null;\r | |
75 | \r | |
76 | private PlatformHeaderDocument.PlatformHeader fpdHdr = null;\r | |
77 | \r | |
78 | private PlatformDefinitionsDocument.PlatformDefinitions fpdPlatformDefs = null;\r | |
79 | \r | |
80 | private FlashDocument.Flash fpdFlash = null;\r | |
81 | \r | |
82 | private BuildOptionsDocument.BuildOptions fpdBuildOpts = null;\r | |
83 | \r | |
84 | private FrameworkModulesDocument.FrameworkModules fpdFrameworkModules = null;\r | |
85 | \r | |
86 | private DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs = null;\r | |
87 | \r | |
908b1c05 | 88 | private HashMap<String, ArrayList<String>> dynPcdMap = null;\r |
a13899c5 | 89 | \r |
90 | /**\r | |
91 | * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.\r | |
92 | */\r | |
93 | public void initDynPcdMap() {\r | |
94 | if (dynPcdMap == null) {\r | |
95 | dynPcdMap = new HashMap<String, ArrayList<String>>();\r | |
96 | List<ModuleSADocument.ModuleSA> l = getfpdFrameworkModules().getModuleSAList();\r | |
97 | if (l == null) {\r | |
98 | return;\r | |
99 | }\r | |
100 | ListIterator<ModuleSADocument.ModuleSA> li = l.listIterator();\r | |
101 | while (li.hasNext()) {\r | |
102 | ModuleSADocument.ModuleSA msa = li.next();\r | |
103 | if (msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null) {\r | |
104 | continue;\r | |
105 | }\r | |
106 | String ModuleInfo = msa.getModuleGuid() + " " + msa.getModuleVersion() +\r | |
107 | " " + msa.getPackageGuid() + " " + msa.getPackageVersion();\r | |
108 | List<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lp = msa.getPcdBuildDefinition().getPcdDataList();\r | |
109 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lpi = lp.listIterator();\r | |
110 | while (lpi.hasNext()) {\r | |
111 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = lpi.next();\r | |
112 | String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName();\r | |
113 | if (dynPcdMap.get(pcdKey) == null) {\r | |
114 | ArrayList<String> al = new ArrayList<String>();\r | |
115 | al.add(ModuleInfo + " " + pcdData.getItemType().toString());\r | |
116 | dynPcdMap.put(pcdKey, al);\r | |
117 | }\r | |
118 | else{\r | |
119 | dynPcdMap.get(pcdKey).add(ModuleInfo + " " + pcdData.getItemType().toString());\r | |
120 | }\r | |
121 | }\r | |
122 | }\r | |
123 | }\r | |
124 | }\r | |
908b1c05 | 125 | \r |
126 | public ArrayList<String> getDynPcdMapValue(String key) {\r | |
127 | return dynPcdMap.get(key);\r | |
128 | }\r | |
a13899c5 | 129 | /**\r |
130 | Constructor to create a new spd file\r | |
131 | **/\r | |
132 | public FpdFileContents() {\r | |
133 | \r | |
134 | fpdd = PlatformSurfaceAreaDocument.Factory.newInstance();\r | |
135 | fpdRoot = fpdd.addNewPlatformSurfaceArea();\r | |
136 | \r | |
137 | }\r | |
138 | \r | |
139 | /**\r | |
140 | Constructor for existing document object\r | |
141 | @param psa\r | |
142 | **/\r | |
143 | public FpdFileContents(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r | |
144 | fpdRoot = fpd;\r | |
145 | fpdHdr = fpdRoot.getPlatformHeader();\r | |
146 | fpdPlatformDefs = fpdRoot.getPlatformDefinitions();\r | |
147 | fpdBuildOpts = fpdRoot.getBuildOptions();\r | |
148 | fpdFrameworkModules = fpdRoot.getFrameworkModules();\r | |
149 | fpdDynPcdBuildDefs = fpdRoot.getDynamicPcdBuildDefinitions();\r | |
150 | fpdFlash = fpdRoot.getFlash();\r | |
151 | }\r | |
152 | \r | |
153 | /**\r | |
154 | Constructor based on an existing spd file\r | |
155 | \r | |
156 | @param f Existing spd file\r | |
157 | **/\r | |
158 | public FpdFileContents(File f) {\r | |
159 | try {\r | |
160 | fpdd = PlatformSurfaceAreaDocument.Factory.parse(f);\r | |
161 | fpdRoot = fpdd.getPlatformSurfaceArea();\r | |
162 | } catch (Exception e) {\r | |
163 | System.out.println(e.toString());\r | |
164 | }\r | |
165 | }\r | |
166 | \r | |
167 | public DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions getfpdDynPcdBuildDefs() {\r | |
168 | if (fpdDynPcdBuildDefs == null){\r | |
169 | fpdDynPcdBuildDefs = fpdRoot.addNewDynamicPcdBuildDefinitions();\r | |
170 | }\r | |
171 | return fpdDynPcdBuildDefs;\r | |
172 | }\r | |
173 | \r | |
174 | public FrameworkModulesDocument.FrameworkModules getfpdFrameworkModules() {\r | |
175 | if (fpdFrameworkModules == null){\r | |
176 | fpdFrameworkModules = fpdRoot.addNewFrameworkModules();\r | |
177 | }\r | |
178 | return fpdFrameworkModules;\r | |
179 | }\r | |
180 | \r | |
a13899c5 | 181 | public int getFrameworkModulesCount() {\r |
182 | if (getfpdFrameworkModules().getModuleSAList() == null){\r | |
183 | return 0;\r | |
184 | }\r | |
185 | return getfpdFrameworkModules().getModuleSAList().size();\r | |
186 | }\r | |
187 | \r | |
188 | public void getFrameworkModulesInfo(String[][] saa) {\r | |
189 | if (getFrameworkModulesCount() == 0){\r | |
190 | return;\r | |
191 | }\r | |
192 | \r | |
193 | ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r | |
194 | int i = 0;\r | |
195 | while(li.hasNext()) {\r | |
196 | ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();\r | |
197 | saa[i][1] = msa.getModuleGuid();\r | |
198 | saa[i][2] = msa.getModuleVersion();\r | |
199 | \r | |
200 | saa[i][3] = msa.getPackageGuid();\r | |
201 | saa[i][4] = msa.getPackageVersion();\r | |
202 | // saa[i][4] = listToString(msa.getSupArchList());\r | |
203 | ++i;\r | |
204 | }\r | |
205 | }\r | |
206 | \r | |
207 | public ModuleSADocument.ModuleSA getModuleSA(String key) {\r | |
208 | String[] s = key.split(" ");\r | |
209 | if (getfpdFrameworkModules().getModuleSAList() == null) {\r | |
210 | return null;\r | |
211 | }\r | |
212 | ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r | |
213 | while(li.hasNext()) {\r | |
214 | ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();\r | |
f3b0ed9a | 215 | if (msa.getModuleGuid().equals(s[0]) && msa.getPackageGuid().equals(s[2])) {\r |
71baa24b | 216 | // if (msa.getModuleVersion() != null) {\r |
217 | // if (!msa.getModuleVersion().equals(s[1])) {\r | |
218 | // continue;\r | |
219 | // }\r | |
220 | // }\r | |
221 | // else{\r | |
222 | // if (s[1] != null) {\r | |
223 | // continue;\r | |
224 | // }\r | |
225 | // }\r | |
226 | // if (msa.getPackageVersion() != null) {\r | |
227 | // if (!msa.getPackageVersion().equals(s[3])) {\r | |
228 | // continue;\r | |
229 | // }\r | |
230 | // }\r | |
231 | // else{\r | |
232 | // if (s[3] != null) {\r | |
233 | // continue;\r | |
234 | // }\r | |
235 | // }\r | |
a13899c5 | 236 | return msa;\r |
237 | }\r | |
238 | }\r | |
239 | return null;\r | |
240 | }\r | |
241 | public void removeModuleSA(int i) {\r | |
242 | XmlObject o = getfpdFrameworkModules();\r | |
243 | if (o == null) {\r | |
244 | return;\r | |
245 | }\r | |
246 | \r | |
247 | XmlCursor cursor = o.newCursor();\r | |
248 | if (cursor.toFirstChild()) {\r | |
249 | for (int j = 0; j < i; ++j) {\r | |
250 | cursor.toNextSibling();\r | |
251 | }\r | |
252 | //\r | |
253 | // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.\r | |
254 | //\r | |
255 | ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject();\r | |
256 | String moduleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + " " +\r | |
257 | moduleSa.getPackageGuid()+ " " + moduleSa.getPackageVersion();\r | |
258 | PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef = moduleSa.getPcdBuildDefinition();\r | |
908b1c05 | 259 | if (pcdBuildDef != null && pcdBuildDef.getPcdDataList() != null) {\r |
260 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> li = pcdBuildDef.getPcdDataList().listIterator();\r | |
261 | while(li.hasNext()) {\r | |
262 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();\r | |
263 | maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleInfo);\r | |
264 | }\r | |
a13899c5 | 265 | }\r |
266 | cursor.removeXml();\r | |
267 | }\r | |
268 | cursor.dispose();\r | |
269 | }\r | |
270 | \r | |
908b1c05 | 271 | private void maintainDynPcdMap(String pcdKey, String moduleInfo) {\r |
272 | \r | |
273 | ArrayList<String> al = dynPcdMap.get(pcdKey);\r | |
274 | if (al == null) {\r | |
a13899c5 | 275 | return;\r |
276 | }\r | |
908b1c05 | 277 | String[] s = moduleInfo.split(" ");\r |
a13899c5 | 278 | for(int i = 0; i < al.size(); ++i){\r |
908b1c05 | 279 | String consumer = al.get(i);\r |
280 | if (consumer.contains(s[0]) && consumer.contains(s[2])){\r | |
281 | al.remove(consumer);\r | |
a13899c5 | 282 | break;\r |
283 | }\r | |
284 | }\r | |
908b1c05 | 285 | \r |
a13899c5 | 286 | if (al.size() == 0) {\r |
287 | dynPcdMap.remove(pcdKey);\r | |
908b1c05 | 288 | String[] s1 = pcdKey.split(" ");\r |
289 | removeDynamicPcdBuildData(s1[0], s1[1]);\r | |
a13899c5 | 290 | }\r |
291 | \r | |
a13899c5 | 292 | }\r |
293 | //\r | |
294 | // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"\r | |
295 | //\r | |
296 | public int getPcdDataCount(String key){\r | |
297 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
298 | if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){\r | |
299 | return 0;\r | |
300 | }\r | |
301 | return msa.getPcdBuildDefinition().getPcdDataList().size();\r | |
302 | }\r | |
303 | \r | |
304 | public void getPcdData(String key, String[][] saa) {\r | |
305 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
306 | if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){\r | |
307 | return;\r | |
308 | }\r | |
309 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData>li = msa.getPcdBuildDefinition().getPcdDataList().listIterator();\r | |
310 | for (int i = 0; i < saa.length; ++i) {\r | |
311 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();\r | |
312 | saa[i][0] = pcdData.getCName();\r | |
313 | saa[i][1] = pcdData.getTokenSpaceGuidCName();\r | |
82961247 | 314 | saa[i][2] = pcdData.getItemType()+"";\r |
a13899c5 | 315 | saa[i][3] = pcdData.getToken().toString();\r |
82961247 | 316 | saa[i][4] = pcdData.getMaxDatumSize()+"";\r |
317 | saa[i][5] = pcdData.getDatumType()+"";\r | |
318 | saa[i][6] = pcdData.getValue();\r | |
a13899c5 | 319 | \r |
320 | }\r | |
321 | }\r | |
908b1c05 | 322 | \r |
323 | public void updatePcdData(String key, String cName, String tsGuid, String itemType, String maxSize, String value){\r | |
324 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
325 | if (msa == null || msa.getPcdBuildDefinition() == null){\r | |
326 | return;\r | |
327 | }\r | |
328 | \r | |
329 | XmlCursor cursor = msa.getPcdBuildDefinition().newCursor();\r | |
330 | if (cursor.toFirstChild()){\r | |
331 | do {\r | |
332 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r | |
333 | if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {\r | |
334 | pcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
335 | if(pcdData.getDatumType().equals("VOID*")) {\r | |
336 | pcdData.setMaxDatumSize(new Integer(maxSize));\r | |
337 | }\r | |
338 | pcdData.setValue(value);\r | |
339 | break;\r | |
340 | }\r | |
341 | }\r | |
342 | while(cursor.toNextSibling());\r | |
343 | }\r | |
344 | cursor.dispose();\r | |
345 | }\r | |
346 | \r | |
347 | /**Get original Pcd info from MSA & SPD files.\r | |
348 | * @param mi ModuleIdentification from which MSA & SPD come\r | |
349 | * @param cName PCD cName\r | |
350 | * @param sa Results: HelpText, Original item type.\r | |
351 | * @return\r | |
352 | */\r | |
353 | public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String[] sa) throws Exception{\r | |
354 | try {\r | |
355 | \r | |
356 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);\r | |
357 | if (msa.getPcdCoded() == null) {\r | |
358 | return false;\r | |
359 | }\r | |
360 | \r | |
361 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r | |
362 | m.put("ModuleSurfaceArea", msa);\r | |
363 | SurfaceAreaQuery.setDoc(m);\r | |
364 | PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null);\r | |
365 | //\r | |
366 | // First look through MSA pcd entries.\r | |
367 | //\r | |
368 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r | |
369 | ListIterator li = l.listIterator();\r | |
370 | while(li.hasNext()) {\r | |
371 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r | |
372 | if (!msaPcd.getCName().equals(cName)) {\r | |
373 | continue;\r | |
374 | }\r | |
375 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r | |
376 | if (spdPcd == null) {\r | |
377 | //\r | |
378 | // ToDo Error \r | |
379 | //\r | |
380 | throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());\r | |
381 | }\r | |
382 | //\r | |
383 | // Get Pcd help text and original item type.\r | |
384 | //\r | |
385 | sa[0] = spdPcd.getHelpText() + msaPcd.getHelpText();\r | |
386 | sa[1] = msaPcd.getPcdItemType()+"";\r | |
387 | return true;\r | |
388 | }\r | |
389 | \r | |
390 | \r | |
391 | }\r | |
392 | catch (Exception e){\r | |
393 | e.printStackTrace();\r | |
394 | throw e;\r | |
395 | }\r | |
396 | \r | |
397 | return false;\r | |
398 | }\r | |
399 | \r | |
400 | /**Remove PCDBuildDefinition entries from ModuleSA\r | |
401 | * @param moduleKey identifier of ModuleSA.\r | |
402 | * @param consumer where these entries come from.\r | |
403 | */\r | |
404 | public void removePcdData(String moduleKey, ModuleIdentification consumer) {\r | |
405 | try {\r | |
406 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(consumer);\r | |
407 | if (msa.getPcdCoded() == null) {\r | |
408 | return;\r | |
409 | }\r | |
410 | \r | |
411 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r | |
412 | ListIterator li = l.listIterator();\r | |
413 | \r | |
414 | while(li.hasNext()) {\r | |
415 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r | |
416 | ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey);\r | |
417 | XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor();\r | |
418 | if (cursor.toFirstChild()) {\r | |
419 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r | |
420 | if (msaPcd.getCName().equals(pcdData.getCName()) && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r | |
421 | \r | |
422 | maintainDynPcdMap(pcdData.getCName()+" "+pcdData.getTokenSpaceGuidCName(), moduleKey);\r | |
423 | cursor.removeXml();\r | |
424 | break;\r | |
425 | }\r | |
426 | while (cursor.toNextSibling()) {\r | |
427 | pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r | |
428 | if (msaPcd.getCName().equals(pcdData.getCName()) && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r | |
429 | maintainDynPcdMap(pcdData.getCName()+" "+pcdData.getTokenSpaceGuidCName(), moduleKey);\r | |
430 | cursor.removeXml();\r | |
431 | break;\r | |
432 | }\r | |
433 | }\r | |
434 | }\r | |
435 | cursor.dispose();\r | |
436 | }\r | |
437 | \r | |
438 | }\r | |
439 | catch (Exception e){\r | |
440 | e.printStackTrace();\r | |
441 | \r | |
442 | }\r | |
443 | }\r | |
a13899c5 | 444 | //\r |
445 | // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"\r | |
446 | //\r | |
447 | public int getLibraryInstancesCount(String key) {\r | |
448 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
449 | if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r | |
450 | return 0;\r | |
451 | }\r | |
452 | return msa.getLibraries().getInstanceList().size();\r | |
453 | }\r | |
454 | \r | |
455 | public void getLibraryInstances(String key, String[][] saa){\r | |
456 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
457 | if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r | |
458 | return ;\r | |
459 | }\r | |
460 | \r | |
461 | ListIterator<LibrariesDocument.Libraries.Instance> li = msa.getLibraries().getInstanceList().listIterator();\r | |
462 | for (int i = 0; i < saa.length; ++i) {\r | |
463 | LibrariesDocument.Libraries.Instance instance = li.next();\r | |
464 | saa[i][1] = instance.getModuleGuid();\r | |
465 | saa[i][2] = instance.getModuleVersion();\r | |
466 | saa[i][3] = instance.getPackageGuid();\r | |
467 | saa[i][4] = instance.getPackageVersion();\r | |
468 | }\r | |
469 | }\r | |
470 | \r | |
908b1c05 | 471 | public void removeLibraryInstance(String key, int i) {\r |
a13899c5 | 472 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
473 | if (msa == null || msa.getLibraries() == null){\r | |
474 | return ;\r | |
475 | }\r | |
476 | \r | |
477 | XmlCursor cursor = msa.getLibraries().newCursor();\r | |
908b1c05 | 478 | if (cursor.toFirstChild()) {\r |
479 | for (int j = 0; j < i; ++j) {\r | |
480 | cursor.toNextSibling();\r | |
481 | }\r | |
482 | cursor.removeXml();\r | |
483 | }\r | |
484 | \r | |
a13899c5 | 485 | cursor.dispose();\r |
486 | }\r | |
487 | \r | |
488 | public void genLibraryInstance(String mg, String mv, String pg, String pv, String key) {\r | |
489 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
490 | if (msa == null){\r | |
491 | msa = getfpdFrameworkModules().addNewModuleSA();\r | |
492 | }\r | |
493 | LibrariesDocument.Libraries libs = msa.getLibraries();\r | |
494 | if(libs == null){\r | |
495 | libs = msa.addNewLibraries();\r | |
496 | }\r | |
497 | \r | |
498 | LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();\r | |
499 | instance.setModuleGuid(mg);\r | |
500 | instance.setModuleVersion(mv);\r | |
501 | instance.setPackageGuid(pg);\r | |
502 | instance.setPackageVersion(pv);\r | |
503 | \r | |
504 | }\r | |
1800d80f | 505 | \r |
506 | public String getFvBinding(String moduleKey){\r | |
507 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
508 | if (msa == null || msa.getModuleSaBuildOptions() == null) {\r | |
509 | return null;\r | |
510 | }\r | |
511 | return msa.getModuleSaBuildOptions().getFvBinding();\r | |
512 | }\r | |
513 | \r | |
514 | public void setFvBinding(String moduleKey, String fvBinding){\r | |
515 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
516 | if (msa == null ) {\r | |
517 | return;\r | |
518 | }\r | |
519 | if(msa.getModuleSaBuildOptions() == null){\r | |
520 | msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r | |
521 | return;\r | |
522 | }\r | |
523 | msa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r | |
524 | }\r | |
525 | \r | |
526 | public String getFfsFileNameGuid(String moduleKey){\r | |
527 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
528 | if (msa == null || msa.getModuleSaBuildOptions() == null) {\r | |
529 | return null;\r | |
530 | }\r | |
531 | return msa.getModuleSaBuildOptions().getFfsFileNameGuid();\r | |
532 | }\r | |
533 | \r | |
534 | public void setFfsFileNameGuid(String moduleKey, String fileGuid){\r | |
535 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
536 | if (msa == null ) {\r | |
537 | return;\r | |
538 | }\r | |
539 | if(msa.getModuleSaBuildOptions() == null){\r | |
540 | msa.addNewModuleSaBuildOptions().setFfsFileNameGuid(fileGuid);\r | |
541 | return;\r | |
542 | }\r | |
543 | msa.getModuleSaBuildOptions().setFfsFileNameGuid(fileGuid);\r | |
544 | }\r | |
545 | \r | |
546 | public String getFfsFormatKey(String moduleKey){\r | |
547 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
548 | if (msa == null || msa.getModuleSaBuildOptions() == null) {\r | |
549 | return null;\r | |
550 | }\r | |
551 | return msa.getModuleSaBuildOptions().getFfsFormatKey();\r | |
552 | }\r | |
553 | \r | |
554 | public void setFfsFormatKey(String moduleKey, String ffsKey){\r | |
555 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
556 | if (msa == null ) {\r | |
557 | return;\r | |
558 | }\r | |
559 | if(msa.getModuleSaBuildOptions() == null){\r | |
560 | msa.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey);\r | |
561 | return;\r | |
562 | }\r | |
563 | msa.getModuleSaBuildOptions().setFvBinding(ffsKey);\r | |
564 | }\r | |
565 | \r | |
566 | public void getModuleSAOptions(String moduleKey, String[][] saa) {\r | |
567 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
568 | if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r | |
569 | || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r | |
570 | return ;\r | |
571 | }\r | |
572 | \r | |
573 | List<OptionDocument.Option> lOpt = msa.getModuleSaBuildOptions().getOptions().getOptionList();\r | |
574 | ListIterator li = lOpt.listIterator();\r | |
575 | int i = 0;\r | |
576 | while(li.hasNext()) {\r | |
577 | OptionDocument.Option opt = (OptionDocument.Option)li.next();\r | |
578 | if (opt.getBuildTargets() != null) {\r | |
579 | saa[i][0] = listToString(opt.getBuildTargets());\r | |
580 | }\r | |
581 | saa[i][1] = opt.getToolChainFamily();\r | |
582 | if (opt.getSupArchList() != null){\r | |
583 | saa[i][2] = listToString(opt.getSupArchList());\r | |
584 | \r | |
585 | }\r | |
586 | saa[i][3] = opt.getToolCode();\r | |
587 | saa[i][4] = opt.getTagName();\r | |
588 | saa[i][5] = opt.getStringValue();\r | |
589 | \r | |
590 | ++i;\r | |
591 | }\r | |
592 | }\r | |
593 | \r | |
594 | public int getModuleSAOptionsCount(String moduleKey){\r | |
595 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
596 | if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r | |
597 | || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r | |
598 | return 0;\r | |
599 | }\r | |
600 | return msa.getModuleSaBuildOptions().getOptions().getOptionList().size();\r | |
601 | }\r | |
602 | \r | |
603 | public void genModuleSAOptionsOpt(String moduleKey, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r | |
604 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
605 | if (msa.getModuleSaBuildOptions() == null) {\r | |
606 | msa.addNewModuleSaBuildOptions();\r | |
607 | }\r | |
608 | if (msa.getModuleSaBuildOptions().getOptions() == null){\r | |
609 | msa.getModuleSaBuildOptions().addNewOptions();\r | |
610 | }\r | |
611 | OptionDocument.Option opt = msa.getModuleSaBuildOptions().getOptions().addNewOption();\r | |
612 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
613 | }\r | |
614 | \r | |
615 | public void removeModuleSAOptionsOpt(String moduleKey, int i) {\r | |
616 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
617 | if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r | |
618 | return ;\r | |
619 | }\r | |
620 | OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r | |
621 | XmlCursor cursor = opts.newCursor();\r | |
622 | if (cursor.toFirstChild()) {\r | |
623 | for (int j = 0; j < i; ++j){\r | |
624 | cursor.toNextSibling();\r | |
625 | }\r | |
626 | cursor.removeXml();\r | |
627 | }\r | |
628 | cursor.dispose();\r | |
629 | }\r | |
630 | \r | |
631 | public void updateModuleSAOptionsOpt(String moduleKey, int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r | |
632 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
633 | if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r | |
634 | return ;\r | |
635 | }\r | |
636 | OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r | |
637 | XmlCursor cursor = opts.newCursor();\r | |
638 | if (cursor.toFirstChild()) {\r | |
639 | for (int j = 0; j < i; ++j){\r | |
640 | cursor.toNextSibling();\r | |
641 | }\r | |
642 | OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r | |
643 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
644 | }\r | |
645 | cursor.dispose();\r | |
646 | }\r | |
647 | \r | |
a13899c5 | 648 | /**add pcd information of module mi to a ModuleSA. \r |
649 | * @param mi\r | |
650 | * @param moduleSa if null, generate a new ModuleSA.\r | |
651 | */\r | |
82961247 | 652 | public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, ModuleSADocument.ModuleSA moduleSa) throws Exception {\r |
a13899c5 | 653 | //ToDo add Arch filter\r |
654 | \r | |
655 | try {\r | |
656 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);\r | |
657 | if (msa.getPcdCoded() == null) {\r | |
658 | return;\r | |
659 | }\r | |
660 | if (moduleSa == null) {\r | |
661 | moduleSa = genModuleSA(mi);\r | |
662 | }\r | |
663 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r | |
664 | m.put("ModuleSurfaceArea", msa);\r | |
665 | SurfaceAreaQuery.setDoc(m);\r | |
666 | PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null);\r | |
667 | //\r | |
668 | // Implementing InitializePlatformPcdBuildDefinitions\r | |
669 | //\r | |
670 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r | |
671 | ListIterator li = l.listIterator();\r | |
672 | while(li.hasNext()) {\r | |
673 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r | |
674 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r | |
675 | if (spdPcd == null) {\r | |
676 | //\r | |
677 | // ToDo Error \r | |
678 | //\r | |
82961247 | 679 | throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());\r |
a13899c5 | 680 | }\r |
681 | //\r | |
682 | // AddItem to ModuleSA PcdBuildDefinitions\r | |
683 | //\r | |
684 | String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();\r | |
908b1c05 | 685 | \r |
a13899c5 | 686 | genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);\r |
687 | }\r | |
688 | \r | |
689 | }\r | |
690 | catch (Exception e){\r | |
691 | e.printStackTrace();\r | |
82961247 | 692 | throw e; \r |
a13899c5 | 693 | }\r |
694 | \r | |
695 | }\r | |
696 | \r | |
697 | private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {\r | |
698 | \r | |
699 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r | |
700 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;\r | |
701 | for (int i = 0; i < depPkgs.length; ++i) {\r | |
702 | m.put("PackageSurfaceArea", GlobalData.getPackageXmlObject(depPkgs[i]));\r | |
703 | SurfaceAreaQuery.setDoc(m);\r | |
704 | XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations();\r | |
705 | if (xo == null) {\r | |
706 | continue;\r | |
707 | }\r | |
708 | for (int j = 0; j < xo.length; ++j) {\r | |
709 | spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j];\r | |
710 | if (msaPcd.getTokenSpaceGuidCName() == null) {\r | |
711 | if (spdPcd.getCName().equals(msaPcd.getCName())) {\r | |
712 | return spdPcd;\r | |
713 | }\r | |
714 | }\r | |
715 | else{\r | |
716 | if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) {\r | |
717 | return spdPcd;\r | |
718 | }\r | |
719 | }\r | |
720 | \r | |
721 | }\r | |
722 | \r | |
723 | }\r | |
724 | return null;\r | |
725 | }\r | |
726 | \r | |
727 | private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi) {\r | |
728 | PackageIdentification pi = GlobalData.getPackageForModule(mi);\r | |
729 | ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();\r | |
730 | msa.setModuleGuid(mi.getGuid());\r | |
731 | msa.setModuleVersion(mi.getVersion());\r | |
732 | msa.setPackageGuid(pi.getGuid());\r | |
733 | msa.setPackageVersion(pi.getVersion());\r | |
734 | \r | |
735 | return msa;\r | |
736 | }\r | |
737 | \r | |
82961247 | 738 | private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) \r |
739 | throws PcdItemTypeConflictException, PcdValueMalFormed{\r | |
a13899c5 | 740 | if (moduleSa.getPcdBuildDefinition() == null){\r |
741 | moduleSa.addNewPcdBuildDefinition();\r | |
742 | }\r | |
743 | //\r | |
744 | // constructe pcd to modulesa mapping first.\r | |
745 | // Attention : for any error condition, remove from map this pcd.\r | |
746 | //\r | |
747 | ArrayList<String> pcdConsumer = LookupPlatformPcdData(cName + " " + tsGuid);\r | |
748 | if (pcdConsumer == null) {\r | |
749 | pcdConsumer = new ArrayList<String>();\r | |
750 | }\r | |
751 | String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r | |
752 | + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() \r | |
753 | + " " + itemType;\r | |
754 | pcdConsumer.add(listValue);\r | |
755 | dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);\r | |
756 | //\r | |
757 | // Special dynamic type, if this pcd already exists in other ModuleSA\r | |
758 | //\r | |
759 | if (itemType.equals("DYNAMIC")) {\r | |
760 | \r | |
761 | ListIterator li = pcdConsumer.listIterator();\r | |
762 | while(li.hasNext()) {\r | |
763 | String value = li.next().toString();\r | |
764 | String[] valuePart= value.split(" ");\r | |
765 | if (!valuePart[4].equals("DYNAMIC")) {\r | |
766 | //ToDo error for same pcd, other type than dynamic\r | |
767 | pcdConsumer.remove(listValue);\r | |
82961247 | 768 | throw new PcdItemTypeConflictException(value);\r |
a13899c5 | 769 | }\r |
770 | }\r | |
771 | }\r | |
772 | else {\r | |
773 | ListIterator li = pcdConsumer.listIterator();\r | |
774 | while(li.hasNext()) {\r | |
775 | String value = li.next().toString();\r | |
776 | String[] valuePart= value.split(" ");\r | |
777 | if (valuePart[4].equals("DYNAMIC")) {\r | |
778 | //ToDo error for same pcd, other type than non-dynamic\r | |
779 | pcdConsumer.remove(listValue);\r | |
82961247 | 780 | throw new PcdItemTypeConflictException(value);\r |
a13899c5 | 781 | }\r |
782 | }\r | |
783 | }\r | |
784 | \r | |
785 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();\r | |
786 | fpdPcd.setCName(cName);\r | |
787 | fpdPcd.setToken(token);\r | |
788 | fpdPcd.setTokenSpaceGuidCName(tsGuid);\r | |
789 | fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));\r | |
790 | fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
791 | \r | |
792 | if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) {\r | |
793 | ArrayList<String> al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid);\r | |
794 | //\r | |
795 | // if only one module mapped to this pcd, then the one is myself. so no other module mapped.\r | |
796 | // so need to add one dyn pcd.\r | |
797 | //\r | |
798 | if (al.size() == 1) {\r | |
799 | addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal);\r | |
800 | }\r | |
801 | }\r | |
802 | else {\r | |
803 | if (defaultVal != null){\r | |
804 | fpdPcd.setValue(defaultVal);\r | |
805 | }\r | |
806 | else {\r | |
807 | if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {\r | |
808 | fpdPcd.setValue("0");\r | |
809 | }\r | |
810 | if (dataType.equals("BOOLEAN")){\r | |
811 | fpdPcd.setValue("false");\r | |
812 | }\r | |
813 | if (dataType.equals("VOID*")) {\r | |
814 | fpdPcd.setValue("");\r | |
815 | }\r | |
816 | }\r | |
817 | if (dataType.equals("UINT8")){\r | |
818 | fpdPcd.setMaxDatumSize(1);\r | |
819 | }\r | |
820 | if (dataType.equals("UINT16")) {\r | |
821 | fpdPcd.setMaxDatumSize(2);\r | |
822 | }\r | |
823 | if (dataType.equals("UINT32")) {\r | |
824 | fpdPcd.setMaxDatumSize(4);\r | |
825 | }\r | |
826 | if (dataType.equals("UINT64")){\r | |
827 | fpdPcd.setMaxDatumSize(8);\r | |
828 | }\r | |
829 | if (dataType.equals("BOOLEAN")){\r | |
830 | fpdPcd.setMaxDatumSize(1);\r | |
831 | }\r | |
832 | if (dataType.equals("VOID*")) {\r | |
833 | int maxSize = setMaxSizeForPointer(fpdPcd.getValue());\r | |
834 | fpdPcd.setMaxDatumSize(maxSize);\r | |
835 | }\r | |
836 | }\r | |
837 | }\r | |
838 | \r | |
908b1c05 | 839 | public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{\r |
a13899c5 | 840 | if (datum == null) {\r |
841 | return 0;\r | |
842 | }\r | |
843 | char ch = datum.charAt(0);\r | |
844 | int start, end;\r | |
845 | String strValue;\r | |
846 | //\r | |
847 | // For void* type PCD, only three datum is support:\r | |
848 | // 1) Unicode: string with start char is "L"\r | |
849 | // 2) Ansci: String is ""\r | |
850 | // 3) byte array: String start char "{"\r | |
851 | // \r | |
852 | if (ch == 'L') {\r | |
853 | start = datum.indexOf('\"');\r | |
854 | end = datum.lastIndexOf('\"');\r | |
855 | if ((start > end) || \r | |
856 | (end > datum.length())||\r | |
857 | ((start == end) && (datum.length() > 0))) {\r | |
858 | //ToDo Error handling here\r | |
82961247 | 859 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 860 | }\r |
861 | \r | |
862 | strValue = datum.substring(start + 1, end);\r | |
863 | return strValue.length() * 2;\r | |
864 | } else if (ch == '\"'){\r | |
865 | start = datum.indexOf('\"');\r | |
866 | end = datum.lastIndexOf('\"');\r | |
867 | if ((start > end) || \r | |
868 | (end > datum.length())||\r | |
869 | ((start == end) && (datum.length() > 0))) {\r | |
82961247 | 870 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 871 | }\r |
872 | strValue = datum.substring(start + 1, end);\r | |
873 | return strValue.length();\r | |
874 | } else if (ch =='{') {\r | |
875 | String[] strValueArray;\r | |
876 | \r | |
877 | start = datum.indexOf('{');\r | |
878 | end = datum.lastIndexOf('}');\r | |
879 | strValue = datum.substring(start + 1, end);\r | |
880 | strValue = strValue.trim();\r | |
881 | if (strValue.length() == 0) {\r | |
882 | return 0;\r | |
883 | }\r | |
884 | strValueArray = strValue.split(",");\r | |
885 | for (int index = 0; index < strValueArray.length; index ++) {\r | |
886 | Integer value = Integer.decode(strValueArray[index].trim());\r | |
887 | \r | |
888 | if (value > 0xFF) {\r | |
889 | // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+\r | |
890 | // "it is byte array in fact. But the element of %s exceed the byte range",\r | |
82961247 | 891 | throw new PcdValueMalFormed (datum); \r |
a13899c5 | 892 | }\r |
893 | }\r | |
894 | return strValueArray.length;\r | |
895 | \r | |
896 | \r | |
897 | } else {\r | |
898 | // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+\r | |
899 | // "1) UNICODE string: like L\"xxxx\";\r\n"+\r | |
900 | // "2) ANSIC string: like \"xxx\";\r\n"+\r | |
901 | // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+\r | |
902 | // "but the datum in seems does not following above format!",\r | |
82961247 | 903 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 904 | \r |
905 | }\r | |
906 | }\r | |
907 | \r | |
908 | private ArrayList<String> LookupDynamicPcdBuildDefinition(String dynPcdKey) {\r | |
909 | ArrayList<String> al = dynPcdMap.get(dynPcdKey);\r | |
910 | \r | |
911 | return al;\r | |
912 | }\r | |
913 | \r | |
914 | private ArrayList<String> LookupPlatformPcdData(String pcdKey) {\r | |
915 | \r | |
916 | return dynPcdMap.get("pcdKey");\r | |
917 | }\r | |
918 | \r | |
919 | public int getDynamicPcdBuildDataCount() {\r | |
920 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {\r | |
921 | return 0;\r | |
922 | }\r | |
923 | return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();\r | |
924 | }\r | |
925 | \r | |
926 | public void getDynamicPcdBuildData(String[][] saa) {\r | |
927 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {\r | |
928 | return ;\r | |
929 | }\r | |
930 | List<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> l = getfpdDynPcdBuildDefs().getPcdBuildDataList();\r | |
931 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> li = l.listIterator();\r | |
932 | int i = 0;\r | |
933 | while(li.hasNext()) {\r | |
934 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcd = li.next();\r | |
935 | saa[i][0] = dynPcd.getCName();\r | |
936 | saa[i][1] = dynPcd.getToken().toString();\r | |
937 | saa[i][2] = dynPcd.getTokenSpaceGuidCName();\r | |
938 | saa[i][3] = dynPcd.getMaxDatumSize()+"";\r | |
939 | saa[i][4] = dynPcd.getDatumType().toString();\r | |
940 | \r | |
941 | ++i;\r | |
942 | }\r | |
943 | }\r | |
944 | \r | |
908b1c05 | 945 | public void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) \r |
82961247 | 946 | throws PcdValueMalFormed{\r |
a13899c5 | 947 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData();\r |
948 | dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
949 | dynPcdData.setCName(cName);\r | |
950 | dynPcdData.setToken(token);\r | |
951 | dynPcdData.setTokenSpaceGuidCName(tsGuid);\r | |
952 | dynPcdData.setDatumType(PcdDataTypes.Enum.forString(dataType));\r | |
953 | \r | |
954 | BigInteger bigInt = new BigInteger("0");\r | |
955 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = dynPcdData.addNewSkuInfo();\r | |
956 | skuInfo.setSkuId(bigInt);\r | |
957 | if (defaultVal != null){\r | |
958 | skuInfo.setValue(defaultVal);\r | |
959 | }\r | |
960 | else {\r | |
961 | if (dataType.equals("UINT8")){\r | |
962 | skuInfo.setValue("0");\r | |
963 | }\r | |
964 | if (dataType.equals("UINT16")) {\r | |
965 | skuInfo.setValue("0");\r | |
966 | }\r | |
967 | if (dataType.equals("UINT32")) {\r | |
968 | skuInfo.setValue("0");\r | |
969 | }\r | |
970 | if (dataType.equals("UINT64")){\r | |
971 | skuInfo.setValue("0");\r | |
972 | }\r | |
973 | if (dataType.equals("BOOLEAN")){\r | |
974 | skuInfo.setValue("false");\r | |
975 | }\r | |
976 | if (dataType.equals("VOID*")) {\r | |
977 | skuInfo.setValue("");\r | |
978 | }\r | |
979 | }\r | |
980 | if (dataType.equals("UINT8")){\r | |
981 | dynPcdData.setMaxDatumSize(1);\r | |
982 | }\r | |
983 | if (dataType.equals("UINT16")) {\r | |
984 | dynPcdData.setMaxDatumSize(2);\r | |
985 | }\r | |
986 | if (dataType.equals("UINT32")) {\r | |
987 | dynPcdData.setMaxDatumSize(4);\r | |
988 | }\r | |
989 | if (dataType.equals("UINT64")){\r | |
990 | dynPcdData.setMaxDatumSize(8);\r | |
991 | }\r | |
992 | if (dataType.equals("BOOLEAN")){\r | |
993 | dynPcdData.setMaxDatumSize(1);\r | |
994 | }\r | |
995 | if (dataType.equals("VOID*")) {\r | |
996 | int maxSize = setMaxSizeForPointer(defaultVal);\r | |
997 | dynPcdData.setMaxDatumSize(maxSize);\r | |
998 | }\r | |
999 | }\r | |
1000 | \r | |
908b1c05 | 1001 | public void removeDynamicPcdBuildData(String cName, String tsGuid) {\r |
a13899c5 | 1002 | XmlObject o = getfpdDynPcdBuildDefs();\r |
1003 | \r | |
1004 | XmlCursor cursor = o.newCursor();\r | |
1005 | if (cursor.toFirstChild()) {\r | |
1006 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = \r | |
1007 | (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
908b1c05 | 1008 | if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) {\r |
1009 | cursor.removeXml();\r | |
1010 | cursor.dispose();\r | |
1011 | return;\r | |
1012 | }\r | |
1013 | while (cursor.toNextSibling()) {\r | |
1014 | \r | |
a13899c5 | 1015 | pcdBuildData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r |
908b1c05 | 1016 | if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) {\r |
1017 | cursor.removeXml();\r | |
1018 | cursor.dispose();\r | |
1019 | return;\r | |
1020 | }\r | |
a13899c5 | 1021 | }\r |
a13899c5 | 1022 | }\r |
1023 | cursor.dispose();\r | |
1024 | }\r | |
1025 | //\r | |
1026 | // Get the Sku Info count of ith dyn pcd element.\r | |
1027 | //\r | |
1028 | public int getDynamicPcdSkuInfoCount(int i){\r | |
1029 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
1030 | return 0;\r | |
1031 | }\r | |
1032 | \r | |
1033 | int skuInfoCount = 0;\r | |
1034 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1035 | if (cursor.toFirstChild()) {\r | |
1036 | for (int j = 0; j < i; ++j) {\r | |
1037 | cursor.toNextSibling();\r | |
1038 | }\r | |
1039 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1040 | if (pcdData.getSkuInfoList() == null) {\r | |
1041 | skuInfoCount = 0;\r | |
1042 | }\r | |
1043 | else {\r | |
1044 | skuInfoCount = pcdData.getSkuInfoList().size();\r | |
1045 | }\r | |
1046 | }\r | |
1047 | cursor.dispose();\r | |
1048 | return skuInfoCount;\r | |
1049 | }\r | |
1050 | \r | |
1051 | public void getDynamicPcdSkuInfos(int i, String[][] saa){\r | |
1052 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
1053 | return;\r | |
1054 | }\r | |
1055 | \r | |
1056 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1057 | if (cursor.toFirstChild()) {\r | |
1058 | for (int j = 0; j < i; ++j) {\r | |
1059 | cursor.toNextSibling();\r | |
1060 | }\r | |
1061 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1062 | if (pcdData.getSkuInfoList() == null) {\r | |
1063 | cursor.dispose();\r | |
1064 | return;\r | |
1065 | }\r | |
1066 | else {\r | |
1067 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r | |
1068 | int k = 0;\r | |
1069 | while (li.hasNext()) {\r | |
1070 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r | |
1071 | saa[k][0] = skuInfo.getSkuId()+"";\r | |
1072 | saa[k][1] = skuInfo.getVariableName();\r | |
1073 | saa[k][2] = skuInfo.getVariableGuid();\r | |
1074 | saa[k][3] = skuInfo.getVariableOffset();\r | |
1075 | saa[k][4] = skuInfo.getHiiDefaultValue();\r | |
1076 | saa[k][5] = skuInfo.getVpdOffset();\r | |
1077 | saa[k][6] = skuInfo.getValue();\r | |
1078 | ++k;\r | |
1079 | }\r | |
1080 | \r | |
1081 | }\r | |
1082 | }\r | |
1083 | cursor.dispose();\r | |
1084 | \r | |
1085 | }\r | |
1086 | \r | |
1087 | public String getDynamicPcdBuildDataValue(int i){\r | |
1088 | String value = null;\r | |
1089 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
1090 | return value;\r | |
1091 | }\r | |
1092 | \r | |
1093 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1094 | if (cursor.toFirstChild()) {\r | |
1095 | for (int j = 0; j < i; ++j) {\r | |
1096 | cursor.toNextSibling();\r | |
1097 | }\r | |
1098 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1099 | if (pcdData.getSkuInfoList() == null) {\r | |
1100 | value = null;\r | |
1101 | }\r | |
1102 | else {\r | |
1103 | value = pcdData.getSkuInfoArray(0).getValue();\r | |
1104 | }\r | |
1105 | }\r | |
1106 | cursor.dispose();\r | |
1107 | return value;\r | |
1108 | }\r | |
1109 | \r | |
1110 | public String getDynamicPcdBuildDataVpdOffset(int i){\r | |
1111 | String vpdOffset = null;\r | |
1112 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
1113 | return vpdOffset;\r | |
1114 | }\r | |
1115 | \r | |
1116 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1117 | if (cursor.toFirstChild()) {\r | |
1118 | for (int j = 0; j < i; ++j) {\r | |
1119 | cursor.toNextSibling();\r | |
1120 | }\r | |
1121 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1122 | if (pcdData.getSkuInfoList() == null) {\r | |
1123 | vpdOffset = null;\r | |
1124 | }\r | |
1125 | else {\r | |
1126 | vpdOffset = pcdData.getSkuInfoArray(0).getVpdOffset();\r | |
1127 | }\r | |
1128 | }\r | |
1129 | cursor.dispose();\r | |
1130 | return vpdOffset;\r | |
1131 | }\r | |
1132 | \r | |
1133 | public void removeDynamicPcdBuildDataSkuInfo(int i) {\r | |
1134 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
1135 | return;\r | |
1136 | }\r | |
1137 | \r | |
1138 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1139 | if (cursor.toFirstChild()) {\r | |
1140 | for (int j = 0; j < i; ++j) {\r | |
1141 | cursor.toNextSibling();\r | |
1142 | }\r | |
1143 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1144 | if (pcdData.getSkuInfoList() == null) {\r | |
1145 | cursor.dispose();\r | |
1146 | return;\r | |
1147 | }\r | |
1148 | else {\r | |
1149 | QName qSkuInfo = new QName(xmlNs, "SkuInfo");\r | |
1150 | cursor.toChild(qSkuInfo);\r | |
1151 | cursor.removeXml();\r | |
1152 | }\r | |
1153 | }\r | |
1154 | cursor.dispose();\r | |
1155 | }\r | |
1156 | //\r | |
1157 | // generate sku info for ith dyn pcd build data.\r | |
1158 | //\r | |
1159 | public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r | |
1160 | String hiiDefault, String vpdOffset, String value, int i) {\r | |
1161 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
1162 | return;\r | |
1163 | }\r | |
1164 | \r | |
1165 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1166 | if (cursor.toFirstChild()) {\r | |
1167 | for (int j = 0; j < i; ++j) {\r | |
1168 | cursor.toNextSibling();\r | |
1169 | }\r | |
1170 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1171 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = pcdData.addNewSkuInfo();\r | |
1172 | skuInfo.setSkuId(new BigInteger(id));\r | |
1173 | if (varName != null){\r | |
1174 | skuInfo.setVariableName(varName);\r | |
1175 | skuInfo.setVariableGuid(varGuid);\r | |
1176 | skuInfo.setVariableOffset(varOffset);\r | |
1177 | skuInfo.setHiiDefaultValue(hiiDefault);\r | |
1178 | }\r | |
1179 | else if (vpdOffset != null){\r | |
1180 | skuInfo.setVpdOffset(vpdOffset);\r | |
1181 | }\r | |
1182 | else{\r | |
1183 | skuInfo.setValue(value);\r | |
1184 | }\r | |
1185 | }\r | |
1186 | }\r | |
1187 | \r | |
1188 | public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r | |
1189 | String hiiDefault, String vpdOffset, String value, int i){\r | |
1190 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
1191 | return;\r | |
1192 | }\r | |
1193 | \r | |
1194 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1195 | if (cursor.toFirstChild()) {\r | |
1196 | for (int j = 0; j < i; ++j) {\r | |
1197 | cursor.toNextSibling();\r | |
1198 | }\r | |
1199 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1200 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r | |
1201 | while (li.hasNext()) {\r | |
1202 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r | |
1203 | if (skuInfo.getSkuId().toString().equals(id)){\r | |
1204 | if (varName != null){\r | |
1205 | skuInfo.setVariableName(varName);\r | |
1206 | skuInfo.setVariableGuid(varGuid);\r | |
1207 | skuInfo.setVariableOffset(varOffset);\r | |
1208 | skuInfo.setHiiDefaultValue(hiiDefault);\r | |
1209 | }\r | |
1210 | else if (vpdOffset != null){\r | |
1211 | skuInfo.setVpdOffset(vpdOffset);\r | |
1212 | }\r | |
1213 | else{\r | |
1214 | skuInfo.setValue(value);\r | |
1215 | }\r | |
1216 | break;\r | |
1217 | }\r | |
1218 | }\r | |
1219 | }\r | |
1220 | }\r | |
1221 | \r | |
a13899c5 | 1222 | public BuildOptionsDocument.BuildOptions getfpdBuildOpts() {\r |
1223 | if (fpdBuildOpts == null) {\r | |
1224 | fpdBuildOpts = fpdRoot.addNewBuildOptions();\r | |
1225 | }\r | |
1226 | return fpdBuildOpts;\r | |
1227 | }\r | |
1228 | \r | |
1229 | public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {\r | |
1230 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1231 | if (udats == null) {\r | |
1232 | udats = getfpdBuildOpts().addNewUserDefinedAntTasks();\r | |
1233 | }\r | |
1234 | \r | |
1235 | AntTaskDocument.AntTask at = udats.addNewAntTask();\r | |
1236 | setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r | |
1237 | }\r | |
1238 | \r | |
1239 | private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) {\r | |
1240 | at.setId(new Integer(id));\r | |
1241 | if (fileName != null){\r | |
1242 | at.setFilename(fileName);\r | |
1243 | }\r | |
202c4f38 | 1244 | if (execOrder != null) {\r |
a13899c5 | 1245 | at.setAntCmdOptions(execOrder);\r |
1246 | }\r | |
1247 | }\r | |
1248 | \r | |
1249 | public void removeBuildOptionsUserDefAntTask(int i) {\r | |
1250 | XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1251 | if (o == null) {\r | |
1252 | return;\r | |
1253 | }\r | |
1254 | XmlCursor cursor = o.newCursor();\r | |
1255 | if (cursor.toFirstChild()) {\r | |
1256 | for (int j = 0; j < i; ++j) {\r | |
1257 | cursor.toNextSibling();\r | |
1258 | }\r | |
1259 | cursor.removeXml();\r | |
1260 | }\r | |
1261 | cursor.dispose();\r | |
1262 | }\r | |
1263 | \r | |
1264 | public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){\r | |
1265 | XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1266 | if (o == null) {\r | |
1267 | return;\r | |
1268 | }\r | |
1269 | XmlCursor cursor = o.newCursor();\r | |
1270 | if (cursor.toFirstChild()) {\r | |
1271 | for (int j = 0; j < i; ++j) {\r | |
1272 | cursor.toNextSibling();\r | |
1273 | }\r | |
1274 | AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject();\r | |
1275 | setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r | |
1276 | }\r | |
1277 | cursor.dispose();\r | |
1278 | }\r | |
1279 | \r | |
1280 | public int getBuildOptionsUserDefAntTaskCount() {\r | |
1281 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1282 | if (udats == null || udats.getAntTaskList() == null) {\r | |
1283 | return 0;\r | |
1284 | }\r | |
1285 | \r | |
1286 | return udats.getAntTaskList().size();\r | |
1287 | }\r | |
1288 | \r | |
1289 | public void getBuildOptionsUserDefAntTasks(String[][] saa) {\r | |
1290 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1291 | if (udats == null || udats.getAntTaskList() == null) {\r | |
1292 | return ;\r | |
1293 | }\r | |
1294 | \r | |
1295 | List<AntTaskDocument.AntTask> l = udats.getAntTaskList();\r | |
1296 | ListIterator li = l.listIterator();\r | |
1297 | int i = 0;\r | |
1298 | while (li.hasNext()) {\r | |
1299 | AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next();\r | |
1300 | saa[i][0] = at.getId() + "";\r | |
1301 | saa[i][1] = saa[i][2] = "";\r | |
1302 | if (at.getFilename() != null){\r | |
1303 | saa[i][1] = at.getFilename();\r | |
1304 | }\r | |
1305 | if (at.getAntCmdOptions() != null) {\r | |
1306 | saa[i][2] = at.getAntCmdOptions();\r | |
1307 | }\r | |
1308 | ++i;\r | |
1309 | }\r | |
1310 | }\r | |
1800d80f | 1311 | public void genBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r |
a13899c5 | 1312 | OptionsDocument.Options opts = getfpdBuildOpts().getOptions();\r |
1313 | if (opts == null) {\r | |
1314 | opts = getfpdBuildOpts().addNewOptions();\r | |
1315 | }\r | |
1316 | OptionDocument.Option opt = opts.addNewOption();\r | |
1317 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1318 | }\r | |
1319 | \r | |
1800d80f | 1320 | private void setBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents, OptionDocument.Option opt){\r |
a13899c5 | 1321 | opt.setStringValue(contents);\r |
1800d80f | 1322 | \r |
1323 | opt.setBuildTargets(buildTargets);\r | |
a13899c5 | 1324 | opt.setToolChainFamily(toolChain);\r |
1325 | opt.setTagName(tagName);\r | |
1326 | opt.setToolCode(toolCmd);\r | |
1800d80f | 1327 | \r |
1328 | opt.setSupArchList(archList);\r | |
a13899c5 | 1329 | }\r |
1330 | \r | |
1331 | public void removeBuildOptionsOpt(int i){\r | |
1332 | \r | |
1333 | XmlObject o = getfpdBuildOpts().getOptions();\r | |
1334 | if (o == null) {\r | |
1335 | return;\r | |
1336 | }\r | |
1337 | \r | |
1338 | XmlCursor cursor = o.newCursor();\r | |
1339 | if (cursor.toFirstChild()) {\r | |
1340 | for (int j = 0; j < i; ++j) {\r | |
1341 | cursor.toNextSibling();\r | |
1342 | }\r | |
1343 | cursor.removeXml();\r | |
1344 | }\r | |
1345 | cursor.dispose();\r | |
1346 | }\r | |
1347 | \r | |
1800d80f | 1348 | public void updateBuildOptionsOpt(int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r |
a13899c5 | 1349 | XmlObject o = getfpdBuildOpts().getOptions();\r |
1350 | if (o == null) {\r | |
1351 | return;\r | |
1352 | }\r | |
1353 | \r | |
1354 | XmlCursor cursor = o.newCursor();\r | |
1355 | if (cursor.toFirstChild()) {\r | |
1356 | for (int j = 0; j < i; ++j) {\r | |
1357 | cursor.toNextSibling();\r | |
1358 | }\r | |
1359 | OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r | |
1360 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1361 | }\r | |
1362 | cursor.dispose();\r | |
1363 | }\r | |
1364 | \r | |
1365 | public int getBuildOptionsOptCount(){\r | |
1366 | if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r | |
1367 | return 0;\r | |
1368 | }\r | |
1369 | return getfpdBuildOpts().getOptions().getOptionList().size();\r | |
1370 | }\r | |
1371 | \r | |
1372 | public void getBuildOptionsOpts(String[][] saa) {\r | |
1373 | if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r | |
1374 | return ;\r | |
1375 | }\r | |
1376 | \r | |
1377 | List<OptionDocument.Option> lOpt = getfpdBuildOpts().getOptions().getOptionList();\r | |
1378 | ListIterator li = lOpt.listIterator();\r | |
1379 | int i = 0;\r | |
1380 | while(li.hasNext()) {\r | |
1381 | OptionDocument.Option opt = (OptionDocument.Option)li.next();\r | |
6cba26e8 | 1382 | if (opt.getBuildTargets() != null) {\r |
1383 | saa[i][0] = listToString(opt.getBuildTargets());\r | |
1384 | }\r | |
a13899c5 | 1385 | saa[i][1] = opt.getToolChainFamily();\r |
1386 | if (opt.getSupArchList() != null){\r | |
6cba26e8 | 1387 | saa[i][2] = listToString(opt.getSupArchList());\r |
1388 | \r | |
a13899c5 | 1389 | }\r |
1390 | saa[i][3] = opt.getToolCode();\r | |
1391 | saa[i][4] = opt.getTagName();\r | |
1392 | saa[i][5] = opt.getStringValue();\r | |
1393 | \r | |
1394 | ++i;\r | |
1395 | }\r | |
1396 | }\r | |
1397 | \r | |
6cba26e8 | 1398 | public void genBuildOptionsFfs(String ffsKey, String type) {\r |
1399 | BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r | |
1400 | ffs.setFfsKey(ffsKey);\r | |
1401 | if (type != null) {\r | |
1402 | ffs.addNewSections().setEncapsulationType(type);\r | |
1403 | }\r | |
1404 | }\r | |
1405 | \r | |
3b405e9b | 1406 | public void updateBuildOptionsFfsSectionsType(int i, String type) {\r |
1407 | BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r | |
1408 | if (type != null) {\r | |
1409 | ffs.addNewSections().setEncapsulationType(type);\r | |
1410 | }\r | |
1411 | }\r | |
1412 | \r | |
6cba26e8 | 1413 | public void genBuildOptionsFfsAttribute(int i, String name, String value) {\r |
1414 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1415 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = ffs.addNewAttribute();\r | |
1416 | attrib.setName(name);\r | |
1417 | attrib.setValue(value);\r | |
1418 | }\r | |
1419 | \r | |
1420 | /**update jth attribute of ith ffs.\r | |
1421 | * @param i\r | |
1422 | * @param j\r | |
1423 | */\r | |
1424 | public void updateBuildOptionsFfsAttribute(int i, int j, String name, String value){\r | |
1425 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1426 | XmlCursor cursor = ffs.newCursor();\r | |
1427 | QName qAttrib = new QName(xmlNs, "Attribute");\r | |
1428 | if (cursor.toChild(qAttrib)) {\r | |
1429 | for (int k = 0; k < j; ++k) {\r | |
1430 | cursor.toNextSibling(qAttrib);\r | |
1431 | }\r | |
1432 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = (BuildOptionsDocument.BuildOptions.Ffs.Attribute)cursor.getObject();\r | |
1433 | attrib.setName(name);\r | |
1434 | attrib.setValue(value);\r | |
1435 | }\r | |
1436 | cursor.dispose();\r | |
1437 | }\r | |
1438 | \r | |
1439 | public void removeBuildOptionsFfsAttribute(int i, int j){\r | |
1440 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1441 | XmlCursor cursor = ffs.newCursor();\r | |
1442 | QName qAttrib = new QName(xmlNs, "Attribute");\r | |
1443 | if (cursor.toChild(qAttrib)) {\r | |
1444 | for (int k = 0; k < j; ++k) {\r | |
1445 | cursor.toNextSibling(qAttrib);\r | |
1446 | }\r | |
1447 | cursor.removeXml();\r | |
1448 | }\r | |
1449 | cursor.dispose();\r | |
1450 | }\r | |
1451 | \r | |
1452 | public void genBuildOptionsFfsSectionsSection(int i, String sectionType) {\r | |
1453 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1454 | if (ffs == null) {\r | |
1455 | return;\r | |
1456 | }\r | |
1457 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1458 | \r | |
1459 | if (sections == null){\r | |
1460 | sections = ffs.addNewSections();\r | |
1461 | }\r | |
1462 | sections.addNewSection().setSectionType(EfiSectionType.Enum.forString(sectionType));\r | |
1463 | }\r | |
1464 | \r | |
3b405e9b | 1465 | public void removeBuildOptionsFfsSectionsSection(int i, int j) {\r |
1466 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1467 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1468 | if (sections == null) {\r | |
1469 | return;\r | |
1470 | }\r | |
1471 | XmlCursor cursor = sections.newCursor();\r | |
1472 | QName qSection = new QName(xmlNs, "Section");\r | |
1473 | if (cursor.toChild(qSection)) {\r | |
1474 | for (int k = 0; k < j; ++k) {\r | |
1475 | cursor.toNextSibling(qSection);\r | |
1476 | }\r | |
1477 | cursor.removeXml();\r | |
1478 | }\r | |
1479 | cursor.dispose();\r | |
1480 | }\r | |
1481 | \r | |
1482 | public void updateBuildOptionsFfsSectionsSection(int i, int j, String type){\r | |
1483 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1484 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1485 | if (sections == null) {\r | |
1486 | return;\r | |
1487 | }\r | |
1488 | XmlCursor cursor = sections.newCursor();\r | |
1489 | QName qSection = new QName(xmlNs, "Section");\r | |
1490 | if (cursor.toChild(qSection)) {\r | |
1491 | for (int k = 0; k < j; ++k) {\r | |
1492 | cursor.toNextSibling(qSection);\r | |
1493 | }\r | |
1494 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Section)cursor.getObject();\r | |
1495 | section.setSectionType(EfiSectionType.Enum.forString(type));\r | |
1496 | }\r | |
1497 | cursor.dispose();\r | |
1498 | } \r | |
1499 | \r | |
6cba26e8 | 1500 | public void genBuildOptionsFfsSectionsSections(int i, String encapType) {\r |
1501 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1502 | if (ffs == null) {\r | |
1503 | return;\r | |
1504 | }\r | |
1505 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1506 | \r | |
1507 | if (sections == null){\r | |
1508 | sections = ffs.addNewSections();\r | |
1509 | }\r | |
1510 | sections.addNewSections().setEncapsulationType(encapType);\r | |
1511 | }\r | |
1512 | \r | |
3b405e9b | 1513 | public void removeBuildOptionsFfsSectionsSections(int i, int j) {\r |
1514 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1515 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1516 | if (sections == null) {\r | |
1517 | return;\r | |
1518 | }\r | |
1519 | XmlCursor cursor = sections.newCursor();\r | |
1520 | QName qSections = new QName(xmlNs, "Sections");\r | |
1521 | if (cursor.toChild(qSections)) {\r | |
1522 | for (int k = 0; k < j; ++k) {\r | |
1523 | cursor.toNextSibling(qSections);\r | |
1524 | }\r | |
1525 | cursor.removeXml();\r | |
1526 | }\r | |
1527 | cursor.dispose();\r | |
1528 | }\r | |
1529 | \r | |
1530 | public void updateBuildOptionsFfsSectionsSections(int i, int j, String type) {\r | |
1531 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1532 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1533 | if (sections == null) {\r | |
1534 | return;\r | |
1535 | }\r | |
1536 | XmlCursor cursor = sections.newCursor();\r | |
1537 | QName qSections = new QName(xmlNs, "Sections");\r | |
1538 | if (cursor.toChild(qSections)) {\r | |
1539 | for (int k = 0; k < j; ++k) {\r | |
1540 | cursor.toNextSibling(qSections);\r | |
1541 | }\r | |
1542 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
1543 | sections2.setEncapsulationType(type);\r | |
1544 | }\r | |
1545 | cursor.dispose();\r | |
1546 | }\r | |
1547 | \r | |
6cba26e8 | 1548 | public void genBuildOptionsFfsSectionsSectionsSection(int i, int j, String type) {\r |
1549 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1550 | if (ffs == null) {\r | |
1551 | return;\r | |
1552 | }\r | |
1553 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1554 | XmlCursor cursor = sections.newCursor();\r | |
1555 | QName qSections = new QName(xmlNs, "Sections");\r | |
1556 | if (cursor.toChild(qSections)){\r | |
1557 | for (int k = 0; k < j; ++k) {\r | |
1558 | cursor.toNextSibling(qSections);\r | |
1559 | }\r | |
1560 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
1561 | sections2.addNewSection().setSectionType(EfiSectionType.Enum.forString(type));\r | |
1562 | }\r | |
1563 | cursor.dispose();\r | |
1564 | }\r | |
1565 | \r | |
3b405e9b | 1566 | public void removeBuildOptionsFfsSectionsSectionsSection(int i, int j, int k) {\r |
1567 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1568 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1569 | if (sections == null) {\r | |
1570 | return;\r | |
1571 | }\r | |
1572 | XmlCursor cursor = sections.newCursor();\r | |
1573 | QName qSections = new QName(xmlNs, "Sections");\r | |
1574 | if (cursor.toChild(qSections)) {\r | |
1575 | for (int l = 0; l < j; ++l) {\r | |
1576 | cursor.toNextSibling(qSections);\r | |
1577 | }\r | |
1578 | if (cursor.toFirstChild()) {\r | |
1579 | for (int m = 0; m < k; ++m) {\r | |
1580 | cursor.toNextSibling();\r | |
1581 | }\r | |
1582 | cursor.removeXml();\r | |
1583 | }\r | |
1584 | }\r | |
1585 | cursor.dispose();\r | |
1586 | }\r | |
1587 | \r | |
1588 | public void updateBuildOptionsFfsSectionsSectionsSection(int i, int j, int k, String type) {\r | |
1589 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1590 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1591 | if (sections == null) {\r | |
1592 | return;\r | |
1593 | }\r | |
1594 | XmlCursor cursor = sections.newCursor();\r | |
1595 | QName qSections = new QName(xmlNs, "Sections");\r | |
1596 | if (cursor.toChild(qSections)) {\r | |
1597 | for (int l = 0; l < j; ++l) {\r | |
1598 | cursor.toNextSibling(qSections);\r | |
1599 | }\r | |
1600 | if (cursor.toFirstChild()) {\r | |
1601 | for (int m = 0; m < k; ++m) {\r | |
1602 | cursor.toNextSibling();\r | |
1603 | }\r | |
1604 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section)cursor.getObject();\r | |
1605 | section.setSectionType(EfiSectionType.Enum.forString(type));\r | |
1606 | }\r | |
1607 | }\r | |
1608 | cursor.dispose();\r | |
1609 | }\r | |
1610 | \r | |
6cba26e8 | 1611 | public void getBuildOptionsFfsSectionsSectionsSection(int i, int j, ArrayList<String> al) {\r |
1612 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1613 | if (ffs == null) {\r | |
1614 | return;\r | |
1615 | }\r | |
1616 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1617 | XmlCursor cursor = sections.newCursor();\r | |
1618 | QName qSections = new QName(xmlNs, "Sections");\r | |
1619 | if (cursor.toChild(qSections)){\r | |
1620 | for (int k = 0; k < j; ++k) {\r | |
1621 | cursor.toNextSibling(qSections);\r | |
1622 | }\r | |
1623 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
1624 | if (sections2.getSectionList() == null){\r | |
1625 | cursor.dispose();\r | |
1626 | return;\r | |
1627 | }\r | |
1628 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section> li = sections2.getSectionList().listIterator();\r | |
1629 | while(li.hasNext()) {\r | |
1630 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = li.next();\r | |
3b405e9b | 1631 | if (section.isSetSectionType()) {\r |
1800d80f | 1632 | al.add(section.getSectionType().toString());\r |
1633 | }\r | |
3b405e9b | 1634 | \r |
1635 | }\r | |
6cba26e8 | 1636 | }\r |
1637 | cursor.dispose();\r | |
1638 | \r | |
1639 | }\r | |
1640 | \r | |
1641 | public int getBuildOptionsFfsCount(){\r | |
1642 | if (getfpdBuildOpts().getFfsList() == null) {\r | |
1643 | return 0;\r | |
1644 | }\r | |
1645 | return getfpdBuildOpts().getFfsList().size();\r | |
1646 | }\r | |
1647 | \r | |
1648 | public void getBuildOptionsFfsKey(String[][] saa) {\r | |
1649 | if (getfpdBuildOpts().getFfsList() == null) {\r | |
1650 | return;\r | |
1651 | }\r | |
1652 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs> li = getfpdBuildOpts().getFfsList().listIterator();\r | |
1653 | int i = 0;\r | |
1654 | while(li.hasNext()){\r | |
1655 | BuildOptionsDocument.BuildOptions.Ffs ffs = li.next();\r | |
1656 | saa[i][0] = ffs.getFfsKey();\r | |
1657 | ++i;\r | |
1658 | }\r | |
1659 | }\r | |
1660 | \r | |
3b405e9b | 1661 | public void updateBuildOptionsFfsKey(int i, String key) {\r |
1662 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1663 | ffs.setFfsKey(key);\r | |
1664 | }\r | |
1665 | \r | |
6cba26e8 | 1666 | /**Get ith FFS key and contents.\r |
1667 | * @param saa\r | |
1668 | */\r | |
1669 | public void getBuildOptionsFfs(int i, String[] sa, LinkedHashMap<String, String> ffsAttribMap, ArrayList<String> firstLevelSections, ArrayList<String> firstLevelSection) {\r | |
1670 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1671 | \r | |
1672 | if (ffs != null) {\r | |
1673 | \r | |
1674 | sa[0] = ffs.getFfsKey();\r | |
1675 | if (ffs.getSections() != null) {\r | |
1676 | if(ffs.getSections().getEncapsulationType() != null){\r | |
1677 | sa[1] = ffs.getSections().getEncapsulationType();\r | |
1678 | }\r | |
1679 | if (ffs.getSections().getSectionList() != null){\r | |
1680 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Section> li = ffs.getSections().getSectionList().listIterator();\r | |
1681 | while (li.hasNext()) {\r | |
1682 | firstLevelSection.add(li.next().getSectionType().toString());\r | |
1683 | }\r | |
1684 | }\r | |
1685 | if (ffs.getSections().getSectionsList() != null) {\r | |
1686 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2> li = ffs.getSections().getSectionsList().listIterator();\r | |
1687 | while(li.hasNext()) {\r | |
1688 | firstLevelSections.add(li.next().getEncapsulationType());\r | |
1689 | }\r | |
1690 | }\r | |
1691 | }\r | |
1692 | if (ffs.getAttributeList() != null) {\r | |
1693 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Attribute> li = ffs.getAttributeList().listIterator();\r | |
1694 | while(li.hasNext()) {\r | |
1695 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = li.next();\r | |
1696 | ffsAttribMap.put(attrib.getName(), attrib.getValue());\r | |
1697 | }\r | |
1698 | \r | |
1699 | }\r | |
1700 | }\r | |
1701 | \r | |
1702 | \r | |
1703 | }\r | |
1704 | \r | |
1705 | private BuildOptionsDocument.BuildOptions.Ffs getFfs(int i) {\r | |
1706 | XmlObject o = getfpdBuildOpts();\r | |
1707 | BuildOptionsDocument.BuildOptions.Ffs ffs = null;\r | |
1708 | \r | |
1709 | XmlCursor cursor = o.newCursor();\r | |
1710 | QName qFfs = new QName(xmlNs, "Ffs");\r | |
1711 | if (cursor.toChild(qFfs)) {\r | |
1712 | for (int j = 0; j < i; ++j) {\r | |
1713 | cursor.toNextSibling(qFfs);\r | |
1714 | }\r | |
1715 | ffs = (BuildOptionsDocument.BuildOptions.Ffs)cursor.getObject();\r | |
1716 | }\r | |
1717 | cursor.dispose();\r | |
1718 | return ffs;\r | |
1719 | }\r | |
1720 | \r | |
1721 | public void removeBuildOptionsFfs(int i) {\r | |
1722 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1723 | if (ffs == null){\r | |
1724 | return;\r | |
1725 | }\r | |
1726 | \r | |
1727 | XmlCursor cursor = ffs.newCursor();\r | |
1728 | cursor.removeXml();\r | |
1729 | cursor.dispose();\r | |
1730 | }\r | |
1731 | \r | |
3b405e9b | 1732 | \r |
1733 | \r | |
a13899c5 | 1734 | public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){\r |
1735 | if (fpdPlatformDefs == null){\r | |
1736 | fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions();\r | |
1737 | }\r | |
1738 | return fpdPlatformDefs;\r | |
1739 | }\r | |
1740 | \r | |
6a09eb19 | 1741 | public void getPlatformDefsSupportedArchs(Vector<Object> archs){\r |
1742 | if (getfpdPlatformDefs().getSupportedArchitectures() == null) {\r | |
1743 | return;\r | |
1744 | }\r | |
1745 | ListIterator li = getfpdPlatformDefs().getSupportedArchitectures().listIterator();\r | |
1746 | while(li.hasNext()) {\r | |
1747 | archs.add(li.next());\r | |
1748 | }\r | |
1749 | }\r | |
1750 | \r | |
1751 | public void setPlatformDefsSupportedArchs(Vector<Object> archs) {\r | |
1752 | getfpdPlatformDefs().setSupportedArchitectures(archs);\r | |
1753 | }\r | |
1754 | \r | |
1755 | public void getPlatformDefsBuildTargets(Vector<Object> targets) {\r | |
1756 | if (getfpdPlatformDefs().getBuildTargets() == null) {\r | |
1757 | return;\r | |
1758 | }\r | |
1759 | ListIterator li = getfpdPlatformDefs().getBuildTargets().listIterator();\r | |
1760 | while(li.hasNext()) {\r | |
1761 | targets.add(li.next());\r | |
1762 | }\r | |
1763 | }\r | |
1764 | \r | |
1765 | public void setPlatformDefsBuildTargets(Vector<Object> targets) {\r | |
1766 | getfpdPlatformDefs().setBuildTargets(targets);\r | |
1767 | }\r | |
1768 | \r | |
1769 | public void genPlatformDefsSkuInfo(String id, String name) {\r | |
1770 | SkuInfoDocument.SkuInfo skuInfo = null;\r | |
1771 | if (getfpdPlatformDefs().getSkuInfo() == null) {\r | |
1772 | skuInfo = getfpdPlatformDefs().addNewSkuInfo();\r | |
1773 | }\r | |
1774 | skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
1775 | if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) {\r | |
1776 | SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r | |
1777 | skuName.setSkuID(new BigInteger("0"));\r | |
1778 | skuName.setStringValue("DEFAULT");\r | |
1779 | }\r | |
1780 | if (id.equals("0")) {\r | |
1781 | return;\r | |
1782 | }\r | |
1783 | SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r | |
1784 | skuName.setSkuID(new BigInteger(id));\r | |
1785 | skuName.setStringValue(name);\r | |
1786 | }\r | |
1787 | \r | |
1788 | public int getPlatformDefsSkuInfoCount(){\r | |
1789 | if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r | |
1790 | return 0;\r | |
1791 | }\r | |
1792 | return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();\r | |
1793 | }\r | |
1794 | \r | |
1795 | public void getPlatformDefsSkuInfos(String[][] saa){\r | |
1796 | if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r | |
1797 | return ;\r | |
1798 | }\r | |
1799 | \r | |
1800 | List<SkuInfoDocument.SkuInfo.UiSkuName> l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();\r | |
1801 | ListIterator<SkuInfoDocument.SkuInfo.UiSkuName> li = l.listIterator();\r | |
1802 | int i = 0;\r | |
1803 | while(li.hasNext()) {\r | |
1804 | SkuInfoDocument.SkuInfo.UiSkuName sku = li.next();\r | |
1805 | saa[i][0] = sku.getSkuID()+"";\r | |
1806 | saa[i][1] = sku.getStringValue();\r | |
1807 | ++i;\r | |
1808 | }\r | |
1809 | }\r | |
1810 | \r | |
1811 | public void removePlatformDefsSkuInfo(int i) {\r | |
1812 | SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
1813 | if (skuInfo == null || i == 0) {\r | |
1814 | return ;\r | |
1815 | }\r | |
1816 | \r | |
1817 | XmlCursor cursor = skuInfo.newCursor();\r | |
1818 | if (cursor.toFirstChild()) {\r | |
1819 | for (int j = 0; j < i; ++j) {\r | |
1820 | cursor.toNextSibling();\r | |
1821 | }\r | |
1822 | cursor.removeXml();\r | |
1823 | }\r | |
1824 | cursor.dispose();\r | |
1825 | }\r | |
1826 | \r | |
1827 | public void updatePlatformDefsSkuInfo(int i, String id, String name) {\r | |
1828 | SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
1829 | if (skuInfo == null || i == 0) {\r | |
1830 | return ;\r | |
1831 | }\r | |
1832 | \r | |
1833 | XmlCursor cursor = skuInfo.newCursor();\r | |
1834 | if (cursor.toFirstChild()) {\r | |
1835 | for (int j = 0; j < i; ++j) {\r | |
1836 | cursor.toNextSibling();\r | |
1837 | }\r | |
1838 | SkuInfoDocument.SkuInfo.UiSkuName sku = (SkuInfoDocument.SkuInfo.UiSkuName)cursor.getObject();\r | |
1839 | sku.setSkuID(new BigInteger(id));\r | |
1840 | sku.setStringValue(name);\r | |
1841 | }\r | |
1842 | cursor.dispose();\r | |
1843 | }\r | |
1844 | \r | |
1845 | public String getPlatformDefsInterDir(){\r | |
1846 | if (getfpdPlatformDefs().getIntermediateDirectories() == null) {\r | |
1847 | return null;\r | |
1848 | }\r | |
1849 | return getfpdPlatformDefs().getIntermediateDirectories().toString();\r | |
1850 | }\r | |
1851 | \r | |
1852 | public void setPlatformDefsInterDir(String interDir){\r | |
1853 | getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType.Enum.forString(interDir));\r | |
1854 | }\r | |
1855 | \r | |
1856 | public String getPlatformDefsOutputDir() {\r | |
1857 | return getfpdPlatformDefs().getOutputDirectory();\r | |
1858 | }\r | |
1859 | \r | |
1860 | public void setPlatformDefsOutputDir(String outputDir) {\r | |
1861 | getfpdPlatformDefs().setOutputDirectory(outputDir);\r | |
1862 | }\r | |
1863 | \r | |
a13899c5 | 1864 | public FlashDocument.Flash getfpdFlash() {\r |
1865 | if (fpdFlash == null) {\r | |
1866 | fpdFlash = fpdRoot.addNewFlash();\r | |
1867 | }\r | |
1868 | return fpdFlash;\r | |
1869 | }\r | |
1870 | \r | |
1871 | public void genFlashDefinitionFile(String file) {\r | |
1872 | FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r | |
1873 | if (fdf == null) {\r | |
1874 | fdf = getfpdFlash().addNewFlashDefinitionFile();\r | |
1875 | }\r | |
1876 | \r | |
1877 | fdf.setStringValue(file);\r | |
1878 | }\r | |
1879 | \r | |
1880 | public String getFlashDefinitionFile() {\r | |
1881 | FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r | |
1882 | if (fdf == null) {\r | |
1883 | return "";\r | |
1884 | }\r | |
1885 | \r | |
1886 | return fdf.getStringValue();\r | |
1887 | }\r | |
1888 | \r | |
a13899c5 | 1889 | public void genFvImagesNameValue(String name, String value) {\r |
1890 | \r | |
1891 | FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r | |
1892 | if (fi == null) {\r | |
1893 | fi = getfpdFlash().addNewFvImages();\r | |
1894 | }\r | |
1895 | \r | |
1896 | FvImagesDocument.FvImages.NameValue nv = fi.addNewNameValue();\r | |
1897 | nv.setName(name);\r | |
1898 | nv.setValue(value);\r | |
1899 | }\r | |
1900 | \r | |
1901 | public void removeFvImagesNameValue(int i){\r | |
1902 | \r | |
1903 | XmlObject o = getfpdFlash().getFvImages();\r | |
1904 | if (o == null) {\r | |
1905 | return;\r | |
1906 | }\r | |
1907 | \r | |
1908 | QName qNameValue = new QName(xmlNs, "NameValue");\r | |
1909 | XmlCursor cursor = o.newCursor();\r | |
1910 | if (cursor.toChild(qNameValue)) {\r | |
1911 | for (int j = 0; j < i; ++j) {\r | |
1912 | cursor.toNextSibling(qNameValue);\r | |
1913 | }\r | |
1914 | cursor.removeXml();\r | |
1915 | }\r | |
1916 | cursor.dispose();\r | |
1917 | }\r | |
1918 | \r | |
1919 | public void updateFvImagesNameValue(int i, String name, String value){\r | |
1920 | \r | |
1921 | XmlObject o = getfpdFlash().getFvImages();\r | |
1922 | if (o == null) {\r | |
1923 | return;\r | |
1924 | }\r | |
1925 | \r | |
1926 | QName qNameValue = new QName(xmlNs, "NameValue");\r | |
1927 | XmlCursor cursor = o.newCursor();\r | |
1928 | if (cursor.toChild(qNameValue)) {\r | |
1929 | for (int j = 0; j < i; ++j) {\r | |
1930 | cursor.toNextSibling(qNameValue);\r | |
1931 | }\r | |
1932 | FvImagesDocument.FvImages.NameValue nv = (FvImagesDocument.FvImages.NameValue)cursor.getObject();\r | |
1933 | nv.setName(name);\r | |
1934 | nv.setValue(value);\r | |
1935 | }\r | |
1936 | cursor.dispose();\r | |
1937 | }\r | |
1938 | \r | |
1939 | public int getFvImagesNameValueCount() {\r | |
1940 | \r | |
1941 | FvImagesDocument.FvImages fi = null;\r | |
1942 | if ((fi = getfpdFlash().getFvImages()) == null || fi.getNameValueList() == null) {\r | |
1943 | return 0;\r | |
1944 | }\r | |
1945 | return fi.getNameValueList().size();\r | |
1946 | }\r | |
1947 | \r | |
1948 | public void getFvImagesNameValues(String[][] nv) {\r | |
1949 | \r | |
1950 | FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r | |
1951 | if (fi == null){\r | |
1952 | return;\r | |
1953 | }\r | |
1954 | List<FvImagesDocument.FvImages.NameValue> l = fi.getNameValueList();\r | |
1955 | int i = 0;\r | |
1956 | ListIterator li = l.listIterator();\r | |
1957 | while (li.hasNext()) {\r | |
1958 | FvImagesDocument.FvImages.NameValue e = (FvImagesDocument.FvImages.NameValue) li\r | |
1959 | .next();\r | |
1960 | nv[i][0] = e.getName();\r | |
1961 | nv[i][1] = e.getValue();\r | |
1962 | \r | |
1963 | i++;\r | |
1964 | }\r | |
1965 | }\r | |
1966 | \r | |
1967 | public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {\r | |
1968 | \r | |
1969 | FvImagesDocument.FvImages fis = null;\r | |
1970 | if ((fis = getfpdFlash().getFvImages()) == null) {\r | |
1971 | fis = getfpdFlash().addNewFvImages();\r | |
1972 | }\r | |
1973 | \r | |
1974 | //\r | |
1975 | //gen FvImage with FvImageNames array\r | |
1976 | //\r | |
1977 | FvImagesDocument.FvImages.FvImage fi = fis.addNewFvImage();\r | |
1978 | for (int i = 0; i < names.length; ++i) {\r | |
1979 | fi.addFvImageNames(names[i]);\r | |
1980 | }\r | |
1981 | fi.setType(FvImageTypes.Enum.forString(types));\r | |
1982 | if (options != null){\r | |
1983 | setFvImagesFvImageFvImageOptions(options, fi);\r | |
1984 | }\r | |
1985 | }\r | |
1986 | \r | |
1987 | private void setFvImagesFvImageFvImageOptions(Map<String, String> options, FvImagesDocument.FvImages.FvImage fi){\r | |
1988 | FvImagesDocument.FvImages.FvImage.FvImageOptions fio = fi.getFvImageOptions();\r | |
1989 | if (fio == null){\r | |
1990 | fio = fi.addNewFvImageOptions();\r | |
1991 | }\r | |
1992 | \r | |
1993 | Set<String> key = options.keySet();\r | |
1994 | Iterator<String> i = key.iterator();\r | |
1995 | while (i.hasNext()) {\r | |
44053733 | 1996 | \r |
a13899c5 | 1997 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fio.addNewNameValue();\r |
1998 | String k = (String)i.next();\r | |
ae0d4fd2 | 1999 | \r |
a13899c5 | 2000 | nv.setName(k);\r |
2001 | nv.setValue((String)options.get(k));\r | |
2002 | \r | |
2003 | }\r | |
2004 | \r | |
2005 | }\r | |
2006 | \r | |
44053733 | 2007 | \r |
a13899c5 | 2008 | public void removeFvImagesFvImage(int i) {\r |
2009 | \r | |
2010 | XmlObject o = getfpdFlash().getFvImages();\r | |
2011 | if (o == null) {\r | |
2012 | return;\r | |
2013 | }\r | |
2014 | \r | |
2015 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2016 | XmlCursor cursor = o.newCursor();\r | |
2017 | if (cursor.toChild(qFvImage)) {\r | |
2018 | for (int j = 0; j < i; ++j) {\r | |
2019 | cursor.toNextSibling(qFvImage);\r | |
2020 | }\r | |
2021 | cursor.removeXml();\r | |
2022 | }\r | |
2023 | cursor.dispose();\r | |
2024 | }\r | |
2025 | \r | |
2026 | public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){\r | |
2027 | \r | |
2028 | XmlObject o = getfpdFlash().getFvImages();\r | |
2029 | if (o == null) {\r | |
2030 | return;\r | |
2031 | }\r | |
2032 | XmlCursor cursor = o.newCursor();\r | |
2033 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2034 | if (cursor.toChild(qFvImage)) {\r | |
2035 | for (int j = 0; j < i; ++j) {\r | |
2036 | cursor.toNextSibling(qFvImage);\r | |
2037 | }\r | |
2038 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r | |
2039 | fi.setType(FvImageTypes.Enum.forString(types));\r | |
2040 | \r | |
2041 | //\r | |
2042 | // remove old FvImageNames before adding new ones\r | |
2043 | //\r | |
2044 | QName qFvImageNames = new QName(xmlNs, "FvImageNames"); \r | |
2045 | cursor.toChild(qFvImageNames);\r | |
2046 | cursor.removeXml();\r | |
2047 | while (cursor.toNextSibling(qFvImageNames)) {\r | |
2048 | cursor.removeXml();\r | |
2049 | }\r | |
2050 | \r | |
2051 | for (int k = 0; k < names.length; ++k) {\r | |
2052 | fi.addFvImageNames(names[k]);\r | |
2053 | }\r | |
2054 | //\r | |
2055 | // remove old FvImageOptions before adding new options\r | |
2056 | //\r | |
2057 | QName qFvImageOptions = new QName(xmlNs, "FvImageOptions");\r | |
2058 | cursor.toNextSibling(qFvImageOptions);\r | |
2059 | cursor.removeXml();\r | |
2060 | \r | |
2061 | setFvImagesFvImageFvImageOptions(options, fi);\r | |
2062 | }\r | |
2063 | cursor.dispose();\r | |
2064 | }\r | |
2065 | \r | |
2066 | public int getFvImagesFvImageCount() {\r | |
2067 | \r | |
2068 | if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r | |
2069 | return 0;\r | |
2070 | }\r | |
2071 | return getfpdFlash().getFvImages().getFvImageList().size();\r | |
2072 | }\r | |
2073 | \r | |
ae0d4fd2 | 2074 | /**Only Get Fv image setting - name and type.\r |
2075 | * @param saa\r | |
2076 | */\r | |
2077 | public void getFvImagesFvImages(String[][] saa) {\r | |
a13899c5 | 2078 | \r |
2079 | if (getfpdFlash().getFvImages() == null) {\r | |
2080 | return;\r | |
2081 | }\r | |
2082 | List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r | |
2083 | if (l == null) {\r | |
2084 | return;\r | |
2085 | }\r | |
2086 | ListIterator li = l.listIterator();\r | |
2087 | int i = 0;\r | |
2088 | while(li.hasNext()) {\r | |
2089 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r | |
2090 | //\r | |
2091 | // get FvImageNames array, space separated\r | |
2092 | //\r | |
2093 | List<String> lfn = fi.getFvImageNamesList();\r | |
2094 | ListIterator lfni = lfn.listIterator();\r | |
2095 | saa[i][0] = " ";\r | |
2096 | while (lfni.hasNext()) {\r | |
2097 | saa[i][0] += (String)lfni.next();\r | |
2098 | saa[i][0] += " ";\r | |
2099 | }\r | |
2100 | saa[i][0] = saa[i][0].trim();\r | |
2101 | \r | |
2102 | saa[i][1] = fi.getType()+"";\r | |
2103 | \r | |
ae0d4fd2 | 2104 | ++i;\r |
2105 | }\r | |
2106 | }\r | |
2107 | \r | |
2108 | /**Get FvImage Options for FvImage i\r | |
2109 | * @param i the ith FvImage\r | |
2110 | */\r | |
2111 | public void getFvImagesFvImageOptions(int i, Map<String, String> m) {\r | |
2112 | XmlObject o = getfpdFlash().getFvImages();\r | |
2113 | if (o == null) {\r | |
2114 | return;\r | |
2115 | }\r | |
2116 | XmlCursor cursor = o.newCursor();\r | |
2117 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2118 | if (cursor.toChild(qFvImage)) {\r | |
2119 | for (int j = 0; j < i; ++j) {\r | |
2120 | cursor.toNextSibling(qFvImage);\r | |
a13899c5 | 2121 | }\r |
ae0d4fd2 | 2122 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r |
2123 | if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null){\r | |
2124 | return;\r | |
a13899c5 | 2125 | }\r |
ae0d4fd2 | 2126 | ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();\r |
2127 | while(li.hasNext()){\r | |
2128 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r | |
a13899c5 | 2129 | m.put(nv.getName(), nv.getValue());\r |
2130 | }\r | |
a13899c5 | 2131 | }\r |
2132 | }\r | |
2133 | \r | |
2134 | /**\r | |
2135 | Get platform header element\r | |
2136 | @return PlatformHeaderDocument.PlatformHeader\r | |
2137 | **/\r | |
2138 | public PlatformHeaderDocument.PlatformHeader getFpdHdr() {\r | |
2139 | if (fpdHdr == null) {\r | |
2140 | fpdHdr = fpdRoot.addNewPlatformHeader();\r | |
2141 | }\r | |
2142 | genPlatformDefsSkuInfo("0", "DEFAULT");\r | |
2143 | return fpdHdr;\r | |
2144 | }\r | |
2145 | \r | |
a13899c5 | 2146 | public String getFpdHdrPlatformName() {\r |
2147 | return getFpdHdr().getPlatformName();\r | |
2148 | }\r | |
2149 | \r | |
2150 | public String getFpdHdrGuidValue() {\r | |
2151 | return getFpdHdr().getGuidValue();\r | |
2152 | }\r | |
2153 | \r | |
2154 | public String getFpdHdrVer() {\r | |
2155 | return getFpdHdr().getVersion();\r | |
2156 | }\r | |
2157 | \r | |
2158 | public String getFpdHdrAbs() {\r | |
2159 | return getFpdHdr().getAbstract();\r | |
2160 | }\r | |
2161 | \r | |
2162 | public String getFpdHdrDescription() {\r | |
2163 | return getFpdHdr().getDescription();\r | |
2164 | }\r | |
2165 | \r | |
2166 | public String getFpdHdrCopyright() {\r | |
2167 | return getFpdHdr().getCopyright();\r | |
2168 | }\r | |
2169 | \r | |
2170 | public String getFpdHdrLicense() {\r | |
2171 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2172 | if (l == null) {\r | |
2173 | return null;\r | |
2174 | }\r | |
2175 | return l.getStringValue();\r | |
2176 | }\r | |
2177 | \r | |
2178 | public String getFpdHdrUrl() {\r | |
2179 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2180 | if (l == null) {\r | |
2181 | return null;\r | |
2182 | }\r | |
2183 | return l.getURL();\r | |
2184 | }\r | |
2185 | \r | |
2186 | public String getFpdHdrSpec() {\r | |
2187 | \r | |
2188 | return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r | |
2189 | // return getFpdHdr().getSpecification();\r | |
2190 | }\r | |
2191 | \r | |
2192 | public void setFpdHdrPlatformName(String name){\r | |
2193 | getFpdHdr().setPlatformName(name);\r | |
2194 | }\r | |
2195 | \r | |
2196 | public void setFpdHdrGuidValue(String guid){\r | |
2197 | getFpdHdr().setGuidValue(guid);\r | |
2198 | }\r | |
2199 | \r | |
2200 | public void setFpdHdrVer(String v){\r | |
2201 | getFpdHdr().setVersion(v);\r | |
2202 | }\r | |
2203 | \r | |
2204 | public void setFpdHdrAbs(String abs) {\r | |
2205 | getFpdHdr().setAbstract(abs);\r | |
2206 | }\r | |
2207 | \r | |
2208 | public void setFpdHdrDescription(String desc){\r | |
2209 | getFpdHdr().setDescription(desc);\r | |
2210 | }\r | |
2211 | \r | |
2212 | public void setFpdHdrCopyright(String cr) {\r | |
2213 | getFpdHdr().setCopyright(cr);\r | |
2214 | }\r | |
2215 | \r | |
2216 | public void setFpdHdrLicense(String license){\r | |
2217 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2218 | if (l == null) {\r | |
2219 | getFpdHdr().addNewLicense().setStringValue(license);\r | |
2220 | }\r | |
2221 | else {\r | |
2222 | l.setStringValue(license);\r | |
2223 | }\r | |
2224 | }\r | |
2225 | \r | |
2226 | public void setFpdHdrUrl(String url){\r | |
2227 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2228 | \r | |
2229 | l.setURL(url);\r | |
2230 | \r | |
2231 | }\r | |
2232 | \r | |
2233 | public void setFpdHdrSpec(String s){\r | |
2234 | s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r | |
2235 | getFpdHdr().setSpecification(s);\r | |
2236 | }\r | |
2237 | /**\r | |
2238 | Save the processed xml contents to file\r | |
2239 | \r | |
2240 | @param fpdFile The file to save xml contents\r | |
2241 | @throws IOException Exceptions during file operation\r | |
2242 | **/\r | |
2243 | public void saveAs(File fpdFile) throws IOException {\r | |
2244 | \r | |
2245 | XmlOptions options = new XmlOptions();\r | |
2246 | \r | |
2247 | options.setCharacterEncoding("UTF-8");\r | |
2248 | options.setSavePrettyPrint();\r | |
2249 | options.setSavePrettyPrintIndent(2);\r | |
2250 | try {\r | |
2251 | fpdd.save(fpdFile, options);\r | |
2252 | } catch (IOException e) {\r | |
2253 | e.printStackTrace();\r | |
2254 | }\r | |
2255 | \r | |
2256 | }\r | |
2257 | \r | |
1800d80f | 2258 | private String listToString(List l) {\r |
a13899c5 | 2259 | if (l == null) {\r |
2260 | return null;\r | |
2261 | }\r | |
2262 | String s = " ";\r | |
2263 | ListIterator li = l.listIterator();\r | |
2264 | while(li.hasNext()) {\r | |
2265 | s += li.next();\r | |
2266 | s += " ";\r | |
2267 | }\r | |
2268 | return s.trim();\r | |
2269 | }\r | |
2270 | }\r | |
82961247 | 2271 | \r |
2272 | class PcdItemTypeConflictException extends Exception {\r | |
2273 | \r | |
2274 | /**\r | |
2275 | * \r | |
2276 | */\r | |
2277 | private static final long serialVersionUID = 1L;\r | |
2278 | private String details = null;\r | |
2279 | \r | |
2280 | PcdItemTypeConflictException(String info){\r | |
2281 | details = info;\r | |
2282 | }\r | |
2283 | \r | |
2284 | public String getMessage() {\r | |
2285 | return details;\r | |
2286 | }\r | |
2287 | }\r | |
2288 | \r | |
2289 | class PcdDeclNotFound extends Exception {\r | |
2290 | \r | |
2291 | /**\r | |
2292 | * \r | |
2293 | */\r | |
2294 | private static final long serialVersionUID = 1L;\r | |
2295 | private String details = null;\r | |
2296 | \r | |
2297 | PcdDeclNotFound(String info) {\r | |
2298 | details = info;\r | |
2299 | }\r | |
2300 | \r | |
2301 | public String getMessage() {\r | |
2302 | return details;\r | |
2303 | }\r | |
2304 | }\r | |
2305 | \r | |
2306 | class PcdValueMalFormed extends Exception {\r | |
2307 | \r | |
2308 | /**\r | |
2309 | * \r | |
2310 | */\r | |
2311 | private static final long serialVersionUID = 1L;\r | |
2312 | private String details = null;\r | |
2313 | \r | |
2314 | PcdValueMalFormed(String info) {\r | |
2315 | details = info;\r | |
2316 | }\r | |
2317 | \r | |
2318 | public String getMessage() {\r | |
2319 | return details;\r | |
2320 | }\r | |
2321 | }\r |