1 23 24 package com.sun.enterprise.deployment.node.runtime.web; 25 26 import org.xml.sax.Attributes ; 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.Element ; 29 30 import com.sun.enterprise.deployment.node.XMLElement; 31 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 32 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor; 33 import com.sun.enterprise.deployment.runtime.web.LocaleCharsetInfo; 34 35 40 public class LocaleCharsetInfoNode extends WebRuntimeNode { 41 42 45 public LocaleCharsetInfoNode() { 46 47 registerElementHandler(new XMLElement(RuntimeTagNames.LOCALE_CHARSET_MAP), 48 LocaleCharsetMapNode.class, "addLocaleCharsetMap"); 49 } 50 51 public void startElement(XMLElement element, Attributes attributes) { 52 if (element.getQName().equals(RuntimeTagNames.LOCALE_CHARSET_INFO)) { 53 LocaleCharsetInfo info = (LocaleCharsetInfo) getDescriptor(); 54 for (int i=0; i<attributes.getLength();i++) { 55 if (RuntimeTagNames.DEFAULT_LOCALE.equals( 56 attributes.getQName(i))) { 57 info.setAttributeValue(LocaleCharsetInfo.DEFAULT_LOCALE, 58 attributes.getValue(i)); 59 } 60 } 61 } else if (element.getQName().equals( 62 RuntimeTagNames.PARAMETER_ENCODING)) { 63 LocaleCharsetInfo info = (LocaleCharsetInfo) getDescriptor(); 64 info.setParameterEncoding(true); 65 for (int i=0; i<attributes.getLength();i++) { 66 if (RuntimeTagNames.DEFAULT_CHARSET.equals( 67 attributes.getQName(i))) { 68 info.setAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, 69 LocaleCharsetInfo.DEFAULT_CHARSET, 70 attributes.getValue(i)); 71 } 72 if (RuntimeTagNames.FORM_HINT_FIELD.equals( 73 attributes.getQName(i))) { 74 info.setAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, 75 LocaleCharsetInfo.FORM_HINT_FIELD, 76 attributes.getValue(i)); 77 } 78 } 79 } else super.startElement(element, attributes); 80 } 81 82 90 public Node writeDescriptor(Node parent, String nodeName, LocaleCharsetInfo descriptor) { 91 92 Element locale = (Element ) super.writeDescriptor(parent, nodeName, descriptor); 93 94 if (descriptor.sizeLocaleCharsetMap()>0) { 96 LocaleCharsetMapNode lcmn = new LocaleCharsetMapNode(); 97 for (int i=0;i<descriptor.sizeLocaleCharsetMap();i++) { 98 lcmn.writeDescriptor(locale, RuntimeTagNames.LOCALE_CHARSET_MAP, descriptor.getLocaleCharsetMap(i)); 99 } 100 } 101 102 if (descriptor.isParameterEncoding()) { 106 Element parameter = (Element ) appendChild(locale, RuntimeTagNames.PARAMETER_ENCODING); 107 108 if (descriptor.getAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, LocaleCharsetInfo.FORM_HINT_FIELD)!=null) { 109 setAttribute(parameter, RuntimeTagNames.FORM_HINT_FIELD, 110 (String ) descriptor.getAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, LocaleCharsetInfo.FORM_HINT_FIELD)); 111 } 112 113 114 if (descriptor.getAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, LocaleCharsetInfo.DEFAULT_CHARSET)!=null) { 115 setAttribute(parameter, RuntimeTagNames.DEFAULT_CHARSET, 116 (String ) descriptor.getAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, LocaleCharsetInfo.DEFAULT_CHARSET)); 117 } 118 } 119 120 if (descriptor.getAttributeValue(LocaleCharsetInfo.DEFAULT_LOCALE) != null) { 122 setAttribute(locale, RuntimeTagNames.DEFAULT_LOCALE, 123 (String ) descriptor.getAttributeValue(LocaleCharsetInfo.DEFAULT_LOCALE)); 124 } 125 return locale; 126 } 127 128 } 129 | Popular Tags |