1 7 8 package org.jdesktop.jdnc.markup.elem; 9 10 import org.jdesktop.swing.data.ConversionException; 11 import org.jdesktop.swing.data.Converter; 12 import org.jdesktop.swing.data.MetaData; 13 14 import org.jdesktop.jdnc.markup.ElementTypes; 15 import org.jdesktop.jdnc.markup.Attributes; 16 import org.jdesktop.jdnc.markup.Namespace; 17 18 import org.jdesktop.jdnc.markup.attr.NullAttribute; 19 20 import java.util.ArrayList ; 21 import java.util.Hashtable ; 22 import java.util.List ; 23 import java.util.Map ; 24 25 import net.openmarkup.ElementAssimilator; 26 import net.openmarkup.ElementHandler; 27 import net.openmarkup.ElementType; 28 import net.openmarkup.Realizable; 29 30 import org.w3c.dom.Element ; 31 import org.w3c.dom.Node ; 32 import org.w3c.dom.NodeList ; 33 34 37 public class DataFieldEnumerationValueElement extends ElementProxy { 38 39 private static final Map attrMap = new Hashtable (); 40 41 public DataFieldEnumerationValueElement(Element element, ElementType elementType) { 42 super(element, elementType); 43 } 44 45 public Object instantiate() { 46 47 Realizable metaDataElement = ElementProxy.getRealizable( 48 (Element )(getParentNode().getParentNode())); 49 MetaData metaData = (MetaData)metaDataElement.getObject(); 50 String elementValue = getAttributeNSOptional(Namespace.JDNC, 51 Attributes.VALUE); 52 62 63 Object value = null; 64 Converter converter = metaData.getConverter(); 65 try { 66 value = converter.decode(elementValue, 67 metaData.getDecodeFormat()); 68 } catch (ConversionException e) { 69 System.out.println(e); 70 } 71 return value; 72 } 73 74 protected Map registerAttributeHandlers() { 75 Map handlerMap = super.registerAttributeHandlers(); 76 if (handlerMap != null) { 77 handlerMap.put(Namespace.JDNC + ":" + Attributes.VALUE, 79 NullAttribute.valueHandler); 80 } 81 return handlerMap; 82 } 83 84 protected Map getAttributeHandlerMap() { 85 return attrMap; 86 } 87 88 } 89 | Popular Tags |