1 17 package org.apache.ws.jaxme.xs.xml.impl; 18 19 import java.util.ArrayList ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 23 import javax.xml.parsers.ParserConfigurationException ; 24 25 import org.apache.ws.jaxme.xs.XSParser; 26 import org.apache.ws.jaxme.xs.parser.DOMBuilder; 27 import org.apache.ws.jaxme.xs.xml.*; 28 import org.xml.sax.ContentHandler ; 29 import org.xml.sax.SAXException ; 30 31 32 55 public class XsEAnnotationImpl extends XsTOpenAttrsImpl implements XsEAnnotation { 56 private XsID id; 57 private List childs; 58 59 protected XsEAnnotationImpl(XsObject pParent) { 60 super(pParent); 61 } 62 63 public void setId(XsID pId) { 64 id = pId; 65 } 66 67 public XsID getId() { 68 return id; 69 } 70 71 protected void addChild(Object pChild) { 72 if (childs == null) { 73 childs = new ArrayList (); 74 } 75 childs.add(pChild); 76 } 77 78 public XsEAppinfo createAppinfo() { 79 XsEAppinfo appinfo = getObjectFactory().newXsEAppinfo(this); 80 addChild(appinfo); 81 return appinfo; 82 } 83 84 public XsEDocumentation createDocumentation() { 85 XsEDocumentation documentation = getObjectFactory().newXsEDocumentation(this); 86 addChild(documentation); 87 return documentation; 88 } 89 90 public XsEAppinfo[] getAppinfos() { 91 if (childs == null) { 92 return new XsEAppinfo[0]; 93 } else { 94 List result = new ArrayList (); 95 for (Iterator iter = childs.iterator(); iter.hasNext(); ) { 96 Object o = iter.next(); 97 if (o instanceof XsEAppinfo) { 98 result.add(o); 99 } 100 } 101 return (XsEAppinfo[]) result.toArray(new XsEAppinfo[result.size()]); 102 } 103 } 104 105 public XsEDocumentation[] getDocumentations() { 106 if (childs == null) { 107 return new XsEDocumentation[0]; 108 } else { 109 List result = new ArrayList (); 110 for (Iterator iter = childs.iterator(); iter.hasNext(); ) { 111 Object o = iter.next(); 112 if (o instanceof XsEDocumentation) { 113 result.add(o); 114 } 115 } 116 return (XsEDocumentation[]) result.toArray(new XsEDocumentation[result.size()]); 117 } 118 } 119 120 public Object [] getChilds() { 121 if (childs == null) { 122 return new Object [0]; 123 } else { 124 return childs.toArray(); 125 } 126 } 127 128 public ContentHandler getChildHandler(String pQName, 129 String pNamespaceURI, String pLocalName) throws SAXException { 130 if (XSParser.XML_SCHEMA_URI.equals(pNamespaceURI)) { 131 return null; } 133 134 try { 135 DOMBuilder db = new DOMBuilder(); 136 addChild(db.getDocument()); 137 return db; 138 } catch (ParserConfigurationException e) { 139 throw new SAXException (e); 140 } 141 } 142 } 143 | Popular Tags |