KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdnc > markup > elem > FormDataElement


1 /*
2  * $Id: FormDataElement.java,v 1.1.1.1 2004/06/16 01:43:40 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

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 JavaDoc;
16
17 import java.util.Hashtable JavaDoc;
18 import java.util.List JavaDoc;
19 import java.util.Map JavaDoc;
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 JavaDoc;
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 /**
36  *
37  * @author Amy Fowler
38  */

39 public class FormDataElement extends ElementProxy {
40     private static final Map JavaDoc attrMap = new Hashtable JavaDoc();
41     private static final Map JavaDoc elementMap = new Hashtable JavaDoc();
42     private static final Map JavaDoc mediaTypeRepresentation = new Hashtable JavaDoc();
43
44     public FormDataElement(Element JavaDoc element, ElementType elementType) {
45         super(element, elementType);
46     }
47
48 /*
49     protected void applyAttributesAfter() {
50         super.applyAttributesAfter();
51         //applyAttribute(Namespace.JDNC, Attributes.COLUMN_DELIMITER);
52     }
53 */

54
55     protected Map JavaDoc registerAttributeHandlers() {
56         Map JavaDoc handlerMap = super.registerAttributeHandlers();
57         if (handlerMap != null) {
58             //handlerMap.put(Namespace.JDNC + ":" + Attributes.COLUMN_DELIMITER, columnDelimiterHandler);
59
// Register null appliers. These attributes are handled elsewhere
60
handlerMap.put(Namespace.JDNC + ":" + Attributes.ID,
61                            NullAttribute.idHandler);
62
63         }
64         return handlerMap;
65     }
66
67     protected Map JavaDoc registerElementHandlers() {
68         Map JavaDoc 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 JavaDoc list = (List JavaDoc) 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 JavaDoc getAttributeHandlerMap() {
90         return attrMap;
91     }
92
93     protected Map JavaDoc getElementHandlerMap() {
94         return elementMap;
95     }
96
97     private static final ElementHandler metaDataElementHandler =
98         new ElementHandler(ElementTypes.META_DATA, metaDataAssimilator);
99
100 }
101
Popular Tags