+ 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
+ removeFvImageNameValue (fi, optName);\r
+ }\r
+ }\r
+ \r
+ /**Add name-value pair to FvImage element with type.\r
+ * @param fvName FV name to add name-value pair.\r
+ * @param type FvImage attribute.\r
+ * @param name\r
+ * @param value\r
+ */\r
+ public void setTypedNamedFvImageNameValue (String fvName, String type, String name, String value) {\r
+ boolean fvImageExists = false;\r
+ if (getfpdFlash().getFvImages() == null) {\r
+ return;\r
+ }\r
+ List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r
+ if (l == null) {\r
+ return;\r
+ }\r
+ ListIterator li = l.listIterator();\r
+ while(li.hasNext()) {\r
+ FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+ if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+ continue;\r
+ }\r
+ if (!fi.getFvImageNamesList().contains(fvName)) {\r
+ continue;\r
+ }\r
+ fvImageExists = true;\r
+ setFvImagesFvImageNameValue (fi, name, value, null);\r
+ }\r
+ \r
+ if (!fvImageExists) {\r
+ HashMap<String, String> map = new HashMap<String, String>();\r
+ map.put(name, value);\r
+ genFvImagesFvImage(new String[]{fvName}, type, map);\r
+ }\r
+ }\r
+ \r
+ /**Add to all FvImage elements with type, the name-value pair.\r
+ * @param type\r
+ * @param name\r
+ * @param value\r
+ */\r
+ public void setTypedFvImageNameValue (String type, String name, String value) {\r
+ if (getfpdFlash().getFvImages() == null) {\r
+ return;\r
+ }\r
+ List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r
+ if (l == null) {\r
+ return;\r
+ }\r
+ ListIterator li = l.listIterator();\r
+ while(li.hasNext()) {\r
+ FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+ if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+ continue;\r
+ }\r
+ setFvImagesFvImageNameValue (fi, name, value, null);\r
+ }\r
+ \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
+ * @param value\r
+ * @param newName\r
+ */\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
+ XmlCursor cursor = fi.getFvImageOptions().newCursor();\r
+ if (cursor.toFirstChild()) {\r
+ do {\r
+ FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue)cursor.getObject();\r
+ if (nv.getName().equals(name)) {\r
+ nv.setValue(value);\r
+ if (newName != null) {\r
+ nv.setName(newName);\r
+ }\r
+ cursor.dispose();\r
+ return;\r
+ }\r
+ }while (cursor.toNextSibling());\r
+ }\r
+ \r
+ FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.getFvImageOptions().addNewNameValue();\r
+ nv.setName(name);\r
+ nv.setValue(value);\r
+ if (newName != null) {\r
+ nv.setName(newName);\r
+ }\r
+ cursor.dispose();\r
+ }\r
+ \r
+ public void getFvImagesFvImageOptions (String fvName, Map<String, String> m) {\r
+ Vector<FvImagesDocument.FvImages.FvImage> vFvImage = getFvImagesFvImageWithName (fvName, "Options");\r
+ for (int i = 0; i < vFvImage.size(); ++i) {\r
+ FvImagesDocument.FvImages.FvImage fi = vFvImage.get(i);\r
+ if (fi == null || fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) {\r
+ continue;\r
+ }\r
+\r
+ ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions()\r
+ .getNameValueList()\r
+ .listIterator();\r
+ while (li.hasNext()) {\r
+ FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r
+ m.put(nv.getName(), nv.getValue());\r
+ }\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