001 /* 002 @license.text@ 003 */ 004 package biz.hammurapi.xml.dom; 005 006 import java.util.Iterator; 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.3 $ 016 */ 017 public class IteratorDomSerializer { 018 019 public DomSerializable convert(final Iterator it, final Converter master) { 020 return new DomSerializable() { 021 022 public void toDom(Element holder) { 023 holder.setAttribute("type", "iterator"); 024 while (it.hasNext()) { 025 DomSerializable ds=(DomSerializable) master.convert(it.next(), 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 }