1 /*
2  *  CVS: $Id: DTDElement.java,v 1.6 2004/07/16 16:22:34 marcus Exp $
3  * 
4  *  This file is part of zuul.
5  *
6  *  zuul is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10 *
11 *  zuul is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with zuul; if not, write to the Free Software
18 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 * 
20 *  Copyrigth 2004 by marcus, leh
21 * 
22 */
23package org.jzuul.dtdparser;
24
25import java.util.ArrayList;
26import java.util.HashMap;
27import java.util.Iterator;
28import java.util.List;
29import java.util.Map;
30
31
32/**
33 * TODO Document new class
34 * 
35 * Created on Jun 7, 2004
36 * 
37 * 
38 * @version $Revision: 1.6 $
39 */
40public class DTDElement extends DTDEntry {
41    public static final int EMPTY = 10;
42    public static final int PCDATA = 20;
43    public static final int ELEMENT = 30;
44
45    protected Map children, attributes;
46    protected int type;
47
48    public DTDElement(String name) {
49        super(name);
50        children = new HashMap();
51        attributes = new HashMap();
52    }
53    
54    public List getChildElements() {
55        return new ArrayList(children.values()); 
56    }
57    
58    public DTDTreeElement getChildElement(String name) {
59        return (DTDTreeElement)children.get(name);
60    }
61    
62    public List getAttributes() {
63        return new ArrayList(attributes.values());
64    }
65    
66    public DTDAttribute getAttribute(String name) {
67        return null;
68    }
69        
70    public void addAttribute(DTDAttribute at) {
71        attributes.put(at.getName(), at);
72    }
73    
74    public void setType(int type) {
75        this.type = type;
76    }
77    
78    public void addChild(DTDElement child) {
79        this.children.put(child.getName(),child);
80    }
81
82    public void mergeSubElements(DTDElement originElement) {
83        List child = originElement.getChildElements();
84        for (Iterator iter = child.iterator(); iter.hasNext();) {
85            DTDElement element = (DTDElement) iter.next();
86                this.addChild(element);
87        }
88    }
89    
90}
91