1 57 58 package org.apache.wsif.schema; 59 60 import java.io.Serializable ; 61 import java.util.ArrayList ; 62 import java.util.List ; 63 import javax.xml.namespace.QName ; 64 65 import org.w3c.dom.Element ; 66 import org.w3c.dom.Node ; 67 import org.w3c.dom.NodeList ; 68 69 74 public class ElementType extends SchemaType implements Serializable { 75 76 static final long serialVersionUID = 1L; 77 78 private String name = ""; 79 private QName typeName = null; 80 private QName elementType = null; 81 private List childTypes = new ArrayList (); 82 private boolean nillable = false; 83 84 88 ElementType(Element el, String tns) { 89 elementType = getAttributeQName(el, "type", tns); 90 typeName = getAttributeQName(el, "name", tns); 91 92 QName nillableAttr = getAttributeQName(el, "nillable", null); 93 String stTrue = "true"; 94 if (nillableAttr != null && stTrue.equals(nillableAttr.getLocalPart())) { 95 nillable = true; 96 } 97 98 if (typeName == null) return; 101 102 name = typeName.getLocalPart(); 103 NodeList children = el.getChildNodes(); 104 for (int i=0; i<children.getLength(); i++) { 105 Node child = children.item(i); 106 if (child.getNodeType() == Node.ELEMENT_NODE) { 107 Element subEl = (Element ) child; 108 String elType = subEl.getLocalName(); 109 if (elType.equals("complexType")) { 110 childTypes.add(new ComplexType(subEl, tns)); 111 } else if (elType.equals("simpleType")) { 112 childTypes.add(new SimpleType(subEl, tns)); 113 } else if (elType.equals("element")) { 114 childTypes.add(new ElementType(subEl, tns)); 115 } else { 116 } 118 } 119 } 120 } 121 122 125 public boolean isElement() { 126 return true; 127 } 128 129 132 public QName getTypeName() { 133 return typeName; 134 } 135 136 139 public QName getElementType() { 140 return elementType; 141 } 142 143 public boolean isNillable() { 144 return nillable; 145 } 146 147 150 public List getChildren() { 151 return childTypes; 152 } 153 } 154 | Popular Tags |