KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > xml > impl > XsEAnnotationImpl


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15
16  */

17 package org.apache.ws.jaxme.xs.xml.impl;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
22
23 import javax.xml.parsers.ParserConfigurationException JavaDoc;
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 JavaDoc;
29 import org.xml.sax.SAXException JavaDoc;
30
31
32 /** <p>Implementation of <code>xs:annotation</code>, as specified
33  * by the following:
34  * <pre>
35  * &lt;xs:element name="annotation" id="annotation"&gt;
36  * &lt;xs:annotation&gt;
37  * &lt;xs:documentation source="http://www.w3.org/TR/xmlschema-1/#element-annotation"/&gt;
38  * &lt;/xs:annotation&gt;
39  * &lt;xs:complexType&gt;
40  * &lt;xs:complexContent&gt;
41  * &lt;xs:extension base="xs:openAttrs"&gt;
42  * &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
43  * &lt;xs:element ref="xs:appinfo"/&gt;
44  * &lt;xs:element ref="xs:documentation"/&gt;
45  * &lt;/xs:choice&gt;
46  * &lt;xs:attribute name="id" type="xs:ID"/&gt;
47  * &lt;/xs:extension&gt;
48  * &lt;/xs:complexContent&gt;
49  * &lt;/xs:complexType&gt;
50  * &lt;/xs:element&gt;
51  * </pre></p>
52  *
53  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
54  */

55 public class XsEAnnotationImpl extends XsTOpenAttrsImpl implements XsEAnnotation {
56   private XsID id;
57   private List JavaDoc 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 JavaDoc pChild) {
72     if (childs == null) {
73       childs = new ArrayList JavaDoc();
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 JavaDoc result = new ArrayList JavaDoc();
95       for (Iterator JavaDoc iter = childs.iterator(); iter.hasNext(); ) {
96         Object JavaDoc 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 JavaDoc result = new ArrayList JavaDoc();
110       for (Iterator JavaDoc iter = childs.iterator(); iter.hasNext(); ) {
111         Object JavaDoc 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 JavaDoc[] getChilds() {
121     if (childs == null) {
122       return new Object JavaDoc[0];
123     } else {
124       return childs.toArray();
125     }
126   }
127
128   public ContentHandler JavaDoc getChildHandler(String JavaDoc pQName,
129                                          String JavaDoc pNamespaceURI, String JavaDoc pLocalName) throws SAXException JavaDoc {
130     if (XSParser.XML_SCHEMA_URI.equals(pNamespaceURI)) {
131       return null; // Let the parser handle this element
132
}
133
134     try {
135       DOMBuilder db = new DOMBuilder();
136       addChild(db.getDocument());
137       return db;
138     } catch (ParserConfigurationException JavaDoc e) {
139       throw new SAXException JavaDoc(e);
140     }
141   }
142 }
143
Popular Tags