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.w3c.dom.Element ; 36 import org.xml.sax.Attributes ; 37 import org.w3c.dom.Node ; 38 39 import com.sun.enterprise.deployment.xml.TagNames; 40 41 47 public class LocalizedNode extends DeploymentDescriptorNode { 48 49 protected String lang = null; 50 protected String localizedValue = null; 51 52 55 public Object getDescriptor() { 56 return getParentNode().getDescriptor(); 57 } 58 59 62 public void startElement(XMLElement element, Attributes attributes) { 63 if (attributes.getLength()>0) { 64 for (int i=0;i<attributes.getLength();i++) { 65 if (attributes.getLocalName(i).equals(TagNames.LANG)) { 66 lang = attributes.getValue(i); 67 } 68 } 69 } 70 } 71 72 78 public void setElementValue(XMLElement element, String value) { 79 if (element.equals(getXMLRootTag())) { 80 localizedValue=value; 81 } else 82 super.setElementValue(element, value); 83 } 84 85 89 public void writeLocalizedMap(Node parentNode, String tagName, Map localizedMap) { 90 if (localizedMap!=null) { 91 for (Iterator itr = localizedMap.keySet().iterator();itr.hasNext();) { 92 String lang = (String ) itr.next(); 93 Element aLocalizedNode = (Element ) appendTextChild(parentNode, tagName, (String ) localizedMap.get(lang)); 94 if (aLocalizedNode!=null && lang!=Locale.getDefault().getLanguage()) { 95 aLocalizedNode.setAttributeNS(TagNames.XML_NAMESPACE, TagNames.XML_NAMESPACE_PREFIX + TagNames.LANG, lang); 96 } 97 } 98 } 99 } 100 101 } 102 | Popular Tags |