1 23 24 29 30 package com.sun.enterprise.deployment.node; 31 32 import java.util.Map ; 33 import java.util.Iterator ; 34 import java.util.Locale ; 35 import org.xml.sax.Attributes ; 36 import org.w3c.dom.Node ; 37 import org.w3c.dom.Element ; 38 39 import com.sun.enterprise.deployment.xml.TagNames; 40 import com.sun.enterprise.deployment.Descriptor; 41 42 46 public class IconNode extends LocalizedNode { 47 48 private String smallIcon = null; 49 private String largeIcon = null; 50 51 54 public Object getDescriptor() { 55 return null; 56 } 57 58 64 public void setElementValue(XMLElement element, String value) { 65 if (element.getQName().equals(TagNames.SMALL_ICON)) { 66 smallIcon = value; 67 } else 68 if (element.getQName().equals(TagNames.LARGE_ICON)) { 69 largeIcon = value; 70 } 71 } 72 73 76 public void postParsing() { 77 Object o = getParentNode().getDescriptor(); 78 if (o!=null && o instanceof Descriptor) { 79 Descriptor descriptor = (Descriptor) o; 80 if (largeIcon!=null) { 81 descriptor.setLocalizedLargeIconUri(lang, largeIcon); 82 } 83 if (smallIcon!=null) { 84 descriptor.setLocalizedSmallIconUri(lang, smallIcon); 85 } 86 } 87 } 88 89 95 public void writeLocalizedInfo(Node parentNode, Descriptor descriptor) { 96 Map largeIcons = descriptor.getLocalizedLargeIconUris(); 97 Map smallIcons = descriptor.getLocalizedSmallIconUris(); 98 if (largeIcons==null && smallIcons==null) { 99 return; 100 } 101 if (smallIcons!=null) { 102 for (Iterator smallItr = smallIcons.keySet().iterator();smallItr.hasNext();) { 103 String lang = (String ) smallItr.next(); 104 String smallIconUri = (String ) smallIcons.get(lang); 105 String largeIconUri = null; 106 if (largeIcons!=null) { 107 largeIconUri = (String ) largeIcons.get(lang); 108 } 109 addIconInfo(parentNode, lang, smallIconUri, largeIconUri); 110 } 111 } 112 if (largeIcons!=null) { 113 for (Iterator largeItr = largeIcons.keySet().iterator();largeItr.hasNext();) { 114 String lang = (String ) largeItr.next(); 115 String largeIconUri = (String ) largeIcons.get(lang); 116 if (smallIcons!=null && smallIcons.get(lang)!=null) { 117 continue; 119 } 120 addIconInfo(parentNode, lang, null, largeIconUri); 121 } 122 } 123 124 } 125 126 129 private void addIconInfo(Node node, String lang, String smallIconUri, String largeIconUri) { 130 131 Element iconNode =appendChild(node, TagNames.ICON); 132 if (lang!=Locale.ENGLISH.getLanguage()) { 133 iconNode.setAttributeNS(TagNames.XML_NAMESPACE, TagNames.XML_NAMESPACE_PREFIX + TagNames.LANG, lang); 134 } 135 appendTextChild(iconNode, TagNames.SMALL_ICON, smallIconUri); 136 appendTextChild(iconNode, TagNames.LARGE_ICON, largeIconUri); 137 } 138 } 139 | Popular Tags |