]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
do not generate version attributes when saving module order information in FV if...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
index 08992048085fe0cddb7047b5108162228ba42519..6ca15710c291dc6b05879f6fad3fb533bf5c1f8c 100644 (file)
@@ -70,6 +70,7 @@ import org.tianocore.frameworkwizard.packaging.PackageIdentification;
 public class FpdFileContents {\r
 \r
     static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0";\r
+    static final String regExpNewLineAndSpaces = "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*";\r
     \r
     private PlatformSurfaceAreaDocument fpdd = null;\r
     \r
@@ -91,6 +92,11 @@ public class FpdFileContents {
     \r
     private HashMap<String, String> defaultPcdValue = new HashMap<String, String>();\r
     \r
+    private String itemType (String pcdInfo) {\r
+        \r
+        return pcdInfo.substring(pcdInfo.lastIndexOf(" ") + 1);\r
+    }\r
+    \r
     /**\r
      * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.\r
      */\r
@@ -184,7 +190,7 @@ public class FpdFileContents {
         return fpdFrameworkModules;\r
     }\r
     \r
-    public void getFrameworkModuleGuid (String fvName, Vector<String> vGuid) {\r
+    public void getFrameworkModuleSAByFvBinding (String fvName, Vector<String[]> vGuid) {\r
         if (getFrameworkModulesCount() == 0){\r
             return;\r
         }\r
@@ -202,8 +208,15 @@ public class FpdFileContents {
             \r
             String[] fvNames = fvBinding.split(" ");\r
             for (int i = 0; i < fvNames.length; ++i) {\r
+                //\r
+                // BugBug : underscore "_" should not be replaced!!! \r
+                // But Fv name FVMAIN from fdf file not consist with FV_MAIN in fpd file.\r
+                //\r
                 if (fvNames[i].equals(fvName) || fvNames[i].replaceAll("_", "").equals(fvName)) {\r
-                    vGuid.add(moduleSa.getModuleGuid());\r
+                    String[] sa = new String[] {moduleSa.getModuleGuid(), moduleSa.getModuleVersion(),\r
+                                                moduleSa.getPackageGuid(), moduleSa.getPackageVersion(), \r
+                                                listToString(moduleSa.getSupArchList())};\r
+                    vGuid.add(sa);\r
                     break;\r
                 }\r
             }\r
@@ -251,12 +264,22 @@ public class FpdFileContents {
     }\r
     \r
     public ModuleSADocument.ModuleSA getModuleSA(String key) {\r
-        String[] s = key.split(" ");\r
+        \r
         if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {\r
             removeElement(getfpdFrameworkModules());\r
             fpdFrameworkModules = null;\r
             return null;\r
         }\r
+        String[] s = key.split(" ");\r
+        String archsInKey = "";\r
+        if (s.length > 4) {\r
+            for (int i = 4; i < s.length; ++i) {\r
+                archsInKey += s[i];\r
+                archsInKey += " ";\r
+            }\r
+            archsInKey = archsInKey.trim();\r
+        }\r
+        \r
         ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r
         while(li.hasNext()) {\r
             ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r
@@ -271,13 +294,17 @@ public class FpdFileContents {
                         continue;\r
                     }\r
                 }\r
-                //ToDo add arch check for s[4]\r
+                //ToDo add arch check .\r
                 if (moduleSa.getSupArchList() != null) {\r
-                    if (!listToString(moduleSa.getSupArchList()).equals(s[4])) {\r
-                        continue;\r
+                    if (listToString(moduleSa.getSupArchList()).equals(archsInKey)) {\r
+                        return moduleSa;\r
+                    }\r
+                }\r
+                else {\r
+                    if (archsInKey.length() == 0) {\r
+                        return moduleSa;\r
                     }\r
                 }\r
-                return moduleSa;\r
             }\r
         }\r
         return null;\r
@@ -326,10 +353,21 @@ public class FpdFileContents {
             }\r
             \r
             cursor.push();\r
-            cursor.toPrevToken();\r
+            while (cursor.hasPrevToken()) {\r
+                cursor.toPrevToken();\r
+                if (!cursor.isText()) {\r
+                    break;\r
+                }\r
+                String s = cursor.getTextValue();\r
+                if (s.matches(regExpNewLineAndSpaces)) {\r
+                    continue;\r
+                }\r
+            }\r
+\r
             if (cursor.isComment()) {\r
                 cursor.removeXml();\r
             }\r
+            \r
             cursor.pop();\r
             cursor.removeXml();\r
             if (getFrameworkModulesCount() == 0) {\r
@@ -370,7 +408,6 @@ public class FpdFileContents {
             vMi.add(libMi);\r
         }\r
         \r
-        try {\r
     nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) {\r
 \r
                 for (int j = 0; j < vMi.size(); ++j) {\r
@@ -382,16 +419,10 @@ public class FpdFileContents {
                 removePcdData(seqModuleSa, saaModuleSaPcd[i][0], saaModuleSaPcd[i][1]);\r
                 dataModified = true;\r
             }\r
-        }\r
-        catch (Exception e) {\r
-            throw e;\r
-        }\r
         //\r
         // add new Pcd from MSA file to ModuleSA.\r
         //\r
-        try {\r
-       \r
-            for (int i = 0; i < vMi.size(); ++i) {\r
+           for (int i = 0; i < vMi.size(); ++i) {\r
                 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile\r
                                                                                                                           .getModuleXmlObject(vMi\r
                                                                                                                                                  .get(i));\r
@@ -431,10 +462,6 @@ public class FpdFileContents {
                  }\r
 \r
             }\r
-        }\r
-        catch (Exception e){\r
-           throw e;\r
-        }\r
         \r
         return dataModified;\r
     }\r
@@ -543,6 +570,9 @@ public class FpdFileContents {
             do {\r
                 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r
                 if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {\r
+                    //\r
+                    // change item type while not updating dynPcdData????\r
+                    //\r
                     pcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r
                     if(pcdData.getDatumType().equals("VOID*")) {\r
                         pcdData.setMaxDatumSize(new Integer(maxSize));\r
@@ -600,6 +630,7 @@ public class FpdFileContents {
                 //\r
                 sa[0] = spdPcd.getHelpText() + msaPcd.getHelpText();\r
                 sa[1] = msaPcd.getPcdItemType()+"";\r
+                sa[2] = msa.getModuleDefinitions().getBinaryModule()+"";\r
                 return true;\r
             }\r
             \r
@@ -613,12 +644,44 @@ public class FpdFileContents {
         return false;\r
     }\r
     \r
+    private boolean multiSourcePcd (String cName, String tsGuidCName, String moduleKey) {\r
+        int libCount = getLibraryInstancesCount(moduleKey);\r
+        String[][] saaLib = new String[libCount][5];\r
+        getLibraryInstances(moduleKey, saaLib);\r
+        ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r
+        Vector<ModuleIdentification> vMi = new Vector<ModuleIdentification>();\r
+        //\r
+        // create vector for module & library instance MIs.\r
+        //\r
+        vMi.add(mi);\r
+        for (int j = 0; j < saaLib.length; ++j) {\r
+            String libKey = saaLib[j][1] + " " + saaLib[j][2] + " " + saaLib[j][3] + " " + saaLib[j][4];\r
+            ModuleIdentification libMi = WorkspaceProfile.getModuleId(libKey);\r
+            vMi.add(libMi);\r
+        }\r
+        \r
+        int pcdSourceCount = 0;\r
+        for (int i = 0; i < vMi.size(); ++i) {\r
+            if (WorkspaceProfile.pcdInMsa(cName, tsGuidCName, vMi.get(i))) {\r
+                pcdSourceCount++;\r
+            }\r
+        }\r
+        \r
+        if (pcdSourceCount < 2) {\r
+            return false;\r
+        }\r
+        else {\r
+            return true;\r
+        }\r
+        \r
+    }\r
+    \r
     /**Remove PCDBuildDefinition entries from ModuleSA\r
      * @param moduleKey identifier of ModuleSA.\r
      * @param consumer where these entries come from.\r
      */\r
     public void removePcdData(String moduleKey, ModuleIdentification consumer) {\r
-        try {\r
+        \r
             ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(consumer);\r
             if (msa.getPcdCoded() == null) {\r
                 return;\r
@@ -632,12 +695,15 @@ public class FpdFileContents {
                 ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey);\r
                 if (moduleSA.getPcdBuildDefinition() != null) {\r
                     XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor();\r
+                    cursor.push();\r
                     if (cursor.toFirstChild()) {\r
                         do {\r
                             PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r
                                                                                                                                                           .getObject();\r
-                            if (msaPcd.getCName().equals(pcdData.getCName())\r
-                                && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r
+                            String cName = msaPcd.getCName();\r
+                            String tsGuidCName = msaPcd.getTokenSpaceGuidCName();\r
+                            if (cName.equals(pcdData.getCName())\r
+                                && tsGuidCName.equals(pcdData.getTokenSpaceGuidCName()) && !multiSourcePcd(cName, tsGuidCName, moduleKey)) {\r
 \r
                                 maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(),\r
                                                   moduleKey);\r
@@ -646,15 +712,15 @@ public class FpdFileContents {
                             }\r
                         } while (cursor.toNextSibling());\r
                     }\r
+                    \r
+                    cursor.pop();\r
+                    if (moduleSA.getPcdBuildDefinition().getPcdDataList().size() == 0) {\r
+                        cursor.removeXml();\r
+                    }\r
                     cursor.dispose();\r
                 }\r
             }\r
-            \r
-        }\r
-        catch (Exception e){\r
-            e.printStackTrace();\r
-            \r
-        }\r
+        \r
     }\r
     //\r
     // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"\r
@@ -695,7 +761,17 @@ public class FpdFileContents {
                 cursor.toNextSibling();\r
             }\r
             cursor.push();\r
-            cursor.toPrevToken();\r
+            while (cursor.hasPrevToken()) {\r
+                cursor.toPrevToken();\r
+                if (!cursor.isText()) {\r
+                    break;\r
+                }\r
+                String s = cursor.getTextValue();\r
+                if (s.matches(regExpNewLineAndSpaces)) {\r
+                    continue;\r
+                }\r
+            }\r
+            \r
             if (cursor.isComment()) {\r
                 cursor.removeXml();\r
             }\r
@@ -895,14 +971,9 @@ public class FpdFileContents {
         setFvBinding (moduleSa, newFvNameList.trim());\r
     }\r
     \r
-    public void updateFvBindingInModuleSA (ModuleIdentification mi, String fvName) {\r
-        Vector<Object> vSupArchs = new Vector<Object>();\r
-        getPlatformDefsSupportedArchs(vSupArchs);\r
-        String moduleInfo = mi.getGuid() + " " + mi.getVersion() + " " + mi.getPackageId().getGuid() + " " + mi.getPackageId().getVersion();\r
-        for (int i = 0; i < vSupArchs.size(); ++i) {\r
-            String moduleKey = moduleInfo + " " + vSupArchs.get(i);\r
-            appendFvBinding (moduleKey, fvName);\r
-        }\r
+    public void updateFvBindingInModuleSA (String moduleKey, String fvName) {\r
+       \r
+        appendFvBinding (moduleKey, fvName);\r
     }\r
     \r
     public String getFfsFileNameGuid(String moduleKey){\r
@@ -1176,15 +1247,24 @@ public class FpdFileContents {
             pcdConsumer = new ArrayList<String>();\r
         }\r
         //\r
+        // Check whether this PCD has already added to ModuleSA, if so, just return.\r
+        //\r
+        String moduleInfo = moduleSa.getModuleGuid().toLowerCase() + " " + moduleSa.getModuleVersion() \r
+        + " " + moduleSa.getPackageGuid().toLowerCase() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList());\r
+        for (int i = 0; i < pcdConsumer.size(); ++i) {\r
+            String pcdInfo = pcdConsumer.get(i);\r
+            if (moduleInfo.equals(pcdInfo.substring(0, pcdInfo.lastIndexOf(" ")))){\r
+                return;\r
+            }\r
+        }\r
+        //\r
         // Using existing Pcd type, if this pcd already exists in other ModuleSA\r
         //\r
         if (pcdConsumer.size() > 0) {\r
-            String[] valPart = pcdConsumer.get(0).split(" ");\r
-            itemType = valPart[5];\r
+            \r
+            itemType = itemType (pcdConsumer.get(0));\r
         }\r
-        String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r
-        + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())\r
-        + " " + itemType;\r
+        String listValue = moduleInfo + " " + itemType;\r
         pcdConsumer.add(listValue);\r
         dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);\r
         \r
@@ -1681,7 +1761,15 @@ public class FpdFileContents {
         for (int i = 0; i < includeModules.size(); ++i) {\r
             cursor.beginElement(elementModule);\r
             cursor.insertAttributeWithValue("ModuleGuid", includeModules.get(i)[0]);\r
-            cursor.insertAttributeWithValue("BaseName", includeModules.get(i)[1]);\r
+            if (!includeModules.get(i)[1].equals("null") && includeModules.get(i)[1].length() != 0) {\r
+                cursor.insertAttributeWithValue("ModuleVersion", includeModules.get(i)[1]);\r
+            }\r
+            cursor.insertAttributeWithValue("PackageGuid", includeModules.get(i)[2]);\r
+            if (!includeModules.get(i)[3].equals("null") && includeModules.get(i)[3].length() != 0) {\r
+                cursor.insertAttributeWithValue("PackageVersion", includeModules.get(i)[3]);\r
+            }\r
+            \r
+            cursor.insertAttributeWithValue("Arch", includeModules.get(i)[4]);\r
             cursor.toEndToken();\r
             cursor.toNextToken();\r
         }\r
@@ -1729,7 +1817,10 @@ public class FpdFileContents {
         QName elementFvName = new QName (xmlNs, "FvName");\r
         QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r
         QName attribModuleGuid = new QName("ModuleGuid");\r
-        QName attribBaseName = new QName("BaseName");\r
+        QName attribModuleVersion = new QName("ModuleVersion");\r
+        QName attribPackageGuid = new QName("PackageGuid");\r
+        QName attribPackageVersion = new QName("PackageVersion");\r
+        QName attribArch = new QName("Arch");\r
         \r
         if (cursor.toChild(elementUserExts)) {\r
             do {\r
@@ -1743,7 +1834,10 @@ public class FpdFileContents {
                             int i = 0;\r
                             do {\r
                                 saa[i][0] = cursor.getAttributeText(attribModuleGuid);\r
-                                saa[i][1] = cursor.getAttributeText(attribBaseName);\r
+                                saa[i][1] = cursor.getAttributeText(attribModuleVersion);\r
+                                saa[i][2] = cursor.getAttributeText(attribPackageGuid);\r
+                                saa[i][3] = cursor.getAttributeText(attribPackageVersion);\r
+                                saa[i][4] = cursor.getAttributeText(attribArch);\r
                                 ++i;\r
                             }while (cursor.toNextSibling());\r
                         }\r
@@ -2608,7 +2702,7 @@ public class FpdFileContents {
         }\r
     }\r
     \r
-    public void AddFvImageFvImageNames (String[] fvNames) {\r
+    public void addFvImageFvImageNames (String[] fvNames) {\r
         FvImagesDocument.FvImages fis = getfpdFlash().getFvImages();\r
         if (fis == null || fis.getFvImageList() == null) {\r
             genFvImagesFvImage (fvNames, "ImageName", null);\r
@@ -2619,14 +2713,35 @@ public class FpdFileContents {
         while (li.hasNext()) {\r
             FvImagesDocument.FvImages.FvImage fi = li.next();\r
             if (fi.getType().toString().equals("ImageName")) {\r
-                for (int i = 0; i < fvNames.length; ++i) {\r
-                    fi.addFvImageNames(fvNames[i]);\r
-                }\r
+                addFvImageNamesInFvImage (fi, fvNames);\r
                 return;\r
             }\r
         }\r
-        genFvImagesFvImage (fvNames, "ImageName", null);\r
+        genFvImagesFvImage (fvNames, "ImageName", null);    \r
+    }\r
+    \r
+    public void addFvImageNamesInFvImage (FvImagesDocument.FvImages.FvImage fi, String[] fvNames) {\r
         \r
+        for (int i = 0; i < fvNames.length; ++i) {\r
+            fi.addFvImageNames(fvNames[i]);\r
+        }\r
+    }\r
+    \r
+    public void addFvImageNamesInFvImage (int i, String[] fvNames) {\r
+        XmlObject o = getfpdFlash().getFvImages();\r
+        if (o == null) {\r
+            return;\r
+        }\r
+        XmlCursor cursor = o.newCursor();\r
+        QName qFvImage = new QName(xmlNs, "FvImage");\r
+        if (cursor.toChild(qFvImage)) {\r
+            for (int j = 0; j < i; ++j) {\r
+                cursor.toNextSibling(qFvImage);\r
+            }\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
+            addFvImageNamesInFvImage(fi, fvNames);\r
+        }\r
+        cursor.dispose();\r
     }\r
     \r
     public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {\r
@@ -2706,6 +2821,22 @@ public class FpdFileContents {
         }\r
     }\r
     \r
+    public void updateFvImageNamesInFvImage (int i, String oldFvName, String newFvName) {\r
+        XmlObject o = getfpdFlash().getFvImages();\r
+        if (o == null) {\r
+            return;\r
+        }\r
+        XmlCursor cursor = o.newCursor();\r
+        QName qFvImage = new QName(xmlNs, "FvImage");\r
+        if (cursor.toChild(qFvImage)) {\r
+            for (int j = 0; j < i; ++j) {\r
+                cursor.toNextSibling(qFvImage);\r
+            }\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
+            updateFvImageNamesInFvImage (fi, oldFvName, newFvName);\r
+        }\r
+        cursor.dispose();\r
+    }\r
     /**\r
      * @param fi\r
      * @param oldFvName The FV Name to be replaced.\r
@@ -2723,7 +2854,7 @@ public class FpdFileContents {
                         cursor.setTextValue(newFvName);\r
                     }\r
                     else {\r
-                            cursor.removeXml();\r
+                        cursor.removeXml();\r
                     }\r
                 }\r
             }while (cursor.toNextSibling(qFvImageNames));\r
@@ -2732,6 +2863,27 @@ public class FpdFileContents {
         cursor.dispose();\r
     }\r
     \r
+    /**update the Type attribute of ith FvImage with new type.\r
+     * @param i\r
+     * @param type\r
+     */\r
+    public void updateFvImagesFvImageType (int i, String type) {\r
+        XmlObject o = getfpdFlash().getFvImages();\r
+        if (o == null) {\r
+            return;\r
+        }\r
+        XmlCursor cursor = o.newCursor();\r
+        QName qFvImage = new QName(xmlNs, "FvImage");\r
+        if (cursor.toChild(qFvImage)) {\r
+            for (int j = 0; j < i; ++j) {\r
+                cursor.toNextSibling(qFvImage);\r
+            }\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
+            fi.setType(FvImageTypes.Enum.forString(type));\r
+        }\r
+        cursor.dispose();\r
+    }\r
+    \r
     public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){\r
            \r
         XmlObject o = getfpdFlash().getFvImages();\r
@@ -2849,19 +3001,43 @@ public class FpdFileContents {
         }\r
     }\r
     \r
+    public void removeFvImageNameValue (int i, String attributeName) {\r
+        XmlObject o = getfpdFlash().getFvImages();\r
+        if (o == null) {\r
+            return;\r
+        }\r
+        XmlCursor cursor = o.newCursor();\r
+        QName qFvImage = new QName(xmlNs, "FvImage");\r
+        if (cursor.toChild(qFvImage)) {\r
+            for (int j = 0; j < i; ++j) {\r
+                cursor.toNextSibling(qFvImage);\r
+            }\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
+            removeFvImageNameValue (fi, attributeName);\r
+        }\r
+        cursor.dispose();\r
+    }\r
+    /**Remove from fi the attribute pair with attributeName in FvImageOptions.\r
+     * @param fi\r
+     * @param attributeName\r
+     */\r
+    public void removeFvImageNameValue (FvImagesDocument.FvImages.FvImage fi, String attributeName) {\r
+        if (fi.getFvImageOptions() != null && fi.getFvImageOptions().getNameValueList() != null) {\r
+            ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();\r
+            while (li.hasNext()) {\r
+                FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r
+                if (nv.getName().equals(attributeName)) {\r
+                    li.remove();\r
+                }\r
+            }\r
+        }\r
+    }\r
+    \r
     public void removeTypedNamedFvImageNameValue (String fvName, String type, String optName) {\r
         Vector<FvImagesDocument.FvImages.FvImage> vFvImage = getFvImagesFvImageWithName(fvName, type);\r
         for (int i = 0; i < vFvImage.size(); ++i) {\r
             FvImagesDocument.FvImages.FvImage fi = vFvImage.get(i);\r
-            if (fi.getFvImageOptions() != null && fi.getFvImageOptions().getNameValueList() != null) {\r
-                ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();\r
-                while (li.hasNext()) {\r
-                    FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r
-                    if (nv.getName().equals(optName)) {\r
-                        li.remove();\r
-                    }\r
-                }\r
-            }\r
+            removeFvImageNameValue (fi, optName);\r
         }\r
     }\r
     \r
@@ -2924,6 +3100,23 @@ public class FpdFileContents {
         \r
     }\r
     \r
+    public void setFvImagesFvImageNameValue (int i, String name, String value) {\r
+        XmlObject o = getfpdFlash().getFvImages();\r
+        if (o == null) {\r
+            return;\r
+        }\r
+        XmlCursor cursor = o.newCursor();\r
+        QName qFvImage = new QName(xmlNs, "FvImage");\r
+        if (cursor.toChild(qFvImage)) {\r
+            for (int j = 0; j < i; ++j) {\r
+                cursor.toNextSibling(qFvImage);\r
+            }\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
+            setFvImagesFvImageNameValue (fi, name, value, null);\r
+        }\r
+        cursor.dispose();\r
+    }\r
+    \r
     /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.\r
      * @param fi\r
      * @param name\r
@@ -2932,6 +3125,12 @@ public class FpdFileContents {
      */\r
     public void setFvImagesFvImageNameValue (FvImagesDocument.FvImages.FvImage fi, String name, String value, String newName) {\r
         if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) {\r
+            FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.addNewFvImageOptions().addNewNameValue();\r
+            nv.setName(name);\r
+            nv.setValue(value);\r
+            if (newName != null) {\r
+                nv.setName(newName);\r
+            }\r
             return;\r
         }\r
         \r
@@ -2976,6 +3175,50 @@ public class FpdFileContents {
             }\r
         }\r
     }\r
+    \r
+    public int getFvImagePosInFvImages (String fvNameList, String type) {\r
+        XmlObject o = getfpdFlash().getFvImages();\r
+        if (o == null) {\r
+            return -1;\r
+        }\r
+        \r
+        int pos = -1;\r
+        String[] fvNameArray = fvNameList.trim().split(" ");\r
+        Vector<String> vFvNames = new Vector<String>();\r
+        \r
+        \r
+        XmlCursor cursor = o.newCursor();\r
+        QName qFvImage = new QName(xmlNs, "FvImage");\r
+        if (cursor.toChild(qFvImage)) {\r
+            do {\r
+                pos++;\r
+                vFvNames.removeAllElements();\r
+                for (int i = 0; i < fvNameArray.length; ++i) {\r
+                    vFvNames.add(fvNameArray[i]);\r
+                }\r
+                FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
+                if (!fi.getType().toString().equals(type)) {\r
+                    continue;\r
+                }\r
+                if (fi.getFvImageNamesList() == null || fi.getFvImageNamesList().size() != vFvNames.size()) {\r
+                    continue;\r
+                }\r
+                ListIterator<String> li = fi.getFvImageNamesList().listIterator();\r
+                while (li.hasNext()) {\r
+                    String name = li.next();\r
+                    vFvNames.remove(name);\r
+                }\r
+                if (vFvNames.size() == 0) {\r
+                    cursor.dispose();\r
+                    return pos;\r
+                }\r
+                \r
+            }while (cursor.toNextSibling(qFvImage));\r
+           \r
+        }\r
+        cursor.dispose();\r
+        return -1;\r
+    }\r
     /**Get FvImage Options for FvImage i\r
      * @param i the ith FvImage\r
      */\r
@@ -2992,6 +3235,7 @@ public class FpdFileContents {
             }\r
             FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
             if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null){\r
+                cursor.dispose();\r
                 return;\r
             }\r
             ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();\r
@@ -3000,6 +3244,7 @@ public class FpdFileContents {
                 m.put(nv.getName(), nv.getValue());\r
             }\r
         }\r
+        cursor.dispose();\r
     }\r
     \r
     /**\r