FileDocCategorySizeDatePackage
LocaleCharsetInfoNode.javaAPI DocGlassfish v2 API6204Fri May 04 22:31:48 BST 2007com.sun.enterprise.deployment.node.runtime.web

LocaleCharsetInfoNode

public class LocaleCharsetInfoNode extends WebRuntimeNode
node for locale-charset-info tag
author
Jerome Dochez

Fields Summary
Constructors Summary
public LocaleCharsetInfoNode()
Initialize the child handlers

	
        registerElementHandler(new XMLElement(RuntimeTagNames.LOCALE_CHARSET_MAP), 
                               LocaleCharsetMapNode.class, "addLocaleCharsetMap");		       
    
Methods Summary
public voidstartElement(com.sun.enterprise.deployment.node.XMLElement element, org.xml.sax.Attributes attributes)

	if (element.getQName().equals(RuntimeTagNames.LOCALE_CHARSET_INFO)) {
            LocaleCharsetInfo info = (LocaleCharsetInfo) getDescriptor();
            for (int i=0; i<attributes.getLength();i++) {
                if (RuntimeTagNames.DEFAULT_LOCALE.equals( 
                    attributes.getQName(i))) {
                    info.setAttributeValue(LocaleCharsetInfo.DEFAULT_LOCALE, 
                        attributes.getValue(i));
                }
            }
        } else if (element.getQName().equals(
            RuntimeTagNames.PARAMETER_ENCODING)) {
	    LocaleCharsetInfo info = (LocaleCharsetInfo) getDescriptor();
            info.setParameterEncoding(true);
            for (int i=0; i<attributes.getLength();i++) {
                if (RuntimeTagNames.DEFAULT_CHARSET.equals(
                    attributes.getQName(i))) {
                    info.setAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING,
                        LocaleCharsetInfo.DEFAULT_CHARSET, 
                        attributes.getValue(i));
                }
                if (RuntimeTagNames.FORM_HINT_FIELD.equals(
                    attributes.getQName(i))) {
                    info.setAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, 
                        LocaleCharsetInfo.FORM_HINT_FIELD,
                        attributes.getValue(i));
                }
            }
	} else super.startElement(element, attributes);
    
public org.w3c.dom.NodewriteDescriptor(org.w3c.dom.Node parent, java.lang.String nodeName, com.sun.enterprise.deployment.runtime.web.LocaleCharsetInfo descriptor)
write the descriptor class to a DOM tree and return it

param
parent node for the DOM tree
param
node name for the descriptor
param
the descriptor to write
return
the DOM tree top node

	
	Element locale = (Element) super.writeDescriptor(parent, nodeName, descriptor);
	
	// locale-charset-map+
	if (descriptor.sizeLocaleCharsetMap()>0) {
	    LocaleCharsetMapNode lcmn = new LocaleCharsetMapNode();
	    for (int i=0;i<descriptor.sizeLocaleCharsetMap();i++) {
		lcmn.writeDescriptor(locale, RuntimeTagNames.LOCALE_CHARSET_MAP, descriptor.getLocaleCharsetMap(i));
	    }
	}
	
	// <!ELEMENT parameter-encoding EMPTY>
	//<!ATTLIST parameter-encoding form-hint-field CDATA #IMPLIED
	//		     default-charset CDATA #IMPLIED>
	if (descriptor.isParameterEncoding()) {
	    Element parameter = (Element) appendChild(locale, RuntimeTagNames.PARAMETER_ENCODING);
	    
	    if (descriptor.getAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, LocaleCharsetInfo.FORM_HINT_FIELD)!=null) {
	        setAttribute(parameter, RuntimeTagNames.FORM_HINT_FIELD, 
	    	(String) descriptor.getAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, LocaleCharsetInfo.FORM_HINT_FIELD));
	    }
	    
	    
	    if (descriptor.getAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, LocaleCharsetInfo.DEFAULT_CHARSET)!=null) {
	        setAttribute(parameter, RuntimeTagNames.DEFAULT_CHARSET, 
	    	(String) descriptor.getAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, LocaleCharsetInfo.DEFAULT_CHARSET));
	    }
	}	    
	
	// default_locale
        if (descriptor.getAttributeValue(LocaleCharsetInfo.DEFAULT_LOCALE) != null) {
	    setAttribute(locale, RuntimeTagNames.DEFAULT_LOCALE, 
	        (String) descriptor.getAttributeValue(LocaleCharsetInfo.DEFAULT_LOCALE));
        }	
	return locale;