1 7 8 package org.jdesktop.jdnc.markup.elem; 9 10 import org.jdesktop.swing.data.DefaultDataModel; 11 import org.jdesktop.swing.data.MetaData; 12 13 import org.jdesktop.jdnc.JNForm; 14 15 import java.io.IOException ; 16 17 import java.util.Hashtable ; 18 import java.util.List ; 19 import java.util.Map ; 20 21 import net.openmarkup.AttributeHandler; 22 import net.openmarkup.ElementAssimilator; 23 import net.openmarkup.ElementHandler; 24 import net.openmarkup.ElementType; 25 import net.openmarkup.Realizable; 26 27 import org.w3c.dom.Element ; 28 29 import org.jdesktop.jdnc.markup.Attributes; 30 import org.jdesktop.jdnc.markup.ElementTypes; 31 import org.jdesktop.jdnc.markup.Namespace; 32 import org.jdesktop.jdnc.markup.attr.DataAttributes; 33 import org.jdesktop.jdnc.markup.attr.NullAttribute; 34 35 39 public class FormDataElement extends ElementProxy { 40 private static final Map attrMap = new Hashtable (); 41 private static final Map elementMap = new Hashtable (); 42 private static final Map mediaTypeRepresentation = new Hashtable (); 43 44 public FormDataElement(Element element, ElementType elementType) { 45 super(element, elementType); 46 } 47 48 54 55 protected Map registerAttributeHandlers() { 56 Map handlerMap = super.registerAttributeHandlers(); 57 if (handlerMap != null) { 58 handlerMap.put(Namespace.JDNC + ":" + Attributes.ID, 61 NullAttribute.idHandler); 62 63 } 64 return handlerMap; 65 } 66 67 protected Map registerElementHandlers() { 68 Map handlerMap = super.registerElementHandlers(); 69 if (handlerMap != null) { 70 handlerMap.put(Namespace.JDNC + ":" + 71 ElementTypes.META_DATA.getLocalName(), 72 metaDataElementHandler); 73 } 74 return handlerMap; 75 } 76 77 public static final ElementAssimilator metaDataAssimilator = new 78 ElementAssimilator() { 79 public void assimilate(Realizable parent, Realizable child) { 80 DefaultDataModel data = (DefaultDataModel)parent.getObject(); 81 List list = (List ) child.getObject(); 82 for (int i = 0; i < list.size(); i++) { 83 MetaData metaData = (MetaData) list.get(i); 84 data.addField(metaData); 85 } 86 } 87 }; 88 89 protected Map getAttributeHandlerMap() { 90 return attrMap; 91 } 92 93 protected Map getElementHandlerMap() { 94 return elementMap; 95 } 96 97 private static final ElementHandler metaDataElementHandler = 98 new ElementHandler(ElementTypes.META_DATA, metaDataAssimilator); 99 100 } 101 | Popular Tags |