KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
21
22 import javax.xml.parsers.ParserConfigurationException JavaDoc;
23
24 import org.apache.ws.jaxme.xs.XSParser;
25 import org.apache.ws.jaxme.xs.parser.DOMBuilder;
26 import org.apache.ws.jaxme.xs.parser.XsObjectCreator;
27 import org.apache.ws.jaxme.xs.xml.*;
28 import org.apache.ws.jaxme.xs.xml.XsAnyURI;
29 import org.apache.ws.jaxme.xs.xml.XsEAppinfo;
30 import org.xml.sax.ContentHandler JavaDoc;
31 import org.xml.sax.SAXException JavaDoc;
32
33
34 /** <p>Implementation of <code>xs:appinfo</code>, as specified by the
35  * following:
36  * <pre>
37  * &lt;xs:element name="appinfo" id="appinfo"&gt;
38  * &lt;xs:annotation&gt;
39  * &lt;xs:documentation source="http://www.w3.org/TR/xmlschema-1/#element-appinfo"/&gt;
40  * &lt;/xs:annotation&gt;
41  * &lt;xs:complexType mixed="true"&gt;
42  * &lt;xs:sequence minOccurs="0" maxOccurs="unbounded"&gt;
43  * &lt;xs:any processContents="lax"/&gt;
44  * &lt;/xs:sequence&gt;
45  * &lt;xs:attribute name="source" type="xs:anyURI"/&gt;
46  * &lt;/xs:complexType&gt;
47  * &lt;/xs:element&gt;
48  * </pre></p>
49  *
50  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
51  */

52 public class XsEAppinfoImpl extends XsObjectImpl implements XsEAppinfo {
53   private List JavaDoc childs;
54   private XsAnyURI source;
55
56   protected XsEAppinfoImpl(XsObject pParent) {
57     super(pParent);
58   }
59
60   protected void addChild(Object JavaDoc pChild) {
61     if (childs == null) {
62       childs = new ArrayList JavaDoc();
63     }
64     childs.add(pChild);
65   }
66
67   protected XsObjectCreator[] getXsObjectCreators() {
68     return null;
69   }
70
71   public Object JavaDoc[] getChilds() {
72     if (childs == null) {
73       return new Object JavaDoc[0];
74     } else {
75       return childs.toArray();
76     }
77   }
78
79   public void setSource(XsAnyURI pSource) {
80     source = pSource;
81   }
82
83   public XsAnyURI getSource() {
84     return source;
85   }
86
87   public ContentHandler JavaDoc getChildHandler(String JavaDoc pQName, String JavaDoc pNamespaceURI, String JavaDoc pLocalName) throws SAXException JavaDoc {
88     XsObjectCreator[] objectCreators = getXsObjectCreators();
89     if (objectCreators != null) {
90       XsQName qName = new XsQName(pNamespaceURI, pLocalName, XsQName.prefixOf(pQName));
91       for (int i = 0; i < objectCreators.length; i++) {
92         XsObject result = objectCreators[i].newBean(this, getObjectFactory().getLocator(), qName);
93         if (result != null) {
94           addChild(result);
95           return getObjectFactory().newXsSAXParser(result);
96         }
97       }
98     }
99
100     if (XSParser.XML_SCHEMA_URI.equals(pNamespaceURI)) {
101       return null; // Let the parser handle this element
102
}
103
104     try {
105       DOMBuilder db = new DOMBuilder();
106       addChild(db.getDocument());
107       return db;
108     } catch (ParserConfigurationException JavaDoc e) {
109       throw new SAXException JavaDoc(e);
110     }
111   }
112
113   /** <p>Adds text to the appinfo contents.</p>
114    */

115   public void addText(String JavaDoc pText) {
116       addChild(pText);
117   }
118 }
119
Popular Tags