1 package xdoclet.sdk.xgg.binding;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.Iterator;
6 import java.util.List;
7
8 /***
9 * Represents a XML element.
10 * Holds references to its children and its referers.
11 *
12 *
13 * @author <a href="mailto:aslak.hellesoy at bekk.no">Aslak Hellesøy</a>
14 * @author <a href="mailto:letiemble at users.sourceforge.net">Laurent Etiemble</a>
15 * @created 6 mai 2003
16 * @version $Revision: 1.4 $
17 */
18 public class Element extends Binding {
19 private boolean _hasPcData = false;
20 private final List _children = new ArrayList();
21 private final List _referers = new ArrayList();
22
23
24 /***
25 *Constructor for the Element object
26 *
27 * @param xmlName Description of the Parameter
28 * @param version Description of the Parameter
29 */
30 public Element(String xmlName, String version) {
31 super(xmlName, version);
32 }
33
34
35 /***
36 * Adds a feature to the Child attribute of the Element object
37 *
38 * @param child The feature to be added to the Child attribute
39 */
40 public void addChild(Child child) {
41 _children.add(child);
42 }
43
44
45 /***
46 * Adds a feature to the Referer attribute of the Element object
47 *
48 * @param subElement The feature to be added to the Referer attribute
49 */
50 public void addReferer(SubElement subElement) {
51 _referers.add(subElement);
52 }
53
54
55 /***
56 * Gets the children attribute of the Element object
57 *
58 * @return The children value
59 */
60 public Collection getChildren() {
61 return _children;
62 }
63
64
65 /***
66 * Gets the javaType attribute of the Element object
67 *
68 * @return The javaType value
69 */
70 public String getJavaType() {
71 return getJavaName();
72 }
73
74
75 /***
76 * Gets the referers attribute of the Element object
77 *
78 * @return The referers value
79 */
80 public List getReferers() {
81 return _referers;
82 }
83
84
85 /***
86 * Gets the referer attribute of the Element object
87 *
88 * @param xmlName Description of the Parameter
89 * @return The referer value
90 */
91 public SubElement getSubElement(String xmlName) {
92 for (Iterator iterator = getChildren().iterator(); iterator.hasNext(); ) {
93 Child child = (Child) iterator.next();
94 if ((child instanceof SubElement) && (child.getXmlName().equals(xmlName))) {
95 return (SubElement) child;
96 }
97 }
98 return null;
99 }
100
101
102 /***
103 * Gets the pcData attribute of the Element object
104 *
105 * @return The pcData value
106 */
107 public boolean isPcData() {
108 return (getRegexp() != null);
109 }
110
111
112 /***
113 * Description of the Method
114 *
115 * @return Description of the Return Value
116 */
117 public String toString() {
118 StringBuffer sb = new StringBuffer("ELEMENT: ").append(getXmlName()).append("\n");
119 for (Iterator iterator = getChildren().iterator(); iterator.hasNext(); ) {
120 Child child = (Child) iterator.next();
121 sb.append(" ").append(child);
122 sb.append("\n");
123 }
124 return sb.toString();
125 }
126 }
This page was automatically generated by Maven