001    /*
002     @license.text@
003      */
004    package biz.hammurapi.xml.dom;
005    
006    import java.util.Enumeration;
007    
008    import org.w3c.dom.Element;
009    
010    import biz.hammurapi.convert.Converter;
011    
012    /**
013     * @author Pavel Vlasov
014     *
015     * @version $Revision: 1.4 $
016     */
017    public class EnumerationDomSerializer {
018    
019            public DomSerializable convert(final Enumeration enumeration, final Converter master) {
020                    return new DomSerializable() {
021    
022                            public void toDom(Element holder) {
023                                holder.setAttribute("type", "enumeration");
024                                while (enumeration.hasMoreElements()) {
025                                    DomSerializable ds=(DomSerializable) master.convert(enumeration.nextElement(), DomSerializable.class, null);
026                                    if (ds!=null) {
027                                            Element el=holder.getOwnerDocument().createElement("element");
028                                            holder.appendChild(el);
029                                            ds.toDom(el);
030                                    }
031                                }
032                            }
033                            
034                    };
035            }
036    }